Search in sources :

Example 71 with PathId

use of org.openkilda.model.PathId 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 72 with PathId

use of org.openkilda.model.PathId 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 73 with PathId

use of org.openkilda.model.PathId 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)

Example 74 with PathId

use of org.openkilda.model.PathId in project open-kilda by telstra.

the class FlowPathBuilderTest method shouldDetectDifferenceInPortsFor2SwitchPaths.

@Test
public void shouldDetectDifferenceInPortsFor2SwitchPaths() {
    SwitchId switchId1 = new SwitchId(1);
    Switch switch1 = Switch.builder().switchId(switchId1).build();
    SwitchId switchId2 = new SwitchId(2);
    Switch switch2 = Switch.builder().switchId(switchId2).build();
    Path path = Path.builder().srcSwitchId(switchId1).destSwitchId(switchId2).segments(Collections.singletonList(Segment.builder().srcSwitchId(switchId1).srcPort(1).destSwitchId(switchId2).destPort(2).build())).build();
    PathId flowPathId = new PathId("test_path_id");
    FlowPath flowPath = FlowPath.builder().srcSwitch(switch1).destSwitch(switch2).pathId(flowPathId).segments(Collections.singletonList(PathSegment.builder().pathId(flowPathId).srcSwitch(switch1).srcPort(2).destSwitch(switch2).destPort(3).build())).build();
    assertFalse(builder.isSamePath(path, flowPath));
}
Also used : FlowPath(org.openkilda.model.FlowPath) Path(org.openkilda.pce.Path) PathId(org.openkilda.model.PathId) Switch(org.openkilda.model.Switch) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) Test(org.junit.Test)

Example 75 with PathId

use of org.openkilda.model.PathId in project open-kilda by telstra.

the class FlowPathBuilderTest method shouldDetectSameSwitchPaths.

@Test
public void shouldDetectSameSwitchPaths() {
    SwitchId switchId = new SwitchId(1);
    Switch switchEntity = Switch.builder().switchId(switchId).build();
    Path path = Path.builder().srcSwitchId(switchId).destSwitchId(switchId).segments(Collections.emptyList()).build();
    FlowPath flowPath = FlowPath.builder().srcSwitch(switchEntity).destSwitch(switchEntity).pathId(new PathId("test_path_id")).build();
    assertTrue(builder.isSamePath(path, flowPath));
}
Also used : FlowPath(org.openkilda.model.FlowPath) Path(org.openkilda.pce.Path) PathId(org.openkilda.model.PathId) Switch(org.openkilda.model.Switch) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) Test(org.junit.Test)

Aggregations

PathId (org.openkilda.model.PathId)124 Flow (org.openkilda.model.Flow)65 FlowPath (org.openkilda.model.FlowPath)65 Test (org.junit.Test)44 Switch (org.openkilda.model.Switch)29 SwitchId (org.openkilda.model.SwitchId)28 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)27 PathSegment (org.openkilda.model.PathSegment)26 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)21 MeterId (org.openkilda.model.MeterId)19 ArrayList (java.util.ArrayList)18 List (java.util.List)13 Slf4j (lombok.extern.slf4j.Slf4j)11 GetPathsResult (org.openkilda.pce.GetPathsResult)11 FlowMirrorPoints (org.openkilda.model.FlowMirrorPoints)10 Path (org.openkilda.pce.Path)10 Collection (java.util.Collection)9 RecoverableException (org.openkilda.pce.exception.RecoverableException)9 String.format (java.lang.String.format)8 HashMap (java.util.HashMap)8