本文整理汇总了Python中neutron_lib.plugins.directory.add_plugin方法的典型用法代码示例。如果您正苦于以下问题:Python directory.add_plugin方法的具体用法?Python directory.add_plugin怎么用?Python directory.add_plugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neutron_lib.plugins.directory
的用法示例。
在下文中一共展示了directory.add_plugin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def setUp(self):
super(TestIPsecDriver, self).setUp()
mock.patch('neutron_lib.rpc.Connection').start()
l3_agent = mock.Mock()
l3_agent.host = FAKE_HOST
plugin = mock.Mock()
plugin.get_l3_agents_hosting_routers.return_value = [l3_agent]
directory.add_plugin(constants.CORE, plugin)
directory.add_plugin(constants.L3, plugin)
self.svc_plugin = mock.Mock()
self.svc_plugin.get_l3_agents_hosting_routers.return_value = [l3_agent]
self._fake_vpn_router_id = _uuid()
self.svc_plugin._get_vpnservice.return_value = {
'router_id': self._fake_vpn_router_id
}
self.driver = ipsec_driver.IPsecVPNDriver(self.svc_plugin)
self.validator = ipsec_validator.IpsecVpnValidator(self.driver)
self.context = n_ctx.get_admin_context()
示例2: test_get_provider_for_flavor_id_provider_not_found
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def test_get_provider_for_flavor_id_provider_not_found(self):
FLAVOR_ID = _uuid()
FAKE_FLAVOR = {'id': FLAVOR_ID,
'service_type': p_constants.VPN,
'enabled': True}
PROVIDERS = [{'provider': 'SOME_PROVIDER'}]
directory.add_plugin(p_constants.FLAVORS,
flavors_plugin.FlavorsPlugin())
mock.patch(
'neutron.services.flavors.flavors_plugin.FlavorsPlugin.get_flavor',
return_value=FAKE_FLAVOR).start()
mock.patch(
'neutron.services.flavors.flavors_plugin.'
'FlavorsPlugin.get_flavor_next_provider',
return_value=PROVIDERS).start()
with self.vpnservices_providers_set():
driver_plugin = vpn_plugin.VPNDriverPlugin()
self.assertRaises(
vpn_flavors.NoProviderFoundForFlavor,
driver_plugin._get_provider_for_flavor,
self.adminContext,
FLAVOR_ID)
示例3: test_get_provider_for_flavor_id
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def test_get_provider_for_flavor_id(self):
FLAVOR_ID = _uuid()
FAKE_FLAVOR = {'id': FLAVOR_ID,
'service_type': p_constants.VPN,
'enabled': True}
PROVIDERS = [{'provider': 'dummy'}]
directory.add_plugin(p_constants.FLAVORS,
flavors_plugin.FlavorsPlugin())
mock.patch(
'neutron.services.flavors.flavors_plugin.FlavorsPlugin.get_flavor',
return_value=FAKE_FLAVOR).start()
mock.patch(
'neutron.services.flavors.flavors_plugin.'
'FlavorsPlugin.get_flavor_next_provider',
return_value=PROVIDERS).start()
with self.vpnservices_providers_set():
driver_plugin = vpn_plugin.VPNDriverPlugin()
self.assertEqual(
'dummy',
driver_plugin._get_provider_for_flavor(
self.adminContext, FLAVOR_ID))
示例4: _mock_l2_resources
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def _mock_l2_resources(self):
expected_journal = {odl_const.ODL_NETWORK: '1',
odl_const.ODL_SUBNET: '2',
odl_const.ODL_PORT: '3'}
network_id = expected_journal[odl_const.ODL_NETWORK]
plugin = mock.Mock()
plugin.get_networks.return_value = [{'id': network_id}]
plugin.get_subnets.return_value = [
{'id': expected_journal[odl_const.ODL_SUBNET],
'network_id': network_id}]
port = {'id': expected_journal[odl_const.ODL_PORT],
odl_const.ODL_SGS: None,
'tenant_id': '123',
'fixed_ips': [],
'network_id': network_id}
plugin.get_ports.side_effect = ([port], [])
directory.add_plugin(constants.CORE, plugin)
return expected_journal
示例5: setUp
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def setUp(self):
self._extension_drivers.append('qos')
super(TestDFTrunkDriver, self).setUp()
drivers_patch = mock.patch.object(trunk_drivers, 'register')
self.addCleanup(drivers_patch.stop)
drivers_patch.start()
compat_patch = mock.patch.object(
trunk_plugin.TrunkPlugin, 'check_compatibility')
self.addCleanup(compat_patch.stop)
compat_patch.start()
self.trunk_plugin = trunk_plugin.TrunkPlugin()
self.trunk_plugin.add_segmentation_type('vlan', lambda x: True)
cfg.CONF.set_override('mechanism_drivers', 'df', group='ml2')
directory.add_plugin('trunk', self.trunk_plugin)
self.df_driver = self.mech_driver.trunk_driver
示例6: test_get_provider_for_flavor_id_invalid_type
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def test_get_provider_for_flavor_id_invalid_type(self):
FAKE_FLAVOR = {'service_type': 'NOT_VPN'}
directory.add_plugin(p_constants.FLAVORS,
flavors_plugin.FlavorsPlugin())
mock.patch(
'neutron.services.flavors.flavors_plugin.FlavorsPlugin.get_flavor',
return_value=FAKE_FLAVOR).start()
with self.vpnservices_providers_set():
driver_plugin = vpn_plugin.VPNDriverPlugin()
self.assertRaises(
lib_exc.InvalidServiceType,
driver_plugin._get_provider_for_flavor,
self.adminContext,
_uuid())
示例7: test_get_provider_for_flavor_id_flavor_disabled
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def test_get_provider_for_flavor_id_flavor_disabled(self):
FAKE_FLAVOR = {'service_type': p_constants.VPN,
'enabled': False}
directory.add_plugin(p_constants.FLAVORS,
flavors_plugin.FlavorsPlugin())
mock.patch(
'neutron.services.flavors.flavors_plugin.FlavorsPlugin.get_flavor',
return_value=FAKE_FLAVOR).start()
with self.vpnservices_providers_set():
driver_plugin = vpn_plugin.VPNDriverPlugin()
self.assertRaises(
flav_exc.FlavorDisabled,
driver_plugin._get_provider_for_flavor,
self.adminContext,
_uuid())
示例8: setUp
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
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'}]}
示例9: setUp
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def setUp(self):
super(TestBgpSpeakerRpcCallback, self).setUp()
self.plugin = mock.Mock()
directory.add_plugin(bgp_ext.BGP_EXT_ALIAS, self.plugin)
self.callback = bgp_speaker_rpc.BgpSpeakerRpcCallback()
示例10: test_l2gateway_con_create_with_invalid_net_id
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def test_l2gateway_con_create_with_invalid_net_id(self):
"""Test l2 gateway connection create with invalid net id."""
name = "l2gw_con2"
device_name = "device_name2"
data_l2gw = self._get_l2_gateway_data(name,
device_name)
gw = self._create_l2gateway(data_l2gw)
net_id = 'invalid_net_id'
l2gw_id = gw['id']
data_con = {self.con_resource: {'l2_gateway_id': l2gw_id,
'network_id': net_id}}
directory.add_plugin('CORE', self.plugin)
self.assertRaises(exc.NetworkNotFound,
self._validate_l2_gateway_connection_for_create,
data_con)
示例11: test_l2gw_callback_update_port
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def test_l2gw_callback_update_port(self):
service_plugin = mock.Mock()
directory.add_plugin(constants.L2GW, service_plugin)
fake_context = mock.Mock()
fake_port = mock.Mock()
fake_kwargs = {'context': fake_context,
'port': fake_port}
l2gateway_db.l2gw_callback(resources.PORT,
events.AFTER_UPDATE,
mock.Mock(),
**fake_kwargs)
self.assertTrue(service_plugin.add_port_mac.called)
示例12: test_l2gw_callback_delete_port
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def test_l2gw_callback_delete_port(self):
service_plugin = mock.Mock()
directory.add_plugin(constants.L2GW, service_plugin)
fake_context = mock.Mock()
fake_port = mock.Mock()
fake_kwargs = {'context': fake_context,
'port': fake_port}
l2gateway_db.l2gw_callback(resources.PORT,
events.AFTER_DELETE,
mock.Mock(),
**fake_kwargs)
self.assertTrue(service_plugin.delete_port_mac.called)
示例13: setUp
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def setUp(self):
self.useFixture(nlib_fixture.PluginDirectoryFixture())
super(QoSDriverTests, self).setUp()
self.qos_plug = qos_plugin.QoSPlugin()
directory.add_plugin('QOS', self.qos_plug)
ext_mgr = QoSTestExtensionManager()
self.resource_prefix_map = {'policies': '/qos'}
self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
tenant_id = uuidutils.generate_uuid()
self.policy_data = {
'policy': {'name': 'test-policy', 'tenant_id': tenant_id}}
示例14: _clean_registered_plugins
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def _clean_registered_plugins(self):
for plugin_type in self._get_all_plugins().keys():
directory.add_plugin(plugin_type, None)
示例15: _test_full_sync_resources
# 需要导入模块: from neutron_lib.plugins import directory [as 别名]
# 或者: from neutron_lib.plugins.directory import add_plugin [as 别名]
def _test_full_sync_resources(self, expected_journal):
self._mock_canary_missing()
directory.add_plugin(constants.CORE, mock.Mock())
full_sync.full_sync(self.db_context)
rows = self._assert_canary_created()
rows = self._filter_out_canary(rows)
self.assertItemsEqual(expected_journal.keys(),
[row['object_type'] for row in rows])
for row in rows:
self.assertEqual(expected_journal[row['object_type']],
row['object_uuid'])