# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1245155631 25200
# Node ID 775f81388994fa3ddb72b2740389b1eeec8c0b13
# Parent 4eb38964b6e6bdd757904d51b83ff115b02dd29a
Adding netfs diskpool creation to RPCS/08_CreateDiskResourcePool.py tc..
Tested on F10 with KVM and current sources.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 4eb38964b6e6 -r 775f81388994
suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py
---
a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py Tue
Jun 16 05:32:03 2009 -0700
+++
b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py Tue
Jun 16 05:33:51 2009 -0700
@@ -52,49 +52,78 @@
from CimTest.ReturnCodes import FAIL, PASS
from XenKvmLib.const import do_main, platform_sup
from XenKvmLib.classes import get_typed_class
-from XenKvmLib.common_util import destroy_diskpool
+from XenKvmLib.common_util import destroy_diskpool, nfs_netfs_setup, \
+ netfs_cleanup
from XenKvmLib.pool import create_pool, verify_pool, undefine_diskpool
-test_pool = "diskpool"
-dp_types = { "DISK_POOL_DIR" : 1 }
-
+dp_types = { "DISK_POOL_DIR" : 1, "DISK_POOL_NETFS" : 3}
+
+def get_pool_attr(server, pool_type):
+ pool_attr = { "Path" : "/tmp" }
+ if pool_type == dp_types['DISK_POOL_NETFS']:
+ status , src_mnt_dir, dir_mnt_dir = nfs_netfs_setup(server)
+ if status != PASS:
+ logger.error("Failed to get pool_attr for '%s' diskpool
type",
+ pool_type)
+ return FAIL, pool_attr
+
+ pool_attr['SourceDirectory'] = src_mnt_dir
+ pool_attr['Host'] = server
+ pool_attr['Path'] = dir_mnt_dir
+
+ return PASS, pool_attr
+
@do_main(platform_sup)
def main():
options = main.options
server = options.ip
virt = options.virt
- pool_attr = { "Path" : "/tmp" }
# For now the test case support only the creation of
- # dir type disk pool, later change to fs and netfs etc
+ # dir type disk pool, netfs later change to fs and disk pooltypes etc
for key, value in dp_types.iteritems():
- status = create_pool(server, virt, test_pool, pool_attr,
- mode_type=value, pool_type= "DiskPool")
- if status != PASS:
- logger.error("Failed to create '%s' type diskpool
'%s'",
- key, test_pool)
+ try:
+ logger.info("Verifying '%s'.....", key)
+ test_pool = key
+ status, pool_attr = get_pool_attr(server, value)
+ if status != PASS:
+ return FAIL
+
+ status = create_pool(server, virt, test_pool, pool_attr,
+ mode_type=value, pool_type= "DiskPool")
+
+ if status != PASS:
+ raise Excpetion("Failed to create '%s' type diskpool
'%s'" \
+ % (key, test_pool))
+
+ status = verify_pool(server, virt, test_pool, pool_attr,
+ mode_type=value, pool_type="DiskPool")
+ if status != PASS:
+ destroy_diskpool(server, virt, test_pool)
+ undefine_diskpool(server, virt, test_pool)
+ raise Exception("Error in diskpool verification")
+
+ status = destroy_diskpool(server, virt, test_pool)
+ if status != PASS:
+ raise Exception("Unable to destroy diskpool '%s'" \
+ % test_pool)
+
+ status = undefine_diskpool(server, virt, test_pool)
+ if status != PASS:
+ raise Exception("Unable to undefine diskpool '%s'" \
+ % test_pool)
+
+ if key == 'DISK_POOL_NETFS':
+ netfs_cleanup(server, pool_attr)
+
+ status = PASS
+
+ except Exception, details:
+ logger.error("Exception details: %s", details)
+ if key == 'DISK_POOL_NETFS':
+ netfs_cleanup(server, pool_attr)
return FAIL
-
- status = verify_pool(server, virt, test_pool, pool_attr,
- mode_type=value, pool_type="DiskPool")
- if status != PASS:
- logger.error("Error in diskpool verification")
- destroy_diskpool(server, virt, test_pool)
- undefine_diskpool(server, virt, test_pool)
- return FAIL
-
- status = destroy_diskpool(server, virt, test_pool)
- if status != PASS:
- logger.error("Unable to destroy diskpool '%s'", test_pool)
- return FAIL
-
- status = undefine_diskpool(server, virt, test_pool)
- if status != PASS:
- logger.error("Unable to undefine diskpool '%s'",
test_pool)
- return FAIL
-
- status = PASS
return status