Skip to content

Commit

Permalink
Merge pull request #165 from vivekkumac/ca-111135
Browse files Browse the repository at this point in the history
Adding info from python-hwinfo
  • Loading branch information
vivekkumac authored May 17, 2017
2 parents 3c60e9f + 4236122 commit 504e81f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
27 changes: 22 additions & 5 deletions autocertkit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def log_basic_info(session):
log.info("Auto Cert Kit Version: %s" % get_ack_version(session))
log.info("Host Software Version: %s" % get_xs_info(session))
log.info("Kernel Version : %s" % get_kernel_version(session))
log.info("Host Hardware Devices:\n%s" % get_system_info_tabular(session))


def init_ack_logging(session, rotate=True):
Expand Down Expand Up @@ -1847,7 +1848,7 @@ def process_values(item):
return [data] if isinstance(data, dict) else data


def call_ack_plugin(session, method, args={}, host=None):
def call_ack_plugin(session, method, args={}, host=None, noJsonHook=False):
if not host:
host = get_pool_master(session)
log.debug("About to call plugin '%s' on host '%s' with args '%s'" %
Expand All @@ -1859,7 +1860,7 @@ def call_ack_plugin(session, method, args={}, host=None):
args)
log.debug("Plugin Output: %s" % (
"%s[...check plugin log for more]" % res[:1000] if res and len(res) > 1000 else res))
return json_loads(res) if res else None
return (json.loads(res) if noJsonHook else json_loads(res)) if res else None


def get_hw_offloads(session, device):
Expand Down Expand Up @@ -1961,10 +1962,26 @@ def check_test_thread_status(threads):
return False


def get_system_info_hwinfo(session):
return call_ack_plugin(session, 'get_system_info_hwinfo', noJsonHook=True)


def get_system_info_tabular(session):
return call_ack_plugin(session, 'get_system_info_tabular')


def get_master_network_devices(session):
devices = call_ack_plugin(session, 'get_network_devices')
log.debug("Network Devices found on machine: '%s'" % devices)
return devices
nics = call_ack_plugin(session, 'get_network_devices')
log.debug("Network Devices found on machine(Plugin): '%s'" % nics)
hwinfo_devs = get_system_info_hwinfo(session)
if hwinfo_devs:
nics_hw = hwinfo_devs['nics']
log.debug("Network Devices found on machine(hwinfo): '%s'" % nics_hw)
for n in nics:
for nh in nics_hw:
if n['PCI_name'] == "0000:%s" % nh['device_bus_id']:
n.update(nh)
return nics


def get_local_storage_info(session):
Expand Down
19 changes: 19 additions & 0 deletions plugins/autocertkit
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import base64
import tarfile
import datetime
import json
import hwinfo.tools.inspector as inspector

from acktools.net import route
import acktools.log
Expand Down Expand Up @@ -1948,6 +1949,22 @@ def get_dmidecode_output(session, args):
return json_dumps(make_local_call(['dmidecode'])["stdout"])


@log_exceptions
def get_system_info_hwinfo(session, args):
"""Returns device dict reported by hwinfo"""
host = inspector.Host()
options = ['bios', 'nic', 'storage', 'gpu', 'cpu']
return inspector.export_system_info(host, options)


@log_exceptions
def get_system_info_tabular(session, args):
"""Get Hardware information reported by hwinfo in tabular form"""
host = inspector.Host()
options = ['bios', 'nic', 'storage', 'gpu', 'cpu']
return json_dumps(inspector.system_info(host, options))


#####################################################

if __name__ == '__main__':
Expand All @@ -1971,6 +1988,8 @@ if __name__ == '__main__':
'retrieve_bonnie_logs': retrieve_bonnie_logs,
'get_network_devices': get_network_devices,
'get_local_storage_devices': get_local_storage_devices,
'get_system_info_hwinfo': get_system_info_hwinfo,
'get_system_info_tabular': get_system_info_tabular,
'get_iface_stats': get_iface_stats,
'get_host_routes': get_host_routes,
'set_nic_device_status': set_nic_device_status,
Expand Down

0 comments on commit 504e81f

Please sign in to comment.