From d089e0209dfcfb481050f1058191c2f75128f955 Mon Sep 17 00:00:00 2001 From: Tristan Smith Date: Thu, 21 Mar 2024 20:29:57 -0400 Subject: [PATCH] Refactor IPMI command execution in server.py --- server-test.py | 14 -------------- server.py | 6 +++++- 2 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 server-test.py diff --git a/server-test.py b/server-test.py deleted file mode 100644 index 7f52482..0000000 --- a/server-test.py +++ /dev/null @@ -1,14 +0,0 @@ -import subprocess - -# Server IPMI details -IPMIHOST = "192.168.1.223" -IPMIUSER = "root" -IPMIPASS = "" - -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) diff --git a/server.py b/server.py index 671b7a8..0f3aaeb 100644 --- a/server.py +++ b/server.py @@ -8,7 +8,11 @@ IPMIPASS = "" 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...")