Removing pl_slice from decorator for PL node
[nepi.git] / test / lib / test_utils.py
index d26c9a8..447c703 100644 (file)
@@ -51,6 +51,25 @@ def skipIfNotAlive(func):
     
     return wrapped
 
+def skipIfAnyNotAlive(func):
+    name = func.__name__
+    def wrapped(*args, **kwargs):
+        argss = list(args)
+        argss.pop(0)
+        for i in xrange(len(argss)/2):
+            username = argss[i*2]
+            hostname = argss[i*2+1]
+            node, ec = create_node(hostname, username)
+
+            if not node.is_alive():
+                print "*** WARNING: Skipping test %s: Node %s is not alive\n" % (
+                    name, node.get("hostname"))
+                return
+
+        return func(*args, **kwargs)
+    
+    return wrapped
+
 def skipInteractive(func):
     name = func.__name__
     def wrapped(*args, **kwargs):
@@ -64,4 +83,16 @@ def skipInteractive(func):
     
     return wrapped
 
+def skipIfNotPLCredentials(func):
+    name = func.__name__
+    def wrapped(*args, **kwargs):
+        pl_user = os.environ.get("PL_USER")
+        pl_pass = os.environ.get("PL_PASS")
+        if not (pl_user and pl_pass):
+            print "*** WARNING: Skipping test %s: Planetlab user, password and slicename not defined\n" % name
+            return
+
+        return func(*args, **kwargs)
+
+    return wrapped