Merge lp:~gnuoy/openstack-mojo-specs/mojo-openstack-specs-ext-port-rejig into lp:openstack-mojo-specs

Proposed by Liam Young on 2016-04-20
Status: Merged
Merged at revision: 257
Proposed branch: lp:~gnuoy/openstack-mojo-specs/mojo-openstack-specs-ext-port-rejig
Merge into: lp:openstack-mojo-specs
Diff against target: 68 lines (+38/-15)
1 file modified
helper/utils/mojo_os_utils.py (+38/-15)
To merge this branch: bzr merge lp:~gnuoy/openstack-mojo-specs/mojo-openstack-specs-ext-port-rejig
Reviewer Review Type Date Requested Status
Ryan Beisner 2016-04-20 Approve on 2016-04-20
Review via email: mp+292363@code.launchpad.net
To post a comment you must log in.
Liam Young (gnuoy) wrote :

Spec works with specs/full_stack/next_keystone_v3/mitaka on xenial and specs/full_stack/next_dvr/mitaka. Ryan, do you want to run with it in osci for a bit before landing?

Ryan Beisner (1chb1n) wrote :

Exercising metal and virtual xenial and trusty specs with this branch in osci, will report back here. Thanks for the mods!

review: Needs Information
Ryan Beisner (1chb1n) wrote :

Validated A-OK on specs:

virtual: trusty-icehouse
virtual: xenial-mitaka
metal: xenial-mitaka

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'helper/utils/mojo_os_utils.py'
2--- helper/utils/mojo_os_utils.py 2016-04-13 10:50:39 +0000
3+++ helper/utils/mojo_os_utils.py 2016-04-20 10:43:15 +0000
4@@ -313,27 +313,50 @@
5
6 for uuid in uuids:
7 server = novaclient.servers.get(uuid)
8- mac_addrs = [a.mac_addr for a in server.interface_list()]
9- if len(mac_addrs) < 2:
10+ ext_port_name = "{}_ext-port".format(server.name)
11+ for port in neutronclient.list_ports(device_id=server.id)['ports']:
12+ if port['name'] == ext_port_name:
13+ logging.warning('Neutron Gateway already has additional port')
14+ break
15+ else:
16 logging.info('Attaching additional port to instance, '
17 'connected to net id: {}'.format(net_id))
18- server.interface_attach(port_id=None, net_id=net_id,
19- fixed_ip=None)
20- else:
21- logging.warning('Neutron Gateway already has additional port')
22+ body_value = {
23+ "port": {
24+ "admin_state_up": True,
25+ "name": ext_port_name,
26+ "network_id": net_id
27+ }
28+ }
29+ port = neutronclient.create_port(body=body_value)
30+ server.interface_attach(port_id=port['port']['id'],
31+ net_id=None, fixed_ip=None)
32+ ext_port_macs = []
33+ for port in neutronclient.list_ports(network_id=net_id)['ports']:
34+ if 'ext-port' in port['name']:
35+ ext_port_macs.append(port['mac_address'])
36+ ext_port_macs.sort()
37+ ext_port_macs_str = ' '.join(ext_port_macs)
38+ if dvr_mode:
39+ service_name = 'neutron-openvswitch'
40+ else:
41+ service_name = 'neutron-gateway'
42 # XXX Trying to track down a failure with juju run neutron-gateway/0 in
43 # the post juju_set check. Try a sleep here to see if some network
44 # reconfigureing on the gateway is still in progress and that's
45 # causing the issue
46- if uuids:
47- if dvr_mode:
48- logging.info('Setting neutron-openvswitch external port to eth1')
49- mojo_utils.juju_set('neutron-openvswitch',
50- 'ext-port=eth1',
51- wait=False)
52- else:
53- logging.info('Setting Neutron Gateway external port to eth1')
54- mojo_utils.juju_set('neutron-gateway', 'ext-port=eth1', wait=False)
55+ if ext_port_macs:
56+ logging.info('Setting ext-port on {} external port to {}'.format(
57+ service_name, ext_port_macs_str))
58+ current_ext_port = mojo_utils.juju_get(service_name, 'ext-port')
59+ if current_ext_port == ext_port_macs_str:
60+ logging.info('Config already set to value')
61+ return
62+ mojo_utils.juju_set(
63+ service_name,
64+ 'ext-port={}'.format(ext_port_macs_str),
65+ wait=False
66+ )
67 time.sleep(240)
68 mojo_utils.juju_wait_finished()
69

Subscribers

People subscribed via source and target branches