当前位置: 首页>>代码示例>>Python>>正文


Python base.url_for函数代码示例

本文整理汇总了Python中sahara.utils.openstack.base.url_for函数的典型用法代码示例。如果您正苦于以下问题:Python url_for函数的具体用法?Python url_for怎么用?Python url_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了url_for函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_cinder_exists

def check_cinder_exists():
    service_type = 'volumev2'
    try:
        base.url_for(context.current().service_catalog, service_type,
                     endpoint_type=CONF.cinder.endpoint_type)
        return True
    except ex.SystemError:
        return False
开发者ID:Chinmoy-Dey,项目名称:sahara,代码行数:8,代码来源:cinder.py

示例2: check_cinder_exists

def check_cinder_exists():
    if CONF.cinder.api_version == 1:
        service_type = 'volume'
    else:
        service_type = 'volumev2'
    try:
        base.url_for(context.current().service_catalog, service_type)
        return True
    except ex.SystemError:
        return False
开发者ID:YongchaoTIAN,项目名称:sahara,代码行数:10,代码来源:cinder.py

示例3: check_cinder_exists

def check_cinder_exists():
    if CONF.cinder.api_version == 2:
        service_type = 'volumev2'
    else:
        service_type = 'volumev3'
    try:
        base.url_for(context.current().service_catalog, service_type,
                     endpoint_type=CONF.cinder.endpoint_type)
        return True
    except keystone_exceptions.EndpointNotFound:
        return False
开发者ID:openstack,项目名称:sahara,代码行数:11,代码来源:cinder.py

示例4: client

def client():
    ctx = context.current()
    if CONF.cinder_api_version == 1:
        volume_url = base.url_for(ctx.service_catalog, 'volume')
        cinder = cinder_client_v1.Client(ctx.username, ctx.token,
                                         ctx.tenant_id, volume_url)
    else:
        volume_url = base.url_for(ctx.service_catalog, 'volumev2')
        cinder = cinder_client_v2.Client(ctx.username, ctx.token,
                                         ctx.tenant_id, volume_url)

    cinder.client.auth_token = ctx.token
    cinder.client.management_url = volume_url

    return cinder
开发者ID:a9261,项目名称:sahara,代码行数:15,代码来源:cinder.py

示例5: client

def client():
    ctx = context.ctx()
    session = sessions.cache().get_heat_session()
    heat_url = base.url_for(ctx.service_catalog, 'orchestration',
                            endpoint_type=CONF.heat.endpoint_type)
    return heat_client.Client(
        '1', endpoint=heat_url, session=session, auth=keystone.auth(),
        region_name=CONF.os_region_name)
开发者ID:openstack,项目名称:sahara,代码行数:8,代码来源:heat.py

示例6: client

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=ctx.auth_token,
                              cert_file=CONF.heat.ca_file,
                              insecure=CONF.heat.api_insecure,
                              username=ctx.username,
                              include_pass=True)
开发者ID:crobby,项目名称:sahara,代码行数:9,代码来源:heat.py

示例7: client

def client():
    ctx = context.ctx()
    args = {
        'username': ctx.username,
        'tenant_name': ctx.tenant_name,
        'tenant_id': ctx.tenant_id,
        'token': ctx.token,
        'endpoint_url': base.url_for(ctx.service_catalog, 'network')
    }
    return neutron_cli.Client('2.0', **args)
开发者ID:AspirinSJL,项目名称:sahara,代码行数:10,代码来源:neutron.py

示例8: client

def client():
    ctx = context.current()
    args = {
        'insecure': CONF.cinder.api_insecure,
        'cacert': CONF.cinder.ca_file
    }
    if CONF.cinder.api_version == 1:
        volume_url = base.url_for(ctx.service_catalog, 'volume')
        cinder = cinder_client_v1.Client(ctx.username, ctx.auth_token,
                                         ctx.tenant_id, volume_url, **args)
    else:
        volume_url = base.url_for(ctx.service_catalog, 'volumev2')
        cinder = cinder_client_v2.Client(ctx.username, ctx.auth_token,
                                         ctx.tenant_id, volume_url, **args)

    cinder.client.auth_token = ctx.auth_token
    cinder.client.management_url = volume_url

    return cinder
