本文整理汇总了Python中neutronclient.v2_0.client.Client方法的典型用法代码示例。如果您正苦于以下问题:Python client.Client方法的具体用法?Python client.Client怎么用?Python client.Client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neutronclient.v2_0.client
的用法示例。
在下文中一共展示了client.Client方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: glance
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def glance(self):
if self._glance:
return self._glance
glanceclient_version = self._get_client_option('glance', 'api_version')
session = self.keystone().session
endpoint_type = self._get_client_option('glance', 'endpoint_type')
region_name = self._get_client_option('glance', 'region_name')
glance_url = self.url_for(service_type='image',
interface=endpoint_type,
region_name=region_name)
self._glance = glanceclient.Client(glanceclient_version,
endpoint=glance_url,
session=session)
return self._glance
示例2: neutron
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def neutron(self):
if self._neutron:
return self._neutron
session = self.keystone().session
if self._get_client_option('neutron', 'ca_file'):
session.verify = self._get_client_option('neutron', 'ca_file')
if self._get_client_option('neutron', 'insecure'):
session.verify = False
endpoint_type = self._get_client_option('neutron', 'endpoint_type')
region_name = self._get_client_option('neutron', 'region_name')
self._neutron = neutronclient.Client(session=session,
endpoint_type=endpoint_type,
region_name=region_name)
return self._neutron
示例3: cinder
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def cinder(self):
if self._cinder:
return self._cinder
session = self.keystone().session
if self._get_client_option('cinder', 'ca_file'):
session.verify = self._get_client_option('cinder', 'ca_file')
if self._get_client_option('cinder', 'insecure'):
session.verify = False
cinder_api_version = self._get_client_option('cinder', 'api_version')
region_name = self._get_client_option('cinder', 'region_name')
endpoint_type = self._get_client_option('cinder', 'endpoint_type')
kwargs = {
'session': self.keystone().session,
'endpoint_type': endpoint_type,
'region_name': region_name,
'cacert': self._get_client_option('cinder', 'ca_file'),
'insecure': self._get_client_option('cinder', 'insecure')
}
self._cinder = cinderclient.Client(version=cinder_api_version,
**kwargs)
return self._cinder
示例4: get_client
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def get_client(context, endpoint):
params = {
'endpoint_url': endpoint,
'timeout': CONF['network_api:neutron'].timeout,
'insecure': CONF['network_api:neutron'].insecure,
'ca_cert': CONF['network_api:neutron'].ca_certificates_file,
}
if context.auth_token:
params['token'] = context.auth_token
params['auth_strategy'] = None
elif CONF['network_api:neutron'].admin_username is not None:
params['username'] = CONF['network_api:neutron'].admin_username
params['project_name'] = CONF['network_api:neutron'].admin_tenant_name
params['password'] = CONF['network_api:neutron'].admin_password
params['auth_url'] = CONF['network_api:neutron'].auth_url
params['auth_strategy'] = CONF['network_api:neutron'].auth_strategy
return clientv20.Client(**params)
示例5: _connect_nova_region
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def _connect_nova_region(self, region_name):
"""Get an OpenStack Nova (compute) client object."""
# Force reauthentication with Keystone
self._cached_keystone_session = None
api_version = self._get_config_value(
'os_compute_api_version',
get_env('OS_COMPUTE_API_VERSION', 2))
service_name = self._get_config_value(
'nova_service_name',
get_env('NOVA_SERVICE_NAME', None))
if self.config.debug_mode:
nova_shell.OpenStackComputeShell().setup_debugging(True)
nova = nova_client.Client(
api_version, session=self._keystone_session,
auth_url=self.auth_url,
region_name=region_name,
service_name=service_name,
http_log_debug=True if self.config.debug_mode else False)
return nova
示例6: _connect_keystone
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def _connect_keystone(self):
"""Get an OpenStack Keystone (identity) client object."""
if self._keystone_version == 3:
return keystone_client.Client(session=self._keystone_session,
auth_url=self.auth_url)
else:
# Wow, the internal keystoneV2 implementation is terribly buggy. It
# needs both a separate Session object and the username, password
# again for things to work correctly. Plus, a manual call to
# authenticate() is also required if the service catalog needs
# to be queried.
keystone = keystone_client.Client(
session=self._keystone_session,
auth_url=self.auth_url,
username=self.username,
password=self.password,
project_name=self.project_name,
region_name=self.region_name)
keystone.authenticate()
return keystone
示例7: get_novaclient
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def get_novaclient():
def do_get_client(api_version=2.1):
session = _get_session()
return nova_client.Client(
version=api_version,
session=session,
region_name=CONF.service_credentials.os_region_name,
endpoint_type=CONF.service_credentials.os_endpoint_type
)
version = CONF["service_credentials:nova"].compute_api_version
# Check whether Nova can support the provided microversion.
max_version = do_get_client().versions.list()[-1].version
if LooseVersion(version) > LooseVersion(max_version) or \
LooseVersion(version) < LooseVersion(NOVA_MIN_API_VERSION):
raise exception.InvalidAPIVersionProvided(
service='compute service', min_version=NOVA_MIN_API_VERSION,
max_version=max_version)
return do_get_client(version)
示例8: heat
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def heat(self):
if self._heat:
return self._heat
endpoint_type = self._get_client_option('heat', 'endpoint_type')
region_name = self._get_client_option('heat', 'region_name')
heatclient_version = self._get_client_option('heat', 'api_version')
endpoint = self.url_for(service_type='orchestration',
interface=endpoint_type,
region_name=region_name)
args = {
'endpoint': endpoint,
'auth_url': self.auth_url,
'token': self.auth_token,
'username': None,
'password': None,
'ca_file': self._get_client_option('heat', 'ca_file'),
'cert_file': self._get_client_option('heat', 'cert_file'),
'key_file': self._get_client_option('heat', 'key_file'),
'insecure': self._get_client_option('heat', 'insecure')
}
self._heat = heatclient.Client(heatclient_version, **args)
return self._heat
示例9: glance
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def glance(self):
if self._glance:
return self._glance
endpoint_type = self._get_client_option('glance', 'endpoint_type')
region_name = self._get_client_option('glance', 'region_name')
glanceclient_version = self._get_client_option('glance', 'api_version')
endpoint = self.url_for(service_type='image',
interface=endpoint_type,
region_name=region_name)
args = {
'endpoint': endpoint,
'auth_url': self.auth_url,
'token': self.auth_token,
'username': None,
'password': None,
'cacert': self._get_client_option('glance', 'ca_file'),
'cert': self._get_client_option('glance', 'cert_file'),
'key': self._get_client_option('glance', 'key_file'),
'insecure': self._get_client_option('glance', 'insecure')
}
self._glance = glanceclient.Client(glanceclient_version, **args)
return self._glance
示例10: nova
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def nova(self):
if self._nova:
return self._nova
endpoint_type = self._get_client_option('nova', 'endpoint_type')
region_name = self._get_client_option('nova', 'region_name')
novaclient_version = self._get_client_option('nova', 'api_version')
endpoint = self.url_for(service_type='compute',
interface=endpoint_type,
region_name=region_name)
args = {
'cacert': self._get_client_option('nova', 'ca_file'),
'insecure': self._get_client_option('nova', 'insecure')
}
session = self.keystone().session
self._nova = novaclient.Client(novaclient_version,
session=session,
endpoint_override=endpoint, **args)
return self._nova
示例11: neutron
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def neutron(self):
if self._neutron:
return self._neutron
endpoint_type = self._get_client_option('neutron', 'endpoint_type')
region_name = self._get_client_option('neutron', 'region_name')
endpoint = self.url_for(service_type='network',
interface=endpoint_type,
region_name=region_name)
args = {
'auth_url': self.auth_url,
'token': self.auth_token,
'endpoint_url': endpoint,
'endpoint_type': endpoint_type,
'ca_cert': self._get_client_option('neutron', 'ca_file'),
'insecure': self._get_client_option('neutron', 'insecure')
}
self._neutron = neutronclient.Client(**args)
return self._neutron
示例12: __init__
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def __init__(self, host='127.0.0.1', version='2', port=None, user='root', password=None, debug=False, project=None,
domain='Default', auth_url=None, ca_file=None):
self.debug = debug
self.host = host
loader = loading.get_plugin_loader('password')
auth = loader.load_from_options(auth_url=auth_url, username=user, password=password, project_name=project,
user_domain_name=domain, project_domain_name=domain)
sess = session.Session(auth=auth, verify=ca_file)
self.nova = novaclient.Client(version, session=sess)
self.glance = glanceclient(version, session=sess)
self.cinder = cinderclient.Client(version, session=sess)
self.neutron = neutronclient(session=sess)
self.conn = self.nova
self.project = project
return
# should cleanly close your connection, if needed
示例13: get_neutron_client_from_env
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def get_neutron_client_from_env():
# We should catch KeyError exception with the purpose of
# source or configure openrc file.
auth_url = os.environ['OS_AUTH_URL']
username = os.environ['OS_USERNAME']
password = os.environ['OS_PASSWORD']
project_name = os.environ['OS_PROJECT_NAME']
# Either project(user)_domain_name or project(user)_domain_id
# would be acceptable.
project_domain_name = os.environ.get("OS_PROJECT_DOMAIN_NAME")
project_domain_id = os.environ.get("OS_PROJECT_DOMAIN_ID")
user_domain_name = os.environ.get("OS_USER_DOMAIN_NAME")
user_domain_id = os.environ.get("OS_USER_DOMAIN_ID")
auth = identity.Password(auth_url=auth_url,
username=username,
password=password,
project_name=project_name,
project_domain_id=project_domain_id,
project_domain_name=project_domain_name,
user_domain_id=user_domain_id,
user_domain_name=user_domain_name)
session = ks.Session(auth=auth)
return client.Client(session=session)
示例14: get_neutron_client
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def get_neutron_client(self):
from keystoneauth1 import identity
from keystoneauth1 import session
from neutronclient.v2_0 import client
auth = identity.Password(
auth_url=self.os_kwargs["auth_url"],
username=self.os_kwargs["username"],
password=self.os_kwargs["password"],
user_domain_name=self.os_kwargs["domain_name"],
project_id=self.os_kwargs["project_id"],
)
sess = session.Session(auth=auth)
neutron = client.Client(session=sess,
region_name=self.os_kwargs["region_name"],
endpoint_type=self.os_kwargs["identity_interface"])
return neutron
示例15: create
# 需要导入模块: from neutronclient.v2_0 import client [as 别名]
# 或者: from neutronclient.v2_0.client import Client [as 别名]
def create(context, conf, **kwargs):
conf.register_opts(neutron_client_opts, group=CONFIG_GROUP)
client_config = conf[CONFIG_GROUP]
url = utils.get_url(SERVICE, context, client_config, **kwargs)
LOG.debug("Creating neutron client with url %s.", url)
if kwargs.get('session'):
return neutron_client.Client(session=kwargs.get('session'),
endpoint_override=url)
args = {
'endpoint_url': url,
'token': context.auth_token,
'cacert': client_config.neutron_ca_cert_file,
'insecure': client_config.neutron_auth_insecure,
}
return neutron_client.Client(**args)