Пример #1
0
def create_neutron_client(key_cl=None, creds=None):
    """
    Instantiates a neutron client object

    :param key_cl: a keystone client object
    :return: neutron client object
    """
    if creds is None:
        if key_cl is None:
            raise Exception("Must supply key_cl or creds")

        creds = {
            "username": key_cl.username,
            "tenant_name": key_cl.tenant_name,
            "password": key_cl.password,
            "auth_url": key_cl.auth_url
        }

    return Client(**creds)
Пример #2
0
def neutron_client(api_session,
                   region_name=None,
                   service_type='network',
                   version=None,
                   interface=None):
    """
    Create the neutron client using the session object.
    :param version: the neutron client version (either explicit or the one in settings)
    :param api_session: Our Keystone Session wrapper
    :type api_session: keystoneauth1.session.Session
    :param str region_name: the region name
    :param str service_type: the neutron service type name as it appears in the service catalog
    :param str interface: the interface used for communication i.e public, private, admin
    :rtype: Client
    """

    region_name = region_name or plugin_settings.DEFAULT_REGION
    interface = interface or plugin_settings.DEFAULT_INTERFACE
    c = Client(session=api_session,
               interface=interface,
               version=version,
               region_name=region_name,
               service_type=service_type)
    return c
Пример #3
0
 def _wait_client_availability(**credentials):
     rest_client = Client(session=get_session(**credentials))
     neutron_client = client.NeutronClient(rest_client)
     neutron_client.networks.find_all()
     return neutron_client
Пример #4
0
def _get_client():
    token = id_client.get_scoped_token_v3("user")
    return Client(endpoint=CONF.syntribos.endpoint, token=token)
Пример #5
0
 def _get_client():
     rest_client = Client(session=get_session())
     return client.NeutronClient(rest_client)
Пример #6
0
 def __init__(self):
     creds = keystone.keystone_retrieve()
     self.neutron_session = Client(**creds)