use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey in project netvirt by opendaylight.
the class VpnUtil method removeMipAdjAndLearntIp.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void removeMipAdjAndLearntIp(String vpnName, String vpnInterface, String prefix) {
final ReentrantLock lock = lockFor(vpnName, prefix);
lock.lock();
try {
String ip = VpnUtil.getIpPrefix(prefix);
InstanceIdentifier<VpnInterfaceOpDataEntry> vpnInterfaceOpId = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface, vpnName);
InstanceIdentifier<AdjacenciesOp> path = vpnInterfaceOpId.augmentation(AdjacenciesOp.class);
Optional<AdjacenciesOp> adjacenciesOp = read(LogicalDatastoreType.OPERATIONAL, path);
if (adjacenciesOp.isPresent()) {
InstanceIdentifier<Adjacency> adjacencyIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).child(VpnInterface.class, new VpnInterfaceKey(vpnInterface)).augmentation(Adjacencies.class).child(Adjacency.class, new AdjacencyKey(ip)).build();
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, adjacencyIdentifier);
LOG.info("removeMipAdjAndLearntIp: Successfully Deleted Adjacency {} from interface {} vpn {}", ip, vpnInterface, vpnName);
}
InstanceIdentifier<LearntVpnVipToPort> id = buildLearntVpnVipToPortIdentifier(vpnName, prefix);
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
LOG.info("removeMipAdjAndLearntIp: Delete learned ARP for fixedIp: {}, vpn {} removed from" + "VpnPortipToPort DS", prefix, vpnName);
} catch (Exception e) {
LOG.error("removeMipAdjAndLearntIp: Exception Deleting learned Ip: {} interface {} vpn {} from " + "LearntVpnPortipToPort DS", prefix, vpnInterface, vpnName, e);
} finally {
lock.unlock();
}
VpnUtil.removeVpnPortFixedIpToPort(dataBroker, vpnName, prefix, null);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey in project netvirt by opendaylight.
the class L3vpnOverMplsGrePopulator method createOperationalAdjacency.
@Override
public Adjacency createOperationalAdjacency(L3vpnInput input) {
Adjacency nextHop = input.getNextHop();
String nextHopIp = input.getNextHopIp();
String prefix = VpnUtil.getIpPrefix(nextHop.getIpAddress());
List<String> adjNextHop = nextHop.getNextHopIpList();
String rd = input.getRd();
String primaryRd = input.getPrimaryRd();
String vpnName = input.getVpnName();
Uint32 label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(primaryRd, prefix));
if (label.longValue() == VpnConstants.INVALID_LABEL) {
String error = "Unable to fetch label from Id Manager. Bailing out of creation of operational " + "vpn interface adjacency " + prefix + "for vpn " + vpnName;
throw new NullPointerException(error);
}
List<String> nextHopList = adjNextHop != null && !adjNextHop.isEmpty() ? adjNextHop : nextHopIp == null ? Collections.emptyList() : singletonList(nextHopIp);
return new AdjacencyBuilder(nextHop).setLabel(label).setNextHopIpList(nextHopList).setIpAddress(prefix).setVrfId(rd).withKey(new AdjacencyKey(prefix)).setAdjacencyType(nextHop.getAdjacencyType()).setSubnetGatewayMacAddress(nextHop.getSubnetGatewayMacAddress()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey in project netvirt by opendaylight.
the class NeutronvpnNatManager method removeAdjacencyAndLearnedEntriesforExternalSubnet.
private void removeAdjacencyAndLearnedEntriesforExternalSubnet(Uuid extNetId, Uuid extSubnetId) {
Collection<String> extElanInterfaces = elanService.getExternalElanInterfaces(extNetId.getValue());
if (extElanInterfaces == null || extElanInterfaces.isEmpty()) {
LOG.error("No external ports attached to external network {}", extNetId.getValue());
return;
}
for (String infName : extElanInterfaces) {
InstanceIdentifier<VpnInterface> vpnIfIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).child(VpnInterface.class, new VpnInterfaceKey(infName)).build();
InstanceIdentifier<Adjacencies> adjacenciesIdentifier = vpnIfIdentifier.augmentation(Adjacencies.class);
try {
// Looking for existing prefix in MDSAL database
Optional<Adjacencies> optionalAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, adjacenciesIdentifier);
if (optionalAdjacencies.isPresent()) {
Map<AdjacencyKey, Adjacency> keyAdjacencyMap = optionalAdjacencies.get().nonnullAdjacency();
Iterator<Adjacency> adjacencyIter = keyAdjacencyMap.values().iterator();
while (adjacencyIter.hasNext()) {
Adjacency adjacency = adjacencyIter.next();
if (!adjacency.getSubnetId().equals(extSubnetId)) {
continue;
}
InstanceIdentifier<Adjacency> adjacencyIdentifier = adjacenciesIdentifier.child(Adjacency.class, new AdjacencyKey(adjacency.getIpAddress()));
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, adjacencyIdentifier);
LOG.trace("Removed Adjacency for fixedIP {} for port {} on external subnet {} ", adjacency.getIpAddress(), infName, extSubnetId);
String extNetVpnName = extNetId.getValue();
String learnedSrcIp = adjacency.getIpAddress().split("/")[0];
InstanceIdentifier<LearntVpnVipToPort> id = NeutronvpnUtils.buildLearntVpnVipToPortIdentifier(extNetVpnName, learnedSrcIp);
Optional<LearntVpnVipToPort> optionalLearntVpnVipToPort = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
if (optionalLearntVpnVipToPort.isPresent()) {
neutronvpnUtils.removeLearntVpnVipToPort(extNetVpnName, learnedSrcIp);
LOG.trace("Removed Learnt Entry for fixedIP {} for port {}", adjacency.getIpAddress(), infName);
}
}
}
} catch (TransactionCommitFailedException | ExecutionException | InterruptedException e) {
LOG.error("exception in removeAdjacencyAndLearnedEntriesforExternalSubnet for interface {}", infName, e);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey in project netvirt by opendaylight.
the class TunnelInterfaceStateListener method handleTunnelEventForDPNVpn.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleTunnelEventForDPNVpn(StateTunnelList stateTunnelList, Map<Uint32, String> vpnIdRdMap, TunnelAction tunnelAction, boolean isTepDeletedOnDpn, List<Uuid> subnetList, TunnelEventProcessingMethod method, VpnInterface cfgVpnInterface) {
String rd;
String intfName = cfgVpnInterface.getName();
final Uint64 srcDpnId = Uint64.valueOf(stateTunnelList.getSrcInfo() != null ? stateTunnelList.getSrcInfo().getTepDeviceId() : "0").intern();
String destTepIp = stateTunnelList.getDstInfo() != null ? stateTunnelList.getDstInfo().getTepIp().stringValue() : null;
String srcTepIp = stateTunnelList.getSrcInfo() != null ? stateTunnelList.getSrcInfo().getTepIp().stringValue() : null;
int tunTypeVal = getTunnelType(stateTunnelList);
Uint64 remoteDpnId = null;
if (tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
remoteDpnId = Uint64.valueOf(stateTunnelList.getDstInfo() != null ? stateTunnelList.getDstInfo().getTepDeviceId() : "0").intern();
}
if (cfgVpnInterface.getVpnInstanceNames() == null) {
LOG.warn("handleTunnelEventForDpn: no vpnName found for interface {}", intfName);
return;
}
try {
for (VpnInstanceNames vpnInstance : cfgVpnInterface.getVpnInstanceNames().values()) {
String vpnName = vpnInstance.getVpnName();
if (method == TunnelEventProcessingMethod.POPULATESUBNETS) {
Optional<VpnInterfaceOpDataEntry> opVpnInterface = vpnUtil.getVpnInterfaceOpDataEntry(intfName, vpnName);
if (opVpnInterface.isPresent()) {
VpnInterfaceOpDataEntry vpnInterface = opVpnInterface.get();
jobCoordinator.enqueueJob("VPNINTERFACE-" + intfName, new UpdateVpnInterfaceOnTunnelEvent(tunnelAction, vpnInterface, stateTunnelList, isTepDeletedOnDpn));
// Populate the List of subnets
InstanceIdentifier<PortOpDataEntry> portOpIdentifier = InstanceIdentifier.builder(PortOpData.class).child(PortOpDataEntry.class, new PortOpDataEntryKey(intfName)).build();
Optional<PortOpDataEntry> optionalPortOp = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, portOpIdentifier);
if (optionalPortOp.isPresent()) {
List<Uuid> subnetIdList = optionalPortOp.get().getSubnetIds();
if (subnetIdList != null) {
for (Uuid subnetId : subnetIdList) {
if (!subnetList.contains(subnetId)) {
subnetList.add(subnetId);
}
}
}
}
// Populate the map for VpnId-to-Rd
Uint32 vpnId = vpnUtil.getVpnId(vpnName);
rd = vpnUtil.getVpnRd(vpnName);
vpnIdRdMap.put(vpnId, rd);
}
} else if (method == TunnelEventProcessingMethod.MANAGEREMOTEROUTES) {
Optional<VpnInterfaceOpDataEntry> opVpnInterface = vpnUtil.getVpnInterfaceOpDataEntry(intfName, vpnName);
if (opVpnInterface.isPresent()) {
VpnInterfaceOpDataEntry vpnInterface = opVpnInterface.get();
AdjacenciesOp adjacencies = vpnInterface.augmentation(AdjacenciesOp.class);
Map<AdjacencyKey, Adjacency> adjacencyKeyAdjacencyMap = adjacencies != null && adjacencies.getAdjacency() != null ? adjacencies.getAdjacency() : Collections.<AdjacencyKey, Adjacency>emptyMap();
String prefix = null;
Uint32 vpnId = vpnUtil.getVpnId(vpnInterface.getVpnInstanceName());
if (vpnIdRdMap.containsKey(vpnId)) {
rd = vpnIdRdMap.get(vpnId);
LOG.info("handleTunnelEventForDPN: Remote DpnId {} VpnId {} rd {} VpnInterface {}" + " srcTepIp {} destTepIp {}", remoteDpnId, vpnId, rd, vpnInterface, srcTepIp, destTepIp);
for (Adjacency adj : adjacencyKeyAdjacencyMap.values()) {
prefix = adj.getIpAddress();
Uint32 label = adj.getLabel();
if (tunnelAction == TunnelAction.TUNNEL_EP_ADD && tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
fibManager.manageRemoteRouteOnDPN(true, srcDpnId, vpnId, rd, prefix, destTepIp, label);
}
if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE && tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
fibManager.manageRemoteRouteOnDPN(false, srcDpnId, vpnId, rd, prefix, destTepIp, label);
}
}
}
}
}
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("handleTunnelEventForDPN: Failed to read data store for interface {} srcDpn {} srcTep {} " + "dstTep {}", intfName, srcDpnId, srcTepIp, destTepIp);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey in project netvirt by opendaylight.
the class VpnInterfaceManager method delAdjFromVpnInterface.
protected void delAdjFromVpnInterface(InstanceIdentifier<VpnInterfaceOpDataEntry> identifier, Adjacency adj, Uint64 dpnId, TypedWriteTransaction<Operational> writeOperTxn, TypedWriteTransaction<Configuration> writeConfigTxn) {
String interfaceName = identifier.firstKeyOf(VpnInterfaceOpDataEntry.class).getName();
String vpnName = identifier.firstKeyOf(VpnInterfaceOpDataEntry.class).getVpnInstanceName();
try {
Optional<VpnInterfaceOpDataEntry> optVpnInterface = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, identifier);
if (optVpnInterface.isPresent()) {
VpnInterfaceOpDataEntry currVpnIntf = optVpnInterface.get();
InstanceIdentifier<AdjacenciesOp> path = identifier.augmentation(AdjacenciesOp.class);
Optional<AdjacenciesOp> optAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, path);
if (optAdjacencies.isPresent()) {
Map<AdjacencyKey, Adjacency> keyAdjacencyMap = optAdjacencies.get().getAdjacency();
if (keyAdjacencyMap != null && !keyAdjacencyMap.isEmpty()) {
LOG.trace("delAdjFromVpnInterface: Adjacencies are {}", keyAdjacencyMap);
for (Adjacency adjacency : keyAdjacencyMap.values()) {
if (Objects.equals(adjacency.getIpAddress(), adj.getIpAddress())) {
String rd = adjacency.getVrfId();
if (adj.getNextHopIpList() != null) {
for (String nh : adj.getNextHopIpList()) {
deleteExtraRouteFromCurrentAndImportingVpns(currVpnIntf.getVpnInstanceName(), adj.getIpAddress(), nh, rd, currVpnIntf.getName(), writeConfigTxn, writeOperTxn);
}
} else if (adj.isPhysNetworkFunc()) {
LOG.info("delAdjFromVpnInterface: deleting PNF adjacency prefix {} subnet {}", adj.getIpAddress(), adj.getSubnetId());
fibManager.removeFibEntry(adj.getSubnetId().getValue(), adj.getIpAddress(), null, writeConfigTxn);
}
break;
}
}
}
LOG.info("delAdjFromVpnInterface: Removed adj {} on dpn {} rd {}", adj.getIpAddress(), dpnId, adj.getVrfId());
} else {
LOG.error("delAdjFromVpnInterface: Cannnot DEL adjacency, since operational interface is " + "unavailable dpnId {} adjIP {} rd {}", dpnId, adj.getIpAddress(), adj.getVrfId());
}
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("delAdjFromVpnInterface: Failed to read data store for ip {} interface {} dpn {} vpn {}", adj.getIpAddress(), interfaceName, dpnId, vpnName);
}
}
Aggregations