Search in sources :

Example 36 with FlowSegmentCookie

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;
}
Also used : FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Flow(org.openkilda.model.Flow)

Example 37 with FlowSegmentCookie

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;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) FlowMirrorPath(org.openkilda.model.FlowMirrorPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId) GroupId(org.openkilda.model.GroupId)

Example 38 with FlowSegmentCookie

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));
}
Also used : FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 39 with FlowSegmentCookie

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;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId)

Example 40 with FlowSegmentCookie

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));
}
Also used : FlowPath(org.openkilda.model.FlowPath) Path(org.openkilda.pce.Path) PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathResources(org.openkilda.wfm.share.flow.resources.FlowResources.PathResources) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Aggregations

FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)59 Flow (org.openkilda.model.Flow)33 FlowPath (org.openkilda.model.FlowPath)31 PathId (org.openkilda.model.PathId)23 MeterId (org.openkilda.model.MeterId)19 Test (org.junit.Test)15 PathSegment (org.openkilda.model.PathSegment)15 Switch (org.openkilda.model.Switch)15 ArrayList (java.util.ArrayList)8 SwitchId (org.openkilda.model.SwitchId)8 FlowEntry (org.openkilda.messaging.info.rule.FlowEntry)6 UUID (java.util.UUID)5 FlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory)5 IngressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory)5 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)5 DeleteRulesCriteria (org.openkilda.messaging.command.switches.DeleteRulesCriteria)4 MirrorConfig (org.openkilda.model.MirrorConfig)4 YFlow (org.openkilda.model.YFlow)4 Before (org.junit.Before)3 EgressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory)3