use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags in project openflowplugin by opendaylight.
the class FlowStatsResponseConvertor method convert.
@Override
public List<FlowAndStatisticsMapList> convert(List<FlowStats> source, FlowStatsResponseConvertorData data) {
final List<FlowAndStatisticsMapList> result = new ArrayList<>();
for (FlowStats flowStats : source) {
// Convert Openflow switch specific flow statistics to the MD-SAL format flow statistics
FlowAndStatisticsMapListBuilder salFlowStatsBuilder = new FlowAndStatisticsMapListBuilder();
salFlowStatsBuilder.setByteCount(new Counter64(flowStats.getByteCount()));
if (flowStats.getCookie() != null) {
salFlowStatsBuilder.setCookie(new FlowCookie(flowStats.getCookie()));
}
DurationBuilder time = new DurationBuilder();
time.setSecond(new Counter32(flowStats.getDurationSec()));
time.setNanosecond(new Counter32(flowStats.getDurationNsec()));
salFlowStatsBuilder.setDuration(time.build());
salFlowStatsBuilder.setHardTimeout(flowStats.getHardTimeout());
salFlowStatsBuilder.setIdleTimeout(flowStats.getIdleTimeout());
salFlowStatsBuilder.setPacketCount(new Counter64(flowStats.getPacketCount()));
salFlowStatsBuilder.setPriority(flowStats.getPriority());
salFlowStatsBuilder.setTableId(flowStats.getTableId());
Short ipProtocol = null;
if (flowStats.getMatchV10() != null) {
final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(flowStats.getMatchV10(), data);
if (matchBuilderOptional.isPresent()) {
if (Objects.nonNull(matchBuilderOptional.get().getIpMatch())) {
ipProtocol = matchBuilderOptional.get().getIpMatch().getIpProtocol();
}
salFlowStatsBuilder.setMatch(matchBuilderOptional.get().build());
}
if (flowStats.getAction() != null && flowStats.getAction().size() != 0) {
salFlowStatsBuilder.setInstructions(wrapOF10ActionsToInstruction(flowStats.getAction(), data.getVersion(), ipProtocol));
}
}
if (flowStats.getMatch() != null) {
final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(flowStats.getMatch(), data);
if (matchBuilderOptional.isPresent()) {
final MatchBuilder matchBuilder = matchBuilderOptional.get();
final AugmentTuple<Match> matchExtensionWrap = MatchExtensionHelper.processAllExtensions(flowStats.getMatch().getMatchEntry(), OpenflowVersion.get(data.getVersion()), data.getMatchPath());
if (matchExtensionWrap != null) {
matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
}
salFlowStatsBuilder.setMatch(matchBuilder.build());
}
salFlowStatsBuilder.setFlags(new FlowModFlags(flowStats.getFlags().isOFPFFCHECKOVERLAP(), flowStats.getFlags().isOFPFFRESETCOUNTS(), flowStats.getFlags().isOFPFFNOPKTCOUNTS(), flowStats.getFlags().isOFPFFNOBYTCOUNTS(), flowStats.getFlags().isOFPFFSENDFLOWREM()));
}
if (flowStats.getInstruction() != null) {
final VersionConvertorData simpleConvertorData = new VersionConvertorData(data.getVersion());
final Optional<Instructions> instructions = getConvertorExecutor().convert(flowStats.getInstruction(), simpleConvertorData);
salFlowStatsBuilder.setInstructions(instructions.orElse(new InstructionsBuilder().setInstruction(Collections.emptyList()).build()));
}
result.add(salFlowStatsBuilder.build());
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags in project openflowplugin by opendaylight.
the class LLDPPacketPuntEnforcer method createFlow.
static Flow createFlow() {
FlowBuilder flowBuilder = new FlowBuilder();
flowBuilder.setMatch(new MatchBuilder().build());
flowBuilder.setInstructions(createSendToControllerInstructions().build());
flowBuilder.setPriority(0);
FlowKey key = new FlowKey(new FlowId(DEFAULT_FLOW_ID));
flowBuilder.setBarrier(Boolean.FALSE);
flowBuilder.setBufferId(OFConstants.OFP_NO_BUFFER);
BigInteger value = BigInteger.valueOf(10L);
flowBuilder.setCookie(new FlowCookie(value));
flowBuilder.setCookieMask(new FlowCookie(value));
flowBuilder.setHardTimeout(0);
flowBuilder.setIdleTimeout(0);
flowBuilder.setInstallHw(false);
flowBuilder.setStrict(false);
flowBuilder.setContainerName(null);
flowBuilder.setFlags(new FlowModFlags(false, false, false, false, true));
flowBuilder.setId(new FlowId("12"));
flowBuilder.setTableId(TABLE_ID);
flowBuilder.setKey(key);
flowBuilder.setFlowName(LLDP_PUNT_WHOLE_PACKET_FLOW);
return flowBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createTestFlowPerfTest.
private FlowBuilder createTestFlowPerfTest(final String flowTypeArg, final String tableId, final int id) {
final FlowBuilder flow = new FlowBuilder();
String flowType = flowTypeArg;
int flowId = id;
if (flowType == null) {
flowType = "f1";
}
flow.setPriority(flowId);
switch(flowType) {
case "f1":
flowId += 1;
flow.setMatch(createMatch1().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
default:
LOG.warn("flow type not understood: {}", flowType);
}
final FlowKey key = new FlowKey(new FlowId(Long.toString(flowId)));
if (null == flow.isBarrier()) {
flow.setBarrier(Boolean.FALSE);
}
final BigInteger value = BigInteger.valueOf(10);
flow.setCookie(new FlowCookie(value));
flow.setCookieMask(new FlowCookie(value));
flow.setHardTimeout(0);
flow.setIdleTimeout(0);
flow.setInstallHw(false);
flow.setStrict(false);
flow.setContainerName(null);
flow.setFlags(new FlowModFlags(false, false, false, false, true));
flow.setId(new FlowId("12"));
flow.setTableId(getTableId(tableId));
flow.setKey(key);
flow.setFlowName(ORIGINAL_FLOW_NAME + "X" + flowType);
return flow;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createTestFlow.
private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
FlowBuilder flow = new FlowBuilder();
long id = 123;
String flowType = flowTypeArg;
if (flowType == null) {
flowType = "f1";
}
switch(flowType) {
case "f1":
id += 1;
flow.setMatch(createMatch1().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f2":
id += 2;
flow.setMatch(createMatch2().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f3":
id += 3;
flow.setMatch(createMatch3().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f4":
id += 4;
flow.setMatch(createEthernetMatch().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f82":
id += 1;
flow.setMatch(createMatch1().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f5":
id += 5;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction().build());
break;
case "f6":
id += 6;
flow.setMatch(createMatch1().build());
flow.setInstructions(createGotoTableInstructions().build());
break;
case "f7":
id += 7;
flow.setMatch(createMatch1().build());
flow.setInstructions(createMeterInstructions().build());
break;
case "f8":
id += 8;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction7().build());
break;
case "f9":
id += 9;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction2().build());
break;
case "f10":
id += 10;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction3().build());
break;
case "f14":
id += 14;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction7().build());
break;
case "f29":
id += 29;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction21().build());
break;
default:
LOG.warn("flow type not understood: {}", flowType);
}
final FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
if (null == flow.isBarrier()) {
flow.setBarrier(Boolean.FALSE);
}
// flow.setBufferId(12L);
BigInteger value = BigInteger.valueOf(10);
BigInteger outputPort = BigInteger.valueOf(4294967295L);
flow.setCookie(new FlowCookie(value));
flow.setCookieMask(new FlowCookie(value));
flow.setHardTimeout(0);
flow.setIdleTimeout(0);
flow.setInstallHw(false);
flow.setStrict(false);
flow.setContainerName(null);
flow.setFlags(new FlowModFlags(false, false, false, false, true));
flow.setId(new FlowId("12"));
flow.setTableId(getTableId(tableId));
flow.setOutGroup(4294967295L);
// set outport to OFPP_NONE (65535) to disable remove restriction for
// flow
flow.setOutPort(outputPort);
flow.setKey(key);
flow.setPriority(2);
flow.setFlowName(originalFlowName + "X" + flowType);
return flow;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags in project openflowplugin by opendaylight.
the class FlowConvertorTest method test.
/**
* Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
*/
@Test
public void test() {
RemoveFlowInputBuilder flowBuilder = new RemoveFlowInputBuilder();
flowBuilder.setBarrier(false);
flowBuilder.setCookie(new FlowCookie(new BigInteger("4")));
flowBuilder.setCookieMask(new FlowCookie(new BigInteger("5")));
flowBuilder.setTableId((short) 6);
flowBuilder.setStrict(true);
flowBuilder.setIdleTimeout(50);
flowBuilder.setHardTimeout(500);
flowBuilder.setPriority(40);
flowBuilder.setBufferId(18L);
flowBuilder.setOutPort(new BigInteger("65535"));
flowBuilder.setOutGroup(5000L);
flowBuilder.setFlags(null);
flowBuilder.setMatch(null);
RemoveFlowInput flow = flowBuilder.build();
VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
data.setDatapathId(new BigInteger("42"));
List<FlowModInputBuilder> flowMod = convert(flow, data);
Assert.assertEquals("Wrong version", 4, flowMod.get(0).getVersion().intValue());
Assert.assertEquals("Wrong cookie", 4, flowMod.get(0).getCookie().intValue());
Assert.assertEquals("Wrong cookie mask", 5, flowMod.get(0).getCookieMask().intValue());
Assert.assertEquals("Wrong table id", 6, flowMod.get(0).getTableId().getValue().intValue());
Assert.assertEquals("Wrong command", FlowModCommand.OFPFCDELETESTRICT, flowMod.get(0).getCommand());
Assert.assertEquals("Wrong idle timeout", 50, flowMod.get(0).getIdleTimeout().intValue());
Assert.assertEquals("Wrong hard timeout", 500, flowMod.get(0).getHardTimeout().intValue());
Assert.assertEquals("Wrong priority", 40, flowMod.get(0).getPriority().intValue());
Assert.assertEquals("Wrong buffer id", 18, flowMod.get(0).getBufferId().intValue());
Assert.assertEquals("Wrong out port", 65535, flowMod.get(0).getOutPort().getValue().intValue());
Assert.assertEquals("Wrong out group", 5000, flowMod.get(0).getOutGroup().intValue());
Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowMod.get(0).getFlags());
Assert.assertEquals("Wrong match", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType", flowMod.get(0).getMatch().getType().getName());
Assert.assertEquals("Wrong match entries size", 0, flowMod.get(0).getMatch().getMatchEntry().size());
}
Aggregations