From 5d84dd90613b9d27411d94c0c25c7fb1c98436f6 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 29 Feb 2020 21:30:56 +0100 Subject: [PATCH] testbed-support: add compatibility with cli-tools v3 --- dist/testbed-support/Makefile.iotlab | 22 +++++++++++++++---- .../makefile.iotlab.single.inc.mk | 19 +++++++++++++--- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/dist/testbed-support/Makefile.iotlab b/dist/testbed-support/Makefile.iotlab index 2071eba2a5..280266d69b 100644 --- a/dist/testbed-support/Makefile.iotlab +++ b/dist/testbed-support/Makefile.iotlab @@ -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) \ diff --git a/dist/testbed-support/makefile.iotlab.single.inc.mk b/dist/testbed-support/makefile.iotlab.single.inc.mk index 51176e2b6f..c9a92cc243 100644 --- a/dist/testbed-support/makefile.iotlab.single.inc.mk +++ b/dist/testbed-support/makefile.iotlab.single.inc.mk @@ -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))