Beispiel #1
0
def get_gringclient(region_name=None):
    ks_cfg = cfg.CONF.keystone_authtoken
    auth_url = keystone.get_auth_url()
    c = client.Client(username=ks_cfg.admin_user,
                      password=ks_cfg.admin_password,
                      project_name=ks_cfg.admin_tenant_name,
                      auth_url=auth_url)
    return c
Beispiel #2
0
def get_manilaclient(region_name=None):
    ks_cfg = cfg.CONF.keystone_authtoken
    endpoint = ks_client.get_endpoint(region_name, 'share')
    auth_token = ks_client.get_token()
    auth_url = ks_client.get_auth_url()
    c = manila_client.Client(ks_cfg.admin_user,
                             ks_cfg.admin_password,
                             None,
                             auth_url=auth_url)
    c.client.auth_token = auth_token
    c.client.management_url = endpoint
    return c
Beispiel #3
0
def get_manilaclient(region_name=None):
    ks_cfg = cfg.CONF.keystone_authtoken
    endpoint = ks_client.get_endpoint(region_name, 'share')
    auth_token = ks_client.get_token()
    auth_url = ks_client.get_auth_url()
    c = manila_client.Client(ks_cfg.admin_user,
                             ks_cfg.admin_password,
                             None,
                             auth_url=auth_url)
    c.client.auth_token = auth_token
    c.client.management_url = endpoint
    return c
Beispiel #4
0
def troveclient(region_name=None):
    ks_cfg = cfg.CONF.keystone_authtoken
    endpoint = ks_client.get_endpoint(region_name, 'database')
    auth_token = ks_client.get_token()
    auth_url = ks_client.get_auth_url()

    tc = trove_client.Client(ks_cfg.admin_user,
                             ks_cfg.admin_password,
                             auth_url=auth_url)

    tc.client.auth_token = auth_token
    tc.client.management_url = endpoint
    return tc
Beispiel #5
0
def troveclient(region_name=None):
    ks_cfg = cfg.CONF.keystone_authtoken
    endpoint = ks_client.get_endpoint(region_name, 'database')
    auth_token = ks_client.get_token()
    auth_url = ks_client.get_auth_url()

    tc = trove_client.Client(ks_cfg.admin_user,
                             ks_cfg.admin_password,
                             auth_url=auth_url)

    tc.client.auth_token = auth_token
    tc.client.management_url = endpoint
    return tc
Beispiel #6
0
def get_novaclient(region_name=None):
    ks_cfg = cfg.CONF.keystone_authtoken
    endpoint = ks_client.get_endpoint(region_name, 'compute')
    auth_token = ks_client.get_token()
    auth_url = ks_client.get_auth_url()

    # Actually, there is no need to give any params to novaclient,
    # but it requires parameters.
    c = nova_client.Client(ks_cfg.admin_user,
                           ks_cfg.admin_password,
                           None, # project_id is not required
                           auth_url=auth_url)

    # Give auth_token and management_url directly to avoid authenticate again.
    c.client.auth_token = auth_token
    c.client.management_url = endpoint
    return c
Beispiel #7
0
def get_client():
    """Only can be used after CONF is initialized
    """
    from gringotts.services import keystone
    from gringotts.client.v2 import client
    ks_cfg = cfg.CONF.keystone_authtoken
    auth_url = keystone.get_auth_url()
    try:
        c = client.Client(username=ks_cfg.admin_user,
                          password=ks_cfg.admin_password,
                          project_name=ks_cfg.admin_tenant_name,
                          auth_url=auth_url)
        return c
    except (exception.Unauthorized, exception.AuthorizationFailure):
        _logger.exception("Billing Authorization Failed - rejecting request")
        raise
    except Exception as e:
        msg = 'Fail to initialize the billing client, for the reason: %s' % e
        _logger.exception(msg)
        raise
Beispiel #8
0
def get_client():
    """Only can be used after CONF is initialized
    """
    from gringotts.services import keystone
    from gringotts.client.v2 import client
    ks_cfg = cfg.CONF.keystone_authtoken
    auth_url = keystone.get_auth_url()
    try:
        c = client.Client(username=ks_cfg.admin_user,
                          password=ks_cfg.admin_password,
                          project_name=ks_cfg.admin_tenant_name,
                          auth_url=auth_url)
        return c
    except (exception.Unauthorized, exception.AuthorizationFailure):
        _logger.exception("Billing Authorization Failed - rejecting request")
        raise
    except Exception as e:
        msg = 'Fail to initialize the billing client, for the reason: %s' % e
        _logger.exception(msg)
        raise