-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathac.py
More file actions
36 lines (32 loc) · 969 Bytes
/
ac.py
File metadata and controls
36 lines (32 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import lib.ssh_util
import time
import lib.bmc_boot_utils as bbu
import argparse
import sys
def ac(ssh, target):
_, stdout, _ = ssh.exec_command("mfg-tool power-control -p 0 -s standby -a cycle")
output = stdout.read().decode()
print(output)
time.sleep(10)
if not bbu.wait_bmc_reboot_connection(target, timeout=600):
print("BMC reboot failed.")
sys.exit(1)
print("BMC reboot success.")
def main(ip):
target = {
"ip": ip,
"port": 22,
"username": "root",
"password": "0penBmc"
}
connected, ssh = lib.ssh_util.get_ssh_session(target)
if not connected:
print(f"Failed to connect to BMC")
sys.exit(1)
print(f"Connected")
ac(ssh, target)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-ip", help="Target BMC IP address", default="10.10.14.94") # Default IP set here
args = parser.parse_args()
main(args.ip)