Search in sources :

Example 1 with MessageContext

use of org.openkilda.messaging.MessageContext 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 2 with MessageContext

use of org.openkilda.messaging.MessageContext 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 3 with MessageContext

use of org.openkilda.messaging.MessageContext 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 4 with MessageContext

use of org.openkilda.messaging.MessageContext 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)

Example 5 with MessageContext

use of org.openkilda.messaging.MessageContext in project open-kilda by telstra.

the class OneSwitchFlowCommandJsonTest method makeRequest.

@Override
protected OneSwitchFlowRequest makeRequest() {
    SwitchId swId = new SwitchId(1);
    OneSwitchFlowRequestFactory factory = new OneSwitchFlowRequestFactory(new MessageContext(), new FlowSegmentMetadata("single-switch-flow-install-request", new Cookie(2), false), new FlowEndpoint(swId, 3, 4), new MeterConfig(new MeterId(6), 7000), new FlowEndpoint(swId, 8, 9), RulesContext.builder().build(), MirrorConfig.builder().build());
    return makeRequest(factory);
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FlowEndpoint(org.openkilda.model.FlowEndpoint) OneSwitchFlowRequestFactory(org.openkilda.floodlight.api.request.factory.OneSwitchFlowRequestFactory) SwitchId(org.openkilda.model.SwitchId) MessageContext(org.openkilda.messaging.MessageContext) MeterConfig(org.openkilda.model.MeterConfig) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) MeterId(org.openkilda.model.MeterId)

Aggregations

MessageContext (org.openkilda.messaging.MessageContext)28 UUID (java.util.UUID)13 FlowSegmentMetadata (org.openkilda.floodlight.model.FlowSegmentMetadata)9 SwitchId (org.openkilda.model.SwitchId)9 ArrayList (java.util.ArrayList)7 Cookie (org.openkilda.model.cookie.Cookie)6 EgressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory)5 InfoMessage (org.openkilda.messaging.info.InfoMessage)5 FlowEndpoint (org.openkilda.model.FlowEndpoint)5 MirrorConfig (org.openkilda.model.MirrorConfig)5 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)5 Session (org.openkilda.floodlight.service.session.Session)4 MeterConfig (org.openkilda.model.MeterConfig)4 MeterId (org.openkilda.model.MeterId)4 List (java.util.List)3 Optional (java.util.Optional)3 CompletableFuture (java.util.concurrent.CompletableFuture)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