def get(self, id): """ Get the mac address of an interface """ try: iperfController = IperfController() json_data = json.dumps(iperfController.get_interface_ipv4Configuration_mac_address(id)) resp = Response(json_data, status=200, mimetype="application/json") return resp except ValueError as ve: return Response(json.dumps(str(ve)), status=404, mimetype="application/json") except Exception as err: return Response(json.dumps(str(err)), status=500, mimetype="application/json")
def put(self, id): """ Update the netmask of an interface """ try: iperfController = IperfController() netmask = request.data.decode() iperfController.update_interface_ipv4Configuration_netmask(id, netmask) return Response(status=202) except ValueError as ve: return Response(json.dumps(str(ve)), status=404, mimetype="application/json") except Exception as err: return Response(json.dumps(str(err)), status=500, mimetype="application/json")
def post(self): """ Start iperf server """ try: iperfController = IperfController() json_data = json.loads(request.data.decode()) resp_data = iperfController.start_iperf_server(json_data) resp = Response(resp_data, status=200, mimetype="application/text") return resp except Exception as err: return Response(json.dumps(str(err)), status=500, mimetype="application/json")
def get(self, id=None): """ Get the configuration of an interface """ try: iperfController = IperfController() if id is None: json_data = json.dumps(iperfController.get_interfaces()) else: json_data = json.dumps(iperfController.get_interface(id)) resp = Response(json_data, status=200, mimetype="application/json") return resp except ValueError as ve: return Response(json.dumps(str(ve)), status=404, mimetype="application/json") except Exception as err: return Response(json.dumps(str(err)), status=500, mimetype="application/json")