Search in sources :

Example 1 with FlowSegmentMetadata

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

the class TransitFlowSegmentInstallCommandTest method happyPathMultiTable.

@Test
public void happyPathMultiTable() throws Exception {
    replayAll();
    TransitFlowSegmentInstallCommand command = makeCommand(encapsulationVxLan, new FlowSegmentMetadata("transit-segment-install-multitable", new Cookie(5), true));
    verifySuccessCompletion(command.execute(commandProcessor));
    verifyWriteCount(1);
    OFFlowAdd expected = of.buildFlowAdd().setTableId(TableId.of(SwitchManager.TRANSIT_TABLE_ID)).setPriority(TransitFlowSegmentInstallCommand.FLOW_PRIORITY).setCookie(U64.of(command.getCookie().getValue())).setMatch(OfAdapter.INSTANCE.matchVxLanVni(of, of.buildMatch(), command.getEncapsulation().getId()).setExact(MatchField.IN_PORT, OFPort.of(command.getIngressIslPort())).setExact(MatchField.ETH_TYPE, EthType.IPv4).setExact(MatchField.IP_PROTO, IpProtocol.UDP).setExact(MatchField.UDP_DST, TransportPort.of(4789)).build()).setInstructions(ImmutableList.of(of.instructions().applyActions(ImmutableList.of(of.actions().buildOutput().setPort(OFPort.of(command.getEgressIslPort())).build())))).build();
    verifyOfMessageEquals(expected, getWriteRecord(0).getRequest());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) OFFlowAdd(org.projectfloodlight.openflow.protocol.OFFlowAdd) Test(org.junit.Test)

Example 2 with FlowSegmentMetadata

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

the class TransitFlowSegmentRemoveCommandTest method makeCommand.

@Override
protected TransitFlowSegmentRemoveCommand makeCommand(FlowTransitEncapsulation encapsulation) {
    MessageContext messageContext = new MessageContext();
    UUID commandId = UUID.randomUUID();
    FlowSegmentMetadata metadata = new FlowSegmentMetadata("transit-flow-segment-remove-flow-id", new Cookie(6), false);
    int ingressIslPort = 3;
    int egressIslPort = 5;
    return new TransitFlowSegmentRemoveCommand(messageContext, mapSwitchId(dpIdNext), commandId, metadata, ingressIslPort, encapsulation, egressIslPort, null);
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) MessageContext(org.openkilda.messaging.MessageContext) UUID(java.util.UUID) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata)

Example 3 with FlowSegmentMetadata

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

the class IngressServer42FlowInstallCommandTest method createCommand.

private IngressServer42FlowInstallCommand createCommand(int outerVlan, int innerVlan, FlowTransitEncapsulation encapsulation, boolean multiTable) throws Exception {
    FlowSegmentMetadata metadata = new FlowSegmentMetadata(FLOW_ID, COOKIE, multiTable);
    IngressServer42FlowInstallCommand command = new IngressServer42FlowInstallCommand(new MessageContext(), UUID.randomUUID(), metadata, INGRESS_SWITCH_ID, CUSTOMER_PORT, outerVlan, innerVlan, EGRESS_SWITCH_ID, ISL_PORT, encapsulation, SERVER_42_PORT, SERVER_42_MAC_ADDRESS);
    FloodlightModuleContext context = new FloodlightModuleContext();
    IOFSwitchService switchServiceMock = mock(IOFSwitchService.class);
    expect(switchServiceMock.getActiveSwitch(anyObject())).andReturn(getOfSwitch()).anyTimes();
    context.addService(IOFSwitchService.class, switchServiceMock);
    FeatureDetectorService featureDetectorServiceMock = mock(FeatureDetectorService.class);
    expect(featureDetectorServiceMock.detectSwitch(anyObject())).andReturn(FEATURES).anyTimes();
    context.addService(FeatureDetectorService.class, featureDetectorServiceMock);
    Properties properties = new Properties();
    properties.setProperty(SERVER_42_UPD_PORT_OFFSET_PROPERTY, Integer.toString(SERVER_42_UPD_PORT_OFFSET));
    PropertiesBasedConfigurationProvider provider = new PropertiesBasedConfigurationProvider(properties);
    KildaCore kildaCoreMock = mock(KildaCore.class);
    expect(kildaCoreMock.getConfig()).andReturn(provider.getConfiguration(KildaCoreConfig.class)).anyTimes();
    context.addService(KildaCore.class, kildaCoreMock);
    replay(switchServiceMock, featureDetectorServiceMock, kildaCoreMock);
    command.setup(context);
    return command;
}
Also used : IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) PropertiesBasedConfigurationProvider(org.openkilda.config.provider.PropertiesBasedConfigurationProvider) MessageContext(org.openkilda.messaging.MessageContext) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) Properties(java.util.Properties) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) KildaCore(org.openkilda.floodlight.KildaCore)

