Port libvirt.test_vif to Python 3
We can't compare int or None with str on Python 3, need convert str into int or just skip. We do this comprehensively for vlan by ensuring that it is initially parsed as an int. Partially-Implements: blueprint goal-python35 Co-Authored-By: Matthew Booth <mbooth@redhat.com> Change-Id: I000839a341aa6164343b6c44e29a8b7d79084b73
This commit is contained in:
parent
83923ad227
commit
6a6457b5a6
|
@ -205,7 +205,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
||||||
vnic_type=network_model.VNIC_TYPE_DIRECT,
|
vnic_type=network_model.VNIC_TYPE_DIRECT,
|
||||||
ovs_interfaceid=None,
|
ovs_interfaceid=None,
|
||||||
details={
|
details={
|
||||||
network_model.VIF_DETAILS_VLAN: '100'},
|
network_model.VIF_DETAILS_VLAN: 100},
|
||||||
profile={'pci_vendor_info': '1137:0043',
|
profile={'pci_vendor_info': '1137:0043',
|
||||||
'pci_slot': '0000:0a:00.1',
|
'pci_slot': '0000:0a:00.1',
|
||||||
'physical_network': 'phynet1'})
|
'physical_network': 'phynet1'})
|
||||||
|
@ -228,7 +228,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
||||||
vnic_type=network_model.VNIC_TYPE_MACVTAP,
|
vnic_type=network_model.VNIC_TYPE_MACVTAP,
|
||||||
ovs_interfaceid=None,
|
ovs_interfaceid=None,
|
||||||
details={
|
details={
|
||||||
network_model.VIF_DETAILS_VLAN: '100'},
|
network_model.VIF_DETAILS_VLAN: 100},
|
||||||
profile={'pci_vendor_info': '1137:0043',
|
profile={'pci_vendor_info': '1137:0043',
|
||||||
'pci_slot': '0000:0a:00.1',
|
'pci_slot': '0000:0a:00.1',
|
||||||
'physical_network': 'phynet1'})
|
'physical_network': 'phynet1'})
|
||||||
|
@ -270,7 +270,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
||||||
vnic_type=network_model.VNIC_TYPE_DIRECT,
|
vnic_type=network_model.VNIC_TYPE_DIRECT,
|
||||||
ovs_interfaceid=None,
|
ovs_interfaceid=None,
|
||||||
details={
|
details={
|
||||||
network_model.VIF_DETAILS_VLAN: '100'},
|
network_model.VIF_DETAILS_VLAN: 100},
|
||||||
profile={'pci_vendor_info': '1137:0043',
|
profile={'pci_vendor_info': '1137:0043',
|
||||||
'pci_slot': '0000:0a:00.1',
|
'pci_slot': '0000:0a:00.1',
|
||||||
'physical_network': 'phynet1'})
|
'physical_network': 'phynet1'})
|
||||||
|
@ -360,7 +360,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
||||||
address='ca:fe:de:ad:be:ef',
|
address='ca:fe:de:ad:be:ef',
|
||||||
network=network_8021,
|
network=network_8021,
|
||||||
type=network_model.VIF_TYPE_MACVTAP,
|
type=network_model.VIF_TYPE_MACVTAP,
|
||||||
details={network_model.VIF_DETAILS_VLAN: '1',
|
details={network_model.VIF_DETAILS_VLAN: 1,
|
||||||
network_model.VIF_DETAILS_PHYS_INTERFACE: 'eth0',
|
network_model.VIF_DETAILS_PHYS_INTERFACE: 'eth0',
|
||||||
network_model.VIF_DETAILS_MACVTAP_SOURCE: 'eth0.1',
|
network_model.VIF_DETAILS_MACVTAP_SOURCE: 'eth0.1',
|
||||||
network_model.VIF_DETAILS_MACVTAP_MODE: 'vepa'})
|
network_model.VIF_DETAILS_MACVTAP_MODE: 'vepa'})
|
||||||
|
@ -1228,9 +1228,10 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
||||||
node = self._get_node(xml)
|
node = self._get_node(xml)
|
||||||
self._assertTypeAndPciEquals(node, "hostdev", self.vif_hw_veb)
|
self._assertTypeAndPciEquals(node, "hostdev", self.vif_hw_veb)
|
||||||
self._assertMacEquals(node, self.vif_hw_veb)
|
self._assertMacEquals(node, self.vif_hw_veb)
|
||||||
vlan = node.find("vlan").find("tag").get("id")
|
|
||||||
vlan_want = self.vif_hw_veb["details"]["vlan"]
|
conf = vconfig.LibvirtConfigGuestInterface()
|
||||||
self.assertEqual(vlan, vlan_want)
|
conf.parse_dom(node)
|
||||||
|
self.assertEqual(conf.vlan, self.vif_hw_veb["details"]["vlan"])
|
||||||
|
|
||||||
def test_hostdev_physical_driver(self):
|
def test_hostdev_physical_driver(self):
|
||||||
d = vif.LibvirtGenericVIFDriver()
|
d = vif.LibvirtGenericVIFDriver()
|
||||||
|
@ -1291,8 +1292,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
||||||
def test_macvtap_plug_vlan(self, ensure_vlan_mock):
|
def test_macvtap_plug_vlan(self, ensure_vlan_mock):
|
||||||
d = vif.LibvirtGenericVIFDriver()
|
d = vif.LibvirtGenericVIFDriver()
|
||||||
d.plug(self.instance, self.vif_macvtap_vlan)
|
d.plug(self.instance, self.vif_macvtap_vlan)
|
||||||
ensure_vlan_mock.assert_called_once_with('1', 'eth0',
|
ensure_vlan_mock.assert_called_once_with(1, 'eth0', interface='eth0.1')
|
||||||
interface='eth0.1')
|
|
||||||
|
|
||||||
@mock.patch.object(linux_net.LinuxBridgeInterfaceDriver, 'ensure_vlan')
|
@mock.patch.object(linux_net.LinuxBridgeInterfaceDriver, 'ensure_vlan')
|
||||||
def test_macvtap_plug_flat(self, ensure_vlan_mock):
|
def test_macvtap_plug_flat(self, ensure_vlan_mock):
|
||||||
|
|
|
@ -1254,7 +1254,7 @@ class LibvirtConfigGuestInterface(LibvirtConfigGuestDevice):
|
||||||
|
|
||||||
if self.vlan and self.net_type in ("direct", "hostdev"):
|
if self.vlan and self.net_type in ("direct", "hostdev"):
|
||||||
vlan_elem = etree.Element("vlan")
|
vlan_elem = etree.Element("vlan")
|
||||||
tag_elem = etree.Element("tag", id=self.vlan)
|
tag_elem = etree.Element("tag", id=str(self.vlan))
|
||||||
vlan_elem.append(tag_elem)
|
vlan_elem.append(tag_elem)
|
||||||
dev.append(vlan_elem)
|
dev.append(vlan_elem)
|
||||||
|
|
||||||
|
@ -1347,7 +1347,7 @@ class LibvirtConfigGuestInterface(LibvirtConfigGuestDevice):
|
||||||
# id in the vlan attribute.
|
# id in the vlan attribute.
|
||||||
for sub in c.getchildren():
|
for sub in c.getchildren():
|
||||||
if sub.tag == 'tag' and sub.get('id'):
|
if sub.tag == 'tag' and sub.get('id'):
|
||||||
self.vlan = sub.get('id')
|
self.vlan = int(sub.get('id'))
|
||||||
break
|
break
|
||||||
elif c.tag == 'virtualport':
|
elif c.tag == 'virtualport':
|
||||||
self.vporttype = c.get('type')
|
self.vporttype = c.get('type')
|
||||||
|
|
|
@ -147,7 +147,7 @@ class LibvirtGenericVIFDriver(object):
|
||||||
|
|
||||||
def _is_multiqueue_enabled(self, image_meta, flavor):
|
def _is_multiqueue_enabled(self, image_meta, flavor):
|
||||||
_, vhost_queues = self._get_virtio_mq_settings(image_meta, flavor)
|
_, vhost_queues = self._get_virtio_mq_settings(image_meta, flavor)
|
||||||
return vhost_queues > 1
|
return vhost_queues > 1 if vhost_queues is not None else False
|
||||||
|
|
||||||
def _get_virtio_mq_settings(self, image_meta, flavor):
|
def _get_virtio_mq_settings(self, image_meta, flavor):
|
||||||
"""A methods to set the number of virtio queues,
|
"""A methods to set the number of virtio queues,
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
nova.tests.unit.api.openstack.compute.test_user_data.ServersControllerCreateTest
|
nova.tests.unit.api.openstack.compute.test_user_data.ServersControllerCreateTest
|
||||||
nova.tests.unit.test_wsgi.TestWSGIServerWithSSL
|
nova.tests.unit.test_wsgi.TestWSGIServerWithSSL
|
||||||
nova.tests.unit.virt.libvirt.test_vif.LibvirtVifTestCase
|
|
||||||
nova.tests.unit.virt.xenapi.test_vm_utils.ResizeFunctionTestCase
|
nova.tests.unit.virt.xenapi.test_vm_utils.ResizeFunctionTestCase
|
||||||
nova.tests.unit.virt.xenapi.test_vm_utils.ScanSrTestCase
|
nova.tests.unit.virt.xenapi.test_vm_utils.ScanSrTestCase
|
||||||
nova.tests.unit.virt.xenapi.test_vm_utils.UnplugVbdTestCase
|
nova.tests.unit.virt.xenapi.test_vm_utils.UnplugVbdTestCase
|
||||||
|
|
Loading…
Reference in New Issue