Python oslo_config.cfg.DictOpt() Examples

The following are 18 code examples of oslo_config.cfg.DictOpt(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module oslo_config.cfg , or try the search function .
Example #1
Source File: default.py    From watcher with Apache License 2.0 6 votes vote down vote up
def get_config_opts(cls):
        return [
            cfg.IntOpt(
                'max_workers',
                default=processutils.get_worker_count(),
                min=1,
                required=True,
                help='Number of workers for taskflow engine '
                     'to execute actions.'),
            cfg.DictOpt(
                'action_execution_rule',
                default={},
                help='The execution rule for linked actions,'
                     'the key is strategy name and '
                     'value ALWAYS means all actions will be executed,'
                     'value ANY means if previous action executes '
                     'success, the next action will be ignored.'
                     'None means ALWAYS.')
            ] 
Example #2
Source File: netns_wrapper.py    From neutron-vpnaas with Apache License 2.0 6 votes vote down vote up
def setup_conf():
    cli_opts = [
        cfg.DictOpt('mount_paths',
                    required=True,
                    help=_('Dict of paths to bind-mount (source:target) '
                           'prior to launch subprocess.')),
        cfg.ListOpt(
            'cmd',
            required=True,
            help=_('Command line to execute as a subprocess '
                   'provided as comma-separated list of arguments.')),
        cfg.StrOpt('rootwrap_config', default='/etc/neutron/rootwrap.conf',
                   help=_('Rootwrap configuration file.')),
    ]
    conf = cfg.CONF
    conf.register_cli_opts(cli_opts)
    return conf 
Example #3
Source File: test_swift_store_multibackend.py    From glance_store with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(TestSingleTenantStoreConnections, self).setUp()
        enabled_backends = {
            "swift1": "swift",
            "swift2": "swift",
        }
        self.conf = self._CONF
        self.conf(args=[])
        self.conf.register_opt(cfg.DictOpt('enabled_backends'))
        self.config(enabled_backends=enabled_backends)
        store.register_store_opts(self.conf)
        self.config(default_backend='swift1', group='glance_store')

        # Ensure stores + locations cleared
        location.SCHEME_TO_CLS_BACKEND_MAP = {}

        store.create_multi_stores(self.conf)
        self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
                        dict())
        self.test_dir = self.useFixture(fixtures.TempDir()).path

        self.useFixture(fixtures.MockPatch(
            'swiftclient.Connection', FakeConnection))
        self.store = swift.SingleTenantStore(self.conf, backend="swift1")
        self.store.configure()
        specs = {'scheme': 'swift',
                 'auth_or_store_url': 'example.com/v2/',
                 'user': 'tenant:user1',
                 'key': 'key1',
                 'container': 'cont',
                 'obj': 'object'}
        self.location = swift.StoreLocation(specs, self.conf,
                                            backend_group="swift1")

        self.register_store_backend_schemes(self.store, 'swift', 'swift1')
        self.addCleanup(self.conf.reset) 
Example #4
Source File: config.py    From st2 with Apache License 2.0 5 votes vote down vote up
def _register_app_opts():
    # Note "host", "port", "allow_origin", "mask_secrets" options are registered as part of
    # st2common config since they are also used outside st2api
    static_root = os.path.join(cfg.CONF.system.base_path, 'static')
    template_path = os.path.join(BASE_DIR, 'templates/')

    pecan_opts = [
        cfg.StrOpt(
            'root', default='st2api.controllers.root.RootController',
            help='Action root controller'),
        cfg.StrOpt('static_root', default=static_root),
        cfg.StrOpt('template_path', default=template_path),
        cfg.ListOpt('modules', default=['st2api']),
        cfg.BoolOpt('debug', default=False),
        cfg.BoolOpt('auth_enable', default=True),
        cfg.DictOpt('errors', default={'__force_dict__': True})
    ]

    CONF.register_opts(pecan_opts, group='api_pecan')

    logging_opts = [
        cfg.BoolOpt('debug', default=False),
        cfg.StrOpt(
            'logging', default='/etc/st2/logging.api.conf',
            help='location of the logging.conf file'),
        cfg.IntOpt(
            'max_page_size', default=100,
            help='Maximum limit (page size) argument which can be '
                 'specified by the user in a query string.')
    ]

    CONF.register_opts(logging_opts, group='api') 
