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);
}
}
}
}
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);
}
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());
}
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);
}
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);
}
Aggregations