def test_nexus_plugin_calls_ignored_if_plugin_not_loaded(self): """Verifies Nexus plugin calls are ignored if plugin is not loaded.""" cisco_config.CONF.set_override(const.NEXUS_PLUGIN, None, 'CISCO_PLUGINS') with mock.patch.object(cisco_nexus_plugin_v2.NexusPlugin, 'create_network') as mock_create_network: model = virt_phy_sw_v2.VirtualPhysicalSwitchModelV2() model._invoke_plugin_per_device(model, const.NEXUS_PLUGIN, 'create_network') self.assertFalse(mock_create_network.called) with mock.patch.object(cisco_nexus_plugin_v2.NexusPlugin, 'update_port') as mock_update_port: model = virt_phy_sw_v2.VirtualPhysicalSwitchModelV2() model._invoke_plugin_per_device(model, const.NEXUS_PLUGIN, 'update_port') self.assertFalse(mock_update_port.called)
def test_non_nexus_device_driver(self): """Tests handling of an non-Nexus device driver being configured.""" with mock.patch.dict(sys.modules, {'mock_driver': mock.Mock()}): cisco_config.CONF.set_override('nexus_driver', 'mock_driver.Non_Nexus_Driver', 'CISCO') # Plugin model instance should have is_nexus_plugin set to False model = virt_phy_sw_v2.VirtualPhysicalSwitchModelV2() self.assertFalse(model.is_nexus_plugin) # Model's _invoke_nexus_for_net_create should just return False user_id = 'user_id' tenant_id = 'tenant_id' ctx = context.Context(user_id, tenant_id) self.assertFalse(model._invoke_nexus_for_net_create( ctx, tenant_id, net_id='net_id', instance_id='instance_id', host_id='host_id'))