Example #1
0
def compile(name, localdir=None, remotedir=None):
    """
    Compiles the given test case on all the hosts in the system.

    The building details and the respect of the convention are enforced by the
    Makefile and not further explained here.
    """
    # Read the defaults from the settings if the arguments are not provided
    if not localdir or not remotedir:
        paths = settings.PATHS['test-cases']

        if not localdir:
            localdir = paths[0]

        if not remotedir:
            remotedir = paths[1]

    local = os.path.join(localdir, name)
    remote = os.path.join(remotedir, name)

    shell.local('rm -f {0}/build/obj.map'.format(local))

    base = os.path.dirname(settings.PATHS['configuration'][1])

    with shell.workon(all_hosts()):
        with shell.cd(remote):
            shell.remote('ENV_BASE={0} make -e clean'.format(base))
            shell.remote('ENV_BASE={0} make -e build'.format(base))
Example #2
0
def command(options):
    """
    Kills all the running measures on the given host (or on all hosts if no host
    is given) independently from the capturing interface or the name with which
    they were started.
    """
    with shell.workon(options.hosts):
        tshark.kill()
Example #3
0
def command(options):
    """
    Kills the jobmgr on one or more hosts.
    """
    if options.hosts:
        # Hosts manually defined, start them all without delays
        with shell.workon(options.hosts):
            jobmgr.kill()
    else:
        jobmgr.killall()
Example #4
0
def stop(name):
    """
    Start a new named measure session in background on all interested hosts.

    As for the start function, the hosts are retrieved from the interfaces
    setting directive and the stop command issued on each one.
    """
    for host, interfaces in map_interfaces():
        with shell.workon(host):
            for i in interfaces:
                tshark.stop(name, i)
Example #5
0
def command(options):
    """
    Starts the jobmgr on the provided hosts. If no hosts are provided, starts
    the jobmgr on all master and client hosts by accounting for a startup delay.
    """
    if options.hosts:
        # Hosts manually defined, start them all without delays
        with shell.workon(options.hosts):
            jobmgr.start()
    else:
        jobmgr.startall()
Example #6
0
def startall():
    """
    Starts all nodes of the system grouped by roles with the necessary delays
    to allow a proper registration to the parent JobMgr.
    
    The delay between the invocations can be set in the settings.
    """
    # Start all masters before, allowing for a proper setup before registering
    # a new slave
    with shell.workon(role('master')):
        start()

    # Wait some (configurable) time. One or two seconds should be enough here
    time.sleep(settings.STARTUP_DELAY)

    # And now start the slaves
    with shell.workon(role('slaves')):
        start()

    # Wait again some time for possible subsequent programs execution
    time.sleep(settings.STARTUP_DELAY)
Example #7
0
def stopall():
    """
    Stops all nodes of the system grouped by roles with the necessary delays
    to allow a proper registration to the parent JobMgr.
    
    The delay between the invocations can be set in the settings.
    
    Note that in this case the delays are not as important as in the start 
    function on could probably safely be omitted. The behavior is preserved to
    grant compatibility with future versions of the JobMgr which possibly
    wants to execute some cleanup code before terminating.
    
    In the meanwhile it is possible to set the delay to 0 in the settings.
    """
    with shell.workon(role('slaves')):
        stop()

    time.sleep(settings.SHUTDOWN_DELAY)

    with shell.workon(role('master')):
        stop()

    time.sleep(settings.SHUTDOWN_DELAY)
Example #8
0
def execute(name, remotedir=None):
    """
    Executes the given test case on all client hosts (normally onle one).
    """
    if not remotedir:
        remotedir = settings.PATHS['test-cases'][1]

    remote = os.path.join(remotedir, name)

    base = os.path.dirname(settings.PATHS['configuration'][1])

    with shell.workon(role('client')):
        with shell.cd(remote):
            shell.remote('ENV_BASE={0} make -e execute'.format(base))
Example #9
0
def toxml(name):
    """
    Converts all raw measure files for the given measure to xml using a remote
    tshark command.

    This will overwrite all already converted files with matching names.
    """
    host_shared, guest_shared = settings.PATHS["shared-measures"]
    pattern = os.path.join(host_shared, name, "*", "*.raw")

    paths = glob.glob(pattern)
    paths = (guest_shared + path[len(host_shared) :] for path in paths)

    with shell.workon(role("client")):
        for path in paths:
            tshark.pcaptoxml(path, path.replace(".raw", ".xml"), settings.DISPLAY_FILTER)
Example #10
0
def start(name):
    """
    Start a new named measure session in background on all interested hosts.

    The hosts are retrieved from the ROLES setting directive and a
    measure is started for each one.
    """
    dest = settings.PATHS["local-measures"][1]
    fltr = settings.CAPTURE_FILTER

    for host, interfaces in map_interfaces():
        with shell.workon(host):
            shell.remote("rm -rf {0} ; mkdir {0}".format(dest), sudo=True)

            for i in interfaces:
                mname = "{0}.{1}".format(name, i)
                tshark.start(mname, i, "{0}/{1}.raw".format(dest, mname), fltr)