Refactor IPMI command execution in server.py

This commit is contained in:
Tristan Smith 2024-03-21 20:29:57 -04:00
parent 686739eda4
commit d089e0209d
2 changed files with 5 additions and 15 deletions

View file

@ -1,14 +0,0 @@
import subprocess
# Server IPMI details
IPMIHOST = "192.168.1.223"
IPMIUSER = "root"
IPMIPASS = "<password>"
def execute_ipmi_command(command):
full_command = f"ipmitool -I lanplus -H {IPMIHOST} -U {IPMIUSER} -P {IPMIPASS} {command}"
print(f"Executing command: {full_command}") # Print the full command to debug
result = subprocess.run(full_command, shell=True, capture_output=True, text=True)
print(result.stdout)
if result.stderr:
print(result.stderr)

View file

@ -8,7 +8,11 @@ IPMIPASS = "<password>"
def execute_ipmi_command(command):
full_command = f"ipmitool -I lanplus -H {IPMIHOST} -U {IPMIUSER} -P {IPMIPASS} {command}"
subprocess.run(full_command, shell=True)
print(f"Executing command: {full_command}") # Print the full command to debug
result = subprocess.run(full_command, shell=True, capture_output=True, text=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
def power_on():
print("Powering on the server...")