Merge "xenapi: Remove vestigial nova-network support"
This commit is contained in:
commit
f5df3eab23
@ -42,7 +42,6 @@ from nova import test
|
|||||||
from nova.tests.unit import fake_flavor
|
from nova.tests.unit import fake_flavor
|
||||||
from nova.tests.unit import fake_instance
|
from nova.tests.unit import fake_instance
|
||||||
from nova.tests.unit.virt.xenapi import stubs
|
from nova.tests.unit.virt.xenapi import stubs
|
||||||
from nova import utils
|
|
||||||
from nova.virt import fake
|
from nova.virt import fake
|
||||||
from nova.virt.xenapi import agent as xenapi_agent
|
from nova.virt.xenapi import agent as xenapi_agent
|
||||||
from nova.virt.xenapi import fake as xenapi_fake
|
from nova.virt.xenapi import fake as xenapi_fake
|
||||||
@ -712,10 +711,8 @@ class SpawnTestCase(VMOpsTestBase):
|
|||||||
@mock.patch.object(vmops.VMOps, '_get_neutron_events',
|
@mock.patch.object(vmops.VMOps, '_get_neutron_events',
|
||||||
return_value=[('network-vif-plugged', 1)])
|
return_value=[('network-vif-plugged', 1)])
|
||||||
def test_spawn_with_neutron(self, mock_get_neutron_events):
|
def test_spawn_with_neutron(self, mock_get_neutron_events):
|
||||||
self.flags(use_neutron=True)
|
|
||||||
network_info = [{'id': 1, 'active': True}]
|
network_info = [{'id': 1, 'active': True}]
|
||||||
self.stub_out('nova.virt.xenapi.vmops.VMOps.'
|
self.stub_out('nova.virt.xenapi.vmops.VMOps._neutron_failed_callback',
|
||||||
'_neutron_failed_callback',
|
|
||||||
lambda event_name, instance: None)
|
lambda event_name, instance: None)
|
||||||
|
|
||||||
self._test_spawn(network_info=network_info)
|
self._test_spawn(network_info=network_info)
|
||||||
@ -1115,8 +1112,7 @@ class SpawnTestCase(VMOpsTestBase):
|
|||||||
mock_resetnetwork.assert_called_once_with()
|
mock_resetnetwork.assert_called_once_with()
|
||||||
mock_update_if_needed.assert_called_once_with('1.2.3')
|
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):
|
||||||
def test_get_neutron_event(self, mock_is_neutron):
|
|
||||||
network_info = [{"active": False, "id": 1},
|
network_info = [{"active": False, "id": 1},
|
||||||
{"active": True, "id": 2},
|
{"active": True, "id": 2},
|
||||||
{"active": False, "id": 3},
|
{"active": False, "id": 3},
|
||||||
@ -1131,21 +1127,7 @@ class SpawnTestCase(VMOpsTestBase):
|
|||||||
self.assertEqual("network-vif-plugged", events[1][0])
|
self.assertEqual("network-vif-plugged", events[1][0])
|
||||||
self.assertEqual(3, events[1][1])
|
self.assertEqual(3, events[1][1])
|
||||||
|
|
||||||
@mock.patch.object(utils, 'is_neutron', return_value=False)
|
def test_get_neutron_event_power_off(self):
|
||||||
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):
|
|
||||||
network_info = [{"active": False, "id": 1},
|
network_info = [{"active": False, "id": 1},
|
||||||
{"active": True, "id": 2},
|
{"active": True, "id": 2},
|
||||||
{"active": False, "id": 3},
|
{"active": False, "id": 3},
|
||||||
@ -1157,8 +1139,7 @@ class SpawnTestCase(VMOpsTestBase):
|
|||||||
power_on, first_boot, rescue)
|
power_on, first_boot, rescue)
|
||||||
self.assertEqual([], events)
|
self.assertEqual([], events)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'is_neutron', return_value=True)
|
def test_get_neutron_event_not_first_boot(self):
|
||||||
def test_get_neutron_event_not_first_boot(self, mock_is_neutron):
|
|
||||||
network_info = [{"active": False, "id": 1},
|
network_info = [{"active": False, "id": 1},
|
||||||
{"active": True, "id": 2},
|
{"active": True, "id": 2},
|
||||||
{"active": False, "id": 3},
|
{"active": False, "id": 3},
|
||||||
@ -1170,8 +1151,7 @@ class SpawnTestCase(VMOpsTestBase):
|
|||||||
power_on, first_boot, rescue)
|
power_on, first_boot, rescue)
|
||||||
self.assertEqual([], events)
|
self.assertEqual([], events)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'is_neutron', return_value=True)
|
def test_get_neutron_event_rescue(self):
|
||||||
def test_get_neutron_event_rescue(self, mock_is_neutron):
|
|
||||||
network_info = [{"active": False, "id": 1},
|
network_info = [{"active": False, "id": 1},
|
||||||
{"active": True, "id": 2},
|
{"active": True, "id": 2},
|
||||||
{"active": False, "id": 3},
|
{"active": False, "id": 3},
|
||||||
|
@ -285,7 +285,6 @@ class XenAPIVMTestCase(stubs.XenAPITestBase,
|
|||||||
"""Unit tests for VM operations."""
|
"""Unit tests for VM operations."""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(XenAPIVMTestCase, self).setUp()
|
super(XenAPIVMTestCase, self).setUp()
|
||||||
self.useFixture(test.SampleNetworks())
|
|
||||||
self.network = importutils.import_object(CONF.network_manager)
|
self.network = importutils.import_object(CONF.network_manager)
|
||||||
self.fixture = self.useFixture(config_fixture.Config(lockutils.CONF))
|
self.fixture = self.useFixture(config_fixture.Config(lockutils.CONF))
|
||||||
self.fixture.config(disable_process_locking=True,
|
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_inject_auto_disk_config.assert_called_once_with(instance,
|
||||||
mock.ANY)
|
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):
|
def test_spawn_with_network_qos(self):
|
||||||
self._create_instance()
|
self._create_instance()
|
||||||
for vif_ref in xenapi_fake.get_all('VIF'):
|
for vif_ref in xenapi_fake.get_all('VIF'):
|
||||||
|
@ -684,8 +684,7 @@ class VMOps(object):
|
|||||||
# With VIF whose status is active, neutron may not notify such event.
|
# 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
|
# Don't get network-vif-plugged events from rescued VM or migrated VM
|
||||||
timeout = CONF.vif_plugging_timeout
|
timeout = CONF.vif_plugging_timeout
|
||||||
if (utils.is_neutron() and power_on and timeout and first_boot and
|
if power_on and timeout and first_boot and not rescue:
|
||||||
not rescue):
|
|
||||||
return [('network-vif-plugged', vif['id'])
|
return [('network-vif-plugged', vif['id'])
|
||||||
for vif in network_info if vif.get('active', True) is False]
|
for vif in network_info if vif.get('active', True) is False]
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user