private List<IpMapping> getIpMappingForPortName(String portName, String routerId) { InstanceIdentifier<Ports> portToIpMapIdentifier = NatUtil.buildPortToIpMapIdentifier(routerId, portName); Optional<Ports> port = NatUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, portToIpMapIdentifier); if(!port.isPresent()) { LOG.error("NAT Service : Unable to read router port entry for router ID {} and port name {}", routerId, portName); return null; } List<IpMapping> ipMappingList = port.get().getIpMapping(); return ipMappingList; }
if (!Objects.equals(_ipMapping, other.getIpMapping())) { return false;
public PortsBuilder(Ports base) { if (base.getKey() == null) { this._key = new PortsKey( base.getPortName() ); this._portName = base.getPortName(); } else { this._key = base.getKey(); this._portName = _key.getPortName(); } this._ipMapping = base.getIpMapping(); if (base instanceof PortsImpl) { PortsImpl impl = (PortsImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
void handleDNATConfigurationForRouterAssociation(String routerName, String vpnName, String externalNetwork) { InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerName); Optional<RouterPorts> optRouterPorts = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId); if(!optRouterPorts.isPresent()) { LOG.debug("Could not read Router Ports data object with id: {} to handle associate vpn {}", routerName, vpnName); return; } Uuid networkId = Uuid.getDefaultInstance(externalNetwork); RouterPorts routerPorts = optRouterPorts.get(); List<Ports> interfaces = routerPorts.getPorts(); Map<String, BigInteger> portToDpnMap = new HashMap<>(); for(Ports port : interfaces) { String portName = port.getPortName(); BigInteger dpnId = NatUtil.getDpnForInterface(interfaceManager, portName); if(dpnId.equals(BigInteger.ZERO)) { LOG.debug("DPN not found for {}, skip handling of router {} association with vpn", portName, routerName, vpnName); continue; } portToDpnMap.put(portName, dpnId); List<IpMapping> ipMapping = port.getIpMapping(); for(IpMapping ipMap : ipMapping) { String externalIp = ipMap.getExternalIp(); //remove all NAT related entries with routerName //floatingIpListener.removeNATOnlyFlowEntries(dpnId, portName, routerName, null, ipMap.getInternalIp(), externalIp); //Create NAT entries with VPN Id LOG.debug("Updating DNAT flows with VPN metadata {} ", vpnName); floatingIpListener.createNATOnlyFlowEntries(dpnId, portName, routerName, vpnName, networkId, ipMap.getInternalIp(), externalIp); } } }
void handleDNATConfigurationForRouterDisassociation(String routerName, String vpnName, String externalNetwork) { InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerName); Optional<RouterPorts> optRouterPorts = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId); if(!optRouterPorts.isPresent()) { LOG.debug("Could not read Router Ports data object with id: {} to handle disassociate vpn {}", routerName, vpnName); return; } Uuid networkId = Uuid.getDefaultInstance(externalNetwork); RouterPorts routerPorts = optRouterPorts.get(); List<Ports> interfaces = routerPorts.getPorts(); for(Ports port : interfaces) { String portName = port.getPortName(); BigInteger dpnId = NatUtil.getDpnForInterface(interfaceManager, portName); if(dpnId.equals(BigInteger.ZERO)) { LOG.debug("DPN not found for {}, skip handling of router {} association with vpn", portName, routerName, vpnName); continue; } List<IpMapping> ipMapping = port.getIpMapping(); for(IpMapping ipMap : ipMapping) { String externalIp = ipMap.getExternalIp(); //remove all NAT related entries with routerName //floatingIpListener.removeNATOnlyFlowEntries(dpnId, portName, routerName, vpnName, ipMap.getInternalIp(), externalIp); //Create NAT entries with VPN Id floatingIpListener.createNATOnlyFlowEntries(dpnId, portName, routerName, null, networkId, ipMap.getInternalIp(), externalIp); } } }
private void disassociateExternalNetworkFromVPN(Networks network, String vpnName) { List<Uuid> routerIds = network.getRouterIds(); //long vpnId = NatUtil.getVpnId(dataBroker, vpnName); for(Uuid routerId : routerIds) { //long router = NatUtil.getVpnId(dataBroker, routerId.getValue()); InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerId.getValue()); Optional<RouterPorts> optRouterPorts = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId); if(!optRouterPorts.isPresent()) { LOG.debug("Could not read Router Ports data object with id: {} to handle disassociate ext nw {}", routerId, network.getId()); continue; } RouterPorts routerPorts = optRouterPorts.get(); List<Ports> interfaces = routerPorts.getPorts(); for(Ports port : interfaces) { String portName = port.getPortName(); BigInteger dpnId = NatUtil.getDpnForInterface(interfaceManager, portName); if(dpnId.equals(BigInteger.ZERO)) { LOG.debug("DPN not found for {}, skip handling of ext nw {} disassociation", portName, network.getId()); continue; } List<IpMapping> ipMapping = port.getIpMapping(); for(IpMapping ipMap : ipMapping) { String externalIp = ipMap.getExternalIp(); floatingIpListener.removeNATFlowEntries(dpnId, portName, vpnName, routerId.getValue(), network.getId(), ipMap.getInternalIp(), externalIp); } } } }
for (Ports ports : portsList) { if (ports.getPortName().equals(fixedNeutronPortName)) { ipMapping = ports.getIpMapping();
continue; List<IpMapping> ipMapping = port.getIpMapping(); for(IpMapping ipMap : ipMapping) { String externalIp = ipMap.getExternalIp();