mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-22 04:40:59 +02:00
GUI -- Device View now has a column for Master Instance Id.
Change-Id: I941e57fce2635168793a88a078a73659642997b7
This commit is contained in:
parent
1a4eca0459
commit
ae65c96f5b
@ -18,6 +18,7 @@ package org.onosproject.ui.impl;
|
|||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.onosproject.mastership.MastershipService;
|
||||||
import org.onosproject.net.Device;
|
import org.onosproject.net.Device;
|
||||||
import org.onosproject.net.device.DeviceService;
|
import org.onosproject.net.device.DeviceService;
|
||||||
|
|
||||||
@ -44,8 +45,10 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler
|
|||||||
String sortDir = string(payload, "sortDir", "asc");
|
String sortDir = string(payload, "sortDir", "asc");
|
||||||
|
|
||||||
DeviceService service = get(DeviceService.class);
|
DeviceService service = get(DeviceService.class);
|
||||||
TableRow[] rows = generateTableRows(service);
|
MastershipService mastershipService = get(MastershipService.class);
|
||||||
RowComparator rc = new RowComparator(sortCol, RowComparator.direction(sortDir));
|
TableRow[] rows = generateTableRows(service, mastershipService);
|
||||||
|
RowComparator rc =
|
||||||
|
new RowComparator(sortCol, RowComparator.direction(sortDir));
|
||||||
Arrays.sort(rows, rc);
|
Arrays.sort(rows, rc);
|
||||||
ArrayNode devices = generateArrayNode(rows);
|
ArrayNode devices = generateArrayNode(rows);
|
||||||
ObjectNode rootNode = mapper.createObjectNode();
|
ObjectNode rootNode = mapper.createObjectNode();
|
||||||
@ -54,10 +57,11 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler
|
|||||||
connection().sendMessage("deviceDataResponse", 0, rootNode);
|
connection().sendMessage("deviceDataResponse", 0, rootNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TableRow[] generateTableRows(DeviceService service) {
|
private TableRow[] generateTableRows(DeviceService service,
|
||||||
|
MastershipService mastershipService) {
|
||||||
List<TableRow> list = new ArrayList<>();
|
List<TableRow> list = new ArrayList<>();
|
||||||
for (Device dev : service.getDevices()) {
|
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()]);
|
return list.toArray(new TableRow[list.size()]);
|
||||||
}
|
}
|
||||||
@ -79,16 +83,19 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler
|
|||||||
private static final String SERIAL = "serial";
|
private static final String SERIAL = "serial";
|
||||||
private static final String PROTOCOL = "protocol";
|
private static final String PROTOCOL = "protocol";
|
||||||
private static final String CHASSISID = "chassisid";
|
private static final String CHASSISID = "chassisid";
|
||||||
|
private static final String MASTERID = "masterid";
|
||||||
|
|
||||||
private static final String[] COL_IDS = {
|
private static final String[] COL_IDS = {
|
||||||
ID, AVAILABLE, AVAILABLE_IID, TYPE_IID, ROLE,
|
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_ONLINE = "deviceOnline";
|
||||||
private static final String ICON_ID_OFFLINE = "deviceOffline";
|
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());
|
boolean available = service.isAvailable(d.id());
|
||||||
String iconId = available ? ICON_ID_ONLINE : ICON_ID_OFFLINE;
|
String iconId = available ? ICON_ID_ONLINE : ICON_ID_OFFLINE;
|
||||||
|
|
||||||
@ -103,6 +110,7 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler
|
|||||||
add(SERIAL, d.serialNumber());
|
add(SERIAL, d.serialNumber());
|
||||||
add(PROTOCOL, d.annotations().value(PROTOCOL));
|
add(PROTOCOL, d.annotations().value(PROTOCOL));
|
||||||
add(CHASSISID, d.chassisId().toString());
|
add(CHASSISID, d.chassisId().toString());
|
||||||
|
add(MASTERID, ms.getMasterFor(d.id()).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTypeIconId(Device d) {
|
private String getTypeIconId(Device d) {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
<th colId="chassisid" sortable>Chassis ID </th>
|
<th colId="chassisid" sortable>Chassis ID </th>
|
||||||
<th colId="serial" sortable>Serial # </th>
|
<th colId="serial" sortable>Serial # </th>
|
||||||
<th colId="protocol" sortable>Protocol </th>
|
<th colId="protocol" sortable>Protocol </th>
|
||||||
|
<th colId="masterid" sortable>Master Instance </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@ -35,6 +36,7 @@
|
|||||||
<td>{{dev.chassisid}}</td>
|
<td>{{dev.chassisid}}</td>
|
||||||
<td>{{dev.serial}}</td>
|
<td>{{dev.serial}}</td>
|
||||||
<td>{{dev.protocol}}</td>
|
<td>{{dev.protocol}}</td>
|
||||||
|
<td>{{dev.masterid}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user