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


Python loading.load_auth_from_conf_options方法代碼示例

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


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

示例1: _get_auth

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def _get_auth(self):
        if self.context.auth_token_info:
            access_info = ka_access.create(body=self.context.auth_token_info,
                                           auth_token=self.context.auth_token)
            auth = ka_access_plugin.AccessInfoPlugin(access_info)
        elif self.context.auth_token:
            auth = ka_v3.Token(auth_url=self.auth_url,
                               token=self.context.auth_token)
        elif self.context.is_admin:
            auth = ka_loading.load_auth_from_conf_options(CONF,
                                                          ksconf.CFG_GROUP)
        else:
            msg = ('Keystone API connection failed: no password, '
                   'trust_id or token found.')
            LOG.error(msg)
            raise exception.AuthorizationFailure(client='keystone',
                                                 message='reason %s' % msg)

        return auth 
開發者ID:openstack,項目名稱:zun,代碼行數:21,代碼來源:keystone.py

示例2: get_admin_session

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def get_admin_session():
    """Returns a keystone session from Mistral's service credentials."""
    if CONF.keystone_authtoken.auth_type is None:
        auth = auth_plugins.Password(
            CONF.keystone_authtoken.www_authenticate_uri,
            username=CONF.keystone_authtoken.admin_user,
            password=CONF.keystone_authtoken.admin_password,
            project_name=CONF.keystone_authtoken.admin_tenant_name,
            # NOTE(jaosorior): Once mistral supports keystone v3 properly, we
            # can fetch the following values from the configuration.
            user_domain_name='Default',
            project_domain_name='Default')

        return ks_session.Session(auth=auth)
    else:
        auth = loading.load_auth_from_conf_options(
            CONF,
            'keystone_authtoken'
        )

        return loading.load_session_from_conf_options(
            CONF,
            'keystone',
            auth=auth
        ) 
開發者ID:openstack,項目名稱:mistral-extra,代碼行數:27,代碼來源:keystone.py

示例3: __init__

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def __init__(self, **kwargs):
        super(MonascaCollector, self).__init__(**kwargs)

        self.auth = ks_loading.load_auth_from_conf_options(
            CONF,
            COLLECTOR_MONASCA_OPTS)
        self.session = ks_loading.load_session_from_conf_options(
            CONF,
            COLLECTOR_MONASCA_OPTS,
            auth=self.auth)
        self.ks_client = ks_client.Client(
            session=self.session,
            interface=CONF.collector_monasca.interface,
        )
        self.mon_endpoint = self._get_monasca_endpoint()
        if not self.mon_endpoint:
            raise EndpointNotFound()
        self._conn = mclient.Client(
            api_version=MONASCA_API_VERSION,
            session=self.session,
            endpoint=self.mon_endpoint)

    # NOTE(lukapeschke) This function should be removed as soon as the endpoint
    # it no longer required by monascaclient 
開發者ID:openstack,項目名稱:cloudkitty,代碼行數:26,代碼來源:monasca.py

示例4: __init__

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def __init__(self, **kwargs):
        super(GnocchiStorage, self).__init__(**kwargs)
        conf = kwargs.get('conf') or ck_utils.load_conf(
            CONF.collect.metrics_conf)
        self.conf = validate_conf(conf)
        self.auth = ks_loading.load_auth_from_conf_options(
            CONF,
            GNOCCHI_STORAGE_OPTS)
        self.session = ks_loading.load_session_from_conf_options(
            CONF,
            GNOCCHI_STORAGE_OPTS,
            auth=self.auth)
        self._conn = gclient.Client(
            '1',
            session=self.session,
            adapter_options={'connect_retries': 3,
                             'interface': CONF.storage_gnocchi.interface})
        self._archive_policy_name = (
            CONF.storage_gnocchi.archive_policy_name)
        self._archive_policy_definition = json.loads(
            CONF.storage_gnocchi.archive_policy_definition)
        self._period = kwargs.get('period') or CONF.collect.period
        self._measurements = dict()
        self._resource_type_data = dict()
        self._init_resource_types() 
開發者ID:openstack,項目名稱:cloudkitty,代碼行數:27,代碼來源:gnocchi.py

示例5: _get_ks_session

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def _get_ks_session():
    # Establishes a keystone session
    try:
        auth = loading.load_auth_from_conf_options(CONF, "keystone_authtoken")
        return session.Session(auth=auth)
    except exc.AuthorizationFailure as aferr:
        LOG.error('Could not authorize against keystone: %s',
                  str(aferr))
        raise AppError(
            title='Could not authorize Shipyard against Keystone',
            description=(
                'Keystone has rejected the authorization request by Shipyard'
            ),
            status=falcon.HTTP_500,
            retry=False
        ) 
開發者ID:airshipit,項目名稱:shipyard,代碼行數:18,代碼來源:service_endpoints.py

示例6: _create_client

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def _create_client(self):
        """Create the HTTP session accessing the placement service."""
        # Flush _resource_providers and aggregates so we start from a
        # clean slate.
        self._resource_providers = {}
        self._provider_aggregate_map = {}
        # TODO(lajoskatona): perhaps not the best to override config options,
        # actually the abused keystoneauth1 options are:
        # auth_type (used for deciding for NoAuthClient) and auth_section
        # (used for communicating the url for the NoAuthClient)
        if self._conf.placement.auth_type == 'noauth':
            return NoAuthClient(self._conf.placement.auth_section)
        else:
            auth_plugin = keystone.load_auth_from_conf_options(
                self._conf, 'placement')
            return keystone.load_session_from_conf_options(
                self._conf, 'placement', auth=auth_plugin,
                additional_headers={'accept': 'application/json'}) 
