diff options
author | Jeff Lane <jeffrey.lane@canonical.com> | 2014-08-06 14:50:34 -0400 |
---|---|---|
committer | Jeff Lane <jeffrey.lane@canonical.com> | 2014-08-06 14:50:34 -0400 |
commit | 86b4ce734361395ebc33bb7e7cc1449828cc4cba (patch) | |
tree | ec04023494df9ebdf6e85b65004400df20e2dc39 | |
parent | 4544bbe63e45dc4f1e7531d89b9dbed08d4fa796 (diff) |
p-p-checkbox: added new script bmc_info and added job description for bmc_info to miscellanea.txt.in. p-p-c-server: added new job to full and functional whitelists.
-rwxr-xr-x | bin/bmc_info | 60 | ||||
-rw-r--r-- | jobs/miscellanea.txt.in | 9 |
2 files changed, 69 insertions, 0 deletions
diff --git a/bin/bmc_info b/bin/bmc_info new file mode 100755 index 0000000..f84d14b --- /dev/null +++ b/bin/bmc_info @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 + +import sys +import shlex +from subprocess import check_output, CalledProcessError + +def main(): + # First, we need to get output + cmd = "ipmitool mc info" + try: + result = check_output(shlex.split(cmd), universal_newlines=True) + except FileNotFoundError: + print("ipmitool was not found! Please install it and try again.", + file=sys.stderr) + except: + print("ipmitool command returned an unknown error. Please try running %s " + "manually to debug this problem." % cmd) + result = result.split('\n') + + # We need some bits that are formatted oddly so we need to do some parsing + data = {} + for line in result: + if ':' in line: + key = line.split(':')[0].strip() + value = line.split(':')[1].strip() + data[key] = value + last = (key, [value]) + else: + # since the last line we matched had a ':', it's key is likely the + # key for the next few lines that don't have a ':' + # This should keep adding items to our last key's list until we hit + # another line with a :, and we start the cycle over again. + last[1].append(line.strip()) + data[last[0]] = last[1] + + # Now print out what we care about: + we_care_about = ['Manufacturer Name', + 'Manufacturer ID', + 'Product Name', + 'Product ID', + 'Firmware Revision', + 'IPMI Version', + 'Additional Device Support'] + + for field in we_care_about: + if type(data[field]) is list: + # Sometimes the first item in the list is ''. This will remove it + data[field].remove('') + print(field.ljust(30),':',data[field].pop(0)) + for item in data[field]: + print(' '.ljust(32),item) + else: + print(field.ljust(30),":",data[field]) + #print("{}:\t{}".format(field, data[field])) + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/jobs/miscellanea.txt.in b/jobs/miscellanea.txt.in index 8cd4e90..7a0fbe9 100644 --- a/jobs/miscellanea.txt.in +++ b/jobs/miscellanea.txt.in @@ -71,6 +71,15 @@ _description: This will run some basic connectivity tests against a BMC, verifying that IPMI works. plugin: shell +id: miscellanea/bmc_info +requires: package.name == 'ipmitool' +estimated_duration: 0.5 +user: root +command: bmc_info +_description: + This will gather some info about the BMC itself for diagnostic purposes. + +plugin: shell id: miscellanea/is_laptop user: root _description: |