def query_and_view_edge_util(): queryType = request.form['queryType'] category = request.form['category'] order = request.form['order'] desc = request.form['desc'] limit = request.form['limit'] requirements = request.form['requirements'] additionalFields = request.form['additionalFields'] device_id = device_config_db.get_device_id() url = 'http://localhost:'+str(server_port)+'/api/utilization/query' json_data = { 'query':{ 'queryID':1, 'queryType':queryType, 'category':category, 'order':order, 'desc':desc, 'limit':limit, 'requirements':requirements, 'additionalFields':additionalFields }, 'DeviceID':device_id } response = requests.post(url, json=json_data) device_status = device_config_db.get_device_status() return render_template('edge_util.html', device_status=device_status)
def run_qos_interpreter_and_view_result(): service_type = request.form['service_type'] service_name = request.form['service_name'] requirements = request.form['requirements'] json_data = { 'service_type': service_type, 'service_name': service_name, 'requirements': json.loads(requirements) } device_id = device_config_db.get_device_id() device_status = device_config_db.get_device_status() temp_result = qos_interpreter.interpret(json_data) output_result = [] if ('delay' in temp_result.keys()): output_result.append(temp_result['delay']) if ('jitter' in temp_result.keys()): output_result.append(temp_result['jitter']) if ('bandwidth' in temp_result.keys()): output_result.append(temp_result['bandwidth']) if ('lossrate' in temp_result.keys()): output_result.append(temp_result['lossrate']) return render_template('qos_interpreter.html', interpreted=True, device_status=device_status, input_desc=json_data, output_result=output_result)
def leave_and_view_edge_config(): #request.form[] url = 'http://localhost:'+str(server_port)+'/api/configuration/leave' response = requests.get(url) device_status = device_config_db.get_device_status() device_id = device_config_db.get_device_id() print('Device status: ', device_status) return render_template('edge_config.html', device_status=device_status, register_list=None)
def get(self): device_id = device_config_db.get_device_id() # TODO: get resources resources = 'none' # Internal function for the API request update(device_id, resources) # return values return {'error':0}, status.HTTP_200_OK
def get(self): device_id = device_config_db.get_device_id() # Relay: not used yet (2017.11.30) relay = 'none' # Internal function for the API request leave(device_id, relay) device_config_db.set_device_status('leave') # return values return {'error':0}, status.HTTP_200_OK
def post(self): # Parse post arguments json_data = request.get_json(force=True) print('[EdgeUtilQuery] recv query from user/service:\n', json_data) if ('query' in json_data): query_index = device_config_db.add_query(json_data['query']) json_data['query']['queryID'] = str(query_index) device_id = '' if ('DeviceID' in json_data): device_id = json_data['DeviceID'] else: device_id = device_config_db.get_device_id() send_query(device_id, json_data['query']) # return values return {'error': 0}, status.HTTP_200_OK
def post(self): # Parse post arguments json_data = request.get_json(force=True) register_list = json_data['register_list'] print('[EdgeConfigRegister] recv JSON Data from user/service:\n', json_data) device_id = device_config_db.get_device_id() # Get registration list register_id = device_config_db.get_register_id(register_list) #device_config_db.add_register_list(register_list) for reg in register_list: index = device_config_db.add_register(reg) reg['index'] = str(index) # Relay: not used yet (2017.11.30) relay = 'none' # Internal function for the API request register(device_id, register_id, register_list, relay) # return values return {'error':0}, status.HTTP_200_OK
def on_connect(client, userdata, flags, rc): device_id = device_config_db.get_device_id() print("connected with result code " + str(rc))