Exemplo n.º 1
0
def get_node_uids_lookup():
    api = iotlabcli.Api(*iotlabcli.get_user_credentials())
    info = iotlabcli.experiment.info_experiment(api)
    return {
        x["uid"]: x["network_address"].split('.')[0]
        for x in info["items"]
    }
Exemplo n.º 2
0
def get_nodes_selection(username, password, experiment_id, nodes_list, *_args,
                        **_kwargs):  # pylint:disable=unused-argument
    """ Return the requested nodes from 'experiment_id', and 'nodes_list """
    username, password = iotlabcli.get_user_credentials(username, password)
    api = iotlabcli.Api(username, password)
    nodes = query_nodes(api, experiment_id, nodes_list)
    return nodes
Exemplo n.º 3
0
def main():
    """ Reads nodes from ressource json in stdin and
    aggregate serial links of all nodes
    """
    parser = opts_parser()
    opts = parser.parse_args()

    try:
        username, password = iotlabcli.get_user_credentials(
            opts.username, opts.password)
        api = iotlabcli.Api(username, password)
        nodes_list = serial_aggregator.get_nodes(api,
                                                 opts.experiment_id,
                                                 opts.nodes_list,
                                                 with_a8=True)
        print "Using algorith: %r" % opts.algo
        algorithm = ALGOS[opts.algo]
    except (ValueError, RuntimeError) as err:
        sys.stderr.write("%s\n" % err)
        exit(1)

    # Connect to the nodes
    results = NodeResults(opts.outfile)
    aggregator = serial_aggregator.NodeAggregator(
        nodes_list, print_lines=True, line_handler=results.handle_line)
    aggregator.start()
    time.sleep(2)

    # Run the algorithm
    try:
        algorithm(aggregator, opts.num_loop)
        time.sleep(3)
    finally:
        aggregator.stop()
        results.write_results(opts.algo == 'syncronous')
Exemplo n.º 4
0
def exp(exp_id=None):
    """ Extract nodes from `exp_id` experiment and set them as commands targets
    Following roles are set:
     * nodes: all the a8 nodes of the experiment
     * frontends: each sites where there are a8 nodes

    """
    username, password = iotlabcli.get_user_credentials()
    api = iotlabcli.Api(username, password)
    exp_id = iotlabcli.get_current_experiment(api, exp_id)

    env.user = username

    nodes = _get_exp_a8_nodes(api, exp_id)
    env.roledefs['nodes'] = nodes

    sites = list(set([url.split('.', 1)[1] for url in nodes]))
    env.roledefs['frontends'] = sites
Exemplo n.º 5
0
def main():
    """ Check the oar uids using given jsons dicts """

    parser = opts_parser()
    opts = parser.parse_args()
    os.listdir(opts.outdir)  # existing directory

    try:
        username, password = iotlabcli.get_user_credentials(
            opts.username, opts.password)
        api = iotlabcli.Api(username, password)
        server_uids = oar_uids(api)
    except RuntimeError as err:
        sys.stderr.write("%s\n" % err)
        exit(1)

    nodes_uids = nodes_read_uids(opts.uids_json_files)

    nodes_cmp = compare_nodes_uids(server_uids, nodes_uids)
    write_outputs(nodes_cmp, os.path.join(opts.outdir, 'uid_cmp'))
Exemplo n.º 6
0
def push_iotlab(name):
    experiment_path = pj(EXPERIMENT_FOLDER, name)
    results_folder = pj(experiment_path, "results", "iotlab")
    if not os.path.exists(results_folder):
        os.makedirs(results_folder)

    # gets user password from credentials file None, None
    user, passwd = iotlabcli.get_user_credentials()
    api = iotlabcli.Api(user, passwd)

    # describe the resources
    resources = None
    with open(pj(experiment_path, "iotlab.json")) as f:
        config = json.loads(f.read())
        resources = [experiment.exp_resources(**c) for c in config]

    print(resources)
    # actually submit the experiment
    exp_id = None
    # We move to the folder to have a portable iotlab.json
    with lcd(experiment_path):
        exp_res = experiment.submit_experiment(
            api, 'dummy_experiment', 1, resources)
        exp_id = exp_wres["id"]
        with open("results/iotlab/iotlab.json", "w") as f:
            f.write(json.dumps({"id": exp_id}))

    # get the content
    print("Exp submited with id: %u" % exp_id)

    run("experiment-cli wait -i %d" % exp_id)

    with open(pj(results_folder, "serial.log"), 'w') as f:
        run("./iot-lab/tools_and_scripts/serial_aggregator.py -i %d" % exp_id,
            stdout=f)
    print("Written serial logs to %s" % pj(results_folder, "serial.log"))
Exemplo n.º 7
0
def get_nodes_list(opts):
    api = iotlabcli.Api(*iotlabcli.get_user_credentials())
    exp_id = iotlabcli.helpers.get_current_experiment(api, opts.experiment_id)
    return iotlabcli.parser.common._get_experiment_nodes_list(api, exp_id)
Exemplo n.º 8
0
def api(auth):
    username, password = auth
    return iotlabcli.Api(username, password)
Exemplo n.º 9
0
def api():
    username, password = iotlabcli.auth.get_user_credentials()
    return iotlabcli.Api(username, password)