diff options
author | Arthur <arthur.she@linaro.org> | 2020-02-12 12:53:10 -0800 |
---|---|---|
committer | Arthur <arthur.she@linaro.org> | 2020-02-12 12:53:10 -0800 |
commit | c119dea0ffec0657a59598bfd11960fca082ccd5 (patch) | |
tree | eaf712dfcea798a728f0f4ae8a11702d3a08912d /automated | |
parent | b93d54ca0e1b8182f3bb45480f423aaa1b128dc3 (diff) |
igt: add control_chamelium.sh
control_chamelium is a net-snmp wrap script used to control the power of
Chamelium.
Signed-off-by: Arthur <arthur.she@linaro.org>
Diffstat (limited to 'automated')
-rwxr-xr-x | automated/linux/igt/control_chamelium.sh | 84 | ||||
-rw-r--r-- | automated/linux/igt/igt-test.yaml | 2 |
2 files changed, 85 insertions, 1 deletions
diff --git a/automated/linux/igt/control_chamelium.sh b/automated/linux/igt/control_chamelium.sh new file mode 100755 index 0000000..1c7f086 --- /dev/null +++ b/automated/linux/igt/control_chamelium.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +delay=10 +SNMPSET="/usr/bin/snmpset" +CONTROL_OID=".1.3.6.1.4.1.318.1.1.4.4.2.1.3." + +usage() { + echo "usage: control-chamelium.py [-h] --hostname HOSTNAME --port PORT --command + {off,on,reboot} [--delay DELAY]\n +optional arguments: + -h, --help show this help message and exit + --hostname HOSTNAME The pdu you wish to control - e.g. pdu05 + --port PORT The pdu port you wish to control, e.g. 4 or 15 + --command {off,on,reboot} + What you wish to do with the port 'off', 'on', + 'reboot' + --delay DELAY Delay in seconds when rebooting between power off and + power on (default 10 seconds)" +} + +send_command() { + control_oid="${CONTROL_OID}${port}" + echo "Turn ${hostname} port ${port} $1" + if [ "$1" = "on" ]; then + cmd="1" + else + cmd="2" + fi + + ${SNMPSET} -v 1 -c private ${hostname} ${control_oid} i ${cmd} +} + +while [ $# -gt 0 ] +do + key="$1" + + case $key in + -h|--help) + usage + exit 0 + ;; + --hostname) + hostname="$2" + shift + shift + ;; + --port) + port="$2" + shift + shift + ;; + --command) + command="$2" + shift + shift + ;; + --delay) + delay="$2" + shift + shift + ;; + *) + usage + exit 0 + ;; + esac +done + +if [ -z "${hostname}" ] || [ -z "${port}" ] || [ -z "${command}" ]; then + usage + exit 1 +fi +if [ "${command}" != "off" ] && [ ${command} != "on" ] && [ ${command} != "reboot" ]; then + usage + exit 1 +fi + +if [ "${command}" = "reboot" ]; then + send_command "off" + sleep ${delay} + send_command "on" +else + send_command ${command} +fi diff --git a/automated/linux/igt/igt-test.yaml b/automated/linux/igt/igt-test.yaml index e0bfbf7..4339561 100644 --- a/automated/linux/igt/igt-test.yaml +++ b/automated/linux/igt/igt-test.yaml @@ -27,7 +27,7 @@ run: steps: - cd ./automated/linux/igt # Check if Chamelium is available - - while [ ${CHAMELIUM_PING_RETRY} -gt 0 ]; do PC=`ping -c 2 ${CHAMELIUM_IP}|grep '100% packet loss'`||true; if [ -n "${PC}" ]; then ./control_chamelium.py ${CHAMELIUM_REBOOT_ARG}; sleep 30; (( CHAMELIUM_PING_RETRY-- )); else break; fi; done + - while [ ${CHAMELIUM_PING_RETRY} -gt 0 ]; do PC=`ping -c 2 ${CHAMELIUM_IP}|grep '100% packet loss'`||true; if [ -n "${PC}" ]; then ./control_chamelium.sh ${CHAMELIUM_REBOOT_ARG}; sleep 30; (( CHAMELIUM_PING_RETRY-- )); else break; fi; done - test ${CHAMELIUM_PING_RETRY} -gt 0 && lava-test-case "Ping-Chamelium" --result pass || lava-test-raise "Ping-Chamelium" - OPT="-d ${IGT_DIR} -t ${TEST_LIST}" # Check Chamelium uboot console status |