Example #5
Source File: weight.py    From watcher with Apache License 2.0 5 votes vote down vote up
def get_config_opts(cls):
        return [
            cfg.DictOpt(
                'weights',
                help="These weights are used to schedule the actions. "
                     "Action Plan will be build in accordance with sets of "
                     "actions ordered by descending weights."
                     "Two action types cannot have the same weight. ",
                default=cls.action_weights),
            cfg.DictOpt(
                'parallelization',
                help="Number of actions to be run in parallel on a per "
                     "action type basis.",
                default=cls.parallelization),
        ] 
Example #6
Source File: workload_stabilization.py    From watcher with Apache License 2.0 5 votes vote down vote up
def get_config_opts(cls):
        return [
            cfg.DictOpt(
                'weights',
                help="These weights are used to schedule the actions",
                default=cls.weights_dict),
        ] 
Example #7
Source File: test_swift_store_multibackend.py    From glance_store with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(TestMultipleContainers, self).setUp()

        enabled_backends = {
            "swift1": "swift",
            "swift2": "swift",
        }
        self.conf = self._CONF
        self.conf(args=[])
        self.conf.register_opt(cfg.DictOpt('enabled_backends'))
        self.config(enabled_backends=enabled_backends)
        store.register_store_opts(self.conf)
        self.config(default_backend='swift1', group='glance_store')

        # Ensure stores + locations cleared
        location.SCHEME_TO_CLS_BACKEND_MAP = {}

        store.create_multi_stores(self.conf)
        self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
                        dict())
        self.test_dir = self.useFixture(fixtures.TempDir()).path

        self.config(group="swift1", swift_store_multiple_containers_seed=3)
        self.store = swift.SingleTenantStore(self.conf, backend="swift1")
        self.store.configure()
        self.register_store_backend_schemes(self.store, 'swift', 'swift1')

        self.addCleanup(self.conf.reset) 
Example #8
Source File: test_swift_store_multibackend.py    From glance_store with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(TestChunkReader, self).setUp()
        enabled_backends = {
            "swift1": "swift",
            "swift2": "swift",
        }
        self.conf = self._CONF
        self.conf(args=[])
        self.conf.register_opt(cfg.DictOpt('enabled_backends'))
        self.config(enabled_backends=enabled_backends)
        store.register_store_opts(self.conf)
        self.config(default_backend='swift1', group='glance_store')

        # Ensure stores + locations cleared
        location.SCHEME_TO_CLS_BACKEND_MAP = {}

        store.create_multi_stores(self.conf)
        self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
                        dict())
        self.test_dir = self.useFixture(fixtures.TempDir()).path

        config = copy.deepcopy(SWIFT_CONF)
        self.store = Store(self.conf, backend="swift1")
        self.config(group="swift1", **config)
        self.store.configure()
        self.register_store_backend_schemes(self.store, 'swift', 'swift1')

        self.addCleanup(self.conf.reset) 
Example #9
Source File: test_swift_store_multibackend.py    From glance_store with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(TestMultiTenantStoreConnections, self).setUp()
        enabled_backends = {
            "swift1": "swift",
            "swift2": "swift",
        }
        self.conf = self._CONF
        self.conf(args=[])
        self.conf.register_opt(cfg.DictOpt('enabled_backends'))
        self.config(enabled_backends=enabled_backends)
        store.register_store_opts(self.conf)
        self.config(default_backend='swift1', group='glance_store')

        # Ensure stores + locations cleared
        location.SCHEME_TO_CLS_BACKEND_MAP = {}

        store.create_multi_stores(self.conf)
        self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
                        dict())
        self.test_dir = self.useFixture(fixtures.TempDir()).path

        self.useFixture(fixtures.MockPatch(
            'swiftclient.Connection', FakeConnection))
        self.context = mock.MagicMock(
            user='tenant:user1', tenant='tenant', auth_token='0123')
        self.store = swift.MultiTenantStore(self.conf, backend="swift1")
        specs = {'scheme': 'swift',
                 'auth_or_store_url': 'example.com',
                 'container': 'cont',
                 'obj': 'object'}
        self.location = swift.StoreLocation(specs, self.conf,
                                            backend_group="swift1")
        self.addCleanup(self.conf.reset) 
