use of org.opencord.dhcpl2relay.DhcpAllocationInfo in project dhcpl2relay by opencord.
the class DhcpL2RelayAllocationsCommand method doExecute.
@Override
protected void doExecute() {
DhcpL2RelayService service = get(DhcpL2RelayService.class);
Map<String, DhcpAllocationInfo> allocations = service.getAllocationInfo();
if (strDeviceId != null && !strDeviceId.isEmpty()) {
DeviceId deviceId = DeviceId.deviceId(strDeviceId);
allocations = allocations.entrySet().stream().filter(a -> a.getValue().location().deviceId().equals(deviceId)).collect(Collectors.toMap(map -> map.getKey(), map -> map.getValue()));
}
allocations.forEach((key, value) -> {
print("SubscriberId=%s,ConnectPoint=%s,State=%s,MAC=%s,VLAN=%s," + "CircuitId=%s,IP Allocated=%s,Allocation Timestamp=%s", value.subscriberId(), value.location(), value.type(), value.macAddress().toString(), value.vlanId().toString(), value.circuitId(), value.ipAddress().getIp4Address().toString(), value.allocationTime().toString());
});
}
use of org.opencord.dhcpl2relay.DhcpAllocationInfo in project dhcpl2relay by opencord.
the class DhcpL2Relay method removeAllocationsByConnectPoint.
@Override
public boolean removeAllocationsByConnectPoint(ConnectPoint cp) {
boolean removed = false;
for (String key : allocations.keySet()) {
DhcpAllocationInfo entry = allocations.asJavaMap().get(key);
if (entry.location().equals(cp)) {
allocations.remove(key);
removed = true;
}
}
return removed;
}
use of org.opencord.dhcpl2relay.DhcpAllocationInfo in project dhcpl2relay by opencord.
the class DhcpL2Relay method activate.
@Activate
protected void activate(ComponentContext context) {
// start the dhcp relay agent
appId = coreService.registerApplication(DHCP_L2RELAY_APP);
componentConfigService.registerProperties(getClass());
eventDispatcher.addSink(DhcpL2RelayEvent.class, listenerRegistry);
KryoNamespace serializer = KryoNamespace.newBuilder().register(KryoNamespaces.API).register(Instant.class).register(DHCP.MsgType.class).register(DhcpAllocationInfo.class).build();
allocations = storageService.<String, DhcpAllocationInfo>consistentMapBuilder().withName("dhcpl2relay-allocations").withSerializer(Serializer.using(serializer)).withApplicationId(appId).build();
dhcpL2RelayCounters.setDelegate(delegate);
eventHandlerExecutor = newSingleThreadExecutor(groupedThreads("onos/dhcp", "dhcp-event-%d", log));
cfgService.addListener(cfgListener);
mastershipService.addListener(changeListener);
deviceService.addListener(deviceListener);
if (sadisService != null) {
subsService = sadisService.getSubscriberInfoService();
} else {
log.warn(SADIS_NOT_RUNNING);
}
factories.forEach(cfgService::registerConfigFactory);
// update the dhcp server configuration.
updateConfig();
if (context != null) {
modified(context);
}
// add the packet services.
packetService.addProcessor(dhcpRelayPacketProcessor, PacketProcessor.director(0));
log.info("DHCP-L2-RELAY Started");
}
Aggregations