use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.RouterId in project netvirt by opendaylight.
the class NatTepChangeListener method handleTepDelForAllRtrs.
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleTepDelForAllRtrs(Uint64 srcDpnId, String srcTepIp) {
LOG.trace("handleTepDelForAllRtrs : TEP DEL ----- on DPN-ID {} having SRC IP : {}", srcDpnId, srcTepIp);
List<RoutersList> routersList = null;
InstanceIdentifier<DpnRoutersList> dpnRoutersListId = NatUtil.getDpnRoutersId(srcDpnId);
Optional<DpnRoutersList> optionalRouterDpnList = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, dpnRoutersListId);
if (optionalRouterDpnList.isPresent()) {
routersList = new ArrayList<RoutersList>(optionalRouterDpnList.get().nonnullRoutersList().values());
} else {
LOG.debug("NAT Service : RouterDpnList is empty for DPN {}. Hence ignoring TEP DEL event", srcDpnId);
return;
}
if (routersList == null) {
LOG.error("handleTepDelForAllRtrs : DPN {} does not have the Routers presence", srcDpnId);
return;
}
for (RoutersList router : routersList) {
String routerName = router.getRouter();
LOG.debug("handleTepDelForAllRtrs : TEP DEL : DNAT -> Withdrawing routes for router {} ", routerName);
Uint32 routerId = NatUtil.getVpnId(dataBroker, routerName);
if (routerId == NatConstants.INVALID_ID) {
LOG.error("handleTepDelForAllRtrs :Invalid ROUTER-ID {} returned for routerName {}", routerId, routerName);
return;
}
Uuid externalNetworkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, externalNetworkId);
if (extNwProvType == null) {
return;
}
boolean isFipExists = hndlTepDelForDnatInEachRtr(router, routerId, srcDpnId, extNwProvType);
LOG.debug("handleTepDelForAllRtrs : TEP DEL : SNAT -> Withdrawing and Advertising routes for router {} ", router.getRouter());
coordinator.enqueueJob((NatConstants.NAT_DJC_PREFIX + router.getRouter()), () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>();
txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, configTx -> {
hndlTepDelForSnatInEachRtr(router, routerId, srcDpnId, srcTepIp, isFipExists, extNwProvType, configTx);
});
return futures;
}, NatConstants.NAT_DJC_MAX_RETRIES);
}
return;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.RouterId in project netvirt by opendaylight.
the class SnatExternalRoutersListener method add.
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public void add(InstanceIdentifier<Routers> identifier, Routers routers) {
if (natMode != NatMode.Conntrack) {
return;
}
String routerName = routers.getRouterName();
if (upgradeState.isUpgradeInProgress()) {
LOG.warn("add event for ext-router {}, but upgrade is in progress.", routerName);
return;
}
LOG.info("add : external router event for {}", routerName);
Uint32 routerId = NatUtil.getVpnId(dataBroker, routerName);
NatUtil.createRouterIdsConfigDS(dataBroker, routerId, routerName);
Uuid bgpVpnUuid = NatUtil.getVpnForRouter(dataBroker, routerName);
if (bgpVpnUuid != null) {
// Router associated to BGPVPN, ignoring it.
return;
}
// Allocate Primary NAPTSwitch for this router
centralizedSwitchScheduler.scheduleCentralizedSwitch(routers);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.RouterId in project netvirt by opendaylight.
the class SnatExternalRoutersListener method update.
@Override
public void update(InstanceIdentifier<Routers> identifier, Routers original, Routers update) {
if (natMode != NatMode.Conntrack) {
return;
}
String routerName = original.getRouterName();
Uint32 routerId = NatUtil.getVpnId(dataBroker, routerName);
if (routerId == NatConstants.INVALID_ID) {
LOG.error("update : external router event - Invalid routerId for routerName {}", routerName);
return;
}
LOG.info("update :called for router {} with originalSNATStatus {} and updatedSNATStatus {}", routerName, original.isEnableSnat(), update.isEnableSnat());
if (!upgradeState.isUpgradeInProgress()) {
centralizedSwitchScheduler.updateCentralizedSwitch(original, update);
}
if (!Objects.equals(original.getSubnetIds(), update.getSubnetIds()) || !Objects.equals(original.getExternalIps(), update.getExternalIps())) {
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, confTx -> natServiceManager.notify(confTx, update, original, null, null, SnatServiceManager.Action.SNAT_ROUTER_UPDATE)), LOG, "error handling external router update");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.RouterId in project netvirt by opendaylight.
the class VxlanGreConntrackBasedSnatService method removeSnatSpecificEntriesForNaptSwitch.
@Override
protected void removeSnatSpecificEntriesForNaptSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers, Uint64 dpnId) throws ExecutionException, InterruptedException {
LOG.info("installSnatSpecificEntriesForNaptSwitch for router {}", routers.getRouterName());
String routerName = routers.getRouterName();
Uint32 routerId = NatUtil.getVpnId(dataBroker, routerName);
/* Remove Outbound NAT entries */
removeSnatMissEntryForPrimrySwch(confTx, dpnId, routerId);
removeTerminatingServiceTblEntryForVxlanGre(confTx, dpnId, routerId);
// Long extNetVpnId = NatUtil.getNetworkVpnIdFromRouterId(dataBroker, routerId);
Uuid vpnUuid = NatUtil.getVpnIdfromNetworkId(dataBroker, routers.getNetworkId());
if (vpnUuid == null) {
LOG.error("installSnatSpecificEntriesForNaptSwitch: Unable to retrieve external vpn_id for " + "external network {} with routerId {}", routers.getNetworkId(), routerId);
return;
}
Uint32 extNetVpnId = NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
LOG.info("installSnatSpecificEntriesForNaptSwitch: external network vpn_id {} for router {}", extNetVpnId, routers.getRouterName());
Map<ExternalIpsKey, ExternalIps> keyExternalIpsMap = routers.nonnullExternalIps();
removeOutboundTblTrackEntryForVxlanGre(confTx, dpnId, routerId);
removeOutboundTblEntryForVxlanGre(confTx, dpnId, routerId, new ArrayList<ExternalIps>(keyExternalIpsMap.values()));
removeNaptPfibFlowForVxlanGre(confTx, routers, dpnId, extNetVpnId);
removeNaptPfibEntry(confTx, dpnId, routerId);
// Install Inbound NAT entries
removeInboundEntryForVxlanGre(confTx, dpnId, routerId, new ArrayList<ExternalIps>(keyExternalIpsMap.values()));
if (keyExternalIpsMap.isEmpty()) {
LOG.error("installSnatSpecificEntriesForNaptSwitch: No externalIP present for router {}", routerName);
return;
}
// The logic now handle only one external IP per router, others if present will be ignored.
String externalIp = NatUtil.validateAndAddNetworkMask(new ArrayList<ExternalIps>(keyExternalIpsMap.values()).get(0).getIpAddress());
externalRouterListener.clearFibTsAndReverseTraffic(dpnId, routerId, routers.getNetworkId(), Collections.singletonList(externalIp), null, routers.getExtGwMacAddress(), confTx);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.RouterId in project netvirt by opendaylight.
the class NatRpcServiceImpl method constructNatInformation.
private List<RouterNat> constructNatInformation(Uuid routerUuid, Uint32 routerId) {
String neutronRouterName = NatUtil.getNeutronRouterNamebyUuid(dataBroker, routerUuid);
RouterNatBuilder natRouterBuilder = new RouterNatBuilder();
natRouterBuilder.setRouterUuid(routerUuid);
natRouterBuilder.setRouterName(neutronRouterName);
IpPortMapping ipPortMapping = NatUtil.getIportMapping(dataBroker, routerId);
if (ipPortMapping == null) {
LOG.warn("constructNatInformation : No SNAT IP Mapping found for router-uuid {}", routerUuid.getValue());
} else {
// Capturing SNAT information
List<SnatIpMapping> snatIpMapping = new ArrayList<>();
for (IntextIpProtocolType protocolType : ipPortMapping.nonnullIntextIpProtocolType().values()) {
for (IpPortMap ipPortMap : protocolType.nonnullIpPortMap().values()) {
String[] internalPortMap = ipPortMap.getIpPortInternal().split(NwConstants.MACADDR_SEP);
SnatIpMappingBuilder natIpMappingBuilder = new SnatIpMappingBuilder().setInternalIp(internalPortMap[0]).setInternalPort(internalPortMap[1]).setExternalIp(ipPortMap.getIpPortExternal().getIpAddress()).setExternalPort(ipPortMap.getIpPortExternal().getPortNum().toString()).setProtocol(protocolType.getProtocol().getName());
snatIpMapping.add(natIpMappingBuilder.build());
}
}
natRouterBuilder.setSnatIpMapping(snatIpMapping);
}
// Capturing DNAT information
List<DnatIpMapping> dnatIpMapping = new ArrayList<>();
List<Ports> fipPorts = NatUtil.getFloatingIpPortsForRouter(dataBroker, routerUuid);
if (fipPorts.isEmpty()) {
LOG.warn("constructNatInformation : No DNAT IP Mapping found for router-uuid {}", routerUuid.getValue());
} else {
for (Ports fipPort : fipPorts) {
for (InternalToExternalPortMap fipMap : fipPort.nonnullInternalToExternalPortMap().values()) {
DnatIpMappingBuilder natIpMappingBuilder = new DnatIpMappingBuilder().setExternalIp(fipMap.getExternalIp()).setInternalIp(fipMap.getInternalIp());
dnatIpMapping.add(natIpMappingBuilder.build());
}
}
natRouterBuilder.setDnatIpMapping(dnatIpMapping);
}
List<RouterNat> natRouterList = new ArrayList<>();
natRouterList.add(natRouterBuilder.build());
return natRouterList;
}
Aggregations