public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Goldish <mgoldish@redhat.com>
To: autotest@test.kernel.org, kvm@vger.kernel.org
Cc: Eduardo Habkost <ehabkost@raisama.net>
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	[thread overview]
Message-ID: <1293550990-10669-5-git-send-email-mgoldish@redhat.com> (raw)
In-Reply-To: <1293550990-10669-1-git-send-email-mgoldish@redhat.com>

Also, move is_vm() closer to the definition of Env.

Signed-off-by: Eduardo Habkost <ehabkost@raisama.net>
---
 client/tests/kvm/kvm_utils.py |   88 ++---------------------------------------
 1 files changed, 4 insertions(+), 84 deletions(-)

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):
-- 
1.7.3.4

  parent reply	other threads:[~2010-12-28 15:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-28 15:43 [KVM-AUTOTEST PATCH 0/4] KVM test: replace 'env' dict with an Env object Michael Goldish
2010-12-28 15:43 ` [KVM-AUTOTEST PATCH 1/4] KVM test: introduce the Env class Michael Goldish
2010-12-28 15:43 ` [KVM-AUTOTEST PATCH 2/4] KVM test: use kvm_utils.Env wherever appropriate Michael Goldish
2010-12-28 15:43 ` [KVM-AUTOTEST PATCH 3/4] KVM test: use the new Env methods instead of the old env_* functions Michael Goldish
2010-12-28 15:43 ` Michael Goldish [this message]
2010-12-28 15:49 ` [KVM-AUTOTEST PATCH 0/4] KVM test: replace 'env' dict with an Env object Lucas Meneghel Rodrigues

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1293550990-10669-5-git-send-email-mgoldish@redhat.com \
    --to=mgoldish@redhat.com \
    --cc=autotest@test.kernel.org \
    --cc=ehabkost@raisama.net \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox