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.
diff --git a/tools/test/cells/cbench b/tools/test/cells/cbench
index 2e0b4783..8601929 100644
--- a/tools/test/cells/cbench
+++ b/tools/test/cells/cbench
@@ -1,7 +1,5 @@
# Local VirtualBox-based single ONOS instance & ONOS mininet box
-export ONOS_CELL="cbench"
-
export ONOS_NIC=192.168.56.*
export OC1="192.168.56.103"
export OCN="192.168.56.103"
diff --git a/tools/test/cells/local b/tools/test/cells/local
index 64b63ec..e8ca7e9 100644
--- a/tools/test/cells/local
+++ b/tools/test/cells/local
@@ -1,7 +1,5 @@
# Local VirtualBox-based ONOS instances 1,2 & ONOS mininet box
-export ONOS_CELL="local"
-
export ONOS_NIC=192.168.56.*
export OC1="192.168.56.101"
export OC2="192.168.56.102"
diff --git a/tools/test/cells/office b/tools/test/cells/office
index 7c6345b..aec5e27 100644
--- a/tools/test/cells/office
+++ b/tools/test/cells/office
@@ -1,7 +1,5 @@
# ProxMox-based cell of ONOS instance; no mininet-box
-export ONOS_CELL="office"
-
export ONOS_NIC="10.1.10.*"
export OC1="10.1.10.223"
export OCI="${OC1}"
diff --git a/tools/test/cells/prox b/tools/test/cells/prox
index 557388f..28e073f 100644
--- a/tools/test/cells/prox
+++ b/tools/test/cells/prox
@@ -1,7 +1,5 @@
# ProxMox-based cell of ONOS instances 1,2 & ONOS mininet box
-export ONOS_CELL="prox"
-
export ONOS_NIC="10.1.9.*"
export OC1="10.1.9.94"
export OC2="10.1.9.82"
diff --git a/tools/test/cells/single b/tools/test/cells/single
index 50296c1..032a583 100644
--- a/tools/test/cells/single
+++ b/tools/test/cells/single
@@ -1,7 +1,5 @@
# Local VirtualBox-based single ONOS instance & ONOS mininet box
-export ONOS_CELL="single"
-
export ONOS_NIC=192.168.56.*
export OC1="192.168.56.101"
export OCN="192.168.56.103"
diff --git a/tools/test/cells/triple b/tools/test/cells/triple
index 104eb05..439b837 100644
--- a/tools/test/cells/triple
+++ b/tools/test/cells/triple
@@ -1,7 +1,5 @@
# Local VirtualBox-based ONOS instances 1,2,3 & ONOS mininet box
-export ONOS_CELL="triple"
-
export ONOS_NIC=192.168.56.*
export OC1="192.168.56.101"
export OC2="192.168.56.102"
diff --git a/web/gui/src/main/java/org/onlab/onos/gui/TopologyResource.java b/web/gui/src/main/java/org/onlab/onos/gui/TopologyResource.java
index ed14353..e8f147d 100644
--- a/web/gui/src/main/java/org/onlab/onos/gui/TopologyResource.java
+++ b/web/gui/src/main/java/org/onlab/onos/gui/TopologyResource.java
@@ -18,9 +18,12 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onlab.onos.net.Annotations;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.Device;
+import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.Host;
+import org.onlab.onos.net.HostId;
import org.onlab.onos.net.HostLocation;
import org.onlab.onos.net.Link;
import org.onlab.onos.net.device.DeviceService;
@@ -35,6 +38,7 @@
import org.onlab.rest.BaseResource;
import javax.ws.rs.GET;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import java.util.HashMap;
@@ -43,12 +47,17 @@
import java.util.Map;
import java.util.Set;
+import static org.onlab.onos.net.DeviceId.deviceId;
+import static org.onlab.onos.net.HostId.hostId;
+
/**
* Topology viewer resource.
*/
@javax.ws.rs.Path("topology")
public class TopologyResource extends BaseResource {
+ private static final String HOST_SEP = "/";
+
@javax.ws.rs.Path("/graph")
@GET
@Produces("application/json")
@@ -70,6 +79,60 @@
return Response.ok(rootNode.toString()).build();
}
+ @javax.ws.rs.Path("/graph/{id}")
+ @GET
+ @Produces("application/json")
+ public Response details(@PathParam("id") String id) {
+ if (id.contains(HOST_SEP)) {
+ return hostDetails(hostId(id));
+ }
+ return deviceDetails(deviceId(id));
+ }
+
+ // Returns device details response.
+ private Response deviceDetails(DeviceId deviceId) {
+ DeviceService deviceService = get(DeviceService.class);
+ Device device = deviceService.getDevice(deviceId);
+ Annotations annot = device.annotations();
+ ObjectNode r = json(deviceId.toString(),
+ new Prop("Name", annot.value("name")),
+ new Prop("Vendor", device.manufacturer()),
+ new Prop("H/W Version", device.hwVersion()),
+ new Prop("S/W Version", device.swVersion()),
+ new Prop("S/W Version", device.serialNumber()),
+ new Prop("Latitude", annot.value("latitude")),
+ new Prop("Longitude", annot.value("longitude")));
+ return Response.ok(r.toString()).build();
+ }
+
+ // Returns host details response.
+ private Response hostDetails(HostId hostId) {
+ HostService hostService = get(HostService.class);
+ Host host = hostService.getHost(hostId);
+ Annotations annot = host.annotations();
+ ObjectNode r = json(hostId.toString(),
+ new Prop("MAC", host.mac().toString()),
+ new Prop("IP", host.ipAddresses().toString()),
+ new Prop("Latitude", annot.value("latitude")),
+ new Prop("Longitude", annot.value("longitude")));
+ return Response.ok(r.toString()).build();
+ }
+
+ // Produces JSON property details.
+ private ObjectNode json(String id, Prop... props) {
+ ObjectMapper mapper = new ObjectMapper();
+ ObjectNode result = mapper.createObjectNode().put("id", id);
+ ObjectNode pnode = mapper.createObjectNode();
+ ArrayNode porder = mapper.createArrayNode();
+ for (Prop p : props) {
+ porder.add(p.key);
+ pnode.put(p.key, p.value);
+ }
+ result.set("propOrder", porder);
+ result.set("props", pnode);
+ return result;
+ }
+
// Encodes all infrastructure devices.
private ArrayNode getDevices(ObjectMapper mapper, DeviceService deviceService,
TopologyGraph graph) {
@@ -209,4 +272,14 @@
return cp.elementId().toString();
}
+ // Auxiliary key/value carrier.
+ private final class Prop {
+ private final String key;
+ private final String value;
+
+ private Prop(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+ }
}
diff --git a/web/gui/src/main/webapp/network.js b/web/gui/src/main/webapp/network.js
index 4f8f76e..3c7507a 100644
--- a/web/gui/src/main/webapp/network.js
+++ b/web/gui/src/main/webapp/network.js
@@ -38,6 +38,7 @@
collisionPrevention: true
},
XjsonUrl: 'rs/topology/graph',
+ XjsonPrefix: '',
jsonUrl: 'json/network.json',
jsonPrefix: 'json/',
iconUrl: {
@@ -889,8 +890,11 @@
}
function detailUrl(id) {
- var safeId = id.replace(/[^a-z0-9]/gi, '_');
- return config.jsonPrefix + safeId + '.json';
+ if (config.jsonPrefix) {
+ var safeId = id.replace(/[^a-z0-9]/gi, '_');
+ return config.jsonPrefix + safeId + '.json';
+ }
+ return config.jsonUrl + '/' + encodeURIComponent(id);
}
function flyinPane(obj) {