Search in sources :

Example 51 with MeterId

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

Example 52 with MeterId

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

the class ValidationServiceImplTest method validateMetersMisconfiguredMeters.

@Test
public void validateMetersMisconfiguredMeters() {
    ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
    MeterSpeakerData actualMeter = MeterSpeakerData.builder().meterId(new MeterId(32)).rate(10002).burst(10498).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.PKTPS, MeterFlag.BURST, MeterFlag.STATS)).build();
    String[] actualFlags = new String[] { "PKTPS", "BURST", "STATS" };
    MeterSpeakerData expectedMeter = MeterSpeakerData.builder().meterId(new MeterId(32)).rate(10000).burst(10500).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.KBPS, MeterFlag.BURST, MeterFlag.STATS)).build();
    ValidateMetersResult response = validationService.validateMeters(SWITCH_ID_B, singletonList(actualMeter), singletonList(expectedMeter));
    assertTrue(response.getMissingMeters().isEmpty());
    assertFalse(response.getMisconfiguredMeters().isEmpty());
    assertEquals(10002, (long) response.getMisconfiguredMeters().get(0).getActual().getRate());
    assertEquals(10000, (long) response.getMisconfiguredMeters().get(0).getExpected().getRate());
    assertEquals(10498L, (long) response.getMisconfiguredMeters().get(0).getActual().getBurstSize());
    assertEquals(10500L, (long) response.getMisconfiguredMeters().get(0).getExpected().getBurstSize());
    assertTrue(Sets.newHashSet(actualFlags).containsAll(Sets.newHashSet(response.getMisconfiguredMeters().get(0).getActual().getFlags())));
    assertTrue(Sets.newHashSet("KBPS", "BURST", "STATS").containsAll(Sets.newHashSet(response.getMisconfiguredMeters().get(0).getExpected().getFlags())));
    assertTrue(response.getProperMeters().isEmpty());
    assertTrue(response.getExcessMeters().isEmpty());
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) ValidationService(org.openkilda.wfm.topology.switchmanager.service.ValidationService) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Example 53 with MeterId

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

the class ValidationServiceImplTest method validateMetersMisconfiguredMetersESwitch.

@Test
public void validateMetersMisconfiguredMetersESwitch() {
    ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
    long rateESwitch = FLOW_E_BANDWIDTH + (long) (FLOW_E_BANDWIDTH * 0.01) + 1;
    long burstSize = (long) (FLOW_E_BANDWIDTH * 1.05);
    long burstSizeESwitch = burstSize + (long) (burstSize * 0.01) + 1;
    MeterSpeakerData actualMeter = MeterSpeakerData.builder().meterId(new MeterId(32)).rate(rateESwitch).burst(burstSizeESwitch).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.PKTPS, MeterFlag.BURST, MeterFlag.STATS)).build();
    MeterSpeakerData expectedMeter = MeterSpeakerData.builder().meterId(new MeterId(32)).rate(rateESwitch).burst(burstSize).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.PKTPS, MeterFlag.BURST, MeterFlag.STATS)).build();
    ValidateMetersResult response = validationService.validateMeters(SWITCH_ID_E, singletonList(actualMeter), singletonList(expectedMeter));
    assertTrue(response.getMissingMeters().isEmpty());
    assertFalse(response.getMisconfiguredMeters().isEmpty());
    assertEquals(10606L, (long) response.getMisconfiguredMeters().get(0).getActual().getBurstSize());
    assertEquals(10500L, (long) response.getMisconfiguredMeters().get(0).getExpected().getBurstSize());
    assertTrue(response.getProperMeters().isEmpty());
    assertTrue(response.getExcessMeters().isEmpty());
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) ValidationService(org.openkilda.wfm.topology.switchmanager.service.ValidationService) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Example 54 with MeterId

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

the class FermaFlowPathRepositoryTest method createTestFlowPathWithIntermediate.

private FlowPath createTestFlowPathWithIntermediate(Switch intSwitch, int intPort) {
    FlowPath flowPath = FlowPath.builder().pathId(new PathId(flow.getFlowId() + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(switchA).destSwitch(switchB).status(FlowPathStatus.ACTIVE).build();
    PathSegment segment1 = PathSegment.builder().pathId(flowPath.getPathId()).srcSwitch(switchA).srcPort(1).destSwitch(intSwitch).destPort(intPort).build();
    PathSegment segment2 = PathSegment.builder().pathId(flowPath.getPathId()).srcSwitch(intSwitch).srcPort(intPort + 100).destSwitch(switchB).destPort(2).build();
    flowPath.setSegments(asList(segment1, segment2));
    flowPathRepository.add(flowPath);
    return flowPath;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) MeterId(org.openkilda.model.MeterId)

Example 55 with MeterId

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

the class FermaFlowRepositoryTest method createTestFlow.

private Flow createTestFlow(String flowId, Switch srcSwitch, int srcPort, int srcVlan, Switch destSwitch, int destPort, int destVlan, boolean multiTable) {
    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).srcWithMultiTable(multiTable).destWithMultiTable(multiTable).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).srcWithMultiTable(multiTable).destWithMultiTable(multiTable).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) MeterId(org.openkilda.model.MeterId)

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