Merge lp:~gnuoy/openstack-charm-testing/ksv3 into lp:openstack-charm-testing

Proposed by Liam Young
Status: Rejected
Rejected by: Ryan Beisner
Proposed branch: lp:~gnuoy/openstack-charm-testing/ksv3
Merge into: lp:openstack-charm-testing
Diff against target: 487 lines (+448/-1)
6 files modified
bin/neutron-ext-net-ksv3 (+163/-0)
bin/neutron-tenant-net-ksv3 (+161/-0)
configure (+1/-1)
novarc (+13/-0)
novarcv3 (+13/-0)
profiles/defaultksv3 (+97/-0)
To merge this branch: bzr merge lp:~gnuoy/openstack-charm-testing/ksv3
Reviewer Review Type Date Requested Status
Ryan Beisner Needs Resubmitting
Review via email: mp+285693@code.launchpad.net
To post a comment you must log in.
177. By Liam Young

Add OS_AUTH_VERSION to make swift client Keystone v3 aware

Revision history for this message
Ryan Beisner (1chb1n) wrote :

I believe similar functionality was merged into o-c-t in a separate proposal. If that is not the case, please rebase and update this proposal. Thank you!

review: Needs Information
Revision history for this message
Ryan Beisner (1chb1n) wrote :

Closing MP, per previous comment, please resubmit if updates are still needed. Thank you!

review: Needs Resubmitting

Unmerged revisions

177. By Liam Young

Add OS_AUTH_VERSION to make swift client Keystone v3 aware

176. By Liam Young

Fix up novarc

175. By Liam Young

Fix router list

174. By Liam Young

