Пример #1
0
def get_ext_net_name(os_creds):
    """
    Returns the first external network name
    :param: os_creds: an instance of snaps OSCreds object
    :return:
    """
    neutron = neutron_utils.neutron_client(os_creds)
    ext_nets = neutron_utils.get_external_networks(neutron)
    return ext_nets[0].name
Пример #2
0
def get_ext_net_name():
    """
    Returns the first external network name
    :return:
    """
    os_env_file = CONST.openstack_creds
    os_creds = openstack_tests.get_credentials(os_env_file=os_env_file)
    neutron = neutron_utils.neutron_client(os_creds)
    ext_nets = neutron_utils.get_external_networks(neutron)
    return ext_nets[0]['network']['name']
Пример #3
0
def get_ext_net_name(os_creds):
    """
    Returns the configured external network name or
    the first retrieved external network name
    :param: os_creds: an instance of snaps OSCreds object
    :return:
    """
    neutron = neutron_utils.neutron_client(os_creds)
    ext_nets = neutron_utils.get_external_networks(neutron)
    if env.get('EXTERNAL_NETWORK'):
        extnet_config = env.get('EXTERNAL_NETWORK')
        for ext_net in ext_nets:
            if ext_net.name == extnet_config:
                return extnet_config
    return ext_nets[0].name if ext_nets else ""
Пример #4
0
def __get_router_variable_value(var_config_values, routers_dict,
                                os_creds_dict):
    """
    Returns the associated network value
    :param var_config_values: the configuration dictionary
    :param routers_dict: the dictionary containing all networks where the key
                          is the network name
    :param os_creds_dict: dict of OpenStack credentials where the key is the
                          name
    :return: the value
    """
    if 'creds_name' in var_config_values:
        os_creds = os_creds_dict.get[var_config_values['creds_name']]
    else:
        os_creds = os_creds_dict.get('admin-creds')

    router_name = var_config_values.get('router_name')
    router_creator = routers_dict[router_name]

    if router_creator:
        if 'external_fixed_ip' == var_config_values.get('attr'):
            session = keystone_utils.keystone_session(os_creds)
            neutron = neutron_utils.neutron_client(os_creds, session)
            try:
                ext_nets = neutron_utils.get_external_networks(neutron)

                subnet_name = var_config_values.get('subnet_name')

                for ext_net in ext_nets:
                    for subnet in ext_net.subnets:
                        if subnet_name == subnet.name:
                            router = router_creator.get_router()
                            for fixed_ips in router.external_fixed_ips:
                                if subnet.id == fixed_ips['subnet_id']:
                                    return fixed_ips['ip_address']
            finally:
                keystone_utils.close_session(session)