From 0e177ab7d0e9f6030b3ac4f982fc5011267c6160 Mon Sep 17 00:00:00 2001 From: Biagio Manzari Date: Wed, 12 Jun 2024 16:10:10 +0200 Subject: [PATCH] [OCPQE-18591] - add hpecmd for hpe SoL support (#65) * add hpecmd for hpe SoL support * review --- images/fcos-bastion-image/root/usr/bin/hpecmd | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 images/fcos-bastion-image/root/usr/bin/hpecmd diff --git a/images/fcos-bastion-image/root/usr/bin/hpecmd b/images/fcos-bastion-image/root/usr/bin/hpecmd new file mode 100644 index 0000000..41505cb --- /dev/null +++ b/images/fcos-bastion-image/root/usr/bin/hpecmd @@ -0,0 +1,25 @@ +#!/bin/bash + +function cleanup() { + rm -f $p +} + +trap cleanup INT TERM + +if [ "${#}" -lt 1 ]; then + echo "Usage: ${0} " + exit 1 +fi + +host_id="${1}" +shift + +host_obj=$(sed 's/^#//' "/etc/hosts_pool_inventory" | yq -p csv '.[] | select(.bmc_address == "*'".${host_id}"'*")') + +user=$(echo "${host_obj}" | yq -r '.bmc_user') +password=$(echo "${host_obj}" | yq -r '.bmc_pass') +address=$(echo "${host_obj}" | yq -r '.bmc_address') +echo -n "${address}: " +p=$(mktemp) +echo "${password}" > $p +sshpass -f $p ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=1000 "${user}"@"${address}" "${@}"