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


Python identity.Password方法代碼示例

本文整理匯總了Python中keystoneauth1.identity.Password方法的典型用法代碼示例。如果您正苦於以下問題:Python identity.Password方法的具體用法?Python identity.Password怎麽用?Python identity.Password使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在keystoneauth1.identity的用法示例。


在下文中一共展示了identity.Password方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_zun_client_from_env

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [as 別名]
def get_zun_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(ZUN_API_VERSION, session=session) 
開發者ID:openstack,項目名稱:zun,代碼行數:27,代碼來源:utils.py

示例2: test_client_with_password_legacy

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [as 別名]
def test_client_with_password_legacy(self, mock_v3, mock_loading, mock_ks):
        self.ctx.is_admin = True
        self.ctx.auth_token_info = None
        self.ctx.auth_token = None
        self.ctx.trust_id = None
        mock_loading.load_auth_from_conf_options.side_effect = \
            ka_exception.MissingRequiredOptions(mock.MagicMock())
        ks_client = keystone.KeystoneClientV3(self.ctx)
        ks_client.client
        session = ks_client.session
        self.assertWarnsRegex(Warning,
                              '[keystone_authtoken] section is deprecated')
        mock_v3.Password.assert_called_once_with(
            auth_url='http://server.test:5000/v3', password='varybadpass',
            project_domain_id='default', project_name='service',
            user_domain_id='default', username='magnum')
        mock_ks.assert_called_once_with(session=session, trust_id=None) 
開發者ID:openstack,項目名稱:magnum,代碼行數:19,代碼來源:test_keystone.py

示例3: get_neutron_client_from_env

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [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) 
開發者ID:openstack,項目名稱:kuryr-libnetwork,代碼行數:27,代碼來源:kuryr_base.py

示例4: setUpClass

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [as 別名]
def setUpClass(cls):
        super(WhenTestingClientConnectivity, cls).setUpClass()
        if 'v2' in CONF.identity.auth_version:
            cls.auth = identity.Password(
                auth_url=CONF.identity.uri,
                username=CONF.keymanager.username,
                password=CONF.keymanager.password,
                tenant_name=CONF.keymanager.project_name)
        else:
            cls.auth = identity.Password(
                auth_url=CONF.identity.uri,
                username=CONF.keymanager.username,
                user_domain_name=CONF.identity.domain_name,
                password=CONF.keymanager.password,
                project_name=CONF.keymanager.project_name,
                project_domain_name=CONF.keymanager.project_domain_name)

        # enables the tests in this class to share a keystone token
        cls.sess = session.Session(auth=cls.auth) 
開發者ID:openstack,項目名稱:python-barbicanclient,代碼行數:21,代碼來源:test_client_connectivity.py

示例5: setUp

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [as 別名]
def setUp(self):
        self.LOG.info('Starting: %s', self._testMethodName)
        super(TestCase, self).setUp()

        if 'v2' in CONF.identity.auth_version:
            self.auth = identity.Password(
                auth_url=CONF.identity.uri,
                username=CONF.keymanager.username,
                password=CONF.keymanager.password,
                tenant_name=CONF.keymanager.project_name)
        else:
            self.auth = identity.Password(
                auth_url=CONF.identity.uri,
                username=CONF.keymanager.username,
                user_domain_name=CONF.identity.domain_name,
                password=CONF.keymanager.password,
                project_name=CONF.keymanager.project_name,
                project_domain_name=CONF.keymanager.project_domain_name)

        self.sess = session.Session(auth=self.auth)
        self.barbicanclient = client.Client(
            endpoint=CONF.keymanager.url,
            project_id=CONF.keymanager.project_id,
            session=self.sess) 
開發者ID:openstack,項目名稱:python-barbicanclient,代碼行數:26,代碼來源:base.py

