Delphine CC Chiu | 256db82 | 2023-06-29 14:57:56 +0800 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # Power off the hosts when fan sensors crossed thresholds. |
| 3 | |
| 4 | echo "Power off the hosts if fansensors threshold crossed ::" |
| 5 | |
| 6 | DBUS_SERVICE="xyz.openbmc_project.State.Chassis" |
| 7 | DBUS_OBJECT="/xyz/openbmc_project/state/chassis" |
| 8 | DBUS_INTERFACE="xyz.openbmc_project.State.Chassis" |
| 9 | DBUS_PROPERTY="RequestedPowerTransition" |
| 10 | PROPERTY_VALUE="xyz.openbmc_project.State.Chassis.Transition.Off" |
| 11 | |
| 12 | # Power off the hosts. |
| 13 | power-off-all-hosts() |
| 14 | { |
| 15 | for host_id in ${HOST_INSTANCES_SED_REPLACEMENT_VALUE} |
| 16 | do |
| 17 | echo "chosen host id :::$host_id" |
| 18 | |
| 19 | # host power off |
| 20 | output=$(busctl set-property $DBUS_SERVICE"$host_id" $DBUS_OBJECT"$host_id" \ |
| 21 | $DBUS_INTERFACE $DBUS_PROPERTY s $PROPERTY_VALUE) |
| 22 | echo "$output" |
| 23 | |
| 24 | done |
| 25 | } |
| 26 | |
| 27 | power-off-all-hosts |