Committed by
Gerrit Code Review
GUI -- Device View now has a column for Master Instance Id.
Change-Id: I941e57fce2635168793a88a078a73659642997b7
Showing
2 changed files
with
16 additions
and
6 deletions
| ... | @@ -18,6 +18,7 @@ package org.onosproject.ui.impl; | ... | @@ -18,6 +18,7 @@ package org.onosproject.ui.impl; |
| 18 | import com.fasterxml.jackson.databind.node.ArrayNode; | 18 | import com.fasterxml.jackson.databind.node.ArrayNode; |
| 19 | import com.fasterxml.jackson.databind.node.ObjectNode; | 19 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 20 | import com.google.common.collect.ImmutableSet; | 20 | import com.google.common.collect.ImmutableSet; |
| 21 | +import org.onosproject.mastership.MastershipService; | ||
| 21 | import org.onosproject.net.Device; | 22 | import org.onosproject.net.Device; |
| 22 | import org.onosproject.net.device.DeviceService; | 23 | import org.onosproject.net.device.DeviceService; |
| 23 | 24 | ||
| ... | @@ -44,8 +45,10 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler | ... | @@ -44,8 +45,10 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler |
| 44 | String sortDir = string(payload, "sortDir", "asc"); | 45 | String sortDir = string(payload, "sortDir", "asc"); |
| 45 | 46 | ||
| 46 | DeviceService service = get(DeviceService.class); | 47 | DeviceService service = get(DeviceService.class); |
| 47 | - TableRow[] rows = generateTableRows(service); | 48 | + MastershipService mastershipService = get(MastershipService.class); |
| 48 | - RowComparator rc = new RowComparator(sortCol, RowComparator.direction(sortDir)); | 49 | + TableRow[] rows = generateTableRows(service, mastershipService); |
| 50 | + RowComparator rc = | ||
| 51 | + new RowComparator(sortCol, RowComparator.direction(sortDir)); | ||
| 49 | Arrays.sort(rows, rc); | 52 | Arrays.sort(rows, rc); |
| 50 | ArrayNode devices = generateArrayNode(rows); | 53 | ArrayNode devices = generateArrayNode(rows); |
| 51 | ObjectNode rootNode = mapper.createObjectNode(); | 54 | ObjectNode rootNode = mapper.createObjectNode(); |
| ... | @@ -54,10 +57,11 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler | ... | @@ -54,10 +57,11 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler |
| 54 | connection().sendMessage("deviceDataResponse", 0, rootNode); | 57 | connection().sendMessage("deviceDataResponse", 0, rootNode); |
| 55 | } | 58 | } |
| 56 | 59 | ||
| 57 | - private TableRow[] generateTableRows(DeviceService service) { | 60 | + private TableRow[] generateTableRows(DeviceService service, |
| 61 | + MastershipService mastershipService) { | ||
| 58 | List<TableRow> list = new ArrayList<>(); | 62 | List<TableRow> list = new ArrayList<>(); |
| 59 | for (Device dev : service.getDevices()) { | 63 | for (Device dev : service.getDevices()) { |
| 60 | - list.add(new DeviceTableRow(service, dev)); | 64 | + list.add(new DeviceTableRow(service, mastershipService, dev)); |
| 61 | } | 65 | } |
| 62 | return list.toArray(new TableRow[list.size()]); | 66 | return list.toArray(new TableRow[list.size()]); |
| 63 | } | 67 | } |
| ... | @@ -79,16 +83,19 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler | ... | @@ -79,16 +83,19 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler |
| 79 | private static final String SERIAL = "serial"; | 83 | private static final String SERIAL = "serial"; |
| 80 | private static final String PROTOCOL = "protocol"; | 84 | private static final String PROTOCOL = "protocol"; |
| 81 | private static final String CHASSISID = "chassisid"; | 85 | private static final String CHASSISID = "chassisid"; |
| 86 | + private static final String MASTERID = "masterid"; | ||
| 82 | 87 | ||
| 83 | private static final String[] COL_IDS = { | 88 | private static final String[] COL_IDS = { |
| 84 | ID, AVAILABLE, AVAILABLE_IID, TYPE_IID, ROLE, | 89 | ID, AVAILABLE, AVAILABLE_IID, TYPE_IID, ROLE, |
| 85 | - MFR, HW, SW, SERIAL, PROTOCOL, CHASSISID | 90 | + MFR, HW, SW, SERIAL, PROTOCOL, CHASSISID, MASTERID |
| 86 | }; | 91 | }; |
| 87 | 92 | ||
| 88 | private static final String ICON_ID_ONLINE = "deviceOnline"; | 93 | private static final String ICON_ID_ONLINE = "deviceOnline"; |
| 89 | private static final String ICON_ID_OFFLINE = "deviceOffline"; | 94 | private static final String ICON_ID_OFFLINE = "deviceOffline"; |
| 90 | 95 | ||
| 91 | - public DeviceTableRow(DeviceService service, Device d) { | 96 | + public DeviceTableRow(DeviceService service, |
| 97 | + MastershipService ms, | ||
| 98 | + Device d) { | ||
| 92 | boolean available = service.isAvailable(d.id()); | 99 | boolean available = service.isAvailable(d.id()); |
| 93 | String iconId = available ? ICON_ID_ONLINE : ICON_ID_OFFLINE; | 100 | String iconId = available ? ICON_ID_ONLINE : ICON_ID_OFFLINE; |
| 94 | 101 | ||
| ... | @@ -103,6 +110,7 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler | ... | @@ -103,6 +110,7 @@ public class DeviceViewMessageHandler extends AbstractTabularViewMessageHandler |
| 103 | add(SERIAL, d.serialNumber()); | 110 | add(SERIAL, d.serialNumber()); |
| 104 | add(PROTOCOL, d.annotations().value(PROTOCOL)); | 111 | add(PROTOCOL, d.annotations().value(PROTOCOL)); |
| 105 | add(CHASSISID, d.chassisId().toString()); | 112 | add(CHASSISID, d.chassisId().toString()); |
| 113 | + add(MASTERID, ms.getMasterFor(d.id()).toString()); | ||
| 106 | } | 114 | } |
| 107 | 115 | ||
| 108 | private String getTypeIconId(Device d) { | 116 | private String getTypeIconId(Device d) { | ... | ... |
| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | <th colId="chassisid" sortable>Chassis ID </th> | 16 | <th colId="chassisid" sortable>Chassis ID </th> |
| 17 | <th colId="serial" sortable>Serial # </th> | 17 | <th colId="serial" sortable>Serial # </th> |
| 18 | <th colId="protocol" sortable>Protocol </th> | 18 | <th colId="protocol" sortable>Protocol </th> |
| 19 | + <th colId="masterid" sortable>Master Instance </th> | ||
| 19 | </tr> | 20 | </tr> |
| 20 | </thead> | 21 | </thead> |
| 21 | 22 | ||
| ... | @@ -35,6 +36,7 @@ | ... | @@ -35,6 +36,7 @@ |
| 35 | <td>{{dev.chassisid}}</td> | 36 | <td>{{dev.chassisid}}</td> |
| 36 | <td>{{dev.serial}}</td> | 37 | <td>{{dev.serial}}</td> |
| 37 | <td>{{dev.protocol}}</td> | 38 | <td>{{dev.protocol}}</td> |
| 39 | + <td>{{dev.masterid}}</td> | ||
| 38 | </tr> | 40 | </tr> |
| 39 | </tbody> | 41 | </tbody> |
| 40 | </table> | 42 | </table> | ... | ... |
-
Please register or login to post a comment