summaryrefslogtreecommitdiff
path: root/virtinst/storage.py
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2018-02-07 17:27:56 -0500
committerCole Robinson <crobinso@redhat.com>2018-02-08 14:03:47 -0500
commitdae8642bb1e094963068e6082c3d2ff7d33f3696 (patch)
tree32977b1ef7eba5812caf5c1b9fff393043e03d5a /virtinst/storage.py
parent8819176ad4adc55f19991ac52edaf4f29ae08023 (diff)
downloadvirt-manager-dae8642bb1e094963068e6082c3d2ff7d33f3696.tar.gz
xmlbuilder: centralize adding child new child prop instances
Currently the domain CPU class has a child property like: siblings = XMLChildProperty(_CPUCellSibling) If a user wants to add a new sibling, we add a convenience function: def add_sibling(self): obj = _CPUCellSibling(self.conn) self.add_child(obj) return obj Rather than require every child property to define a similar matching helper function, this adds infrastructure in xmlbuilder to do this generically for every child property. Now callers can do obj = guest.cpu.siblings.add_new()
Diffstat (limited to 'virtinst/storage.py')
-rw-r--r--virtinst/storage.py13
1 files changed, 2 insertions, 11 deletions
diff --git a/virtinst/storage.py b/virtinst/storage.py
index 52a0df4c..21cd5b1a 100644
--- a/virtinst/storage.py
+++ b/virtinst/storage.py
@@ -186,8 +186,8 @@ class StoragePool(_StorageObject):
obj.type = pool_type
obj.source_path = parseobj.source_path
for h in parseobj.hosts:
- parseobj.remove_host(h)
- obj.add_host_obj(h)
+ parseobj.remove_child(h)
+ obj.add_child(h)
obj.source_name = parseobj.source_name
obj.format = parseobj.format
@@ -421,15 +421,6 @@ class StoragePool(_StorageObject):
target_path = XMLProperty("./target/path",
default_cb=_get_default_target_path)
- def add_host_obj(self, obj):
- self.add_child(obj)
- def add_host(self, name, port=None):
- obj = _Host(self.conn)
- obj.name = name
- obj.port = port
- self.add_child(obj)
- def remove_host(self, obj):
- self.remove_child(obj)
hosts = XMLChildProperty(_Host, relative_xpath="./source")