[test-API][PATCH] Update activate pool case

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

 



* delete the unused function
* fix column length and some other nits

Signed-off-by: Wayne Sun <gsun@xxxxxxxxxx>
---
 repos/storage/activate_pool.py |   45 +++++++++++++++++----------------------
 1 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/repos/storage/activate_pool.py b/repos/storage/activate_pool.py
index 064f356..d3adef8 100644
--- a/repos/storage/activate_pool.py
+++ b/repos/storage/activate_pool.py
@@ -1,8 +1,5 @@
 #!/usr/bin/env python
 
-import os
-import re
-import sys
 import time
 
 import libvirt
@@ -13,42 +10,40 @@ from src import sharedmod
 required_params = ('poolname',)
 optional_params = {}
 
-def display_pool_info(stg, logger):
-    """Display current storage pool information"""
-    logger.debug("current defined storage pool: %s" % \
-                  stg.defstorage_pool_list())
-    logger.debug("current active storage pool: %s" % stg.storage_pool_list())
-
 def activate_pool(params):
-    """Undefine a storage pool that's been defined and inactive"""
+    """activate a storage pool that's been defined
+       and inactive
+    """
     logger = params['logger']
     poolname = params['poolname']
 
     conn = sharedmod.libvirtobj['conn']
-    pool_names = conn.listDefinedStoragePools()
-    pool_names += conn.listStoragePools()
+    try:
+        pool_names = conn.listDefinedStoragePools()
+        pool_names += conn.listStoragePools()
 
-    if poolname in pool_names:
-        poolobj = conn.storagePoolLookupByName(poolname)
-    else:
-        logger.error("%s not found\n" % poolname);
-        return 1
+        if poolname in pool_names:
+            poolobj = conn.storagePoolLookupByName(poolname)
+        else:
+            logger.error("%s not found\n" % poolname);
+            return 1
 
-    if poolobj.isActive():
-        logger.error("%s is active already" % poolname)
-        return 1
+        if poolobj.isActive():
+            logger.error("%s is active already" % poolname)
+            return 1
 
-    try:
         poolobj.create(0)
         time.sleep(5)
         if  poolobj.isActive():
-            logger.info("activating %s storage pool is SUCCESSFUL!!!" % poolname)
+            logger.info("activating %s storage pool is SUCCESSFUL!!!" %
+                        poolname)
         else:
-            logger.info("activating %s storage pool is UNSUCCESSFUL!!!" % poolname)
+            logger.info("activating %s storage pool is UNSUCCESSFUL!!!" %
+                        poolname)
             return 1
+
     except libvirtError, e:
-        logger.error("API error message: %s, error code is %s" \
-                     % (e.message, e.get_error_code()))
+        logger.error("libvirt call failed: " + str(e))
         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]