parent
a868d28452
commit
0077240255
3 changed files with 25 additions and 7 deletions
|
|
@ -1215,8 +1215,12 @@ def run_hw_tests(state):
|
||||||
v['Objects'][-1].update_status('N/A')
|
v['Objects'][-1].update_status('N/A')
|
||||||
if k == TESTS_CPU[-1]:
|
if k == TESTS_CPU[-1]:
|
||||||
# Last CPU test run, post CPU results
|
# 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.ost.post_device_results(
|
||||||
state.cpu, state.ticket_id, state.ticket_name)
|
state.cpu, state.ticket_id, state.ticket_name, color_code)
|
||||||
# Recheck attributes
|
# Recheck attributes
|
||||||
if state.tests['NVMe / SMART']['Enabled']:
|
if state.tests['NVMe / SMART']['Enabled']:
|
||||||
for test_obj in state.tests['NVMe / SMART']['Objects']:
|
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:
|
if _disk_tests_enabled and state.disks and not state.ost.disabled:
|
||||||
print_standard('Posting results to osTicket...')
|
print_standard('Posting results to osTicket...')
|
||||||
for disk in state.disks:
|
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(
|
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
|
# Check if disk checkbox needs updating
|
||||||
all_disks_passed = True
|
all_disks_passed = True
|
||||||
|
|
|
||||||
|
|
@ -502,15 +502,15 @@ class osTicket():
|
||||||
# Done
|
# Done
|
||||||
return data
|
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."""
|
"""Generate osTicket friendly report and post as response to ticket."""
|
||||||
if not dev.tests:
|
if not dev.tests:
|
||||||
# No test results available, aborting post
|
# No test results available, aborting post
|
||||||
return
|
return
|
||||||
response = self.generate_report(dev, ticket_id, ticket_name)
|
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."""
|
"""Post a reply to a ticket in osTicket."""
|
||||||
self.connect()
|
self.connect()
|
||||||
|
|
||||||
|
|
@ -525,12 +525,13 @@ class osTicket():
|
||||||
# Build SQL cmd
|
# Build SQL cmd
|
||||||
sql_cmd = "INSERT INTO `{Name}`.`{Response}`".format(
|
sql_cmd = "INSERT INTO `{Name}`.`{Response}`".format(
|
||||||
**OSTICKET['Database'], **OSTICKET['Tables'])
|
**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 += " VALUES ("
|
||||||
sql_cmd += " '{}',".format(ticket_id)
|
sql_cmd += " '{}',".format(ticket_id)
|
||||||
sql_cmd += " '{ID}', '{Name}',".format(**OSTICKET['Staff'])
|
sql_cmd += " '{ID}', '{Name}',".format(**OSTICKET['Staff'])
|
||||||
sql_cmd += " '{}',".format(response.replace("'", "\\'"))
|
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 += " );"
|
sql_cmd += " );"
|
||||||
|
|
||||||
# Run SQL cmd
|
# Run SQL cmd
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
# Wizard Kit: Settings - osTicket
|
# Wizard Kit: Settings - osTicket
|
||||||
|
|
||||||
OSTICKET = {
|
OSTICKET = {
|
||||||
|
'Color Codes': {
|
||||||
|
'Normal': '0',
|
||||||
|
'Contact': '1',
|
||||||
|
'Diags': '2',
|
||||||
|
'Diags FAIL': '3',
|
||||||
|
},
|
||||||
'Database': {
|
'Database': {
|
||||||
'Name': 'osticket',
|
'Name': 'osticket',
|
||||||
'User': 'wizardkit',
|
'User': 'wizardkit',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue