本文整理汇总了Python中neutron_lib.plugins.directory.add_plugin函数的典型用法代码示例。如果您正苦于以下问题:Python add_plugin函数的具体用法?Python add_plugin怎么用?Python add_plugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_plugin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, options=None, config_file=None):
# If no options have been provided, create an empty dict
if not options:
options = {}
msg = validate_pre_plugin_load()
if msg:
LOG.critical(msg)
raise Exception(msg)
# NOTE(jkoelker) Testing for the subclass with the __subclasshook__
# breaks tach monitoring. It has been removed
# intentionally to allow v2 plugins to be monitored
# for performance metrics.
plugin_provider = cfg.CONF.core_plugin
LOG.info("Loading core plugin: %s", plugin_provider)
# NOTE(armax): keep hold of the actual plugin object
plugin = self._get_plugin_instance(CORE_PLUGINS_NAMESPACE,
plugin_provider)
directory.add_plugin(lib_const.CORE, plugin)
msg = validate_post_plugin_load()
if msg:
LOG.critical(msg)
raise Exception(msg)
# load services from the core plugin first
self._load_services_from_core_plugin(plugin)
self._load_service_plugins()
# Used by pecan WSGI
self.resource_plugin_mappings = {}
self.resource_controller_mappings = {}
self.path_prefix_resource_mappings = defaultdict(list)
示例2: _test_update_arp_entry_for_dvr_service_port
def _test_update_arp_entry_for_dvr_service_port(
self, device_owner, action):
router_dict = {'name': 'test_router', 'admin_state_up': True,
'distributed': True}
router = self._create_router(router_dict)
plugin = mock.Mock()
directory.add_plugin(plugin_constants.CORE, plugin)
l3_notify = self.mixin.l3_rpc_notifier = mock.Mock()
port = {
'id': 'my_port_id',
'fixed_ips': [
{'subnet_id': '51edc9e0-24f9-47f2-8e1e-2a41cb691323',
'ip_address': '10.0.0.11'},
{'subnet_id': '2b7c8a07-6f8e-4937-8701-f1d5da1a807c',
'ip_address': '10.0.0.21'},
{'subnet_id': '48534187-f077-4e81-93ff-81ec4cc0ad3b',
'ip_address': 'fd45:1515:7e0:0:f816:3eff:fe1a:1111'}],
'mac_address': 'my_mac',
'device_owner': device_owner
}
dvr_port = {
'id': 'dvr_port_id',
'fixed_ips': mock.ANY,
'device_owner': const.DEVICE_OWNER_DVR_INTERFACE,
'device_id': router['id']
}
plugin.get_ports.return_value = [dvr_port]
if action == 'add':
self.mixin.update_arp_entry_for_dvr_service_port(
self.ctx, port)
self.assertEqual(3, l3_notify.add_arp_entry.call_count)
elif action == 'del':
self.mixin.delete_arp_entry_for_dvr_service_port(
self.ctx, port)
self.assertEqual(3, l3_notify.del_arp_entry.call_count)
示例3: setUp
def setUp(self):
super(L3SchedulerBaseTest, self).setUp(PLUGIN_NAME)
self.l3_plugin = l3_router_plugin.L3RouterPlugin()
directory.add_plugin(plugin_constants.L3, self.l3_plugin)
self.adminContext = context.get_admin_context()
self.adminContext.tenant_id = _uuid()
示例4: setUp
def setUp(self):
super(ProvidernetExtensionTestCase, self).setUp()
plugin = 'neutron.neutron_plugin_base_v2.NeutronPluginBaseV2'
# Ensure existing ExtensionManager is not used
extensions.PluginAwareExtensionManager._instance = None
self.useFixture(fixture.APIDefinitionFixture())
# Update the plugin and extensions path
self.setup_coreplugin(plugin, load_plugins=False)
self._plugin_patcher = mock.patch(plugin, autospec=True)
self.plugin = self._plugin_patcher.start()
# Ensure Quota checks never fail because of mock
instance = self.plugin.return_value
instance.get_networks_count.return_value = 1
# Register mock plugin and enable the 'provider' extension
instance.supported_extension_aliases = ["provider"]
directory.add_plugin(constants.CORE, instance)
ext_mgr = ProviderExtensionManager()
self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
self.addCleanup(self._plugin_patcher.stop)
self.api = webtest.TestApp(router.APIRouter())
quota.QUOTAS._driver = None
cfg.CONF.set_override('quota_driver', 'neutron.quota.ConfDriver',
group='QUOTAS')
示例5: _helper_delete_floatingip_agent_gateway_port
def _helper_delete_floatingip_agent_gateway_port(self, port_host):
ports = [{
'id': 'my_port_id',
portbindings.HOST_ID: 'foo_host',
'network_id': 'ext_network_id',
'device_owner': const.DEVICE_OWNER_ROUTER_GW
},
{
'id': 'my_new_port_id',
portbindings.HOST_ID: 'my_foo_host',
'network_id': 'ext_network_id',
'device_owner': const.DEVICE_OWNER_ROUTER_GW
}]
plugin = mock.Mock()
directory.add_plugin(plugin_constants.CORE, plugin)
plugin.get_ports.return_value = ports
self.mixin.delete_floatingip_agent_gateway_port(
self.ctx, port_host, 'ext_network_id')
plugin.get_ports.assert_called_with(self.ctx, filters={
'network_id': ['ext_network_id'],
'device_owner': [const.DEVICE_OWNER_AGENT_GW]})
if port_host:
plugin.ipam.delete_port.assert_called_once_with(
self.ctx, 'my_port_id')
else:
plugin.ipam.delete_port.assert_called_with(
self.ctx, 'my_new_port_id')
示例6: _test_validate_log_type_for_port
def _test_validate_log_type_for_port(self, port, expected_result):
driver_manager = self._create_manager_with_drivers({
'driver-A': {
'is_loaded': True,
'supported_logging_types': ['security_group'],
'vif_types': [portbindings.VIF_TYPE_OVS],
'vnic_types': [portbindings.VNIC_NORMAL]
}
})
is_log_type_supported_mock = mock.Mock()
if expected_result:
is_log_type_supported_mock.return_value = expected_result
log_driver = list(driver_manager.drivers)[0]
log_driver.is_logging_type_supported = (
is_log_type_supported_mock
)
class FakeLoggingPlugin(object):
def __init__(self):
self.driver_manager = driver_manager
directory.add_plugin(plugin_const.LOG_API, FakeLoggingPlugin())
self.assertEqual(
expected_result,
validators.validate_log_type_for_port('security_group', port))
if expected_result:
is_log_type_supported_mock.assert_called_once_with(
'security_group')
else:
is_log_type_supported_mock.assert_not_called()
示例7: test_delete_network_check_disassociated_floatingips
def test_delete_network_check_disassociated_floatingips(self):
l3_mock = mock.Mock()
directory.add_plugin("L3_ROUTER_NAT", l3_mock)
with self.network() as net:
req = self.new_delete_request("networks", net["network"]["id"])
res = req.get_response(self.api)
self.assertEqual(exc.HTTPNoContent.code, res.status_int)
(l3_mock.delete_disassociated_floatingips.assert_called_once_with(mock.ANY, net["network"]["id"]))
示例8: _test_get_latest_resource
def _test_get_latest_resource(self, resource_type):
# Drivers needs to be initialized to register resources for recovery
# and full sync mechasnim.
helper.TestDriver()
directory.add_plugin(helper.TEST_PLUGIN, helper.TestPlugin())
self.addCleanup(directory.add_plugin, helper.TEST_PLUGIN, None)
return db.create_pending_row(self.db_context, resource_type,
'id', odl_const.ODL_DELETE, {})
示例9: setUp
def setUp(self):
super(RpcCallbacksTestCase, self).setUp()
self.type_manager = managers.TypeManager()
self.notifier = plugin_rpc.AgentNotifierApi(topics.AGENT)
self.callbacks = plugin_rpc.RpcCallbacks(self.notifier,
self.type_manager)
self.plugin = mock.MagicMock()
directory.add_plugin(plugin_constants.CORE, self.plugin)
示例10: _setup_delete_current_gw_port_deletes_dvr_internal_ports
def _setup_delete_current_gw_port_deletes_dvr_internal_ports(
self, port=None, gw_port=True, new_network_id='ext_net_id_2'):
router_db = {
'name': 'foo_router',
'admin_state_up': True,
'distributed': True
}
router = self._create_router(router_db)
if gw_port:
with self.subnet(cidr='10.10.10.0/24') as subnet:
port_dict = {
'device_id': router.id,
'device_owner': const.DEVICE_OWNER_ROUTER_GW,
'admin_state_up': True,
'fixed_ips': [{'subnet_id': subnet['subnet']['id'],
'ip_address': '10.10.10.100'}]
}
net_id = subnet['subnet']['network_id']
port_res = self.create_port(net_id, port_dict)
port_res_dict = self.deserialize(self.fmt, port_res)
with self.ctx.session.begin(subtransactions=True):
port_db = self.ctx.session.query(models_v2.Port).filter_by(
id=port_res_dict['port']['id']).one()
router.gw_port = port_db
router_port = l3_models.RouterPort(
router_id=router.id,
port_id=port_db.id,
port_type=const.DEVICE_OWNER_ROUTER_GW
)
self.ctx.session.add(router)
self.ctx.session.add(router_port)
else:
net_id = None
plugin = mock.Mock()
directory.add_plugin(plugin_constants.CORE, plugin)
with mock.patch.object(l3_dvr_db.l3_db.L3_NAT_db_mixin,
'router_gw_port_has_floating_ips',
return_value=False),\
mock.patch.object(
self.mixin,
'_get_router') as grtr,\
mock.patch.object(
self.mixin,
'delete_csnat_router_interface_ports') as del_csnat_port,\
mock.patch.object(
self.mixin,
'delete_floatingip_agent_gateway_port') as del_agent_gw_port,\
mock.patch.object(
self.mixin.l3_rpc_notifier,
'delete_fipnamespace_for_ext_net') as del_fip:
plugin.get_ports.return_value = port
grtr.return_value = router
self.mixin._delete_current_gw_port(
self.ctx, router['id'], router, new_network_id)
return router, plugin, net_id, del_csnat_port,\
del_agent_gw_port, del_fip
示例11: _test_prepare_direct_delete_dvr_internal_ports
def _test_prepare_direct_delete_dvr_internal_ports(self, port):
plugin = mock.Mock()
directory.add_plugin(plugin_constants.CORE, plugin)
plugin.get_port.return_value = port
self.mixin._router_exists = mock.Mock(return_value=True)
self.assertRaises(exceptions.ServicePortInUse,
self.mixin.prevent_l3_port_deletion,
self.ctx,
port['id'])
示例12: setUp
def setUp(self):
super(TestAristaJSONRPCWrapper, self).setUp()
plugin_klass = importutils.import_class(
"neutron.db.db_base_plugin_v2.NeutronDbPluginV2")
directory.add_plugin(plugin_constants.CORE, plugin_klass())
setup_valid_config()
self.drv = arista_json.AristaRPCWrapperJSON()
self.drv._server_ip = "10.11.12.13"
self.region = 'RegionOne'
示例13: setUp
def setUp(self):
super(TestVpnValidation, self).setUp()
self.l3_plugin = mock.Mock()
self.core_plugin = mock.Mock()
directory.add_plugin(nconstants.CORE, self.core_plugin)
directory.add_plugin(nconstants.L3, self.l3_plugin)
self.context = n_ctx.Context('some_user', 'some_tenant')
self.validator = vpn_validator.VpnReferenceValidator()
self.router = mock.Mock()
self.router.gw_port = {'fixed_ips': [{'ip_address': '10.0.0.99'}]}
示例14: _add_side_effect
def _add_side_effect(self):
plugins = self._get_all_plugins()
resources = self._get_all_resources()
for resource_type, plugin_name in resources:
name = self._get_name(resource_type)
setattr(plugins[plugin_name][0], "get_%s" % name[12:],
getattr(self, name))
if directory.get_plugin(plugin_name) is None:
directory.add_plugin(plugin_name, plugins[plugin_name][0])
示例15: setUp
def setUp(self):
super(SyncServiceTest, self).setUp()
utils.setup_arista_wrapper_config(cfg)
plugin_klass = importutils.import_class(
"neutron.db.db_base_plugin_v2.NeutronDbPluginV2")
directory.add_plugin(plugin_constants.CORE, plugin_klass())
utils.setup_scenario()
self.mech_queue = queue.LightQueue()
self.sync_service = arista_sync.AristaSyncWorker(self.mech_queue)
self.sync_service._rpc = utils.MockCvx('region')