return ext != null && ext.isExternal();
}
+ protected String getExistingOperationalVpn(String primaryRd) {
+ try {
+ Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataOptional = SingleTransactionDataBroker
+ .syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, getVpnOpDataIdentifier(primaryRd));
+ if (vpnInstanceOpDataOptional.isPresent()) {
+ return vpnInstanceOpDataOptional.get().getVpnInstanceName();
+ }
+ } catch (ExecutionException | InterruptedException e) {
+ LOG.error("getExistingOperationalVpn: Exception while checking operational status of vpn with rd {}",
+ primaryRd, e);
+ }
+ return null;
+ }
+
static InstanceIdentifier<NetworkMap> buildNetworkMapIdentifier(Uuid networkId) {
InstanceIdentifier<NetworkMap> id = InstanceIdentifier.builder(NetworkMaps.class).child(NetworkMap.class, new
NetworkMapKey(networkId)).build();
return ret;
}
+ public String getVpnForRD(String rd) {
+ InstanceIdentifier<VpnInstances> path = InstanceIdentifier.builder(VpnInstances.class).build();
+ Optional<VpnInstances> vpnInstancesOptional = read(LogicalDatastoreType.CONFIGURATION, path);
+ if (vpnInstancesOptional.isPresent() && vpnInstancesOptional.get().getVpnInstance() != null) {
+ for (VpnInstance vpnInstance : vpnInstancesOptional.get().getVpnInstance().values()) {
+ List<String> rds = vpnInstance.getRouteDistinguisher();
+ if (rds != null && rds.contains(rd)) {
+ return vpnInstance.getVpnInstanceName();
+ }
+ }
+ }
+ return null;
+ }
+
public List<String> getExistingRDs() {
List<String> existingRDs = new ArrayList<>();
InstanceIdentifier<VpnInstances> path = InstanceIdentifier.builder(VpnInstances.class).build();
public void updateVpnInstanceWithIpFamily(String vpnName, IpVersionChoice ipVersion, boolean add) {
jobCoordinator.enqueueJob("VPN-" + vpnName, () -> {
- VpnInstance vpnInstance = getVpnInstance(dataBroker, new Uuid(vpnName));
+ VpnInstance vpnInstance = getVpnInstance(new Uuid(vpnName));
if (vpnInstance == null) {
return Collections.emptyList();
}
/**
* Get the vpnInstance from its Uuid.
*
- * @param broker to get informations from ds
* @param vpnId the Uuid of the VPN
* @return the VpnInstance or null if unfindable
*/
@Nullable
- public VpnInstance getVpnInstance(DataBroker broker, Uuid vpnId) {
- if (broker == null || vpnId == null) {
+ public VpnInstance getVpnInstance(Uuid vpnId) {
+ if (vpnId == null) {
return null;
}
InstanceIdentifier<VpnInstance> id = InstanceIdentifier.builder(VpnInstances.class).child(VpnInstance.class,
public void updateVpnInstanceWithBgpVpnType(VpnInstance.BgpvpnType bgpvpnType, @NonNull Uuid vpnName) {
jobCoordinator.enqueueJob("VPN-" + vpnName.getValue(), () -> {
- VpnInstance vpnInstance = getVpnInstance(dataBroker, vpnName);
+ VpnInstance vpnInstance = getVpnInstance(vpnName);
if (vpnInstance == null) {
LOG.error("updateVpnInstanceWithBgpVpnType: Failed to Update VpnInstance {} with BGP-VPN type {}."
+ "VpnInstance is does not exist in the CONFIG. Do nothing.", vpnName.getValue(), bgpvpnType);