Teach `configure_gateway_ext_port()` about OVN
Also stop using ``juju_wait``.
This commit is contained in:
@@ -85,6 +85,8 @@ def get_machines_for_application(application):
|
||||
:rtype: Iterator[str]
|
||||
"""
|
||||
status = get_application_status(application)
|
||||
if not status:
|
||||
raise StopIteration
|
||||
|
||||
# libjuju juju status no longer has units for subordinate charms
|
||||
# Use the application it is subordinate-to to find machines
|
||||
|
||||
@@ -46,7 +46,6 @@ from swiftclient import client as swiftclient
|
||||
import datetime
|
||||
import io
|
||||
import itertools
|
||||
import juju_wait
|
||||
import logging
|
||||
import os
|
||||
import paramiko
|
||||
@@ -59,6 +58,7 @@ import tenacity
|
||||
import textwrap
|
||||
import urllib
|
||||
|
||||
import zaza
|
||||
from zaza import model
|
||||
from zaza.openstack.utilities import (
|
||||
exceptions,
|
||||
@@ -502,6 +502,8 @@ def deprecated_external_networking():
|
||||
if dvr_enabled():
|
||||
bridge_mappings = get_application_config_option('neutron-openvswitch',
|
||||
BRIDGE_MAPPINGS)
|
||||
elif ovn_present():
|
||||
return False
|
||||
else:
|
||||
bridge_mappings = get_application_config_option('neutron-gateway',
|
||||
BRIDGE_MAPPINGS)
|
||||
@@ -605,21 +607,35 @@ def configure_gateway_ext_port(novaclient, neutronclient, net_id=None,
|
||||
:param net_id: Network ID
|
||||
:type net_id: string
|
||||
"""
|
||||
deprecated_extnet_mode = deprecated_external_networking()
|
||||
|
||||
port_config_key = 'data-port'
|
||||
if deprecated_extnet_mode:
|
||||
port_config_key = 'ext-port'
|
||||
|
||||
config = {}
|
||||
if dvr_enabled():
|
||||
uuids = get_ovs_uuids()
|
||||
# If dvr, do not attempt to persist nic in netplan
|
||||
# https://github.com/openstack-charmers/zaza-openstack-tests/issues/78
|
||||
add_dataport_to_netplan = False
|
||||
application_name = 'neutron-openvswitch'
|
||||
application_names = ['neutron-openvswitch']
|
||||
elif ovn_present():
|
||||
uuids = get_ovn_uuids()
|
||||
application_names = ['ovn-chassis']
|
||||
try:
|
||||
ovn_dc_name = 'ovn-dedicated-chassis'
|
||||
next(juju_utils.get_machine_uuids_for_application(ovn_dc_name))
|
||||
application_names.append(ovn_dc_name)
|
||||
except StopIteration:
|
||||
# ovn-dedicated-chassis not in deployment
|
||||
pass
|
||||
port_config_key = 'interface-bridge-mappings'
|
||||
config.update({'ovn-bridge-mappings': 'physnet1:br-ex'})
|
||||
add_dataport_to_netplan = False
|
||||
else:
|
||||
uuids = get_gateway_uuids()
|
||||
application_name = 'neutron-gateway'
|
||||
|
||||
deprecated_extnet_mode = deprecated_external_networking()
|
||||
|
||||
config_key = 'data-port'
|
||||
if deprecated_extnet_mode:
|
||||
config_key = 'ext-port'
|
||||
application_names = ['neutron-gateway']
|
||||
|
||||
if not net_id:
|
||||
net_id = get_admin_net(neutronclient)['id']
|
||||
@@ -654,23 +670,31 @@ def configure_gateway_ext_port(novaclient, neutronclient, net_id=None,
|
||||
if 'ext-port' in port['name']:
|
||||
if deprecated_extnet_mode:
|
||||
ext_br_macs.append(port['mac_address'])
|
||||
elif ovn_present():
|
||||
ext_br_macs.append('{}:br-ex'.format(port['mac_address']))
|
||||
else:
|
||||
ext_br_macs.append('br-ex:{}'.format(port['mac_address']))
|
||||
ext_br_macs.sort()
|
||||
ext_br_macs_str = ' '.join(ext_br_macs)
|
||||
|
||||
if ext_br_macs:
|
||||
logging.info('Setting {} on {} external port to {}'.format(
|
||||
config_key, application_name, ext_br_macs_str))
|
||||
current_data_port = get_application_config_option(application_name,
|
||||
config_key)
|
||||
if current_data_port == ext_br_macs_str:
|
||||
logging.info('Config already set to value')
|
||||
return
|
||||
model.set_application_config(
|
||||
application_name,
|
||||
configuration={config_key: ext_br_macs_str})
|
||||
juju_wait.wait(wait_for_workload=True)
|
||||
config.update({port_config_key: ext_br_macs_str})
|
||||
for application_name in application_names:
|
||||
logging.info('Setting {} on {}'.format(
|
||||
config, application_name))
|
||||
current_data_port = get_application_config_option(application_name,
|
||||
port_config_key)
|
||||
if current_data_port == ext_br_macs_str:
|
||||
logging.info('Config already set to value')
|
||||
return
|
||||
|
||||
model.set_application_config(
|
||||
application_name,
|
||||
configuration=config)
|
||||
zaza.model.wait_for_agent_status()
|
||||
test_config = zaza.charm_lifecycle.utils.get_charm_config()
|
||||
zaza.model.wait_for_application_states(
|
||||
states=test_config.get('target_deploy_status', {}))
|
||||
|
||||
|
||||
@tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, max=60),
|
||||
|
||||
Reference in New Issue
Block a user