開發者ID:openstack,項目名稱:neutron-lib,代碼行數:20,代碼來源:client.py

示例7: get_os_admin_session

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def get_os_admin_session():
    """Create a context to interact with OpenStack as an administrator."""
    # NOTE(ft): this is a singletone because keystone's session looks thread
    # safe for both regular and token renewal requests
    global _admin_session
    if not _admin_session:
        auth_plugin = ks_loading.load_auth_from_conf_options(
            CONF, GROUP_AUTHTOKEN)
        _admin_session = ks_loading.load_session_from_conf_options(
            CONF, GROUP_AUTHTOKEN, auth=auth_plugin)

    return _admin_session 
開發者ID:openstack,項目名稱:ec2-api,代碼行數:14,代碼來源:clients.py

示例8: get_auth

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def get_auth(self):
        if not self._auth:
            self._auth = ks_loading.load_auth_from_conf_options(
                cfg.CONF, self.section)
        return self._auth 
開發者ID:openstack,項目名稱:octavia,代碼行數:7,代碼來源:keystone.py

示例9: get_keystone_session

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def get_keystone_session():
    auth = loading.load_auth_from_conf_options(cfg.CONF, "keystone_authtoken")
    return session.Session(auth=auth) 
開發者ID:airshipit,項目名稱:armada,代碼行數:5,代碼來源:keystone.py

示例10: _get_trusts_auth_plugin

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def _get_trusts_auth_plugin(trust_id=None):
    return loading.load_auth_from_conf_options(
        CONF, TRUSTEE_CONF_GROUP, trust_id=trust_id) 
開發者ID:cloudbase,項目名稱:vdi-broker,代碼行數:5,代碼來源:keystone.py

示例11: _get_session

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def _get_session():
    global _session
    if not _session:
        auth = ka_loading.load_auth_from_conf_options(CONF, GROUP)
        _session = ka_loading.load_session_from_conf_options(
            CONF, GROUP, auth=auth)
    return _session 
開發者ID:openstack,項目名稱:searchlight,代碼行數:9,代碼來源:openstack_clients.py

示例12: _get_auth

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def _get_auth(self):
        if self.context.auth_token_info:
            access_info = ka_access.create(body=self.context.auth_token_info,
                                           auth_token=self.context.auth_token)
            auth = ka_access_plugin.AccessInfoPlugin(access_info)
        elif self.context.auth_token:
            auth = ka_v3.Token(auth_url=self.auth_url,
                               token=self.context.auth_token)
        elif self.context.trust_id:
            auth_info = {
                'auth_url': self.auth_url,
                'username': self.context.user_name,
                'password': self.context.password,
                'user_domain_id': self.context.user_domain_id,
                'user_domain_name': self.context.user_domain_name,
                'trust_id': self.context.trust_id
            }

            auth = ka_v3.Password(**auth_info)
        elif self.context.is_admin:
            try:
                auth = ka_loading.load_auth_from_conf_options(
                    CONF, ksconf.CFG_GROUP)
            except ka_exception.MissingRequiredOptions:
                auth = self._get_legacy_auth()
        else:
            msg = ('Keystone API connection failed: no password, '
                   'trust_id or token found.')
            LOG.error(msg)
            raise exception.AuthorizationFailure(client='keystone',
                                                 message='reason %s' % msg)

        return auth 
開發者ID:openstack,項目名稱:magnum,代碼行數:35,代碼來源:keystone.py

示例13: test_get_client_admin_true

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def test_get_client_admin_true(self):
        mock_load_session = self.mock_object(auth,
                                             'load_session_from_conf_options')

        self.auth.get_client(self.context, admin=True)

        mock_load_session.assert_called_once_with(client_auth.CONF,
                                                  'foo_group')
        self.fake_client.assert_called_once_with(
            session=mock_load_session(),
            auth=auth.load_auth_from_conf_options(
                client_auth.CONF, 'foo_group')) 
開發者ID:openstack,項目名稱:manila,代碼行數:14,代碼來源:test_client_auth.py

示例14: test_load_auth_plugin_no_auth

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def test_load_auth_plugin_no_auth(self):
        auth.load_auth_from_conf_options.return_value = None

        self.assertRaises(fake_client_exception_class.Unauthorized,
                          self.auth._load_auth_plugin) 
開發者ID:openstack,項目名稱:manila,代碼行數:7,代碼來源:test_client_auth.py

示例15: _load_auth_plugin

# 需要導入模塊: from keystoneauth1 import loading [as 別名]
# 或者: from keystoneauth1.loading import load_auth_from_conf_options [as 別名]
def _load_auth_plugin(self):
        if self.admin_auth:
            return self.admin_auth
        self.auth_plugin = ks_loading.load_auth_from_conf_options(
            CONF, self.group)

        if self.auth_plugin:
            return self.auth_plugin

        msg = _('Cannot load auth plugin for %s') % self.group
        raise self.exception_module.Unauthorized(message=msg) 
開發者ID:openstack,項目名稱:manila,代碼行數:13,代碼來源:client_auth.py


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