1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

testbed-support: add compatibility with cli-tools v3

This commit is contained in:
Alexandre Abadie 2020-02-29 21:30:56 +01:00
parent 681678e3f3
commit 5d84dd9061
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
2 changed files with 34 additions and 7 deletions

View File

@ -1,5 +1,19 @@
.PHONY: iotlab-exp iotlab-flash iotlab-reset iotlab-term iotlab-check-exp
# There are several deprecated features used here and introduced between
# versions 2 and 3 of the IoT-LAB cli tools.
# For backward compatibility, we manage these changes here.
_CLI_TOOLS_MAJOR_VERSION ?= $(shell iotlab-experiment --version | cut -f1 -d.)
ifeq (2,$(_CLI_TOOLS_MAJOR_VERSION))
_NODES_LIST_OPTION = --resources
_NODES_ID_LIST_OPTION = --resources-id
_NODES_FLASH_OPTION = --update
else
_NODES_LIST_OPTION = --nodes
_NODES_ID_LIST_OPTION = --nodes-id
_NODES_FLASH_OPTION = --flash
endif
IOTLAB_NODES ?= 5
IOTLAB_DURATION ?= 30
IOTLAB_TYPE ?= m3:at86rf231
@ -8,7 +22,7 @@ IOTLAB_USER ?= $(shell cut -f1 -d: $(IOTLAB_AUTH))
IOTLAB_EXP_ID ?= $(shell iotlab-experiment get -l --state Running | grep -m 1 '"id"' | grep -Eo '[[:digit:]]+')
IOTLAB_EXP_NAME ?= RIOT_EXP
IOTLAB_DEBUG_PORT ?= 3333
IOTLAB_DEBUG_NODE ?= $(shell iotlab-experiment get -i $(IOTLAB_EXP_ID) --resources | \
IOTLAB_DEBUG_NODE ?= $(shell iotlab-experiment get -i $(IOTLAB_EXP_ID) $(_NODES_LIST_OPTION) | \
grep -m 1 "network_address" | sed 's/.*-\([0-9]*\)\..*/\1/')
IOTLAB_AUTHORITY = "$(IOTLAB_USER)@$(IOTLAB_SITE).iot-lab.info"
@ -16,7 +30,7 @@ ifeq (,$(filter iotlab-exp,$(MAKECMDGOALS)))
# derive experiment site from IOTLAB_EXP_ID, if not given and not used with
# `iotlab_exp`
IOTLAB_SITE ?= $(shell iotlab-experiment --format=str --jmespath "keys(items[0])[0]" \
get -ri -i $(IOTLAB_EXP_ID))
get $(_NODES_ID_LIST_OPTION) -i $(IOTLAB_EXP_ID))
endif
ifneq (,$(findstring m3,$(IOTLAB_TYPE)))
@ -62,7 +76,7 @@ iotlab-exp: $(IOTLAB_AUTH) all
endif
iotlab-flash: $(IOTLAB_AUTH) all
$(Q)iotlab-node --update $(BINARY) -i $(IOTLAB_EXP_ID) $(NODES_PARAM_BASE) $(EXCLUDE_PARAM)
$(Q)iotlab-node $(_NODES_FLASH_OPTION) $(BINARY) -i $(IOTLAB_EXP_ID) $(NODES_PARAM_BASE) $(EXCLUDE_PARAM)
iotlab-reset: $(IOTLAB_AUTH)
$(Q)iotlab-node --reset -i $(IOTLAB_EXP_ID) $(NODES_PARAM_BASE) $(EXCLUDE_PARAM)
@ -82,7 +96,7 @@ iotlab-stop: $(IOTLAB_AUTH)
IOTLABTERMFLASHDEPS ?= $(filter iotlab-flash iotlab-exp,$(MAKECMDGOALS))
iotlab-term: $(IOTLABTERMFLASHDEPS)
$(Q)ssh -t $(IOTLAB_AUTHORITY) "iotlab-experiment get -r -i $(IOTLAB_EXP_ID) > /dev/null || \
$(Q)ssh -t $(IOTLAB_AUTHORITY) "iotlab-experiment get $(_NODES_LIST_OPTION) -i $(IOTLAB_EXP_ID) > /dev/null || \
iotlab-auth -u $(IOTLAB_USER)"
$(Q)ssh -t $(IOTLAB_AUTHORITY) \

