use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class SpeakerFlowSegmentRequestBuilderTest method buildFlow.
private Flow buildFlow(Switch srcSwitch, int srcPort, int srcVlan, Switch dstSwitch, int dstPort, int dstVlan, int bandwidth) {
Flow flow = Flow.builder().flowId(UUID.randomUUID().toString()).srcSwitch(srcSwitch).srcPort(srcPort).srcVlan(srcVlan).destSwitch(dstSwitch).destPort(dstPort).destVlan(dstVlan).bandwidth(bandwidth).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).build();
Long rawCookie = cookieFactory.next();
flow.setForwardPath(buildFlowPath(flow, flow.getSrcSwitch(), flow.getDestSwitch(), new FlowSegmentCookie(FlowPathDirection.FORWARD, rawCookie)));
flow.setReversePath(buildFlowPath(flow, flow.getDestSwitch(), flow.getSrcSwitch(), new FlowSegmentCookie(FlowPathDirection.REVERSE, rawCookie)));
return flow;
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class SimpleSwitchRuleConverterTest method buildFlow.
private Flow buildFlow(FlowEncapsulationType flowEncapsulationType, boolean checkWithGroup) {
Switch switchA = Switch.builder().switchId(TEST_SWITCH_ID_A).description("").build();
Switch switchB = Switch.builder().switchId(TEST_SWITCH_ID_B).description("").build();
Switch switchC = Switch.builder().switchId(TEST_SWITCH_ID_C).description("").build();
Flow flow = Flow.builder().flowId(TEST_FLOW_ID_A).srcSwitch(switchA).srcPort(FLOW_A_SRC_PORT).srcVlan(FLOW_A_SRC_VLAN).destSwitch(switchC).destPort(FLOW_A_DST_PORT).destVlan(FLOW_A_DST_VLAN).allocateProtectedPath(true).encapsulationType(flowEncapsulationType).bandwidth(FLOW_A_BANDWIDTH).status(FlowStatus.UP).build();
FlowPath forwardFlowPath = FlowPath.builder().pathId(FLOW_A_FORWARD_PATH_ID).cookie(new FlowSegmentCookie(FLOW_A_FORWARD_COOKIE_VALUE)).meterId(new MeterId(FLOW_A_FORWARD_METER_ID)).srcSwitch(switchA).destSwitch(switchC).status(FlowPathStatus.ACTIVE).bandwidth(FLOW_A_BANDWIDTH).build();
flow.setForwardPath(forwardFlowPath);
PathSegment forwardSegmentA = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchA).srcPort(FLOW_A_SEGMENT_A_SRC_PORT).destSwitch(switchB).destPort(FLOW_A_SEGMENT_A_DST_PORT).build();
PathSegment forwardSegmentB = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchB).srcPort(FLOW_A_SEGMENT_B_SRC_PORT).destSwitch(switchC).destPort(FLOW_A_SEGMENT_B_DST_PORT).build();
forwardFlowPath.setSegments(Lists.newArrayList(forwardSegmentA, forwardSegmentB));
if (checkWithGroup) {
FlowMirrorPoints flowMirrorPoints = FlowMirrorPoints.builder().mirrorSwitch(switchA).mirrorGroup(MirrorGroup.builder().switchId(TEST_SWITCH_ID_A).groupId(new GroupId(FLOW_GROUP_ID_A)).pathId(FLOW_A_FORWARD_PATH_ID).flowId(TEST_FLOW_ID_A).mirrorGroupType(MirrorGroupType.TRAFFIC_INTEGRITY).mirrorDirection(MirrorDirection.INGRESS).build()).build();
FlowMirrorPath flowMirrorPath = FlowMirrorPath.builder().pathId(new PathId("mirror_path")).mirrorSwitch(switchA).egressSwitch(switchA).egressPort(FLOW_GROUP_ID_A_OUT_PORT).egressOuterVlan(FLOW_GROUP_ID_A_OUT_VLAN).build();
flowMirrorPoints.addPaths(flowMirrorPath);
forwardFlowPath.addFlowMirrorPoints(flowMirrorPoints);
}
return flow;
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class SimpleSwitchRuleConverterTest method shouldConvertReverseLoopedFlowPathWithTransitVlanEncapToSimpleSwitchRules.
@Test
public void shouldConvertReverseLoopedFlowPathWithTransitVlanEncapToSimpleSwitchRules() {
Flow flow = buildFlow(FlowEncapsulationType.TRANSIT_VLAN);
flow.setLoopSwitchId(flow.getDestSwitchId());
List<SimpleSwitchRule> expectedSwitchRules = getSimpleSwitchRuleForTransitVlan();
expectedSwitchRules.add(SimpleSwitchRule.builder().switchId(TEST_SWITCH_ID_C).cookie(new FlowSegmentCookie(FLOW_A_FORWARD_COOKIE_VALUE).toBuilder().looped(true).build().getValue()).inPort(FLOW_A_SEGMENT_B_DST_PORT).outPort(FLOW_A_SEGMENT_B_DST_PORT).inVlan(FLOW_A_ENCAP_ID).build());
List<SimpleSwitchRule> switchRules = simpleSwitchRuleConverter.convertFlowPathToSimpleSwitchRules(flow, flow.getForwardPath(), TransitVlan.builder().flowId(TEST_FLOW_ID_A).pathId(FLOW_A_FORWARD_PATH_ID).vlan(FLOW_A_ENCAP_ID).build(), MIN_BURST_SIZE_IN_KBITS, BURST_COEFFICIENT);
assertEquals(expectedSwitchRules.size(), switchRules.size());
assertTrue(expectedSwitchRules.containsAll(switchRules));
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class SimpleSwitchRuleConverterTest method buildOneSwitchPortFlow.
private Flow buildOneSwitchPortFlow() {
Switch switchD = Switch.builder().switchId(TEST_SWITCH_ID_D).description("").build();
Flow flow = Flow.builder().flowId(TEST_FLOW_ID_B).srcSwitch(switchD).srcPort(FLOW_B_SRC_PORT).srcVlan(FLOW_B_SRC_VLAN).destSwitch(switchD).destPort(FLOW_B_SRC_PORT).destVlan(FLOW_B_DST_VLAN).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).bandwidth(FLOW_B_BANDWIDTH).status(FlowStatus.UP).build();
FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_B + "_forward_path")).cookie(new FlowSegmentCookie(FLOW_B_FORWARD_COOKIE_VALUE)).meterId(new MeterId(FLOW_B_FORWARD_METER_ID)).srcSwitch(switchD).destSwitch(switchD).status(FlowPathStatus.ACTIVE).bandwidth(FLOW_B_BANDWIDTH).build();
flow.setForwardPath(forwardFlowPath);
return flow;
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class FlowPathBuilderTest method shouldBuildFlowPathFor2SwitchPath.
@Test
public void shouldBuildFlowPathFor2SwitchPath() {
SwitchId switchId1 = new SwitchId(1);
SwitchId switchId2 = new SwitchId(2);
Path path = Path.builder().srcSwitchId(switchId1).destSwitchId(switchId2).segments(Collections.singletonList(Segment.builder().srcSwitchId(switchId1).srcPort(1).destSwitchId(switchId2).destPort(2).build())).build();
Flow flow = Flow.builder().flowId("test_flow").srcSwitch(Switch.builder().switchId(switchId1).build()).destSwitch(Switch.builder().switchId(switchId2).build()).build();
PathId pathId = new PathId("test_path_id");
MeterId meterId = new MeterId(MeterId.MIN_FLOW_METER_ID);
PathResources pathResources = PathResources.builder().pathId(pathId).meterId(meterId).build();
FlowSegmentCookie cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1);
FlowPath flowPath = builder.buildFlowPath(flow, pathResources, path, cookie, false, flow.getFlowId());
assertEquals(switchId1, flowPath.getSrcSwitchId());
assertEquals(switchId2, flowPath.getDestSwitchId());
assertEquals(pathId, flowPath.getPathId());
assertEquals(meterId, flowPath.getMeterId());
assertEquals(cookie, flowPath.getCookie());
assertThat(flowPath.getSegments(), hasSize(1));
}
Aggregations