# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1210730487 25200
# Node ID 82e90471b04874cb48a473dd72468be6f784acba
# Parent 06c87ac466e374f7ca5b7e3dd1923ee32f1ef2ce
[TEST] Resubmit PoolXML class for creating a virtual pool in vxml.py
Removed source tag and add pool destroy function
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 06c87ac466e3 -r 82e90471b048 suites/libvirt-cim/lib/XenKvmLib/const.py
--- a/suites/libvirt-cim/lib/XenKvmLib/const.py Tue May 13 06:07:27 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Tue May 13 19:01:27 2008 -0700
@@ -37,6 +37,9 @@ default_bridge_name = 'testbridge'
default_bridge_name = 'testbridge'
default_network_name = 'default-net'
+#vxml.PoolXML
+default_pool_name = 'testpool'
+
# vxml.VirtXML
default_domname = 'domU1'
default_memory = 128
diff -r 06c87ac466e3 -r 82e90471b048 suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue May 13 06:07:27 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue May 13 19:01:27 2008 -0700
@@ -143,12 +143,14 @@ class Virsh:
self.vuri = 'qemu:///system'
def run(self, ip, vcmd, param):
- file_arg_cmds = ['define', 'create', 'net-create']
+ file_arg_cmds = ['define', 'create', 'net-create',
'pool-create']
if vcmd in file_arg_cmds:
ntf = tempfile.NamedTemporaryFile('w')
ntf.write(param)
ntf.flush()
name = ntf.name
+ elif vcmd == 'pool-destroy':
+ name = param
elif param is None:
name = ""
else:
@@ -211,6 +213,28 @@ class NetXML(Virsh, XMLClass):
def create_vnet(self):
return self.run(self.server, 'net-create', self.xml_string)
+class PoolXML(Virsh, XMLClass):
+
+ def __init__(self, server, poolname=const.default_pool_name,
+ virt='xen'):
+
+ XMLClass.__init__(self)
+ if virt == 'XenFV':
+ virt = 'xen'
+ Virsh.__init__(self, str(virt).lower())
+ self.pool_name = poolname
+ self.server = server
+
+ pool = self.add_sub_node(self.xdoc, 'pool', type='dir')
+ self.add_sub_node(pool, 'name', self.pool_name)
+ target = self.add_sub_node(pool, 'target')
+ self.add_sub_node(target, 'path', '/tmp')
+
+ def create_vpool(self):
+ return self.run(self.server, 'pool-create', self.xml_string)
+
+ def destroy_vpool(self):
+ return self.run(self.server, 'pool-destroy', self.pool_name)
class VirtXML(Virsh, XMLClass):
"""Base class for all XML generation &
operation"""