예제 #1
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))
예제 #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
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
예제 #4
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
예제 #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
예제 #6
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
예제 #7
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
예제 #8
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
예제 #9
0
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)
예제 #10
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
예제 #11
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)
예제 #12
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)