Added ksv3 setup scripts

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'bin/neutron-ext-net-ksv3'
--- bin/neutron-ext-net-ksv3 1970-01-01 00:00:00 +0000
+++ bin/neutron-ext-net-ksv3 2016-02-12 13:19:26 +0000
@@ -0,0 +1,163 @@
1#!/usr/bin/python
2
3from keystoneclient.auth import identity
4from keystoneclient import session, v3
5from neutronclient.v2_0 import client
6import optparse
7import os
8import sys
9import logging
10
11
12usage = """Usage: %prog [options] ext_net_name
13
14For example:
15
16 %prog -g 192.168.21.1 -c 192.168.21.0/25 \\
17 -f 192.168.21.100:192.168.21.200 ext_net
18"""
19
20if __name__ == '__main__':
21 parser = optparse.OptionParser(usage)
22 parser.add_option('-p', '--project',
23 help='Project name to create network for',
24 dest='project', action='store',
25 default=None)
26 parser.add_option("-d", "--debug",
27 help="Enable debug logging",
28 dest="debug", action="store_true", default=False)
29 parser.add_option("-g", "--gateway",
30 help="Default gateway to use.",
31 dest="default_gateway", action="store", default=None)
32 parser.add_option("-c", "--cidr",
33 help="CIDR of external network.",
34 dest="cidr", action="store", default=None)
35 parser.add_option("-f", "--floating-range",
36 help="Range of floating IP's to use (separated by :).",
37 dest="floating_range", action="store", default=None)
38 parser.add_option("--network-type",
39 help="Network type.",
40 dest="network_type", action="store", default='gre')
41 (opts, args) = parser.parse_args()
42
43 if len(args) != 1:
44 parser.print_help()
45 sys.exit(1)
46
47 if opts.debug:
48 logging.basicConfig(level=logging.DEBUG)
49 else:
50 logging.basicConfig(level=logging.INFO)
51
52 net_name = args[0]
53 subnet_name = '{}_subnet'.format(net_name)
54
55 if (opts.floating_range):
56 (start_floating_ip, end_floating_ip) = opts.floating_range.split(':')
57 else:
58 start_floating_ip = None
59 end_floating_ip = None
60
61 auth = identity.v3.Password(
62 user_domain_name=os.environ['OS_DEFAULT_DOMAIN'],
63 username=os.environ['OS_USERNAME'],
64 password=os.environ['OS_PASSWORD'],
65 project_domain_name=os.environ['OS_PROJECT_DOMAIN_NAME'],
66 project_name=os.environ['OS_PROJECT_NAME'],
67 auth_url=os.environ['OS_AUTH_URL'])
68 sess = session.Session(auth=auth)
69
70 # Clients support sessions
71 keystone = v3.Client(session=sess)
72 quantum = client.Client(session=sess)
73
74 # Resolve tenant id
75 project_id = None
76 for proj in [t._info for t in keystone.projects.list()]:
77 if (proj['name'] ==
78 (opts.project or os.environ['OS_PROJECT_NAME'])):
79 project_id = proj['id']
80 break # Tenant ID found - stop looking
81 if not project_id:
82 logging.error("Unable to locate project id for %s.", opts.tenant)
83 sys.exit(1)
84
85 networks = quantum.list_networks(name=net_name)
86 if len(networks['networks']) == 0:
87 logging.info("Configuring external network '%s'", net_name)
88 network_msg = {
89 'network': {
90 'name': net_name,
91 'router:external': True,
92 'tenant_id': project_id,
93 'provider:network_type': opts.network_type,
94 }
95 }
96
97 if opts.network_type == 'vxlan':
98 network_msg['network']['provider:segmentation_id'] = 1234
99 elif opts.network_type == 'vlan':
100 network_msg['network']['provider:segmentation_id'] = 2
101 network_msg['network']['provider:physical_network'] = 'physnet1'
102 else:
103 network_msg['network']['provider:segmentation_id'] = 2
104
105 logging.info('Creating new external network definition: %s', net_name)
106 network = quantum.create_network(network_msg)['network']
107 logging.info('New external network created: %s', network['id'])
108 else:
109 logging.warning('Network %s already exists.', net_name)
110 network = networks['networks'][0]
111
112 subnets = quantum.list_subnets(name=subnet_name)
113 if len(subnets['subnets']) == 0:
114 subnet_msg = {
115 'name': subnet_name,
116 'network_id': network['id'],
117 'enable_dhcp': False,
118 'ip_version': 4,
119 'tenant_id': project_id
120 }
121
122 if opts.default_gateway:
123 subnet_msg['gateway_ip'] = opts.default_gateway
124 if opts.cidr:
125 subnet_msg['cidr'] = opts.cidr
126 if (start_floating_ip and end_floating_ip):
127 subnet_msg['allocation_pools'] = [
128 {
129 'start': start_floating_ip,
130 'end': end_floating_ip
131 }
132 ]
133
134 logging.info('Creating new subnet for %s', net_name)
135 subnet = quantum.create_subnet({'subnet': subnet_msg})['subnet']
136 logging.info('New subnet created: %s', subnet['id'])
137 else:
138 logging.warning('Subnet %s already exists.', subnet_name)
139 subnet = subnets['subnets'][0]
140
141 routers = quantum.list_routers(name='provider-router')
142 if len(routers['routers']) == 0:
143 logging.info('Creating provider router for external network access')
144 router = quantum.create_router(
145 {'router': {'name': 'provider-router', 'tenant_id': project_id}}
146 )['router']
147 logging.info('New router created: %s', (router['id']))
148 else:
149 logging.warning('Router provider-router already exists.')
150 router = routers['routers'][0]
151
152 ports = quantum.list_ports(device_owner='network:router_gateway',
153 network_id=network['id'])
154 if len(ports['ports']) == 0:
155 logging.info('Plugging router into ext_net')
156 router = \
157 quantum.add_gateway_router(
158 router=router['id'],
159 body={'network_id': network['id']}
160 )
161 logging.info('Router connected to %s', net_name)
162 else:
163 logging.warning('Router already connect to %s', net_name)
0164
=== added file 'bin/neutron-tenant-net-ksv3'
--- bin/neutron-tenant-net-ksv3 1970-01-01 00:00:00 +0000
+++ bin/neutron-tenant-net-ksv3 2016-02-12 13:19:26 +0000
@@ -0,0 +1,161 @@
1#!/usr/bin/python
2
3from keystoneclient.auth import identity
4from keystoneclient import session, v3
5from neutronclient.v2_0 import client
6import optparse
7import os
8import sys
9import logging
10
11usage = """Usage: %prog [options] name cidr
12
13For example:
14
15 %prog -t admin -r provider-router admin_net 10.5.5.0/24
16
17will create a new network for the admin tenant called 'admin_net' with a
18default gateway of 10.5.5.1 and a dhcp allocation range of
1910.5.5.2->10.5.5.254
20"""
21
22if __name__ == '__main__':
23 parser = optparse.OptionParser(usage)
24 parser.add_option('-p', '--project',
25 help='Project name to create network for',
26 dest='project', action='store',
27 default=None)
28 parser.add_option('-s', '--shared',
29 help='Create a shared rather than private network',
30 dest='shared', action='store_true', default=False)
31 parser.add_option('-r', '--router',
32 help='Router to plug new network into',
33 dest='router', action='store', default=None)
34 parser.add_option("-d", "--debug",
35 help="Enable debug logging",
36 dest="debug", action="store_true", default=False)
37 parser.add_option("-D", "--disable-dhcp",
38 help="Disable dhcp on network",
39 dest="dhcp", action="store_false", default=True)
40 parser.add_option("-N", "--dns-nameservers",
41 help="Comma separated list of dns servers to use.",
42 dest="dns_servers", action="store", default=None)
43 parser.add_option("--network-type",
44 help="Network type.",
45 dest="network_type", action="store", default='gre')
46 (opts, args) = parser.parse_args()
47
48 if len(args) != 2:
49 parser.print_help()
50 sys.exit(1)
51
52 if opts.debug:
53 logging.basicConfig(level=logging.DEBUG)
54 else:
55 logging.basicConfig(level=logging.INFO)
56
57 net_name = args[0]
58 subnet_name = "{}_subnet".format(net_name)
59 cidr = args[1]
60
61
62 auth = identity.v3.Password(
63 user_domain_name=os.environ['OS_DEFAULT_DOMAIN'],
64 username=os.environ['OS_USERNAME'],
65 password=os.environ['OS_PASSWORD'],
66 project_domain_name=os.environ['OS_PROJECT_DOMAIN_NAME'],
67 project_name=os.environ['OS_PROJECT_NAME'],
68 auth_url=os.environ['OS_AUTH_URL'])
69 sess = session.Session(auth=auth)
70
71 # Clients support sessions
72 keystone = v3.Client(session=sess)
73 quantum = client.Client(session=sess)
74
75 # Resolve tenant id
76 project_id = None
77 for proj in [t._info for t in keystone.projects.list()]:
78 if (proj['name'] ==
79 (opts.project or os.environ['OS_PROJECT_NAME'])):
80 project_id = proj['id']
81 break # Tenant ID found - stop looking
82 if not project_id:
83 logging.error("Unable to locate project id for %s.", opts.tenant)
84 sys.exit(1)
85
86 # Create network
87 networks = quantum.list_networks(name=net_name)
88 if len(networks['networks']) == 0:
89 logging.info('Creating tenant network: %s', net_name)
90 network_msg = {
91 'network': {
92 'name': net_name,
93 'shared': opts.shared,
94 'tenant_id': project_id,
95 'provider:network_type': opts.network_type,
96 }
97 }
98
99 if opts.network_type == 'vxlan':
100 network_msg['network']['provider:segmentation_id'] = 1233
101 elif opts.network_type == 'vlan':
102 network_msg['network']['provider:segmentation_id'] = 5
103 network_msg['network']['provider:physical_network'] = 'physnet1'
104 else:
105 network_msg['network']['provider:segmentation_id'] = 5
106
107 network = quantum.create_network(network_msg)['network']
108 else:
109 logging.warning('Network %s already exists.', net_name)
110 network = networks['networks'][0]
111
112 # Create subnet
113 subnets = quantum.list_subnets(name=subnet_name)
114 if len(subnets['subnets']) == 0:
115 logging.info('Creating subnet for %s',
116 net_name)
117 subnet_msg = {
118 'subnet': {
119 'name': subnet_name,
120 'network_id': network['id'],
121 'enable_dhcp': opts.dhcp,
122 'cidr': cidr,
123 'ip_version': 4,
124 'tenant_id': project_id
125 }
126 }
127 subnet = quantum.create_subnet(subnet_msg)['subnet']
128 else:
129 logging.warning('Subnet %s already exists.', subnet_name)
130 subnet = subnets['subnets'][0]
131
132 # Update dns_nameservers
133 if opts.dns_servers:
134 msg = {
135 'subnet': {
136 'dns_nameservers': opts.dns_servers.split(',')
137 }
138 }
139 logging.info('Updating dns_nameservers (%s) for subnet %s',
140 opts.dns_servers,
141 subnet_name)
142 quantum.update_subnet(subnet['id'], msg)
143
144 # Plug subnet into router if provided
145 if opts.router:
146 routers = quantum.list_routers(name=opts.router)
147 if len(routers['routers']) == 0:
148 logging.error('Unable to locate provider router %s', opts.router)
149 sys.exit(1)
150 else:
151 # Check to see if subnet already plugged into router
152 ports = quantum.list_ports(device_owner='network:router_interface',
153 network_id=network['id'])
154 if len(ports['ports']) == 0:
155 logging.info('Adding interface from %s to %s',
156 opts.router, subnet_name)
157 router = routers['routers'][0]
158 quantum.add_interface_router(router['id'],
159 {'subnet_id': subnet['id']})
160 else:
161 logging.warning('Router already connected to subnet')
0162
=== modified file 'configure'
--- configure 2016-01-05 21:04:33 +0000
+++ configure 2016-02-12 13:19:26 +0000
@@ -1,6 +1,6 @@
1#!/bin/sh1#!/bin/sh
22
3valid="default stsstack dellstack kernelstack ppc64el powerkvm lxd multihypervisor"3valid="default defaultksv3 stsstack dellstack kernelstack ppc64el powerkvm lxd multihypervisor"
44
5usage() {5usage() {
6 echo "$0 <profile>"6 echo "$0 <profile>"
77
=== modified file 'novarc'
--- novarc 2014-02-27 15:35:17 +0000
+++ novarc 2016-02-12 13:19:26 +0000
@@ -1,4 +1,17 @@
1#!/bin/bash1#!/bin/bash
2
3# Stop Keystone v3 env polluting v2 env
4unset OS_REGION_NAME
5unset OS_DEFAULT_DOMAIN
6unset OS_USER_DOMAIN_ID
7unset OS_PROJECT_NAME
8unset OS_IDENTITY_API_VERSION
9unset OS_PASSWORD
10unset OS_AUTH_URL
11unset OS_USERNAME
12unset OS_PROJECT_DOMAIN_NAME
13unset OS_AUTH_VERSION
14
2export OS_USERNAME=admin15export OS_USERNAME=admin
3export OS_PASSWORD=openstack16export OS_PASSWORD=openstack
4export OS_TENANT_NAME=admin17export OS_TENANT_NAME=admin
518
=== added file 'novarcv3'
--- novarcv3 1970-01-01 00:00:00 +0000
+++ novarcv3 2016-02-12 13:19:26 +0000
@@ -0,0 +1,13 @@
1#!/bin/bash
2
3export OS_USERNAME=admin
4export OS_PASSWORD=openstack
5export OS_REGION_NAME=RegionOne
6export OS_AUTH_URL=${OS_AUTH_PROTOCOL:-http}://`juju-deployer -f keystone`:5000/v3
7export OS_DEFAULT_DOMAIN=default
8export OS_PROJECT_NAME=admin
9export OS_PROJECT_DOMAIN_NAME=default
10export OS_IDENTITY_API_VERSION=3
11export export OS_USER_DOMAIN_ID=default
12# Swift needs this:
13export OS_AUTH_VERSION=3
014
=== added file 'profiles/defaultksv3'
--- profiles/defaultksv3 1970-01-01 00:00:00 +0000
+++ profiles/defaultksv3 2016-02-12 13:19:26 +0000
@@ -0,0 +1,97 @@
1#!/bin/bash
2
3set -e
4
5function upload_image {
6 src=$1
7 image_name=$2
8 image_file=$3
9 case "$src" in
10 swift) http_root="http://$SWIFT_IP:80/swift/v1/images";;
11 cloudimages) http_root="http://cloud-images.ubuntu.com/${image_name}/current";;
12 esac
13 [ -f ~/images/$image_file ] || {
14 wget -O ~/images/$image_file ${http_root}/${image_file}
15 }
16 openstack image show $image_name || {
17 openstack image create --container-format=bare --disk-format=qcow2 --file=${HOME}/images/$image_file $image_name
18 }
19}
20
21# Install dependencies and CLI tools
22# See also requirements.txt in tempest (probably need to sudo pip install -r requirements.txt)
23sudo apt-get install git testrepository subunit python-nose python-lxml python-boto \
24 python-junitxml python-subunit python-testresources python-oslotest python-stevedore \
25 python-cinderclient python-glanceclient python-heatclient python-keystoneclient \
26 python-neutronclient python-novaclient python-swiftclient python-ceilometerclient \
27 openvswitch-test openvswitch-common -y
28
29# Set serverstack defaults, if not already set.
30[[ -z "$GATEWAY" ]] && export GATEWAY="10.5.0.1"
31[[ -z "$CIDR_EXT" ]] && export CIDR_EXT="10.5.0.0/16"
32[[ -z "$FIP_RANGE" ]] && export FIP_RANGE="10.5.150.0:10.5.200.254"
33[[ -z "$NAMESERVER" ]] && export NAMESERVER="10.245.160.2"
34[[ -z "$CIDR_PRIV" ]] && export CIDR_PRIV="192.168.21.0/24"
35[[ -z "$SWIFT_IP" ]] && export SWIFT_IP="10.245.161.162"
36
37# Accept network type as first parameter, assume gre if unspecified
38net_type=${1:-"gre"}
39
40# If not on bare metal, add extra port to overcloud neutron-gateway and configure charm to use it
41if [[ "${BARE_METAL^^}" != "TRUE" ]]; then
42 unset OS_DEFAULT_DOMAIN OS_PROJECT_NAME OS_IDENTITY_API_VERSION OS_PROJECT_DOMAIN_NAME
43 source ~/novarc
44 ./bin/post-deploy-config neutron-gateway
45fi
46# Configure neutron networking on overcloud
47source novarcv3
48./bin/neutron-ext-net-ksv3 --network-type $net_type -g $GATEWAY -c $CIDR_EXT -f $FIP_RANGE ext_net
49./bin/neutron-tenant-net-ksv3 --network-type $net_type -p admin -r provider-router -N $NAMESERVER private $CIDR_PRIV
50
51# Download images if not already present
52mkdir -vp ~/images
53upload_image cloudimages wily wily-server-cloudimg-amd64-disk1.img
54upload_image cloudimages vivid vivid-server-cloudimg-amd64-disk1.img
55upload_image cloudimages trusty trusty-server-cloudimg-amd64-disk1.img
56upload_image cloudimages precise precise-server-cloudimg-amd64-disk1.img
57upload_image swift cirros cirros-0.3.4-x86_64-disk.img
58
59# Create demo/testing users, tenants and flavor
60openstack project show demo || openstack project create demo
61openstack user show demo || openstack user create --project demo --password pass --enable --email demo@dev.null demo
62openstack role show Member || openstack role create Member
63openstack role add --user demo --project demo Member
64openstack project show alt_demo || openstack project create alt_demo
65openstack user show alt_demo || openstack user create --project alt_demo --password secret --enable --email alt_demo@dev.null alt_demo
66openstack role add --user alt_demo --project alt_demo Member
67
68openstack flavor show m1.cirros || openstack flavor create --id 6 --ram 64 --disk 1 --vcpus 1 m1.cirros
69openstack flavor show m1.tempest || openstack flavor create --id 7 --ram 256 --disk 5 --vcpus 1 m1.tempest
70openstack flavor show m2.tempest || openstack flavor create --id 8 --ram 512 --disk 5 --vcpus 1 m2.tempest
71exit 0
72# Gather vars for tempest template
73access=$(openstack ec2 credentials create --user demo --project demo | awk '/access/ {print $4}')
74secret=$(openstack ec2 credentials show $access | awk '/secret/ {print $4}')
75image_id=$(openstack image list | awk '/cirros/ {print $2}')
76image_alt_id=$(openstack image list | awk '/precise/ {print $2}')
77ext_net=$(openstack network list | awk '/ext_net/ {print $2}')
78# This needs fixing:
79router=$(neutron --os-user-domain-id default --os-project-domain-id default router-list | grep provider-router | awk '{ print $2}')
80keystone=$(juju-deployer -f keystone)
81dashboard=$(juju-deployer -f openstack-dashboard)
82ncc=$(juju-deployer -f nova-cloud-controller)
83http=${OS_AUTH_PROTOCOL:-http}
84
85# Insert vars into tempest conf
86sed -e "s/__IMAGE_ID__/$image_id/g" -e "s/__IMAGE_ALT_ID__/$image_alt_id/g" \
87 -e "s/__DASHBOARD__/$dashboard/g" -e "s/__KEYSTONE__/$keystone/g" \
88 -e "s/__EXT_NET__/$ext_net/g" -e "s/__PROTO__/$http/g" \
89 -e "s/__SWIFT__/$SWIFT_IP/g" \
90 -e "s/__NAMESERVER__/$NAMESERVER/g" \
91 -e "s/__CIDR_PRIV__/${CIDR_PRIV////\\/}/g" \
92 -e "s/__NCC__/$ncc/g" -e "s/__SECRET__/$secret/g" -e "s/__ACCESS__/$access/g" \
93 templates/tempest/tempest.conf.template > tempest.conf
94
95# Git tempest, place the rendered tempest template
96[ -d tempest ] || git clone https://github.com/openstack/tempest
97cp tempest.conf tempest/etc

Subscribers

People subscribed via source and target branches

to status/vote changes: