113 lines
5.4 KiB
Bash
Executable File
113 lines
5.4 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# This is a helper to get tripleo-cd admins to prepare a ci-overcloud for CI repeatably.
|
|
set -ux
|
|
set -o pipefail
|
|
|
|
source $1
|
|
|
|
set -e
|
|
|
|
# These are only here for local install tests and should be noop if deploy-ci-overcloud was used to create overcloud
|
|
$TRIPLEO_ROOT/tripleo-incubator/scripts/assert-admin-users $TRIPLEO_ROOT/tripleo-incubator/tripleo-cloud/tripleo-cd-admins
|
|
$TRIPLEO_ROOT/tripleo-incubator/scripts/assert-users $TRIPLEO_ROOT/tripleo-incubator/tripleo-cloud/tripleo-cd-admins
|
|
$TRIPLEO_ROOT/tripleo-incubator/scripts/assert-users $TRIPLEO_ROOT/tripleo-incubator/tripleo-cloud/tripleo-cd-users
|
|
|
|
# Get the ID of the nodepool tenant
|
|
NODEPOOL_TENANT_ID=$(keystone tenant-list | awk '$4=="openstack-nodepool" {print $2}')
|
|
|
|
# Each instance uses 3 ports
|
|
neutron quota-update --tenant-id $NODEPOOL_TENANT_ID --port 300
|
|
nova quota-update --cores -1 --ram $TE_NP_RAM_QUOTA --instances 100 --floating-ips 100 --fixed-ips -1 $NODEPOOL_TENANT_ID
|
|
|
|
# Create the test network and subnet if they don't exist
|
|
if ! neutron net-show tripleo-bm-test ; then
|
|
neutron net-create tripleo-bm-test --tenant-id $NODEPOOL_TENANT_ID --provider:network_type flat --provider:physical_network $TE_PROVIDER_NET_NAME
|
|
fi
|
|
TESTNETID=$(neutron net-show tripleo-bm-test | awk '$2=="id" {print $4}')
|
|
if [ $(neutron net-show tripleo-bm-test | awk '$2=="subnets" {print $4}') == "|" ] ; then
|
|
neutron subnet-create --ip_version 4 --tenant-id $NODEPOOL_TENANT_ID --allocation-pool start=192.168.1.1,end=192.168.1.234 --no-gateway $TESTNETID 192.168.1.0/24 --dns-nameservers list=true 8.8.8.8
|
|
fi
|
|
|
|
# update subnet of default-net with some dns
|
|
DEFAULTSUBNETID=$(neutron net-show default-net | awk '$2=="subnets" {print $4}')
|
|
neutron subnet-update $DEFAULTSUBNETID --dns-nameservers list=true 8.8.8.8
|
|
|
|
# we may already have this so keystone may error
|
|
# XXX: we can query this membership.
|
|
keystone user-role-add --role Member --user tripleo-ci --tenant openstack-nodepool || true
|
|
|
|
# The the images that nodepool uses to creat templates
|
|
F20_IMAGE_URL=http://cloud.fedoraproject.org/fedora-20.x84_64.qcow2
|
|
F20_IMAGE_FILE=$TRIPLEO_ROOT/fedora-20.x86_64.qcow2
|
|
if [ ! -e $F20_IMAGE_FILE ] ; then
|
|
curl $F20_IMAGE_URL -o $F20_IMAGE_FILE
|
|
fi
|
|
PRECISE_IMAGE_FILE=$TRIPLEO_ROOT/precise-server-cloudimg-amd64-disk1.img
|
|
PRECISE_IMAGE_URL=http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img
|
|
if [ ! -e $PRECISE_IMAGE_FILE ] ; then
|
|
curl $PRECISE_IMAGE_URL -o $PRECISE_IMAGE_FILE
|
|
fi
|
|
if ! glance image-show "Fedora 20 64-bit" ; then
|
|
glance image-create --name "Fedora 20 64-bit" --disk-format qcow2 --container-format bare --is-public 1 --file $F20_IMAGE_FILE --progress
|
|
fi
|
|
if ! glance image-show "Ubuntu Precise 12.04 LTS Server 64-bit" ; then
|
|
glance image-create --name "Ubuntu Precise 12.04 LTS Server 64-bit" --disk-format qcow2 --container-format bare --is-public 1 --file $PRECISE_IMAGE_FILE --progress
|
|
fi
|
|
|
|
NETLIST=$(neutron net-list)
|
|
DEFAULT_NET=$(awk '/default-net/ { print $2 }' <<< "$NETLIST")
|
|
EXT_NET=$(awk '/ext-net/ { print $2 }' <<< "$NETLIST")
|
|
|
|
# Create and boot test env gear broker
|
|
BROKER_IMG=$TRIPLEO_ROOT/te-broker.qcow2
|
|
if [ ! -e $BROKER_IMG -o "$USE_CACHE" != "1" ] ; then
|
|
$TRIPLEO_ROOT/diskimage-builder/bin/disk-image-create -a amd64 -o $BROKER_IMG \
|
|
$TE_DISTRO vm geard stackuser dhcp-all-interfaces
|
|
fi
|
|
if ! glance image-show "te-broker" ; then
|
|
glance image-create --name "te-broker" --disk-format qcow2 --container-format bare --is-public 1 --file $BROKER_IMG --progress
|
|
fi
|
|
|
|
NP_CREDS="--os-username=tripleo-ci --os-password=$TE_OVERCLOUDPASSWD --os-tenant-name=openstack-nodepool"
|
|
if ! nova $NP_CREDS keypair-list | grep -q " default "; then
|
|
nova $NP_CREDS keypair-add default > ~/.ssh/tripleo-ci
|
|
chmod 0600 ~/.ssh/tripleo-ci
|
|
fi
|
|
if ! nova $NP_CREDS show te-broker ; then
|
|
nova $NP_CREDS boot --image "te-broker" --flavor $TE_BROKER_FLAVOR --nic net-id=$DEFAULT_NET --nic net-id=$TESTNETID,v4-fixed-ip=192.168.1.254 --key-name default te-broker
|
|
fi
|
|
|
|
# Create and boot squid broker
|
|
SQUID_IMG=$TRIPLEO_ROOT/squid.qcow2
|
|
if [ ! -e $SQUID_IMG -o "$USE_CACHE" != "1" ] ; then
|
|
$TRIPLEO_ROOT/diskimage-builder/bin/disk-image-create -a amd64 -o $SQUID_IMG \
|
|
$TE_DISTRO vm squid stackuser dhcp-all-interfaces
|
|
fi
|
|
if ! glance image-show squid ; then
|
|
glance image-create --name squid --disk-format qcow2 --container-format bare --is-public 1 --file $SQUID_IMG --progress
|
|
fi
|
|
|
|
if ! nova $NP_CREDS show squid ; then
|
|
nova $NP_CREDS boot --image "squid" --flavor $TE_BROKER_FLAVOR --nic net-id=$DEFAULT_NET --nic net-id=$TESTNETID,v4-fixed-ip=192.168.1.253 --key-name default squid
|
|
fi
|
|
|
|
# Assign a floting IP to the broker
|
|
TE_ID=$(nova $NP_CREDS show te-broker | awk '$2=="id" { print $4 }')
|
|
FLOATING_IP=$(nova $NP_CREDS floating-ip-list | awk '$4=="'$TE_ID'" {print $2}')
|
|
if [ -z "$FLOATING_IP" ]; then
|
|
FLOATING_IP=$(nova $NP_CREDS floating-ip-create | awk '$8=="ext-net" {print $2}')
|
|
nova $NP_CREDS add-floating-ip te-broker $FLOATING_IP
|
|
fi
|
|
|
|
# Ensure the default tripleo security group has ICMP and SSH inbound access
|
|
|
|
if ! neutron $NP_CREDS security-group-rule-list | grep -q 'default.*icmp' ; then
|
|
neutron $NP_CREDS security-group-rule-create default --protocol icmp \
|
|
--direction ingress --port-range-min 8
|
|
fi
|
|
if ! neutron $NP_CREDS security-group-rule-list | grep -q 'default.*tcp' ; then
|
|
neutron $NP_CREDS security-group-rule-create default --protocol tcp \
|
|
--direction ingress --port-range-min 22 --port-range-max 22
|
|
fi
|