summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Wilson <wilsonan@us.ibm.com>2018-09-13 13:48:52 -0500
committerAnthony Wilson <wilsonan@us.ibm.com>2018-10-23 10:40:31 -0500
commit79f697e02c64c5a4ce17af36d7d251cd99d7b274 (patch)
tree5896b39630d47514ff9472a6af301b2eb1426635
parentd998f82bda2f1f28f1a7a5db58025f1c575c5261 (diff)
downloadphosphor-state-manager-79f697e02c64c5a4ce17af36d7d251cd99d7b274.tar.gz
phosphor-state-manager-79f697e02c64c5a4ce17af36d7d251cd99d7b274.zip
obmcutil: Rewrite in sh and move to phosphor-state-manager
Due to space, security, and performance concerns obmcutil is being converted to shell script. Have implemented the basic state interface queries (bmc, chassis, and host). Moved to phosphor-state-manager repo as this tool mostly deals with setting and querying state interfaces. Change-Id: Ib42da06a45e386dd1cc150ac85b638bdf87bdb9d Signed-off-by: Anthony Wilson <wilsonan@us.ibm.com>
-rw-r--r--obmcutil61
1 files changed, 61 insertions, 0 deletions
diff --git a/obmcutil b/obmcutil
new file mode 100644
index 0000000..65ca763
--- /dev/null
+++ b/obmcutil
@@ -0,0 +1,61 @@
+#!/bin/sh -e
+
+set -euo pipefail
+
+USAGE="Usage: obmcutil {bmcstate,chassisstate,hoststate,state,status}"
+
+INTERFACE_ROOT=xyz.openbmc_project
+STATE_INTERFACE=$INTERFACE_ROOT.State
+
+OBJECT_ROOT=/xyz/openbmc_project
+STATE_OBJECT=$OBJECT_ROOT/state
+
+get_property ()
+{
+ busctl get-property "$@"
+}
+
+state_query ()
+{
+ local state=$(get_property "$@" | cut -d '"' -f2)
+ printf "%-20s: %s\n" $4 $state
+}
+
+handle_cmd ()
+{
+ case "$1" in
+ bmcstate)
+ OBJECT=$STATE_OBJECT/bmc0
+ SERVICE=$(mapper get-service $OBJECT)
+ INTERFACE=$STATE_INTERFACE.BMC
+ PROPERTY=CurrentBMCState
+ state_query $SERVICE $OBJECT $INTERFACE $PROPERTY
+ ;;
+ chassisstate)
+ OBJECT=$STATE_OBJECT/chassis0
+ SERVICE=$(mapper get-service $OBJECT)
+ INTERFACE=$STATE_INTERFACE.Chassis
+ PROPERTY=CurrentPowerState
+ state_query $SERVICE $OBJECT $INTERFACE $PROPERTY
+ ;;
+ hoststate)
+ OBJECT=$STATE_OBJECT/host0
+ SERVICE=$(mapper get-service $OBJECT)
+ INTERFACE=$STATE_INTERFACE.Host
+ PROPERTY=CurrentHostState
+ state_query $SERVICE $OBJECT $INTERFACE $PROPERTY
+ ;;
+ state|status)
+ for query in bmcstate chassisstate hoststate
+ do
+ handle_cmd $query
+ done
+ ;;
+ *)
+ echo "ERROR: Invalid Choice: '$1'"
+ echo "$USAGE"
+ ;;
+ esac
+}
+
+handle_cmd $1
OpenPOWER on IntegriCloud