Example #10
Source File: test_swift_store_multibackend.py    From glance_store with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        """Establish a clean test environment."""
        super(TestStoreAuthV1, self).setUp()
        enabled_backends = {
            "swift1": "swift",
            "swift2": "swift",
        }
        self.conf = self._CONF
        self.conf(args=[])
        self.conf.register_opt(cfg.DictOpt('enabled_backends'))
        self.config(enabled_backends=enabled_backends)
        store.register_store_opts(self.conf)
        self.config(default_backend='swift1', group='glance_store')

        # Ensure stores + locations cleared
        location.SCHEME_TO_CLS_BACKEND_MAP = {}

        store.create_multi_stores(self.conf)
        self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
                        dict())
        self.test_dir = self.useFixture(fixtures.TempDir()).path

        config = self.getConfig()

        conf_file = 'glance-swift.conf'
        self.swift_config_file = self.copy_data_file(conf_file, self.test_dir)
        config.update({'swift_store_config_file': self.swift_config_file})

        self.stub_out_swiftclient(config['swift_store_auth_version'])
        self.mock_keystone_client()
        self.store = Store(self.conf, backend="swift1")
        self.config(group="swift1", **config)
        self.store.configure()

        self.register_store_backend_schemes(self.store, 'swift', 'swift1')
        self.addCleanup(self.conf.reset) 
Example #11
Source File: test_store_base.py    From glance_store with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(TestMultiStoreBase, self).setUp()
        enabled_backends = {
            "fast": "file",
            "cheap": "file",
        }

        self.reserved_stores = {
            'consuming_service_reserved_store': 'file'
        }

        self.conf = self._CONF
        self.conf(args=[])
        self.conf.register_opt(cfg.DictOpt('enabled_backends'))
        self.config(enabled_backends=enabled_backends)

        store.register_store_opts(self.conf,
                                  reserved_stores=self.reserved_stores)
        self.config(default_backend='file1', group='glance_store')

        # Ensure stores + locations cleared
        location.SCHEME_TO_CLS_BACKEND_MAP = {}

        store.create_multi_stores(self.conf,
                                  reserved_stores=self.reserved_stores)
        self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
                        dict())
        self.addCleanup(self.conf.reset) 
Example #12
Source File: test_fs_mount.py    From glance_store with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(HostMountStateTestCase, self).setUp()
        CONF.register_opt(cfg.DictOpt('enabled_backends'))
        CONF.set_override('enabled_backends', 'fake:file')
        # Since this is mocked in other tests, we unmock it here
        if 'glance_store.common.fs_mount' in sys.modules:
            sys.modules.pop('glance_store.common.fs_mount')
        # Since the _HostMountStateManager class instantiates on its
        # import, this import is done here to register the enabled_backends
        # config option before it is used during initialization
        from glance_store.common import fs_mount as mount  # noqa
        self.mounted = set()
        self.m = mount._HostMountState()

        def fake_execute(cmd, *args, **kwargs):
            if cmd == 'mount':
                path = args[-1]
                if path in self.mounted:
                    raise processutils.ProcessExecutionError('Already mounted')
                self.mounted.add(path)
            elif cmd == 'umount':
                path = args[-1]
                if path not in self.mounted:
                    raise processutils.ProcessExecutionError('Not mounted')
                self.mounted.remove(path)

        def fake_ismount(path):
            return path in self.mounted

        mock_execute = mock.MagicMock(side_effect=fake_execute)

        self.useFixture(fixtures.MonkeyPatch(
            'oslo_concurrency.processutils.execute',
            mock_execute))
        self.useFixture(fixtures.MonkeyPatch('os.path.ismount', fake_ismount)) 
