Skip to content

Instantly share code, notes, and snippets.

@noslin005
Created August 24, 2020 15:20
Show Gist options
  • Save noslin005/c2e8790e6900a9057716171e41e77dfd to your computer and use it in GitHub Desktop.
Save noslin005/c2e8790e6900a9057716171e41e77dfd to your computer and use it in GitHub Desktop.
subprocess ipmitool.py
def ____run(self, command):
procs = {}
for node in self.nodes:
ip = node['ip']
user = node['user']
password = node['password']
cmd = f'ipmitool -H {ip} -U {user} -P {password} {command}'
procs[ip] = subprocess.Popen(cmd,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True)
while procs:
for ip, proc in procs.items():
if proc.poll() is not None: # command finished
del procs[ip]
if proc.returncode == 0:
print(f"{ip}\t: SUCCESS ")
else:
print(f"{ip}\t: FAIL ({proc.stdout})")
break
@mlarivie
Copy link

mlarivie commented Feb 8, 2022

Design/test time saver.. thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment