use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project netvirt by opendaylight.
the class GeniusProvider method getEgressVxlanPortForNode.
public Optional<Long> getEgressVxlanPortForNode(BigInteger dpnId) {
List<OvsdbTerminationPointAugmentation> tpList = interfaceMgr.getTunnelPortsOnBridge(dpnId);
if (tpList == null) {
// Most likely the bridge doesnt exist for this dpnId
LOG.warn("getEgressVxlanPortForNode Tunnel Port TerminationPoint list not available for dpnId [{}]", dpnId);
return Optional.empty();
}
for (OvsdbTerminationPointAugmentation tp : tpList) {
if (tp == null) {
// Technically we should never have a list with NULL entries, but
// in a preliminary version of interfaceMgr.getTunnelPortsOnBridge()
// we were getting a list where all termination point entries were
// null. Leaving this check for now for protection.
LOG.error("getEgressVxlanPortForNode received a NULL termination point from tpList on dpnId [{}]", dpnId);
continue;
}
Class<? extends InterfaceTypeBase> ifType = tp.getInterfaceType();
if (ifType.equals(InterfaceTypeVxlan.class)) {
List<Options> tpOptions = tp.getOptions();
for (Options tpOption : tpOptions) {
// From the VXLAN Tunnels, we want the one with the GPE option set
if (tpOption.getKey().getOption().equals(OPTION_KEY_EXTS)) {
if (tpOption.getValue().equals(OPTION_VALUE_EXTS_GPE)) {
return Optional.ofNullable(tp.getOfport());
}
}
}
}
}
LOG.warn("getEgressVxlanPortForNode no Vxgpe tunnel ports available for dpnId [{}]", dpnId);
return Optional.empty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project genius by opendaylight.
the class HwVtepTunnelsStateHandler method resetMonitoringTask.
// tunnelKey, nodeId, topologyId are initialized to null and immediately passed to getTunnelIdentifier which
// FindBugs as a "Load of known null value" violation. Not sure sure what the intent...
@SuppressFBWarnings("NP_LOAD_OF_KNOWN_NULL_VALUE")
void resetMonitoringTask(boolean isEnable) {
// TODO: get the corresponding hwvtep tunnel from the sourceInterface
// once InterfaceMgr implements renderer for HWVTEP VXLAN tunnels
// tunnelKey, nodeId, topologyId are initialized to null and immediately passed to getTunnelIdentifier which
// FindBugs flags as a "Load of known null value" violation. Not sure sure what the intent...
TunnelsKey tunnelKey = null;
String nodeId = null;
String topologyId = null;
Optional<Tunnels> tunnelsOptional = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, getTunnelIdentifier(topologyId, nodeId, tunnelKey));
if (!tunnelsOptional.isPresent()) {
LOG.warn("Tunnel {} is not present on the Node {}. So not disabling the BFD monitoring", tunnelKey, nodeId);
return;
}
Tunnels tunnel = tunnelsOptional.get();
List<BfdParams> tunnelBfdParams = tunnel.getBfdParams();
if (tunnelBfdParams == null || tunnelBfdParams.isEmpty()) {
LOG.debug("there is no bfd params available for the tunnel {}", tunnel);
return;
}
Iterator<BfdParams> tunnelBfdParamsIterator = tunnelBfdParams.iterator();
while (tunnelBfdParamsIterator.hasNext()) {
BfdParams bfdParam = tunnelBfdParamsIterator.next();
if (bfdParam.getBfdParamKey().equals(AlivenessMonitorConstants.BFD_PARAM_ENABLE)) {
tunnelBfdParamsIterator.remove();
break;
}
}
setBfdParamForEnable(tunnelBfdParams, isEnable);
Tunnels tunnelWithBfdReset = new TunnelsBuilder().setKey(tunnelKey).setBfdParams(tunnelBfdParams).build();
MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, getTunnelIdentifier(topologyId, nodeId, tunnelKey), tunnelWithBfdReset);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project genius by opendaylight.
the class HwVtepTunnelsStateHandler method update.
@Override
public void update(@Nonnull Tunnels oldTunnelInfo, @Nonnull Tunnels updatedTunnelInfo) {
List<BfdStatus> oldBfdStatus = oldTunnelInfo.getBfdStatus();
List<BfdStatus> newBfdStatus = updatedTunnelInfo.getBfdStatus();
LivenessState oldTunnelOpState = getTunnelOpState(oldBfdStatus);
final LivenessState newTunnelOpState = getTunnelOpState(newBfdStatus);
if (oldTunnelOpState == newTunnelOpState) {
LOG.debug("Tunnel state of old tunnel {} and update tunnel {} are same", oldTunnelInfo, updatedTunnelInfo);
return;
}
updatedTunnelInfo.getTunnelUuid();
String interfaceName = "<TODO>";
// TODO: find out the corresponding interface using tunnelIdentifier or
// any attributes of tunnelInfo object
final String monitorKey = getBfdMonitorKey(interfaceName);
LOG.debug("Processing monitorKey: {} for received Tunnels update DCN", monitorKey);
final Semaphore lock = alivenessMonitor.getLock(monitorKey);
LOG.debug("Acquiring lock for monitor key : {} to process monitor DCN", monitorKey);
alivenessMonitor.acquireLock(lock);
final ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
ListenableFuture<Optional<MonitoringState>> stateResult = tx.read(LogicalDatastoreType.OPERATIONAL, getMonitorStateId(monitorKey));
Futures.addCallback(stateResult, new FutureCallback<Optional<MonitoringState>>() {
@Override
public void onSuccess(@Nonnull Optional<MonitoringState> optState) {
if (optState.isPresent()) {
final MonitoringState currentState = optState.get();
if (currentState.getState() == newTunnelOpState) {
return;
}
final boolean stateChanged = true;
final MonitoringState state = new MonitoringStateBuilder().setMonitorKey(monitorKey).setState(newTunnelOpState).build();
tx.merge(LogicalDatastoreType.OPERATIONAL, getMonitorStateId(monitorKey), state);
ListenableFuture<Void> writeResult = tx.submit();
// WRITE Callback
Futures.addCallback(writeResult, new FutureCallback<Void>() {
@Override
public void onSuccess(Void arg0) {
alivenessMonitor.releaseLock(lock);
if (stateChanged) {
// send notifications
LOG.info("Sending notification for monitor Id : {} with Current State: {}", currentState.getMonitorId(), newTunnelOpState);
alivenessMonitor.publishNotification(currentState.getMonitorId(), newTunnelOpState);
} else {
if (LOG.isTraceEnabled()) {
LOG.trace("Successful in writing monitoring state {} to ODS", state);
}
}
}
@Override
public void onFailure(@Nonnull Throwable error) {
alivenessMonitor.releaseLock(lock);
LOG.warn("Error in writing monitoring state : {} to Datastore", monitorKey, error);
if (LOG.isTraceEnabled()) {
LOG.trace("Error in writing monitoring state: {} to Datastore", state);
}
}
}, MoreExecutors.directExecutor());
} else {
LOG.warn("Monitoring State not available for key: {} to process the Packet received", monitorKey);
// Complete the transaction
tx.submit();
alivenessMonitor.releaseLock(lock);
}
}
@Override
public void onFailure(@Nonnull Throwable error) {
LOG.error("Error when reading Monitoring State for key: {} to process the Packet received", monitorKey, error);
// FIXME: Not sure if the transaction status is valid to cancel
tx.cancel();
alivenessMonitor.releaseLock(lock);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project genius by opendaylight.
the class ItmManagerRpcService method getInternalOrExternalInterfaceName.
@Override
public Future<RpcResult<GetInternalOrExternalInterfaceNameOutput>> getInternalOrExternalInterfaceName(GetInternalOrExternalInterfaceNameInput input) {
RpcResultBuilder<GetInternalOrExternalInterfaceNameOutput> resultBld = RpcResultBuilder.failed();
BigInteger srcDpn = input.getSourceDpid();
IpAddress dstIp = input.getDestinationIp();
InstanceIdentifier<ExternalTunnel> path1 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(String.valueOf(dstIp.getValue()), srcDpn.toString(), input.getTunnelType()));
Optional<ExternalTunnel> optExtTunnel = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path1, dataBroker);
if (optExtTunnel != null && optExtTunnel.isPresent()) {
ExternalTunnel extTunnel = optExtTunnel.get();
GetInternalOrExternalInterfaceNameOutputBuilder output = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(extTunnel.getTunnelInterfaceName());
resultBld = RpcResultBuilder.success();
resultBld.withResult(output.build());
} else {
Collection<DPNTEPsInfo> meshedDpnList = dpnTEPsInfoCache.getAllPresent();
// Look for external tunnels if not look for internal tunnel
for (DPNTEPsInfo teps : meshedDpnList) {
TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
if (dstIp.equals(firstEndPt.getIpAddress())) {
Optional<InternalTunnel> optTunnel = Optional.absent();
if (ItmUtils.isTunnelAggregationUsed(input.getTunnelType())) {
optTunnel = ItmUtils.getInternalTunnelFromDS(srcDpn, teps.getDPNID(), TunnelTypeLogicalGroup.class, dataBroker);
LOG.debug("MULTIPLE_VxLAN_TUNNELS: getInternalOrExternalInterfaceName {}", optTunnel);
}
if (!optTunnel.isPresent()) {
optTunnel = ItmUtils.getInternalTunnelFromDS(srcDpn, teps.getDPNID(), input.getTunnelType(), dataBroker);
}
if (optTunnel.isPresent()) {
InternalTunnel tunnel = optTunnel.get();
List<String> tunnelInterfaces = tunnel.getTunnelInterfaceNames();
if (tunnelInterfaces != null && !tunnelInterfaces.isEmpty()) {
GetInternalOrExternalInterfaceNameOutputBuilder output = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(tunnelInterfaces.get(0));
resultBld = RpcResultBuilder.success();
resultBld.withResult(output.build());
} else {
LOG.error("No tunnel interface found between source DPN {} ans destination IP {}", srcDpn, dstIp);
}
break;
} else {
LOG.error("Tunnel not found for source DPN {} ans destination IP {}", srcDpn, dstIp);
}
}
}
}
return Futures.immediateFuture(resultBld.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project genius by opendaylight.
the class ItmUtils method getTunnelsofTzone.
public static List<String> getTunnelsofTzone(List<HwVtep> hwVteps, String tzone, DataBroker dataBroker, Boolean hwVtepsExist) {
List<String> tunnels = new ArrayList<>();
InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzone)).build();
Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
if (transportZoneOptional.isPresent()) {
TransportZone transportZone = transportZoneOptional.get();
Class<? extends TunnelTypeBase> tunType = transportZone.getTunnelType();
if (transportZone.getSubnets() != null && !transportZone.getSubnets().isEmpty()) {
for (Subnets sub : transportZone.getSubnets()) {
if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
for (Vteps vtepLocal : sub.getVteps()) {
for (Vteps vtepRemote : sub.getVteps()) {
if (!vtepLocal.equals(vtepRemote)) {
InternalTunnelKey key = new InternalTunnelKey(vtepRemote.getDpnId(), vtepLocal.getDpnId(), tunType);
InstanceIdentifier<InternalTunnel> intIID = InstanceIdentifier.builder(TunnelList.class).child(InternalTunnel.class, key).build();
Optional<InternalTunnel> tunnelsOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, intIID, dataBroker);
if (tunnelsOptional.isPresent()) {
List<String> tunnelInterfaceNames = tunnelsOptional.get().getTunnelInterfaceNames();
if (tunnelInterfaceNames != null && !tunnelInterfaceNames.isEmpty()) {
String tunnelInterfaceName = tunnelInterfaceNames.get(0);
LOG.trace("Internal Tunnel added {}", tunnelInterfaceName);
tunnels.add(tunnelInterfaceName);
}
}
}
}
if (hwVteps != null && !hwVteps.isEmpty()) {
for (HwVtep hwVtep : hwVteps) {
tunnels.add(getExtTunnel(hwVtep.getNodeId(), vtepLocal.getDpnId().toString(), tunType, dataBroker));
tunnels.add(getExtTunnel(vtepLocal.getDpnId().toString(), hwVtep.getNodeId(), tunType, dataBroker));
}
}
}
}
}
}
if (hwVtepsExist) {
for (HwVtep hwVtep : hwVteps) {
for (HwVtep hwVtepOther : hwVteps) {
if (!hwVtep.getHwIp().equals(hwVtepOther.getHwIp())) {
tunnels.add(getExtTunnel(hwVtep.getNodeId(), hwVtepOther.getNodeId(), tunType, dataBroker));
tunnels.add(getExtTunnel(hwVtepOther.getNodeId(), hwVtep.getNodeId(), tunType, dataBroker));
}
}
}
}
}
return tunnels;
}
Aggregations