[test-API][PATCH] Add storage cases of pool list, pool lookup and volume lookup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add 3 simple storage realted API cases
* pool_list_active is only for testing with flags:
  libvirt.VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE
* pool_lookup is for testing lookup pool object by name, UUID,
  UUIDString and volume object
* vol_lookup is for testing lookup volume object by name, key
  and path
* add cases into storage_dir.conf

Signed-off-by: Wayne Sun <gsun@xxxxxxxxxx>
---
 cases/storage_dir.conf            |   14 +++++++
 repos/storage/pool_list_active.py |   50 +++++++++++++++++++++++++
 repos/storage/pool_lookup.py      |   74 +++++++++++++++++++++++++++++++++++++
 repos/storage/vol_lookup.py       |   62 +++++++++++++++++++++++++++++++
 4 files changed, 200 insertions(+), 0 deletions(-)
 create mode 100644 repos/storage/pool_list_active.py
 create mode 100644 repos/storage/pool_lookup.py
 create mode 100644 repos/storage/vol_lookup.py

diff --git a/cases/storage_dir.conf b/cases/storage_dir.conf
index 38b349d..2bdb7d6 100644
--- a/cases/storage_dir.conf
+++ b/cases/storage_dir.conf
@@ -2,14 +2,22 @@ storage:define_dir_pool
     poolname
         $defaultpoolname
 
+storage:pool_lookup
+    poolname
+        $defaultpoolname
+
 storage:build_dir_pool
     poolname
         $defaultpoolname
 
+storage:pool_list_active
+
 storage:activate_pool
     poolname
         $defaultpoolname
 
+storage:pool_list_active
+
 storage:create_dir_volume
     poolname
         $defaultpoolname
@@ -20,6 +28,12 @@ storage:create_dir_volume
     capacity
         $defaultvolumesize
 
+storage:vol_lookup
+    poolname
+        $defaultpoolname
+    volname
+        $defaultvolumename
+
 storage:vol_clone
     poolname
         $defaultpoolname
