diff mbox

[KVM-AUTOTEST,3/4] KVM test: use the new Env methods instead of the old env_* functions

Message ID 1293550990-10669-4-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Dec. 28, 2010, 3:43 p.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
index 9d942d3..7d7bf55 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -106,7 +106,7 @@  class kvm(test.test):
                 raise
             # Abort on error
             logging.info("Aborting job (%s)", e)
-            for vm in kvm_utils.env_get_all_vms(env):
+            for vm in env.get_all_vms():
                 if vm.is_dead():
                     continue
                 logging.info("VM '%s' is alive.", vm.name)
diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
index 25c4e5f..4daafec 100644
--- a/client/tests/kvm/kvm_preprocessing.py
+++ b/client/tests/kvm/kvm_preprocessing.py
@@ -50,13 +50,13 @@  def preprocess_vm(test, params, env, name):
     @param name: The name of the VM object.
     """
     logging.debug("Preprocessing VM '%s'..." % name)
-    vm = kvm_utils.env_get_vm(env, name)
+    vm = env.get_vm(name)
     if vm:
         logging.debug("VM object found in environment")
     else:
         logging.debug("VM object does not exist; creating it")
         vm = kvm_vm.VM(name, params, test.bindir, env.get("address_cache"))
-        kvm_utils.env_register_vm(env, name, vm)
+        env.register_vm(name, vm)
 
     start_vm = False
 
@@ -122,7 +122,7 @@  def postprocess_vm(test, params, env, name):
     @param name: The name of the VM object.
     """
     logging.debug("Postprocessing VM '%s'..." % name)
-    vm = kvm_utils.env_get_vm(env, name)
+    vm = env.get_vm(name)
     if vm:
         logging.debug("VM object found in environment")
     else:
@@ -338,7 +338,7 @@  def postprocess(test, params, env):
     if params.get("kill_unresponsive_vms") == "yes":
         logging.debug("'kill_unresponsive_vms' specified; killing all VMs "
                       "that fail to respond to a remote login request...")
-        for vm in kvm_utils.env_get_all_vms(env):
+        for vm in env.get_all_vms():
             if vm.is_alive():
                 session = vm.remote_login()
                 if session:
@@ -350,7 +350,7 @@  def postprocess(test, params, env):
     kvm_subprocess.kill_tail_threads()
 
     # Terminate tcpdump if no VMs are alive
-    living_vms = [vm for vm in kvm_utils.env_get_all_vms(env) if vm.is_alive()]
+    living_vms = [vm for vm in env.get_all_vms() if vm.is_alive()]
     if not living_vms and "tcpdump" in env:
         env["tcpdump"].close()
         del env["tcpdump"]
@@ -408,7 +408,7 @@  def _take_screendumps(test, params, env):
     cache = {}
 
     while True:
-        for vm in kvm_utils.env_get_all_vms(env):
+        for vm in env.get_all_vms():
             if not vm.is_alive():
                 continue
             try:
