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


Python loading.get_plugin_loader方法代码示例

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


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

示例1: __init__

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def __init__(self, host='127.0.0.1', version='2', port=None, user='root', password=None, debug=False, project=None,
                 domain='Default', auth_url=None, ca_file=None):
        self.debug = debug
        self.host = host
        loader = loading.get_plugin_loader('password')
        auth = loader.load_from_options(auth_url=auth_url, username=user, password=password, project_name=project,
                                        user_domain_name=domain, project_domain_name=domain)
        sess = session.Session(auth=auth, verify=ca_file)
        self.nova = novaclient.Client(version, session=sess)
        self.glance = glanceclient(version, session=sess)
        self.cinder = cinderclient.Client(version, session=sess)
        self.neutron = neutronclient(session=sess)
        self.conn = self.nova
        self.project = project
        return

# should cleanly close your connection, if needed 
开发者ID:karmab,项目名称:kcli,代码行数:19,代码来源:__init__.py

示例2: __init__

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def __init__(self, cloud):
        self._cloud=cloud
        self._credential=cloud.platform_credential
        auth=loading.get_plugin_loader('password').load_from_options(
            auth_url=self._credential['auth_url'],
            username=self._credential['username'],
            password=self._credential['password'],
            project_name=self._credential['project_name']
        )
        kwargs={
            'version': self._credential['api_version'],
            'session': session.Session(auth=auth)
        }
        self._nova_client=nova_client.Client(**kwargs)
        self._cinder_client=cinder_client.Client(**kwargs)
        self._glance_client=glance_client.Client(**kwargs)
        self.instances=InstanceManager(self)
        self.volumes=VolumeManager(self)
        self.flavors=self._nova_client.flavors
        self.keypairs=self._nova_client.keypairs#create, delete
        self.images=self._glance_client.images 
开发者ID:cas-packone,项目名称:packone,代码行数:23,代码来源:openstack.py

示例3: add_auth_options

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def add_auth_options(options, service_type):
    def add_options(opts, opts_to_add):
        for new_opt in opts_to_add:
            for opt in opts:
                if opt.name == new_opt.name:
                    break
            else:
                opts.append(new_opt)

    opts = copy.deepcopy(options)
    opts.insert(0, loading.get_auth_common_conf_options()[0])
    # NOTE(dims): There are a lot of auth plugins, we just generate
    # the config options for a few common ones
    plugins = ['password', 'v2password', 'v3password']
    for name in plugins:
        plugin = loading.get_plugin_loader(name)
        add_options(opts, loading.get_auth_plugin_conf_options(plugin))
    add_options(opts, loading.get_session_conf_options())
    adapter_opts = loading.get_adapter_conf_options(
        include_deprecated=False)
    cfg.set_defaults(adapter_opts, service_type=service_type,
                     valid_interfaces=DEFAULT_VALID_INTERFACES)
    add_options(opts, adapter_opts)
    opts.sort(key=lambda x: x.name)
    return opts 
开发者ID:openstack,项目名称:ironic-inspector,代码行数:27,代码来源:keystone.py

示例4: create_trust

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def create_trust(ctxt):
    LOG.debug("Creating Keystone trust")

    trusts_auth_plugin = _get_trusts_auth_plugin()

    loader = loading.get_plugin_loader("v3token")
    auth = loader.load_from_options(
        auth_url=trusts_auth_plugin.auth_url,
        token=ctxt.auth_token,
        project_name=ctxt.project_name,
        project_domain_name=ctxt.project_domain)
    session = ks_session.Session(
        auth=auth, verify=not CONF.keystone.allow_untrusted)

    try:
        trustee_user_id = trusts_auth_plugin.get_user_id(session)
    except ks_exceptions.Unauthorized as ex:
        LOG.exception(ex)
        raise exception.NotAuthorized("Trustee authentication failed")

    trustor_user_id = ctxt.user
    trustor_proj_id = ctxt.tenant
    roles = ctxt.roles

    LOG.debug("Granting Keystone trust. Trustor: %(trustor_user_id)s, trustee:"
              " %(trustee_user_id)s, project: %(trustor_proj_id)s, roles:"
              " %(roles)s",
              {"trustor_user_id": trustor_user_id,
               "trustee_user_id": trustee_user_id,
               "trustor_proj_id": trustor_proj_id,
               "roles": roles})

    # Trusts are not supported before Keystone v3
    client = kc_v3.Client(session=session)
    trust = client.trusts.create(trustor_user=trustor_user_id,
                                 trustee_user=trustee_user_id,
                                 project=trustor_proj_id,
                                 impersonation=True,
                                 role_names=roles)
    LOG.debug("Trust id: %s" % trust.id)
    return trust.id 
