use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project openflowplugin by opendaylight.
the class FlowConvertor method isSetVlanIdActionCasePresent.
// check if set vlanid action is present in the flow
private static boolean isSetVlanIdActionCasePresent(Flow flow) {
// If yes,then we would need to two flows
if (flow.getInstructions() != null && flow.getInstructions().getInstruction() != null) {
for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : flow.getInstructions().getInstruction()) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction.getInstruction();
if (curInstruction instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase applyActionscase = (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) curInstruction;
ApplyActions applyActions = applyActionscase.getApplyActions();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action action : applyActions.getAction()) {
if (action.getAction() instanceof SetVlanIdActionCase) {
return true;
}
}
}
}
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project openflowplugin by opendaylight.
the class FlowConvertor method toInstructions.
private List<Instruction> toInstructions(Flow flow, short version, BigInteger datapathid) {
final List<Instruction> instructionsList = new ArrayList<>();
final ActionConvertorData data = new ActionConvertorData(version);
data.setDatapathId(datapathid);
data.setIpProtocol(FlowConvertorUtil.getIpProtocolFromFlow(flow));
Instructions instructions = flow.getInstructions();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : instructions.getInstruction()) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction.getInstruction();
Optional<Instruction> result = PROCESSOR.process(curInstruction, data, getConvertorExecutor());
if (result.isPresent()) {
instructionsList.add(result.get());
}
}
return instructionsList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project openflowplugin by opendaylight.
the class FlowConvertor method toFlowModInput.
private FlowModInputBuilder toFlowModInput(Flow flow, VersionDatapathIdConvertorData versionConverterData) {
FlowModInputBuilder flowMod = new FlowModInputBuilder();
salToOFFlowCookie(flow, flowMod);
salToOFFlowCookieMask(flow, flowMod);
salToOFFlowTableId(flow, flowMod);
salToOFFlowCommand(flow, flowMod);
salToOFFlowIdleTimeout(flow, flowMod);
salToOFFlowHardTimeout(flow, flowMod);
salToOFFlowPriority(flow, flowMod);
salToOFFlowBufferId(flow, flowMod);
salToOFFlowOutPort(flow, flowMod);
salToOFFlowOutGroup(flow, flowMod);
// convert and inject flowFlags
final Optional<Object> conversion = getConvertorExecutor().convert(flow.getFlags(), versionConverterData);
FlowFlagsInjector.inject(conversion, flowMod, versionConverterData.getVersion());
// convert and inject match
final Optional<Object> conversionMatch = getConvertorExecutor().convert(flow.getMatch(), versionConverterData);
MatchInjector.inject(conversionMatch, flowMod, versionConverterData.getVersion());
if (flow.getInstructions() != null) {
flowMod.setInstruction(toInstructions(flow, versionConverterData.getVersion(), versionConverterData.getDatapathId()));
flowMod.setAction(getActions(versionConverterData.getVersion(), versionConverterData.getDatapathId(), flow));
}
flowMod.setVersion(versionConverterData.getVersion());
return flowMod;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project bgpcep by opendaylight.
the class TeLspAttributesParser method serializeLspAttributes.
static void serializeLspAttributes(final RSVPTeObjectRegistry registry, final TeLspAttributesCase linkState, final ByteBuf output) {
LOG.trace("Started serializing TE LSP Objects");
final ByteBuf byteBuf = Unpooled.buffer();
final TeLspAttributes teLspAttribute = linkState.getTeLspAttributes();
final TspecObject tSpec = teLspAttribute.getTspecObject();
registry.serializeRSPVTe(tSpec, byteBuf);
final FlowSpecObject flow = teLspAttribute.getFlowSpecObject();
registry.serializeRSPVTe(flow, byteBuf);
final SessionAttributeObject sao = teLspAttribute.getSessionAttributeObject();
if (sao instanceof BasicSessionAttributeObject) {
registry.serializeRSPVTe((BasicSessionAttributeObject) sao, byteBuf);
} else if (sao instanceof SessionAttributeObjectWithResourcesAffinities) {
registry.serializeRSPVTe((SessionAttributeObjectWithResourcesAffinities) sao, byteBuf);
}
final ExplicitRouteObject ero = teLspAttribute.getExplicitRouteObject();
registry.serializeRSPVTe(ero, byteBuf);
final RecordRouteObject rro = teLspAttribute.getRecordRouteObject();
registry.serializeRSPVTe(rro, byteBuf);
final FastRerouteObject fro = teLspAttribute.getFastRerouteObject();
if (fro instanceof BasicFastRerouteObject) {
registry.serializeRSPVTe((BasicFastRerouteObject) fro, byteBuf);
} else if (fro instanceof LegacyFastRerouteObject) {
registry.serializeRSPVTe((LegacyFastRerouteObject) fro, byteBuf);
}
final DetourObject dto = teLspAttribute.getDetourObject();
if (dto instanceof Ipv4DetourObject) {
registry.serializeRSPVTe((Ipv4DetourObject) dto, byteBuf);
} else if (dto instanceof Ipv6DetourObject) {
registry.serializeRSPVTe((Ipv6DetourObject) dto, byteBuf);
}
final ExcludeRouteObject exro = teLspAttribute.getExcludeRouteObject();
registry.serializeRSPVTe(exro, byteBuf);
final SecondaryExplicitRouteObject sero = teLspAttribute.getSecondaryExplicitRouteObject();
registry.serializeRSPVTe(sero, byteBuf);
final SecondaryRecordRouteObject srro = teLspAttribute.getSecondaryRecordRouteObject();
registry.serializeRSPVTe(srro, byteBuf);
final LspAttributesObject lspAtt = teLspAttribute.getLspAttributesObject();
registry.serializeRSPVTe(lspAtt, byteBuf);
final LspRequiredAttributesObject rao = teLspAttribute.getLspRequiredAttributesObject();
registry.serializeRSPVTe(rao, byteBuf);
final ProtectionObject po = teLspAttribute.getProtectionObject();
if (po instanceof DynamicControlProtectionObject) {
registry.serializeRSPVTe((DynamicControlProtectionObject) po, byteBuf);
} else if (po instanceof BasicProtectionObject) {
registry.serializeRSPVTe((BasicProtectionObject) po, byteBuf);
}
final AssociationObject aso = teLspAttribute.getAssociationObject();
registry.serializeRSPVTe(aso, byteBuf);
final PrimaryPathRouteObject ppr = teLspAttribute.getPrimaryPathRouteObject();
registry.serializeRSPVTe(ppr, byteBuf);
final AdminStatusObject adso = teLspAttribute.getAdminStatusObject();
registry.serializeRSPVTe(adso, byteBuf);
final BandwidthObject bo = teLspAttribute.getBandwidthObject();
if (bo instanceof BasicBandwidthObject) {
registry.serializeRSPVTe((BasicBandwidthObject) bo, byteBuf);
} else if (bo instanceof ReoptimizationBandwidthObject) {
registry.serializeRSPVTe((ReoptimizationBandwidthObject) bo, byteBuf);
}
final MetricObject mo = teLspAttribute.getMetricObject();
registry.serializeRSPVTe(mo, byteBuf);
output.writeShort(MAGIC_NUMBER);
output.writeShort(byteBuf.readableBytes());
output.writeBytes(byteBuf);
LOG.trace("Finished serializing TE LSP Objects");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project genius by opendaylight.
the class FlowBasedServicesUtils method installLPortDispatcherFlow.
public static void installLPortDispatcherFlow(BigInteger dpId, BoundServices boundService, String interfaceName, WriteTransaction writeTransaction, int interfaceTag, short currentServiceIndex, short nextServiceIndex) {
String serviceRef = boundService.getServiceName();
List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForDispatcherTable(interfaceTag, currentServiceIndex);
// Get the metadata and mask from the service's write metadata
// instruction
StypeOpenflow stypeOpenFlow = boundService.getAugmentation(StypeOpenflow.class);
List<Instruction> serviceInstructions = stypeOpenFlow.getInstruction();
int instructionSize = serviceInstructions != null ? serviceInstructions.size() : 0;
BigInteger[] metadataValues = IfmUtil.mergeOpenflowMetadataWriteInstructions(serviceInstructions);
BigInteger metadata = MetaDataUtil.getMetaDataForLPortDispatcher(interfaceTag, nextServiceIndex, metadataValues[0]);
BigInteger metadataMask = MetaDataUtil.getWriteMetaDataMaskForDispatcherTable();
// build the final instruction for LPort Dispatcher table flow entry
List<Instruction> instructions = new ArrayList<>();
instructions.add(MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, ++instructionSize));
if (serviceInstructions != null && !serviceInstructions.isEmpty()) {
for (Instruction info : serviceInstructions) {
// Skip meta data write as that is handled already
if (info.getInstruction() instanceof WriteMetadataCase) {
continue;
} else if (info.getInstruction() instanceof WriteActionsCase) {
info = MDSALUtil.buildWriteActionsInstruction(ActionConverterUtil.convertServiceActionToFlowAction(((WriteActionsCase) info.getInstruction()).getWriteActions().getAction()));
} else if (info.getInstruction() instanceof ApplyActionsCase) {
info = MDSALUtil.buildApplyActionsInstruction(ActionConverterUtil.convertServiceActionToFlowAction(((ApplyActionsCase) info.getInstruction()).getApplyActions().getAction()));
}
instructions.add(info);
}
}
// build the flow and install it
String flowRef = getFlowRef(dpId, NwConstants.LPORT_DISPATCHER_TABLE, interfaceName, currentServiceIndex);
Flow ingressFlow = MDSALUtil.buildFlowNew(NwConstants.LPORT_DISPATCHER_TABLE, flowRef, DEFAULT_DISPATCHER_PRIORITY, serviceRef, 0, 0, stypeOpenFlow.getFlowCookie(), matches, instructions);
LOG.debug("Installing LPort Dispatcher Flow on DPN {}, for interface {}, with flowRef {}", dpId, interfaceName, flowRef);
installFlow(dpId, ingressFlow, writeTransaction);
}
Aggregations