use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance in project netvirt by opendaylight.
the class NeutronvpnUtils method getExistingRDs.
public List<String> getExistingRDs() {
List<String> existingRDs = new ArrayList<>();
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()) {
if (vpnInstance.getIpv4Family() == null) {
continue;
}
List<String> rds = vpnInstance.getIpv4Family().getRouteDistinguisher();
if (rds != null) {
existingRDs.addAll(rds);
}
}
}
return existingRDs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance in project netvirt by opendaylight.
the class NeutronvpnUtils method shouldVpnHandleIpVersionChangeToRemove.
public boolean shouldVpnHandleIpVersionChangeToRemove(Subnetmap sm, Uuid vpnId) {
if (sm == null) {
return false;
}
InstanceIdentifier<Subnetmaps> subnetMapsId = InstanceIdentifier.builder(Subnetmaps.class).build();
Optional<Subnetmaps> allSubnetMaps = read(LogicalDatastoreType.CONFIGURATION, subnetMapsId);
// calculate and store in list IpVersion for each subnetMap, belonging to current VpnInstance
List<IpVersionChoice> snIpVersions = new ArrayList<>();
for (Subnetmap snMap : allSubnetMaps.get().getSubnetmap()) {
if (snMap.getId().equals(sm.getId())) {
continue;
}
if (snMap.getVpnId() != null && snMap.getVpnId().equals(vpnId)) {
snIpVersions.add(getIpVersionFromString(snMap.getSubnetIp()));
}
if (snMap.getInternetVpnId() != null && snMap.getInternetVpnId().equals(vpnId)) {
snIpVersions.add(getIpVersionFromString(snMap.getSubnetIp()));
}
}
IpVersionChoice ipVersion = getIpVersionFromString(sm.getSubnetIp());
if (!snIpVersions.contains(ipVersion)) {
return true;
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance in project netvirt by opendaylight.
the class NeutronEvpnUtils method updateElanWithVpnInfo.
public void updateElanWithVpnInfo(String elanInstanceName, VpnInstance vpnInstance, Operation operation) {
String vpnName = vpnInstance.getVpnInstanceName();
InstanceIdentifier<ElanInstance> elanIid = ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName);
ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
Optional<ElanInstance> elanInstanceOptional = Optional.absent();
try {
elanInstanceOptional = transaction.read(LogicalDatastoreType.CONFIGURATION, elanIid).checkedGet();
} catch (ReadFailedException e) {
LOG.error("updateElanWithVpnInfo throws ReadFailedException e {}", e);
}
if (!elanInstanceOptional.isPresent()) {
return;
}
EvpnAugmentationBuilder evpnAugmentationBuilder = new EvpnAugmentationBuilder();
ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder(elanInstanceOptional.get());
if (elanInstanceBuilder.getAugmentation(EvpnAugmentation.class) != null) {
evpnAugmentationBuilder = new EvpnAugmentationBuilder(elanInstanceBuilder.getAugmentation(EvpnAugmentation.class));
}
if (operation == Operation.ADD) {
evpnAugmentationBuilder.setEvpnName(vpnName);
LOG.debug("Writing Elan-EvpnAugmentation with key {}", elanInstanceName);
} else {
evpnAugmentationBuilder.setEvpnName(null);
LOG.debug("Deleting Elan-EvpnAugmentation with key {}", elanInstanceName);
}
elanInstanceBuilder.addAugmentation(EvpnAugmentation.class, evpnAugmentationBuilder.build());
transaction.put(LogicalDatastoreType.CONFIGURATION, elanIid, elanInstanceBuilder.build(), WriteTransaction.CREATE_MISSING_PARENTS);
transaction.submit();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance in project netvirt by opendaylight.
the class NeutronEvpnUtils method updateVpnWithElanInfo.
public void updateVpnWithElanInfo(VpnInstance vpnInstance, String elanInstanceName, Operation operation) {
String rd = vpnManager.getPrimaryRdFromVpnInstance(vpnInstance);
InstanceIdentifier<EvpnRdToNetwork> rdToNetworkIdentifier = getRdToNetworkIdentifier(rd);
jobCoordinator.enqueueJob("EVPN_ASSOCIATE-" + rd, () -> {
ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (operation == Operation.DELETE) {
LOG.debug("Deleting Evpn-Network with key {}", rd);
transaction.delete(LogicalDatastoreType.CONFIGURATION, rdToNetworkIdentifier);
} else {
EvpnRdToNetworkBuilder evpnRdToNetworkBuilder = new EvpnRdToNetworkBuilder().setKey(new EvpnRdToNetworkKey(rd));
evpnRdToNetworkBuilder.setRd(rd);
evpnRdToNetworkBuilder.setNetworkId(elanInstanceName);
LOG.info("updating Evpn {} with elaninstance {} and rd {}", vpnInstance.getVpnInstanceName(), elanInstanceName, rd);
transaction.put(LogicalDatastoreType.CONFIGURATION, rdToNetworkIdentifier, evpnRdToNetworkBuilder.build(), WriteTransaction.CREATE_MISSING_PARENTS);
}
futures.add(transaction.submit());
return futures;
});
}
Aggregations