当前位置: 首页>>代码示例>>Python>>正文


Python loading.load_session_from_conf_options方法代码示例

本文整理汇总了Python中keystoneauth1.loading.load_session_from_conf_options方法的典型用法代码示例。如果您正苦于以下问题:Python loading.load_session_from_conf_options方法的具体用法?Python loading.load_session_from_conf_options怎么用?Python loading.load_session_from_conf_options使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keystoneauth1.loading的用法示例。


在下文中一共展示了loading.load_session_from_conf_options方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_client

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import load_session_from_conf_options [as 别名]
def get_client(self, context, admin=False, **kwargs):
        """Get's the client with the correct auth/session context

        """
        auth_plugin = None

        if not self.session:
            self.session = ks_loading.load_session_from_conf_options(
                self.conf, self.group)

        if admin or (context.is_admin and not context.auth_token):
            if not self.admin_auth:
                self.admin_auth = self._load_auth_plugin()
            auth_plugin = self.admin_auth
        else:
            # NOTE(mkoderer): Manila basically needs admin clients for
            # it's actions. If needed this must be enhanced later
            raise exception.ManilaException(
                _("Client (%s) is not flagged as admin") % self.group)

        return self.client_class(session=self.session, auth=auth_plugin,
                                 **kwargs) 
开发者ID:openstack,项目名称:manila,代码行数:24,代码来源:client_auth.py

示例2: get_admin_session

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import load_session_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_session_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_session_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: _create_client

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import load_session_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

示例6: _get_session

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import load_session_from_conf_options [as 别名]
def _get_session(self, auth):
        session = ka_loading.load_session_from_conf_options(
            CONF, ksconf.CFG_GROUP, auth=auth)
        return session 
开发者ID:openstack,项目名称:zun,代码行数:6,代码来源:keystone.py

示例7: get_os_admin_session

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import load_session_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_session

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import load_session_from_conf_options [as 别名]
def get_session(self):
        """Initializes a Keystone session.

        :return: a Keystone Session object
        """
        if not self._session:
            self._session = ks_loading.load_session_from_conf_options(
                cfg.CONF, self.section, auth=self.get_auth())

        return self._session 
开发者ID:openstack,项目名称:octavia,代码行数:12,代码来源:keystone.py

示例9: _get_session

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import load_session_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

示例10: get_session

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import load_session_from_conf_options [as 别名]
def get_session():
    """Get a vitrage service credentials auth session."""
    auth_plugin = ka_loading.load_auth_from_conf_options(CONF, CFG_GROUP)
    return ka_loading.load_session_from_conf_options(
        CONF, CFG_GROUP, auth=auth_plugin
    ) 
开发者ID:openstack,项目名称:vitrage,代码行数:8,代码来源:keystone_client.py

示例11: __init__

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import load_session_from_conf_options [as 别名]
def __init__(self):
        self.auth = ks_loading.load_auth_from_conf_options(
            CONF,
            FETCHER_KEYSTONE_OPTS)
        self.session = ks_loading.load_session_from_conf_options(
            CONF,
            FETCHER_KEYSTONE_OPTS,
            auth=self.auth)
        self.admin_ks = kclient.Client(
            version=CONF.fetcher_keystone.keystone_version,
            session=self.session,
            auth_url=self.auth.auth_url) 
开发者ID:openstack,项目名称:cloudkitty,代码行数:14,代码来源:keystone.py

示例12: _get_keystone_session

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import load_session_from_conf_options [as 别名]
def _get_keystone_session(self):
        auth = ka_loading.load_auth_from_conf_options(CONF,
                                                      _CLIENTS_AUTH_GROUP)
        sess = ka_loading.load_session_from_conf_options(CONF,
                                                         _CLIENTS_AUTH_GROUP,
                                                         auth=auth)
        return sess 
开发者ID:openstack,项目名称:watcher,代码行数:9,代码来源:clients.py

示例13: _build_trust

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import load_session_from_conf_options [as 别名]
def _build_trust(self):
        # Get zaqar trustee user ID for trust building
        auth = ks_loading.load_auth_from_conf_options(CONF, 'zaqar')
        session = ks_loading.load_session_from_conf_options(CONF, 'zaqar')
        zaqar_trustee_user_id = session.get_user_id(auth=auth)
        try:
            trust = self.keystone().trust_get_by_trustor(self.user,
                                                         zaqar_trustee_user_id,
                                                         self.project)
            if not trust:
                # Create a trust if no existing one found
                roles = self.notifier_roles
                for role in roles:
                    # Remove 'admin' role from delegated roles list
                    # unless it is the only role user has
                    if role == 'admin' and len(roles) > 1:
                        roles.remove(role)
                trust = self.keystone().trust_create(self.user,
                                                     zaqar_trustee_user_id,
                                                     self.project,
                                                     roles)
        except exc.InternalError as ex:
            LOG.error('Can not build trust between user %(user)s and zaqar '
                      'service user %(zaqar)s for receiver %(receiver)s.',
                      {
                          'user': self.user,
                          'zaqar': zaqar_trustee_user_id,
                          'receiver': self.id
                      })
            raise exc.EResourceCreation(type='trust',
                                        message=str(ex))
        return trust.id 
开发者ID:openstack,项目名称:senlin,代码行数:34,代码来源:message.py

示例14: _get_auth_and_session

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import load_session_from_conf_options [as 别名]
def _get_auth_and_session(confgrp):
    ksa_auth = ks_loading.load_auth_from_conf_options(CONF, confgrp)
    return ks_loading.load_session_from_conf_options(
        CONF, confgrp, auth=ksa_auth) 
开发者ID:openstack,项目名称:cyborg,代码行数:6,代码来源:utils.py

示例15: _session_and_auth

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import load_session_from_conf_options [as 别名]
def _session_and_auth(context):
    # Session is cached, but auth needs to be pulled from context each time.
    global _SESSION

    if not _SESSION:
        _SESSION = ks_loading.load_session_from_conf_options(
            CONF, cyborg.conf.glance.glance_group.name)

    auth = service_auth.get_auth_plugin(context)

    return _SESSION, auth 
开发者ID:openstack,项目名称:cyborg,代码行数:13,代码来源:glance.py


注:本文中的keystoneauth1.loading.load_session_from_conf_options方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。