示例6: get_neutron_client

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [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 
開發者ID:Mirantis,項目名稱:kqueen,代碼行數:18,代碼來源:openstack_kubespray.py

示例7: create

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [as 別名]
def create(context, conf, **kwargs):
    register_opts(conf)

    client_config = conf.swift_client
    session = kwargs.get('session', None)

    if not session:
        auth = identity.Password(
            auth_url=client_config.swift_auth_url,
            username=client_config.swift_user,
            password=client_config.swift_key,
            project_name=client_config.swift_tenant_name,
            project_domain_name=client_config.swift_project_domain_name,
            user_domain_name=client_config.swift_user_domain_name,
        )
        session = keystone_session.Session(auth=auth)

    return swift.Connection(
        session=session,
        insecure=client_config.swift_auth_insecure,
        cacert=client_config.swift_ca_cert_file,
        retries=client_config.swift_retry_attempts,
        starting_backoff=client_config.swift_retry_backoff,
    ) 
開發者ID:openstack,項目名稱:karbor,代碼行數:26,代碼來源:swift.py

示例8: get_keystone_client

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [as 別名]
def get_keystone_client():
    auth = Password(**keystone_args_from_env())
    session = Session(auth=auth,
                      app_name='keystone-init',
                      user_agent='keystone-init',
                      timeout=KEYSTONE_TIMEOUT,
                      verify=KEYSTONE_VERIFY,
                      cert=KEYSTONE_CERT)

    discover = Discover(session=session)
    return discover.create_client() 
開發者ID:monasca,項目名稱:monasca-docker,代碼行數:13,代碼來源:keystone_init.py

示例9: session

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [as 別名]
def session(self):
        if not self._session:
            auth_kwargs = dict(auth_url=self.auth_url, username=self.username,
                               password=self.password, project_name=self.tenant)
            if self.keystone_version == 3:
                auth_kwargs.update(dict(user_domain_id=self.domain_id,
                                        project_domain_name=self.domain_id))
            pass_auth = Password(**auth_kwargs)
            self._session = Session(auth=pass_auth, verify=False)
        return self._session 
開發者ID:RedHatQE,項目名稱:wrapanapi,代碼行數:12,代碼來源:openstack.py

示例10: _get_auth_handler

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [as 別名]
def _get_auth_handler(kwargs):
    if 'token' in kwargs:
        auth = identity.Token(
            auth_url=kwargs.get('auth_url', None),
            token=kwargs.get('token', None),
            project_id=kwargs.get('project_id', None),
            project_name=kwargs.get('project_name', None),
            project_domain_id=kwargs.get('project_domain_id', None),
            project_domain_name=kwargs.get('project_domain_name', None)
        )
    elif {'username', 'password'} <= set(kwargs):
        auth = identity.Password(
            auth_url=kwargs.get('auth_url', None),
            username=kwargs.get('username', None),
            password=kwargs.get('password', None),
            project_id=kwargs.get('project_id', None),
            project_name=kwargs.get('project_name', None),
            project_domain_id=kwargs.get('project_domain_id', None),
            project_domain_name=kwargs.get('project_domain_name', None),
            user_domain_id=kwargs.get('user_domain_id', None),
            user_domain_name=kwargs.get('user_domain_name', None)
        )
    else:
        raise Exception('monascaclient can be configured with either '
                        '"token" or "username:password" but neither of '
                        'them was found in passed arguments.')
    return auth 
開發者ID:openstack,項目名稱:python-monascaclient,代碼行數:29,代碼來源:client.py

示例11: test_client_with_password

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [as 別名]
def test_client_with_password(self, mock_ks):
        self.ctx.is_admin = True
        self.ctx.auth_token_info = None
        self.ctx.auth_token = None
        self.ctx.trust_id = None
        ks_client = keystone.KeystoneClientV3(self.ctx)
        ks_client.client
        session = ks_client.session
        auth_plugin = session.auth
        mock_ks.assert_called_once_with(session=session, trust_id=None)
        self.assertIsInstance(auth_plugin, ka_identity.Password) 
開發者ID:openstack,項目名稱:magnum,代碼行數:13,代碼來源:test_keystone.py

示例12: get_client

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [as 別名]
def get_client(client, **kwargs):
    auth = identity.Password(**kwargs)
    sess = session.Session(auth=auth)
    neutron = client(session=sess)
    return neutron 
開發者ID:openstack,項目名稱:dragonflow,代碼行數:7,代碼來源:clients.py

示例13: _get_auth_plugin

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [as 別名]
def _get_auth_plugin(self, **kwargs):
        auth_plugin = v3.Password(**kwargs)

        return auth_plugin 
開發者ID:openstack,項目名稱:tacker,代碼行數:6,代碼來源:openstack_driver.py

示例14: __init__

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [as 別名]
def __init__(self, auth_attr):
        auth_cred = auth_attr.copy()
        verify = 'True' == auth_cred.pop('cert_verify', 'True') or False
        auth = identity.Password(**auth_cred)
        sess = session.Session(auth=auth, verify=verify)
        self.client = neutron_client.Client(session=sess) 
開發者ID:openstack,項目名稱:tacker,代碼行數:8,代碼來源:openstack_driver.py

示例15: create_keystone_session

# 需要導入模塊: from keystoneauth1 import identity [as 別名]
# 或者: from keystoneauth1.identity import Password [as 別名]
def create_keystone_session(
            self, args, api_version, kwargs_dict, auth_type
    ):
        # Make sure we have the correct arguments to function
        self.check_auth_arguments(args, api_version, raise_exc=True)

        kwargs = self.build_kwargs_based_on_version(args, api_version)
        kwargs.update(kwargs_dict)

        _supported_version = _IDENTITY_API_VERSION_2 + _IDENTITY_API_VERSION_3
        if not api_version or api_version not in _supported_version:
            self.stderr.write(
                "WARNING: The identity version <{0}> is not in supported "
                "versions <{1}>, falling back to <{2}>.".format(
                    api_version,
                    _IDENTITY_API_VERSION_2 + _IDENTITY_API_VERSION_3,
                    _DEFAULT_IDENTITY_API_VERSION
                )
            )
        method = identity.Token if auth_type == 'token' else identity.Password

        auth = method(**kwargs)
        cacert = args.os_cacert
        cert = args.os_cert
        key = args.os_key
        insecure = args.insecure
        if insecure:
            verify = False
        else:
            verify = cacert or True
        if cert and key:
            cert = (cert, key)
        return session.Session(auth=auth, verify=verify, cert=cert) 
開發者ID:openstack,項目名稱:python-barbicanclient,代碼行數:35,代碼來源:barbican.py


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