Skip to content

Commit 287a051

Browse files
committed
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 <meili@redhat.com>
1 parent 6c649eb commit 287a051

1 file changed

Lines changed: 121 additions & 1 deletion

File tree

  • virttest/libvirt_xml/devices

virttest/libvirt_xml/devices/disk.py

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ class DiskSource(base.base.LibvirtXMLBase):
372372
"config_file",
373373
"snapshot_name",
374374
"address",
375+
"dataStore",
375376
)
376377

377378
def __init__(self, virsh_instance=base.base.virsh):
@@ -440,6 +441,14 @@ def __init__(self, virsh_instance=base.base.virsh):
440441
accessors.XMLElementDict(
441442
"address", self, parent_xpath="/", tag_name="address"
442443
)
444+
accessors.XMLElementNest(
445+
"dataStore",
446+
self,
447+
parent_xpath="/",
448+
tag_name="dataStore",
449+
subclass=Disk.dataStore,
450+
subclass_dargs={"virsh_instance": virsh_instance},
451+
)
443452
super(self.__class__, self).__init__(virsh_instance=virsh_instance)
444453
self.xml = "<source/>"
445454

@@ -877,9 +886,20 @@ class Source(base.base.LibvirtXMLBase):
877886
dict, nested xml of backingStore/source tag
878887
file:
879888
string, attribute of backingStore/source tag
889+
datastore:
890+
dict, nexted xml of backingStore/source/dataStore tag
880891
"""
881892

882-
__slots__ = ("attrs", "dev", "protocol", "name", "host", "file", "auth")
893+
__slots__ = (
894+
"attrs",
895+
"dev",
896+
"protocol",
897+
"name",
898+
"host",
899+
"file",
900+
"auth",
901+
"datastore",
902+
)
883903

884904
def __init__(self, virsh_instance=base.base.virsh):
885905
accessors.XMLElementDict(
@@ -912,6 +932,14 @@ def __init__(self, virsh_instance=base.base.virsh):
912932
subclass=Disk.Auth,
913933
subclass_dargs={"virsh_instance": virsh_instance},
914934
)
935+
accessors.XMLElementNest(
936+
"datastore",
937+
self,
938+
parent_xpath="/",
939+
tag_name="dataStore",
940+
subclass=Disk.dataStore,
941+
subclass_dargs={"virsh_instance": virsh_instance},
942+
)
915943

916944
super(self.__class__, self).__init__(virsh_instance=virsh_instance)
917945
self.xml = "<source/>"
@@ -944,3 +972,95 @@ def __init__(self, virsh_instance=base.base.virsh):
944972
)
945973
super(self.__class__, self).__init__(virsh_instance=virsh_instance)
946974
self.xml = "<metadata_cache/>"
975+
976+
class dataStore(base.base.LibvirtXMLBase):
977+
"""
978+
DataStore device XML class
979+
980+
type:
981+
string, attribute of dataStore tag
982+
index:
983+
string, attribute of dataStore tag
984+
format:
985+
dict, key-attribute of dataStore tag
986+
source:
987+
nested xml of dataStore tag
988+
"""
989+
990+
__slots__ = ("type", "index", "format", "source")
991+
992+
def __init__(self, virsh_instance=base.base.virsh):
993+
accessors.XMLAttribute(
994+
"type",
995+
self,
996+
parent_xpath="/",
997+
tag_name="dataStore",
998+
attribute="type",
999+
)
1000+
accessors.XMLAttribute(
1001+
"index",
1002+
self,
1003+
parent_xpath="/",
1004+
tag_name="dataStore",
1005+
attribute="index",
1006+
)
1007+
accessors.XMLElementDict(
1008+
"format", self, parent_xpath="/", tag_name="format"
1009+
)
1010+
accessors.XMLElementNest(
1011+
"source",
1012+
self,
1013+
parent_xpath="/",
1014+
tag_name="source",
1015+
subclass=self.Source,
1016+
subclass_dargs={"virsh_instance": virsh_instance},
1017+
)
1018+
super(self.__class__, self).__init__(virsh_instance=virsh_instance)
1019+
self.xml = "<dataStore/>"
1020+
1021+
class Source(base.base.LibvirtXMLBase):
1022+
"""
1023+
Source of datastore xml class
1024+
1025+
dev:
1026+
string, attribute of dataStore/source tag
1027+
protocal:
1028+
string, attribute of dataStore/source tag
1029+
name:
1030+
string, attribute of dataStore/source tag
1031+
host:
1032+
dict, nested xml of dataStore/source tag
1033+
file:
1034+
string, attribute of dataStore/source tag
1035+
"""
1036+
1037+
__slots__ = ("attrs", "protocol", "name", "host", "auth")
1038+
1039+
def __init__(self, virsh_instance=base.base.virsh):
1040+
accessors.XMLElementDict(
1041+
"attrs", self, parent_xpath="/", tag_name="source"
1042+
)
1043+
accessors.XMLAttribute(
1044+
"protocol",
1045+
self,
1046+
parent_xpath="/",
1047+
tag_name="source",
1048+
attribute="protocol",
1049+
)
1050+
accessors.XMLAttribute(
1051+
"name", self, parent_xpath="/", tag_name="source", attribute="name"
1052+
)
1053+
accessors.XMLElementDict(
1054+
"host", self, parent_xpath="/", tag_name="host"
1055+
)
1056+
accessors.XMLElementNest(
1057+
"auth",
1058+
self,
1059+
parent_xpath="/",
1060+
tag_name="auth",
1061+
subclass=Disk.Auth,
1062+
subclass_dargs={"virsh_instance": virsh_instance},
1063+
)
1064+
1065+
super(self.__class__, self).__init__(virsh_instance=virsh_instance)
1066+
self.xml = "<source/>"

0 commit comments

Comments
 (0)