}
Set<VpnTarget> routeTargets = vpnManager.getRtListForVpn(vpnId.getValue());
boolean isIpFamilyUpdated = false;
+ IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
for (Uuid nw : networkList) {
Network network = neutronvpnUtils.getNeutronNetwork(nw);
if (network == null) {
*/
if (neutronvpnUtils.getIsExternal(network)) {
extNwMap.put(nw, network);
- }
- if (NeutronvpnUtils.getIsExternal(network)) {
isExternalNetwork = true;
+ //Check whether router-gw is set with external network before external network to BGPVPN association
+ List<Uuid> routerList = neutronvpnUtils.getRouterIdsForExtNetwork(nw);
+ if (!routerList.isEmpty()) {
+ for (Uuid routerId : routerList) {
+ //If v6 subnet was already added to router means it requires IPv6 AddrFamily in VpnInstance
+ if (neutronvpnUtils.isV6SubnetPartOfRouter(routerId)) {
+ ipVersion = ipVersion.addVersion(IpVersionChoice.IPV6);
+ LOG.debug("associateNetworksToVpn: External network {} is already associated with "
+ + "router(router-gw) {} and V6 subnet is part of that router. Hence Set IPv6 "
+ + "address family type in Internet VPN Instance {}", network, routerId, vpnId);
+ break;
+ }
+ }
+ }
}
List<Subnetmap> subnetmapList = neutronvpnUtils.getSubnetmapListFromNetworkId(nw);
if (subnetmapList == null || subnetmapList.isEmpty()) {
if (vpnManager.checkForOverlappingSubnets(nw, subnetmapList, vpnId, routeTargets, failedNwList)) {
continue;
}
- IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
for (Subnetmap subnetmap : subnetmapList) {
IpVersionChoice ipVers = NeutronvpnUtils.getIpVersionFromString(subnetmap.getSubnetIp());
if (!ipVersion.isIpVersionChosen(ipVers)) {
List<String> failedNwList = new ArrayList<>();
HashSet<Uuid> passedNwList = new HashSet<>();
ConcurrentMap<Uuid, Network> extNwMap = new ConcurrentHashMap<>();
+ IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
if (networkList.isEmpty()) {
LOG.error("dissociateNetworksFromVpn: Failed as networks list is empty");
failedNwList.add(String.format("Failed to disassociate networks from VPN %s as networks list is empty",
*/
if (neutronvpnUtils.getIsExternal(network)) {
extNwMap.put(nw, network);
+ //Handle external-Nw to BGPVPN Disassociation and still ext-router is being set with external-Nw
+ List<Uuid> routerList = neutronvpnUtils.getRouterIdsForExtNetwork(nw);
+ if (!routerList.isEmpty()) {
+ for (Uuid routerId : routerList) {
+ //If v6 subnet was already added to router means it requires IPv6 AddrFamily in VpnInstance
+ if (neutronvpnUtils.isV6SubnetPartOfRouter(routerId)) {
+ ipVersion = ipVersion.addVersion(IpVersionChoice.IPV6);
+ LOG.debug("dissociateNetworksFromVpn: External network {} is still associated with "
+ + "router(router-gw) {} and V6 subnet is part of that router. Hence Set IPv6 "
+ + "address family type in Internet VPN Instance {}", network, routerId, vpnId);
+ break;
+ }
+ }
+ }
}
- IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
for (Uuid subnet : networkSubnets) {
Subnetmap subnetmap = neutronvpnUtils.getSubnetmap(subnet);
if (subnetmap == null) {
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExtRouters;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.FloatingIpPortInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes;
settableFuture.setException(throwable);
}
}
+
+ public List<Uuid> getRouterIdsForExtNetwork(Uuid extNetwork) {
+ InstanceIdentifier<ExternalNetworks> externalNwIdentifier = InstanceIdentifier.create(ExternalNetworks.class);
+ Optional<ExternalNetworks> externalNwData;
+ try {
+ externalNwData = SingleTransactionDataBroker.syncReadOptional(dataBroker,
+ LogicalDatastoreType.CONFIGURATION, externalNwIdentifier);
+ } catch (ExecutionException | InterruptedException e) {
+ LOG.warn("getRouterIdsForExtNetwork: Exception while reading External-Network DS for the network {}",
+ extNetwork.getValue(), e);
+ return Collections.emptyList();
+ }
+ if (externalNwData.isPresent()) {
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external
+ .networks.Networks externalNw : externalNwData.get().getNetworks().values()) {
+ if (externalNw.getId().equals(extNetwork)) {
+ return externalNw.getRouterIds();
+ }
+ }
+ }
+ return Collections.emptyList();
+ }
}