View File

@ -82,6 +82,20 @@ IOTLAB_ARCHI_wsn430-v1_3b = wsn430:cc1101
IOTLAB_ARCHI_wsn430-v1_4 = wsn430:cc2420
IOTLAB_ARCHI := $(IOTLAB_ARCHI_$(BOARD))
# There are several deprecated and incompatible features used here that were
# introduced between versions 2 and 3 of the IoT-LAB cli tools.
# For backward compatibility, we manage these changes here.
_CLI_TOOLS_MAJOR_VERSION ?= $(shell iotlab-experiment --version | cut -f1 -d.)
ifeq (2,$(_CLI_TOOLS_MAJOR_VERSION))
_NODES_DEPLOYED = $(shell iotlab-experiment --jmespath='deploymentresults."0"' --format='" ".join' get $(_IOTLAB_EXP_ID) --print)
_NODES_LIST_OPTION = --resources
_NODES_FLASH_OPTION = --update
else
_NODES_DEPLOYED = $(shell iotlab-experiment --jmespath='"0"' --format='" ".join' get $(_IOTLAB_EXP_ID) --deployment)
_NODES_LIST_OPTION = --nodes
_NODES_FLASH_OPTION = --flash
endif
# Try detecting the node automatically
# * It takes the first working node that match BOARD
# * Check correctly deployed nodes with 'deploymentresults == "0"'
@ -92,11 +106,10 @@ ifneq (,$(filter auto auto-ssh,$(IOTLAB_NODE)))
$(error Could not find 'archi' for $(BOARD), update mapping in $(lastword $(MAKEFILE_LIST)))
endif
_NODES_DEPLOYED = $(shell iotlab-experiment --jmespath='deploymentresults."0"' --format='" ".join' get $(_IOTLAB_EXP_ID) --print)
ifeq (auto,$(IOTLAB_NODE))
_NODES_DEPLOYED := $(filter %.$(shell hostname).iot-lab.info, $(_NODES_DEPLOYED))
endif
_NODES_FOR_BOARD = $(shell iotlab-experiment --jmespath="items[?archi=='$(IOTLAB_ARCHI)'].network_address" --format='" ".join' get $(_IOTLAB_EXP_ID) --resources)
_NODES_FOR_BOARD = $(shell iotlab-experiment --jmespath="items[?archi=='$(IOTLAB_ARCHI)'].network_address" --format='" ".join' get $(_IOTLAB_EXP_ID) $(_NODES_LIST_OPTION))
_IOTLAB_NODE := $(word $(IOTLAB_NODE_AUTO_NUM),$(filter $(_NODES_DEPLOYED),$(_NODES_FOR_BOARD)))
ifeq (auto,$(IOTLAB_NODE))
@ -160,7 +173,7 @@ ifneq (iotlab-a8-m3,$(BOARD))
FLASHER = iotlab-node
RESET = iotlab-node
_NODE_FMT = --jmespath='keys(@)[0]' --format='int'
FFLAGS = $(_NODE_FMT) $(_IOTLAB_EXP_ID) $(_IOTLAB_NODELIST) --update $(FLASHFILE) | $(_STDIN_EQ_0)
FFLAGS = $(_NODE_FMT) $(_IOTLAB_EXP_ID) $(_IOTLAB_NODELIST) $(_NODES_FLASH_OPTION) $(FLASHFILE) | $(_STDIN_EQ_0)
RESET_FLAGS = $(_NODE_FMT) $(_IOTLAB_EXP_ID) $(_IOTLAB_NODELIST) --reset | $(_STDIN_EQ_0)
ifeq (,$(_IOTLAB_ON_FRONTEND))