2 # NEPI, a framework to manage network experiments
3 # Copyright (C) 2013 INRIA
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20 from nepi.resources.linux.node import LinuxNode
24 class DummyEC(object):
29 def create_node(hostname, username):
31 node = LinuxNode(ec, 1)
32 node.set("hostname", hostname)
33 node.set("username", username)
35 # If we don't return the reference to the EC
36 # it will be released by the garbage collector since
37 # the resources only save a weak refernce to it.
40 def skipIfNotAlive(func):
42 def wrapped(*args, **kwargs):
43 node, ec = create_node(args[1], args[2])
45 if not node.is_alive():
46 print "*** WARNING: Skipping test %s: Node %s is not alive\n" % (
47 name, node.get("hostname"))
50 return func(*args, **kwargs)
54 def skipIfAnyNotAlive(func):
56 def wrapped(*args, **kwargs):
59 for i in xrange(len(argss)/2):
61 hostname = argss[i*2+1]
62 node, ec = create_node(hostname, username)
64 if not node.is_alive():
65 print "*** WARNING: Skipping test %s: Node %s is not alive\n" % (
66 name, node.get("hostname"))
69 return func(*args, **kwargs)
73 def skipInteractive(func):
75 def wrapped(*args, **kwargs):
76 mode = os.environ.get("NEPI_INTERACTIVE_TEST", False)
77 mode = mode and mode.lower() in ['true', 'yes']
79 print "*** WARNING: Skipping test %s: Interactive mode off \n" % name
82 return func(*args, **kwargs)
86 def skipIfNotPLCredentials(func):
88 def wrapped(*args, **kwargs):
89 pl_user = os.environ.get("PL_USER")
90 pl_pass = os.environ.get("PL_PASS")
91 pl_slice = os.environ.get("PL_SLICE")
92 if not (pl_user and pl_pass and pl_slice):
93 print "*** WARNING: Skipping test %s: Planetlab user, password and slicename not defined\n" % name
96 return func(*args, **kwargs)