From 6e97937d540bf724b894aea0d9cdfb2802273720 Mon Sep 17 00:00:00 2001 From: Andrei Kartashev Date: Thu, 25 Mar 2021 21:21:28 +0300 Subject: [PATCH] vegman: add a way to configure PSU Redundancy Add command for tech to change PSU Redundancy settings End-User-Impact: new command for tech user: bmc psuredundancy enable|disable Signed-off-by: Andrei Kartashev --- commands/bmc.vegman | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/commands/bmc.vegman b/commands/bmc.vegman index b2e2c4d..b44e55b 100755 --- a/commands/bmc.vegman +++ b/commands/bmc.vegman @@ -12,6 +12,9 @@ SETTINGS_SERVICE="xyz.openbmc_project.Settings" TIMESYNC_METHOD_PATH="/xyz/openbmc_project/time/sync_method" TIMESYNC_METHOD_IFACE="xyz.openbmc_project.Time.Synchronization" TIMESYNC_METHOD_PROPERTY="TimeSyncMethod" +PSU_REDUNDANCY_OBJECT="/xyz/openbmc_project/control/power_supply_redundancy" +PSU_REDUNDANCY_IFACE="xyz.openbmc_project.Control.PowerSupplyRedundancy" +PSU_REDUNDANCY_PROPERTY="PowerSupplyRedundancyEnabled" SYSLOG_CONFIG_SERVICE="xyz.openbmc_project.Syslog.Config" SYSLOG_CONFIG_PATH="/xyz/openbmc_project/logging/config/remote" @@ -483,3 +486,50 @@ function cmd_remoteimage_disconnect { nbd-client -d "${nbd_device}" } + +# @sudo cmd_psuredundancy admin +# @restrict cmd_psuredundancy admin +# @doc cmd_psuredundancy +# Control Power Supply Redundancy behaviour +# enable +# disable +# show +function cmd_psuredundancy { + if [[ $# -le 0 ]]; then + print_help cmd_psuredundancy + return 1 + fi + local action="show" + while [[ $# -gt 0 ]]; do + case "$1" in + enable|disable|show) + action="$1" + ;; + *) abort_badarg "$1";; + esac + shift + done + + if [ "${action}" == show ]; then + if busctl get-property ${SETTINGS_SERVICE} \ + ${PSU_REDUNDANCY_OBJECT} \ + ${PSU_REDUNDANCY_IFACE} \ + ${PSU_REDUNDANCY_PROPERTY} | grep -q true + then + echo "Enabled" + else + echo "Disabled" + fi + elif [ "${action}" == enable ]; then + busctl set-property ${SETTINGS_SERVICE} \ + ${PSU_REDUNDANCY_OBJECT} \ + ${PSU_REDUNDANCY_IFACE} \ + ${PSU_REDUNDANCY_PROPERTY} b true + elif [ "${action}" == disable ]; then + busctl set-property ${SETTINGS_SERVICE} \ + ${PSU_REDUNDANCY_OBJECT} \ + ${PSU_REDUNDANCY_IFACE} \ + ${PSU_REDUNDANCY_PROPERTY} b false + fi + +}