物联网实验室测试台ssh命令行客户端

iotlabsshcli的Python项目详细描述


PyPI package statusTravis build statusCodecov coverage status

ssh cli tools提供一组用于远程轻松交互的命令 物联网实验室开放A8节点。见here 以获取有关此类节点的更多信息。

ssh cli工具提供的所有可用操作都可用作子命令 IotLab ssh的。

提供的子命令是:

Sub-commandFunction
flash-m3Flash the given firmware on the M3 MCU of A8 nodes
reset-m3Reset the M3 node of A8 nodes
wait-for-bootBlock the execution until all given A8 nodes have booted or maximum wait time has expired
run-scriptRun a given script in background (screen session) on the given A8 nodes
run-cmdRun a command on the given A8 nodes
copy-fileCopy a file on SSH frontend homedir directory (~/A8/.iotlabsshcli)

ssh cli工具可以与 IoT-Lab CLI Tools类似的命令 物联网实验室认证和物联网实验室实验。

安装:

你需要Pythonpip。 要在系统范围内安装ssh cli工具,请使用pip(或pip3 for Python3):

$ sudo pip install iotlabsshcli

已知pip version>;=9.0可以工作;您可能需要升级。 有关安装选项的详细信息,请参见INSTALLING.md

要求:

可通过网关ssh服务器(iot lab ssh)访问开放的a8节点 前端)。因此,您必须验证 ssh cli工具已记录在iot实验室用户配置文件中。你可以找到 在此配置物联网实验室ssh访问 tutorial

示例:

开始一个实验,等待它准备好,等待所有A8启动:

$ iotlab-experiment submit -d 120 -l saclay,a8,1-10
{
    "id": 65535
}
$ iotlab-experiment wait
Waiting that experiment 65535 gets in state Running
"Running"
$ iotlab-ssh wait-for-boot
{
    "wait-for-boot": {
        "0": [
            "node-a8-2.saclay.iot-lab.info",
            "node-a8-3.saclay.iot-lab.info",
            "node-a8-5.saclay.iot-lab.info",
            "node-a8-6.saclay.iot-lab.info",
            "node-a8-7.saclay.iot-lab.info",
            "node-a8-9.saclay.iot-lab.info",
            "node-a8-10.saclay.iot-lab.info"
        ],
        "1": [
            "node-a8-4.saclay.iot-lab.info",
            "node-a8-8.saclay.iot-lab.info"
        ]
    }
}

注意:saclay中的node-a8-4和node-a8-8断开。

在工作节点的m3上闪存固件:

$ iotlab-ssh flash-m3 <firmware.elf> -l saclay,a8,2-3+5-7+9-10
{
    "flash-m3": {
        "0": [
            "node-a8-2.saclay.iot-lab.info",
            "node-a8-3.saclay.iot-lab.info",
            "node-a8-5.saclay.iot-lab.info",
            "node-a8-6.saclay.iot-lab.info",
            "node-a8-7.saclay.iot-lab.info",
            "node-a8-9.saclay.iot-lab.info",
            "node-a8-10.saclay.iot-lab.info"
        ]
    }
}

重置一个A8节点的M3:

$ iotlab-ssh reset-m3 -l saclay,a8,2
{
    "reset-m3": {
        "0": [
            "node-a8-2.saclay.iot-lab.info"
        ]
    }
}

使用–verbose选项获得命令输出:

$ iotlab-ssh --verbose reset-m3 -l saclay,a8,2
Connecting via SSH proxy saclay.iot-lab.info:22 -> node-a8-2.saclay.iot-lab.info:22
[node-a8-2.saclay.iot-lab.info]     Open On-Chip Debugger 0.9.0-dirty (2016-04-15-00:55)
[node-a8-2.saclay.iot-lab.info]     Licensed under GNU GPL v2
[node-a8-2.saclay.iot-lab.info] For bug reports, read
[node-a8-2.saclay.iot-lab.info]     http://openocd.org/doc/doxygen/bugs.html
[node-a8-2.saclay.iot-lab.info]     adapter speed: 1000 kHz
[...]
[node-a8-2.saclay.iot-lab.info]     TargetName         Type       Endian TapName            State
[node-a8-2.saclay.iot-lab.info]     --  ------------------ ---------- ------ ------------------ ------------
[node-a8-2.saclay.iot-lab.info] 0* stm32f1x.cpu       cortex_m   little stm32f1x.cpu       running
[node-a8-2.saclay.iot-lab.info]     Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
[node-a8-2.saclay.iot-lab.info]     Info : JTAG tap: stm32f1x.bs tap/device found: 0x06414041 (mfg: 0x020, part: 0x6414, ver: 0x0)
[node-a8-2.saclay.iot-lab.info]     shutdown command invoked
[node-a8-2.saclay.iot-lab.info]     Return Value: 0
{
    "reset-m3": {
        "0": [
            "node-a8-2.saclay.iot-lab.info"
        ]
    }
}

