本文整理汇总了Python中keystoneclient.auth.identity.v3.Password方法的典型用法代码示例。如果您正苦于以下问题:Python v3.Password方法的具体用法?Python v3.Password怎么用?Python v3.Password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keystoneclient.auth.identity.v3
的用法示例。
在下文中一共展示了v3.Password方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: authenticate_keystone_admin
# 需要导入模块: from keystoneclient.auth.identity import v3 [as 别名]
# 或者: from keystoneclient.auth.identity.v3 import Password [as 别名]
def authenticate_keystone_admin(self, keystone_sentry, user, password,
tenant=None, api_version=None,
keystone_ip=None):
"""Authenticates admin user with the keystone admin endpoint."""
self.log.debug('Authenticating keystone admin...')
unit = keystone_sentry
if not keystone_ip:
keystone_ip = unit.relation('shared-db',
'mysql:shared-db')['private-address']
base_ep = "http://{}:35357".format(keystone_ip.strip().decode('utf-8'))
if not api_version or api_version == 2:
ep = base_ep + "/v2.0"
return keystone_client.Client(username=user, password=password,
tenant_name=tenant, auth_url=ep)
else:
ep = base_ep + "/v3"
auth = keystone_id_v3.Password(
user_domain_name='admin_domain',
username=user,
password=password,
domain_name='admin_domain',
auth_url=ep,
)
sess = keystone_session.Session(auth=auth)
return keystone_client_v3.Client(session=sess)
示例2: get_keystone_client
# 需要导入模块: from keystoneclient.auth.identity import v3 [as 别名]
# 或者: from keystoneclient.auth.identity.v3 import Password [as 别名]
def get_keystone_client(self):
username = cfg.CONF.keystone_authtoken.username
password = cfg.CONF.keystone_authtoken.password
project_name = cfg.CONF.keystone_authtoken.project_name
auth_url = cfg.CONF.keystone_authtoken.auth_url
if not auth_url.endswith('/v3'):
auth_url += '/v3'
user_domain_name = cfg.CONF.keystone_authtoken.user_domain_name
project_domain_name = cfg.CONF.keystone_authtoken.project_domain_name
auth = v3.Password(auth_url=auth_url,
username=username,
password=password,
project_name=project_name,
user_domain_name=user_domain_name,
project_domain_name=project_domain_name)
sess = session.Session(auth=auth)
keystone_client = k_client.Client(session=sess)
return keystone_client
示例3: authenticate_keystone_admin
# 需要导入模块: from keystoneclient.auth.identity import v3 [as 别名]
# 或者: from keystoneclient.auth.identity.v3 import Password [as 别名]
def authenticate_keystone_admin(self, keystone_sentry, user, password,
tenant=None, api_version=None,
keystone_ip=None):
"""Authenticates admin user with the keystone admin endpoint."""
self.log.debug('Authenticating keystone admin...')
if not keystone_ip:
keystone_ip = keystone_sentry.info['public-address']
base_ep = "http://{}:35357".format(keystone_ip.strip().decode('utf-8'))
if not api_version or api_version == 2:
ep = base_ep + "/v2.0"
return keystone_client.Client(username=user, password=password,
tenant_name=tenant, auth_url=ep)
else:
ep = base_ep + "/v3"
auth = keystone_id_v3.Password(
user_domain_name='admin_domain',
username=user,
password=password,
domain_name='admin_domain',
auth_url=ep,
)
sess = keystone_session.Session(auth=auth)
return keystone_client_v3.Client(session=sess)
示例4: __init__
# 需要导入模块: from keystoneclient.auth.identity import v3 [as 别名]
# 或者: from keystoneclient.auth.identity.v3 import Password [as 别名]
def __init__(self, endpoint, **kwargs):
try:
from keystoneclient.v2_0 import client
from keystoneclient.auth.identity import v2
from keystoneclient import session
except ImportError:
if six.PY2:
apt_install(["python-keystoneclient"], fatal=True)
else:
apt_install(["python3-keystoneclient"], fatal=True)
from keystoneclient.v2_0 import client
from keystoneclient.auth.identity import v2
from keystoneclient import session
self.api_version = 2
token = kwargs.get("token", None)
if token:
api = client.Client(endpoint=endpoint, token=token)
else:
auth = v2.Password(username=kwargs.get("username"),
password=kwargs.get("password"),
tenant_name=kwargs.get("tenant_name"),
auth_url=endpoint)
sess = session.Session(auth=auth)
api = client.Client(session=sess)
self.api = api
示例5: _get_keystone_session
# 需要导入模块: from keystoneclient.auth.identity import v3 [as 别名]
# 或者: from keystoneclient.auth.identity.v3 import Password [as 别名]
def _get_keystone_session(self):
auth = auth_identity.Password(
auth_url=cfg.CONF.client.identity_url,
username=cfg.CONF.client.admin_username,
password=cfg.CONF.client.admin_password,
project_name=cfg.CONF.client.admin_tenant,
user_domain_name=cfg.CONF.client.admin_user_domain_name,
project_domain_name=cfg.CONF.client.admin_tenant_domain_name)
return session.Session(auth=auth)
示例6: auth
# 需要导入模块: from keystoneclient.auth.identity import v3 [as 别名]
# 或者: from keystoneclient.auth.identity.v3 import Password [as 别名]
def auth(self):
"""Create a session."""
auth = v3.Password(auth_url=self.authurl, reauthenticate=True,
**self.kwargs)
self.auth_session = session.Session(auth=auth, verify=self.verify)