From 295100c3fefb32df5bf075ffcfab02a0f5e25395 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 25 Nov 2019 11:28:17 +0000 Subject: [PATCH] xenapi: Remove vestigial nova-network support I suspect there is more to be removed here, but this is all I could spot for the moment. Change-Id: Ifb8dc7de5d4845dd639fba71b853d38cdb851c7d Signed-off-by: Stephen Finucane --- nova/tests/unit/virt/xenapi/test_vmops.py | 30 ++--------- nova/tests/unit/virt/xenapi/test_xenapi.py | 60 ---------------------- nova/virt/xenapi/vmops.py | 3 +- 3 files changed, 6 insertions(+), 87 deletions(-) diff --git a/nova/tests/unit/virt/xenapi/test_vmops.py b/nova/tests/unit/virt/xenapi/test_vmops.py index 5cc5be810f6d..22bbf67359d6 100644 --- a/nova/tests/unit/virt/xenapi/test_vmops.py +++ b/nova/tests/unit/virt/xenapi/test_vmops.py @@ -42,7 +42,6 @@ from nova import test from nova.tests.unit import fake_flavor from nova.tests.unit import fake_instance from nova.tests.unit.virt.xenapi import stubs -from nova import utils from nova.virt import fake from nova.virt.xenapi import agent as xenapi_agent from nova.virt.xenapi import fake as xenapi_fake @@ -712,10 +711,8 @@ class SpawnTestCase(VMOpsTestBase): @mock.patch.object(vmops.VMOps, '_get_neutron_events', return_value=[('network-vif-plugged', 1)]) def test_spawn_with_neutron(self, mock_get_neutron_events): - self.flags(use_neutron=True) network_info = [{'id': 1, 'active': True}] - self.stub_out('nova.virt.xenapi.vmops.VMOps.' - '_neutron_failed_callback', + self.stub_out('nova.virt.xenapi.vmops.VMOps._neutron_failed_callback', lambda event_name, instance: None) self._test_spawn(network_info=network_info) @@ -1115,8 +1112,7 @@ class SpawnTestCase(VMOpsTestBase): mock_resetnetwork.assert_called_once_with() mock_update_if_needed.assert_called_once_with('1.2.3') - @mock.patch.object(utils, 'is_neutron', return_value=True) - def test_get_neutron_event(self, mock_is_neutron): + def test_get_neutron_event(self): network_info = [{"active": False, "id": 1}, {"active": True, "id": 2}, {"active": False, "id": 3}, @@ -1131,21 +1127,7 @@ class SpawnTestCase(VMOpsTestBase): self.assertEqual("network-vif-plugged", events[1][0]) self.assertEqual(3, events[1][1]) - @mock.patch.object(utils, 'is_neutron', return_value=False) - def test_get_neutron_event_not_neutron_network(self, mock_is_neutron): - network_info = [{"active": False, "id": 1}, - {"active": True, "id": 2}, - {"active": False, "id": 3}, - {"id": 4}] - power_on = True - first_boot = True - rescue = False - events = self.vmops._get_neutron_events(network_info, - power_on, first_boot, rescue) - self.assertEqual([], events) - - @mock.patch.object(utils, 'is_neutron', return_value=True) - def test_get_neutron_event_power_off(self, mock_is_neutron): + def test_get_neutron_event_power_off(self): network_info = [{"active": False, "id": 1}, {"active": True, "id": 2}, {"active": False, "id": 3}, @@ -1157,8 +1139,7 @@ class SpawnTestCase(VMOpsTestBase): power_on, first_boot, rescue) self.assertEqual([], events) - @mock.patch.object(utils, 'is_neutron', return_value=True) - def test_get_neutron_event_not_first_boot(self, mock_is_neutron): + def test_get_neutron_event_not_first_boot(self): network_info = [{"active": False, "id": 1}, {"active": True, "id": 2}, {"active": False, "id": 3}, @@ -1170,8 +1151,7 @@ class SpawnTestCase(VMOpsTestBase): power_on, first_boot, rescue) self.assertEqual([], events) - @mock.patch.object(utils, 'is_neutron', return_value=True) - def test_get_neutron_event_rescue(self, mock_is_neutron): + def test_get_neutron_event_rescue(self): network_info = [{"active": False, "id": 1}, {"active": True, "id": 2}, {"active": False, "id": 3}, diff --git a/nova/tests/unit/virt/xenapi/test_xenapi.py b/nova/tests/unit/virt/xenapi/test_xenapi.py index 0985fe332077..27d65fff586f 100644 --- a/nova/tests/unit/virt/xenapi/test_xenapi.py +++ b/nova/tests/unit/virt/xenapi/test_xenapi.py @@ -285,7 +285,6 @@ class XenAPIVMTestCase(stubs.XenAPITestBase, """Unit tests for VM operations.""" def setUp(self): super(XenAPIVMTestCase, self).setUp() - self.useFixture(test.SampleNetworks()) self.network = importutils.import_object(CONF.network_manager) self.fixture = self.useFixture(config_fixture.Config(lockutils.CONF)) self.fixture.config(disable_process_locking=True, @@ -1134,65 +1133,6 @@ class XenAPIVMTestCase(stubs.XenAPITestBase, mock_inject_auto_disk_config.assert_called_once_with(instance, mock.ANY) - @mock.patch.object(vmops.VMOps, '_create_vifs') - @mock.patch('nova.privsep.linux_net.add_bridge', return_value=('', '')) - @mock.patch('nova.privsep.linux_net.set_device_mtu') - @mock.patch('nova.privsep.linux_net.set_device_enabled') - @mock.patch('nova.privsep.linux_net.set_device_macaddr') - @mock.patch('nova.privsep.linux_net.change_ip') - @mock.patch('nova.privsep.linux_net.address_command_deprecated') - @mock.patch('nova.privsep.linux_net.ipv4_forwarding_check', - return_value=False) - @mock.patch('nova.privsep.linux_net._enable_ipv4_forwarding_inner') - @mock.patch('nova.privsep.linux_net.add_vlan') - @mock.patch('nova.privsep.linux_net.iptables_get_rules', - return_value=('', '')) - @mock.patch('nova.privsep.linux_net.iptables_set_rules', - return_value=('', '')) - @mock.patch('nova.privsep.linux_net.bridge_setfd') - @mock.patch('nova.privsep.linux_net.bridge_disable_stp') - @mock.patch('nova.privsep.linux_net.bridge_add_interface', - return_value=('', '')) - def test_spawn_vlanmanager(self, mock_bridge_add_interface, - mock_bridge_disable_stp, - mock_bridge_setfd, - mock_iptables_set_rules, - mock_iptables_get_rules, - mock_add_vlan, mock_forwarding_enable, - mock_forwarding_check, - mock_address_command_horrid, - mock_change_ip, mock_set_macaddr, - mock_set_enabled, mock_set_mtu, mock_add_bridge, - mock_create_vifs): - self.flags(network_manager='nova.network.manager.VlanManager', - vlan_interface='fake0') - # Reset network table - xenapi_fake.reset_table('network') - # Instance 2 will use vlan network (see db/fakes.py) - ctxt = self.context.elevated() - inst2 = self._create_instance(False, obj=True) - networks = self.network.db.network_get_all(ctxt) - with mock.patch('nova.objects.network.Network._from_db_object'): - for network in networks: - self.network.set_network_host(ctxt, network) - - self.network.allocate_for_instance(ctxt, - instance_id=inst2.id, - instance_uuid=inst2.uuid, - host=CONF.host, - vpn=None, - rxtx_factor=3, - project_id=self.project_id, - macs=None) - self._test_spawn(IMAGE_MACHINE, - IMAGE_KERNEL, - IMAGE_RAMDISK, - instance_id=inst2.id, - create_record=False) - # TODO(salvatore-orlando): a complete test here would require - # a check for making sure the bridge for the VM's VIF is - # consistent with bridge specified in nova db - def test_spawn_with_network_qos(self): self._create_instance() for vif_ref in xenapi_fake.get_all('VIF'): diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 0b6f3bc8cdb1..f960deab505b 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -684,8 +684,7 @@ class VMOps(object): # With VIF whose status is active, neutron may not notify such event. # Don't get network-vif-plugged events from rescued VM or migrated VM timeout = CONF.vif_plugging_timeout - if (utils.is_neutron() and power_on and timeout and first_boot and - not rescue): + if power_on and timeout and first_boot and not rescue: return [('network-vif-plugged', vif['id']) for vif in network_info if vif.get('active', True) is False] else: