Ejemplo n.º 1
0
def client():
    ctx = context.current()
    heat_url = base.url_for(ctx.service_catalog, 'orchestration',
                            endpoint_type=CONF.heat.endpoint_type)
    return heat_client.Client('1', heat_url, token=context.get_auth_token(),
                              cert_file=CONF.heat.ca_file,
                              insecure=CONF.heat.api_insecure,
                              username=ctx.username,
                              include_pass=True)
Ejemplo n.º 2
0
Archivo: heat.py Proyecto: uladz/sahara
def client():
    ctx = context.current()
    heat_url = base.url_for(ctx.service_catalog,
                            'orchestration',
                            endpoint_type=CONF.heat.endpoint_type)
    return heat_client.Client('1',
                              heat_url,
                              token=context.get_auth_token(),
                              cert_file=CONF.heat.ca_file,
                              insecure=CONF.heat.api_insecure,
                              username=ctx.username,
                              include_pass=True)
Ejemplo n.º 3
0
def client():
    ctx = context.ctx()
    args = {
        'username': ctx.username,
        'project_name': ctx.tenant_name,
        'project_id': ctx.tenant_id,
        'input_auth_token': context.get_auth_token(),
        'auth_url': base.retrieve_auth_url(),
        'service_catalog_url': base.url_for(ctx.service_catalog, 'share'),
        'ca_cert': CONF.manila.ca_file,
        'insecure': CONF.manila.api_insecure
    }
    return manila_client.Client(str(CONF.manila.api_version), **args)
Ejemplo n.º 4
0
def client():
    ctx = context.ctx()
    args = {
        'username': ctx.username,
        'project_name': ctx.tenant_name,
        'project_id': ctx.tenant_id,
        'input_auth_token': context.get_auth_token(),
        'auth_url': base.retrieve_auth_url(),
        'service_catalog_url': base.url_for(ctx.service_catalog, 'share'),
        'ca_cert': CONF.manila.ca_file,
        'insecure': CONF.manila.api_insecure
    }
    return manila_client.Client(str(CONF.manila.api_version), **args)
Ejemplo n.º 5
0
    def get_neutron_info(self, instance=None):
        if not instance:
            instance = self.instance
        neutron_info = dict()
        neutron_info['network'] = instance.cluster.neutron_management_network
        ctx = context.current()
        neutron_info['token'] = context.get_auth_token()
        neutron_info['tenant'] = ctx.tenant_name
        neutron_info['host'] = _get_access_ip(instance)

        log_info = copy.deepcopy(neutron_info)
        del log_info['token']
        LOG.debug('Returning neutron info: {info}'.format(info=log_info))
        return neutron_info
Ejemplo n.º 6
0
    def get_neutron_info(self, instance=None):
        if not instance:
            instance = self.instance
        neutron_info = dict()
        neutron_info['network'] = instance.cluster.neutron_management_network
        ctx = context.current()
        neutron_info['token'] = context.get_auth_token()
        neutron_info['tenant'] = ctx.tenant_name
        neutron_info['host'] = instance.management_ip

        log_info = copy.deepcopy(neutron_info)
        del log_info['token']
        LOG.debug('Returning neutron info: {info}'.format(info=log_info))
        return neutron_info
Ejemplo n.º 7
0
def client_from_token(token=None):
    if not token:
        token = context.get_auth_token()
    '''return a Swift client authenticated from a token.'''
    return swiftclient.Connection(auth_version='2.0',
                                  cacert=CONF.swift.ca_file,
                                  insecure=CONF.swift.api_insecure,
                                  preauthurl=base.url_for(
                                      service_type="object-store",
                                      endpoint_type=CONF.swift.endpoint_type),
                                  preauthtoken=token,
                                  retries=CONF.retries.retries_number,
                                  retry_on_ratelimit=True,
                                  starting_backoff=CONF.retries.retry_after,
                                  max_backoff=CONF.retries.retry_after)
