本文整理汇总了Python中keystoneauth1.loading.get_plugin_loader方法的典型用法代码示例。如果您正苦于以下问题:Python loading.get_plugin_loader方法的具体用法?Python loading.get_plugin_loader怎么用?Python loading.get_plugin_loader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keystoneauth1.loading
的用法示例。
在下文中一共展示了loading.get_plugin_loader方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [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
示例2: __init__
# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def __init__(self, cloud):
self._cloud=cloud
self._credential=cloud.platform_credential
auth=loading.get_plugin_loader('password').load_from_options(
auth_url=self._credential['auth_url'],
username=self._credential['username'],
password=self._credential['password'],
project_name=self._credential['project_name']
)
kwargs={
'version': self._credential['api_version'],
'session': session.Session(auth=auth)
}
self._nova_client=nova_client.Client(**kwargs)
self._cinder_client=cinder_client.Client(**kwargs)
self._glance_client=glance_client.Client(**kwargs)
self.instances=InstanceManager(self)
self.volumes=VolumeManager(self)
self.flavors=self._nova_client.flavors
self.keypairs=self._nova_client.keypairs#create, delete
self.images=self._glance_client.images
示例3: add_auth_options
# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def add_auth_options(options, service_type):
def add_options(opts, opts_to_add):
for new_opt in opts_to_add:
for opt in opts:
if opt.name == new_opt.name:
break
else:
opts.append(new_opt)
opts = copy.deepcopy(options)
opts.insert(0, loading.get_auth_common_conf_options()[0])
# NOTE(dims): There are a lot of auth plugins, we just generate
# the config options for a few common ones
plugins = ['password', 'v2password', 'v3password']
for name in plugins:
plugin = loading.get_plugin_loader(name)
add_options(opts, loading.get_auth_plugin_conf_options(plugin))
add_options(opts, loading.get_session_conf_options())
adapter_opts = loading.get_adapter_conf_options(
include_deprecated=False)
cfg.set_defaults(adapter_opts, service_type=service_type,
valid_interfaces=DEFAULT_VALID_INTERFACES)
add_options(opts, adapter_opts)
opts.sort(key=lambda x: x.name)
return opts
示例4: create_trust
# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def create_trust(ctxt):
LOG.debug("Creating Keystone trust")
trusts_auth_plugin = _get_trusts_auth_plugin()
loader = loading.get_plugin_loader("v3token")
auth = loader.load_from_options(
auth_url=trusts_auth_plugin.auth_url,
token=ctxt.auth_token,
project_name=ctxt.project_name,
project_domain_name=ctxt.project_domain)
session = ks_session.Session(
auth=auth, verify=not CONF.keystone.allow_untrusted)
try:
trustee_user_id = trusts_auth_plugin.get_user_id(session)
except ks_exceptions.Unauthorized as ex:
LOG.exception(ex)
raise exception.NotAuthorized("Trustee authentication failed")
trustor_user_id = ctxt.user
trustor_proj_id = ctxt.tenant
roles = ctxt.roles
LOG.debug("Granting Keystone trust. Trustor: %(trustor_user_id)s, trustee:"
" %(trustee_user_id)s, project: %(trustor_proj_id)s, roles:"
" %(roles)s",
{"trustor_user_id": trustor_user_id,
"trustee_user_id": trustee_user_id,
"trustor_proj_id": trustor_proj_id,
"roles": roles})
# Trusts are not supported before Keystone v3
client = kc_v3.Client(session=session)
trust = client.trusts.create(trustor_user=trustor_user_id,
trustee_user=trustee_user_id,
project=trustor_proj_id,
impersonation=True,
role_names=roles)
LOG.debug("Trust id: %s" % trust.id)
return trust.id
示例5: _get_session
# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def _get_session(self, auth_args):
""" Return Keystone API session object."""
loader = loading.get_plugin_loader('password')
auth = loader.load_from_options(**auth_args)
sess = session.Session(auth=auth)
return sess
示例6: os_connect
# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def os_connect(os_creds: OSCreds, version: str = "2") -> OSConnection:
loader = loading.get_plugin_loader('password')
auth = loader.load_from_options(auth_url=os_creds.auth_url,
username=os_creds.name,
password=os_creds.passwd,
project_id=os_creds.tenant)
auth_sess = session.Session(auth=auth)
glance = GlanceClient(version, session=auth_sess)
nova = NovaClient(version, session=auth_sess)
cinder = CinderClient(os_creds.name, os_creds.passwd, os_creds.tenant, os_creds.auth_url,
insecure=os_creds.insecure, api_version=version)
return OSConnection(nova, cinder, glance)
示例7: _get_auth_loader
# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def _get_auth_loader(self, config):
# Use the 'none' plugin for variants of None specified,
# since it does not look up endpoints or tokens but rather
# does a passthrough. This is useful for things like Ironic
# that have a keystoneless operational mode, but means we're
# still dealing with a keystoneauth Session object, so all the
# _other_ things (SSL arg handling, timeout) all work consistently
if config['auth_type'] in (None, "None", ''):
config['auth_type'] = 'none'
elif config['auth_type'] == 'token_endpoint':
# Humans have been trained to use a thing called token_endpoint
# That it does not exist in keystoneauth is irrelvant- it not
# doing what they want causes them sorrow.
config['auth_type'] = 'admin_token'
return loading.get_plugin_loader(config['auth_type'])
示例8: get_session
# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def get_session(self):
loader = loading.get_plugin_loader('password')
auth = loader.load_from_options(auth_url = self.openstack['auth_url'],
username = self.openstack['username'],
password = self.openstack['password'],
project_name = self.openstack['project_name'],
user_domain_name = self.openstack['user_domain_name'],
project_domain_name = self.openstack['project_domain_name'],
)
return session.Session(auth = auth,
verify = self.openstack['cacert'],
)
示例9: _set_session
# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def _set_session(self):
self.session = session.Session()
loader = loading.get_plugin_loader('password')
self.session.auth = loader.load_from_options(
auth_url=self.identity_url, username='xx', password='xx')
示例10: create_session
# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def create_session(self, user_id, password):
user = self.get_user(user_id)
loader = loading.get_plugin_loader('password')
auth = loader.load_from_options(
auth_url=CONF.watcher_clients_auth.auth_url,
password=password,
user_id=user_id,
project_id=user.default_project_id)
return session.Session(auth=auth)
示例11: get_keystone_session
# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def get_keystone_session():
auth_details = {}
auth_details['auth_url'] = CONF.keystone.auth_url
auth_details['username'] = CONF.keystone.username
auth_details['password'] = CONF.keystone.password
auth_details['project_name'] = CONF.keystone.project_name
auth_details['user_domain_name'] = CONF.keystone.user_domain_name
auth_details['project_domain_name'] = CONF.keystone.project_domain_name
loader = kaloading.get_plugin_loader('password')
auth_plugin = loader.load_from_options(**auth_details)
session = kaloading.session.Session().load_from_options(
auth=auth_plugin)
return session
示例12: new_client
# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def new_client(self):
self.session = session.Session()
loader = loading.get_plugin_loader('password')
self.session.auth = loader.load_from_options(
auth_url=self.identity_url, username='xx', password='xx')
return proxy_client.Client(service_type='nfv-orchestration',
interface='public',
endpoint_type='public',
region_name='RegionOne',
auth_url=self.identity_url,
token=self.token.token_id,
endpoint_url=TACKER_URL)
示例13: create_trust
# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def create_trust(ctxt):
if ctxt.trust_id:
return
LOG.debug("Creating Keystone trust")
trusts_auth_plugin = _get_trusts_auth_plugin()
loader = loading.get_plugin_loader("v3token")
auth = loader.load_from_options(
auth_url=trusts_auth_plugin.auth_url,
token=ctxt.auth_token,
project_name=ctxt.project_name,
project_domain_name=ctxt.project_domain_name)
session = ks_session.Session(
auth=auth, verify=not CONF.keystone.allow_untrusted)
try:
trustee_user_id = trusts_auth_plugin.get_user_id(session)
except ks_exceptions.Unauthorized as ex:
LOG.exception(ex)
raise exception.NotAuthorized("Trustee authentication failed")
trustor_user_id = ctxt.user
trustor_proj_id = ctxt.tenant
roles = ctxt.roles
LOG.debug("Granting Keystone trust. Trustor: %(trustor_user_id)s, trustee:"
" %(trustee_user_id)s, project: %(trustor_proj_id)s, roles:"
" %(roles)s",
{"trustor_user_id": trustor_user_id,
"trustee_user_id": trustee_user_id,
"trustor_proj_id": trustor_proj_id,
"roles": roles})
# Trusts are not supported before Keystone v3
client = kc_v3.Client(session=session)
trust = client.trusts.create(trustor_user=trustor_user_id,
trustee_user=trustee_user_id,
project=trustor_proj_id,
impersonation=True,
role_names=roles)
LOG.debug("Trust id: %s" % trust.id)
ctxt.trust_id = trust.id