use of org.onosproject.dhcprelay.cli.DhcpRelayCommand in project onos by opennetworkinglab.
the class DhcpRelayWebResource method dhcpRelayRecords.
/**
* To get the list of dhcp relay records.
*
* @return dhcpRelayRecords type ArrayNode.
*/
private ArrayNode dhcpRelayRecords() {
DhcpRelayCommand dhcpRelayCommand = new DhcpRelayCommand();
DhcpRelayService dhcpDelayService = get(DhcpRelayService.class);
Collection<DhcpRecord> records = dhcpDelayService.getDhcpRecords();
ObjectNode node = mapper().createObjectNode();
ArrayNode dhcpRelayRecords = mapper().createArrayNode();
records.forEach(record -> {
ObjectNode dhcpRecord = mapper().createObjectNode();
dhcpRecord.put("id", record.macAddress() + "/" + record.vlanId());
dhcpRecord.put("locations", record.locations().toString().concat(record.directlyConnected() ? DIRECTLY : EMPTY));
dhcpRecord.put("last-seen", Tools.timeAgo(record.lastSeen()));
dhcpRecord.put("IPv4", dhcpRelayCommand.ip4State(record));
dhcpRecord.put("IPv6", dhcpRelayCommand.ip6State(record));
dhcpRelayRecords.add(dhcpRecord);
});
return dhcpRelayRecords;
}
Aggregations