在两个A8节点上运行命令:

$ iotlab-ssh --verbose run-cmd "uname -a" -l saclay,a8,2-3
Connecting via SSH proxy saclay.iot-lab.info:22 -> node-a8-2.saclay.iot-lab.info:22
[node-a8-2.saclay.iot-lab.info]     Linux node-a8-2 3.18.5-iotlab+ #9 Thu Sep 1 16:17:22 CEST 2016 armv7l GNU/Linux
[node-a8-3.saclay.iot-lab.info]     Linux node-a8-3 3.18.5-iotlab+ #9 Thu Sep 1 16:17:22 CEST 2016 armv7l GNU/Linux
{
    "run-cmd": {
        "0": [
            "node-a8-2.saclay.iot-lab.info",
            "node-a8-3.saclay.iot-lab.info"
        ]
    }
}

在ssh前端运行命令:

$ iotlab-ssh --verbose run-cmd "uname -a" --frontend
[saclay.iot-lab.info]       Linux saclay 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux
{
    "run-cmd": {
        "0": [
            "saclay.iot-lab.info"
        ]
    }
}

在ssh frontend homedir目录(~/a8/.iotlabsshcli)上复制文件:

$ iotlab-ssh copy-file test.tar.gz
{
    "run-cmd": {
        "0": [
            "saclay.iot-lab.info"
        ]
    }
}
$ iotlab-ssh run-cmd "tar -xzvf ~/A8/.iotlabsshcli/test.tar.gz -C ~/A8/.iotlabsshcli/" --frontend
{
    "run-cmd": {
        "0": [
            "saclay.iot-lab.info"
        ]
    }
}

注意:a8 homedir目录在实验期间由a8节点挂载(通过nfs)。

在saclay:

中的node-a8-2上运行脚本/tmp/test.sh
$ iotlab-ssh run-script /tmp/test.sh -l saclay,a8,2
{
    "run-script": {
        "0": [
            "node-a8-2.saclay.iot-lab.info"
        ]
    }
}

注意:在A8节点上启动屏幕会话 实际运行脚本并在需要时提供对输出的简单访问。 脚本结束时,屏幕会话终止,日志消失。

root@node-a8-2:~# screen -ls
There is a screen on:
       1877.<login>-<exp_id>   (Detached)
1 Socket in /tmp/screens/S-root.

注意:类似于run命令,如果 您想在ssh前端的后台启动一个脚本。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
用户界面java,使用gui连接到另一台计算机/服务器的文件系统   运行sbt的ubuntu返回错误:“javahome需要<path>参数”   java如何在Android中处理许多ImageView而不出现内存问题?   查询中非法字符的java相同URL失败   安卓取消引用可能会产生“java”。lang.NullPointerException'   java中的indexoutofboundsexception“java.lang.ArrayIndexOutOfBoundsException”错误   xml Java将dom保存到文件>文件在程序结束后由另一个进程打开   Java的垃圾收集器是如何工作的?   Java如何筛选值(列表)   java处理字符串我怎样才能像在真实的书籍中一样在上面部分生成“小数字”呢?   java SonarQube是否有一个API来获取所有项目分析的一部分?   java startActivity(intent)什么都不做   JAVAutil。扫描器类Java   java如何从Firebase更新电子邮件?UpdateMail方法已被弃用   java Hibernate。如何正确组织带有注释的onetomany关系?   在java中获得卷标和驱动器号之间的映射(而不是FileSystemView)的解决方法是什么   java查找文件的路径