def __init__(self, conf, host, binary, topic, manager_, report_interval=None, periodic_enable=None, periodic_fuzzy_delay=None, periodic_interval_max=None, *args, **kwargs): super(Service, self).__init__() self.conf = conf self.host = host self.binary = binary self.topic = topic self.manager_class_name = manager_ manager_class = importutils.import_class(self.manager_class_name) kwargs_ = kwargs.copy() kwargs_['conf'] = conf self.manager = manager_class(host=self.host, *args, **kwargs_) self.src_transport = kwargs['src_transport'] self.rpcserver = None self.report_interval = report_interval self.periodic_enable = periodic_enable self.periodic_fuzzy_delay = periodic_fuzzy_delay self.periodic_interval_max = periodic_interval_max self.saved_args, self.saved_kwargs = args, kwargs
def setUp(self): super(TackerPolicyTestCase, self).setUp() policy.reset() policy.init() self.addCleanup(policy.reset) self.admin_only_legacy = "role:admin" self.admin_or_owner_legacy = "role:admin or tenant_id:%(tenant_id)s" # Add a Fake 'something' resource to RESOURCE_ATTRIBUTE_MAP attributes.RESOURCE_ATTRIBUTE_MAP.update(FAKE_RESOURCE) self.rules = dict((k, common_policy.parse_rule(v)) for k, v in { "context_is_admin": "role:admin", "admin_or_network_owner": "rule:context_is_admin or " "tenant_id:%(network:tenant_id)s", "admin_or_owner": ("rule:context_is_admin or " "tenant_id:%(tenant_id)s"), "admin_only": "rule:context_is_admin", "regular_user": "******", "shared": "field:networks:shared=True", "external": "field:networks:router:external=True", "default": '@', "create_network": "rule:admin_or_owner", "create_network:shared": "rule:admin_only", "update_network": '@', "update_network:shared": "rule:admin_only", "get_network": "rule:admin_or_owner or " "rule:shared or " "rule:external", "create_port:mac": "rule:admin_or_network_owner", "create_something": "rule:admin_or_owner", "create_something:attr": "rule:admin_or_owner", "create_something:attr:sub_attr_1": "rule:admin_or_owner", "create_something:attr:sub_attr_2": "rule:admin_only", "get_firewall_policy": "rule:admin_or_owner or " "rule:shared", "get_firewall_rule": "rule:admin_or_owner or " "rule:shared" }.items()) def fakepolicyinit(): common_policy.set_rules(common_policy.Rules(self.rules)) def remove_fake_resource(): del attributes.RESOURCE_ATTRIBUTE_MAP["%ss" % FAKE_RESOURCE_NAME] self.patcher = mock.patch.object(tacker.policy, 'init', new=fakepolicyinit) self.patcher.start() self.addCleanup(remove_fake_resource) self.context = context.Context('fake', 'fake', roles=['user']) plugin_klass = importutils.import_class( "tacker.db.db_base_plugin_v2.TackerDbPluginV2") self.manager_patcher = mock.patch('tacker.manager.TackerManager') fake_manager = self.manager_patcher.start() fake_manager_instance = fake_manager.return_value fake_manager_instance.plugin = plugin_klass()
def __init__(self, host, binary, topic, manager, report_interval=None, periodic_interval=None, periodic_fuzzy_delay=None, *args, **kwargs): self.binary = binary self.manager_class_name = manager manager_class = importutils.import_class(self.manager_class_name) self.manager = manager_class(host=host, *args, **kwargs) self.report_interval = report_interval self.periodic_interval = periodic_interval self.periodic_fuzzy_delay = periodic_fuzzy_delay self.saved_args, self.saved_kwargs = args, kwargs self.timers = [] super(Service, self).__init__(host, topic, manager=self.manager)
def __init__(self, conf, host, binary, topic, manager, report_interval=None, periodic_interval=None, periodic_fuzzy_delay=None, *args, **kwargs): self.binary = binary self.manager_class_name = manager manager_class = importutils.import_class(self.manager_class_name) self.manager = manager_class(conf=conf, host=host, *args, **kwargs) self.report_interval = report_interval self.periodic_interval = periodic_interval self.periodic_fuzzy_delay = periodic_fuzzy_delay self.saved_args, self.saved_kwargs = args, kwargs self.timers = [] super(TackerService, self).__init__(conf, host, topic, manager=self.manager)
def _load_service_plugins(self): """Loads service plugins. Starts from the core plugin and checks if it supports advanced services then loads classes provided in configuration. """ # plugin_providers = cfg.CONF.service_plugins plugin_providers = ['tacker.vm.plugin.ServiceVMPlugin'] LOG.debug(_("Loading service plugins: %s"), plugin_providers) for provider in plugin_providers: if provider == '': continue try: LOG.info(_("Loading Plugin: %s"), provider) plugin_class = importutils.import_class(provider) except ImportError: LOG.exception(_("Error loading plugin")) raise ImportError(_("Plugin not found.")) plugin_inst = plugin_class() # only one implementation of svc_type allowed # specifying more than one plugin # for the same type is a fatal exception if plugin_inst.get_plugin_type() in self.service_plugins: raise ValueError( _("Multiple plugins for service " "%s were configured"), plugin_inst.get_plugin_type()) self.service_plugins[plugin_inst.get_plugin_type()] = plugin_inst # # search for possible agent notifiers declared in service plugin # # (needed by agent management extension) # if (hasattr(self.plugin, 'agent_notifiers') and # hasattr(plugin_inst, 'agent_notifiers')): # self.plugin.agent_notifiers.update(plugin_inst.agent_notifiers) LOG.debug( _("Successfully loaded %(type)s plugin. " "Description: %(desc)s"), { "type": plugin_inst.get_plugin_type(), "desc": plugin_inst.get_plugin_description() })
def _load_service_plugins(self): """Loads service plugins. Starts from the core plugin and checks if it supports advanced services then loads classes provided in configuration. """ # plugin_providers = cfg.CONF.service_plugins plugin_providers = ['tacker.vm.plugin.ServiceVMPlugin'] LOG.debug(_("Loading service plugins: %s"), plugin_providers) for provider in plugin_providers: if provider == '': continue try: LOG.info(_("Loading Plugin: %s"), provider) plugin_class = importutils.import_class(provider) except ImportError: LOG.exception(_("Error loading plugin")) raise ImportError(_("Plugin not found.")) plugin_inst = plugin_class() # only one implementation of svc_type allowed # specifying more than one plugin # for the same type is a fatal exception if plugin_inst.get_plugin_type() in self.service_plugins: raise ValueError(_("Multiple plugins for service " "%s were configured"), plugin_inst.get_plugin_type()) self.service_plugins[plugin_inst.get_plugin_type()] = plugin_inst # # search for possible agent notifiers declared in service plugin # # (needed by agent management extension) # if (hasattr(self.plugin, 'agent_notifiers') and # hasattr(plugin_inst, 'agent_notifiers')): # self.plugin.agent_notifiers.update(plugin_inst.agent_notifiers) LOG.debug(_("Successfully loaded %(type)s plugin. " "Description: %(desc)s"), {"type": plugin_inst.get_plugin_type(), "desc": plugin_inst.get_plugin_description()})
def _load_driver(self, driver_provider): LOG.debug(_("Driver location: %s"), driver_provider) plugin_klass = importutils.import_class(driver_provider) return plugin_klass(self.conf)