예제 #1
0
파일: webapi.py 프로젝트: bbill/flowmanager
 def get_topology(self, req, **_kwargs):
     """Get topology info
     """
     res = Response(content_type="application/json")
     reply = self.api.get_topology_data()
     res.json = reply
     return res
예제 #2
0
    def get_flow_data(self, req, **_kwargs):
        """Get switch data
        """
        # TODO: merge with get_flow_stats
        if req.GET:
            lst = {}
            if req.GET.get("list") == "switches":
                lst = {t[0]: t[0] for t in self.api.get_switches()}
            if req.GET.get("switchdesc"):
                dpid = int(req.GET["switchdesc"])
                lst = self.api.get_switch_desc(dpid)
            if req.GET.get("portdesc"):
                dpid = int(req.GET["portdesc"])
                lst = self.api.get_port_desc(dpid)
            if req.GET.get("portstat"):
                dpid = int(req.GET["portstat"])
                lst = self.api.get_port_stat(dpid)
            if req.GET.get("flowsumm"):
                dpid = int(req.GET["flowsumm"])
                lst = self.api.get_flow_summary(dpid)
            if req.GET.get("tablestat"):
                dpid = int(req.GET["tablestat"])
                lst = self.api.get_table_stat(dpid)

            res = Response(content_type="application/json")
            res.json = lst
            return res
        return Response(status=400)  # bad request
예제 #3
0
 def get_logs(self, _):
     """Get log mesages
     """
     logger.debug("Requesting logs")
     res = Response(content_type="application/json")
     res.json = self.ctrl_api.read_logs()
     return res
예제 #4
0
 def get_topology(self, _):
     """Get topology info
     """
     logger.debug("Requesting topology")
     res = Response(content_type="application/json")
     res.json = self.ctrl_api.get_topology_data()
     return res
예제 #5
0
파일: webapi.py 프로젝트: bbill/flowmanager
 def get_flow_stats(self, req, **_kwargs):
     """Get stats
     """
     if req.GET['status'] and req.GET['dpid']:
         res = Response(content_type="application/json")
         res.json = self.api.get_stats(req.GET['status'], req.GET['dpid'])
         return res
     return Response(status=404)  # Resource does not exist
예제 #6
0
파일: webapi.py 프로젝트: bbill/flowmanager
 def get_logs(self, req, **_kwargs):
     """Get log mesages
     """
     if req.GET:
         logs = self.api.read_logs()
         res = Response(content_type="application/json")
         res.json = logs
         return res
     return Response(status=400)  # bad request
예제 #7
0
 def get_flow_stats(self, req):
     """Get stats
     """
     if 'status' in req.GET and 'dpid' in req.GET:
         res = Response(content_type="application/json")
         res.json = self.ctrl_api.get_stats(req.GET['status'],
                                            req.GET['dpid'])
         return res
     return Response(status=404)  # Resource does not exist
예제 #8
0
    def get_switch_data(self, req):
        """Get switch data
        """
        logger.debug("Requesting data")
        lst = {}  # the server always returns somthing??
        if req.GET.get("list") == "switches":
            lst = {t[0]: t[0] for t in self.ctrl_api.get_switches()}
        else:
            request = list(req.GET.keys())[0]
            dpid = int(req.GET[request])
            lst = self.ctrl_api.get_stats_request(request, dpid)

        res = Response(content_type="application/json")
        res.json = lst
        return res
예제 #9
0
파일: webapi.py 프로젝트: bbill/flowmanager
    def get_switch_data(self, req, **_kwargs):
        """Get switch data
        """
        if req.GET:  # is this if needed?
            lst = {}  # the server always returns somthing??
            if req.GET.get("list") == "switches":
                lst = {t[0]: t[0] for t in self.api.get_switches()}
            else:
                request = list(req.GET.keys())[0]
                dpid = int(req.GET[request])
                lst = self.api.get_stats_request(request, dpid)

            res = Response(content_type="application/json")
            res.json = lst
            return res
        return Response(status=400)  # bad request
예제 #10
0
    def get_flow_form(self, req, **_kwargs):
        """Connect with flow form
        """
        if req.POST:
            res = Response()
            res.body = self.api.process_flow_message(req.json)
            return res
        elif req.GET and "list" in req.GET:
            lst = {}
            if req.GET["list"] == "actions":
                lst = self.lists["actions"]
            elif req.GET["list"] == "matches":
                lst = self.lists["matches"]
            elif req.GET["list"] == "switches":
                lst = {t[0]: str(t[0]) for t in self.api.get_switches()}
                #print(lst)

            res = Response(content_type="application/json")
            res.json = lst
            return res
        return Response(status=400)  # bad request