Thomas Vachuska

Added GUI integration for device & host properties.

Fixed cell files to remove ONOS_CELL definition within; this is defined externally based on the cell itself.
1 # Local VirtualBox-based single ONOS instance & ONOS mininet box 1 # Local VirtualBox-based single ONOS instance & ONOS mininet box
2 2
3 -export ONOS_CELL="cbench"
4 -
5 export ONOS_NIC=192.168.56.* 3 export ONOS_NIC=192.168.56.*
6 export OC1="192.168.56.103" 4 export OC1="192.168.56.103"
7 export OCN="192.168.56.103" 5 export OCN="192.168.56.103"
......
1 # Local VirtualBox-based ONOS instances 1,2 & ONOS mininet box 1 # Local VirtualBox-based ONOS instances 1,2 & ONOS mininet box
2 2
3 -export ONOS_CELL="local"
4 -
5 export ONOS_NIC=192.168.56.* 3 export ONOS_NIC=192.168.56.*
6 export OC1="192.168.56.101" 4 export OC1="192.168.56.101"
7 export OC2="192.168.56.102" 5 export OC2="192.168.56.102"
......
1 # ProxMox-based cell of ONOS instance; no mininet-box 1 # ProxMox-based cell of ONOS instance; no mininet-box
2 2
3 -export ONOS_CELL="office"
4 -
5 export ONOS_NIC="10.1.10.*" 3 export ONOS_NIC="10.1.10.*"
6 export OC1="10.1.10.223" 4 export OC1="10.1.10.223"
7 export OCI="${OC1}" 5 export OCI="${OC1}"
......
1 # ProxMox-based cell of ONOS instances 1,2 & ONOS mininet box 1 # ProxMox-based cell of ONOS instances 1,2 & ONOS mininet box
2 2
3 -export ONOS_CELL="prox"
4 -
5 export ONOS_NIC="10.1.9.*" 3 export ONOS_NIC="10.1.9.*"
6 export OC1="10.1.9.94" 4 export OC1="10.1.9.94"
7 export OC2="10.1.9.82" 5 export OC2="10.1.9.82"
......
1 # Local VirtualBox-based single ONOS instance & ONOS mininet box 1 # Local VirtualBox-based single ONOS instance & ONOS mininet box
2 2
3 -export ONOS_CELL="single"
4 -
5 export ONOS_NIC=192.168.56.* 3 export ONOS_NIC=192.168.56.*
6 export OC1="192.168.56.101" 4 export OC1="192.168.56.101"
7 export OCN="192.168.56.103" 5 export OCN="192.168.56.103"
......
1 # Local VirtualBox-based ONOS instances 1,2,3 & ONOS mininet box 1 # Local VirtualBox-based ONOS instances 1,2,3 & ONOS mininet box
2 2
3 -export ONOS_CELL="triple"
4 -
5 export ONOS_NIC=192.168.56.* 3 export ONOS_NIC=192.168.56.*
6 export OC1="192.168.56.101" 4 export OC1="192.168.56.101"
7 export OC2="192.168.56.102" 5 export OC2="192.168.56.102"
......
...@@ -18,9 +18,12 @@ package org.onlab.onos.gui; ...@@ -18,9 +18,12 @@ package org.onlab.onos.gui;
18 import com.fasterxml.jackson.databind.ObjectMapper; 18 import com.fasterxml.jackson.databind.ObjectMapper;
19 import com.fasterxml.jackson.databind.node.ArrayNode; 19 import com.fasterxml.jackson.databind.node.ArrayNode;
20 import com.fasterxml.jackson.databind.node.ObjectNode; 20 import com.fasterxml.jackson.databind.node.ObjectNode;
21 +import org.onlab.onos.net.Annotations;
21 import org.onlab.onos.net.ConnectPoint; 22 import org.onlab.onos.net.ConnectPoint;
22 import org.onlab.onos.net.Device; 23 import org.onlab.onos.net.Device;
24 +import org.onlab.onos.net.DeviceId;
23 import org.onlab.onos.net.Host; 25 import org.onlab.onos.net.Host;
26 +import org.onlab.onos.net.HostId;
24 import org.onlab.onos.net.HostLocation; 27 import org.onlab.onos.net.HostLocation;
25 import org.onlab.onos.net.Link; 28 import org.onlab.onos.net.Link;
26 import org.onlab.onos.net.device.DeviceService; 29 import org.onlab.onos.net.device.DeviceService;
...@@ -35,6 +38,7 @@ import org.onlab.packet.MacAddress; ...@@ -35,6 +38,7 @@ import org.onlab.packet.MacAddress;
35 import org.onlab.rest.BaseResource; 38 import org.onlab.rest.BaseResource;
36 39
37 import javax.ws.rs.GET; 40 import javax.ws.rs.GET;
41 +import javax.ws.rs.PathParam;
38 import javax.ws.rs.Produces; 42 import javax.ws.rs.Produces;
39 import javax.ws.rs.core.Response; 43 import javax.ws.rs.core.Response;
40 import java.util.HashMap; 44 import java.util.HashMap;
...@@ -43,12 +47,17 @@ import java.util.Iterator; ...@@ -43,12 +47,17 @@ import java.util.Iterator;
43 import java.util.Map; 47 import java.util.Map;
44 import java.util.Set; 48 import java.util.Set;
45 49
50 +import static org.onlab.onos.net.DeviceId.deviceId;
51 +import static org.onlab.onos.net.HostId.hostId;
52 +
46 /** 53 /**
47 * Topology viewer resource. 54 * Topology viewer resource.
48 */ 55 */
49 @javax.ws.rs.Path("topology") 56 @javax.ws.rs.Path("topology")
50 public class TopologyResource extends BaseResource { 57 public class TopologyResource extends BaseResource {
51 58
59 + private static final String HOST_SEP = "/";
60 +
52 @javax.ws.rs.Path("/graph") 61 @javax.ws.rs.Path("/graph")
53 @GET 62 @GET
54 @Produces("application/json") 63 @Produces("application/json")
...@@ -70,6 +79,60 @@ public class TopologyResource extends BaseResource { ...@@ -70,6 +79,60 @@ public class TopologyResource extends BaseResource {
70 return Response.ok(rootNode.toString()).build(); 79 return Response.ok(rootNode.toString()).build();
71 } 80 }
72 81
82 + @javax.ws.rs.Path("/graph/{id}")
83 + @GET
84 + @Produces("application/json")
85 + public Response details(@PathParam("id") String id) {
86 + if (id.contains(HOST_SEP)) {
87 + return hostDetails(hostId(id));
88 + }
89 + return deviceDetails(deviceId(id));
90 + }
91 +
92 + // Returns device details response.
93 + private Response deviceDetails(DeviceId deviceId) {
94 + DeviceService deviceService = get(DeviceService.class);
95 + Device device = deviceService.getDevice(deviceId);
96 + Annotations annot = device.annotations();
97 + ObjectNode r = json(deviceId.toString(),
98 + new Prop("Name", annot.value("name")),
99 + new Prop("Vendor", device.manufacturer()),
100 + new Prop("H/W Version", device.hwVersion()),
101 + new Prop("S/W Version", device.swVersion()),
102 + new Prop("S/W Version", device.serialNumber()),
103 + new Prop("Latitude", annot.value("latitude")),
104 + new Prop("Longitude", annot.value("longitude")));
105 + return Response.ok(r.toString()).build();
106 + }
107 +
108 + // Returns host details response.
109 + private Response hostDetails(HostId hostId) {
110 + HostService hostService = get(HostService.class);
111 + Host host = hostService.getHost(hostId);
112 + Annotations annot = host.annotations();
113 + ObjectNode r = json(hostId.toString(),
114 + new Prop("MAC", host.mac().toString()),
115 + new Prop("IP", host.ipAddresses().toString()),
116 + new Prop("Latitude", annot.value("latitude")),
117 + new Prop("Longitude", annot.value("longitude")));
118 + return Response.ok(r.toString()).build();
119 + }
120 +
121 + // Produces JSON property details.
122 + private ObjectNode json(String id, Prop... props) {
123 + ObjectMapper mapper = new ObjectMapper();
124 + ObjectNode result = mapper.createObjectNode().put("id", id);
125 + ObjectNode pnode = mapper.createObjectNode();
126 + ArrayNode porder = mapper.createArrayNode();
127 + for (Prop p : props) {
128 + porder.add(p.key);
129 + pnode.put(p.key, p.value);
130 + }
131 + result.set("propOrder", porder);
132 + result.set("props", pnode);
133 + return result;
134 + }
135 +
73 // Encodes all infrastructure devices. 136 // Encodes all infrastructure devices.
74 private ArrayNode getDevices(ObjectMapper mapper, DeviceService deviceService, 137 private ArrayNode getDevices(ObjectMapper mapper, DeviceService deviceService,
75 TopologyGraph graph) { 138 TopologyGraph graph) {
...@@ -209,4 +272,14 @@ public class TopologyResource extends BaseResource { ...@@ -209,4 +272,14 @@ public class TopologyResource extends BaseResource {
209 return cp.elementId().toString(); 272 return cp.elementId().toString();
210 } 273 }
211 274
275 + // Auxiliary key/value carrier.
276 + private final class Prop {
277 + private final String key;
278 + private final String value;
279 +
280 + private Prop(String key, String value) {
281 + this.key = key;
282 + this.value = value;
283 + }
284 + }
212 } 285 }
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
38 collisionPrevention: true 38 collisionPrevention: true
39 }, 39 },
40 XjsonUrl: 'rs/topology/graph', 40 XjsonUrl: 'rs/topology/graph',
41 + XjsonPrefix: '',
41 jsonUrl: 'json/network.json', 42 jsonUrl: 'json/network.json',
42 jsonPrefix: 'json/', 43 jsonPrefix: 'json/',
43 iconUrl: { 44 iconUrl: {
...@@ -889,8 +890,11 @@ ...@@ -889,8 +890,11 @@
889 } 890 }
890 891
891 function detailUrl(id) { 892 function detailUrl(id) {
892 - var safeId = id.replace(/[^a-z0-9]/gi, '_'); 893 + if (config.jsonPrefix) {
893 - return config.jsonPrefix + safeId + '.json'; 894 + var safeId = id.replace(/[^a-z0-9]/gi, '_');
895 + return config.jsonPrefix + safeId + '.json';
896 + }
897 + return config.jsonUrl + '/' + encodeURIComponent(id);
894 } 898 }
895 899
896 function flyinPane(obj) { 900 function flyinPane(obj) {
......