GUI -- Device View now has a column for Master Instance Id.
Change-Id: I941e57fce2635168793a88a078a73659642997b7
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/DeviceViewMessageHandler.java b/web/gui/src/main/java/org/onosproject/ui/impl/DeviceViewMessageHandler.java
index 0f8e347..6b1ac7b 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/DeviceViewMessageHandler.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/DeviceViewMessageHandler.java
@@ -18,6 +18,7 @@
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.ImmutableSet;
+import org.onosproject.mastership.MastershipService;
import org.onosproject.net.Device;
import org.onosproject.net.device.DeviceService;
@@ -44,8 +45,10 @@
String sortDir = string(payload, "sortDir", "asc");
DeviceService service = get(DeviceService.class);
- TableRow[] rows = generateTableRows(service);
- RowComparator rc = new RowComparator(sortCol, RowComparator.direction(sortDir));
+ MastershipService mastershipService = get(MastershipService.class);
+ TableRow[] rows = generateTableRows(service, mastershipService);
+ RowComparator rc =
+ new RowComparator(sortCol, RowComparator.direction(sortDir));
Arrays.sort(rows, rc);
ArrayNode devices = generateArrayNode(rows);
ObjectNode rootNode = mapper.createObjectNode();
@@ -54,10 +57,11 @@
connection().sendMessage("deviceDataResponse", 0, rootNode);
}
- private TableRow[] generateTableRows(DeviceService service) {
+ private TableRow[] generateTableRows(DeviceService service,
+ MastershipService mastershipService) {
List<TableRow> list = new ArrayList<>();
for (Device dev : service.getDevices()) {
- list.add(new DeviceTableRow(service, dev));
+ list.add(new DeviceTableRow(service, mastershipService, dev));
}
return list.toArray(new TableRow[list.size()]);
}
@@ -79,16 +83,19 @@
private static final String SERIAL = "serial";
private static final String PROTOCOL = "protocol";
private static final String CHASSISID = "chassisid";
+ private static final String MASTERID = "masterid";
private static final String[] COL_IDS = {
ID, AVAILABLE, AVAILABLE_IID, TYPE_IID, ROLE,
- MFR, HW, SW, SERIAL, PROTOCOL, CHASSISID
+ MFR, HW, SW, SERIAL, PROTOCOL, CHASSISID, MASTERID
};
private static final String ICON_ID_ONLINE = "deviceOnline";
private static final String ICON_ID_OFFLINE = "deviceOffline";
- public DeviceTableRow(DeviceService service, Device d) {
+ public DeviceTableRow(DeviceService service,
+ MastershipService ms,
+ Device d) {
boolean available = service.isAvailable(d.id());
String iconId = available ? ICON_ID_ONLINE : ICON_ID_OFFLINE;
@@ -103,6 +110,7 @@
add(SERIAL, d.serialNumber());
add(PROTOCOL, d.annotations().value(PROTOCOL));
add(CHASSISID, d.chassisId().toString());
+ add(MASTERID, ms.getMasterFor(d.id()).toString());
}
private String getTypeIconId(Device d) {