Search in sources :

Example 11 with FlowSourceAdapter

use of org.openkilda.adapter.FlowSourceAdapter in project open-kilda by telstra.

the class FlowValidator method checkForConnectedDevisesConflict.

private void checkForConnectedDevisesConflict(String flowId, SwitchId switchId) throws InvalidFlowException {
    SwitchProperties properties = switchPropertiesRepository.findBySwitchId(switchId).orElseThrow(() -> new InvalidFlowException(format("Couldn't get switch properties for switch %s.", switchId), ErrorType.DATA_INVALID));
    if (properties.isSwitchLldp() || properties.isSwitchArp()) {
        String errorMessage = format("Connected devices feature is active on the switch %s, " + "flow mirror point cannot be created on this switch.", switchId);
        throw new InvalidFlowException(errorMessage, ErrorType.PARAMETERS_INVALID);
    }
    Optional<Flow> foundFlow = flowRepository.findById(flowId);
    if (foundFlow.isPresent()) {
        Flow flow = foundFlow.get();
        FlowEndpoint source = new FlowSourceAdapter(flow).getEndpoint();
        FlowEndpoint destination = new FlowDestAdapter(flow).getEndpoint();
        if (switchId.equals(source.getSwitchId())) {
            if (source.isTrackLldpConnectedDevices() || source.isTrackArpConnectedDevices()) {
                String errorMessage = format("Connected devices feature is active on the flow %s for endpoint %s, " + "flow mirror point cannot be created this flow", flow.getFlowId(), source);
                throw new InvalidFlowException(errorMessage, ErrorType.PARAMETERS_INVALID);
            }
        } else {
            if (destination.isTrackLldpConnectedDevices() || destination.isTrackArpConnectedDevices()) {
                String errorMessage = format("Connected devices feature is active on the flow %s for endpoint %s, " + "flow mirror point cannot be created this flow", flow.getFlowId(), destination);
                throw new InvalidFlowException(errorMessage, ErrorType.PARAMETERS_INVALID);
            }
        }
    }
}
Also used : FlowSourceAdapter(org.openkilda.adapter.FlowSourceAdapter) FlowEndpoint(org.openkilda.model.FlowEndpoint) FlowDestAdapter(org.openkilda.adapter.FlowDestAdapter) SwitchProperties(org.openkilda.model.SwitchProperties) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) YSubFlow(org.openkilda.model.YSubFlow) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow)

Example 12 with FlowSourceAdapter

use of org.openkilda.adapter.FlowSourceAdapter in project open-kilda by telstra.

the class SingleTableIngressYRuleGeneratorTest method buildMatchVlanEncapsulationSingleVlanTest.

@Test
public void buildMatchVlanEncapsulationSingleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, 0);
    SingleTableIngressYRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    Set<FieldMatch> match = generator.buildMatch(new FlowSourceAdapter(flow).getEndpoint(), FEATURES);
    Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_1).build());
    assertEqualsMatch(expectedMatch, match);
}
Also used : FlowSourceAdapter(org.openkilda.adapter.FlowSourceAdapter) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 13 with FlowSourceAdapter

use of org.openkilda.adapter.FlowSourceAdapter in project open-kilda by telstra.

the class InputLldpRuleGeneratorTest method buildLldpRuleWithOverlappedEndpointsTest.

@Test
public void buildLldpRuleWithOverlappedEndpointsTest() {
    FlowEndpoint endpoint = new FlowEndpoint(SW.getSwitchId(), PORT_NUMBER_1, 0, 0, true, false);
    FlowSideAdapter adapter = new FlowSourceAdapter(Flow.builder().flowId("some").srcSwitch(SW).destSwitch(buildSwitch("OF_13", Collections.emptySet())).detectConnectedDevices(DetectConnectedDevices.builder().srcLldp(true).srcSwitchLldp(true).build()).build());
    InputLldpRuleGenerator generator = InputLldpRuleGenerator.builder().ingressEndpoint(endpoint).multiTable(true).overlappingIngressAdapters(Sets.newHashSet(adapter)).build();
    assertEquals(0, generator.generateCommands(SW).size());
}
Also used : FlowSourceAdapter(org.openkilda.adapter.FlowSourceAdapter) FlowEndpoint(org.openkilda.model.FlowEndpoint) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) Test(org.junit.Test)

Example 14 with FlowSourceAdapter

use of org.openkilda.adapter.FlowSourceAdapter in project open-kilda by telstra.

the class MultiTableIngressYRuleGeneratorTest method buildMatchVlanEncapsulationDoubleVlanTest.

@Test
public void buildMatchVlanEncapsulationDoubleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    MultiTableIngressYRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    Set<FieldMatch> match = generator.buildIngressMatch(new FlowSourceAdapter(flow).getEndpoint(), FEATURES);
    RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
    Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID_1).build(), FieldMatch.builder().field(Field.METADATA).value(metadata.getValue()).mask(metadata.getMask()).build());
    assertEqualsMatch(expectedMatch, match);
}
Also used : FlowSourceAdapter(org.openkilda.adapter.FlowSourceAdapter) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 15 with FlowSourceAdapter

use of org.openkilda.adapter.FlowSourceAdapter in project open-kilda by telstra.

the class SingleTableIngressRuleGeneratorTest method buildMatchVlanEncapsulationFullPortTest.

@Test
public void buildMatchVlanEncapsulationFullPortTest() {
    Flow flow = buildFlow(PATH, 0, 0);
    SingleTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    Set<FieldMatch> match = generator.buildMatch(new FlowSourceAdapter(flow).getEndpoint(), FEATURES);
    Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build());
    assertEqualsMatch(expectedMatch, match);
}
Also used : FlowSourceAdapter(org.openkilda.adapter.FlowSourceAdapter) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Aggregations

FlowSourceAdapter (org.openkilda.adapter.FlowSourceAdapter)19 Test (org.junit.Test)14 Flow (org.openkilda.model.Flow)13 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)12 FlowEndpoint (org.openkilda.model.FlowEndpoint)7 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)6 FlowDestAdapter (org.openkilda.adapter.FlowDestAdapter)5 FlowSideAdapter (org.openkilda.adapter.FlowSideAdapter)4 FlowRequest (org.openkilda.messaging.command.flow.FlowRequest)2 YFlow (org.openkilda.model.YFlow)2 YSubFlow (org.openkilda.model.YSubFlow)2 PortColourCookie (org.openkilda.model.cookie.PortColourCookie)2 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)2 Instructions (org.openkilda.rulemanager.Instructions)2 OfMetadata (org.openkilda.rulemanager.OfMetadata)2 SpeakerData (org.openkilda.rulemanager.SpeakerData)2 RequestedFlow (org.openkilda.wfm.topology.flowhs.model.RequestedFlow)2 FlowDirection (org.openkilda.messaging.model.FlowDirection)1 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)1 Ping (org.openkilda.messaging.model.Ping)1