diff --git a/repos/storage/pool_list_active.py b/repos/storage/pool_list_active.py
new file mode 100644
index 0000000..3e390c8
--- /dev/null
+++ b/repos/storage/pool_list_active.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# list active storage pool testing with flag:
+# libvirt.VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ()
+optional_params = {
+                  }
+
+def pool_list_active(params):
+    """list active storage pool testing"""
+
+    global logger
+    logger = params['logger']
+    namelist = []
+
+    conn = sharedmod.libvirtobj['conn']
+    try:
+        pool_num = conn.numOfStoragePools()
+        logger.info("number of active storage pools is %s" % pool_num)
+
+        flag = libvirt.VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE
+        poolobj_list = conn.listAllStoragePools(flag)
+        if not len(poolobj_list) == pool_num:
+            logger.error("active pool object number mismatched")
+            return 1
+
+        for i in poolobj_list:
+            pool_name = i.name()
+            namelist.append(pool_name)
+
+        logger.info("active pool name list is %s" % namelist)
+
+        active_namelist = conn.listStoragePools()
+        if namelist == active_namelist:
+            logger.info("active pool name list matched")
+        else:
+            logger.error("active pool name list mismatched")
+            return 1
+
+    except libvirtError, e:
+        logger.error("libvirt call failed: " + str(e))
+        return 1
+
+    logger.info("list active storage pool succeed")
+    return 0
diff --git a/repos/storage/pool_lookup.py b/repos/storage/pool_lookup.py
new file mode 100644
index 0000000..89d7252
--- /dev/null
+++ b/repos/storage/pool_lookup.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+# storage pool lookup testing
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('poolname',)
+optional_params = {
+                   'volname': None
+                  }
+
+def pool_lookup(params):
+    """storage pool lookup testing"""
+
+    global logger
+    logger = params['logger']
+    poolname = params['poolname']
+    volname = params.get('volname')
+    retval = 0
+
+    logger.info("the poolname is %s" % poolname)
+    if volname:
+        logger.info("the given volume name is %s" % volname)
+
+    conn = sharedmod.libvirtobj['conn']
+    try:
+        logger.info("lookup the pool object by name: %s" % poolname)
+        poolobj = conn.storagePoolLookupByName(poolname)
+        if poolobj.name() == poolname:
+            logger.info("pool object lookup by name succeed")
+        else:
+            logger.error("pool object lookup by name failed")
+            retval += 1
+
+        uuid = poolobj.UUID()
+        logger.info("lookup the pool object by UUID: %s" % uuid)
+        poolobj_uuid = conn.storagePoolLookupByUUID(uuid)
+        if poolobj_uuid.name() == poolname:
+            logger.info("pool object lookup by UUID succeed")
+        else:
+            logger.error("pool object lookup by UUID failed")
+            retval += 1
+
+        uuidstr = poolobj.UUIDString()
+        logger.info("lookup the pool object by UUID string: %s" % uuidstr)
+        poolobj_uuidstr = conn.storagePoolLookupByUUIDString(uuidstr)
+        if poolobj_uuidstr.name() == poolname:
+            logger.info("pool object lookup by UUID string succeed")
+        else:
+            logger.error("pool object lookup by UUID string failed")
+            retval += 1
+
+        if volname:
+            logger.info("lookup volume object by volume name: %s" % volname)
+            volobj = poolobj.storageVolLookupByName(volname)
+            logger.info("lookup the pool object by volume object")
+            poolobj_vol = volobj.storagePoolLookupByVolume()
+
+            if poolobj_vol.name() == poolname:
+                logger.info("pool object lookup by UUID string succeed")
+            else:
+                logger.error("pool object lookup by UUID string failed")
+                retval += 1
+
+    except libvirtError, e:
+        logger.error("libvirt call failed: " + str(e))
+        return 1
+
+    if retval:
+        return 1
+
+    return 0
diff --git a/repos/storage/vol_lookup.py b/repos/storage/vol_lookup.py
new file mode 100644
index 0000000..30238e1
--- /dev/null
+++ b/repos/storage/vol_lookup.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# storage pool volume lookup testing
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('poolname', 'volname',)
+optional_params = {
+                  }
+
+def vol_lookup(params):
+    """storage pool volume lookup testing"""
+
+    global logger
+    logger = params['logger']
+    poolname = params['poolname']
+    volname = params['volname']
+    retval = 0
+
+    logger.info("the poolname is %s" % poolname)
+    logger.info("the given volume name is %s" % volname)
+
+    conn = sharedmod.libvirtobj['conn']
+    try:
+        poolobj = conn.storagePoolLookupByName(poolname)
+
+        logger.info("lookup the volume object by name: %s" % volname)
+        volobj = poolobj.storageVolLookupByName(volname)
+        if volobj.name() == volname:
+            logger.info("volume object lookup by name succeed")
+        else:
+            logger.error("volume object lookup by name failed")
+            retval += 1
+
+        volkey = volobj.key()
+        logger.info("lookup the volume object by key: %s" % volkey)
+        volobj_key = conn.storageVolLookupByKey(volkey)
+        if volobj_key.name() == volname:
+            logger.info("volume object lookup by key succeed")
+        else:
+            logger.error("volume object lookup by key failed")
+            retval += 1
+
+        volpath = volobj.path()
+        logger.info("lookup the volume object by path: %s" % volpath)
+        volobj_path = conn.storageVolLookupByPath(volpath)
+        if volobj_path.name() == volname:
+            logger.info("volume object lookup by path succeed")
+        else:
+            logger.error("volume object lookup by path failed")
+            retval += 1
+
+    except libvirtError, e:
+        logger.error("libvirt call failed: " + str(e))
+        return 1
+
+    if retval:
+        return 1
+
+    return 0
-- 
1.7.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]