blob: 0a7ac5ddf0be6e60c9958178bf76f1328aae06f1 [file] [log] [blame]
Jonathan Hart3d7730a2013-02-22 11:51:17 -08001package net.onrc.onos.registry.controller;
2
3import java.util.HashMap;
4import java.util.List;
5import java.util.Map;
6
7import org.restlet.resource.Get;
8import org.restlet.resource.ServerResource;
9import org.slf4j.Logger;
10import org.slf4j.LoggerFactory;
11
12public class SwitchRegistryResource extends ServerResource {
13
14 protected static Logger log = LoggerFactory.getLogger(SwitchRegistryResource.class);
15
16 @Get("json")
17 public Map<String, List<ControllerRegistryEntry>> getAllControllers(){
18 IControllerRegistryService registry =
19 (IControllerRegistryService) getContext().getAttributes().
20 get(IControllerRegistryService.class.getCanonicalName());
21
22 Map<String, List<ControllerRegistryEntry>> switches = null;
23 switches = registry.getAllSwitches();
24
25 if (switches == null){
26 switches = new HashMap<String, List<ControllerRegistryEntry>>();
27 }
28
Jonathan Hartf02a0932013-03-18 18:30:48 -070029 /*for (List<ControllerRegistryEntry> list: switches.values()){
Jonathan Hart3d7730a2013-02-22 11:51:17 -080030 for (ControllerRegistryEntry en : list) {
31 log.debug("Controller id {}", en.getControllerId());
32 }
Jonathan Hartf02a0932013-03-18 18:30:48 -070033 }*/
Jonathan Hart3d7730a2013-02-22 11:51:17 -080034
Jonathan Hart3d7730a2013-02-22 11:51:17 -080035 return switches;
36 }
37}