use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.vpn.instance.vpntargets.VpnTarget in project netvirt by opendaylight.
the class NeutronvpnManager method dissociateNetworksFromVpn.
/**
* Parses and disassociates networks list from given VPN.
*
* @param vpnId Uuid of given VPN.
* @param networkList List list of network Ids (Uuid), which will be disassociated.
* @return list of formatted strings with detailed error messages.
*/
@NonNull
protected List<String> dissociateNetworksFromVpn(@NonNull Uuid vpnId, @NonNull List<Uuid> networkList) {
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", vpnId.getValue()));
return failedNwList;
}
for (Uuid nw : networkList) {
List<Uuid> networkSubnets = neutronvpnUtils.getSubnetIdsFromNetworkId(nw);
if (networkSubnets == null) {
passedNwList.add(nw);
continue;
}
Network network = neutronvpnUtils.getNeutronNetwork(nw);
if (network == null) {
LOG.error("dissociateNetworksFromVpn: Network {} not found in ConfigDS", nw.getValue());
failedNwList.add(String.format("Failed to disassociate network %s as is not found in ConfigDS", nw.getValue()));
continue;
}
Uuid networkVpnId = neutronvpnUtils.getVpnForNetwork(nw);
if (networkVpnId == null) {
LOG.error("dissociateNetworksFromVpn: Network {} is not associated to any VPN", nw.getValue());
failedNwList.add(String.format("Failed to disassociate network %s as is not associated to any VPN", nw.getValue()));
continue;
}
if (!vpnId.equals(networkVpnId)) {
LOG.error("dissociateNetworksFromVpn: Network {} is associated to another VPN {} instead of given {}", nw.getValue(), networkVpnId.getValue(), vpnId.getValue());
failedNwList.add(String.format("Failed to disassociate network %s as it is associated to another " + "vpn %s instead of given %s", nw.getValue(), networkVpnId.getValue(), vpnId.getValue()));
continue;
}
/* Handle disassociation of external network(s) from Internet BGP-VPN use case outside of the
* networkList iteration
*/
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;
}
}
}
}
for (Uuid subnet : networkSubnets) {
Subnetmap subnetmap = neutronvpnUtils.getSubnetmap(subnet);
if (subnetmap == null) {
failedNwList.add(String.format("subnetmap %s not found for network %s", subnet.getValue(), nw.getValue()));
LOG.error("dissociateNetworksFromVpn: Subnetmap for subnet {} not found when " + "dissociating network {} from VPN {}", subnet.getValue(), nw.getValue(), vpnId.getValue());
continue;
}
IpVersionChoice ipVers = NeutronvpnUtils.getIpVersionFromString(subnetmap.getSubnetIp());
if (!ipVersion.isIpVersionChosen(ipVers)) {
ipVersion = ipVersion.addVersion(ipVers);
}
if (!NeutronvpnUtils.getIsExternal(network)) {
LOG.debug("dissociateNetworksFromVpn: Withdraw subnet {} from VPN {}", subnet.getValue(), vpnId.getValue());
removeSubnetFromVpn(vpnId, subnetmap, null);
Set<VpnTarget> routeTargets = vpnManager.getRtListForVpn(vpnId.getValue());
vpnManager.removeRouteTargetsToSubnetAssociation(routeTargets, subnetmap.getSubnetIp(), vpnId.getValue());
passedNwList.add(nw);
}
}
if (ipVersion != IpVersionChoice.UNDEFINED) {
LOG.debug("dissociateNetworksFromVpn: Updating vpnInstance with ip address family {}" + " for VPN {}", ipVersion, vpnId);
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, false);
}
}
// Handle disassociation of external network(s) from Internet BGP-VPN Instance use case
if (!extNwMap.isEmpty() || extNwMap != null) {
for (Network extNw : extNwMap.values()) {
if (disassociateExtNetworkFromVpn(vpnId, extNw)) {
passedNwList.add(extNw.getUuid());
} else {
LOG.error("dissociateNetworksFromVpn: Failed to withdraw External Provider Network {} from VPN {}", extNw, vpnId.getValue());
failedNwList.add(String.format("Failed to withdraw External Provider Network %s from VPN %s", extNw, vpnId.getValue()));
continue;
}
}
}
clearFromVpnMaps(vpnId, null, new ArrayList<>(passedNwList));
LOG.info("dissociateNetworksFromVpn: Network(s) {} disassociated from L3VPN {} successfully", passedNwList, vpnId.getValue());
return failedNwList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.vpn.instance.vpntargets.VpnTarget in project netvirt by opendaylight.
the class NeutronSubnetChangeListener method handleNeutronSubnetDeleted.
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleNeutronSubnetDeleted(Uuid subnetId, Uuid networkId, String subnetCidr) {
try {
Uuid vpnId = neutronvpnUtils.getVpnForNetwork(networkId);
if (vpnId != null) {
Set<VpnTarget> routeTargets = vpnManager.getRtListForVpn(vpnId.getValue());
LOG.warn("Subnet {} deleted without disassociating network {} from VPN {}. Ideally, please " + "disassociate network from VPN before deleting neutron subnet.", subnetId.getValue(), networkId.getValue(), vpnId.getValue());
Subnetmap subnetmap = neutronvpnUtils.getSubnetmap(subnetId);
if (subnetmap != null) {
nvpnManager.removeSubnetFromVpn(vpnId, subnetmap, null);
} else {
LOG.error("Subnetmap for subnet {} not found", subnetId.getValue());
}
if (!routeTargets.isEmpty()) {
vpnManager.removeRouteTargetsToSubnetAssociation(routeTargets, subnetCidr, vpnId.getValue());
}
}
if (networkId != null) {
deleteSubnetToNetworkMapping(subnetId, networkId);
}
nvpnManager.deleteSubnetMapNode(subnetId);
} catch (Exception e) {
LOG.error("handleNeutronSubnetDeleted: Failed for subnet {} with subnet IP {} and networkId {}", subnetId.getValue(), subnetCidr, networkId.getValue(), e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.vpn.instance.vpntargets.VpnTarget in project netvirt by opendaylight.
the class NeutronvpnManager method associateNetworksToVpn.
/**
* Parses and associates networks list with given VPN.
*
* @param vpnId Uuid of given VPN.
* @param networkList List list of network Ids (Uuid), which will be associated.
* @return list of formatted strings with detailed error messages.
*/
@NonNull
protected List<String> associateNetworksToVpn(@NonNull Uuid vpnId, @NonNull List<Uuid> networkList) {
List<String> failedNwList = new ArrayList<>();
HashSet<Uuid> passedNwList = new HashSet<>();
ConcurrentMap<Uuid, Network> extNwMap = new ConcurrentHashMap<>();
boolean isExternalNetwork = false;
if (networkList.isEmpty()) {
LOG.error("associateNetworksToVpn: Failed as given networks list is empty, VPN Id: {}", vpnId.getValue());
failedNwList.add(String.format("Failed to associate networks with VPN %s as given networks list is empty", vpnId.getValue()));
return failedNwList;
}
VpnInstance vpnInstance = VpnHelper.getVpnInstance(dataBroker, vpnId.getValue());
if (vpnInstance == null) {
LOG.error("associateNetworksToVpn: Can not find vpnInstance for VPN {} in ConfigDS", vpnId.getValue());
failedNwList.add(String.format("Failed to associate network: can not found vpnInstance for VPN %s " + "in ConfigDS", vpnId.getValue()));
return failedNwList;
}
try {
if (isVpnOfTypeL2(vpnInstance) && neutronEvpnUtils.isVpnAssociatedWithNetwork(vpnInstance)) {
LOG.error("associateNetworksToVpn: EVPN {} supports only one network to be associated with", vpnId.getValue());
failedNwList.add(String.format("Failed to associate network: EVPN %s supports only one network to be " + "associated with", vpnId.getValue()));
return failedNwList;
}
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) {
LOG.error("associateNetworksToVpn: Network {} not found in ConfigDS", nw.getValue());
failedNwList.add(String.format("Failed to associate network: network %s not found in ConfigDS", nw.getValue()));
continue;
}
NetworkProviderExtension providerExtension = network.augmentation(NetworkProviderExtension.class);
if (providerExtension.getSegments() != null && providerExtension.getSegments().size() > 1) {
LOG.error("associateNetworksToVpn: MultiSegmented network {} not supported in BGPVPN {}", nw.getValue(), vpnId.getValue());
failedNwList.add(String.format("Failed to associate multisegmented network %s with BGPVPN %s", nw.getValue(), vpnId.getValue()));
continue;
}
Uuid networkVpnId = neutronvpnUtils.getVpnForNetwork(nw);
if (networkVpnId != null) {
LOG.error("associateNetworksToVpn: Network {} already associated with another VPN {}", nw.getValue(), networkVpnId.getValue());
failedNwList.add(String.format("Failed to associate network %s as it is already associated to " + "another VPN %s", nw.getValue(), networkVpnId.getValue()));
continue;
}
/* Handle association of external network(s) to Internet BGP-VPN use case outside of the
* networkList iteration
*/
if (neutronvpnUtils.getIsExternal(network)) {
extNwMap.put(nw, 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()) {
passedNwList.add(nw);
continue;
}
if (vpnManager.checkForOverlappingSubnets(nw, subnetmapList, vpnId, routeTargets, failedNwList)) {
continue;
}
for (Subnetmap subnetmap : subnetmapList) {
IpVersionChoice ipVers = NeutronvpnUtils.getIpVersionFromString(subnetmap.getSubnetIp());
if (!ipVersion.isIpVersionChosen(ipVers)) {
ipVersion = ipVersion.addVersion(ipVers);
}
}
// Update vpnInstance for IP address family
if (ipVersion != IpVersionChoice.UNDEFINED && !isIpFamilyUpdated) {
LOG.debug("associateNetworksToVpn: Updating vpnInstance with ip address family {}" + " for VPN {} ", ipVersion, vpnId);
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, true);
isIpFamilyUpdated = true;
}
for (Subnetmap subnetmap : subnetmapList) {
Uuid subnetId = subnetmap.getId();
Uuid subnetVpnId = neutronvpnUtils.getVpnForSubnet(subnetId);
if (subnetVpnId != null) {
LOG.error("associateNetworksToVpn: Failed to associate subnet {} with VPN {}" + " as it is already associated", subnetId.getValue(), subnetVpnId.getValue());
failedNwList.add(String.format("Failed to associate subnet %s with VPN %s" + " as it is already associated", subnetId.getValue(), vpnId.getValue()));
continue;
}
if (!NeutronvpnUtils.getIsExternal(network)) {
LOG.debug("associateNetworksToVpn: Add subnet {} to VPN {}", subnetId.getValue(), vpnId.getValue());
addSubnetToVpn(vpnId, subnetId, null);
vpnManager.updateRouteTargetsToSubnetAssociation(routeTargets, subnetmap.getSubnetIp(), vpnId.getValue());
passedNwList.add(nw);
}
}
passedNwList.add(nw);
// Handle association of external network(s) to Internet BGP-VPN Instance use case
if (!extNwMap.isEmpty() || extNwMap != null) {
for (Network extNw : extNwMap.values()) {
if (!associateExtNetworkToVpn(vpnId, extNw, vpnInstance.getBgpvpnType())) {
LOG.error("associateNetworksToVpn: Failed to associate Provider External Network {} with " + "VPN {}", extNw, vpnId.getValue());
failedNwList.add(String.format("Failed to associate Provider External Network %s with " + "VPN %s", extNw, vpnId.getValue()));
continue;
}
}
}
}
} catch (ExecutionException | InterruptedException e) {
LOG.error("associateNetworksToVpn: Failed to associate VPN {} with networks {}: ", vpnId.getValue(), networkList, e);
failedNwList.add(String.format("Failed to associate VPN %s with networks %s: %s", vpnId.getValue(), networkList, e));
}
// VpnMap update for ext-nw is already done in associateExtNetworkToVpn() method.
if (!isExternalNetwork) {
updateVpnMaps(vpnId, null, null, null, new ArrayList<>(passedNwList));
}
LOG.info("Network(s) {} associated to L3VPN {} successfully", passedNwList, vpnId.getValue());
return failedNwList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.vpn.instance.vpntargets.VpnTarget in project netvirt by opendaylight.
the class VpnInstanceListener method addVpnInstance.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void addVpnInstance(VpnInstance value, WriteTransaction writeConfigTxn, WriteTransaction writeOperTxn) {
VpnAfConfig config = value.getIpv4Family();
String vpnInstanceName = value.getVpnInstanceName();
long vpnId = VpnUtil.getUniqueId(idManager, VpnConstants.VPN_IDPOOL_NAME, vpnInstanceName);
if (vpnId == 0) {
LOG.error("{} addVpnInstance: Unable to fetch label from Id Manager. Bailing out of adding operational" + " data for Vpn Instance {}", LOGGING_PREFIX_ADD, value.getVpnInstanceName());
return;
}
LOG.info("{} addVpnInstance: VPN Id {} generated for VpnInstanceName {}", LOGGING_PREFIX_ADD, vpnId, vpnInstanceName);
String primaryRd = VpnUtil.getPrimaryRd(value);
org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance vpnInstanceToVpnId = VpnUtil.getVpnInstanceToVpnId(vpnInstanceName, vpnId, primaryRd);
if (writeConfigTxn != null) {
writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, VpnOperDsUtils.getVpnInstanceToVpnIdIdentifier(vpnInstanceName), vpnInstanceToVpnId, WriteTransaction.CREATE_MISSING_PARENTS);
} else {
TransactionUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, VpnOperDsUtils.getVpnInstanceToVpnIdIdentifier(vpnInstanceName), vpnInstanceToVpnId);
}
VpnIds vpnIdToVpnInstance = VpnUtil.getVpnIdToVpnInstance(vpnId, value.getVpnInstanceName(), primaryRd, VpnUtil.isBgpVpn(vpnInstanceName, primaryRd));
if (writeConfigTxn != null) {
writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, VpnUtil.getVpnIdToVpnInstanceIdentifier(vpnId), vpnIdToVpnInstance, WriteTransaction.CREATE_MISSING_PARENTS);
} else {
TransactionUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, VpnUtil.getVpnIdToVpnInstanceIdentifier(vpnId), vpnIdToVpnInstance);
}
try {
String cachedTransType = fibManager.getConfTransType();
if (cachedTransType.equals("Invalid")) {
try {
fibManager.setConfTransType("L3VPN", "VXLAN");
} catch (Exception e) {
LOG.error("{} addVpnInstance: Exception caught setting the L3VPN tunnel transportType for vpn {}", LOGGING_PREFIX_ADD, vpnInstanceName, e);
}
} else {
LOG.debug("{} addVpnInstance: Configured tunnel transport type for L3VPN {} as {}", LOGGING_PREFIX_ADD, vpnInstanceName, cachedTransType);
}
} catch (Exception e) {
LOG.error("{} addVpnInstance: Error when trying to retrieve tunnel transport type for L3VPN {}", LOGGING_PREFIX_ADD, vpnInstanceName, e);
}
VpnInstanceOpDataEntryBuilder builder = new VpnInstanceOpDataEntryBuilder().setVrfId(primaryRd).setVpnId(vpnId).setVpnInstanceName(vpnInstanceName).setVpnState(VpnInstanceOpDataEntry.VpnState.Created).setIpv4Configured(false).setIpv6Configured(false);
if (VpnUtil.isBgpVpn(vpnInstanceName, primaryRd)) {
List<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpntargets.VpnTarget> opVpnTargetList = new ArrayList<>();
builder.setBgpvpnType(VpnInstanceOpDataEntry.BgpvpnType.BGPVPNExternal);
if (value.getL3vni() != null) {
builder.setL3vni(value.getL3vni());
}
if (value.getType() == VpnInstance.Type.L2) {
builder.setType(VpnInstanceOpDataEntry.Type.L2);
}
VpnTargets vpnTargets = config.getVpnTargets();
if (vpnTargets != null) {
List<VpnTarget> vpnTargetList = vpnTargets.getVpnTarget();
if (vpnTargetList != null) {
for (VpnTarget vpnTarget : vpnTargetList) {
VpnTargetBuilder vpnTargetBuilder = new VpnTargetBuilder().setKey(new VpnTargetKey(vpnTarget.getKey().getVrfRTValue())).setVrfRTType(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpntargets.VpnTarget.VrfRTType.forValue(vpnTarget.getVrfRTType().getIntValue())).setVrfRTValue(vpnTarget.getVrfRTValue());
opVpnTargetList.add(vpnTargetBuilder.build());
}
}
}
VpnTargetsBuilder vpnTargetsBuilder = new VpnTargetsBuilder().setVpnTarget(opVpnTargetList);
builder.setVpnTargets(vpnTargetsBuilder.build());
List<String> rds = config.getRouteDistinguisher();
builder.setRd(rds);
} else {
builder.setBgpvpnType(VpnInstanceOpDataEntry.BgpvpnType.VPN);
}
if (writeOperTxn != null) {
writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, VpnUtil.getVpnInstanceOpDataIdentifier(primaryRd), builder.build(), true);
} else {
TransactionUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, VpnUtil.getVpnInstanceOpDataIdentifier(primaryRd), builder.build());
}
LOG.info("{} addVpnInstance: VpnInstanceOpData populated successfully for vpn {} rd {}", LOGGING_PREFIX_ADD, vpnInstanceName, primaryRd);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.vpn.instance.vpntargets.VpnTarget in project netvirt by opendaylight.
the class NeutronvpnManager method updateVpnInstanceNode.
private void updateVpnInstanceNode(Uuid vpnId, List<String> rd, List<String> irt, List<String> ert, VpnInstance.Type type, long l3vni, IpVersionChoice ipVersion) {
String vpnName = vpnId.getValue();
VpnInstanceBuilder builder = null;
List<VpnTarget> vpnTargetList = new ArrayList<>();
boolean isLockAcquired = false;
InstanceIdentifier<VpnInstance> vpnIdentifier = InstanceIdentifier.builder(VpnInstances.class).child(VpnInstance.class, new VpnInstanceKey(vpnName)).build();
try {
Optional<VpnInstance> optionalVpn = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIdentifier);
LOG.debug("Creating/Updating a new vpn-instance node: {} ", vpnName);
if (optionalVpn.isPresent()) {
builder = new VpnInstanceBuilder(optionalVpn.get());
LOG.debug("updating existing vpninstance node");
} else {
builder = new VpnInstanceBuilder().setKey(new VpnInstanceKey(vpnName)).setVpnInstanceName(vpnName).setType(type).setL3vni(l3vni);
}
if (irt != null && !irt.isEmpty()) {
if (ert != null && !ert.isEmpty()) {
List<String> commonRT = new ArrayList<>(irt);
commonRT.retainAll(ert);
for (String common : commonRT) {
irt.remove(common);
ert.remove(common);
VpnTarget vpnTarget = new VpnTargetBuilder().setKey(new VpnTargetKey(common)).setVrfRTValue(common).setVrfRTType(VpnTarget.VrfRTType.Both).build();
vpnTargetList.add(vpnTarget);
}
}
for (String importRT : irt) {
VpnTarget vpnTarget = new VpnTargetBuilder().setKey(new VpnTargetKey(importRT)).setVrfRTValue(importRT).setVrfRTType(VpnTarget.VrfRTType.ImportExtcommunity).build();
vpnTargetList.add(vpnTarget);
}
}
if (ert != null && !ert.isEmpty()) {
for (String exportRT : ert) {
VpnTarget vpnTarget = new VpnTargetBuilder().setKey(new VpnTargetKey(exportRT)).setVrfRTValue(exportRT).setVrfRTType(VpnTarget.VrfRTType.ExportExtcommunity).build();
vpnTargetList.add(vpnTarget);
}
}
VpnTargets vpnTargets = new VpnTargetsBuilder().setVpnTarget(vpnTargetList).build();
Ipv4FamilyBuilder ipv4vpnBuilder = new Ipv4FamilyBuilder().setVpnTargets(vpnTargets);
Ipv6FamilyBuilder ipv6vpnBuilder = new Ipv6FamilyBuilder().setVpnTargets(vpnTargets);
if (rd != null && !rd.isEmpty()) {
ipv4vpnBuilder.setRouteDistinguisher(rd);
ipv6vpnBuilder.setRouteDistinguisher(rd);
}
if (ipVersion != null && ipVersion.isIpVersionChosen(IpVersionChoice.IPV4)) {
builder.setIpv4Family(ipv4vpnBuilder.build());
}
if (ipVersion != null && ipVersion.isIpVersionChosen(IpVersionChoice.IPV6)) {
builder.setIpv6Family(ipv6vpnBuilder.build());
}
if (ipVersion != null && ipVersion.isIpVersionChosen(IpVersionChoice.UNDEFINED)) {
builder.setIpv4Family(ipv4vpnBuilder.build());
}
VpnInstance newVpn = builder.build();
isLockAcquired = vpnLock.tryLock(vpnId, LOCK_WAIT_TIME, TimeUnit.SECONDS);
LOG.debug("Creating/Updating vpn-instance for {} ", vpnName);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIdentifier, newVpn);
} catch (ReadFailedException | TransactionCommitFailedException e) {
LOG.error("Update VPN Instance node failed for node: {} {} {} {}", vpnName, rd, irt, ert);
} finally {
if (isLockAcquired) {
vpnLock.unlock(vpnId);
}
}
}
Aggregations