def commandRegister(token): url = env.URL_BASE + '/v1/controller/register' sysInfo = getSystemInfo() payload = sysInfo.getInfoJSON() payload['token'] = token r = requests.post(url, data=json.dumps(payload)) return statusHandler(r)
def sysBoot(): url = env.URL_BASE + '/v1/controller/boot' sysInfo = getSystemInfo() payload = sysInfo.getInfoJSON() r = requests.post(url, data=json.dumps(payload)) print('sysBoot request') print(json.dumps(payload)) return statusHandler(r)
def sysinfoUpdate(): url = env.URL_BASE + '/v1/controller/sysinfo/update' sysInfo = getSystemInfo() payload = { 'id': str(sysInfo.hardwarehash), 'ip': str(sysInfo.network.ip_local), 'upgrade': str(sysInfo.VERSION) } r = requests.post(url, data=json.dumps(payload)) return statusHandler(r)
def commandUpdate(commandId, result, message): url = env.URL_BASE + '/v1/controller/command/update' sysInfo = getSystemInfo() payload = { 'id': str(sysInfo.hardwarehash), 'commandId': str(commandId), 'result': str(result), 'message': str(message) } r = requests.post(url, data=json.dumps(payload)) return statusHandler(r)
def startServer(): sysInfo = getSystemInfo() http = HTTPServer((sysInfo.network.ip_local, 28080), RESTHandler) print('Server ready to start') http.serve_forever() print('Server started')
def commandGet(): url = env.URL_BASE + '/v1/controller/command/get' sysInfo = getSystemInfo() payload = {'id': str(sysInfo.hardwarehash)} r = requests.post(url, data=json.dumps(payload)) return statusHandler(r)