Created
August 10, 2015 15:57
-
-
Save moali87/c5586c621065f3626b02 to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/env python | |
| import subprocess | |
| def get_ipmi_ip(): | |
| grains = {} | |
| grains['ipmi_ip'] = True | |
| ipmiIpString = ('/usr/bin/ipmitool', 'lan', 'print', '1') #This will print out the full ipmitool lan print, not just the IP unfortunately | |
| #['/usr/bin/ipmitool', 'lan', 'print', '|', 'awk', '"/IP Address /', '{ print $4 }"'] | |
| #"/usr/bin/ipmitool lan print | awk '/IP Address / { print $4 }'" | |
| process = subprocess.Popen((ipmiIpString), stdout=subprocess.PIPE) | |
| output = subprocess.check_output(('grep', 'IP Address'), stdin=process.stdout) | |
| outputFormat1 = output.strip('\n').split(':') | |
| outputFormat2 = outputFormat1[2].strip(" ") | |
| grains['ipmi_ip'] = outputFormat2 | |
| return grains |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment