Created
August 24, 2020 15:20
-
-
Save noslin005/c2e8790e6900a9057716171e41e77dfd to your computer and use it in GitHub Desktop.
subprocess ipmitool.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Design/test time saver.. thank you!