From 739ef184cc0a1fd4105053db9bfb4a8bc2f3d39a Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Mon, 6 Apr 2020 21:59:14 +0200 Subject: [PATCH] ci/bare-metal: add support for eth008 power relay Signed-off-by: Christian Gmeiner Acked-by: Daniel Stone Reviewed-by: Emma Anholt Part-of: --- .gitlab-ci/bare-metal/eth008-power-down.sh | 10 ++++++++ .gitlab-ci/bare-metal/eth008-power-relay.py | 28 +++++++++++++++++++++ .gitlab-ci/bare-metal/eth008-power-up.sh | 12 +++++++++ 3 files changed, 50 insertions(+) create mode 100755 .gitlab-ci/bare-metal/eth008-power-down.sh create mode 100755 .gitlab-ci/bare-metal/eth008-power-relay.py create mode 100755 .gitlab-ci/bare-metal/eth008-power-up.sh diff --git a/.gitlab-ci/bare-metal/eth008-power-down.sh b/.gitlab-ci/bare-metal/eth008-power-down.sh new file mode 100755 index 00000000000..8a270bd2c6f --- /dev/null +++ b/.gitlab-ci/bare-metal/eth008-power-down.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +relay=$1 + +if [ -z "$relay" ]; then + echo "Must supply a relay arg" + exit 1 +fi + +$CI_PROJECT_DIR/install/bare-metal/eth008-power-relay.py $ETH_HOST $ETH_PORT off $relay diff --git a/.gitlab-ci/bare-metal/eth008-power-relay.py b/.gitlab-ci/bare-metal/eth008-power-relay.py new file mode 100755 index 00000000000..589ea5dd6f4 --- /dev/null +++ b/.gitlab-ci/bare-metal/eth008-power-relay.py @@ -0,0 +1,28 @@ +#!/usr/bin/python3 + +import sys +import socket + +host = sys.argv[1] +port = sys.argv[2] +mode = sys.argv[3] +relay = sys.argv[4] +msg = None + +if mode == "on": + msg = b'\x20' +else: + msg = b'\x21' + +msg += int(relay).to_bytes(1, 'big') +msg += b'\x00' + +c = socket.create_connection((host, int(port))) +c.sendall(msg) + +data = c.recv(1) +c.close() + +if data[0] == b'\x01': + print('Command failed') + sys.exit(1) diff --git a/.gitlab-ci/bare-metal/eth008-power-up.sh b/.gitlab-ci/bare-metal/eth008-power-up.sh new file mode 100755 index 00000000000..2d1071bb6f3 --- /dev/null +++ b/.gitlab-ci/bare-metal/eth008-power-up.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +relay=$1 + +if [ -z "$relay" ]; then + echo "Must supply a relay arg" + exit 1 +fi + +$CI_PROJECT_DIR/install/bare-metal/eth008-power-relay.py $ETH_HOST $ETH_PORT off $relay +sleep 5 +$CI_PROJECT_DIR/install/bare-metal/eth008-power-relay.py $ETH_HOST $ETH_PORT on $relay