Example 4 with FlowSegmentMetadata

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

the class EgressFlowSegmentCommandJsonTest method makeRequest.

@Override
protected EgressFlowSegmentRequest makeRequest() {
    SwitchId swId = new SwitchId(1);
    EgressFlowSegmentRequestFactory factory = new EgressFlowSegmentRequestFactory(new MessageContext(), new FlowSegmentMetadata("egress-flow-segment-install-request", new Cookie(2), false), new FlowEndpoint(swId, 3, 4), new FlowEndpoint(new SwitchId(swId.toLong() + 1), 6, 7), 9, new FlowTransitEncapsulation(10, FlowEncapsulationType.TRANSIT_VLAN), MirrorConfig.builder().build());
    return makeRequest(factory);
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) EgressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory) FlowEndpoint(org.openkilda.model.FlowEndpoint) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) MessageContext(org.openkilda.messaging.MessageContext) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata)

Example 5 with FlowSegmentMetadata

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

the class IngressFlowLoopSegmentInstallCommandTest method createCommand.

private IngressFlowLoopSegmentInstallCommand createCommand(int outerVlan, int innerVlan, boolean multiTable) throws Exception {
    FlowSegmentMetadata metadata = new FlowSegmentMetadata(FLOW_ID, COOKIE, multiTable);
    FlowEndpoint endpoint = FlowEndpoint.builder().switchId(SWITCH_ID_1).portNumber(PORT_1).outerVlanId(outerVlan).innerVlanId(innerVlan).build();
    IngressFlowLoopSegmentInstallCommand command = new IngressFlowLoopSegmentInstallCommand(new MessageContext(), UUID.randomUUID(), metadata, endpoint);
    FloodlightModuleContext context = new FloodlightModuleContext();
    IOFSwitchService switchServiceMock = mock(IOFSwitchService.class);
    expect(switchServiceMock.getActiveSwitch(anyObject())).andReturn(getOfSwitch()).anyTimes();
    context.addService(IOFSwitchService.class, switchServiceMock);
    FeatureDetectorService featureDetectorServiceMock = mock(FeatureDetectorService.class);
    expect(featureDetectorServiceMock.detectSwitch(anyObject())).andReturn(FEATURES).anyTimes();
    context.addService(FeatureDetectorService.class, featureDetectorServiceMock);
    PropertiesBasedConfigurationProvider provider = new PropertiesBasedConfigurationProvider(new Properties());
    KildaCore kildaCoreMock = mock(KildaCore.class);
    expect(kildaCoreMock.getConfig()).andReturn(provider.getConfiguration(KildaCoreConfig.class)).anyTimes();
    context.addService(KildaCore.class, kildaCoreMock);
    replay(switchServiceMock, featureDetectorServiceMock, kildaCoreMock);
    command.setup(context);
    return command;
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) PropertiesBasedConfigurationProvider(org.openkilda.config.provider.PropertiesBasedConfigurationProvider) MessageContext(org.openkilda.messaging.MessageContext) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) Properties(java.util.Properties) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) KildaCore(org.openkilda.floodlight.KildaCore)

Aggregations

FlowSegmentMetadata (org.openkilda.floodlight.model.FlowSegmentMetadata)11 MessageContext (org.openkilda.messaging.MessageContext)9 Cookie (org.openkilda.model.cookie.Cookie)6 UUID (java.util.UUID)5 EgressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory)4 FlowEndpoint (org.openkilda.model.FlowEndpoint)4 ArrayList (java.util.ArrayList)3 EgressMirrorFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressMirrorFlowSegmentRequestFactory)3 FlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory)3 IngressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory)3 IngressMirrorFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.IngressMirrorFlowSegmentRequestFactory)3 TransitFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.TransitFlowSegmentRequestFactory)3 MirrorConfig (org.openkilda.model.MirrorConfig)3 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)3 Properties (java.util.Properties)2 IOFSwitchService (net.floodlightcontroller.core.internal.IOFSwitchService)2 FloodlightModuleContext (net.floodlightcontroller.core.module.FloodlightModuleContext)2 Test (org.junit.Test)2 PropertiesBasedConfigurationProvider (org.openkilda.config.provider.PropertiesBasedConfigurationProvider)2 KildaCore (org.openkilda.floodlight.KildaCore)2