开发者ID:cloudbase,项目名称:vdi-broker,代码行数:43,代码来源:keystone.py

示例5: _get_session

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def _get_session(self, auth_args):
        """ Return Keystone API session object."""
        loader = loading.get_plugin_loader('password')
        auth = loader.load_from_options(**auth_args)
        sess = session.Session(auth=auth)

        return sess 
开发者ID:ntt-sic,项目名称:masakari,代码行数:9,代码来源:masakari_util.py

示例6: os_connect

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def os_connect(os_creds: OSCreds, version: str = "2") -> OSConnection:
    loader = loading.get_plugin_loader('password')
    auth = loader.load_from_options(auth_url=os_creds.auth_url,
                                    username=os_creds.name,
                                    password=os_creds.passwd,
                                    project_id=os_creds.tenant)
    auth_sess = session.Session(auth=auth)

    glance = GlanceClient(version, session=auth_sess)
    nova = NovaClient(version, session=auth_sess)
    cinder = CinderClient(os_creds.name, os_creds.passwd, os_creds.tenant, os_creds.auth_url,
                          insecure=os_creds.insecure, api_version=version)
    return OSConnection(nova, cinder, glance) 
开发者ID:Mirantis,项目名称:disk_perf_test_tool,代码行数:15,代码来源:openstack_api.py

示例7: _get_auth_loader

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def _get_auth_loader(self, config):
        # Use the 'none' plugin for variants of None specified,
        # since it does not look up endpoints or tokens but rather
        # does a passthrough. This is useful for things like Ironic
        # that have a keystoneless operational mode, but means we're
        # still dealing with a keystoneauth Session object, so all the
        # _other_ things (SSL arg handling, timeout) all work consistently
        if config['auth_type'] in (None, "None", ''):
            config['auth_type'] = 'none'
        elif config['auth_type'] == 'token_endpoint':
            # Humans have been trained to use a thing called token_endpoint
            # That it does not exist in keystoneauth is irrelvant- it not
            # doing what they want causes them sorrow.
            config['auth_type'] = 'admin_token'
        return loading.get_plugin_loader(config['auth_type']) 
开发者ID:openstack,项目名称:openstacksdk,代码行数:17,代码来源:loader.py

示例8: get_session

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def get_session(self):
       loader = loading.get_plugin_loader('password')
       auth = loader.load_from_options(auth_url            = self.openstack['auth_url'],
                                       username            = self.openstack['username'],
                                       password            = self.openstack['password'],
                                       project_name        = self.openstack['project_name'],
                                       user_domain_name    = self.openstack['user_domain_name'],
                                       project_domain_name = self.openstack['project_domain_name'],
                                       )

       return  session.Session(auth   = auth,
                               verify = self.openstack['cacert'],
               ) 
开发者ID:cirrax,项目名称:openstack-nagios-plugins,代码行数:15,代码来源:openstacknagios.py

示例9: _set_session

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def _set_session(self):
        self.session = session.Session()
        loader = loading.get_plugin_loader('password')
        self.session.auth = loader.load_from_options(
            auth_url=self.identity_url, username='xx', password='xx') 
