~openstack-charm-testers/openstack-charm-testing/openstack-monitoring

« back to all changes in this revision

Viewing changes to profiles/lxd

  • Committer: Edward Hope-Morley
  • Date: 2016-12-05 15:01:45 UTC
  • mfrom: (220.1.37 openstack-charm-testing)
  • Revision ID: edward.hope-morley@canonical.com-20161205150145-5xs44qcs5ifqsnl5
rebase

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
set -ex
4
4
 
5
 
# Install dependencies and CLI tools
6
 
# See also requirements.txt in tempest (probably need to sudo pip install -r requirements.txt)
7
 
sudo apt-get install git testrepository subunit python-nose python-lxml python-boto \
8
 
    python-junitxml python-subunit python-testresources python-oslotest python-stevedore \
9
 
    python-cinderclient python-glanceclient python-heatclient python-keystoneclient \
10
 
    python-neutronclient python-novaclient python-swiftclient python-ceilometerclient \
11
 
    openvswitch-test openvswitch-common -y
 
5
. ./profiles/common
 
6
 
 
7
install_packages
12
8
 
13
9
# Set serverstack defaults, if not already set.
14
10
[[ -z "$GATEWAY" ]] && export GATEWAY="10.5.0.1"
24
20
# If not on bare metal, add extra port to overcloud neutron-gateway and configure charm to use it
25
21
if [[ "${BARE_METAL^^}" != "TRUE" ]]; then
26
22
    source ~/novarc
27
 
    # ens6 is a brittle hack for late-landing Xenial net dev name change
28
 
    ./bin/post-deploy-config neutron-gateway ens6
 
23
    ./bin/post-deploy-config neutron-gateway
29
24
fi
30
25
 
31
26
# Configure neutron networking on overcloud
32
27
source novarc
33
 
./bin/quantum-ext-net --network-type $net_type -g $GATEWAY -c $CIDR_EXT -f $FIP_RANGE ext_net
 
28
./bin/neutron-ext-net --network-type flat -g $GATEWAY -c $CIDR_EXT -f $FIP_RANGE ext_net
34
29
./bin/quantum-tenant-net --network-type $net_type -t admin -r provider-router -N $NAMESERVER private $CIDR_PRIV
35
30
 
36
 
# Download images if not already present
37
 
mkdir -vp ~/images
38
 
[ -f ~/images/trusty-server-cloudimg-amd64-root.tar.xz ] || {
39
 
    wget -O ~/images/trusty-server-cloudimg-amd64-root.tar.xz http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-root.tar.xz
40
 
}
41
 
[ -f ~/images/xenial-server-cloudimg-amd64-root.tar.xz ] || {
42
 
    wget -O ~/images/xenial-server-cloudimg-amd64-root.tar.xz http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-root.tar.xz
43
 
}
44
 
 
45
 
# Upload glance images to overcloud
46
 
glance --os-image-api-version 1 image-create --name="trusty-lxd" --is-public=true --progress \
47
 
    --container-format=bare --disk-format=raw --property hypervisor_type=lxc \
48
 
    --property architecture=x86_64 < ~/images/trusty-server-cloudimg-amd64-root.tar.xz
49
 
 
50
 
glance --os-image-api-version 1 image-create --name="xenial-lxd" --is-public=true --progress \
51
 
    --container-format=bare --disk-format=raw --property hypervisor_type=lxc \
52
 
    --property architecture=x86_64 < ~/images/xenial-server-cloudimg-amd64-root.tar.xz
53
 
 
54
 
# Create demo/testing users, tenants and flavor
55
 
keystone tenant-create --name demo
56
 
keystone user-create --name demo --tenant demo --pass pass --enabled true --email demo@dev.null
57
 
keystone user-role-add --user demo --role Member --tenant demo || :
58
 
keystone tenant-create --name alt_demo
59
 
keystone user-create --name alt_demo --tenant alt_demo --pass secret --enabled true --email alt_demo@dev.null
60
 
