def get_apps(self, req, **kwargs):
     apps = self.data["apps"]
     body = json.dumps(apps)
     return Response(content_type='application/json', body=body)
Exemplo n.º 2
0
 def _ret(val):
     return Response(content_type='application/json',
                     body=json.dumps(val))
Exemplo n.º 3
0
 def list_switches(self, _req, **_kwargs):
     dpids = self.conf_switch.dpids()
     body = json.dumps([dpid_lib.dpid_to_str(dpid) for dpid in dpids])
     return Response(content_type='application/json', body=body)
Exemplo n.º 4
0
 def list_mac_table(self, req, **kwargs):
     body = json.dumps(self.haec_api_app.mac_to_node.keys())
     return Response(content_type='application/json', body=body)
Exemplo n.º 5
0
    def retrieve_links(self, req, **kwargs):

        body = '{"connected": ' + str(link_list) + '}'
        return Response(content_type='application/json', body=body)
Exemplo n.º 6
0
 def test(self, req, **kwargs):
     data = [{'test': 0}]
     body = json.dumps(data)
     print(type(req))
     print(str(req.environ))
     return Response(content_type='application/json', body=body)
 def switch_number(self, **kwargs):
     dps = list(self.dpset.dps.keys())
     body = json.dumps(dps)
     return Response(content_type='application/json', body=body)
Exemplo n.º 8
0
 def form_response(self, process_response):
     """Provides common form repsonse
     """
     res = Response()
     res.text = self.get_unicode(process_response)
     return res
Exemplo n.º 9
0
 def list_connections(self, req, **kwargs):
     simple_switch = self.simple_switch_app
     connections = copy.deepcopy(simple_switch.subflows)
     body = json.dumps(connections)
     return Response(content_type='application/json', body=body)
Exemplo n.º 10
0
 def test_root(self, req, **_kwargs):
     return Response(status=200, body='root')
Exemplo n.º 11
0
 def post_flow_delete(self, req):
     """Receive flows delete request
     """
     res = Response()
     res.text = self.get_unicode(self.ctrl_api.delete_flow_list(req.json))
     return res
Exemplo n.º 12
0
 def test_get_dpid(self, req, dpid, **_kwargs):
     return Response(status=200, body=dpid)
Exemplo n.º 13
0
    def wrapper(self, req, dpid, *args, **kwargs):
        # Parse request json body
        try:
            if req.body:
                # We use ast.literal_eval() to parse request json body
                # instead of json.loads().
                # Because we need to parse binary format body
                # in send_experimenter().
                body = ast.literal_eval(req.body.decode('utf-8'))
            else:
                body = {}
        except SyntaxError:
            LOG.exception('Invalid syntax: %s', req.body)
            return Response(status=400)

        # Get datapath instance from DPSet
        try:
            if dpid:
                dp = self.dpset.get(int(str(dpid), 0))
            else:
                LOG.error('No DPID specified in URL: %s', dpid)
        except ValueError:
            LOG.exception('Invalid dpid: %s', dpid)
            return Response(status=400)
        if dp is None:
            LOG.error('No such Datapath: %s', dpid)
            return Response(status=404)

        # Get lib/ofctl_* module
        try:
            ofctl = supported_ofctl.get(dp.ofproto.OFP_VERSION)
        except KeyError:
            LOG.exception('Unsupported OF version: version=%s',
                          dp.ofproto.OFP_VERSION)
            return Response(status=501)

        # Invoke StatsController method
        try:
            method(self, req, dp, ofctl, body, *args, **kwargs)
            return Response(status=200)
        except ValueError:
            LOG.exception('Invalid syntax: %s', req.body)
            return Response(status=400)
        except AttributeError:
            LOG.exception('Unsupported OF request in this version: %s',
                          dp.ofproto.OFP_VERSION)
            return Response(status=501)
        except CommandNotFoundError as e:
            LOG.exception(e.message)
            return Response(status=404)
        except PortNotFoundError as e:
            LOG.exception(e.message)
            return Response(status=404)
        except TableNotFoundError as e:
            LOG.exception(e.message)
            return Response(status=404)
        except FlowNotFoundError as e:
            LOG.exception(e.message)
            return Response(status=404)
 def get_devices(self, req, **kwargs):
     devices = self.data["devices"]
     body = json.dumps(devices)
     return Response(content_type='application/json', body=body)
Exemplo n.º 15
0
 def req_handler_vnf(self, req, **kwargs):
     return Response(
         content_type="application/json",
         body=json.dumps([vnf.as_dict() for vnf in self.app.vnfs.values()], indent=4),
     )
Exemplo n.º 16
0
    def get_topology(self, req, **kwargs):
        simple_switch = self.simple_switch_app

        body = json.dumps(
            list(simple_switch.net.nodes) + list(simple_switch.net.edges))
        return Response(content_type='application/json', body=body)
Exemplo n.º 17
0
 def _ret(keys):
     body = json.dumps(keys)
     return Response(content_type='application/json', body=body)
Exemplo n.º 18
0
    def evaluate_results(self, req, **kwargs):
        # this is called at the end of the test

        f = open("index.html")
        page = f.read()
        return Response(content_type="text/html", body=page)
Exemplo n.º 19
0
 def get_utilization(self, req, **kwargs):
     utilization, queue_length = self.topology_api_app.get_utilization()
     data = {'link_utilization': utilization, 'queue_length': queue_length}
     body = json.dumps(data)
     return Response(content_type='application/json', body=body)
Exemplo n.º 20
0
 def get_dpids(self, req, **_kwargs):
     dps = list(self.dpset.dps.keys())
     body = json.dumps(dps)
     return Response(content_type='application/json', body=body)
Exemplo n.º 21
0
 def cost_handler(self, req, **kwargs):
     cost = float(req.body)
     self.haec_api_app.set_cost(kwargs["source"].encode(),
                                kwargs["dest"].encode(), cost)
     res = Response(status=200)
     return res
Exemplo n.º 22
0
 def get_links(self, req, **kwargs):
     links = self.network_monitor.create_links_view()
     body = json.dumps(links)
     return Response(content_type='application/json', body=body)
Exemplo n.º 23
0
 def list_host_ifce_table(self, req, **kwargs):
     body = json.dumps(self.haec_api_app.host_to_ifce)
     return Response(content_type='application/json', body=body)
Exemplo n.º 24
0
 def req_handler_lldp(self, req, **kwargs):
     attr = json.loads(req.body)
     attr["dst"]["addr"] = req.remote_addr
     self.app.model.update(attr)
     return Response(status=200)
Exemplo n.º 25
0
 def _ret(_ret):
     return Response(status=http_client.CREATED)
Exemplo n.º 26
0
 def req_handler_model(self, req, **kwargs):
     return Response(
         content_type="application/json",
         body=self.app.model.as_json(indent=2),
     )
Exemplo n.º 27
0
 def _ret(_ret):
     return Response()
Exemplo n.º 28
0
 def req_handler_plot(self, req, **kwargs):
     self.app.model.plot()
     return Response(status=200)
Exemplo n.º 29
0
 def _ret(_ret):
     return Response(status=http_client.ACCEPTED)
Exemplo n.º 30
0
 def flows_handler(self, req, **kwargs):
     body = json.dumps(self.haec_api_app.get_flows())
     return Response(content_type='application/json', body=body)