コード例 #1
0
ファイル: neutron.py プロジェクト: gbraad/ustack-gringotts
def _delete_tunnels(tunnels, region_name=None):
    endpoint = ks_client.get_endpoint(region_name, "network")
    auth_token = ks_client.get_token()
    path = "%s/v2.0/uos_resources/%s/remove_tunnel.json" % (endpoint.rstrip("/"), "%s")
    for tunnel in tunnels:
        url = path % tunnel
        try:
            requests.put(url, headers={"X-Auth-Token": auth_token})
        except Exception as e:
            LOG.error("Fail to delete tunnel: %s, as: %s" % (tunnel, e))
コード例 #2
0
def _delete_tunnels(tunnels, region_name=None):
    endpoint = ks_client.get_endpoint(region_name, 'network')
    auth_token = ks_client.get_token()
    path = "%s/v2.0/uos_resources/%s/remove_tunnel.json" % (
        endpoint.rstrip('/'), '%s')
    for tunnel in tunnels:
        url = path % tunnel
        try:
            requests.put(url, headers={'X-Auth-Token': auth_token})
        except Exception as e:
            LOG.error('Fail to delete tunnel: %s, as: %s' % (tunnel, e))
コード例 #3
0
ファイル: lotus.py プロジェクト: zhaozhilong1993/gringotts
def request_to_lotus(method, api_url, body=None, headers=None):
    service_url = cfg.CONF.lotus_endpoint
    if not service_url:
        return

    auth_token = keystone.get_token()
    client = lotus_client()
    if headers:
        client.headers.update(headers)
    client.headers.update({'X-Auth-Token': auth_token})
    client.request(method, service_url.rstrip('/') + api_url, data=body)
コード例 #4
0
ファイル: manila.py プロジェクト: ShooterTT/gringotts
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
コード例 #5
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
コード例 #6
0
ファイル: lotus.py プロジェクト: ShooterTT/gringotts
def request_to_lotus(method, api_url, body=None, headers=None):
    service_url = cfg.CONF.lotus_endpoint
    if not service_url:
        return

    auth_token = keystone.get_token()
    client = lotus_client()
    if headers:
        client.headers.update(headers)
    client.headers.update({'X-Auth-Token': auth_token})
    client.request(method,
                   service_url.rstrip('/') + api_url,
                   data=body)
コード例 #7
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
コード例 #8
0
ファイル: kunkka.py プロジェクト: scorpioxiatian/gringotts
def get_uos_user(user_id):
    # NOTE(chengkun): Now The user's detail info is stored in kunkka,
    # so we should use kunkka api to get user info.
    ks_cfg = cfg.CONF.keystone_authtoken
    auth_url = '%s://%s' % (ks_cfg.auth_protocol, ks_cfg.auth_host)
    url = auth_url + '/api/v1/user/%s' % user_id
    r = requests.get(url,
                     headers={'Content-Type': 'application/json',
                              'X-Auth-Token': keystone.get_token()})
    if r.status_code == 404:
        LOG.warn("can't not find user %s from kunkka" % user_id)
        raise exception.NotFound()
    return r.json()
コード例 #9
0
ファイル: trove.py プロジェクト: ShooterTT/gringotts
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
コード例 #10
0
def get_uos_user(user_id):
    # NOTE(chengkun): Now The user's detail info is stored in kunkka,
    # so we should use kunkka api to get user info.
    ks_cfg = cfg.CONF.keystone_authtoken
    auth_url = '%s://%s' % (ks_cfg.auth_protocol, ks_cfg.auth_host)
    url = auth_url + '/api/v1/user/%s' % user_id
    r = requests.get(url,
                     headers={
                         'Content-Type': 'application/json',
                         'X-Auth-Token': keystone.get_token()
                     })
    if r.status_code == 404:
        LOG.warn("can't not find user %s from kunkka" % user_id)
        raise exception.NotFound()
    return r.json()
コード例 #11
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
コード例 #12
0
def get_neutronclient(region_name=None):
    endpoint = ks_client.get_endpoint(region_name, 'network')
    auth_token = ks_client.get_token()
    c = neutron_client.Client(token=auth_token, endpoint_url=endpoint)
    return c
コード例 #13
0
ファイル: glance.py プロジェクト: xiaolihope/gringotts
def get_glanceclient(region_name=None):
    endpoint = ks_client.get_endpoint(region_name, 'image')
    if endpoint[-1] != '/':
        endpoint += '/'
    auth_token = ks_client.get_token()
    return glanceclient.Client('2', endpoint, token=auth_token)
コード例 #14
0
ファイル: neutron.py プロジェクト: gbraad/ustack-gringotts
def get_neutronclient(region_name=None):
    endpoint = ks_client.get_endpoint(region_name, "network")
    auth_token = ks_client.get_token()
    c = neutron_client.Client(token=auth_token, endpoint_url=endpoint)
    return c
コード例 #15
0
ファイル: ceilometer.py プロジェクト: gbraad/ustack-gringotts
def get_cmclient(region_name=None):
    endpoint = ks_client.get_endpoint(region_name, "metering")
    auth_token = ks_client.get_token()
    return cmclient.get_client(2, os_auth_token=(lambda: auth_token), ceilometer_url=endpoint)
コード例 #16
0
def get_cmclient(region_name=None):
    endpoint = ks_client.get_endpoint(region_name, 'metering')
    auth_token = ks_client.get_token()
    return cmclient.get_client(2,
                               os_auth_token=(lambda: auth_token),
                               ceilometer_url=endpoint)