Files
utilities/personal/cron_scripts/power/ipmi_poweroff.py
T
wjones 95f132bdf8 Add scripts for managing VM and LXC container power states and fan control
- Implemented set_fanspeed.py for dynamic fan speed control based on temperature.
- Created ilo_poweroff.py and ilo_poweron.py for iLO power management.
- Added ipmi_poweroff.py and ipmi_poweron.py for IPMI power control.
- Developed vm_start.py, vm_stop.py, vm_restart.py, and vm_shutdown.py for VM and LXC management.
- Introduced wrapper scripts (start_wrapper.sh, stop_wrapper.sh) for simplified execution.
- Removed deprecated shell scripts for power control.
2025-10-06 10:10:54 -04:00

32 lines
825 B
Python

#!/usr/bin/env python3
import argparse
import subprocess
import sys
IPMIUSER = "<username>"
IPMIPW = "<password>"
IPMIEK = "0000000000000000000000000000000000000000"
def main():
p = argparse.ArgumentParser(description="Send IPMI power off")
p.add_argument("-H", "--host", required=True, help="IPMI host address")
args = p.parse_args()
cmd = [
"ipmitool",
"-I", "lanplus",
"-H", args.host,
"-U", IPMIUSER,
"-P", IPMIPW,
"-y", IPMIEK,
"power", "off",
]
proc = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
if proc.returncode != 0:
print("ipmitool failed:", proc.stderr.strip(), file=sys.stderr)
sys.exit(proc.returncode)
print(proc.stdout.strip())
if __name__ == "__main__":
main()