~openstack-charm-testers/openstack-charm-testing/percona-split-net

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash

set -ex

# Install dependencies and CLI tools
# See also requirements.txt in tempest (probably need to sudo pip install -r requirements.txt)
sudo apt-get install git testrepository subunit python-nose python-lxml python-boto \
    python-junitxml python-subunit python-testresources python-oslotest python-stevedore \
    python-cinderclient python-glanceclient python-heatclient python-keystoneclient \
    python-neutronclient python-novaclient python-swiftclient python-ceilometerclient \
    openvswitch-test openvswitch-common -y

# Set serverstack defaults, if not already set.
[[ -z "$GATEWAY" ]] && export GATEWAY="10.5.0.1"
[[ -z "$CIDR_EXT" ]] && export CIDR_EXT="10.5.0.0/16"
[[ -z "$FIP_RANGE" ]] && export FIP_RANGE="10.5.150.0:10.5.200.254"
[[ -z "$NAMESERVER" ]] && export NAMESERVER="10.245.160.2"
[[ -z "$CIDR_PRIV" ]] && export CIDR_PRIV="192.168.21.0/24"
[[ -z "$SWIFT_IP" ]] && export SWIFT_IP="10.245.161.162"

# Accept network type as first parameter, assume gre if unspecified
net_type=${1:-"gre"}

# If not on bare metal, add extra port to overcloud neutron-gateway and configure charm to use it
if [[ "${BARE_METAL^^}" != "TRUE" ]]; then
    source ~/novarc
    ./bin/post-deploy-config neutron-gateway
fi

# Configure neutron networking on overcloud
source novarc
./bin/quantum-ext-net --network-type $net_type -g $GATEWAY -c $CIDR_EXT -f $FIP_RANGE ext_net
./bin/quantum-tenant-net --network-type $net_type -t admin -r provider-router -N $NAMESERVER private $CIDR_PRIV

# Download images if not already present
mkdir -vp ~/images
[ -f ~/images/xenial-server-cloudimg-amd64-disk1.img ] || {
    wget -O ~/images/xenial-server-cloudimg-amd64-disk1.img http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
}
[ -f ~/images/wily-server-cloudimg-amd64-disk1.img ] || {
    wget -O ~/images/wily-server-cloudimg-amd64-disk1.img http://cloud-images.ubuntu.com/wily/current/wily-server-cloudimg-amd64-disk1.img
}
[ -f ~/images/trusty-server-cloudimg-amd64-disk1.img ] || {
    wget -O ~/images/trusty-server-cloudimg-amd64-disk1.img http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
}
[ -f ~/images/precise-server-cloudimg-amd64-disk1.img ] || {
    wget -O ~/images/precise-server-cloudimg-amd64-disk1.img http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img
}
[ -f ~/images/cirros-0.3.4-x86_64-disk.img ] || {
    wget -O ~/images/cirros-0.3.4-x86_64-disk.img http://$SWIFT_IP:80/swift/v1/images/cirros-0.3.4-x86_64-disk.img
}
[ -f ~/images/cirros-0.3.4-x86_64-uec.tar.gz ] || {
    wget -O ~/images/cirros-0.3.4-x86_64-uec.tar.gz http://$SWIFT_IP:80/swift/v1/images/cirros-0.3.4-x86_64-uec.tar.gz
    (cd ~/images && tar -xzf cirros-0.3.4-x86_64-uec.tar.gz)
}

# Upload glance images to overcloud
glance --os-image-api-version 1 image-create --name="xenial" --is-public=true --progress \
    --container-format=bare --disk-format=qcow2 < ~/images/xenial-server-cloudimg-amd64-disk1.img
glance --os-image-api-version 1 image-create --name="wily" --is-public=true --progress \
    --container-format=bare --disk-format=qcow2 < ~/images/wily-server-cloudimg-amd64-disk1.img
glance --os-image-api-version 1 image-create --name="trusty" --is-public=true --progress \
    --container-format=bare --disk-format=qcow2 < ~/images/trusty-server-cloudimg-amd64-disk1.img
glance --os-image-api-version 1 image-create --name="precise" --is-public=true --progress \
    --container-format=bare --disk-format=qcow2 < ~/images/precise-server-cloudimg-amd64-disk1.img
glance --os-image-api-version 1 image-create --name="cirros" --is-public=true --progress \
    --container-format=bare --disk-format=qcow2 < ~/images/cirros-0.3.4-x86_64-disk.img

# Create demo/testing users, tenants and flavor
keystone tenant-create --name demo
keystone user-create --name demo --tenant demo --pass pass --enabled true --email demo@dev.null
keystone user-role-add --user demo --role Member --tenant demo || :
keystone tenant-create --name alt_demo
keystone user-create --name alt_demo --tenant alt_demo --pass secret --enabled true --email alt_demo@dev.null
keystone user-role-add --user alt_demo --role Member --tenant alt_demo || :

nova flavor-create m1.cirros 6 64 1 1
nova flavor-create m1.tempest 7 256 5 1
nova flavor-create m2.tempest 8 512 5 1

# Gather vars for tempest template
access=$(keystone --os-username demo --os-password pass --os-tenant-name demo ec2-credentials-create | grep access | awk '{ print $4 }')
secret=$(keystone ec2-credentials-get --access $access | grep secret | awk '{ print $4 }')
image_id=$(glance image-list | grep cirros | awk '{ print $2 }')
image_alt_id=$(glance image-list | grep precise | awk '{ print $2 }')
ext_net=$(neutron net-list | grep ext_net | awk '{ print $2 }')
router=$(neutron router-list | grep provider-router | awk '{ print $2}')
keystone=$(juju-deployer -f keystone)
dashboard=$(juju-deployer -f openstack-dashboard)
ncc=$(juju-deployer -f nova-cloud-controller)
http=${OS_AUTH_PROTOCOL:-http}

# Insert vars into tempest conf
sed -e "s/__IMAGE_ID__/$image_id/g" -e "s/__IMAGE_ALT_ID__/$image_alt_id/g" \
    -e "s/__DASHBOARD__/$dashboard/g" -e "s/__KEYSTONE__/$keystone/g" \
    -e "s/__EXT_NET__/$ext_net/g" -e "s/__PROTO__/$http/g" \
    -e "s/__SWIFT__/$SWIFT_IP/g" \
    -e "s/__NAMESERVER__/$NAMESERVER/g" \
    -e "s/__CIDR_PRIV__/${CIDR_PRIV////\\/}/g" \
    -e "s/__NCC__/$ncc/g" -e "s/__SECRET__/$secret/g" -e "s/__ACCESS__/$access/g" \
    templates/tempest/tempest.conf.template > tempest.conf

# Git tempest, place the rendered tempest template
[ -d tempest ] || git clone https://github.com/openstack/tempest
cp tempest.conf tempest/etc