use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep in project genius by opendaylight.
the class ItmOfTunnelDeleteWorker method removeTunnelConfiguration.
private void removeTunnelConfiguration(OfDpnTep dpnTep, TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException, OperationFailedException {
LOG.info("removing ofTep configuration for {}", dpnTep.getOfPortName());
Optional<OvsBridgeRefEntry> ovsBridgeRefEntry = ovsBridgeRefEntryCache.get(dpnTep.getSourceDpnId());
Optional<OvsBridgeEntry> ovsBridgeEntryOptional;
OvsdbBridgeRef ovsdbBridgeRef = null;
if (ovsBridgeRefEntry.isPresent()) {
ovsdbBridgeRef = ovsBridgeRefEntry.get().getOvsBridgeReference();
} else {
ovsBridgeEntryOptional = ovsBridgeEntryCache.get(dpnTep.getSourceDpnId());
if (ovsBridgeEntryOptional.isPresent()) {
ovsdbBridgeRef = ovsBridgeEntryOptional.get().getOvsBridgeReference();
}
}
if (ovsdbBridgeRef != null) {
removeTerminationEndPoint(ovsdbBridgeRef.getValue(), dpnTep.getOfPortName());
}
// delete tunnel ingress flow
removeOfPortIngressFlow(tx, dpnTep.getOfPortName(), dpnTep.getSourceDpnId());
// delete bridge to tunnel interface mappings
OvsBridgeEntryKey bridgeEntryKey = new OvsBridgeEntryKey(dpnTep.getSourceDpnId());
InstanceIdentifier<OvsBridgeEntry> bridgeEntryIid = DirectTunnelUtils.getOvsBridgeEntryIdentifier(bridgeEntryKey);
ovsBridgeEntryOptional = ovsBridgeEntryCache.get(dpnTep.getSourceDpnId());
if (ovsBridgeEntryOptional.isPresent()) {
Map<OvsBridgeTunnelEntryKey, OvsBridgeTunnelEntry> bridgeTunnelEntries = ovsBridgeEntryOptional.get().getOvsBridgeTunnelEntry();
deleteBridgeInterfaceEntry(bridgeEntryKey, bridgeTunnelEntries.values().stream().collect(Collectors.toList()), bridgeEntryIid, dpnTep.getOfPortName());
// IfIndex needs to be removed only during State Clean up not Config
cleanUpOfTepWithUnknownState(dpnTep.getOfPortName(), tx);
directTunnelUtils.removeLportTagInterfaceMap(dpnTep.getOfPortName());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep in project genius by opendaylight.
the class TunnelInventoryStateListener method handleOfTepStateUpdates.
private void handleOfTepStateUpdates(Optional<OfDpnTep> dpnTepInfo, TypedReadWriteTransaction<Operational> tx, boolean opStateModified, String ofTepName, Interface.OperStatus opState) {
LOG.debug("updating oftep state entry for {}", ofTepName);
InstanceIdentifier<OfTep> ofTepStateId = ItmUtils.buildStateOfTepListId(new OfTepKey(ofTepName));
OfTepBuilder ofTepBuilder = new OfTepBuilder();
ofTepBuilder.withKey(new OfTepKey(ofTepName));
if (opStateModified) {
LOG.debug("updating oftep oper status as {} for {}", opState.getName(), ofTepName);
ofTepBuilder.setOfTepState(DirectTunnelUtils.convertInterfaceToTunnelOperState(opState));
LOG.trace("updated to {} for {}", opState.getName(), ofTepName);
}
tx.merge(ofTepStateId, ofTepBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep in project genius by opendaylight.
the class TunnelInventoryStateListener method removeOfTepStateConfiguration.
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "https://github.com/spotbugs/spotbugs/issues/811")
private List<? extends ListenableFuture<?>> removeOfTepStateConfiguration(NodeConnectorId nodeConnectorIdNew, NodeConnectorId nodeConnectorIdOld, String ofTepName, FlowCapableNodeConnector fcNodeConnectorOld) {
List<ListenableFuture<?>> futures = new ArrayList<>();
NodeConnectorId nodeConnectorId = (nodeConnectorIdOld != null && !nodeConnectorIdNew.equals(nodeConnectorIdOld)) ? nodeConnectorIdOld : nodeConnectorIdNew;
Uint64 dpId = DirectTunnelUtils.getDpnFromNodeConnectorId(nodeConnectorId);
// scenario, and should be treated as port removal.
if (fcNodeConnectorOld.getReason() != PortReason.Delete) {
// Remove event is because of connection lost between controller and switch, or switch shutdown.
// Hence, dont remove the interface but set the status as "unknown"
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
updateOfTepStateOnNodeRemove(dpId, ofTepName, fcNodeConnectorOld, tx);
}));
} else {
LOG.debug("removing oftep state for oftep: {}", ofTepName);
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
directTunnelUtils.deleteOfTepStateEntry(ofTepName);
directTunnelUtils.removeLportTagInterfaceMap(ofTepName);
directTunnelUtils.removeTunnelIngressFlow(tx, dpId, ofTepName);
}));
EVENT_LOGGER.debug("ITM-OfTepInventoryState,REMOVE Table 0 flow for {} completed", ofTepName);
}
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep in project genius by opendaylight.
the class OfPortStateAddWorker method addStateEntry.
private OfTep addStateEntry(String ofPortName, long portNo) throws ExecutionException, InterruptedException, OperationFailedException {
final int ifIndex = directTunnelUtils.allocateId(IfmConstants.IFM_IDPOOL_NAME, ofPortName);
if (ifIndex == ITMConstants.INVALID_ID) {
LOG.trace("aborting addStateEntry for {}, due to invalid Id", ofPortName);
return null;
}
createLportTagInterfaceMap(ofPortName, ifIndex);
final OfTepBuilder ofTepBuilder = new OfTepBuilder();
Interface.OperStatus operStatus = Interface.OperStatus.Up;
TunnelOperStatus tunnelOperStatus = DirectTunnelUtils.convertInterfaceToTunnelOperState(operStatus);
OfTepKey ofTepKey = new OfTepKey(ofPortName);
ofTepBuilder.withKey(ofTepKey).setTunnelType(dpnTep.getTunnelType()).setOfPortName(ofPortName).setTepIp(dpnTep.getTepIp()).setPortNumber(String.valueOf(portNo)).setIfIndex(Uint16.valueOf(ifIndex)).setOfTepState(tunnelOperStatus).setSourceDpnId(dpnTep.getSourceDpnId());
InstanceIdentifier<OfTep> ofTepsListId = ItmUtils.buildStateOfTepListId(ofTepKey);
LOG.trace("Batching the Creation of tunnel_state: {} for Id: {}", ofTepBuilder.build(), ofTepsListId);
ITMBatchingUtils.write(ofTepsListId, ofTepBuilder.build(), ITMBatchingUtils.EntityType.DEFAULT_OPERATIONAL);
return ofTepBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep in project genius by opendaylight.
the class ItmManagerRpcService method getEgressActionsForInternalTunnels.
private ListenableFuture<GetEgressActionsForTunnelOutput> getEgressActionsForInternalTunnels(String interfaceName, Long tunnelKey, Integer actionKey) throws ExecutionException, InterruptedException, OperationFailedException {
if (interfaceName.startsWith("of")) {
Optional<OfTep> oftep = ofTepStateCache.get(interfaceName);
if (!oftep.isPresent()) {
throw new IllegalStateException("Interface information not present in oper DS for" + interfaceName);
}
List<ActionInfo> actions = getEgressActionInfosForOpenFlowTunnel(oftep.get().getIfIndex(), oftep.get().getTepIp(), tunnelKey, actionKey);
return Futures.immediateFuture(new GetEgressActionsForTunnelOutputBuilder().setAction(actions.stream().map(ActionInfo::buildAction).collect(Collectors.toList())).build());
} else {
DpnTepInterfaceInfo interfaceInfo = dpnTepStateCache.getTunnelFromCache(interfaceName);
if (interfaceInfo == null) {
throw new IllegalStateException("Interface information not present in config DS for" + interfaceName);
}
String tunnelType = ItmUtils.convertTunnelTypetoString(interfaceInfo.getTunnelType());
if (!tunnelType.equalsIgnoreCase(ITMConstants.TUNNEL_TYPE_VXLAN)) {
throw new IllegalArgumentException(tunnelType + " tunnel not handled by ITM");
}
Optional<DPNTEPsInfo> dpntePsInfoOptional = dpnTEPsInfoCache.get(InstanceIdentifier.builder(DpnEndpoints.class).child(DPNTEPsInfo.class, new DPNTEPsInfoKey(// FIXME: the cache should be caching this value, not just as a String
dpnTepStateCache.getTunnelEndPointInfoFromCache(interfaceInfo.getTunnelName()).getDstEndPointInfo())).build());
Integer dstId;
if (dpntePsInfoOptional.isPresent()) {
dstId = dpntePsInfoOptional.get().getDstId();
} else {
dstId = directTunnelUtils.allocateId(ITMConstants.ITM_IDPOOL_NAME, interfaceInfo.getRemoteDPN().toString());
}
List<ActionInfo> result = new ArrayList<>();
long regValue = MetaDataUtil.getRemoteDpnMetadatForEgressTunnelTable(dstId);
int actionKeyStart = actionKey == null ? 0 : actionKey;
result.add(new ActionSetFieldTunnelId(actionKeyStart++, Uint64.valueOf(tunnelKey != null ? tunnelKey : 0L)));
result.add(new ActionRegLoad(actionKeyStart++, NxmNxReg6.class, MetaDataUtil.REG6_START_INDEX, MetaDataUtil.REG6_END_INDEX, regValue));
result.add(new ActionNxResubmit(actionKeyStart, NwConstants.EGRESS_TUNNEL_TABLE));
return Futures.immediateFuture(new GetEgressActionsForTunnelOutputBuilder().setAction(result.stream().map(ActionInfo::buildAction).collect(Collectors.toList())).build());
}
}
Aggregations