Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libvirt_xml/devices/address: add optional zpci subelement #3975

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions virttest/libvirt_xml/devices/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ class Address(base.TypedDeviceBase):
def __init__(self, type_name, virsh_instance=base.base.virsh):
# Blindly accept any/all attributes as simple dictionary
accessors.XMLElementDict("attrs", self, parent_xpath="/", tag_name="address")
accessors.XMLElementNest(
"zpci_attrs",
self,
parent_xpath="/",
tag_name="zpci",
subclass=self.Zpci,
subclass_dargs={"virsh_instance": virsh_instance},
)
super(self.__class__, self).__init__(
device_tag="address", type_name=type_name, virsh_instance=virsh_instance
)
Expand Down Expand Up @@ -46,3 +54,33 @@ def new_from_element(cls, element, virsh_instance=base.base.virsh):
"type attribute is manditory for " "Address class"
)
return cls.new_from_dict(edict, virsh_instance=virsh_instance)

class Zpci(base.base.LibvirtXMLBase):
"""Represents the optional subelement for zpci addresses"""

__slots__ = ("uid", "fid")

def __init__(self, virsh_instance=base.base.virsh):
accessors.XMLAttribute(
"uid",
self,
parent_xpath="/",
tag_name="zpci",
attribute="uid",
)
accessors.XMLAttribute(
"fid",
self,
parent_xpath="/",
tag_name="zpci",
attribute="fid",
)
super(self.__class__, self).__init__(virsh_instance=virsh_instance)
self.xml = "<zpci/>"

@classmethod
def new_from_dict(cls, attributes, virsh_instance=base.base.virsh):
instance = cls(virsh_instance=virsh_instance)
instance.uid = attributes["uid"]
instance.fid = attributes["fid"]
return instance
Loading