keystone user-role-add --user alt_demo --role Member --tenant alt_demo || :
61
 
 
62
 
nova flavor-create m1.cirros 6 64 1 1
63
 
nova flavor-create m1.tempest 7 256 5 1
64
 
nova flavor-create m2.tempest 8 512 5 1
 
31
upload_image cloudimages xenial xenial-server-cloudimg-amd64-root.tar.xz raw
 
32
upload_image cloudimages trusty trusty-server-cloudimg-amd64-root.tar.xz raw
 
33
 
 
34
image_id=$(openstack image list | grep trusty | awk '{ print $2 }')
 
35
image_alt_id=$(openstack image list | grep xenial | awk '{ print $2 }')
 
36
 
 
37
create_tempest_users
 
38
 
 
39
access=$(openstack --os-username demo --os-password pass --os-tenant-name demo ec2 credentials create | grep access | awk '{ print $4 }')
 
40
secret=$(openstack ec2 credentials show $access | grep secret | awk '{ print $4 }')
 
41
 
 
42
create_tempest_flavors
 
43
 
 
44
function create_exclusive_aggregate {
 
45
    exclusive_flavor=$1
 
46
    app_hostnames=$(./bin/application-hostnames nova-compute-exclusive-${exclusiveflavor})
 
47
    if [ -n "$app_hostnames" ]; then
 
48
        aggregate_name=exclusive-lxd-${exclusive_flavor}
 
49
        openstack aggregate show ${aggregate_name} || {
 
50
            openstack aggregate create ${aggregate_name}
 
51
            openstack aggregate set --property exclusive-flavor=${exclusive_flavor} ${aggregate_name}
 
52
            openstack aggregate set --property max_instances_per_host=1 ${aggregate_name}
 
53
            for hostname in ${app_hostnames}; do
 
54
                openstack aggregate add host ${aggregate_name} ${hostname}
 
55
            done
 
56
        }
 
57
    fi
 
58
}
 
59
 
 
60
function create_exclusive_flavor {
 
61
    exclusive_flavor=$1
 
62
    case ${exclusive_flavor} in
 
63
        small)
 
64
            ram=1500
 
65
            cpu=1
 
66
            disk=40
 
67
            ;;
 
68
        medium)
 
69
            ram=3500
 
70
            cpu=2
 
71
            disk=40
 
72
            ;;
 
73
        large)
 
74
            ram=7500
 
75
            cpu=4
 
76
            disk=80
 
77
            ;;
 
78
    esac
 
79
    flavor_name=e1.lxd.${exclusive_flavor}
 
80
    openstack flavor show ${flavor_name} || {
 
81
        openstack flavor create --public --ram ${ram} --disk ${disk} --vcpus ${cpu} ${flavor_name}
 
82
        openstack flavor set --property aggregate_instance_extra_specs:exclusive-flavor=${exclusive_flavor} ${flavor_name}
 
83
    }
 
84
}
 
85
 
 
86
for exclusive_flavor in small medium large; do
 
87
    create_exclusive_aggregate ${exclusive_flavor}
 
88
    create_exclusive_flavor ${exclusive_flavor}
 
89
done
65
90
 
66
91
# Gather vars for tempest template
67
 
access=$(keystone --os-username demo --os-password pass --os-tenant-name demo ec2-credentials-create | grep access | awk '{ print $4 }')
68
 
secret=$(keystone ec2-credentials-get --access $access | grep secret | awk '{ print $4 }')
69
 
image_id=$(glance image-list | grep trusty-server | awk '{ print $2 }')
70
 
image_alt_id=$(glance image-list | grep trusty-server | awk '{ print $2 }')
71
92
ext_net=$(neutron net-list | grep ext_net | awk '{ print $2 }')
72
93
router=$(neutron router-list | grep provider-router | awk '{ print $2}')
73
94
keystone=$(juju-deployer -f keystone)