cmd_args_parser.add_argument('--action',choices=['restart'],required=True,help='action to frr daemons')
cmd_args_parser.add_argument('--daemon',choices=['bfdd','bgpd','ospfd','ospf6d','ripd','ripngd','staticd','zebra'],required=False,nargs='*',help='select single or multiple daemons')
# parse arguments
cmd_args=cmd_args_parser.parse_args()
# main logic
# restart daemon
ifcmd_args.action=='restart':
ifnot_save_and_restore('save'):
logger.error("Failed to rename permanent comfig")
print("Failed to rename permanent comfig")
sys.exit(1)
ifnot_write_config():
print("Failed to save active config")
_save_and_restore('restore')
sys.exit(1)
ifcmd_args.daemon:
# check all daemons if they are running
ifnot_check_args_daemon(cmd_args.daemon):
print("Warning: some of listed daemons are not running")
# run command to restart daemon
fordaemonincmd_args.daemon:
ifnot_daemon_restart(daemon):
print("Failed to restart daemon: {}".format(daemon))