Search in sources :

Example 6 with NeutronvpnService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronvpnService in project netvirt by opendaylight.

the class ArpMonitoringHandler method add.

@Override
protected void add(InstanceIdentifier<LearntVpnVipToPort> identifier, LearntVpnVipToPort value) {
    runOnlyInOwnerNode("ArpMonitoringHandler: 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());
            jobCoordinator.enqueueJob(buildJobKey(srcInetAddr.toString(), vpnName), new ArpMonitorStartTask(macEntry, arpMonitorProfileId, dataBroker, alivenessManager, neutronVpnService, interfaceManager));
        } catch (UnknownHostException e) {
            LOG.error("Error in deserializing packet {} with exception", value, e);
        }
    });
}
Also used : UnknownHostException(java.net.UnknownHostException) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) InetAddress(java.net.InetAddress)

Example 7 with NeutronvpnService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronvpnService in project netvirt by opendaylight.

the class NatRouterInterfaceListener method remove.

@Override
public void remove(InstanceIdentifier<Interfaces> identifier, Interfaces interfaceInfo) {
    LOG.trace("remove : Remove event - key: {}, value: {}", interfaceInfo.key(), interfaceInfo);
    final String routerId = identifier.firstKeyOf(RouterInterfaces.class).getRouterId().getValue();
    final String interfaceName = interfaceInfo.getInterfaceId();
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState = NatUtil.getInterfaceStateFromOperDS(dataBroker, interfaceName);
    if (interfaceState != null) {
        Uint64 dpId = NatUtil.getDpIdFromInterface(interfaceState);
        if (dpId.equals(Uint64.ZERO)) {
            LOG.warn("REMOVE : Could not retrieve DPN ID for interface {} to handle router {} dissociation model", interfaceName, routerId);
            return;
        }
        final ReentrantLock lock = NatUtil.lockForNat(dpId);
        lock.lock();
        try {
            if (NatUtil.isSnatEnabledForRouterId(dataBroker, routerId)) {
                NatUtil.removeSnatEntriesForPort(dataBroker, naptManager, mdsalManager, neutronVpnService, interfaceName, routerId);
            }
            LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, operTx -> {
                // Delete the NeutronRouterDpnMap from the ODL:L3VPN operational model
                NatUtil.removeFromNeutronRouterDpnsMap(routerId, interfaceName, dpId, operTx);
                // Delete the DpnRouterMap from the ODL:L3VPN operational model
                NatUtil.removeFromDpnRoutersMap(dataBroker, routerId, interfaceName, dpId, interfaceManager, operTx);
            }), LOG, "Error handling NAT router interface removal");
            // Delete the RouterInterfaces maintained in the ODL:L3VPN configuration model
            LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> confTx.delete(NatUtil.getRouterInterfaceId(interfaceName))), LOG, "Error handling NAT router interface removal");
        } finally {
            lock.unlock();
        }
    }
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) RouterInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.router.interfaces.RouterInterfaceBuilder) Uint64(org.opendaylight.yangtools.yang.common.Uint64) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) RouterInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.RouterInterfaces) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) RouterInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.router.interfaces.RouterInterface) Singleton(javax.inject.Singleton) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) RouterInterfacesMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.RouterInterfacesMap) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) RouterInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.router.interfaces.RouterInterfaceKey) Logger(org.slf4j.Logger) ReentrantLock(java.util.concurrent.locks.ReentrantLock) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) NeutronvpnService(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronvpnService) Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

InetAddress (java.net.InetAddress)2 ExecutionException (java.util.concurrent.ExecutionException)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)2 UnknownHostException (java.net.UnknownHostException)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 PreDestroy (javax.annotation.PreDestroy)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 Before (org.junit.Before)1 MDSALUtil (org.opendaylight.genius.mdsalutil.MDSALUtil)1 IMdsalApiManager (org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager)1 Executors (org.opendaylight.infrautils.utils.concurrent.Executors)1 LoggingFutures (org.opendaylight.infrautils.utils.concurrent.LoggingFutures)1 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)1 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)1 CONFIGURATION (org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION)1 OPERATIONAL (org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL)1 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)1