Search in sources :

Example 56 with MeterId

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

the class FermaFlowRepositoryTest method createTestFlowWithIntermediate.

private Flow createTestFlowWithIntermediate(String flowId, Switch srcSwitch, Switch intSwitch, int intPort, Switch destSwitch) {
    Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcPort(PORT_1).destSwitch(destSwitch).destPort(PORT_2).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    flowRepository.add(flow);
    FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(srcSwitch).destSwitch(destSwitch).status(FlowPathStatus.ACTIVE).build();
    flowPathRepository.add(forwardFlowPath);
    flow.setForwardPath(forwardFlowPath);
    PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(1).destSwitch(intSwitch).destPort(intPort).build();
    forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
    FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(destSwitch).destSwitch(srcSwitch).status(FlowPathStatus.ACTIVE).build();
    flowPathRepository.add(reverseFlowPath);
    flow.setReversePath(reverseFlowPath);
    PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(intSwitch).srcPort(100).destSwitch(srcSwitch).destPort(1).build();
    reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
    return flow;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId)

Example 57 with MeterId

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

the class FermaYFlowRepositoryTest method createTestFlow.

private Flow createTestFlow(String flowId, Switch srcSwitch, int srcPort, int srcVlan, Switch destSwitch, int destPort, int destVlan) {
    Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcPort(srcPort).srcVlan(srcVlan).destSwitch(destSwitch).destPort(destPort).destVlan(destVlan).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    flowRepository.add(flow);
    FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(srcSwitch).destSwitch(destSwitch).status(FlowPathStatus.ACTIVE).build();
    PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(destSwitch).destPort(destPort).build();
    forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
    flowPathRepository.add(forwardFlowPath);
    flow.setForwardPath(forwardFlowPath);
    FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(destSwitch).destSwitch(srcSwitch).status(FlowPathStatus.ACTIVE).build();
    PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(destSwitch).srcPort(destPort).destSwitch(srcSwitch).destPort(srcPort).build();
    reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
    flowPathRepository.add(reverseFlowPath);
    flow.setReversePath(reverseFlowPath);
    return flow;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) YSubFlow(org.openkilda.model.YSubFlow) MeterId(org.openkilda.model.MeterId)

Example 58 with MeterId

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

the class FermaSwitchRepositoryTest method createOneSwitchFlow.

private void createOneSwitchFlow() {
    Switch switchA = createTestSwitch(TEST_SWITCH_ID_A.getId());
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID_A).srcSwitch(switchA).srcPort(1).destSwitch(switchA).destPort(2).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_A + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(switchA).destSwitch(switchA).status(FlowPathStatus.ACTIVE).build();
    flow.setForwardPath(forwardFlowPath);
    FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_A + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(switchA).destSwitch(switchA).status(FlowPathStatus.ACTIVE).build();
    flow.setReversePath(reverseFlowPath);
    flowRepository.add(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 59 with MeterId

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

the class FermaSwitchRepositoryTest method createTwoFlows.

private void createTwoFlows() {
    Switch switchA = createTestSwitch(TEST_SWITCH_ID_A.getId());
    Switch switchB = createTestSwitch(TEST_SWITCH_ID_B.getId());
    // create flow TEST_FLOW_ID_A
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID_A).srcSwitch(switchA).srcPort(1).destSwitch(switchB).destPort(4).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_A + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(switchA).destSwitch(switchB).status(FlowPathStatus.ACTIVE).build();
    flow.setForwardPath(forwardFlowPath);
    PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchA).srcPort(2).destSwitch(switchB).destPort(3).build();
    forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
    FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_A + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(switchB).destSwitch(switchA).status(FlowPathStatus.ACTIVE).build();
    flow.setReversePath(reverseFlowPath);
    PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(switchB).srcPort(3).destSwitch(switchA).destPort(2).build();
    reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
    flowRepository.add(flow);
    Switch switchC = createTestSwitch(TEST_SWITCH_ID_C.getId());
    // create flow TEST_FLOW_ID_B
    flow = Flow.builder().flowId(TEST_FLOW_ID_B).srcSwitch(switchA).srcPort(1).destSwitch(switchC).destPort(7).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    forwardFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_B + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(3)).srcSwitch(switchA).destSwitch(switchC).status(FlowPathStatus.ACTIVE).build();
    flow.setForwardPath(forwardFlowPath);
    PathSegment forwardSegmentA = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchA).srcPort(2).destSwitch(switchB).destPort(3).build();
    PathSegment forwardSegmentB = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchB).srcPort(5).destSwitch(switchC).destPort(6).build();
    forwardFlowPath.setSegments(Lists.newArrayList(forwardSegmentA, forwardSegmentB));
    reverseFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_B + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(4)).srcSwitch(switchC).destSwitch(switchA).status(FlowPathStatus.ACTIVE).build();
    flow.setReversePath(reverseFlowPath);
    PathSegment reverseSegmentA = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(switchC).srcPort(6).destSwitch(switchB).destPort(5).build();
    PathSegment reverseSegmentB = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(switchB).srcPort(3).destSwitch(switchA).destPort(2).build();
    reverseFlowPath.setSegments(Lists.newArrayList(reverseSegmentA, reverseSegmentB));
    flowRepository.add(flow);
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId)

Example 60 with MeterId

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

the class MeterIdConverterTest method shouldConvertStringToId.

@Test
public void shouldConvertStringToId() {
    // given
    MeterId meterId = new MeterId(0x123);
    // when
    MeterId actualEntity = MeterIdConverter.INSTANCE.toEntityAttribute(meterId.getValue());
    // then
    assertEquals(meterId, actualEntity);
}
Also used : MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Aggregations

MeterId (org.openkilda.model.MeterId)62 PathId (org.openkilda.model.PathId)20 Flow (org.openkilda.model.Flow)19 FlowPath (org.openkilda.model.FlowPath)18 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)18 Test (org.junit.Test)17 SwitchId (org.openkilda.model.SwitchId)16 Switch (org.openkilda.model.Switch)11 ArrayList (java.util.ArrayList)10 PathSegment (org.openkilda.model.PathSegment)9 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)7 List (java.util.List)6 ValidateMetersResult (org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult)6 FlowMeter (org.openkilda.model.FlowMeter)5 MeterConfig (org.openkilda.model.MeterConfig)5 YFlow (org.openkilda.model.YFlow)5 Instructions (org.openkilda.rulemanager.Instructions)5 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)5 ValidationService (org.openkilda.wfm.topology.switchmanager.service.ValidationService)5 MessageContext (org.openkilda.messaging.MessageContext)4