"status_function": status_application,
"stop_function": stop_application,
"configure_function": configure_application,
- "box_attributes": ["command", "sudo", "stdin"],
+ "box_attributes": ["command", "sudo", "stdin",
+ "depends", "build-depends", "build",
+ "sources" ],
"connector_types": ["node"],
"traces": ["stdout", "stderr"]
}),
'max_bandwidth' : ('bw%(timeframe)s', '[value'),
}
+ DEPENDS_PIDFILE = '/tmp/nepi-depends.pid'
+ DEPENDS_LOGFILE = '/tmp/nepi-depends.log'
+
def __init__(self, api=None):
if not api:
api = plcapi.PLCAPI()
def install_dependencies(self):
if self.required_packages:
# TODO: make dependant on the experiment somehow...
- pidfile = '/tmp/nepi-depends.pid'
- logfile = '/tmp/nepi-depends.log'
+ pidfile = self.DEPENDS_PIDFILE
+ logfile = self.DEPENDS_LOGFILE
# Start process in a "daemonized" way, using nohup and heavy
# stdin/out redirection to avoid connection issues
def wait_dependencies(self, pidprobe=1, probe=10, pidmax=10):
if self.required_packages:
+ pidfile = self.DEPENDS_PIDFILE
+
# get PID
pid = ppid = None
for probenum in xrange(pidmax):
"""
def remote_spawn(command, pidfile, stdout='/dev/null', stderr=STDOUT, stdin='/dev/null', home=None, create_home=False, sudo=False,
- host = None, port = None, user = None, agent = None, ident_key = None):
+ host = None, port = None, user = None, agent = None, ident_key = None, tty = False):
"""
Spawn a remote command such that it will continue working asynchronously.
'stderr' : stderr,
'stdin' : stdin,
- 'sudo' : 'sudo' if sudo else '',
+ 'sudo' : 'sudo -S' if sudo else '',
'pidfile' : server.shell_escape(pidfile),
'gohome' : 'cd %s ; ' % (server.shell_escape(home),) if home else '',
port = port,
user = user,
agent = agent,
- ident_key = ident_key
+ ident_key = ident_key,
+ tty = tty
)
if proc.wait():
""" % {
'ppid' : ppid,
'pid' : pid,
- 'sudo' : 'sudo' if sudo else ''
+ 'sudo' : 'sudo -S' if sudo else ''
},
host = host,
port = port,
def popen_ssh_command(command, host, port, user, agent,
stdin="",
- ident_key = None):
+ ident_key = None,
+ tty = False):
"""
Executes a remote commands, returns ((stdout,stderr),process)
"""
args.append('-p%d' % port)
if ident_key:
args.extend(('-i', ident_key))
+ if tty:
+ args.append('-t')
args.append(command)
# connects to the remote host and starts a remote connection
def popen_ssh_subprocess(python_code, host, port, user, agent,
python_path = None,
- ident_key = None):
+ ident_key = None,
+ tty = False):
if python_path:
python_path.replace("'", r"'\''")
cmd = """PYTHONPATH="$PYTHONPATH":'%s' """ % python_path
args.append('-p%d' % port)
if ident_key:
args.extend(('-i', ident_key))
+ if tty:
+ args.append('-t')
args.append(cmd)
# connects to the remote host and starts a remote rpyc connection
def tearDown(self):
shutil.rmtree(self.root_dir)
- @test_util.skipUnless(test_util.pl_auth() is not None, "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
- def test_simple(self):
+ def make_instance(self):
testbed_version = "01"
instance = planetlab.TestbedController(testbed_version)
slicename = "inria_nepi12"
instance.defer_configure("authUser", pl_user)
instance.defer_configure("authPass", pl_pwd)
+ return instance
+
+ @test_util.skipUnless(test_util.pl_auth() is not None, "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
+ def test_simple(self):
+ instance = self.make_instance()
+
instance.defer_create(2, "Node")
instance.defer_create_set(2, "hostname", "onelab11.pl.sophia.inria.fr")
instance.defer_create(3, "Node")
instance.stop()
instance.shutdown()
+ @test_util.skipUnless(test_util.pl_auth() is not None, "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
+ def test_depends(self):
+ instance = self.make_instance()
+
+ instance.defer_create(2, "Node")
+ instance.defer_create_set(2, "hostname", "onelab11.pl.sophia.inria.fr")
+ instance.defer_create(3, "NodeInterface")
+ instance.defer_connect(2, "devs", 3, "node")
+ instance.defer_create(4, "Internet")
+ instance.defer_connect(3, "inet", 4, "devs")
+ instance.defer_create(5, "Application")
+ instance.defer_create_set(5, "command", "gfortran --version")
+ instance.defer_create_set(5, "depends", "gcc-gfortran")
+ instance.defer_add_trace(5, "stdout")
+ instance.defer_connect(5, "node", 2, "apps")
+
+ instance.do_setup()
+ instance.do_create()
+ instance.do_connect()
+ instance.do_preconfigure()
+ instance.do_configure()
+
+ instance.start()
+ while instance.status(5) != STATUS_FINISHED:
+ time.sleep(0.5)
+ ping_result = instance.trace(5, "stdout") or ""
+ comp_result = r".*GNU Fortran \(GCC\).*"
+ self.assertTrue(re.match(comp_result, ping_result, re.MULTILINE),
+ "Unexpected trace:\n" + ping_result)
+ instance.stop()
+ instance.shutdown()
+
if __name__ == '__main__':
unittest.main()