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);
}
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;
}
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));
}
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);
}
}
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);
}
}
}
Aggregations