diff --git a/zaza/openstack/charm_tests/neutron/setup.py b/zaza/openstack/charm_tests/neutron/setup.py index e8f2439..f65b87a 100644 --- a/zaza/openstack/charm_tests/neutron/setup.py +++ b/zaza/openstack/charm_tests/neutron/setup.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python3 - # Copyright 2018 Canonical Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,6 +26,8 @@ from zaza.openstack.utilities import ( openstack as openstack_utils, ) +import zaza.charm_lifecycle.utils as lifecycle_utils + # The overcloud network configuration settings are declared. # These are the network configuration settings under test. @@ -81,12 +81,20 @@ def basic_overcloud_network(limit_gws=None): # Get keystone session keystone_session = openstack_utils.get_overcloud_keystone_session() + # Get optional use_juju_wait for netw ork option + options = (lifecycle_utils + .get_charm_config(fatal=False) + .get('configure_options', {})) + use_juju_wait = options.get( + 'configure_gateway_ext_port_use_juju_wait', True) + # Handle network for OpenStack-on-OpenStack scenarios if juju_utils.get_provider_type() == "openstack": undercloud_ks_sess = openstack_utils.get_undercloud_keystone_session() network.setup_gateway_ext_port(network_config, keystone_session=undercloud_ks_sess, - limit_gws=None) + limit_gws=None, + use_juju_wait=use_juju_wait) # Confugre the overcloud network network.setup_sdn(network_config, keystone_session=keystone_session) diff --git a/zaza/openstack/configure/network.py b/zaza/openstack/configure/network.py index 649992c..ad1a07b 100755 --- a/zaza/openstack/configure/network.py +++ b/zaza/openstack/configure/network.py @@ -184,7 +184,8 @@ def setup_sdn(network_config, keystone_session=None): def setup_gateway_ext_port(network_config, keystone_session=None, - limit_gws=None): + limit_gws=None, + use_juju_wait=True): """Perform setup external port on Neutron Gateway. For OpenStack on OpenStack scenarios. @@ -195,6 +196,8 @@ def setup_gateway_ext_port(network_config, keystone_session=None, :type keystone_session: keystoneauth1.session.Session object :param limit_gws: Limit the number of gateways that get a port attached :type limit_gws: Optional[int] + :param use_juju_wait: Use juju wait (default True) for model to settle + :type use_juju_wait: boolean :returns: None :rtype: None """ @@ -230,7 +233,8 @@ def setup_gateway_ext_port(network_config, keystone_session=None, neutron_client, net_id=net_id, add_dataport_to_netplan=add_dataport_to_netplan, - limit_gws=limit_gws) + limit_gws=limit_gws, + use_juju_wait=use_juju_wait) def run_from_cli(**kwargs): @@ -269,6 +273,11 @@ def run_from_cli(**kwargs): default="network.yaml") parser.add_argument("--cacert", help="Path to CA certificate bundle file", default=None) + parser.add_argument("--no-use-juju-wait", + help=("don't use juju wait for the model to settle " + "(default true)"), + action="store_false", + default=True) # Handle CLI options options = parser.parse_args() net_topology = (kwargs.get('net_toplogoy') or @@ -289,7 +298,9 @@ def run_from_cli(**kwargs): undercloud_ks_sess = openstack_utils.get_undercloud_keystone_session( verify=cacert) setup_gateway_ext_port(network_config, - keystone_session=undercloud_ks_sess) + keystone_session=undercloud_ks_sess, + use_juju_wait=cli_utils.parse_arg( + options, 'no_use_juju_wait')) overcloud_ks_sess = openstack_utils.get_overcloud_keystone_session( verify=cacert) diff --git a/zaza/openstack/utilities/openstack.py b/zaza/openstack/utilities/openstack.py index 7ab203d..0c31c05 100644 --- a/zaza/openstack/utilities/openstack.py +++ b/zaza/openstack/utilities/openstack.py @@ -64,7 +64,6 @@ import textwrap import urllib import zaza -import zaza.charm_lifecycle.utils as lifecycle_utils from zaza import model from zaza.openstack.utilities import ( @@ -703,7 +702,8 @@ def add_interface_to_netplan(server_name, mac_address): def configure_gateway_ext_port(novaclient, neutronclient, net_id=None, add_dataport_to_netplan=False, - limit_gws=None): + limit_gws=None, + use_juju_wait=True): """Configure the neturong-gateway external port. :param novaclient: Authenticated novaclient @@ -714,6 +714,9 @@ def configure_gateway_ext_port(novaclient, neutronclient, net_id=None, :type net_id: string :param limit_gws: Limit the number of gateways that get a port attached :type limit_gws: Optional[int] + :param use_juju_wait: Whether to use juju wait to wait for the model to + settle once the gateway has been configured. Default is True + :type use_juju_wait: boolean """ deprecated_extnet_mode = deprecated_external_networking() @@ -821,11 +824,13 @@ def configure_gateway_ext_port(novaclient, neutronclient, net_id=None, # NOTE(fnordahl): We are stuck with juju_wait until we figure out how # to deal with all the non ['active', 'idle', 'Unit is ready.'] # workload/agent states and msgs that our mojo specs are exposed to. - if lifecycle_utils.get_config_options().get( - 'configure_gateway_ext_port_use_juju_wait', True): + if use_juju_wait: juju_wait.wait(wait_for_workload=True) else: zaza.model.wait_for_agent_status() + # TODO: shouldn't access get_charm_config() here as it relies on + # ./tests/tests.yaml existing by default (regardless of the + # fatal=False) ... it's not great design. test_config = zaza.charm_lifecycle.utils.get_charm_config( fatal=False) zaza.model.wait_for_application_states(