if not ask_yes_no('WARNING: This is a potentially unsafe function!\n' \
'You may lose the connection to the router or active configuration after\n' \
'running this command. Use it at your own risk!\n\n'
'Continue?'):
return False
# check if another restart process already running
if len([process for process in psutil.process_iter(attrs=['pid', 'name', 'cmdline']) if 'python' in process.info['name'] and 'restart_frr.py' in process.info['cmdline'][1]]) > 1:
message = 'Another restart_frr.py process is already running!'
logger.error(message)
if not ask_yes_no(f'\n{message} It is unsafe to continue.\n\n' \
'Do you want to process anyway?'):
return False
# check if watchfrr.sh is running
tmp = os.path.basename(watchfrr)
if process_named_running(tmp):
message = f'Another {tmp} process is already running.'
logger.error(message)
if not ask_yes_no(f'{message} It is unsafe to continue.\n\n' \
'Do you want to process anyway?'):
return False
# check if vtysh is running
if process_named_running('vtysh'):
message = 'vtysh process is executed by another task.'
logger.error(message)
if not ask_yes_no(f'{message} It is unsafe to continue.\n\n' \