Skip to content

Commit

Permalink
Merge pull request avocado-framework#3456 from Yingshun/iface_virtual…
Browse files Browse the repository at this point in the history
…port

interface: Add support for virtualport
  • Loading branch information
chloerh authored Jul 13, 2022
2 parents 2e2a5a0 + f952a29 commit 3d8a0b5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
35 changes: 32 additions & 3 deletions virttest/libvirt_xml/devices/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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 = '<virtualport/>'
2 changes: 1 addition & 1 deletion virttest/utils_test/libvirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3d8a0b5

Please sign in to comment.