use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.RouterIds in project netvirt by opendaylight.
the class NatVpnMapsChangeListener method update.
@Override
public void update(InstanceIdentifier<VpnMap> identifier, VpnMap original, VpnMap updated) {
Uuid vpnUuid = updated.getVpnId();
String vpnName = vpnUuid.getValue();
List<RouterIds> updatedRouterIdList = new ArrayList<RouterIds>(updated.nonnullRouterIds().values());
List<RouterIds> originalRouterIdList = new ArrayList<RouterIds>(original.nonnullRouterIds().values());
List<RouterIds> routersAddedList = null;
List<RouterIds> routersRemovedList = null;
if (originalRouterIdList == null && updatedRouterIdList != null) {
routersAddedList = updatedRouterIdList;
} else if (originalRouterIdList != null && updatedRouterIdList != null) {
routersAddedList = updatedRouterIdList.stream().filter(routerId -> (!originalRouterIdList.contains(routerId))).collect(Collectors.toList());
}
if (originalRouterIdList != null && updatedRouterIdList == null) {
routersRemovedList = originalRouterIdList;
} else if (originalRouterIdList != null && updatedRouterIdList != null) {
routersRemovedList = originalRouterIdList.stream().filter(routerId -> (!updatedRouterIdList.contains(routerId))).collect(Collectors.toList());
}
if (routersAddedList != null) {
routersAddedList.stream().filter(router -> !(Objects.equals(router.getRouterId(), updated.getVpnId()))).forEach(router -> {
String routerName = router.getRouterId().getValue();
onRouterAssociatedToVpn(vpnName, routerName);
});
}
if (routersRemovedList != null) {
routersRemovedList.stream().filter(router -> !(Objects.equals(router.getRouterId(), original.getVpnId()))).forEach(router -> {
String routerName = router.getRouterId().getValue();
onRouterDisassociatedFromVpn(vpnName, routerName);
});
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.RouterIds in project netvirt by opendaylight.
the class NeutronvpnUtils method getVpnInstanceRouterIdsList.
public static List<RouterIds> getVpnInstanceRouterIdsList(List<Uuid> routerIds) {
List<RouterIds> listRouterIds = new ArrayList<>();
for (Uuid routerId : routerIds) {
final RouterIds routerIdInstance = getvpnInstanceRouterIds(routerId);
listRouterIds.add(routerIdInstance);
}
return listRouterIds;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.RouterIds in project netvirt by opendaylight.
the class IVpnLinkServiceImpl method buildRouterXL3VPNMap.
private Map<String, String> buildRouterXL3VPNMap() {
InstanceIdentifier<VpnMaps> vpnMapsIdentifier = InstanceIdentifier.builder(VpnMaps.class).build();
Optional<VpnMaps> optVpnMaps = Optional.empty();
try {
optVpnMaps = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapsIdentifier);
} catch (ExecutionException | InterruptedException e) {
LOG.error("buildRouterXL3VPNMap: Exception while reading VpnMaps DS", e);
}
if (!optVpnMaps.isPresent()) {
LOG.info("Could not retrieve VpnMaps object from Configurational DS");
return new HashMap<>();
}
Map<String, String> vmap = new HashMap<>();
final Map<VpnMapKey, VpnMap> keyVpnMapMap = optVpnMaps.get().nonnullVpnMap();
for (VpnMap map : keyVpnMapMap.values()) {
if (map.getRouterIds() == null) {
continue;
}
final List<Uuid> vpnRouterIds = NeutronUtils.getVpnMapRouterIdsListUuid(new ArrayList<RouterIds>(map.nonnullRouterIds().values()));
for (Uuid routerId : vpnRouterIds) {
if (map.getVpnId().getValue().equalsIgnoreCase(routerId.getValue())) {
// VPN is internal
break;
}
vmap.put(routerId.getValue(), map.getVpnId().getValue());
}
}
return vmap;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.RouterIds in project netvirt by opendaylight.
the class NeutronvpnNatManager method removeRouterFromExternalSubnets.
private void removeRouterFromExternalSubnets(Uuid routerId, Uuid externalNetworkId, List<ExternalFixedIps> externalFixedIps) {
LOG.debug("Removing routerID {} from external subnets of external network{}", routerId, externalNetworkId);
List<Subnets> fixedIpsSubnets = getSubnets(getExternalSubnetsUuidsSetForFixedIps(externalFixedIps));
for (Subnets subnets : fixedIpsSubnets) {
Uuid subnetId = subnets.getId();
List<Uuid> routerIds = new ArrayList<>();
routerIds = subnets.getRouterIds() != null ? new ArrayList<>(subnets.getRouterIds()) : routerIds;
if (routerIds != null) {
if (subnets.getExternalNetworkId() != null && subnets.getExternalNetworkId().equals(externalNetworkId) && routerIds.contains(routerId)) {
routerIds.remove(routerId);
LOG.debug("Will remove routerIDs {} from external subnet {} router ID {}", routerIds, subnetId, routerId);
addExternalSubnet(externalNetworkId, subnetId, routerIds);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.RouterIds in project netvirt by opendaylight.
the class NeutronvpnManager method removeVpn.
public void removeVpn(Uuid vpnId) {
// read VPNMaps
VpnMap vpnMap = neutronvpnUtils.getVpnMap(vpnId);
if (vpnMap != null) {
Map<RouterIdsKey, RouterIds> keyRouterIdsMap = vpnMap.getRouterIds();
List<Uuid> routerUuidList = new ArrayList<>();
// dissociate router
if (keyRouterIdsMap != null && !keyRouterIdsMap.isEmpty()) {
for (RouterIds router : keyRouterIdsMap.values()) {
Uuid routerId = router.getRouterId();
routerUuidList.add(routerId);
dissociateRouterFromVpn(vpnId, routerId);
}
}
if (!routerUuidList.contains(vpnId) && vpnMap.getNetworkIds() != null) {
dissociateNetworksFromVpn(vpnId, vpnMap.getNetworkIds());
}
} else {
LOG.error("removeVpn: vpnMap is null for vpn {}", vpnId.getValue());
}
// remove entire vpnMaps node
deleteVpnMapsNode(vpnId);
// remove vpn-instance
deleteVpnInstance(vpnId);
LOG.debug("Deleted L3VPN with ID {}", vpnId.getValue());
}
Aggregations