Search in sources :

Example 1 with DhcpAllocationInfo

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());
    });
}
Also used : DhcpL2RelayService(org.opencord.dhcpl2relay.DhcpL2RelayService) DeviceId(org.onosproject.net.DeviceId) DhcpAllocationInfo(org.opencord.dhcpl2relay.DhcpAllocationInfo)

Example 2 with DhcpAllocationInfo

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;
}
Also used : DhcpAllocationInfo(org.opencord.dhcpl2relay.DhcpAllocationInfo)

Example 3 with DhcpAllocationInfo

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");
}
Also used : Instant(java.time.Instant) KryoNamespace(org.onlab.util.KryoNamespace) DhcpAllocationInfo(org.opencord.dhcpl2relay.DhcpAllocationInfo) DHCP(org.onlab.packet.DHCP) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

DhcpAllocationInfo (org.opencord.dhcpl2relay.DhcpAllocationInfo)3 Instant (java.time.Instant)1 DHCP (org.onlab.packet.DHCP)1 KryoNamespace (org.onlab.util.KryoNamespace)1 DeviceId (org.onosproject.net.DeviceId)1 DhcpL2RelayService (org.opencord.dhcpl2relay.DhcpL2RelayService)1 Activate (org.osgi.service.component.annotations.Activate)1