How to use the stevedore.extension.Extension function in stevedore

To help you get started, we’ve selected a few stevedore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / ceilometer / nova_tests / test_folsom.py View on Github external
"uuid": "144e08f4-00cb-11e2-888e-5453ed1bbb5f",
                         "system_metadata": {}}
        self.stubs.Set(db, 'instance_info_cache_delete', self.do_nothing)
        self.stubs.Set(db, 'instance_destroy', self.do_nothing)
        self.stubs.Set(db, 'instance_system_metadata_get',
                       self.fake_db_instance_system_metadata_get)
        self.stubs.Set(db, 'block_device_mapping_get_all_by_instance',
                       lambda context, instance: {})
        self.stubs.Set(db, 'instance_update_and_get_original',
                       lambda context, uuid, kwargs: (self.instance,
                                                      self.instance))

        agent_manager = manager.AgentManager()
        agent_manager.pollster_manager = \
            test_manager.TestExtensionManager([
                extension.Extension('test',
                                    None,
                                    None,
                                    self.Pollster(),
                                    ),
            ])
        nova_notifier.initialize_manager(agent_manager)
github openstack / ceilometer / tests / collector / test_service.py View on Github external
def test_udp_receive_storage_error(self):
        mock_dispatcher = mock.MagicMock()
        self.srv.dispatcher_manager = test_manager.TestExtensionManager(
            [extension.Extension('test',
                                 None,
                                 None,
                                 mock_dispatcher
                                 ),
             ])
        mock_dispatcher.record_metering_data.side_effect = self._raise_error

        self.counter['source'] = 'mysource'
        self.counter['counter_name'] = self.counter['name']
        self.counter['counter_volume'] = self.counter['volume']
        self.counter['counter_type'] = self.counter['type']
        self.counter['counter_unit'] = self.counter['unit']

        with patch('socket.socket', self._make_fake_socket):
            self.srv.start()
github openstack / monasca-transform / tests / functional / test_resources / mock_component_manager.py View on Github external
def get_insert_pre_hourly_cmpt_mgr():
        return ExtensionManager.make_test_instance([Extension(
            'prepare_data',
            'monasca_transform.component.insert.prepare_data:PrepareData',
            PrepareData(),
            None),
            Extension('insert_data',
                      'tests.functional.component.insert.dummy_insert:'
                      'DummyInsert',
                      DummyInsert(),
                      None),
            Extension('insert_data_pre_hourly',
                      'tests.functional.component.insert.'
                      'dummy_insert_pre_hourly:'
                      'DummyInsertPreHourly',
                      DummyInsertPreHourly(),
                      None),
        ])
github openstack / ceilometer / nova_tests / test_notifier.py View on Github external
self.stubs.Set(db, 'instance_destroy', self.do_nothing)
        self.stubs.Set(db, 'instance_system_metadata_get',
                       self.fake_db_instance_system_metadata_get)
        self.stubs.Set(db, 'block_device_mapping_get_all_by_instance',
                       lambda context, instance: {})
        self.stubs.Set(db, 'instance_update_and_get_original',
                       lambda *args, **kwargs: (self.instance, self.instance))
        self.stubs.Set(flavors, 'extract_flavor', self.fake_extract_flavor)

        # Set up to capture the notification messages generated by the
        # plugin and to invoke our notifier plugin.
        self.notifications = []

        ext_mgr = extension.ExtensionManager.make_test_instance(
            extensions=[
                extension.Extension('test',
                                    None,
                                    None,
                                    self.Pollster(),
                                ),
            ],
        )
        self.ext_mgr = ext_mgr
        self.gatherer = nova_notifier.DeletedInstanceStatsGatherer(ext_mgr)
        # Initialize the global _gatherer in nova_notifier to use the
        # gatherer in this test instead of the gatherer in nova_notifier.
        nova_notifier.initialize_gatherer(self.gatherer)

        # Terminate the instance to trigger the notification.
        with contextlib.nested(
            # Under Grizzly, Nova has moved to no-db access on the
            # compute node. The compute manager uses RPC to talk to
github openstack / ceilometer / tests / collector / test_service.py View on Github external
def test_message_to_event_missing_keys(self):
        now = timeutils.utcnow()
        timeutils.set_time_override(now)
        message = {'event_type': "foo",
                   'message_id': "abc",
                   'publisher_id': "1"}

        mock_dispatcher = mock.MagicMock()
        self.srv.dispatcher_manager = test_manager.TestExtensionManager(
            [extension.Extension('test',
                                 None,
                                 None,
                                 mock_dispatcher
                                 ),
             ])

        with patch('ceilometer.collector.service.LOG') as mylog:
            self.srv._message_to_event(message)
            self.assertFalse(mylog.exception.called)
        events = mock_dispatcher.record_events.call_args[0]
        self.assertEqual(1, len(events))
        event = events[0]
        self.assertEqual("foo", event.event_name)
        self.assertEqual(now, event.generated)
        self.assertEqual(1, len(event.traits))
github caronc / nzb-subliminal / Subliminal / guessit / plugins / transformers.py View on Github external
def _load_one_plugin(self, ep, invoke_on_load, invoke_args, invoke_kwds, verify_requirements=True):
        if not ep.dist:
            # `require` argument of ep.load() is deprecated in newer versions of setuptools
            if hasattr(ep, 'resolve'):
                plugin = ep.resolve()
            elif hasattr(ep, '_load'):
                plugin = ep._load()
            else:
                plugin = ep.load(require=False)
        else:
            plugin = ep.load()
        if invoke_on_load:
            obj = plugin(*invoke_args, **invoke_kwds)
        else:
            obj = None
        return Extension(ep.name, ep, plugin, obj)
github h3llrais3r / Auto-Subliminal / lib / guessit / plugins / transformers.py View on Github external
def _load_one_plugin(ep, invoke_on_load, invoke_args, invoke_kwds, verify_requirements=True):
        if not ep.dist:
            # `require` argument of ep.load() is deprecated in newer versions of setuptools
            if hasattr(ep, 'resolve'):
                plugin = ep.resolve()
            elif hasattr(ep, '_load'):
                plugin = ep._load()
            else:
                plugin = ep.load(require=False)
        else:
            plugin = ep.load()
        if invoke_on_load:
            obj = plugin(*invoke_args, **invoke_kwds)
        else:
            obj = None
        return Extension(ep.name, ep, plugin, obj)
github eonpatapon / contrail-api-cli / contrail_api_cli / manager.py View on Github external
def add(self, name, cmd):
        ext = extension.Extension(name, None, cmd.__class__, cmd)
        self.mgrs[0].extensions.append(ext)
github openstack / stevedore / stevedore / extension.py View on Github external
def _load_one_plugin(self, ep, invoke_on_load, invoke_args, invoke_kwds,
                         verify_requirements):
        # NOTE(dhellmann): Using require=False is deprecated in
        # setuptools 11.3.
        if hasattr(ep, 'resolve') and hasattr(ep, 'require'):
            if verify_requirements:
                ep.require()
            plugin = ep.resolve()
        else:
            plugin = ep.load()
        if invoke_on_load:
            obj = plugin(*invoke_args, **invoke_kwds)
        else:
            obj = None
        return Extension(ep.name, ep, plugin, obj)