From acb0090159d088e816ee97fa10bb74d5d2da562c Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Tue, 25 May 2021 16:10:09 +0200 Subject: [bas-python] Add optional contact information argument (first-/lastname) --- modules.d/bas-python/scripts/collect_hw_info_json.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules.d/bas-python/scripts/collect_hw_info_json.py b/modules.d/bas-python/scripts/collect_hw_info_json.py index 5341279a..d52a9ad2 100755 --- a/modules.d/bas-python/scripts/collect_hw_info_json.py +++ b/modules.d/bas-python/scripts/collect_hw_info_json.py @@ -188,6 +188,18 @@ def prepare_location(parent, rack, bay, slot): location['slot'] = slot return location +def prepare_contacts(contact_list): + contacts = [] + if contact_list == None: + return contacts + print(str(contact_list)) + for contact in contact_list: + contacts.append({ + 'firstname': contact[0], + 'lastname': contact[1], + }) + return contacts + def send_post(url, payload): headers = { 'Content-type': 'application/json', 'Accept': 'text/plain' } # req = requests.post(url, json=payload, headers=headers) @@ -207,6 +219,7 @@ def main(): parser.add_argument('-s', '--slot', action='store', help='') parser.add_argument('-b', '--bay', action='store', help='') parser.add_argument('-l', '--location', action='store', help=': Roomname where the client is located') + parser.add_argument('-c', '--contact', action='append', help=': of the person responsible for this machine', nargs=2) args = parser.parse_args() if args.debug: @@ -223,6 +236,7 @@ def main(): _collecthw['lshw'] = get_lshw() _collecthw['net'] = get_net_fallback() _collecthw['location'] = prepare_location(args.location, args.rack, args.bay, args.slot) + _collecthw['contacts'] = prepare_contacts(args.contact) collecthw_json = json.dumps(_collecthw) if (args.url): -- cgit v1.2.3-55-g7522