开发者ID:openstack,项目名称:tacker,代码行数:7,代码来源:client.py

示例10: create_session

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def create_session(self, user_id, password):
        user = self.get_user(user_id)
        loader = loading.get_plugin_loader('password')
        auth = loader.load_from_options(
            auth_url=CONF.watcher_clients_auth.auth_url,
            password=password,
            user_id=user_id,
            project_id=user.default_project_id)
        return session.Session(auth=auth) 
开发者ID:openstack,项目名称:watcher,代码行数:11,代码来源:keystone_helper.py

示例11: get_keystone_session

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def get_keystone_session():

    auth_details = {}
    auth_details['auth_url'] = CONF.keystone.auth_url
    auth_details['username'] = CONF.keystone.username
    auth_details['password'] = CONF.keystone.password
    auth_details['project_name'] = CONF.keystone.project_name
    auth_details['user_domain_name'] = CONF.keystone.user_domain_name
    auth_details['project_domain_name'] = CONF.keystone.project_domain_name
    loader = kaloading.get_plugin_loader('password')
    auth_plugin = loader.load_from_options(**auth_details)
    session = kaloading.session.Session().load_from_options(
        auth=auth_plugin)
    return session 
开发者ID:openstack,项目名称:monasca-notification,代码行数:16,代码来源:utils.py

示例12: new_client

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def new_client(self):
        self.session = session.Session()
        loader = loading.get_plugin_loader('password')
        self.session.auth = loader.load_from_options(
            auth_url=self.identity_url, username='xx', password='xx')

        return proxy_client.Client(service_type='nfv-orchestration',
                                   interface='public',
                                   endpoint_type='public',
                                   region_name='RegionOne',
                                   auth_url=self.identity_url,
                                   token=self.token.token_id,
                                   endpoint_url=TACKER_URL) 
开发者ID:openstack,项目名称:python-tackerclient,代码行数:15,代码来源:client.py

示例13: create_trust

# 需要导入模块: from keystoneauth1 import loading [as 别名]
# 或者: from keystoneauth1.loading import get_plugin_loader [as 别名]
def create_trust(ctxt):
    if ctxt.trust_id:
        return

    LOG.debug("Creating Keystone trust")

    trusts_auth_plugin = _get_trusts_auth_plugin()

    loader = loading.get_plugin_loader("v3token")
    auth = loader.load_from_options(
        auth_url=trusts_auth_plugin.auth_url,
        token=ctxt.auth_token,
        project_name=ctxt.project_name,
        project_domain_name=ctxt.project_domain_name)
    session = ks_session.Session(
        auth=auth, verify=not CONF.keystone.allow_untrusted)

    try:
        trustee_user_id = trusts_auth_plugin.get_user_id(session)
    except ks_exceptions.Unauthorized as ex:
        LOG.exception(ex)
        raise exception.NotAuthorized("Trustee authentication failed")

    trustor_user_id = ctxt.user
    trustor_proj_id = ctxt.tenant
    roles = ctxt.roles

    LOG.debug("Granting Keystone trust. Trustor: %(trustor_user_id)s, trustee:"
              " %(trustee_user_id)s, project: %(trustor_proj_id)s, roles:"
              " %(roles)s",
              {"trustor_user_id": trustor_user_id,
               "trustee_user_id": trustee_user_id,
               "trustor_proj_id": trustor_proj_id,
               "roles": roles})

    # Trusts are not supported before Keystone v3
    client = kc_v3.Client(session=session)
    trust = client.trusts.create(trustor_user=trustor_user_id,
                                 trustee_user=trustee_user_id,
                                 project=trustor_proj_id,
                                 impersonation=True,
                                 role_names=roles)
    LOG.debug("Trust id: %s" % trust.id)
    ctxt.trust_id = trust.id 
开发者ID:cloudbase,项目名称:coriolis,代码行数:46,代码来源:keystone.py


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