本文整理汇总了Python中sahara.utils.openstack.base.url_for函数的典型用法代码示例。如果您正苦于以下问题:Python url_for函数的具体用法?Python url_for怎么用?Python url_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了url_for函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: client
def client():
ctx = context.current()
auth_url = base.retrieve_auth_url()
compute_url = base.url_for(ctx.service_catalog, 'compute')
nova = nova_client.Client(username=ctx.username,
api_key=None,
project_id=ctx.tenant_id,
auth_url=auth_url)
nova.client.auth_token = ctx.token
nova.client.management_url = compute_url
nova.images = images.SaharaImageManager(nova)
return nova
开发者ID:AspirinSJL,项目名称:sahara,代码行数:14,代码来源:nova.py
示例17: client_from_token
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='3',
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)
开发者ID:openstack,项目名称:sahara,代码行数:15,代码来源:swift.py
示例18: test_url_for_regions
def test_url_for_regions(self):
service_catalog = (
'[{"endpoints": '
' [{"adminURL": "http://192.168.0.5:8774/v2", '
' "region": "RegionOne", '
' "id": "83d12c9ad2d647ecab7cbe91adb8666b", '
' "internalURL": "http://192.168.0.5:8774/v2", '
' "publicURL": "http://172.18.184.5:8774/v2"}, '
' {"adminURL": "http://192.168.0.6:8774/v2", '
' "region": "RegionTwo", '
' "id": "07c5a555176246c783d8f0497c98537b", '
' "internalURL": "http://192.168.0.6:8774/v2", '
' "publicURL": "http://172.18.184.6:8774/v2"}], '
' "endpoints_links": [], '
' "type": "compute", '
' "name": "nova"}]')
self.override_config("os_region_name", "RegionOne")
self.assertEqual("http://172.18.184.5:8774/v2",
b.url_for(service_catalog, "compute"))
self.override_config("os_region_name", "RegionTwo")
self.assertEqual("http://172.18.184.6:8774/v2",
b.url_for(service_catalog, "compute"))
开发者ID:AspirinSJL,项目名称:sahara,代码行数:24,代码来源:test_base.py
示例19: retrieve_auth_url
def retrieve_auth_url():
"""This function returns auth url v2.0 api.
Hadoop Swift library doesn't support keystone v3 api.
"""
auth_url = clients_base.url_for(context.current().service_catalog,
'identity')
info = urlparse.urlparse(auth_url)
if CONF.use_domain_for_proxy_users:
url = 'v3/auth'
else:
url = 'v2.0'
return '{scheme}://{hostname}:{port}/{url}/'.format(scheme=info.scheme,
hostname=info.hostname,
port=info.port,
url=url)
开发者ID:AlexanderYAPPO,项目名称:sahara,代码行数:18,代码来源:utils.py
示例20: generate_etc_hosts
def generate_etc_hosts(cluster):
hosts = "127.0.0.1 localhost\n"
for node_group in cluster.node_groups:
for instance in node_group.instances:
hosts += "%s %s %s\n" % (instance.internal_ip,
instance.fqdn(),
instance.hostname())
# 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:egafford,项目名称:sahara,代码行数:19,代码来源:cluster.py
注:本文中的sahara.utils.openstack.base.url_for函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论