Search in sources :

Example 16 with FlowSourceAdapter

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

the class InputArpRuleGeneratorTest method buildArpRuleWithOverlappedEndpointsTest.

@Test
public void buildArpRuleWithOverlappedEndpointsTest() {
    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().srcArp(true).srcSwitchArp(true).build()).build());
    InputArpRuleGenerator generator = InputArpRuleGenerator.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 17 with FlowSourceAdapter

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

the class MultiTableIngressRuleGeneratorTest method buildMatchVlanEncapsulationSingleVlanTest.

@Test
public void buildMatchVlanEncapsulationSingleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, 0);
    MultiTableIngressRuleGenerator 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.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 18 with FlowSourceAdapter

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

the class RequestedFlowMapper method toFlowRequest.

/**
 * Convert {@link Flow} to {@link FlowRequest}.
 */
public FlowRequest toFlowRequest(Flow flow) {
    FlowRequest request = generatedMap(flow);
    request.setSource(new FlowSourceAdapter(flow).getEndpoint());
    request.setDestination(new FlowDestAdapter(flow).getEndpoint());
    return request;
}
Also used : FlowSourceAdapter(org.openkilda.adapter.FlowSourceAdapter) FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) FlowDestAdapter(org.openkilda.adapter.FlowDestAdapter)

Example 19 with FlowSourceAdapter

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

the class PingProducer method buildPing.

private Ping buildPing(PingContext pingContext, FlowDirection direction) {
    Flow flow = pingContext.getFlow();
    FlowEndpoint ingress;
    FlowEndpoint egress;
    int islPort;
    if (FlowDirection.FORWARD == direction) {
        ingress = new FlowSourceAdapter(flow).getEndpoint();
        egress = new FlowDestAdapter(flow).getEndpoint();
        islPort = getIslPort(flow, flow.getForwardPath());
    } else if (FlowDirection.REVERSE == direction) {
        ingress = new FlowDestAdapter(flow).getEndpoint();
        egress = new FlowSourceAdapter(flow).getEndpoint();
        islPort = getIslPort(flow, flow.getReversePath());
    } else {
        throw new IllegalArgumentException(String.format("Unexpected %s value: %s", FlowDirection.class.getCanonicalName(), direction));
    }
    return new Ping(new NetworkEndpoint(ingress.getSwitchId(), ingress.getPortNumber()), new NetworkEndpoint(egress.getSwitchId(), egress.getPortNumber()), pingContext.getTransitEncapsulation(), islPort);
}
Also used : FlowSourceAdapter(org.openkilda.adapter.FlowSourceAdapter) FlowEndpoint(org.openkilda.model.FlowEndpoint) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) FlowDirection(org.openkilda.messaging.model.FlowDirection) FlowDestAdapter(org.openkilda.adapter.FlowDestAdapter) Ping(org.openkilda.messaging.model.Ping) FlowEndpoint(org.openkilda.model.FlowEndpoint) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) Flow(org.openkilda.model.Flow)

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