Example #13
Source File: test_multistore_rbd.py    From glance_store with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        """Establish a clean test environment."""
        super(TestMultiStore, self).setUp()
        enabled_backends = {
            "ceph1": "rbd",
            "ceph2": "rbd"
        }
        self.conf = self._CONF
        self.conf(args=[])
        self.conf.register_opt(cfg.DictOpt('enabled_backends'))
        self.config(enabled_backends=enabled_backends)
        store.register_store_opts(self.conf)
        self.config(default_backend='ceph1', group='glance_store')

        # Ensure stores + locations cleared
        g_location.SCHEME_TO_CLS_BACKEND_MAP = {}

        with mock.patch.object(rbd_store.Store, '_set_url_prefix'):
            store.create_multi_stores(self.conf)

        self.addCleanup(setattr, g_location, 'SCHEME_TO_CLS_BACKEND_MAP',
                        dict())
        self.addCleanup(self.conf.reset)

        rbd_store.rados = MockRados
        rbd_store.rbd = MockRBD

        self.store = rbd_store.Store(self.conf, backend="ceph1")
        self.store.configure()
        self.store.chunk_size = 2
        self.called_commands_actual = []
        self.called_commands_expected = []
        self.store_specs = {'pool': 'fake_pool',
                            'image': 'fake_image',
                            'snapshot': 'fake_snapshot'}
        self.location = rbd_store.StoreLocation(self.store_specs,
                                                self.conf)
        # Provide enough data to get more than one chunk iteration.
        self.data_len = 3 * units.Ki
        self.data_iter = six.BytesIO(b'*' * self.data_len) 
Example #14
Source File: test_multistore_cinder.py    From glance_store with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(TestMultiCinderStore, self).setUp()
        enabled_backends = {
            "cinder1": "cinder",
            "cinder2": "cinder"
        }
        self.conf = self._CONF
        self.conf(args=[])
        self.conf.register_opt(cfg.DictOpt('enabled_backends'))
        self.config(enabled_backends=enabled_backends)
        store.register_store_opts(self.conf)
        self.config(default_backend='cinder1', group='glance_store')

        # Ensure stores + locations cleared
        location.SCHEME_TO_CLS_BACKEND_MAP = {}
        store.create_multi_stores(self.conf)

        self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
                        dict())
        self.test_dir = self.useFixture(fixtures.TempDir()).path
        self.addCleanup(self.conf.reset)

        self.store = cinder.Store(self.conf, backend="cinder1")
        self.store.configure()
        self.register_store_backend_schemes(self.store, 'cinder', 'cinder1')
        self.store.READ_CHUNKSIZE = 4096
        self.store.WRITE_CHUNKSIZE = 4096

        fake_sc = [{u'endpoints': [{u'publicURL': u'http://foo/public_url'}],
                    u'endpoints_links': [],
                    u'name': u'cinder',
                    u'type': u'volumev2'}]
        self.context = FakeObject(service_catalog=fake_sc,
                                  user='fake_user',
                                  auth_token='fake_token',
                                  tenant='fake_tenant') 
Example #15
Source File: test_multistore_filesystem.py    From glance_store with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        """Establish a clean test environment."""
        super(TestMultiStore, self).setUp()
        self.enabled_backends = {
            "file1": "file",
            "file2": "file",
        }
        self.conf = self._CONF
        self.conf(args=[])
        self.conf.register_opt(cfg.DictOpt('enabled_backends'))
        self.config(enabled_backends=self.enabled_backends)
        store.register_store_opts(self.conf)
        self.config(default_backend='file1', group='glance_store')

        # Ensure stores + locations cleared
        location.SCHEME_TO_CLS_BACKEND_MAP = {}
        store.create_multi_stores(self.conf)

        self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
                        dict())
        self.test_dir = self.useFixture(fixtures.TempDir()).path
        self.addCleanup(self.conf.reset)

        self.store = filesystem.Store(self.conf, backend='file1')
        self.config(filesystem_store_datadir=self.test_dir,
                    filesystem_store_chunk_size=10,
                    group="file1")
        self.store.configure()
        self.register_store_backend_schemes(self.store, 'file', 'file1') 
