From patchwork Tue Dec 28 15:43:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 436631 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 oBSFiIgu022292 for ; Tue, 28 Dec 2010 15:44:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754165Ab0L1PoQ (ORCPT ); Tue, 28 Dec 2010 10:44:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49702 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754155Ab0L1PoN (ORCPT ); Tue, 28 Dec 2010 10:44:13 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBSFiCZ0001309 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 28 Dec 2010 10:44:12 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oBSFiBt5017251; Tue, 28 Dec 2010 10:44:11 -0500 Received: from moof.tlv.redhat.com (dhcp-1-185.tlv.redhat.com [10.35.1.185]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id oBSFi39h019837; Tue, 28 Dec 2010 10:44:10 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish , Eduardo Habkost Subject: [KVM-AUTOTEST PATCH 4/4] KVM test: get rid of the kvm_utils.env_* functions Date: Tue, 28 Dec 2010 17:43:10 +0200 Message-Id: <1293550990-10669-5-git-send-email-mgoldish@redhat.com> In-Reply-To: <1293550990-10669-1-git-send-email-mgoldish@redhat.com> References: <1293550990-10669-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 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.3 (demeter1.kernel.org [140.211.167.41]); Tue, 28 Dec 2010 15:44:19 +0000 (UTC) diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index 2423dd9..49e3fe8 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -27,39 +27,13 @@ def _unlock_file(f): f.close() -def dump_env(obj, filename): - """ - Dump KVM test environment to a file. - - @param filename: Path to a file where the environment will be dumped to. - """ - file = open(filename, "w") - cPickle.dump(obj, file) - file.close() - - -def load_env(filename, version): +def is_vm(obj): """ - Load KVM test environment from an env file. - If the version recorded in the file is lower than version, return an empty - env. If some other error occurs during unpickling, return an empty env. + Tests whether a given object is a VM object. - @param filename: Path to an env file. + @param obj: Python object. """ - default = {"version": version} - try: - file = open(filename, "r") - env = cPickle.load(file) - file.close() - if env.get("version", 0) < version: - logging.warn("Incompatible env file found. Not using it.") - return default - return env - # Almost any exception can be raised during unpickling, so let's catch - # them all - except Exception, e: - logging.warn(e) - return default + return obj.__class__.__name__ == "VM" class Env(UserDict.IterableUserDict): @@ -326,60 +300,6 @@ def verify_ip_address_ownership(ip, macs, timeout=10.0): return bool(regex.search(o)) -# Functions for working with the environment (a dict-like object) - -def is_vm(obj): - """ - Tests whether a given object is a VM object. - - @param obj: Python object (pretty much everything on python). - """ - return obj.__class__.__name__ == "VM" - - -def env_get_all_vms(env): - """ - Return a list of all VM objects on a given environment. - - @param env: Dictionary with environment items. - """ - vms = [] - for obj in env.values(): - if is_vm(obj): - vms.append(obj) - return vms - - -def env_get_vm(env, name): - """ - Return a VM object by its name. - - @param name: VM name. - """ - return env.get("vm__%s" % name) - - -def env_register_vm(env, name, vm): - """ - Register a given VM in a given env. - - @param env: Environment where we will register the VM. - @param name: VM name. - @param vm: VM object. - """ - env["vm__%s" % name] = vm - - -def env_unregister_vm(env, name): - """ - Remove a given VM from a given env. - - @param env: Environment where we will un-register the VM. - @param name: VM name. - """ - del env["vm__%s" % name] - - # Utility functions for dealing with external processes def find_command(cmd):