From patchwork Sun Apr 10 17:10:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 696841 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3AHAXkg026896 for ; Sun, 10 Apr 2011 17:10:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755396Ab1DJRKa (ORCPT ); Sun, 10 Apr 2011 13:10:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30272 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755351Ab1DJRKa (ORCPT ); Sun, 10 Apr 2011 13:10:30 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3AHASNi015978 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 10 Apr 2011 13:10:28 -0400 Received: from freedom.redhat.com (vpn-8-90.rdu.redhat.com [10.11.8.90]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p3AHAPGx016247; Sun, 10 Apr 2011 13:10:26 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH 1/5] Moving test_setup.display_attributes to kvm_utils Date: Sun, 10 Apr 2011 14:10:19 -0300 Message-Id: <1302455423-32116-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 10 Apr 2011 17:10:34 +0000 (UTC) Signed-off-by: Lucas Meneghel Rodrigues --- client/tests/kvm/kvm_utils.py | 14 ++++++++++++++ client/tests/kvm/test_setup.py | 18 +++--------------- 2 files changed, 17 insertions(+), 15 deletions(-) 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: