示例#1
0
    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")
示例#2
0
    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")
示例#3
0
    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")
示例#4
0
    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")