use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGenerator method buildServer42IngressCommand.
private FlowSpeakerData buildServer42IngressCommand(Switch sw, FlowEndpoint ingressEndpoint, Set<FieldMatch> match, int priority) {
FlowSegmentCookie cookie = new FlowSegmentCookie(flowPath.getCookie().getValue()).toBuilder().type(CookieType.SERVER_42_FLOW_RTT_INGRESS).build();
FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(ingressEndpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.INGRESS).priority(priority).match(match).instructions(buildIngressInstructions(sw, ingressEndpoint.getInnerVlanId()));
if (sw.getFeatures().contains(SwitchFeature.RESET_COUNTS_FLAG)) {
builder.flags(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS));
}
return builder.build();
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class RerouteServiceTest method setup.
@Before
public void setup() throws Throwable {
doAnswer(invocation -> {
TransactionCallbackWithoutResult<?> arg = invocation.getArgument(0);
arg.doInTransaction();
return null;
}).when(transactionManager).doInTransaction(Mockito.<TransactionCallbackWithoutResult<?>>any());
doAnswer(invocation -> {
TransactionCallback<?, ?> arg = invocation.getArgument(0);
return arg.doInTransaction();
}).when(transactionManager).doInTransaction(Mockito.<TransactionCallback<?, ?>>any());
pinnedFlow = Flow.builder().flowId(FLOW_ID).srcSwitch(SWITCH_A).destSwitch(SWITCH_C).pinned(true).build();
FlowPath pinnedFlowForwardPath = FlowPath.builder().pathId(new PathId("1")).srcSwitch(SWITCH_A).destSwitch(SWITCH_C).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1)).build();
List<PathSegment> pinnedFlowForwardSegments = new ArrayList<>();
pinnedFlowForwardSegments.add(PathSegment.builder().pathId(pinnedFlowForwardPath.getPathId()).srcSwitch(SWITCH_A).srcPort(1).destSwitch(SWITCH_B).destPort(1).build());
pinnedFlowForwardSegments.add(PathSegment.builder().pathId(pinnedFlowForwardPath.getPathId()).srcSwitch(SWITCH_B).srcPort(2).destSwitch(SWITCH_C).destPort(1).build());
pinnedFlowForwardPath.setSegments(pinnedFlowForwardSegments);
FlowPath pinnedFlowReversePath = FlowPath.builder().pathId(new PathId("2")).srcSwitch(SWITCH_C).destSwitch(SWITCH_A).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 2)).build();
List<PathSegment> pinnedFlowReverseSegments = new ArrayList<>();
pinnedFlowReverseSegments.add(PathSegment.builder().pathId(pinnedFlowReversePath.getPathId()).srcSwitch(SWITCH_C).srcPort(1).destSwitch(SWITCH_B).destPort(2).build());
pinnedFlowReverseSegments.add(PathSegment.builder().pathId(pinnedFlowReversePath.getPathId()).srcSwitch(SWITCH_B).srcPort(1).destSwitch(SWITCH_A).destPort(1).build());
pinnedFlowReversePath.setSegments(pinnedFlowReverseSegments);
pinnedFlow.setForwardPath(pinnedFlowForwardPath);
pinnedFlow.setReversePath(pinnedFlowReversePath);
regularFlow = Flow.builder().flowId(FLOW_ID).srcSwitch(SWITCH_A).destSwitch(SWITCH_C).pinned(false).priority(2).build();
FlowPath regularFlowForwardPath = FlowPath.builder().pathId(new PathId("3")).srcSwitch(SWITCH_A).destSwitch(SWITCH_C).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 3)).status(FlowPathStatus.ACTIVE).build();
List<PathSegment> unpinnedFlowForwardSegments = new ArrayList<>();
unpinnedFlowForwardSegments.add(PathSegment.builder().pathId(regularFlowForwardPath.getPathId()).srcSwitch(SWITCH_A).srcPort(1).destSwitch(SWITCH_B).destPort(1).build());
unpinnedFlowForwardSegments.add(PathSegment.builder().pathId(regularFlowForwardPath.getPathId()).srcSwitch(SWITCH_B).srcPort(2).destSwitch(SWITCH_C).destPort(1).build());
regularFlowForwardPath.setSegments(unpinnedFlowForwardSegments);
FlowPath regularFlowReversePath = FlowPath.builder().pathId(new PathId("4")).srcSwitch(SWITCH_C).destSwitch(SWITCH_A).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 3)).status(FlowPathStatus.ACTIVE).build();
List<PathSegment> unpinnedFlowReverseSegments = new ArrayList<>();
unpinnedFlowReverseSegments.add(PathSegment.builder().pathId(regularFlowReversePath.getPathId()).srcSwitch(SWITCH_C).srcPort(1).destSwitch(SWITCH_B).destPort(2).build());
unpinnedFlowReverseSegments.add(PathSegment.builder().pathId(regularFlowReversePath.getPathId()).srcSwitch(SWITCH_B).srcPort(1).destSwitch(SWITCH_A).destPort(1).build());
regularFlowReversePath.setSegments(unpinnedFlowReverseSegments);
regularFlow.setForwardPath(regularFlowForwardPath);
regularFlow.setReversePath(regularFlowReversePath);
oneSwitchFlow = Flow.builder().flowId(FLOW_ID).srcSwitch(SWITCH_A).destSwitch(SWITCH_A).build();
FlowPath oneSwitchFlowForwardPath = FlowPath.builder().pathId(new PathId("5")).srcSwitch(SWITCH_A).destSwitch(SWITCH_A).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 4)).status(FlowPathStatus.ACTIVE).build();
FlowPath oneSwitchFlowReversePath = FlowPath.builder().pathId(new PathId("6")).srcSwitch(SWITCH_A).destSwitch(SWITCH_A).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 4)).status(FlowPathStatus.ACTIVE).build();
oneSwitchFlow.setForwardPath(oneSwitchFlowForwardPath);
oneSwitchFlow.setReversePath(oneSwitchFlowReversePath);
regularYFlow = YFlow.builder().yFlowId(YFLOW_ID).priority(2).sharedEndpoint(new SharedEndpoint(SWITCH_A.getSwitchId(), 10)).build();
FlowPath regularYFlowForwardPath = FlowPath.builder().pathId(new PathId("3")).srcSwitch(SWITCH_A).destSwitch(SWITCH_C).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 3)).status(FlowPathStatus.ACTIVE).build();
regularYFlowForwardPath.setSegments(unpinnedFlowForwardSegments);
FlowPath regularYFlowReversePath = FlowPath.builder().pathId(new PathId("4")).srcSwitch(SWITCH_C).destSwitch(SWITCH_A).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 3)).status(FlowPathStatus.ACTIVE).build();
regularYFlowReversePath.setSegments(unpinnedFlowReverseSegments);
subFlow = Flow.builder().flowId(SUB_YFLOW_ID).srcSwitch(SWITCH_A).destSwitch(SWITCH_C).pinned(false).priority(2).yFlowId(YFLOW_ID).yFlow(regularYFlow).build();
subFlow.setForwardPath(regularYFlowForwardPath);
subFlow.setReversePath(regularYFlowReversePath);
Set<YSubFlow> subFlows = Collections.singleton(YSubFlow.builder().yFlow(regularYFlow).flow(subFlow).build());
regularYFlow.setSubFlows(subFlows);
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class TestFlowBuilder method build.
/**
* Build a Flow with set properties.
*/
public Flow build() {
Switch srcSwitch = source.sw;
Switch destSwitch = destination.sw;
if (srcSwitch.getSwitchId().equals(destSwitch.getSwitchId())) {
checkArgument(transit.isEmpty(), "Transit endpoints were provided for a one-switch flow");
checkArgument(protectedTransit.isEmpty(), "ProtectedTransit endpoints were provided for a one-switch flow");
} else {
checkArgument(transit.isEmpty() || transit.size() % 2 == 0, "The number of transit endpoints is wrong");
}
checkArgument(protectedTransit.isEmpty() || protectedUnmaskedCookie != unmaskedCookie, "Same unmasked cookies provided with enabled ProtectedTransit");
Flow flow = Flow.builder().flowId(flowId).yFlowId(yFlowId).srcSwitch(srcSwitch).srcPort(source.port).srcVlan(srcVlan).destSwitch(destSwitch).destPort(destination.port).destVlan(destVlan).bandwidth(bandwidth).ignoreBandwidth(ignoreBandwidth).encapsulationType(encapsulationType).maxLatency(maxLatency).priority(priority).detectConnectedDevices(detectConnectedDevices).pathComputationStrategy(pathComputationStrategy).description(description).build();
flow.setStatus(status);
FlowPath forwardPath = buildFlowPath(flow, srcSwitch, destSwitch, transit, new FlowSegmentCookie(FlowPathDirection.FORWARD, unmaskedCookie), new MeterId(forwardMeterId));
flow.setForwardPath(forwardPath);
FlowPath reversePath = buildFlowPath(flow, destSwitch, srcSwitch, Lists.reverse(transit), new FlowSegmentCookie(FlowPathDirection.REVERSE, unmaskedCookie), new MeterId(reverseMeterId));
flow.setReversePath(reversePath);
if (!protectedTransit.isEmpty()) {
FlowPath protectedForwardPath = buildFlowPath(flow, srcSwitch, destSwitch, protectedTransit, new FlowSegmentCookie(FlowPathDirection.FORWARD, protectedUnmaskedCookie), new MeterId(protectedForwardMeterId));
flow.setProtectedForwardPath(protectedForwardPath);
FlowPath protectedReversePath = buildFlowPath(flow, destSwitch, srcSwitch, Lists.reverse(protectedTransit), new FlowSegmentCookie(FlowPathDirection.REVERSE, protectedUnmaskedCookie), new MeterId(protectedReverseMeterId));
flow.setProtectedReversePath(protectedReversePath);
}
return flow;
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class FlowMapper method buildPath.
private FlowPath buildPath(FlowDto flowDto) {
Switch srcSwitch = Switch.builder().switchId(flowDto.getSourceSwitch()).build();
Switch destSwitch = Switch.builder().switchId(flowDto.getDestinationSwitch()).build();
return FlowPath.builder().srcSwitch(srcSwitch).destSwitch(destSwitch).cookie(new FlowSegmentCookie(flowDto.getCookie())).bandwidth(flowDto.getBandwidth()).ignoreBandwidth(flowDto.isIgnoreBandwidth()).pathId(new PathId(UUID.randomUUID().toString())).meterId(flowDto.getMeterId() != null ? new MeterId(flowDto.getMeterId()) : null).build();
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class CommandBuilderImplTest method shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithTransitVlanEncapsulation.
@Test
public void shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithTransitVlanEncapsulation() {
Long cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue();
String inPort = "1";
String inVlan = "10";
String outPort = "2";
FlowEntry flowEntry = buildFlowEntry(cookie, inPort, inVlan, outPort, null, false, null, null);
RemoveFlow removeFlow = commandBuilder.buildRemoveFlowWithoutMeterFromFlowEntry(SWITCH_ID_A, flowEntry);
assertEquals(cookie, removeFlow.getCookie());
DeleteRulesCriteria criteria = removeFlow.getCriteria();
assertEquals(cookie, criteria.getCookie());
assertEquals(Integer.valueOf(inPort), criteria.getInPort());
assertEquals(Integer.valueOf(inVlan), criteria.getEncapsulationId());
assertEquals(Integer.valueOf(outPort), criteria.getOutPort());
assertNull(criteria.getMetadataValue());
assertNull(criteria.getMetadataMask());
}
Aggregations