开发者ID:YongchaoTIAN,项目名称:sahara,代码行数:19,代码来源:cinder.py

示例9: get_neutron_info

    def get_neutron_info(self):
        neutron_info = h.HashableDict()
        neutron_info['network'] = (
            self.instance.node_group.cluster.neutron_management_network)
        ctx = context.current()
        neutron_info['uri'] = base.url_for(ctx.service_catalog, 'network')
        neutron_info['token'] = ctx.token
        neutron_info['tenant'] = ctx.tenant_name
        neutron_info['host'] = self.instance.management_ip

        LOG.debug('Returning neutron info: {0}'.format(neutron_info))
        return neutron_info
开发者ID:viplav,项目名称:sahara,代码行数:12,代码来源:ssh_remote.py

示例10: client

def client():
    ctx = context.current()
    volume_url = base.url_for(ctx.service_catalog, 'volume')

    cinder = cinder_client.Client(ctx.username,
                                  ctx.token,
                                  ctx.tenant_id, volume_url)

    cinder.client.auth_token = ctx.token
    cinder.client.management_url = volume_url

    return cinder
开发者ID:AspirinSJL,项目名称:sahara,代码行数:12,代码来源:cinder.py

示例11: client

def client():
    ctx = context.ctx()
    args = {
        'username': ctx.username,
        'tenant_name': ctx.tenant_name,
        'tenant_id': ctx.tenant_id,
        'token': ctx.auth_token,
        'endpoint_url': base.url_for(ctx.service_catalog, 'network'),
        'ca_cert': CONF.neutron.ca_file,
        'insecure': CONF.neutron.api_insecure
    }
    return neutron_cli.Client('2.0', **args)
开发者ID:AllenFromMinneapolis,项目名称:sahara,代码行数:12,代码来源:neutron.py

示例12: _etc_hosts_for_services

def _etc_hosts_for_services(hosts):
    # add alias for keystone and swift
    for service in ["identity", "object-store"]:
        try:
            hostname = parse.urlparse(
                auth_base.url_for(service_type=service,
                                  endpoint_type="publicURL")).hostname
        except keystone_ex.EndpointNotFound:
            LOG.debug("Endpoint not found for service: \"%s\"", service)
            continue
        hosts += "%s %s\n" % (socket.gethostbyname(hostname), hostname)
    return hosts
开发者ID:Imperat,项目名称:sahara,代码行数:12,代码来源:cluster.py

示例13: client_from_token

def client_from_token(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"),
                                  preauthtoken=token,
                                  retries=CONF.retries.retries_number,
                                  retry_on_ratelimit=True,
                                  starting_backoff=CONF.retries.retry_after,
                                  max_backoff=CONF.retries.retry_after)
开发者ID:rsaha,项目名称:sahara,代码行数:12,代码来源:swift.py

示例14: get_neutron_info

    def get_neutron_info(self, instance=None):
        if not instance:
            instance = self.instance
        neutron_info = h.HashableDict()
        neutron_info['network'] = instance.cluster.neutron_management_network
        ctx = context.current()
        neutron_info['uri'] = base.url_for(ctx.service_catalog, 'network')
        neutron_info['token'] = ctx.auth_token
        neutron_info['tenant'] = ctx.tenant_name
        neutron_info['host'] = instance.management_ip

        LOG.debug('Returning neutron info: {info}'.format(info=neutron_info))
        return neutron_info
开发者ID:AlexanderYAPPO,项目名称:sahara,代码行数:13,代码来源:ssh_remote.py

示例15: client

def client():
    ctx = context.ctx()
    args = {
        'username': ctx.username,
        'project_name': ctx.tenant_name,
        'project_id': ctx.tenant_id,
        'input_auth_token': ctx.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(CONF.manila.api_version, **args)
开发者ID:rsaha,项目名称:sahara,代码行数:13,代码来源:manila.py


注:本文中的sahara.utils.openstack.base.url_for函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。