diff --git a/client/tests/kvm/kvm_test_utils.py b/client/tests/kvm/kvm_test_utils.py
index 6569d3b..7ed3330 100644
--- a/client/tests/kvm/kvm_test_utils.py
+++ b/client/tests/kvm/kvm_test_utils.py
@@ -35,7 +35,7 @@  def get_living_vm(env, vm_name):
     @param vm_name: Name of the desired VM object.
     @return: A VM object.
     """
-    vm = kvm_utils.env_get_vm(env, vm_name)
+    vm = env.get_vm(vm_name)
     if not vm:
         raise error.TestError("VM '%s' not found in environment" % vm_name)
     if not vm.is_alive():
@@ -275,7 +275,7 @@  def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp",
 
     # Replace the source VM with the new cloned VM
     if (dest_host == 'localhost') and (env is not None):
-        kvm_utils.env_register_vm(env, vm.name, dest_vm)
+        env.register_vm(vm.name, dest_vm)
 
     # Return the new cloned VM
     if dest_host == 'localhost':
diff --git a/client/tests/kvm/tests/ksm_overcommit.py b/client/tests/kvm/tests/ksm_overcommit.py
index deadda1..c6368d3 100644
--- a/client/tests/kvm/tests/ksm_overcommit.py
+++ b/client/tests/kvm/tests/ksm_overcommit.py
@@ -544,7 +544,7 @@  def run_ksm_overcommit(test, params, env):
 
     # Creating the first guest
     kvm_preprocessing.preprocess_vm(test, params, env, vm_name)
-    lvms.append(kvm_utils.env_get_vm(env, vm_name))
+    lvms.append(env.get_vm(vm_name))
     if not lvms[0]:
         raise error.TestError("VM object not found in environment")
     if not lvms[0].is_alive():
@@ -575,7 +575,7 @@  def run_ksm_overcommit(test, params, env):
 
         # Last VM is later used to run more allocators simultaneously
         lvms.append(lvms[0].clone(vm_name, params))
-        kvm_utils.env_register_vm(env, vm_name, lvms[i])
+        env.register_vm(vm_name, lvms[i])
         params['vms'] += " " + vm_name
 
         logging.debug("Booting guest %s" % lvms[i].name)
diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py
index 39b7427..6351a84 100644
--- a/client/tests/kvm/tests/qemu_img.py
+++ b/client/tests/kvm/tests/qemu_img.py
@@ -289,7 +289,7 @@  def run_qemu_img(test, params, env):
             # Start a new VM, using backing file as its harddisk
             vm_name = params.get('main_vm')
             kvm_preprocessing.preprocess_vm(test, params, env, vm_name)
-            vm = kvm_utils.env_get_vm(env, vm_name)
+            vm = env.get_vm(vm_name)
             vm.create()
             timeout = int(params.get("login_timeout", 360))
             session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
@@ -317,7 +317,7 @@  def run_qemu_img(test, params, env):
             # Here, the commit_testfile should not exist
             vm_name = params.get('main_vm')
             kvm_preprocessing.preprocess_vm(test, params, env, vm_name)
-            vm = kvm_utils.env_get_vm(env, vm_name)
+            vm = env.get_vm(vm_name)
             vm.create()
             timeout = int(params.get("login_timeout", 360))
             session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
@@ -343,7 +343,7 @@  def run_qemu_img(test, params, env):
             # Start a new VM, using image_name as its harddisk
             vm_name = params.get('main_vm')
             kvm_preprocessing.preprocess_vm(test, params, env, vm_name)
-            vm = kvm_utils.env_get_vm(env, vm_name)
+            vm = env.get_vm(vm_name)
             vm.create()
             timeout = int(params.get("login_timeout", 360))
             session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
diff --git a/client/tests/kvm/tests/stepmaker.py b/client/tests/kvm/tests/stepmaker.py
index ee0ed92..9f6d9b2 100755
--- a/client/tests/kvm/tests/stepmaker.py
+++ b/client/tests/kvm/tests/stepmaker.py
@@ -337,7 +337,7 @@  class StepMaker(stepeditor.StepMakerWindow):
 
 
 def run_stepmaker(test, params, env):
-    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
+    vm = env.get_vm(params.get("main_vm"))
     if not vm:
         raise error.TestError("VM object not found in environment")
     if not vm.is_alive():
diff --git a/client/tests/kvm/tests/steps.py b/client/tests/kvm/tests/steps.py
index 6f782f5..5d4ed25 100644
--- a/client/tests/kvm/tests/steps.py
+++ b/client/tests/kvm/tests/steps.py
@@ -181,7 +181,7 @@  def barrier_2(vm, words, params, debug_dir, data_scrdump_filename,
 
 
 def run_steps(test, params, env):
-    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
+    vm = env.get_vm(params.get("main_vm"))
     if not vm:
         raise error.TestError("VM object not found in environment")
     if not vm.is_alive():
diff --git a/client/tests/kvm/tests/stress_boot.py b/client/tests/kvm/tests/stress_boot.py
index 13dc944..37d853b 100644
--- a/client/tests/kvm/tests/stress_boot.py
+++ b/client/tests/kvm/tests/stress_boot.py
@@ -36,7 +36,7 @@  def run_stress_boot(tests, params, env):
             vm_name = "vm" + str(num)
             vm_params = vm.get_params().copy()
             curr_vm = vm.clone(vm_name, vm_params)
-            kvm_utils.env_register_vm(env, vm_name, curr_vm)
+            env.register_vm(vm_name, curr_vm)
             logging.info("Booting guest #%d" % num)
             kvm_preprocessing.preprocess_vm(tests, vm_params, env, vm_name)
             params['vms'] += " " + vm_name
diff --git a/client/tests/kvm/tests/unittest.py b/client/tests/kvm/tests/unittest.py
index 67686e3..c724051 100644
--- a/client/tests/kvm/tests/unittest.py
+++ b/client/tests/kvm/tests/unittest.py
@@ -88,7 +88,7 @@  def run_unittest(test, params, env):
             try:
                 vm_name = params.get('main_vm')
                 kvm_preprocessing.preprocess_vm(test, params, env, vm_name)
-                vm = kvm_utils.env_get_vm(env, vm_name)
+                vm = env.get_vm(vm_name)
                 vm.create()
                 vm.monitor.cmd("cont")
                 logging.info("Waiting for unittest %s to complete, timeout %s, "
diff --git a/client/tests/kvm/tests/virtio_console.py b/client/tests/kvm/tests/virtio_console.py
index a51e309..fea3685 100644
--- a/client/tests/kvm/tests/virtio_console.py
+++ b/client/tests/kvm/tests/virtio_console.py
@@ -583,7 +583,7 @@  def run_virtio_console(test, params, env):
         kvm_preprocessing.preprocess_vm(test, params, env,
                                         params.get("main_vm"))
 
-        vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
+        vm = env.get_vm(params.get("main_vm"))
 
         session = kvm_test_utils.wait_for_login(vm, 0,
                                          float(params.get("boot_timeout", 240)),