diff mbox

[1/5] Moving test_setup.display_attributes to kvm_utils

Message ID 1302455423-32116-1-git-send-email-lmr@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Meneghel Rodrigues April 10, 2011, 5:10 p.m. UTC
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 client/tests/kvm/kvm_utils.py  |   14 ++++++++++++++
 client/tests/kvm/test_setup.py |   18 +++---------------
 2 files changed, 17 insertions(+), 15 deletions(-)
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index c3810f9..38c4afe 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -6,6 +6,7 @@  KVM test utility functions.
 
 import time, string, random, socket, os, signal, re, logging, commands, cPickle
 import fcntl, shelve, ConfigParser, rss_file_transfer, threading, sys, UserDict
+import inspect
 from autotest_lib.client.bin import utils, os_dep
 from autotest_lib.client.common_lib import error, logging_config
 import kvm_subprocess
@@ -1199,6 +1200,19 @@  def create_report(report_dir, results_dir):
     os.system('%s -r %s -f %s -R' % (reporter, results_dir, html_file))
 
 
+def display_attributes(instance):
+    """
+    Inspects a given class instance attributes and displays them, convenient
+    for debugging.
+    """
+    logging.debug("Attributes set:")
+    for member in inspect.getmembers(instance):
+        name, value = member
+        attribute = getattr(instance, name)
+        if not (name.startswith("__") or callable(attribute) or not value):
+            logging.debug("    %s: %s", name, value)
+
+
 def get_full_pci_id(pci_id):
     """
     Get full PCI ID of pci_id.
diff --git a/client/tests/kvm/test_setup.py b/client/tests/kvm/test_setup.py
index 1125aea..b4363e5 100644
--- a/client/tests/kvm/test_setup.py
+++ b/client/tests/kvm/test_setup.py
@@ -5,6 +5,7 @@  import os, shutil, tempfile, re, ConfigParser, glob, inspect
 import logging, time
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin import utils
+import kvm_utils
 
 
 @error.context_aware
@@ -42,19 +43,6 @@  def clean_old_image(image):
         os.remove(image)
 
 
-def display_attributes(instance):
-    """
-    Inspects a given class instance attributes and displays them, convenient
-    for debugging.
-    """
-    logging.debug("Attributes set:")
-    for member in inspect.getmembers(instance):
-        name, value = member
-        attribute = getattr(instance, name)
-        if not (name.startswith("__") or callable(attribute) or not value):
-            logging.debug("    %s: %s", name, value)
-
-
 class Disk(object):
     """
     Abstract class for Disk objects, with the common methods implemented.
@@ -490,7 +478,7 @@  class UnattendedInstallConfig(object):
         Uses an appropriate strategy according to each install model.
         """
         logging.info("Starting unattended install setup")
-        display_attributes(self)
+        kvm_utils.display_attributes(self)
 
         if self.unattended_file and (self.floppy or self.cdrom_unattended):
             self.setup_boot_disk()
@@ -640,7 +628,7 @@  class EnospcConfig(object):
     def setup(self):
         logging.debug("Starting enospc setup")
         error.context("performing enospc setup")
-        display_attributes(self)
+        kvm_utils.display_attributes(self)
         # Double check if there aren't any leftovers
         self.cleanup()
         try: