Skip to content

Commit fbac773

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 fbac773

1 file changed

Lines changed: 122 additions & 1 deletion

File tree

  • virttest/libvirt_xml/devices

virttest/libvirt_xml/devices/disk.py

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

0 commit comments

Comments
 (0)