Beispiel #1
0
def setup_gateway_ext_port(network_config,
                           keystone_session=None,
                           limit_gws=None,
                           use_juju_wait=True):
    """Perform setup external port on Neutron Gateway.

    For OpenStack on OpenStack scenarios.

    :param network_config: Network configuration dictionary
    :type network_config: dict
    :param keystone_session: Keystone session object for undercloud
    :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
    """
    # If a session has not been provided, acquire one
    if not keystone_session:
        keystone_session = openstack_utils.get_undercloud_keystone_session()

    # Get authenticated clients
    nova_client = openstack_utils.get_nova_session_client(keystone_session)
    neutron_client = openstack_utils.get_neutron_session_client(
        keystone_session)

    # Add an interface to the neutron-gateway units and tell juju to use it
    # as the external port.
    if "net_id" in network_config.keys():
        net_id = network_config["net_id"]
    else:
        net_id = None

    try:
        # If we're using netplan, we need to add the new interface to the guest
        current_release = openstack_utils.get_os_release()
        bionic_queens = openstack_utils.get_os_release('bionic_queens')
        if current_release >= bionic_queens:
            logging.warn("Adding second interface for dataport to guest "
                         "netplan for bionic-queens and later")
            add_dataport_to_netplan = True
        else:
            add_dataport_to_netplan = False
    except zaza.openstack.utilities.exceptions.ApplicationNotFound:
        # The setup_gateway_ext_port helper may be used with non-OpenStack
        # workloads.
        add_dataport_to_netplan = False

    logging.info("Configuring network for OpenStack undercloud/provider")
    openstack_utils.configure_gateway_ext_port(
        nova_client,
        neutron_client,
        net_id=net_id,
        add_dataport_to_netplan=add_dataport_to_netplan,
        limit_gws=limit_gws,
        use_juju_wait=use_juju_wait)
def setup_gateway_ext_port(network_config, keystone_session=None):
    """Perform setup external port on Neutron Gateway.

    For OpenStack on OpenStack scenarios.

    :param network_config: Network configuration dictionary
    :type network_config: dict
    :param keystone_session: Keystone session object for undercloud
    :type keystone_session: keystoneauth1.session.Session object
    :returns: None
    :rtype: None
    """
    # If a session has not been provided, acquire one
    if not keystone_session:
        keystone_session = openstack_utils.get_undercloud_keystone_session()

    # Get authenticated clients
    nova_client = openstack_utils.get_nova_session_client(keystone_session)
    neutron_client = openstack_utils.get_neutron_session_client(
        keystone_session)

    # Add an interface to the neutron-gateway units and tell juju to use it
    # as the external port.
    if "net_id" in network_config.keys():
        net_id = network_config["net_id"]
    else:
        net_id = None

    # If we're using netplan, we need to add the new interface to the guest
    current_release = openstack_utils.get_os_release()
    bionic_queens = openstack_utils.get_os_release('bionic_queens')
    if current_release >= bionic_queens:
        logging.warn("Adding second interface for dataport to guest netplan "
                     "for bionic-queens and later")
        add_dataport_to_netplan = True
    else:
        add_dataport_to_netplan = False

    logging.info("Configuring network for OpenStack undercloud/provider")
    openstack_utils.configure_gateway_ext_port(
        nova_client,
        neutron_client,
        dvr_mode=network_config.get("dvr_enabled", False),
        net_id=net_id,
        add_dataport_to_netplan=add_dataport_to_netplan)