Get osTicket number and verify with name in ticket
This commit is contained in:
parent
58dead2382
commit
5edde45f0e
1 changed files with 51 additions and 14 deletions
|
|
@ -137,6 +137,22 @@ def get_graph_step(rate, scale=16):
|
||||||
break
|
break
|
||||||
return step
|
return step
|
||||||
|
|
||||||
|
def get_osticket_number():
|
||||||
|
"""Get ticket number and confirm with name from osTicket DB."""
|
||||||
|
ticket_number = None
|
||||||
|
while ticket_number is None:
|
||||||
|
print_standard(' ')
|
||||||
|
_input = input('Enter ticket number: ')
|
||||||
|
if not re.match(r'^([0-9]+)$', _input):
|
||||||
|
continue
|
||||||
|
_name = osticket_get_ticket_name(_input)
|
||||||
|
if _name:
|
||||||
|
print_standard('You have selected ticket #{} ({})'.format(
|
||||||
|
_input, _name))
|
||||||
|
if ask('Is this correct?'):
|
||||||
|
ticket_number = _input
|
||||||
|
return ticket_number
|
||||||
|
|
||||||
def get_read_rate(s):
|
def get_read_rate(s):
|
||||||
"""Get read rate in bytes/s from dd progress output."""
|
"""Get read rate in bytes/s from dd progress output."""
|
||||||
real_rate = None
|
real_rate = None
|
||||||
|
|
@ -226,10 +242,11 @@ def menu_diags(*args):
|
||||||
if selection.isnumeric():
|
if selection.isnumeric():
|
||||||
if diag_modes[int(selection)-1]['Name'] != 'Quick drive test':
|
if diag_modes[int(selection)-1]['Name'] != 'Quick drive test':
|
||||||
# Save log for non-quick tests
|
# Save log for non-quick tests
|
||||||
ticket_number = get_ticket_number()
|
ticket_number = get_osticket_number()
|
||||||
global_vars['LogDir'] = '{}/Logs/{}'.format(
|
global_vars['LogDir'] = '{}/Logs/{}_{}'.format(
|
||||||
global_vars['Env']['HOME'],
|
global_vars['Env']['HOME'],
|
||||||
ticket_number if ticket_number else global_vars['Date-Time'])
|
ticket_number,
|
||||||
|
global_vars['Date-Time'])
|
||||||
os.makedirs(global_vars['LogDir'], exist_ok=True)
|
os.makedirs(global_vars['LogDir'], exist_ok=True)
|
||||||
global_vars['LogFile'] = '{}/Hardware Diagnostics.log'.format(
|
global_vars['LogFile'] = '{}/Hardware Diagnostics.log'.format(
|
||||||
global_vars['LogDir'])
|
global_vars['LogDir'])
|
||||||
|
|
@ -255,6 +272,28 @@ def menu_diags(*args):
|
||||||
elif selection == 'Q':
|
elif selection == 'Q':
|
||||||
break
|
break
|
||||||
|
|
||||||
|
def osticket_get_ticket_name(ticket_id):
|
||||||
|
"""Lookup ticket and return name as str."""
|
||||||
|
ticket_name = 'Unknown'
|
||||||
|
if not ticket_id:
|
||||||
|
raise GenericError
|
||||||
|
if not ost_db['Cursor']:
|
||||||
|
# Skip section
|
||||||
|
return
|
||||||
|
|
||||||
|
# Set command
|
||||||
|
sql_cmd = "SELECT name FROM `ost_ticket` WHERE `ticket_id` = {}".format(
|
||||||
|
ticket_id)
|
||||||
|
|
||||||
|
# Run command
|
||||||
|
try:
|
||||||
|
ost_db['Cursor'].execute(sql_cmd)
|
||||||
|
for name in ost_db['Cursor']:
|
||||||
|
ticket_name = name[0]
|
||||||
|
return ticket_name
|
||||||
|
except:
|
||||||
|
ost_db['Errors'] = True
|
||||||
|
|
||||||
def osticket_needs_attention(ticket_id):
|
def osticket_needs_attention(ticket_id):
|
||||||
"""Marks the ticket as "NEEDS ATTENTION" in osTicket."""
|
"""Marks the ticket as "NEEDS ATTENTION" in osTicket."""
|
||||||
if not ticket_id:
|
if not ticket_id:
|
||||||
|
|
@ -273,7 +312,7 @@ def osticket_needs_attention(ticket_id):
|
||||||
try:
|
try:
|
||||||
ost_db['Cursor'].execute(sql_cmd)
|
ost_db['Cursor'].execute(sql_cmd)
|
||||||
except:
|
except:
|
||||||
sql_errors = True
|
ost_db['Errors'] = True
|
||||||
|
|
||||||
def osticket_reply(ticket_id, response):
|
def osticket_reply(ticket_id, response):
|
||||||
"""Post a reply to a ticket in osTicket."""
|
"""Post a reply to a ticket in osTicket."""
|
||||||
|
|
@ -296,7 +335,7 @@ def osticket_reply(ticket_id, response):
|
||||||
try:
|
try:
|
||||||
ost_db['Cursor'].execute(sql_cmd)
|
ost_db['Cursor'].execute(sql_cmd)
|
||||||
except:
|
except:
|
||||||
sql_errors = True
|
ost_db['Errors'] = True
|
||||||
|
|
||||||
def osticket_set_drive_result(ticket_id, passed):
|
def osticket_set_drive_result(ticket_id, passed):
|
||||||
"""Marks the pass/fail box for the drive(s) in osTicket."""
|
"""Marks the pass/fail box for the drive(s) in osTicket."""
|
||||||
|
|
@ -317,7 +356,7 @@ def osticket_set_drive_result(ticket_id, passed):
|
||||||
try:
|
try:
|
||||||
ost_db['Cursor'].execute(sql_cmd)
|
ost_db['Cursor'].execute(sql_cmd)
|
||||||
except:
|
except:
|
||||||
sql_errors = True
|
ost_db['Errors'] = True
|
||||||
|
|
||||||
def run_badblocks():
|
def run_badblocks():
|
||||||
"""Run a read-only test for all detected disks."""
|
"""Run a read-only test for all detected disks."""
|
||||||
|
|
@ -739,18 +778,16 @@ def run_tests(tests):
|
||||||
TESTS['NVMe/SMART']['Quick'] = 'Quick' in tests
|
TESTS['NVMe/SMART']['Quick'] = 'Quick' in tests
|
||||||
|
|
||||||
# Initialize
|
# Initialize
|
||||||
|
if not TESTS['NVMe/SMART']['Quick']:
|
||||||
|
print_standard(' ')
|
||||||
|
try_and_print(
|
||||||
|
message='Connecting to osTicket database...',
|
||||||
|
function=connect_to_db,
|
||||||
|
width=40)
|
||||||
if TESTS['NVMe/SMART']['Enabled'] or TESTS['badblocks']['Enabled'] or TESTS['iobenchmark']['Enabled']:
|
if TESTS['NVMe/SMART']['Enabled'] or TESTS['badblocks']['Enabled'] or TESTS['iobenchmark']['Enabled']:
|
||||||
if not TESTS['NVMe/SMART']['Quick']:
|
|
||||||
print_standard(' ')
|
|
||||||
try_and_print(
|
|
||||||
message='Connecting to osTicket database...',
|
|
||||||
function=connect_to_db,
|
|
||||||
width=40)
|
|
||||||
print_standard(' ')
|
print_standard(' ')
|
||||||
scan_disks()
|
scan_disks()
|
||||||
update_progress()
|
update_progress()
|
||||||
pause()
|
|
||||||
exit_script()
|
|
||||||
|
|
||||||
# Run
|
# Run
|
||||||
mprime_aborted = False
|
mprime_aborted = False
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue