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))
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))
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
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
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
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
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)
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
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)
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)