use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.Networks in project netvirt by opendaylight.
the class NeutronvpnManager method clearFromVpnMaps.
private void clearFromVpnMaps(Uuid vpnId, @Nullable Uuid routerId, @Nullable List<Uuid> networkIds) {
InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class).child(VpnMap.class, new VpnMapKey(vpnId)).build();
Optional<VpnMap> optionalVpnMap;
try {
optionalVpnMap = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
} catch (ExecutionException | InterruptedException e) {
LOG.error("Error reading the VPN map for {}", vpnMapIdentifier, e);
return;
}
if (optionalVpnMap.isPresent()) {
VpnMap vpnMap = optionalVpnMap.get();
VpnMapBuilder vpnMapBuilder = new VpnMapBuilder(vpnMap);
List<RouterIds> rtrIds = new ArrayList<>(vpnMap.nonnullRouterIds().values());
if (rtrIds == null) {
rtrIds = new ArrayList<>();
}
if (routerId != null) {
if (vpnMap.getNetworkIds() == null && routerId.equals(vpnMap.getVpnId())) {
rtrIds.add(new RouterIdsBuilder().setRouterId(routerId).build());
vpnMapBuilder.setRouterIds(rtrIds);
try (AcquireResult lock = tryVpnLock(vpnId)) {
if (!lock.wasAcquired()) {
// FIXME: why do we even bother with locking if we do not honor it?!
logTryLockFailure(vpnId);
}
LOG.debug("removing vpnMaps node: {} ", vpnId);
try {
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
} catch (TransactionCommitFailedException e) {
LOG.error("Deletion of vpnMaps node failed for vpn {}", vpnId.getValue());
}
}
return;
} else if (vpnMap.getNetworkIds() == null && !routerId.equals(vpnMap.getVpnId())) {
rtrIds.remove(new RouterIdsBuilder().setRouterId(routerId).build());
vpnMapBuilder.setRouterIds(rtrIds);
LOG.debug("Removing routerId {} in vpnMaps for the vpn {}", routerId, vpnId.getValue());
}
}
if (networkIds != null) {
List<Uuid> vpnNw = vpnMap.getNetworkIds() != null ? new ArrayList<>(vpnMap.getNetworkIds()) : new ArrayList<>();
vpnNw.removeAll(networkIds);
if (vpnNw.isEmpty()) {
LOG.debug("setting networks null in vpnMaps node: {} ", vpnId.getValue());
vpnMapBuilder.setNetworkIds(null);
} else {
vpnMapBuilder.setNetworkIds(vpnNw);
}
}
try (AcquireResult lock = tryVpnLock(vpnId)) {
if (!lock.wasAcquired()) {
// FIXME: why do we even bother with locking if we do not honor it?!
logTryLockFailure(vpnId);
}
LOG.debug("clearing from vpnMaps node: {} ", vpnId.getValue());
try {
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier, vpnMapBuilder.build());
} catch (TransactionCommitFailedException e) {
LOG.error("Clearing from vpnMaps node failed for vpn {}", vpnId.getValue());
}
}
} else {
LOG.error("VPN : {} not found", vpnId.getValue());
}
LOG.debug("Clear from VPNMaps DS successful for VPN {} ", vpnId.getValue());
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.Networks in project netvirt by opendaylight.
the class NeutronvpnManager method disassociateExtNetworkFromVpn.
private boolean disassociateExtNetworkFromVpn(@NonNull Uuid vpnId, @NonNull Network extNet) {
if (!removeExternalNetworkFromVpn(extNet)) {
return false;
}
// check, if there is another Provider Networks associated with given VPN
List<Uuid> vpnNets = getNetworksForVpn(vpnId);
if (vpnNets != null) {
// Remove currently disassociated network from the list
vpnNets.remove(extNet.getUuid());
for (Uuid netId : vpnNets) {
if (NeutronvpnUtils.getIsExternal(getNeutronNetwork(netId))) {
LOG.error("dissociateExtNetworkFromVpn: Internet VPN {} is still associated with Provider Network " + "{}", vpnId.getValue(), netId.getValue());
return true;
}
}
}
// /Set VPN Type is BGPVPN from InternetBGPVPN
LOG.info("disassociateExtNetworkFromVpn: Set BGP-VPN type with {} for VPN {} and update IPv6 address family. " + "Since external network is disassociated from VPN {}", VpnInstance.BgpvpnType.BGPVPN, extNet, vpnId.getValue());
neutronvpnUtils.updateVpnInstanceWithBgpVpnType(VpnInstance.BgpvpnType.BGPVPN, vpnId);
IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
for (Uuid snId : neutronvpnUtils.getPrivateSubnetsToExport(extNet, vpnId)) {
Subnetmap sm = neutronvpnUtils.getSubnetmap(snId);
if (sm == null) {
LOG.error("disassociateExtNetworkFromVpn: can not find subnet with Id {} in ConfigDS", snId.getValue());
continue;
}
IpVersionChoice ipVers = NeutronvpnUtils.getIpVersionFromString(sm.getSubnetIp());
if (ipVers.isIpVersionChosen(IpVersionChoice.IPV4)) {
continue;
}
if (ipVers.isIpVersionChosen(IpVersionChoice.IPV6)) {
updateVpnInternetForSubnet(sm, vpnId, false);
}
if (!ipVersion.isIpVersionChosen(ipVers)) {
ipVersion = ipVersion.addVersion(ipVers);
}
}
if (ipVersion != IpVersionChoice.UNDEFINED) {
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), IpVersionChoice.IPV6, false);
LOG.info("disassociateExtNetworkFromVpn: withdraw IPv6 Internet default route from VPN {}", vpnId.getValue());
neutronvpnUtils.updateVpnInstanceWithFallback(/*routerId*/
null, vpnId, false);
}
return true;
}
Aggregations