update xen to use network_model
blueprint xenapi-network-info-model updated xenapi to use the new network info models also: updated virt firewall to handle both old version and new hotness made a few minor changes to the network info model moved the legacy converstion shim from compute/utils to the model itself wharrgarbl'd a few of the tests NOTE: no unittests were skipped during the creation of this patch Change-Id: Ib77dd2bf4f0a525b73800441f19013e842c77f98
This commit is contained in:
@@ -30,7 +30,6 @@ from xml.dom import minidom
|
|||||||
from nova.api.ec2 import cloud
|
from nova.api.ec2 import cloud
|
||||||
from nova.compute import instance_types
|
from nova.compute import instance_types
|
||||||
from nova.compute import power_state
|
from nova.compute import power_state
|
||||||
from nova.compute import utils as compute_utils
|
|
||||||
from nova.compute import vm_states
|
from nova.compute import vm_states
|
||||||
from nova import context
|
from nova import context
|
||||||
from nova import db
|
from nova import db
|
||||||
@@ -1892,7 +1891,7 @@ class IptablesFirewallTestCase(test.TestCase):
|
|||||||
|
|
||||||
_fake_stub_out_get_nw_info(self.stubs, lambda *a, **kw: network_model)
|
_fake_stub_out_get_nw_info(self.stubs, lambda *a, **kw: network_model)
|
||||||
|
|
||||||
network_info = compute_utils.legacy_network_info(network_model)
|
network_info = network_model.legacy()
|
||||||
self.fw.prepare_instance_filter(instance_ref, network_info)
|
self.fw.prepare_instance_filter(instance_ref, network_info)
|
||||||
self.fw.apply_instance_filter(instance_ref, network_info)
|
self.fw.apply_instance_filter(instance_ref, network_info)
|
||||||
|
|
||||||
|
@@ -75,7 +75,7 @@ class LibvirtVifTestCase(test.TestCase):
|
|||||||
conf.memory = 100 * 1024
|
conf.memory = 100 * 1024
|
||||||
conf.vcpus = 4
|
conf.vcpus = 4
|
||||||
|
|
||||||
nic = driver.plug(self.instance, self.net, self.mapping)
|
nic = driver.plug(self.instance, (self.net, self.mapping))
|
||||||
conf.add_device(nic)
|
conf.add_device(nic)
|
||||||
return conf.to_xml()
|
return conf.to_xml()
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ class LibvirtVifTestCase(test.TestCase):
|
|||||||
mac = node.find("mac").get("address")
|
mac = node.find("mac").get("address")
|
||||||
self.assertEqual(mac, self.mapping['mac'])
|
self.assertEqual(mac, self.mapping['mac'])
|
||||||
|
|
||||||
d.unplug(None, self.net, self.mapping)
|
d.unplug(None, (self.net, self.mapping))
|
||||||
|
|
||||||
def test_ovs_ethernet_driver(self):
|
def test_ovs_ethernet_driver(self):
|
||||||
d = vif.LibvirtOpenVswitchDriver()
|
d = vif.LibvirtOpenVswitchDriver()
|
||||||
@@ -111,7 +111,7 @@ class LibvirtVifTestCase(test.TestCase):
|
|||||||
script = node.find("script").get("path")
|
script = node.find("script").get("path")
|
||||||
self.assertEquals(script, "")
|
self.assertEquals(script, "")
|
||||||
|
|
||||||
d.unplug(None, self.net, self.mapping)
|
d.unplug(None, (self.net, self.mapping))
|
||||||
|
|
||||||
def test_ovs_virtualport_driver(self):
|
def test_ovs_virtualport_driver(self):
|
||||||
d = vif.LibvirtOpenVswitchVirtualPortDriver()
|
d = vif.LibvirtOpenVswitchVirtualPortDriver()
|
||||||
@@ -137,7 +137,7 @@ class LibvirtVifTestCase(test.TestCase):
|
|||||||
iface_id_found = True
|
iface_id_found = True
|
||||||
|
|
||||||
self.assertTrue(iface_id_found)
|
self.assertTrue(iface_id_found)
|
||||||
d.unplug(None, self.net, self.mapping)
|
d.unplug(None, (self.net, self.mapping))
|
||||||
|
|
||||||
def test_quantum_bridge_ethernet_driver(self):
|
def test_quantum_bridge_ethernet_driver(self):
|
||||||
d = vif.QuantumLinuxBridgeVIFDriver()
|
d = vif.QuantumLinuxBridgeVIFDriver()
|
||||||
@@ -155,4 +155,4 @@ class LibvirtVifTestCase(test.TestCase):
|
|||||||
script = node.find("script").get("path")
|
script = node.find("script").get("path")
|
||||||
self.assertEquals(script, "")
|
self.assertEquals(script, "")
|
||||||
|
|
||||||
d.unplug(None, self.net, self.mapping)
|
d.unplug(None, (self.net, self.mapping))
|
||||||
|
@@ -29,7 +29,6 @@ from nova.compute import aggregate_states
|
|||||||
from nova.compute import instance_types
|
from nova.compute import instance_types
|
||||||
from nova.compute import power_state
|
from nova.compute import power_state
|
||||||
from nova.compute import task_states
|
from nova.compute import task_states
|
||||||
from nova.compute import utils as compute_utils
|
|
||||||
from nova.compute import vm_states
|
from nova.compute import vm_states
|
||||||
from nova import context
|
from nova import context
|
||||||
from nova import db
|
from nova import db
|
||||||
@@ -377,24 +376,28 @@ class XenAPIVMTestCase(test.TestCase):
|
|||||||
if check_injection:
|
if check_injection:
|
||||||
xenstore_data = self.vm['xenstore_data']
|
xenstore_data = self.vm['xenstore_data']
|
||||||
self.assertEquals(xenstore_data['vm-data/hostname'], 'test')
|
self.assertEquals(xenstore_data['vm-data/hostname'], 'test')
|
||||||
key = 'vm-data/networking/DEADBEEF0000'
|
key = 'vm-data/networking/DEADBEEF0001'
|
||||||
xenstore_value = xenstore_data[key]
|
xenstore_value = xenstore_data[key]
|
||||||
tcpip_data = ast.literal_eval(xenstore_value)
|
tcpip_data = ast.literal_eval(xenstore_value)
|
||||||
self.assertEquals(tcpip_data,
|
self.assertEquals(tcpip_data,
|
||||||
{'broadcast': '192.168.0.255',
|
{'broadcast': '192.168.1.255',
|
||||||
'dns': ['192.168.0.1'],
|
'dns': ['192.168.1.3', '192.168.1.4'],
|
||||||
'gateway': '192.168.0.1',
|
'gateway': '192.168.1.1',
|
||||||
'gateway_v6': 'dead:beef::1',
|
'gateway_v6': 'fe80::def',
|
||||||
'ip6s': [{'enabled': '1',
|
'ip6s': [{'enabled': '1',
|
||||||
'ip': 'dead:beef::dcad:beff:feef:0',
|
'ip': '2001:db8:0:1::1',
|
||||||
'netmask': '64'}],
|
'netmask': 64,
|
||||||
|
'gateway': 'fe80::def'}],
|
||||||
'ips': [{'enabled': '1',
|
'ips': [{'enabled': '1',
|
||||||
'ip': '192.168.0.100',
|
'ip': '192.168.1.100',
|
||||||
'netmask': '255.255.255.0'}],
|
'netmask': '255.255.255.0',
|
||||||
'dhcp_server': '192.168.0.1',
|
'gateway': '192.168.1.1'},
|
||||||
'label': 'fake',
|
{'enabled': '1',
|
||||||
'mac': 'DE:AD:BE:EF:00:00',
|
'ip': '192.168.1.101',
|
||||||
'rxtx_cap': 3})
|
'netmask': '255.255.255.0',
|
||||||
|
'gateway': '192.168.1.1'}],
|
||||||
|
'label': 'test1',
|
||||||
|
'mac': 'DE:AD:BE:EF:00:01'})
|
||||||
|
|
||||||
def check_vm_params_for_windows(self):
|
def check_vm_params_for_windows(self):
|
||||||
self.assertEquals(self.vm['platform']['nx'], 'true')
|
self.assertEquals(self.vm['platform']['nx'], 'true')
|
||||||
@@ -467,27 +470,12 @@ class XenAPIVMTestCase(test.TestCase):
|
|||||||
instance = db.instance_create(self.context, instance_values)
|
instance = db.instance_create(self.context, instance_values)
|
||||||
else:
|
else:
|
||||||
instance = db.instance_get(self.context, instance_id)
|
instance = db.instance_get(self.context, instance_id)
|
||||||
network_info = [({'bridge': 'fa0', 'id': 0,
|
|
||||||
'injected': True,
|
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
|
||||||
'cidr': '192.168.0.0/24',
|
spectacular=True)
|
||||||
'cidr_v6': 'dead:beef::1/120',
|
|
||||||
},
|
|
||||||
{'broadcast': '192.168.0.255',
|
|
||||||
'dns': ['192.168.0.1'],
|
|
||||||
'gateway': '192.168.0.1',
|
|
||||||
'gateway_v6': 'dead:beef::1',
|
|
||||||
'ip6s': [{'enabled': '1',
|
|
||||||
'ip': 'dead:beef::dcad:beff:feef:0',
|
|
||||||
'netmask': '64'}],
|
|
||||||
'ips': [{'enabled': '1',
|
|
||||||
'ip': '192.168.0.100',
|
|
||||||
'netmask': '255.255.255.0'}],
|
|
||||||
'dhcp_server': '192.168.0.1',
|
|
||||||
'label': 'fake',
|
|
||||||
'mac': 'DE:AD:BE:EF:00:00',
|
|
||||||
'rxtx_cap': 3})]
|
|
||||||
if empty_dns:
|
if empty_dns:
|
||||||
network_info[0][1]['dns'] = []
|
# NOTE(tr3buchet): this is a terrible way to do this...
|
||||||
|
network_info[0]['network']['subnets'][0]['dns'] = []
|
||||||
|
|
||||||
# admin_pass isn't part of the DB model, but it does get set as
|
# admin_pass isn't part of the DB model, but it does get set as
|
||||||
# an attribute for spawn to use
|
# an attribute for spawn to use
|
||||||
@@ -605,11 +593,11 @@ class XenAPIVMTestCase(test.TestCase):
|
|||||||
index = config.index('auto eth0')
|
index = config.index('auto eth0')
|
||||||
self.assertEquals(config[index + 1:index + 8], [
|
self.assertEquals(config[index + 1:index + 8], [
|
||||||
'iface eth0 inet static',
|
'iface eth0 inet static',
|
||||||
'address 192.168.0.100',
|
'address 192.168.1.100',
|
||||||
'netmask 255.255.255.0',
|
'netmask 255.255.255.0',
|
||||||
'broadcast 192.168.0.255',
|
'broadcast 192.168.1.255',
|
||||||
'gateway 192.168.0.1',
|
'gateway 192.168.1.1',
|
||||||
'dns-nameservers 192.168.0.1',
|
'dns-nameservers 192.168.1.3 192.168.1.4',
|
||||||
''])
|
''])
|
||||||
self._tee_executed = True
|
self._tee_executed = True
|
||||||
return '', ''
|
return '', ''
|
||||||
@@ -708,7 +696,7 @@ class XenAPIVMTestCase(test.TestCase):
|
|||||||
vif_rec = xenapi_fake.get_record('VIF', vif_ref)
|
vif_rec = xenapi_fake.get_record('VIF', vif_ref)
|
||||||
self.assertEquals(vif_rec['qos_algorithm_type'], 'ratelimit')
|
self.assertEquals(vif_rec['qos_algorithm_type'], 'ratelimit')
|
||||||
self.assertEquals(vif_rec['qos_algorithm_params']['kbps'],
|
self.assertEquals(vif_rec['qos_algorithm_params']['kbps'],
|
||||||
str(3 * 1024))
|
str(3 * 10 * 1024))
|
||||||
|
|
||||||
def test_rescue(self):
|
def test_rescue(self):
|
||||||
instance = self._create_instance()
|
instance = self._create_instance()
|
||||||
@@ -778,25 +766,8 @@ class XenAPIVMTestCase(test.TestCase):
|
|||||||
'os_type': 'linux',
|
'os_type': 'linux',
|
||||||
'architecture': 'x86-64'}
|
'architecture': 'x86-64'}
|
||||||
instance = db.instance_create(self.context, instance_values)
|
instance = db.instance_create(self.context, instance_values)
|
||||||
network_info = [({'bridge': 'fa0', 'id': 0,
|
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
|
||||||
'injected': False,
|
spectacular=True)
|
||||||
'cidr': '192.168.0.0/24',
|
|
||||||
'cidr_v6': 'dead:beef::1/120',
|
|
||||||
},
|
|
||||||
{'broadcast': '192.168.0.255',
|
|
||||||
'dns': ['192.168.0.1'],
|
|
||||||
'gateway': '192.168.0.1',
|
|
||||||
'gateway_v6': 'dead:beef::1',
|
|
||||||
'ip6s': [{'enabled': '1',
|
|
||||||
'ip': 'dead:beef::dcad:beff:feef:0',
|
|
||||||
'netmask': '64'}],
|
|
||||||
'ips': [{'enabled': '1',
|
|
||||||
'ip': '192.168.0.100',
|
|
||||||
'netmask': '255.255.255.0'}],
|
|
||||||
'dhcp_server': '192.168.0.1',
|
|
||||||
'label': 'fake',
|
|
||||||
'mac': 'DE:AD:BE:EF:00:00',
|
|
||||||
'rxtx_cap': 3})]
|
|
||||||
image_meta = {'id': glance_stubs.FakeGlance.IMAGE_VHD,
|
image_meta = {'id': glance_stubs.FakeGlance.IMAGE_VHD,
|
||||||
'disk_format': 'vhd'}
|
'disk_format': 'vhd'}
|
||||||
if spawn:
|
if spawn:
|
||||||
@@ -951,20 +922,8 @@ class XenAPIMigrateInstance(test.TestCase):
|
|||||||
fake_finish_revert_migration)
|
fake_finish_revert_migration)
|
||||||
|
|
||||||
conn = xenapi_conn.get_connection(False)
|
conn = xenapi_conn.get_connection(False)
|
||||||
network_info = [({'bridge': 'fa0', 'id': 0, 'injected': False},
|
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
|
||||||
{'broadcast': '192.168.0.255',
|
spectacular=True)
|
||||||
'dns': ['192.168.0.1'],
|
|
||||||
'gateway': '192.168.0.1',
|
|
||||||
'gateway_v6': 'dead:beef::1',
|
|
||||||
'ip6s': [{'enabled': '1',
|
|
||||||
'ip': 'dead:beef::dcad:beff:feef:0',
|
|
||||||
'netmask': '64'}],
|
|
||||||
'ips': [{'enabled': '1',
|
|
||||||
'ip': '192.168.0.100',
|
|
||||||
'netmask': '255.255.255.0'}],
|
|
||||||
'label': 'fake',
|
|
||||||
'mac': 'DE:AD:BE:EF:00:00',
|
|
||||||
'rxtx_cap': 3})]
|
|
||||||
image_meta = {'id': instance.image_ref, 'disk_format': 'vhd'}
|
image_meta = {'id': instance.image_ref, 'disk_format': 'vhd'}
|
||||||
base = xenapi_fake.create_vdi('hurr', 'fake')
|
base = xenapi_fake.create_vdi('hurr', 'fake')
|
||||||
base_uuid = xenapi_fake.get_record('VDI', base)['uuid']
|
base_uuid = xenapi_fake.get_record('VDI', base)['uuid']
|
||||||
@@ -995,20 +954,8 @@ class XenAPIMigrateInstance(test.TestCase):
|
|||||||
"VDI_resize_online", fake_vdi_resize)
|
"VDI_resize_online", fake_vdi_resize)
|
||||||
|
|
||||||
conn = xenapi_conn.get_connection(False)
|
conn = xenapi_conn.get_connection(False)
|
||||||
network_info = [({'bridge': 'fa0', 'id': 0, 'injected': False},
|
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
|
||||||
{'broadcast': '192.168.0.255',
|
spectacular=True)
|
||||||
'dns': ['192.168.0.1'],
|
|
||||||
'gateway': '192.168.0.1',
|
|
||||||
'gateway_v6': 'dead:beef::1',
|
|
||||||
'ip6s': [{'enabled': '1',
|
|
||||||
'ip': 'dead:beef::dcad:beff:feef:0',
|
|
||||||
'netmask': '64'}],
|
|
||||||
'ips': [{'enabled': '1',
|
|
||||||
'ip': '192.168.0.100',
|
|
||||||
'netmask': '255.255.255.0'}],
|
|
||||||
'label': 'fake',
|
|
||||||
'mac': 'DE:AD:BE:EF:00:00',
|
|
||||||
'rxtx_cap': 3})]
|
|
||||||
image_meta = {'id': instance.image_ref, 'disk_format': 'vhd'}
|
image_meta = {'id': instance.image_ref, 'disk_format': 'vhd'}
|
||||||
conn.finish_migration(self.context, self.migration, instance,
|
conn.finish_migration(self.context, self.migration, instance,
|
||||||
dict(base_copy='hurr', cow='durr'),
|
dict(base_copy='hurr', cow='durr'),
|
||||||
@@ -1029,20 +976,8 @@ class XenAPIMigrateInstance(test.TestCase):
|
|||||||
self.stubs.Set(stubs.FakeSessionForVMTests,
|
self.stubs.Set(stubs.FakeSessionForVMTests,
|
||||||
"VDI_resize_online", fake_vdi_resize)
|
"VDI_resize_online", fake_vdi_resize)
|
||||||
conn = xenapi_conn.get_connection(False)
|
conn = xenapi_conn.get_connection(False)
|
||||||
network_info = [({'bridge': 'fa0', 'id': 0, 'injected': False},
|
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
|
||||||
{'broadcast': '192.168.0.255',
|
spectacular=True)
|
||||||
'dns': ['192.168.0.1'],
|
|
||||||
'gateway': '192.168.0.1',
|
|
||||||
'gateway_v6': 'dead:beef::1',
|
|
||||||
'ip6s': [{'enabled': '1',
|
|
||||||
'ip': 'dead:beef::dcad:beff:feef:0',
|
|
||||||
'netmask': '64'}],
|
|
||||||
'ips': [{'enabled': '1',
|
|
||||||
'ip': '192.168.0.100',
|
|
||||||
'netmask': '255.255.255.0'}],
|
|
||||||
'label': 'fake',
|
|
||||||
'mac': 'DE:AD:BE:EF:00:00',
|
|
||||||
'rxtx_cap': 3})]
|
|
||||||
image_meta = {'id': instance.image_ref, 'disk_format': 'vhd'}
|
image_meta = {'id': instance.image_ref, 'disk_format': 'vhd'}
|
||||||
conn.finish_migration(self.context, self.migration, instance,
|
conn.finish_migration(self.context, self.migration, instance,
|
||||||
dict(base_copy='hurr', cow='durr'),
|
dict(base_copy='hurr', cow='durr'),
|
||||||
@@ -1057,21 +992,8 @@ class XenAPIMigrateInstance(test.TestCase):
|
|||||||
self.stubs.Set(stubs.FakeSessionForVMTests,
|
self.stubs.Set(stubs.FakeSessionForVMTests,
|
||||||
"VDI_resize_online", fake_vdi_resize)
|
"VDI_resize_online", fake_vdi_resize)
|
||||||
conn = xenapi_conn.get_connection(False)
|
conn = xenapi_conn.get_connection(False)
|
||||||
network_info = [({'bridge': 'fa0', 'id': 0, 'injected': False},
|
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
|
||||||
{'broadcast': '192.168.0.255',
|
spectacular=True)
|
||||||
'dns': ['192.168.0.1'],
|
|
||||||
'gateway': '192.168.0.1',
|
|
||||||
'gateway_v6': 'dead:beef::1',
|
|
||||||
'ip6s': [{'enabled': '1',
|
|
||||||
'ip': 'dead:beef::dcad:beff:feef:0',
|
|
||||||
'netmask': '64'}],
|
|
||||||
'ips': [{'enabled': '1',
|
|
||||||
'ip': '192.168.0.100',
|
|
||||||
'netmask': '255.255.255.0'}],
|
|
||||||
'label': 'fake',
|
|
||||||
'mac': 'DE:AD:BE:EF:00:00',
|
|
||||||
'rxtx_cap': 3})]
|
|
||||||
|
|
||||||
# Resize instance would be determined by the compute call
|
# Resize instance would be determined by the compute call
|
||||||
image_meta = {'id': instance.image_ref, 'disk_format': 'vhd'}
|
image_meta = {'id': instance.image_ref, 'disk_format': 'vhd'}
|
||||||
conn.finish_migration(self.context, self.migration, instance,
|
conn.finish_migration(self.context, self.migration, instance,
|
||||||
@@ -1569,7 +1491,7 @@ class XenAPIDom0IptablesFirewallTestCase(test.TestCase):
|
|||||||
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
|
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
|
||||||
lambda *a, **kw: network_model)
|
lambda *a, **kw: network_model)
|
||||||
|
|
||||||
network_info = compute_utils.legacy_network_info(network_model)
|
network_info = network_model.legacy()
|
||||||
self.fw.prepare_instance_filter(instance_ref, network_info)
|
self.fw.prepare_instance_filter(instance_ref, network_info)
|
||||||
self.fw.apply_instance_filter(instance_ref, network_info)
|
self.fw.apply_instance_filter(instance_ref, network_info)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user