diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 144f6698..39551a56 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -1215,8 +1215,12 @@ def run_hw_tests(state): v['Objects'][-1].update_status('N/A') if k == TESTS_CPU[-1]: # Last CPU test run, post CPU results + cpu_failed = False + for test in state.cpu.tests.values(): + cpu_failed = cpu_failed or test.failed + color_code = 'Diags FAIL' if cpu_failed else 'Diags' state.ost.post_device_results( - state.cpu, state.ticket_id, state.ticket_name) + state.cpu, state.ticket_id, state.ticket_name, color_code) # Recheck attributes if state.tests['NVMe / SMART']['Enabled']: for test_obj in state.tests['NVMe / SMART']['Objects']: @@ -1251,8 +1255,15 @@ def run_hw_tests(state): if _disk_tests_enabled and state.disks and not state.ost.disabled: print_standard('Posting results to osTicket...') for disk in state.disks: + # Set color code + color_code = 'Diags' + for test in disk.tests.values(): + if test.disabled: + continue + if test.failed or not (test.passed or 'N/A' in test.status): + color_code = 'Diags FAIL' state.ost.post_device_results( - disk, state.ticket_id, state.ticket_name) + disk, state.ticket_id, state.ticket_name, color_code) # Check if disk checkbox needs updating all_disks_passed = True diff --git a/.bin/Scripts/functions/osticket.py b/.bin/Scripts/functions/osticket.py index 7164ccd6..3c2981be 100644 --- a/.bin/Scripts/functions/osticket.py +++ b/.bin/Scripts/functions/osticket.py @@ -502,15 +502,15 @@ class osTicket(): # Done return data - def post_device_results(self, dev, ticket_id, ticket_name): + def post_device_results(self, dev, ticket_id, ticket_name, color='Diags'): """Generate osTicket friendly report and post as response to ticket.""" if not dev.tests: # No test results available, aborting post return response = self.generate_report(dev, ticket_id, ticket_name) - self.post_response(response, ticket_id) + self.post_response(response, ticket_id, color) - def post_response(self, response, ticket_id): + def post_response(self, response, ticket_id, color='Normal'): """Post a reply to a ticket in osTicket.""" self.connect() @@ -525,12 +525,13 @@ class osTicket(): # Build SQL cmd sql_cmd = "INSERT INTO `{Name}`.`{Response}`".format( **OSTICKET['Database'], **OSTICKET['Tables']) - sql_cmd += " (ticket_id, staff_id, staff_name, response, created)" + sql_cmd += " (ticket_id, staff_id, staff_name, response, created, code)" sql_cmd += " VALUES (" sql_cmd += " '{}',".format(ticket_id) sql_cmd += " '{ID}', '{Name}',".format(**OSTICKET['Staff']) sql_cmd += " '{}',".format(response.replace("'", "\\'")) - sql_cmd += " '{}'".format(time.strftime("%Y-%m-%d %H:%M:%S")) + sql_cmd += " '{}',".format(time.strftime("%Y-%m-%d %H:%M:%S")) + sql_cmd += " '{}'".format(OSTICKET['Color Codes'][color]) sql_cmd += " );" # Run SQL cmd diff --git a/.bin/Scripts/settings/osticket.py b/.bin/Scripts/settings/osticket.py index dc30ced3..66a360f0 100644 --- a/.bin/Scripts/settings/osticket.py +++ b/.bin/Scripts/settings/osticket.py @@ -1,6 +1,12 @@ # Wizard Kit: Settings - osTicket OSTICKET = { + 'Color Codes': { + 'Normal': '0', + 'Contact': '1', + 'Diags': '2', + 'Diags FAIL': '3', + }, 'Database': { 'Name': 'osticket', 'User': 'wizardkit',