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

[libvirt] [test-API 3/3] Destroy use of check class



---
I see much TODO for cleaning up/refactoring, will come step by
step in near future.
---
 repos/domain/balloon_memory.py      |    3 +--
 repos/domain/dump.py                |    4 +---
 repos/domain/install_linux_check.py |   15 +++++++--------
 repos/snapshot/file_flag.py         |    7 +++----
 repos/snapshot/flag_check.py        |    3 +--
 5 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py
index 25b8318..de18b87 100644
--- a/repos/domain/balloon_memory.py
+++ b/repos/domain/balloon_memory.py
@@ -23,8 +23,7 @@ def get_mem_size(ip):
 
     username = 'root'
     password = 'redhat'
-    checking = check.Check()
-    current_memory = checking.get_remote_memory(ip, username, password)
+    current_memory = check.get_remote_memory(ip, username, password)
     return current_memory
 
 def compare_memory(expect_memory, actual_memory):
diff --git a/repos/domain/dump.py b/repos/domain/dump.py
index 37cfac9..01bdc93 100644
--- a/repos/domain/dump.py
+++ b/repos/domain/dump.py
@@ -35,8 +35,6 @@ def check_guest_kernel(*args):
     """Check guest kernel version"""
     (guestname, logger) = args
 
-    chk = check.Check()
-
     mac = utils.get_dom_mac_addr(guestname)
     logger.debug("guest mac address: %s" %mac)
 
@@ -47,7 +45,7 @@ def check_guest_kernel(*args):
 
     logger.debug("guest ip address: %s" %ipaddr)
 
-    kernel = chk.get_remote_kernel(ipaddr, "root", "redhat")
+    kernel = check.get_remote_kernel(ipaddr, "root", "redhat")
     logger.debug("current kernel version: %s" %kernel)
 
     if kernel:
diff --git a/repos/domain/install_linux_check.py b/repos/domain/install_linux_check.py
index 1c27fc1..351bba5 100644
--- a/repos/domain/install_linux_check.py
+++ b/repos/domain/install_linux_check.py
@@ -82,7 +82,6 @@ def install_linux_check(params):
     domain_name=guestname
     blk_type=params['hdmodel']
     nic_type=params['nicmodel']
-    chk = check.Check()
     Test_Result = 0
 
     # Ping guest from host
@@ -96,9 +95,9 @@ def install_linux_check(params):
 
     # Creat file and read file in guest.
     logger.info("check point2: creat and read dirctory/file in guest")
-    if chk.create_dir(ipaddr, "root", "redhat") == 0:
+    if check.create_dir(ipaddr, "root", "redhat") == 0:
         logger.info("create dir - /tmp/test successfully")
-        if chk.write_file(ipaddr, "root", "redhat") == 0:
+        if check.write_file(ipaddr, "root", "redhat") == 0:
             logger.info("write and read file: /tmp/test/test.log successfully")
         else:
             logger.error("Error: fail to write/read file - /tmp/test/test.log")
@@ -115,7 +114,7 @@ def install_linux_check(params):
     vcpunum_expect = int(utils.get_num_vcpus(domain_name))
     logger.info("vcpu number in domain config xml - %s is %s" % \
                  (domain_name, vcpunum_expect))
-    vcpunum_actual = int(chk.get_remote_vcpus(ipaddr, "root", "redhat"))
+    vcpunum_actual = int(check.get_remote_vcpus(ipaddr, "root", "redhat"))
     logger.info("The actual vcpu number in guest - %s is %s" %
                  (domain_name, vcpunum_actual))
     if vcpunum_expect == vcpunum_actual:
@@ -133,7 +132,7 @@ def install_linux_check(params):
     mem_expect = utils.get_size_mem(domain_name)
     logger.info("current mem size in domain config xml - %s is %s" %
                  (domain_name, mem_expect))
-    mem_actual = chk.get_remote_memory(ipaddr, "root", "redhat")
+    mem_actual = check.get_remote_memory(ipaddr, "root", "redhat")
     logger.info("The actual mem size in guest - %s is %s" %
                 (domain_name, mem_actual))
     diff_range = int(mem_expect) * 0.07
@@ -156,7 +155,7 @@ def install_linux_check(params):
     envparser = env_parser.Envparser(envfile)
     file_url = envparser.get_value("other", "wget_url")
 
-    if chk.run_wget_app(ipaddr, "root", "redhat", file_url, logger) == 0:
+    if check.run_wget_app(ipaddr, "root", "redhat", file_url, logger) == 0:
         logger.info("run wget successfully in guest.")
     else:
         logger.error("Error: fail to run wget in guest")
@@ -167,9 +166,9 @@ def install_linux_check(params):
     if 'kvm' in guesttype or 'xenfv' in guesttype:
         logger.info("check point6: check nic and blk driver in guest is \
                      expected as your config:")
-        if chk.validate_remote_nic_type(ipaddr, "root", "redhat",
+        if check.validate_remote_nic_type(ipaddr, "root", "redhat",
            nic_type, logger) == 0 and \
-           chk.validate_remote_blk_type(ipaddr, "root", "redhat",
+           check.validate_remote_blk_type(ipaddr, "root", "redhat",
                                         blk_type, logger) == 0:
             logger.info("nic type - %s and blk type - %s check successfully" %
                        (nic_type, blk_type))
diff --git a/repos/snapshot/file_flag.py b/repos/snapshot/file_flag.py
index 4d88416..f2257f6 100644
--- a/repos/snapshot/file_flag.py
+++ b/repos/snapshot/file_flag.py
@@ -33,9 +33,9 @@ def check_domain_running(conn, guestname, logger):
     else:
         return True
 
-def make_flag(chk, ipaddr, username, password, logger):
+def make_flag(ipaddr, username, password, logger):
     """ enter guest OS, create a file in /tmp folder """
-    ret = chk.remote_exec_pexpect(ipaddr, username, password, MAKE_FLAG)
+    ret = check.remote_exec_pexpect(ipaddr, username, password, MAKE_FLAG)
     if ret == "TIMEOUT!!!":
         logger.error("connecting to guest OS timeout")
         return False
@@ -55,7 +55,6 @@ def file_flag(params):
     username = params['username']
     password = params['password']
 
-    chk = check.Check()
     conn = sharedmod.libvirtobj['conn']
 
     if not check_domain_running(conn, guestname, logger):
@@ -81,7 +80,7 @@ def file_flag(params):
         logger.info("vm %s failed to get ip address" % guestname)
         return 1
 
-    if not make_flag(chk, ipaddr, username, password, logger):
+    if not make_flag(ipaddr, username, password, logger):
         logger.error("making flag in guest %s failed" % guestname)
         return 1
     else:
diff --git a/repos/snapshot/flag_check.py b/repos/snapshot/flag_check.py
index 7bdc14c..218d7e4 100644
--- a/repos/snapshot/flag_check.py
+++ b/repos/snapshot/flag_check.py
@@ -44,7 +44,6 @@ def flag_check(params):
     else:
         expected_result = "exist"
 
-    chk = check.Check()
     conn = sharedmod.libvirtobj['conn']
 
     if not check_domain_running(conn, guestname, logger):
@@ -70,7 +69,7 @@ def flag_check(params):
         logger.info("vm %s failed to get ip address" % guestname)
         return 1
 
-    ret = chk.remote_exec_pexpect(ipaddr, username, password, FLAG_CHECK)
+    ret = check.remote_exec_pexpect(ipaddr, username, password, FLAG_CHECK)
     if ret == "TIMEOUT!!!":
         logger.error("connecting to guest OS timeout")
         return 1
-- 
1.7.7.3


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