Search in sources :

Example 16 with RouterPorts

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts in project netvirt by opendaylight.

the class FloatingIPListener method processFloatingIPAdd.

private void processFloatingIPAdd(final InstanceIdentifier<InternalToExternalPortMap> identifier, final InternalToExternalPortMap mapping) {
    LOG.trace("processFloatingIPAdd key: {}, value: {}", mapping.getKey(), mapping);
    final String routerId = identifier.firstKeyOf(RouterPorts.class).getRouterId();
    final PortsKey pKey = identifier.firstKeyOf(Ports.class);
    String interfaceName = pKey.getPortName();
    InstanceIdentifier<RouterPorts> portIid = identifier.firstIdentifierOf(RouterPorts.class);
    coordinator.enqueueJob(NatConstants.NAT_DJC_PREFIX + mapping.getKey(), () -> {
        WriteTransaction writeFlowInvTx = dataBroker.newWriteOnlyTransaction();
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        createNATFlowEntries(interfaceName, mapping, portIid, routerId, writeFlowInvTx);
        // final submit call for writeFlowInvTx
        futures.add(NatUtil.waitForTransactionToComplete(writeFlowInvTx));
        return futures;
    }, NatConstants.NAT_DJC_MAX_RETRIES);
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) RouterPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) PortsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.PortsKey)

Example 17 with RouterPorts

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts in project netvirt by opendaylight.

the class FloatingIPListener method getExtNetworkId.

private Uuid getExtNetworkId(final InstanceIdentifier<RouterPorts> portIid, LogicalDatastoreType dataStoreType) {
    Optional<RouterPorts> rtrPort = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, dataStoreType, portIid);
    if (!rtrPort.isPresent()) {
        LOG.error("getExtNetworkId : Unable to read router port entry for {}", portIid);
        return null;
    }
    Uuid extNwId = rtrPort.get().getExternalNetworkId();
    return extNwId;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RouterPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts)

Example 18 with RouterPorts

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts in project netvirt by opendaylight.

the class InterfaceStateEventListener method processInterfaceRemoved.

private void processInterfaceRemoved(String portName, BigInteger dpnId, String routerId, List<ListenableFuture<Void>> futures) {
    LOG.trace("processInterfaceRemoved : Processing Interface Removed Event for interface {} on DPN ID {}", portName, dpnId);
    List<InternalToExternalPortMap> intExtPortMapList = getIntExtPortMapListForPortName(portName, routerId);
    if (intExtPortMapList == null || intExtPortMapList.isEmpty()) {
        LOG.debug("processInterfaceRemoved : Ip Mapping list is empty/null for portName {}", portName);
        return;
    }
    InstanceIdentifier<RouterPorts> portIid = NatUtil.buildRouterPortsIdentifier(routerId);
    WriteTransaction removeFlowInvTx = dataBroker.newWriteOnlyTransaction();
    for (InternalToExternalPortMap intExtPortMap : intExtPortMapList) {
        LOG.trace("processInterfaceRemoved : Removing DNAT Flow entries for dpnId {} ", dpnId);
        floatingIPListener.removeNATFlowEntries(portName, intExtPortMap, portIid, routerId, dpnId, removeFlowInvTx);
    }
    // final submit call for removeFlowInvTx
    futures.add(NatUtil.waitForTransactionToComplete(removeFlowInvTx));
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) RouterPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts) InternalToExternalPortMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)

Example 19 with RouterPorts

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts in project netvirt by opendaylight.

the class NeutronvpnNatManager method removeRouterFromFloatingIpInfo.

private void removeRouterFromFloatingIpInfo(Router update, DataBroker broker) {
    Uuid routerId = update.getUuid();
    InstanceIdentifier.InstanceIdentifierBuilder<RouterPorts> routerPortsIdentifierBuilder = InstanceIdentifier.builder(FloatingIpInfo.class).child(RouterPorts.class, new RouterPortsKey(routerId.getValue()));
    try {
        Optional<RouterPorts> optionalRouterPorts = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsIdentifierBuilder.build());
        if (optionalRouterPorts.isPresent()) {
            SingleTransactionDataBroker.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, routerPortsIdentifierBuilder.build());
        }
    } catch (ReadFailedException | TransactionCommitFailedException e) {
        LOG.error("Failed to read from FloatingIpInfo DS for routerid {}", routerId, e);
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RouterPortsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPortsKey) RouterPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) FloatingIpInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.FloatingIpInfo)

Example 20 with RouterPorts

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts in project netvirt by opendaylight.

the class NeutronFloatingToFixedIpMappingChangeListener method removeRouterPortsOrPortsNode.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void removeRouterPortsOrPortsNode(String routerName, InstanceIdentifier.InstanceIdentifierBuilder<RouterPorts> routerPortsIdentifierBuilder, List<Ports> portsList, String fixedNeutronPortName, boolean isLockAcquired) {
    String lockName = null;
    try {
        if (portsList.size() == 1) {
            // remove entire routerPorts node
            lockName = routerName;
            isLockAcquired = routerLock.tryLock(lockName, LOCK_WAIT_TIME, TimeUnit.SECONDS);
            LOG.debug("removing routerPorts node: {} ", routerName);
            MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsIdentifierBuilder.build());
        } else {
            // remove entire ports node under this routerPorts node
            lockName = fixedNeutronPortName;
            isLockAcquired = routerLock.tryLock(lockName, LOCK_WAIT_TIME, TimeUnit.SECONDS);
            LOG.debug("removing ports node {} under routerPorts node {}", fixedNeutronPortName, routerName);
            InstanceIdentifier.InstanceIdentifierBuilder<Ports> portsIdentifierBuilder = routerPortsIdentifierBuilder.child(Ports.class, new PortsKey(fixedNeutronPortName));
            MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, portsIdentifierBuilder.build());
        }
    } catch (Exception e) {
        LOG.error("Failure in deletion of routerPorts node {}", routerName, e);
    } finally {
        if (isLockAcquired) {
            routerLock.unlock(lockName);
        }
    }
}
Also used : InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) RouterPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) PortsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.PortsKey) RouterPortsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPortsKey)

Aggregations

RouterPorts (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts)17 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)12 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports)10 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)10 BigInteger (java.math.BigInteger)7 RouterPortsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPortsKey)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)5 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)5 PortsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.PortsKey)5 ArrayList (java.util.ArrayList)4 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)4 FloatingIpInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.FloatingIpInfo)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 RouterPortsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPortsBuilder)2 InternalToExternalPortMapKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMapKey)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)1 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)1 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)1 CreateFibEntryInput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.CreateFibEntryInput)1