aboutsummaryrefslogtreecommitdiff
path: root/litsupport/remote.py
blob: 887ce0c12459bac4739da8be05ac422410de15cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Test module to execute a benchmark through ssh on a remote device.
This assumes all relevant directories and files are present on the remote
device (typically shared by NFS)."""
from litsupport import testplan
import logging


def _mutateCommandline(context, commandline, suffix=""):
    shfilename = context.tmpBase + suffix + ".sh"
    shfile = open(shfilename, "w")
    shfile.write(commandline + "\n")
    logging.info("Created shfile '%s'", shfilename)
    shfile.close()

    config = context.config
    remote_commandline = config.remote_client
    if config.remote_user:
        remote_commandline += " -l %s" % config.remote_user
    if config.remote_port:
        remote_commandline += " -p %s" % config.remote_port
    if config.remote_flags:
        remote_commandline += config.remote_flags
    remote_commandline += " %s" % config.remote_host
    remote_commandline += " /bin/sh %s" % shfilename
    return remote_commandline


def _mutateScript(context, script, suffix=""):
    mutate = lambda c, cmd: _mutateCommandline(c, cmd, suffix)
    return testplan.mutateScript(context, script, mutate)


def mutatePlan(context, plan):
    plan.preparescript = _mutateScript(context, plan.preparescript, "-prepare")
    plan.runscript = _mutateScript(context, plan.runscript)