Example #16
Source File: test_swift_store_multibackend.py    From glance_store with Apache License 2.0 4 votes vote down vote up
def setUp(self):
        super(TestCreatingLocations, self).setUp()
        enabled_backends = {
            "swift1": "swift",
            "swift2": "swift",
        }
        self.conf = self._CONF
        self.conf(args=[])
        self.conf.register_opt(cfg.DictOpt('enabled_backends'))
        self.config(enabled_backends=enabled_backends)
        store.register_store_opts(self.conf)
        self.config(default_backend='swift1', group='glance_store')

        # Ensure stores + locations cleared
        location.SCHEME_TO_CLS_BACKEND_MAP = {}

        store.create_multi_stores(self.conf)
        self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
                        dict())
        self.test_dir = self.useFixture(fixtures.TempDir()).path

        config = copy.deepcopy(SWIFT_CONF)
        self.store = Store(self.conf, backend="swift1")
        self.config(group="swift1", **config)
        self.store.configure()
        self.register_store_backend_schemes(self.store, 'swift', 'swift1')

        moves.reload_module(swift)
        self.addCleanup(self.conf.reset)

        service_catalog = [
            {
                'endpoint_links': [],
                'endpoints': [
                    {
                        'adminURL': 'https://some_admin_endpoint',
                        'region': 'RegionOne',
                        'internalURL': 'https://some_internal_endpoint',
                        'publicURL': 'https://some_endpoint',
                    },
                ],
                'type': 'object-store',
                'name': 'Object Storage Service',
            }
        ]
        self.ctxt = mock.MagicMock(user='user', tenant='tenant',
                                   auth_token='123',
                                   service_catalog=service_catalog) 
Example #17
Source File: test_multistore_s3.py    From glance_store with Apache License 2.0 4 votes vote down vote up
def setUp(self):
        """Establish a clean test environment."""
        super(TestMultiS3Store, self).setUp()
        enabled_backends = {
            "s3_region1": "s3",
            "s3_region2": "s3"
        }
        self.hash_algo = 'sha256'
        self.conf = self._CONF
        self.conf(args=[])
        self.conf.register_opt(cfg.DictOpt('enabled_backends'))
        self.config(enabled_backends=enabled_backends)
        store.register_store_opts(self.conf)
        self.config(default_backend='s3_region1', group='glance_store')

        # set s3 related config options
        self.config(group='s3_region1',
                    s3_store_access_key='user',
                    s3_store_secret_key='key',
                    s3_store_host='https://s3-region1.com',
                    s3_store_bucket='glance',
                    s3_store_large_object_size=5,
                    s3_store_large_object_chunk_size=6)

        self.config(group='s3_region2',
                    s3_store_access_key='user',
                    s3_store_secret_key='key',
                    s3_store_host='http://s3-region2.com',
                    s3_store_bucket='glance',
                    s3_store_large_object_size=5,
                    s3_store_large_object_chunk_size=6)
        # Ensure stores + locations cleared
        location.SCHEME_TO_CLS_BACKEND_MAP = {}
        store.create_multi_stores(self.conf)

        self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
                        dict())
        self.addCleanup(self.conf.reset)

        self.store = s3.Store(self.conf, backend="s3_region1")
        self.store.configure()
        self.register_store_backend_schemes(self.store, 's3', 's3_region1') 
Example #18
Source File: test_multistore_vmware.py    From glance_store with Apache License 2.0 4 votes vote down vote up
def setUp(self, mock_api_session, mock_get_datastore):
        """Establish a clean test environment."""
        super(TestMultiStore, self).setUp()
        enabled_backends = {
            "vmware1": "vmware",
            "vmware2": "vmware"
        }
        self.hash_algo = 'sha256'
        self.conf = self._CONF
        self.conf(args=[])
        self.conf.register_opt(cfg.DictOpt('enabled_backends'))
        self.config(enabled_backends=enabled_backends)
        store.register_store_opts(self.conf)
        self.config(default_backend='vmware1', group='glance_store')

        # set vmware related config options
        self.config(group='vmware1',
                    vmware_server_username='admin',
                    vmware_server_password='admin',
                    vmware_server_host='127.0.0.1',
                    vmware_insecure='True',
                    vmware_datastores=['a:b:0'],
                    vmware_store_image_dir='/openstack_glance')

        self.config(group='vmware2',
                    vmware_server_username='admin',
                    vmware_server_password='admin',
                    vmware_server_host='127.0.0.1',
                    vmware_insecure='True',
                    vmware_datastores=['a:b:1'],
                    vmware_store_image_dir='/openstack_glance_1')
        # Ensure stores + locations cleared
        location.SCHEME_TO_CLS_BACKEND_MAP = {}
        store.create_multi_stores(self.conf)

        self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
                        dict())
        self.addCleanup(self.conf.reset)

        vm_store.Store.CHUNKSIZE = 2

        mock_get_datastore.side_effect = fake_datastore_obj

        self.store = vm_store.Store(self.conf, backend="vmware1")
        self.store.configure()