Ejemplo n.º 8
0
def client_from_token(token=None):
    if not token:
        token = context.get_auth_token()
    '''return a Swift client authenticated from a token.'''
    return swiftclient.Connection(auth_version='2.0',
                                  cacert=CONF.swift.ca_file,
                                  insecure=CONF.swift.api_insecure,
                                  preauthurl=base.url_for(
                                      service_type="object-store",
                                      endpoint_type=CONF.swift.endpoint_type),
                                  preauthtoken=token,
                                  retries=CONF.retries.retries_number,
                                  retry_on_ratelimit=True,
                                  starting_backoff=CONF.retries.retry_after,
                                  max_backoff=CONF.retries.retry_after)
Ejemplo n.º 9
0
def url_for(service_catalog=None, service_type='identity',
            endpoint_type="internalURL"):
    if not service_catalog:
        service_catalog = context.current().service_catalog
    try:
        return keystone_service_catalog.ServiceCatalogV2(
            {'serviceCatalog': json.loads(service_catalog)}).url_for(
                service_type=service_type, endpoint_type=endpoint_type,
                region_name=CONF.os_region_name)
    except keystone_ex.EndpointNotFound:
        return keystone_service_catalog.ServiceCatalogV3(
            context.get_auth_token(),
            {'catalog': json.loads(service_catalog)}).url_for(
                service_type=service_type, endpoint_type=endpoint_type,
                region_name=CONF.os_region_name)
Ejemplo n.º 10
0
def url_for(service_catalog=None,
            service_type='identity',
            endpoint_type="internalURL"):
    if not service_catalog:
        service_catalog = context.current().service_catalog
    try:
        return keystone_service_catalog.ServiceCatalogV2({
            'serviceCatalog':
            json.loads(service_catalog)
        }).url_for(service_type=service_type,
                   endpoint_type=endpoint_type,
                   region_name=CONF.os_region_name)
    except keystone_ex.EndpointNotFound:
        return keystone_service_catalog.ServiceCatalogV3(
            context.get_auth_token(), {
                'catalog': json.loads(service_catalog)
            }).url_for(service_type=service_type,
                       endpoint_type=endpoint_type,
                       region_name=CONF.os_region_name)
Ejemplo n.º 11
0
def use_os_admin_auth_token(cluster):
    """Set the current context to the admin user's trust scoped token

    This will configure the current context to the admin user's identity
    with the cluster's tenant. It will also generate an authentication token
    based on the admin user and a delegated trust associated with the
    cluster.

    :param cluster: The cluster to use for tenant and trust identification.

    """
    ctx = context.current()
    cluster = conductor.cluster_get(ctx, cluster)
    if CONF.use_identity_api_v3 and cluster.trust_id:
        ctx.username = CONF.keystone_authtoken.admin_user
        ctx.tenant_id = cluster.tenant_id
        ctx.auth_plugin = keystone.auth_for_admin(trust_id=cluster.trust_id)
        ctx.auth_token = context.get_auth_token()
        ctx.service_catalog = json.dumps(keystone.service_catalog_from_auth(ctx.auth_plugin))
Ejemplo n.º 12
0
def use_os_admin_auth_token(cluster):
    '''Set the current context to the admin user's trust scoped token

    This will configure the current context to the admin user's identity
    with the cluster's tenant. It will also generate an authentication token
    based on the admin user and a delegated trust associated with the
    cluster.

    :param cluster: The cluster to use for tenant and trust identification.

    '''
    ctx = context.current()
    cluster = conductor.cluster_get(ctx, cluster)
    if CONF.use_identity_api_v3 and cluster.trust_id:
        ctx.username = CONF.keystone_authtoken.admin_user
        ctx.tenant_id = cluster.tenant_id
        ctx.auth_plugin = keystone.auth_for_admin(trust_id=cluster.trust_id)
        ctx.auth_token = context.get_auth_token()
        ctx.service_catalog = json.dumps(
            keystone.service_catalog_from_auth(ctx.auth_plugin))
Ejemplo n.º 13
0
def auth():
    '''Return a token auth plugin for the current context.'''
    ctx = context.current()
    return ctx.auth_plugin or token_auth(token=context.get_auth_token(),
                                         project_id=ctx.tenant_id)
Ejemplo n.º 14
0
def auth():
    '''Return a token auth plugin for the current context.'''
    ctx = context.current()
    return ctx.auth_plugin or token_auth(token=context.get_auth_token(),
                                         project_id=ctx.tenant_id)