Search in sources :

Example 1 with MacEntry

use of org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry in project netvirt by opendaylight.

the class IpMonitoringHandler method add.

@Override
public void add(InstanceIdentifier<LearntVpnVipToPort> identifier, LearntVpnVipToPort value) {
    runOnlyInOwnerNode("IpMonitoringHandler: add event", () -> {
        try {
            InetAddress srcInetAddr = InetAddress.getByName(value.getPortFixedip());
            if (value.getMacAddress() == null) {
                LOG.warn("The mac address received is null for VpnPortipToPort {}, ignoring the DTCN", value);
                return;
            }
            MacAddress srcMacAddress = MacAddress.getDefaultInstance(value.getMacAddress());
            String vpnName = value.getVpnName();
            MacEntry macEntry = new MacEntry(vpnName, srcMacAddress, srcInetAddr, value.getPortName(), value.getCreationTime());
            Optional<Uint32> monitorProfileId = getMonitorProfileId(value.getPortFixedip());
            if (monitorProfileId.isPresent()) {
                jobCoordinator.enqueueJob(VpnUtil.buildIpMonitorJobKey(srcInetAddr.toString(), vpnName), new IpMonitorStartTask(macEntry, monitorProfileId.get().toJava(), alivenessMonitorUtils));
            }
        } catch (UnknownHostException e) {
            LOG.error("Error in deserializing packet {} with exception", value, e);
        }
    });
}
Also used : UnknownHostException(java.net.UnknownHostException) MacEntry(org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) InetAddress(java.net.InetAddress) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 2 with MacEntry

use of org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry in project netvirt by opendaylight.

the class IpMonitorEventListener method onMonitorEvent.

@Override
public void onMonitorEvent(MonitorEvent notification) {
    Long monitorId = notification.getEventData().getMonitorId().toJava();
    MacEntry macEntry = AlivenessMonitorUtils.getMacEntryFromMonitorId(monitorId);
    if (macEntry == null) {
        LOG.debug("No MacEntry found associated with the monitor Id {}", monitorId);
        return;
    }
    LivenessState livenessState = notification.getEventData().getMonitorState();
    if (livenessState.equals(LivenessState.Down)) {
        String vpnName = macEntry.getVpnName();
        String learntIp = macEntry.getIpAddress().getHostAddress();
        LearntVpnVipToPort vpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, learntIp);
        if (vpnVipToPort != null && macEntry.getCreatedTime().equals(vpnVipToPort.getCreationTime())) {
            String jobKey = VpnUtil.buildIpMonitorJobKey(macEntry.getIpAddress().getHostAddress(), macEntry.getVpnName());
            jobCoordinator.enqueueJob(jobKey, new IpMonitorStopTask(macEntry, dataBroker, Boolean.TRUE, vpnUtil, alivenessMonitorUtils));
        }
    }
}
Also used : MacEntry(org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry) LivenessState(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.LivenessState) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort)

Example 3 with MacEntry

use of org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry in project netvirt by opendaylight.

the class IpMonitorStopTask method call.

@Override
public List<ListenableFuture<Void>> call() {
    final List<ListenableFuture<Void>> futures = new ArrayList<>();
    java.util.Optional<Uint32> monitorIdOptional = alivenessMonitorUtils.getMonitorIdFromInterface(macEntry);
    if (monitorIdOptional.isPresent()) {
        alivenessMonitorUtils.stopIpMonitoring(monitorIdOptional.get());
    } else {
        LOG.warn("MonitorId not available for IP {} interface {}. IpMonitoring not stopped", macEntry.getIpAddress(), macEntry.getInterfaceName());
    }
    String learntIp = macEntry.getIpAddress().getHostAddress();
    if (this.isRemoveMipAdjAndLearntIp) {
        String vpnName = macEntry.getVpnName();
        LearntVpnVipToPort vpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, learntIp);
        if (vpnVipToPort != null && !Objects.equals(vpnVipToPort.getCreationTime(), macEntry.getCreatedTime())) {
            LOG.warn("The MIP {} over vpn {} has been learnt again and processed. " + "Ignoring this remove event.", learntIp, vpnName);
            return futures;
        }
        vpnUtil.removeLearntVpnVipToPort(macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress(), null);
        vpnUtil.removeVpnPortFixedIpToPort(dataBroker, macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress(), null);
        LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> vpnUtil.removeMipAdjacency(macEntry.getVpnName(), macEntry.getInterfaceName(), macEntry.getIpAddress().getHostAddress(), tx)), LOG, "ArpMonitorStopTask: Error writing to datastore for Vpn {} IP  {}", macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress());
    } else {
        // Delete only MIP adjacency
        vpnUtil.removeMipAdjacency(macEntry.getInterfaceName(), learntIp);
    }
    return futures;
}
Also used : VpnUtil(org.opendaylight.netvirt.vpnmanager.VpnUtil) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) LoggerFactory(org.slf4j.LoggerFactory) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) Callable(java.util.concurrent.Callable) ArrayList(java.util.ArrayList) Objects(java.util.Objects) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) MacEntry(org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry) Datastore(org.opendaylight.mdsal.binding.util.Datastore) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 4 with MacEntry

use of org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry in project netvirt by opendaylight.

the class IpMonitoringHandler method remove.

@Override
public void remove(InstanceIdentifier<LearntVpnVipToPort> key, LearntVpnVipToPort value) {
    runOnlyInOwnerNode("IpMonitoringHandler: remove event", () -> {
        try {
            InetAddress srcInetAddr = InetAddress.getByName(value.getPortFixedip());
            if (value.getMacAddress() == null) {
                LOG.warn("The mac address received is null for LearntVpnVipToPort {}, ignoring the DTCN", value);
                return;
            }
            String vpnName = value.getVpnName();
            String learntIp = srcInetAddr.getHostAddress();
            LearntVpnVipToPort vpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, learntIp);
            if (vpnVipToPort != null && !vpnVipToPort.getCreationTime().equals(value.getCreationTime())) {
                LOG.warn("The MIP {} over vpn {} has been learnt again and processed. " + "Ignoring this remove event.", learntIp, vpnName);
                return;
            }
            MacAddress srcMacAddress = MacAddress.getDefaultInstance(value.getMacAddress());
            String interfaceName = value.getPortName();
            MacEntry macEntry = new MacEntry(vpnName, srcMacAddress, srcInetAddr, interfaceName, value.getCreationTime());
            jobCoordinator.enqueueJob(VpnUtil.buildIpMonitorJobKey(srcInetAddr.toString(), vpnName), new IpMonitorStopTask(macEntry, dataBroker, Boolean.FALSE, vpnUtil, alivenessMonitorUtils));
        } catch (UnknownHostException e) {
            LOG.error("Error in deserializing packet {} with exception", value, e);
        }
    });
}
Also used : UnknownHostException(java.net.UnknownHostException) MacEntry(org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) InetAddress(java.net.InetAddress)

Aggregations

MacEntry (org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry)4 LearntVpnVipToPort (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort)3 InetAddress (java.net.InetAddress)2 UnknownHostException (java.net.UnknownHostException)2 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)2 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Callable (java.util.concurrent.Callable)1 LoggingFutures (org.opendaylight.infrautils.utils.concurrent.LoggingFutures)1 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)1 Datastore (org.opendaylight.mdsal.binding.util.Datastore)1 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)1 ManagedNewTransactionRunnerImpl (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl)1 VpnUtil (org.opendaylight.netvirt.vpnmanager.VpnUtil)1 LivenessState (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.LivenessState)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1