本文整理汇总了Python中neutron_lib.plugins.directory.add_plugin函数的典型用法代码示例。如果您正苦于以下问题:Python add_plugin函数的具体用法?Python add_plugin怎么用?Python add_plugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_plugin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:mmalchuk,项目名称:openstack-neutron,代码行数:32,代码来源:manager.py
示例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)
开发者ID:openstack,项目名称:neutron,代码行数:35,代码来源:test_l3_dvr_db.py
示例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()
开发者ID:igordcard,项目名称:neutron,代码行数:7,代码来源:test_l3_agent_scheduler.py
示例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')
开发者ID:eayunstack,项目名称:neutron,代码行数:28,代码来源:test_providernet.py
示例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')
开发者ID:openstack,项目名称:neutron,代码行数:27,代码来源:test_l3_dvr_db.py
示例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()
开发者ID:cubeek,项目名称:neutron,代码行数:32,代码来源:test_validators.py
示例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"]))
开发者ID:openstack,项目名称:neutron,代码行数:8,代码来源:test_external_net.py
示例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, {})
开发者ID:openstack,项目名称:networking-odl,代码行数:8,代码来源:test_recovery.py
示例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)
开发者ID:eayunstack,项目名称:neutron,代码行数:8,代码来源:test_rpc.py
示例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
开发者ID:openstack,项目名称:neutron,代码行数:58,代码来源:test_l3_dvr_db.py
示例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'])
开发者ID:openstack,项目名称:neutron,代码行数:9,代码来源:test_l3_dvr_db.py
示例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'
开发者ID:openstack,项目名称:networking-arista,代码行数:9,代码来源:test_arista_json_rpc_wrapper.py
示例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'}]}
开发者ID:openstack,项目名称:neutron-vpnaas,代码行数:10,代码来源:test_vpn_validator.py
示例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])
开发者ID:openstack,项目名称:networking-odl,代码行数:10,代码来源:test_full_sync.py
示例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')
开发者ID:openstack,项目名称:networking-arista,代码行数:10,代码来源:test_arista_sync.py
示例16: test__get_agent_gw_ports_exist_for_network
def test__get_agent_gw_ports_exist_for_network(self):
plugin = mock.Mock()
directory.add_plugin(plugin_constants.CORE, plugin)
plugin.get_ports.return_value = []
self.mixin._get_agent_gw_ports_exist_for_network(
self.ctx, 'network_id', 'host', 'agent_id')
plugin.get_ports.assert_called_with(self.ctx, {
'network_id': ['network_id'],
'device_id': ['agent_id'],
'device_owner': [const.DEVICE_OWNER_AGENT_GW]})
开发者ID:openstack,项目名称:neutron,代码行数:10,代码来源:test_l3_dvr_db.py
示例17: _load_services_from_core_plugin
def _load_services_from_core_plugin(self, plugin):
"""Puts core plugin in service_plugins for supported services."""
LOG.debug("Loading services supported by the core plugin")
# supported service types are derived from supported extensions
for ext_alias in getattr(plugin, "supported_extension_aliases", []):
if ext_alias in constants.EXT_TO_SERVICE_MAPPING:
service_type = constants.EXT_TO_SERVICE_MAPPING[ext_alias]
directory.add_plugin(service_type, plugin)
LOG.info("Service %s is supported by the core plugin",
service_type)
开发者ID:mmalchuk,项目名称:openstack-neutron,代码行数:11,代码来源:manager.py
示例18: test_plugin_not_registered
def test_plugin_not_registered(self):
self._register_resources()
# NOTE(rajivk): workaround, as we don't have delete method for plugin
plugin = directory.get_plugin(helper.TEST_PLUGIN)
directory.add_plugin(helper.TEST_PLUGIN, None)
self.addCleanup(self.add_plugin, helper.TEST_PLUGIN, plugin)
self.assertRaises(exceptions.PluginMethodNotFound,
full_sync.sync_resources,
self.db_context,
helper.TEST_RESOURCE1)
self.assertEqual([], db.get_all_db_rows(self.db_context))
开发者ID:openstack,项目名称:networking-odl,代码行数:11,代码来源:test_full_sync.py
示例19: __init__
def __init__(self):
config.register_nsxv_azs(cfg.CONF, cfg.CONF.nsxv.availability_zones)
self.context = neutron_context.get_admin_context()
self.filters = get_plugin_filters(self.context)
super(NsxVPluginWrapper, self).__init__()
# Make this the core plugin
directory.add_plugin('CORE', self)
# finish the plugin initialization
# (with md-proxy config, but without housekeeping)
with mock.patch("vmware_nsx.plugins.common.housekeeper."
"housekeeper.NsxHousekeeper"):
self.init_complete(0, 0, 0)
开发者ID:openstack,项目名称:vmware-nsx,代码行数:12,代码来源:utils.py
示例20: test_can_be_trunked_returns_false
def test_can_be_trunked_returns_false(self):
# need to trigger a driver registration
fakes.FakeDriverCanTrunkBoundPort.create()
self.trunk_plugin = trunk_plugin.TrunkPlugin()
directory.add_plugin('trunk', self.trunk_plugin)
with self.port() as port:
core_plugin = directory.get_plugin()
port['port']['binding:host_id'] = 'host'
core_plugin.update_port(self.context, port['port']['id'], port)
validator = rules.TrunkPortValidator(port['port']['id'])
# port cannot be trunked because of binding mismatch
self.assertFalse(validator.can_be_trunked(self.context))
开发者ID:cubeek,项目名称:neutron,代码行数:12,代码来源:test_rules.py
注:本文中的neutron_lib.plugins.directory.add_plugin函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论