use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps in project netvirt by opendaylight.
the class NeutronvpnUtils method getNetworksForVpn.
protected List<Uuid> getNetworksForVpn(Uuid vpnId) {
InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class).child(VpnMap.class, new VpnMapKey(vpnId)).build();
Optional<VpnMap> optionalVpnMap = read(LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
if (optionalVpnMap.isPresent()) {
VpnMap vpnMap = optionalVpnMap.get();
return vpnMap.getNetworkIds();
}
LOG.error("getNetworksforVpn: Failed as VPNMaps DS is absent for VPN {}", vpnId.getValue());
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps in project netvirt by opendaylight.
the class NeutronvpnUtils method getVpnForRouter.
// @param external vpn - true if external vpn being fetched, false for internal vpn
protected Uuid getVpnForRouter(Uuid routerId, Boolean externalVpn) {
if (routerId == null) {
return null;
}
InstanceIdentifier<VpnMaps> vpnMapsIdentifier = InstanceIdentifier.builder(VpnMaps.class).build();
Optional<VpnMaps> optionalVpnMaps = read(LogicalDatastoreType.CONFIGURATION, vpnMapsIdentifier);
if (optionalVpnMaps.isPresent() && optionalVpnMaps.get().getVpnMap() != null) {
List<VpnMap> allMaps = optionalVpnMaps.get().getVpnMap();
for (VpnMap vpnMap : allMaps) {
if (routerId.equals(vpnMap.getRouterId())) {
if (externalVpn) {
if (!routerId.equals(vpnMap.getVpnId())) {
return vpnMap.getVpnId();
}
} else {
if (routerId.equals(vpnMap.getVpnId())) {
return vpnMap.getVpnId();
}
}
}
}
}
LOG.debug("getVpnForRouter: Failed for router {} as no VPN present in VPNMaps DS", routerId.getValue());
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps in project netvirt by opendaylight.
the class NeutronvpnManager method handleNeutronRouterDeleted.
protected void handleNeutronRouterDeleted(Uuid routerId, List<Uuid> routerSubnetIds) {
// check if the router is associated to some VPN
Uuid vpnId = neutronvpnUtils.getVpnForRouter(routerId, true);
Uuid internetVpnId = neutronvpnUtils.getInternetvpnUuidBoundToRouterId(routerId);
if (vpnId != null) {
// remove existing external vpn interfaces
for (Uuid subnetId : routerSubnetIds) {
removeSubnetFromVpn(vpnId, subnetId, internetVpnId);
}
clearFromVpnMaps(vpnId, routerId, null);
} else {
// remove existing internal vpn interfaces
for (Uuid subnetId : routerSubnetIds) {
removeSubnetFromVpn(routerId, subnetId, internetVpnId);
}
}
// delete entire vpnMaps node for internal VPN
deleteVpnMapsNode(routerId);
// delete vpn-instance for internal VPN
deleteVpnInstance(routerId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps in project netvirt by opendaylight.
the class NeutronvpnManager method removeVpn.
public void removeVpn(Uuid id) {
// read VPNMaps
VpnMap vpnMap = neutronvpnUtils.getVpnMap(id);
Uuid router = vpnMap != null ? vpnMap.getRouterId() : null;
// dissociate router
if (router != null) {
dissociateRouterFromVpn(id, router);
}
// dissociate networks
if (!id.equals(router) && vpnMap.getNetworkIds() != null) {
dissociateNetworksFromVpn(id, vpnMap.getNetworkIds());
}
// remove entire vpnMaps node
deleteVpnMapsNode(id);
// remove vpn-instance
deleteVpnInstance(id);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps in project netvirt by opendaylight.
the class NatUtil method getVpnForRouter.
static Uuid getVpnForRouter(DataBroker broker, String routerId) {
InstanceIdentifier<VpnMaps> vpnMapsIdentifier = InstanceIdentifier.builder(VpnMaps.class).build();
Optional<VpnMaps> optionalVpnMaps = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(broker, LogicalDatastoreType.CONFIGURATION, vpnMapsIdentifier);
if (optionalVpnMaps.isPresent() && optionalVpnMaps.get().getVpnMap() != null) {
List<VpnMap> allMaps = optionalVpnMaps.get().getVpnMap();
if (routerId != null) {
for (VpnMap vpnMap : allMaps) {
if (vpnMap.getRouterId() != null && routerId.equals(vpnMap.getRouterId().getValue()) && !routerId.equals(vpnMap.getVpnId().getValue())) {
return vpnMap.getVpnId();
}
}
}
}
LOG.debug("getVpnForRouter : VPN not found for routerID:{}", routerId);
return null;
}
Aggregations