|
41 | 41 | This class is responsible for
|
42 | 42 | """
|
43 | 43 | simple_switch_instance_name = 'simple_switch_api_app'
|
44 |
| -url = '/simpleswitch/mactable/{dpid}' |
45 |
| -urll = '/mininet/topo/switches/' |
| 44 | +url = '/mininet/topo/' |
46 | 45 | class RestHandler(ControllerBase):
|
47 | 46 | _CONTEXTS = { 'wsgi': WSGIApplication }
|
48 | 47 |
|
49 | 48 | def __init__(self, req, link, data, **config):
|
50 | 49 | super(RestHandler, self).__init__(req, link, data, **config)
|
51 | 50 | self.simpl_switch_spp = data[simple_switch_instance_name]
|
52 | 51 |
|
53 |
| - @route('simpleswitch', urll, methods=['GET']) |
54 |
| - def list_mac_table(self, req, **kwargs): |
| 52 | + @route('simpleswitch', url+"switches/", methods=['GET']) |
| 53 | + def list_switches(self, req, **kwargs): |
55 | 54 | simple_switch = self.simpl_switch_spp
|
56 | 55 |
|
57 | 56 | body = json.dumps(simple_switch.topo_shape.get_switches_dpid())
|
58 | 57 | return Response(content_type='application/json', body=body)
|
59 | 58 |
|
| 59 | + @route('simpleswitch', url+"links/", methods=['GET']) |
| 60 | + def list_links(self, req, **kwargs): |
| 61 | + simple_switch = self.simpl_switch_spp |
| 62 | + |
| 63 | + body = json.dumps(simple_switch.topo_shape.get_links_str()) |
| 64 | + return Response(content_type='application/json', body=body) |
| 65 | + |
60 | 66 | """
|
61 | 67 | This holds the hosts information and their connection to switches.
|
62 | 68 | An instance of this class is used in TopoStructure to save the topo info.
|
@@ -410,6 +416,16 @@ def print_switches(self, func_str=None):
|
410 | 416 | for p in s.ports:
|
411 | 417 | print ("\t\t\t " + str(p.hw_addr))
|
412 | 418 |
|
| 419 | + def get_links_str(self): |
| 420 | + """ |
| 421 | + Uses the built in __str__ function to print the links saved in the class `topo_raw_links`. |
| 422 | + Returns a list of link strings |
| 423 | + """ |
| 424 | + out = [] |
| 425 | + for l in self.topo_raw_links: |
| 426 | + out.append(str(l)) |
| 427 | + return out |
| 428 | + |
413 | 429 | def get_hw_addresses_for_dpid(self, in_dpid):
|
414 | 430 | """
|
415 | 431 | For a specific dpid of switch it return a list of mac addresses for each port of that sw.
|
|
0 commit comments