use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.Path in project netvirt by opendaylight.
the class NodeConnectedHandlerUtils method addPsNode.
void addPsNode(InstanceIdentifier<Node> path, InstanceIdentifier<Node> parentPath, List<String> portNameList, TypedWriteTransaction<Operational> tx) {
PhysicalSwitchAugmentationBuilder physicalSwitchAugmentationBuilder = new PhysicalSwitchAugmentationBuilder();
physicalSwitchAugmentationBuilder.setManagedBy(new HwvtepGlobalRef(parentPath));
physicalSwitchAugmentationBuilder.setPhysicalSwitchUuid(getUUid("d1s3"));
physicalSwitchAugmentationBuilder.setHwvtepNodeName(new HwvtepNodeName("s3"));
physicalSwitchAugmentationBuilder.setHwvtepNodeDescription("description");
List<TunnelIps> tunnelIps = new ArrayList<>();
IpAddress ip = new IpAddress(new Ipv4Address("192.168.122.30"));
tunnelIps.add(new TunnelIpsBuilder().withKey(new TunnelIpsKey(ip)).setTunnelIpsKey(ip).build());
physicalSwitchAugmentationBuilder.setTunnelIps(tunnelIps);
NodeBuilder nodeBuilder = prepareOperationalNode(path);
nodeBuilder.addAugmentation(physicalSwitchAugmentationBuilder.build());
PhysicalSwitchHelper.dId = parentPath;
nodeBuilder.setTerminationPoint(PhysicalSwitchHelper.addPhysicalSwitchTerminationPoints(path, portNameList));
tx.mergeParentStructurePut(path, nodeBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.Path in project netvirt by opendaylight.
the class NodeConnectedHandlerUtils method addNode.
void addNode(InstanceIdentifier<Node> path, InstanceIdentifier<Node> psPath, String logicalSwitchData, String localUcasMacData, String localMcastData, String remoteMcastData, String remoteUcasteMacData, String globalTerminationPointIp, TypedWriteTransaction<Operational> tx) {
NodeBuilder nodeBuilder = prepareOperationalNode(path);
HwvtepGlobalAugmentationBuilder augmentationBuilder = prepareAugmentationBuilder();
GlobalAugmentationHelper.addLogicalSwitches(augmentationBuilder, getData(logicalSwitchData));
GlobalAugmentationHelper.addLocalUcastMacs(path, augmentationBuilder, getData(localUcasMacData));
GlobalAugmentationHelper.addLocalMcastMacs(path, augmentationBuilder, getData(localMcastData));
GlobalAugmentationHelper.addRemoteMcastMacs(path, augmentationBuilder, getData(remoteMcastData));
GlobalAugmentationHelper.addRemoteUcastMacs(path, augmentationBuilder, getData(remoteUcasteMacData));
GlobalAugmentationHelper.addGlobalTerminationPoints(nodeBuilder, path, getData(globalTerminationPointIp));
GlobalAugmentationHelper.addSwitches(augmentationBuilder, psPath);
nodeBuilder.addAugmentation(augmentationBuilder.build());
tx.put(path, nodeBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.Path in project netvirt by opendaylight.
the class VpnInterfaceManager method advertiseAdjacenciesForVpnToBgp.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void advertiseAdjacenciesForVpnToBgp(final String rd, Uint64 dpnId, final InstanceIdentifier<VpnInterfaceOpDataEntry> identifier, String vpnName, String interfaceName) {
if (rd == null) {
LOG.error("advertiseAdjacenciesForVpnFromBgp: Unable to recover rd for interface {} on dpn {} in vpn {}", interfaceName, dpnId, vpnName);
return;
} else {
if (rd.equals(vpnName)) {
LOG.info("advertiseAdjacenciesForVpnFromBgp: Ignoring BGP advertisement for interface {} on dpn {}" + " as it is in internal vpn{} with rd {}", interfaceName, dpnId, vpnName, rd);
return;
}
}
LOG.info("advertiseAdjacenciesForVpnToBgp: Advertising interface {} on dpn {} in vpn {} with rd {} ", interfaceName, dpnId, vpnName, rd);
String nextHopIp = InterfaceUtils.getEndpointIpAddressForDPN(dataBroker, dpnId);
if (nextHopIp == null) {
LOG.error("advertiseAdjacenciesForVpnToBgp: NextHop for interface {} on dpn {} is null," + " returning from advertising route with rd {} vpn {} to bgp", interfaceName, dpnId, rd, vpnName);
return;
}
try {
// Read NextHops
InstanceIdentifier<AdjacenciesOp> path = identifier.augmentation(AdjacenciesOp.class);
Optional<AdjacenciesOp> adjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, path);
if (adjacencies.isPresent()) {
Map<AdjacencyKey, Adjacency> nextHopsMap = adjacencies.get().getAdjacency();
if (nextHopsMap != null && !nextHopsMap.isEmpty()) {
LOG.debug("advertiseAdjacenciesForVpnToBgp: NextHops are {} for interface {} on dpn {} for vpn {}" + " rd {}", nextHopsMap, interfaceName, dpnId, vpnName, rd);
VpnInstanceOpDataEntry vpnInstanceOpData = vpnUtil.getVpnInstanceOpData(rd);
Uint32 l3vni = vpnInstanceOpData.getL3vni();
VrfEntry.EncapType encapType = VpnUtil.isL3VpnOverVxLan(l3vni) ? VrfEntry.EncapType.Vxlan : VrfEntry.EncapType.Mplsgre;
for (Adjacency nextHop : nextHopsMap.values()) {
if (nextHop.getAdjacencyType() == AdjacencyType.ExtraRoute) {
continue;
}
String gatewayMac = null;
Uint32 label = Uint32.ZERO;
if (VpnUtil.isL3VpnOverVxLan(l3vni)) {
final VpnPortipToPort gwPort = vpnUtil.getNeutronPortFromVpnPortFixedIp(vpnInstanceOpData.getVpnInstanceName(), nextHop.getIpAddress());
gatewayMac = arpResponderHandler.getGatewayMacAddressForInterface(gwPort, interfaceName).get();
} else {
label = nextHop.getLabel();
}
try {
LOG.info("VPN ADVERTISE: advertiseAdjacenciesForVpnToBgp: Adding Fib Entry rd {} prefix {}" + " nexthop {} label {}", rd, nextHop.getIpAddress(), nextHopIp, label);
bgpManager.advertisePrefix(rd, nextHop.getMacAddress(), nextHop.getIpAddress(), nextHopIp, encapType, label, l3vni, Uint32.ZERO, /*l2vni*/
gatewayMac);
LOG.info("VPN ADVERTISE: advertiseAdjacenciesForVpnToBgp: Added Fib Entry rd {} prefix {}" + " nexthop {} label {} for interface {} on dpn {} for vpn {}", rd, nextHop.getIpAddress(), nextHopIp, label, interfaceName, dpnId, vpnName);
} catch (Exception e) {
LOG.error("advertiseAdjacenciesForVpnToBgp: Failed to advertise prefix {} in vpn {}" + " with rd {} for interface {} on dpn {}", nextHop.getIpAddress(), vpnName, rd, interfaceName, dpnId, e);
}
}
}
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("advertiseAdjacenciesForVpnToBgp: Failed to read data store for interface {} dpn {} nexthop {}" + "vpn {} rd {}", interfaceName, dpnId, nextHopIp, vpnName, rd);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.Path in project netvirt by opendaylight.
the class VpnInterfaceManager method processVpnInterfaceUp.
// "Unconditional wait" and "Wait not in loop" wrt the VpnNotifyTask below - suppressing the FB violation -
// see comments below.
@SuppressFBWarnings({ "UW_UNCOND_WAIT", "WA_NOT_IN_LOOP" })
protected void processVpnInterfaceUp(final Uint64 dpId, VpnInterface vpnInterface, final String primaryRd, final int lportTag, boolean isInterfaceUp, TypedWriteTransaction<Configuration> writeConfigTxn, TypedWriteTransaction<Operational> writeOperTxn, TypedReadWriteTransaction<Configuration> writeInvTxn, Interface interfaceState, final String vpnName, Set<String> prefixListForRefreshFib) throws ExecutionException, InterruptedException {
final String interfaceName = vpnInterface.getName();
Optional<VpnInterfaceOpDataEntry> optOpVpnInterface = vpnUtil.getVpnInterfaceOpDataEntry(interfaceName, vpnName);
VpnInterfaceOpDataEntry opVpnInterface = optOpVpnInterface.isPresent() ? optOpVpnInterface.get() : null;
boolean isBgpVpnInternetVpn = vpnUtil.isBgpVpnInternet(vpnName);
if (!isInterfaceUp) {
LOG.info("processVpnInterfaceUp: Binding vpn service to interface {} onto dpn {} for vpn {}", interfaceName, dpId, vpnName);
Uint32 vpnId = vpnUtil.getVpnId(vpnName);
if (VpnConstants.INVALID_ID.equals(vpnId)) {
LOG.warn("processVpnInterfaceUp: VpnInstance to VPNId mapping not available for VpnName {}" + " processing vpninterface {} on dpn {}, bailing out now.", vpnName, interfaceName, dpId);
return;
}
boolean waitForVpnInterfaceOpRemoval = false;
if (opVpnInterface != null) {
String opVpnName = opVpnInterface.getVpnInstanceName();
String primaryInterfaceIp = null;
if (Objects.equals(opVpnName, vpnName)) {
// Please check if the primary VRF Entry does not exist for VPNInterface
// If so, we have to process ADD, as this might be a DPN Restart with Remove and Add triggered
// back to back
// However, if the primary VRF Entry for this VPNInterface exists, please continue bailing out !
List<Adjacency> adjs = vpnUtil.getAdjacenciesForVpnInterfaceFromConfig(interfaceName);
if (adjs == null) {
LOG.error("processVpnInterfaceUp: VPN Interface {} on dpn {} for vpn {} failed as adjacencies" + " for this vpn interface could not be obtained", interfaceName, dpId, vpnName);
return;
}
for (Adjacency adj : adjs) {
if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
primaryInterfaceIp = adj.getIpAddress();
break;
}
}
if (primaryInterfaceIp == null) {
LOG.error("processVpnInterfaceUp: VPN Interface {} addition on dpn {} for vpn {} failed" + " as primary adjacency for this vpn interface could not be obtained", interfaceName, dpId, vpnName);
return;
}
// Get the rd of the vpn instance
VrfEntry vrf = vpnUtil.getVrfEntry(primaryRd, primaryInterfaceIp);
if (vrf != null) {
LOG.error("processVpnInterfaceUp: VPN Interface {} on dpn {} for vpn {} already provisioned ," + " bailing out from here.", interfaceName, dpId, vpnName);
return;
}
waitForVpnInterfaceOpRemoval = true;
} else {
LOG.error("processVpnInterfaceUp: vpn interface {} to go to configured vpn {} on dpn {}," + " but in operational vpn {}", interfaceName, vpnName, dpId, opVpnName);
}
}
if (!waitForVpnInterfaceOpRemoval) {
// Add the VPNInterface and quit
vpnFootprintService.updateVpnToDpnMapping(dpId, vpnName, primaryRd, interfaceName, null, /*ipAddressSourceValuePair*/
true);
processVpnInterfaceAdjacencies(dpId, lportTag, vpnName, primaryRd, interfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState, prefixListForRefreshFib);
if (!isBgpVpnInternetVpn) {
vpnUtil.bindService(vpnName, interfaceName, false);
}
LOG.info("processVpnInterfaceUp: Plumbed vpn interface {} onto dpn {} for vpn {}", interfaceName, dpId, vpnName);
if (interfaceManager.isExternalInterface(interfaceName)) {
processExternalVpnInterface(interfaceName, vpnName, dpId, lportTag, NwConstants.ADD_FLOW);
}
return;
}
// FIB didn't get a chance yet to clean up this VPNInterface
// Let us give it a chance here !
LOG.info("processVpnInterfaceUp: Trying to add VPN Interface {} on dpn {} for vpn {}," + " but waiting for FIB to clean up! ", interfaceName, dpId, vpnName);
try {
Runnable notifyTask = new VpnNotifyTask();
synchronized (notifyTask) {
// Per FB's "Unconditional wait" violation, the code should really verify that the condition it
// intends to wait for is not already satisfied before calling wait. However the VpnNotifyTask is
// published here while holding the lock on it so this path will hit the wait before notify can be
// invoked.
vpnIntfMap.put(interfaceName, notifyTask);
try {
notifyTask.wait(VpnConstants.MAX_WAIT_TIME_IN_MILLISECONDS);
} catch (InterruptedException e) {
// Ignored
}
}
} finally {
vpnIntfMap.remove(interfaceName);
}
if (opVpnInterface != null) {
LOG.warn("processVpnInterfaceUp: VPN Interface {} removal on dpn {} for vpn {}" + " by FIB did not complete on time," + " bailing addition ...", interfaceName, dpId, vpnName);
vpnUtil.unsetScheduledToRemoveForVpnInterface(interfaceName);
return;
}
// VPNInterface got removed, proceed with Add
LOG.info("processVpnInterfaceUp: Continuing to plumb vpn interface {} onto dpn {} for vpn {}", interfaceName, dpId, vpnName);
vpnFootprintService.updateVpnToDpnMapping(dpId, vpnName, primaryRd, interfaceName, null, /*ipAddressSourceValuePair*/
true);
processVpnInterfaceAdjacencies(dpId, lportTag, vpnName, primaryRd, interfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState, prefixListForRefreshFib);
if (!isBgpVpnInternetVpn) {
vpnUtil.bindService(vpnName, interfaceName, false);
}
LOG.info("processVpnInterfaceUp: Plumbed vpn interface {} onto dpn {} for vpn {} after waiting for" + " FIB to clean up", interfaceName, dpId, vpnName);
if (interfaceManager.isExternalInterface(interfaceName)) {
processExternalVpnInterface(interfaceName, vpnName, dpId, lportTag, NwConstants.ADD_FLOW);
}
} else {
try {
// Interface is retained in the DPN, but its Link Up.
// Advertise prefixes again for this interface to BGP
InstanceIdentifier<VpnInterface> identifier = VpnUtil.getVpnInterfaceIdentifier(vpnInterface.getName());
InstanceIdentifier<VpnInterfaceOpDataEntry> vpnInterfaceOpIdentifier = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
advertiseAdjacenciesForVpnToBgp(primaryRd, dpId, vpnInterfaceOpIdentifier, vpnName, interfaceName);
// Perform similar operation as interface add event for extraroutes.
InstanceIdentifier<Adjacencies> path = identifier.augmentation(Adjacencies.class);
Optional<Adjacencies> optAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
if (!optAdjacencies.isPresent()) {
LOG.trace("No config adjacencyKeyAdjacencyMap present for vpninterface {}", vpnInterface);
return;
}
Map<AdjacencyKey, Adjacency> adjacencyKeyAdjacencyMap = optAdjacencies.get().nonnullAdjacency();
for (Adjacency adjacency : adjacencyKeyAdjacencyMap.values()) {
if (adjacency.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
continue;
}
// if BGPVPN Internet, filter only IPv6 Adjacencies
if (isBgpVpnInternetVpn && !vpnUtil.isAdjacencyEligibleToVpnInternet(adjacency)) {
continue;
}
addNewAdjToVpnInterface(vpnInterfaceOpIdentifier, primaryRd, adjacency, dpId, writeOperTxn, writeConfigTxn, writeInvTxn, prefixListForRefreshFib);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("processVpnInterfaceUp: Failed to read data store for interface {} vpn {} rd {} dpn {}", interfaceName, vpnName, primaryRd, dpId);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.Path in project netvirt by opendaylight.
the class AddVpnPseudoPortDataJob method call.
@Override
public List<ListenableFuture<Void>> call() {
LOG.debug("Adding VpnToPseudoPortMap: vpnRd={} vpnPseudoLportTag={} scfTag={} scfTable={}", super.vpnRd, vpnPseudoLportTag, scfTag, scfTableIdToGo);
VpnToPseudoPortData newValue = new VpnToPseudoPortDataBuilder().withKey(new VpnToPseudoPortDataKey(super.vpnRd)).setVrfId(super.vpnRd).setScfTableId(scfTableIdToGo).setScfTag(scfTag).setVpnLportTag(vpnPseudoLportTag).build();
LOG.trace("Adding lportTag={} to VpnToLportTag map for VPN with rd={}", vpnPseudoLportTag, vpnRd);
InstanceIdentifier<VpnToPseudoPortData> path = VpnServiceChainUtils.getVpnToPseudoPortTagIid(vpnRd);
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, path, newValue)));
}
Aggregations