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


Python cfg.DuplicateOptError方法代码示例

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


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

示例1: __init__

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DuplicateOptError [as 别名]
def __init__(self, conf, backend=None):
        """
        Initialize the Store
        """

        super(Store, self).__init__()

        self.conf = conf
        self.backend_group = backend
        self.store_location_class = None
        self._url_prefix = None

        try:
            if self.OPTIONS is not None:
                group = 'glance_store'
                if self.backend_group:
                    group = self.backend_group
                    if self.MULTI_BACKEND_OPTIONS is not None:
                        self.conf.register_opts(
                            self.MULTI_BACKEND_OPTIONS, group=group)

                self.conf.register_opts(self.OPTIONS, group=group)
        except cfg.DuplicateOptError:
            pass 
开发者ID:openstack,项目名称:glance_store,代码行数:26,代码来源:driver.py

示例2: _create_key_manager

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DuplicateOptError [as 别名]
def _create_key_manager(self):
        self.fixed_key = '1' * 64
        try:
            self.conf.register_opt(cfg.StrOpt('fixed_key'),
                                   group='key_manager')
        except cfg.DuplicateOptError:
            pass
        self.conf.set_override('fixed_key',
                               self.fixed_key,
                               group='key_manager')
        return key_manager.API(self.conf) 
开发者ID:openstack,项目名称:castellan,代码行数:13,代码来源:test_migration_key_manager.py

示例3: Store

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DuplicateOptError [as 别名]
def Store(conf, backend=None):
    group = 'glance_store'
    if backend:
        group = backend
        multi_tenant = getattr(conf, backend).swift_store_multi_tenant
        default_store = conf.glance_store.default_backend
    else:
        default_store = conf.glance_store.default_store
        multi_tenant = conf.glance_store.swift_store_multi_tenant

    # NOTE(dharinic): Multi-tenant store cannot work with swift config
    if multi_tenant:
        if (default_store == 'swift+config' or
                sutils.is_multiple_swift_store_accounts_enabled(
                    conf, backend=backend)):
            msg = _("Swift multi-tenant store cannot be configured to "
                    "work with swift+config. The options "
                    "'swift_store_multi_tenant' and "
                    "'swift_store_config_file' are mutually exclusive. "
                    "If you inted to use multi-tenant swift store, please "
                    "make sure that you have not set a swift configuration "
                    "file with the 'swift_store_config_file' option.")
            raise exceptions.BadStoreConfiguration(store_name="swift",
                                                   reason=msg)
    try:
        conf.register_opts(_SWIFT_OPTS + sutils.swift_opts +
                           buffered.BUFFERING_OPTS, group=group)
    except cfg.DuplicateOptError:
        pass

    if multi_tenant:
        return MultiTenantStore(conf, backend=backend)
    return SingleTenantStore(conf, backend=backend) 
开发者ID:openstack,项目名称:glance_store,代码行数:35,代码来源:store.py

示例4: _safe_register

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DuplicateOptError [as 别名]
def _safe_register(self, opt, group):
        try:
            CONF.register_opt(opt, group=group)
        except cfg.DuplicateOptError:
            pass  # If it's already registered ignore it 
开发者ID:openstack,项目名称:cyborg,代码行数:7,代码来源:configuration.py

示例5: handle_migration

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DuplicateOptError [as 别名]
def handle_migration(conf, key_mgr):
    try:
        conf.register_opt(cfg.StrOpt('fixed_key'), group='key_manager')
    except cfg.DuplicateOptError:
        pass

    if conf.key_manager.fixed_key is not None and \
       not conf.key_manager.backend.endswith('ConfKeyManager'):

        LOG.warning("Using MigrationKeyManager to provide support for legacy"
                    " fixed_key encryption")

        class MigrationKeyManager(type(key_mgr)):
            def __init__(self, configuration):
                self.fixed_key = configuration.key_manager.fixed_key
                self.fixed_key_id = '00000000-0000-0000-0000-000000000000'
                super(MigrationKeyManager, self).__init__(configuration)

            def get(self, context, managed_object_id):
                if managed_object_id == self.fixed_key_id:
                    LOG.debug("Processing request for secret associated"
                              " with fixed_key key ID")

                    if context is None:
                        raise exception.Forbidden()

                    key_bytes = bytes(binascii.unhexlify(self.fixed_key))
                    secret = symmetric_key.SymmetricKey('AES',
                                                        len(key_bytes) * 8,
                                                        key_bytes)
                else:
                    secret = super(MigrationKeyManager, self).get(
                        context, managed_object_id)
                return secret

            def delete(self, context, managed_object_id):
                if managed_object_id == self.fixed_key_id:
                    LOG.debug("Not deleting key associated with"
                              " fixed_key key ID")

                    if context is None:
                        raise exception.Forbidden()
                else:
                    super(MigrationKeyManager, self).delete(context,
                                                            managed_object_id)

        key_mgr = MigrationKeyManager(configuration=conf)

    return key_mgr 
开发者ID:openstack,项目名称:castellan,代码行数:51,代码来源:migration.py


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