Skip to content
Merged
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
122 changes: 121 additions & 1 deletion virttest/libvirt_xml/devices/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ class DiskSource(base.base.LibvirtXMLBase):
"config_file",
"snapshot_name",
"address",
"dataStore",
)

def __init__(self, virsh_instance=base.base.virsh):
Expand Down Expand Up @@ -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 = "<source/>"

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 = "<source/>"
Expand Down Expand Up @@ -944,3 +972,95 @@ def __init__(self, virsh_instance=base.base.virsh):
)
super(self.__class__, self).__init__(virsh_instance=virsh_instance)
self.xml = "<metadata_cache/>"

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 = "<dataStore/>"

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 = "<source/>"