Provide the option to supply the CI table similar to other options, e.g. SN_FIELDS, etc.
Explanation of change starting @ line 226:
if not selection:
selection = ['host_name', 'fqdn', 'ip_address']
for k in selection:
if k in record:
if record[k] != '':
target = record[k]
The line if k in record: handles the case where a selection_order item/field is provided that does not exist in the table. e.g. the cmdb_ci_netgear table does not have a host_name field, which caused a KeyError:
Traceback (most recent call last):
File "now.py", line 339, in <module>
main(sys.argv)
File "now.py", line 334, in main
inventory.generate()
File "now.py", line 229, in generate
if record[k] != '':
KeyError: 'host_name'
Provide the option to supply the CI table similar to other options, e.g. SN_FIELDS, etc.
Explanation of change starting @ line 226:
The line
if k in record:
handles the case where a selection_order item/field is provided that does not exist in the table. e.g. thecmdb_ci_netgear
table does not have ahost_name
field, which caused a KeyError:Adding the
if k in record:
avoids the KeyError