libvirt: Remove node device XML validate flags
Node device XML validation flags [1]:
VIR_NODE_DEVICE_(CREATE|DEFINE)_XML_VALIDATE
were added in libvirt 8.10.0 but we support older libvirt versions
which will raise an AttributeError when flag access is attempted.
We are not currently using the flags (nothing calling with
validate=True) so this removes the flags from the code entirely. If the
flags are needed in the future, they can be added again at that time.
Closes-Bug: #2076163
[1] d8791c3c7c
Change-Id: I015d9b7cad413986058da4d29ca7711c844bfa84
This commit is contained in:
parent
bb2d7f9cad
commit
f63029b461
nova
6
nova/tests/fixtures/libvirt.py
vendored
6
nova/tests/fixtures/libvirt.py
vendored
@ -202,12 +202,6 @@ VIR_DOMAIN_METADATA_DESCRIPTION = 0
|
||||
VIR_DOMAIN_METADATA_TITLE = 1
|
||||
VIR_DOMAIN_METADATA_ELEMENT = 2
|
||||
|
||||
# virNodeDeviceCreateXML flags
|
||||
VIR_NODE_DEVICE_CREATE_XML_VALIDATE = 4
|
||||
|
||||
# virNodeDeviceDefineXML flags
|
||||
VIR_NODE_DEVICE_DEFINE_XML_VALIDATE = 5
|
||||
|
||||
# Libvirt version to match MIN_LIBVIRT_VERSION in driver.py
|
||||
FAKE_LIBVIRT_VERSION = versionutils.convert_version_to_int(
|
||||
libvirt_driver.MIN_LIBVIRT_VERSION)
|
||||
|
@ -1168,6 +1168,18 @@ Active: 8381604 kB
|
||||
self.host.device_lookup_by_name("foo")
|
||||
mock_nodeDeviceLookupByName.assert_called_once_with("foo")
|
||||
|
||||
@mock.patch.object(fakelibvirt.virConnect, 'nodeDeviceCreateXML')
|
||||
def test_device_create(self, mock_create):
|
||||
node_dev = vconfig.LibvirtConfigNodeDevice()
|
||||
self.host.device_create(node_dev)
|
||||
mock_create.assert_called_once_with(node_dev.to_xml(), flags=0)
|
||||
|
||||
@mock.patch.object(fakelibvirt.virConnect, 'nodeDeviceDefineXML')
|
||||
def test_device_define(self, mock_define):
|
||||
node_dev = vconfig.LibvirtConfigNodeDevice()
|
||||
self.host.device_define(node_dev)
|
||||
mock_define.assert_called_once_with(node_dev.to_xml(), flags=0)
|
||||
|
||||
def test_get_pcinet_info(self):
|
||||
dev_name = "net_enp2s2_02_9a_a1_37_be_54"
|
||||
parent_address = "pci_0000_04_11_7"
|
||||
|
@ -1254,35 +1254,29 @@ class Host(object):
|
||||
"""
|
||||
return self.get_connection().nodeDeviceLookupByName(name)
|
||||
|
||||
def device_create(self, conf, validate=False):
|
||||
def device_create(self, conf):
|
||||
"""Create a node device from specified device XML
|
||||
|
||||
This creates the device as transient.
|
||||
|
||||
:param conf: A LibvirtConfigObject of the device to create
|
||||
:param validate: whether to validate the XML document against schema
|
||||
|
||||
:returns: a virNodeDevice instance if successful, else None
|
||||
"""
|
||||
flag = libvirt.VIR_NODE_DEVICE_CREATE_XML_VALIDATE
|
||||
flags = validate and flag or 0
|
||||
device_xml = conf.to_xml()
|
||||
return self.get_connection().nodeDeviceCreateXML(device_xml, flags)
|
||||
return self.get_connection().nodeDeviceCreateXML(device_xml, flags=0)
|
||||
|
||||
def device_define(self, conf, validate=False):
|
||||
def device_define(self, conf):
|
||||
"""Define a node device from specified device XML
|
||||
|
||||
This defines the device to make it persistent.
|
||||
|
||||
:param conf: A LibvirtConfigObject of the device to create
|
||||
:param validate: whether to validate the XML document against schema
|
||||
|
||||
:returns: a virNodeDevice instance if successful, else None
|
||||
"""
|
||||
flag = libvirt.VIR_NODE_DEVICE_DEFINE_XML_VALIDATE
|
||||
flags = validate and flag or 0
|
||||
device_xml = conf.to_xml()
|
||||
return self.get_connection().nodeDeviceDefineXML(device_xml, flags)
|
||||
return self.get_connection().nodeDeviceDefineXML(device_xml, flags=0)
|
||||
|
||||
def device_start(self, dev):
|
||||
"""Start a defined node device
|
||||
|
Loading…
x
Reference in New Issue
Block a user