Applications
Use the Paho MQTT python library
IX14 User Guide
494
POLL_TIME = 60
def cmd_reboot(params):
print("Rebooting unit...")
try:
cli.execute("reboot", 10)
except:
print("Failed to run 'reboot' command")
return HTTPStatus.INTERNAL_SERVER_ERROR
return HTTPStatus.OK
def cmd_fwupdate(params):
try:
fw_uri = params["uri"]
except:
print("Firmware file URI not passed")
return HTTPStatus.BAD_REQUEST
print("Request to update firmware with URI: {}".format(fw_uri))
try:
fd, fname = tempfile.mkstemp()
os.close(fd)
try:
urllib.request.urlretrieve(fw_uri, fname)
except:
print("Failed to download FW file from URI {}".format(fw_uri))
return HTTPStatus.NOT_FOUND
try:
ret = cli.execute("system firmware update file " + fname, 60)
except:
print("Failed to run firmware update command")
return HTTPStatus.INTERNAL_SERVER_ERROR
if not "Firmware update completed" in ret:
print("Failed to update firmware")
return HTTPStatus.INTERNAL_SERVER_ERROR
finally:
os.remove(fname)
print("Firmware update finished")
return HTTPStatus.OK
CMD_HANDLERS = {
"reboot": cmd_reboot,
"fw-update": cmd_fwupdate
}
def send_cmd_reply(client, cmd_path, cid, cmd, status):
if not status or not cid:
return
if cmd_path.startswith(PREFIX_CMD):
path = cmd_path[len(PREFIX_CMD):]
else:
print("Invalid command path ({}), cannot send reply".format(cmd_path))
Содержание IX14
Страница 1: ...IX14 User Guide Firmware version 22 2 ...
Страница 45: ...Configuration and management Exit the command line interface IX14 User Guide 45 Type q or quit to exit ...
Страница 515: ...Monitoring This chapter contains the following topics intelliFlow 516 Configure NetFlow Probe 523 IX14 User Guide 515 ...
Страница 756: ...Routing Virtual Router Redundancy Protocol VRRP IX14 User Guide 756 ...
Страница 803: ...Command line interface Command line reference IX14 User Guide 803 Parameters None ...
Страница 812: ...Command line interface Command line reference IX14 User Guide 812 reboot Reboot the system Parameters None ...