| 1234567891011121314151617181920212223242526 |
- #!/usr/bin/env python3
- """Minimal BMC host-only power check; never cycles BMC power."""
- import argparse
- import os
- import subprocess
- def main():
- parser = argparse.ArgumentParser()
- parser.add_argument("--action", choices=("status", "off"), required=True)
- args = parser.parse_args()
- password = os.environ.get("STL_BMC_S1_PASSWORD", "")
- if not password:
- raise SystemExit("BMC password environment is not configured")
- env = {**os.environ, "IPMI_PASSWORD": password}
- command = ["ipmitool", "-I", "lanplus", "-C", "17", "-H", "192.168.0.100",
- "-U", "ADMIN", "-E", "chassis", "power", args.action]
- result = subprocess.run(command, env=env, text=True, capture_output=True, timeout=25, check=False)
- print(result.stdout.strip())
- if result.stderr.strip():
- print(result.stderr.strip())
- return result.returncode
- if __name__ == "__main__":
- raise SystemExit(main())
|