From f952a29dde0c60a34fa390f42b572f5bb2c7a389 Mon Sep 17 00:00:00 2001 From: Yingshun Cui Date: Tue, 12 Jul 2022 16:25:16 +0800 Subject: [PATCH] interface: Add support for virtualport Signed-off-by: Yingshun Cui --- virttest/libvirt_xml/devices/interface.py | 35 +++++++++++++++++++++-- virttest/utils_test/libvirt.py | 2 +- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/virttest/libvirt_xml/devices/interface.py b/virttest/libvirt_xml/devices/interface.py index 72fb0bd396..e9e7b2570a 100644 --- a/virttest/libvirt_xml/devices/interface.py +++ b/virttest/libvirt_xml/devices/interface.py @@ -15,7 +15,7 @@ class Interface(base.TypedDeviceBase): __slots__ = ('source', 'hostdev_address', 'managed', 'mac_address', 'bandwidth', 'model', 'coalesce', 'link_state', 'target', 'driver', 'address', 'boot', 'rom', 'mtu', 'filterref', 'backend', - 'virtualport_type', 'alias', "ips", "teaming", "vlan", "port", + 'virtualport', 'alias', "ips", "teaming", "vlan", "port", 'acpi') def __init__(self, type_name='network', virsh_instance=base.base.virsh): @@ -108,8 +108,6 @@ def __init__(self, type_name='network', virsh_instance=base.base.virsh): tag_name='address', subclass=self.Address, subclass_dargs={'type_name': 'pci', 'virsh_instance': virsh_instance}) - accessors.XMLAttribute('virtualport_type', self, parent_xpath='/', - tag_name='virtualport', attribute='type') accessors.XMLElementDict('alias', self, parent_xpath='/', tag_name='alias') accessors.XMLElementDict(property_name="acpi", @@ -134,6 +132,12 @@ def __init__(self, type_name='network', virsh_instance=base.base.virsh): subclass=self.Vlan, subclass_dargs={ 'virsh_instance': virsh_instance}) + accessors.XMLElementNest("virtualport", self, + parent_xpath='/', + tag_name='virtualport', + subclass=self.VirtualPort, + subclass_dargs={ + 'virsh_instance': virsh_instance}) accessors.XMLElementDict(property_name='port', libvirtxml=self, forbidden=None, @@ -312,3 +316,28 @@ def marshal_to_tag(tag, attr_dict, index, libvirtxml): if tag != 'tag': return None # skip this one return dict(attr_dict) # return copy of dict, not reference@ + + class VirtualPort(base.base.LibvirtXMLBase): + """ + Interface virtualport xml class. + + Properties: + + type: + attribute. + parameters: + dict. + """ + __slots__ = ("type", "parameters") + + def __init__(self, virsh_instance=base.base.virsh): + accessors.XMLAttribute(property_name="type", + libvirtxml=self, + forbidden=None, + parent_xpath='/', + tag_name='virtualport', + attribute='type') + accessors.XMLElementDict("parameters", self, parent_xpath="/", + tag_name="parameters") + super(self.__class__, self).__init__(virsh_instance=virsh_instance) + self.xml = '' diff --git a/virttest/utils_test/libvirt.py b/virttest/utils_test/libvirt.py index 407cec2e44..c7e7457065 100644 --- a/virttest/utils_test/libvirt.py +++ b/virttest/utils_test/libvirt.py @@ -3657,7 +3657,7 @@ def modify_vm_iface(vm_name, oper, iface_dict, index=0, virsh_instance=virsh): if iface_teaming: iface.teaming = eval(iface_teaming) if iface_virtualport_type: - iface.virtualport_type = iface_virtualport_type + iface.setup_attrs(virtualport={'type': iface_virtualport_type}) if iface_port: iface.port = eval(iface_port) if iface_coalesce: