Skip to content

Commit

Permalink
Merge pull request #3975 from smitterl/add_zfcp
Browse files Browse the repository at this point in the history
libvirt_xml/devices/address: add optional zpci subelement
  • Loading branch information
chloerh authored Oct 30, 2024
2 parents 05e2ec4 + b28ac07 commit a25af49
Showing 1 changed file with 38 additions and 0 deletions.
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

0 comments on commit a25af49

Please sign in to comment.