From 287a051bc0c02bfd78da335ccb0cc7e302032e52 Mon Sep 17 00:00:00 2001 From: meinaLi Date: Tue, 25 Mar 2025 02:17:20 -0400 Subject: [PATCH] Disk: add new dataStore element to disk.py Now a new element dataStore has been implemented. So add it to disk.py. Signed-off-by: meinaLi --- virttest/libvirt_xml/devices/disk.py | 122 ++++++++++++++++++++++++++- 1 file changed, 121 insertions(+), 1 deletion(-) diff --git a/virttest/libvirt_xml/devices/disk.py b/virttest/libvirt_xml/devices/disk.py index f84c6adc4e..429b545e16 100644 --- a/virttest/libvirt_xml/devices/disk.py +++ b/virttest/libvirt_xml/devices/disk.py @@ -372,6 +372,7 @@ class DiskSource(base.base.LibvirtXMLBase): "config_file", "snapshot_name", "address", + "dataStore", ) def __init__(self, virsh_instance=base.base.virsh): @@ -440,6 +441,14 @@ def __init__(self, virsh_instance=base.base.virsh): accessors.XMLElementDict( "address", self, parent_xpath="/", tag_name="address" ) + accessors.XMLElementNest( + "dataStore", + self, + parent_xpath="/", + tag_name="dataStore", + subclass=Disk.dataStore, + subclass_dargs={"virsh_instance": virsh_instance}, + ) super(self.__class__, self).__init__(virsh_instance=virsh_instance) self.xml = "" @@ -877,9 +886,20 @@ class Source(base.base.LibvirtXMLBase): dict, nested xml of backingStore/source tag file: string, attribute of backingStore/source tag + datastore: + dict, nexted xml of backingStore/source/dataStore tag """ - __slots__ = ("attrs", "dev", "protocol", "name", "host", "file", "auth") + __slots__ = ( + "attrs", + "dev", + "protocol", + "name", + "host", + "file", + "auth", + "datastore", + ) def __init__(self, virsh_instance=base.base.virsh): accessors.XMLElementDict( @@ -912,6 +932,14 @@ def __init__(self, virsh_instance=base.base.virsh): subclass=Disk.Auth, subclass_dargs={"virsh_instance": virsh_instance}, ) + accessors.XMLElementNest( + "datastore", + self, + parent_xpath="/", + tag_name="dataStore", + subclass=Disk.dataStore, + subclass_dargs={"virsh_instance": virsh_instance}, + ) super(self.__class__, self).__init__(virsh_instance=virsh_instance) self.xml = "" @@ -944,3 +972,95 @@ def __init__(self, virsh_instance=base.base.virsh): ) super(self.__class__, self).__init__(virsh_instance=virsh_instance) self.xml = "" + + class dataStore(base.base.LibvirtXMLBase): + """ + DataStore device XML class + + type: + string, attribute of dataStore tag + index: + string, attribute of dataStore tag + format: + dict, key-attribute of dataStore tag + source: + nested xml of dataStore tag + """ + + __slots__ = ("type", "index", "format", "source") + + def __init__(self, virsh_instance=base.base.virsh): + accessors.XMLAttribute( + "type", + self, + parent_xpath="/", + tag_name="dataStore", + attribute="type", + ) + accessors.XMLAttribute( + "index", + self, + parent_xpath="/", + tag_name="dataStore", + attribute="index", + ) + accessors.XMLElementDict( + "format", self, parent_xpath="/", tag_name="format" + ) + accessors.XMLElementNest( + "source", + self, + parent_xpath="/", + tag_name="source", + subclass=self.Source, + subclass_dargs={"virsh_instance": virsh_instance}, + ) + super(self.__class__, self).__init__(virsh_instance=virsh_instance) + self.xml = "" + + class Source(base.base.LibvirtXMLBase): + """ + Source of datastore xml class + + dev: + string, attribute of dataStore/source tag + protocal: + string, attribute of dataStore/source tag + name: + string, attribute of dataStore/source tag + host: + dict, nested xml of dataStore/source tag + file: + string, attribute of dataStore/source tag + """ + + __slots__ = ("attrs", "protocol", "name", "host", "auth") + + def __init__(self, virsh_instance=base.base.virsh): + accessors.XMLElementDict( + "attrs", self, parent_xpath="/", tag_name="source" + ) + accessors.XMLAttribute( + "protocol", + self, + parent_xpath="/", + tag_name="source", + attribute="protocol", + ) + accessors.XMLAttribute( + "name", self, parent_xpath="/", tag_name="source", attribute="name" + ) + accessors.XMLElementDict( + "host", self, parent_xpath="/", tag_name="host" + ) + accessors.XMLElementNest( + "auth", + self, + parent_xpath="/", + tag_name="auth", + subclass=Disk.Auth, + subclass_dargs={"virsh_instance": virsh_instance}, + ) + + super(self.__class__, self).__init__(virsh_instance=virsh_instance) + self.xml = ""