當前位置: 首頁>>代碼示例>>Python>>正文


Python v3.Password方法代碼示例

本文整理匯總了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) 
開發者ID:openstack,項目名稱:charm-plumgrid-gateway,代碼行數:27,代碼來源:utils.py

示例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 
開發者ID:openstack,項目名稱:networking-h3c,代碼行數:22,代碼來源:mechanism_h3c.py

示例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) 
開發者ID:openstack,項目名稱:charm-neutron-api-plumgrid,代碼行數:26,代碼來源:utils.py

示例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 
開發者ID:openstack,項目名稱:charm-swift-proxy,代碼行數:31,代碼來源:keystone.py

示例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) 
開發者ID:openstack,項目名稱:trio2o,代碼行數:11,代碼來源:client.py

示例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) 
開發者ID:openstack,項目名稱:freezer-dr,代碼行數:7,代碼來源:osclient.py


注:本文中的keystoneclient.auth.identity.v3.Password方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。