Search in sources :

Example 1 with InputService

use of org.openkilda.floodlight.service.of.InputService in project open-kilda by telstra.

the class PathVerificationService method startUp.

@Override
public void startUp(FloodlightModuleContext context) throws FloodlightModuleException {
    logger.info("Stating {}", PathVerificationService.class.getCanonicalName());
    KafkaChannel kafkaChannel = context.getServiceImpl(KafkaUtilityService.class).getKafkaChannel();
    logger.info("region: {}", kafkaChannel.getRegion());
    topoDiscoTopic = context.getServiceImpl(KafkaUtilityService.class).getKafkaChannel().getTopoDiscoTopic();
    islLatencyTopic = context.getServiceImpl(KafkaUtilityService.class).getKafkaChannel().getIslLatencyTopic();
    region = context.getServiceImpl(KafkaUtilityService.class).getKafkaChannel().getRegion();
    InputService inputService = context.getServiceImpl(InputService.class);
    inputService.addTranslator(OFType.PACKET_IN, this);
    context.getServiceImpl(PingService.class).setup(context);
    context.getServiceImpl(IRestApiService.class).addRestletRoutable(new PathVerificationServiceWebRoutable());
}
Also used : IRestApiService(net.floodlightcontroller.restserver.IRestApiService) InputService(org.openkilda.floodlight.service.of.InputService) PingService(org.openkilda.floodlight.service.ping.PingService) KafkaChannel(org.openkilda.floodlight.KafkaChannel) KafkaUtilityService(org.openkilda.floodlight.service.kafka.KafkaUtilityService) PathVerificationServiceWebRoutable(org.openkilda.floodlight.pathverification.web.PathVerificationServiceWebRoutable)

Example 2 with InputService

use of org.openkilda.floodlight.service.of.InputService in project open-kilda by telstra.

the class PingService method setup.

/**
 * Initialize internal data structures. Called by module that own this service. Called after all dependencies have
 * been loaded.
 */
@Override
public void setup(FloodlightModuleContext moduleContext) throws FloodlightModuleException {
    // FIXME(surabujin): avoid usage foreign module configuration
    Map<String, String> config = moduleContext.getConfigParams(PathVerificationService.class);
    try {
        signature = new DataSignature(config.get("hmac256-secret"));
    } catch (InvalidSignatureConfigurationException e) {
        throw new FloodlightModuleException(String.format("Unable to initialize %s", getClass().getName()), e);
    }
    InputService inputService = moduleContext.getServiceImpl(InputService.class);
    inputService.addTranslator(OFType.PACKET_IN, new PingInputTranslator());
    KildaCoreConfig coreConfig = moduleContext.getServiceImpl(KildaCore.class).getConfig();
    magicSourceMacAddress = MacAddress.of(coreConfig.getFlowPingMagicSrcMacAddress());
}
Also used : InputService(org.openkilda.floodlight.service.of.InputService) FloodlightModuleException(net.floodlightcontroller.core.module.FloodlightModuleException) InvalidSignatureConfigurationException(org.openkilda.floodlight.error.InvalidSignatureConfigurationException) KildaCoreConfig(org.openkilda.floodlight.KildaCoreConfig) KildaCore(org.openkilda.floodlight.KildaCore) DataSignature(org.openkilda.floodlight.utils.DataSignature)

Example 3 with InputService

use of org.openkilda.floodlight.service.of.InputService in project open-kilda by telstra.

the class PingRequestCommandWriteOkTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    InputService inputService = createMock(InputService.class);
    inputService.addTranslator(eq(OFType.PACKET_IN), anyObject(PingInputTranslator.class));
    moduleContext.addService(InputService.class, inputService);
    expect(pingService.getSignature()).andDelegateTo(realPingService);
    expect(pingService.wrapData(anyObject(Ping.class), anyObject())).andDelegateTo(realPingService);
    expect(switchAlpha.getLatency()).andReturn(U64.of(1L)).anyTimes();
    expect(switchBeta.getLatency()).andReturn(U64.of(2L)).anyTimes();
    expect(switchNotCapable.getLatency()).andReturn(U64.of(3L)).anyTimes();
}
Also used : PingInputTranslator(org.openkilda.floodlight.service.ping.PingInputTranslator) InputService(org.openkilda.floodlight.service.of.InputService) Ping(org.openkilda.messaging.model.Ping) Before(org.junit.Before)

Example 4 with InputService

use of org.openkilda.floodlight.service.of.InputService in project open-kilda by telstra.

the class PingResponseCommandTest method success.

@Test
public void success() throws Exception {
    final PingService realPingService = new PingService();
    moduleContext.addService(PingService.class, realPingService);
    final ISwitchManager realSwitchManager = new SwitchManager();
    moduleContext.addService(ISwitchManager.class, realSwitchManager);
    InputService inputService = createMock(InputService.class);
    moduleContext.addService(InputService.class, inputService);
    inputService.addTranslator(eq(OFType.PACKET_IN), anyObject());
    replayAll();
    final DatapathId dpIdBeta = DatapathId.of(0x0000fffe000002L);
    final Ping ping = new Ping(new NetworkEndpoint(new SwitchId(dpIdBeta.getLong()), 8), new NetworkEndpoint(new SwitchId(dpId.getLong()), 9), new FlowTransitEncapsulation(2, FlowEncapsulationType.TRANSIT_VLAN), 3);
    final PingData payload = PingData.of(ping);
    moduleContext.addConfigParam(new PathVerificationService(), "hmac256-secret", "secret");
    realPingService.setup(moduleContext);
    byte[] signedPayload = realPingService.getSignature().sign(payload);
    byte[] wireData = realPingService.wrapData(ping, signedPayload).serialize();
    OFFactory ofFactory = new OFFactoryVer13();
    OFPacketIn message = ofFactory.buildPacketIn().setReason(OFPacketInReason.ACTION).setXid(1L).setCookie(PingService.OF_CATCH_RULE_COOKIE).setData(wireData).build();
    FloodlightContext metadata = new FloodlightContext();
    IPacket decodedEthernet = new Ethernet().deserialize(wireData, 0, wireData.length);
    Assert.assertTrue(decodedEthernet instanceof Ethernet);
    IFloodlightProviderService.bcStore.put(metadata, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, (Ethernet) decodedEthernet);
    OfInput input = new OfInput(iofSwitch, message, metadata);
    final PingResponseCommand command = makeCommand(input);
    command.call();
    final List<Message> replies = kafkaMessageCatcher.getValues();
    Assert.assertEquals(1, replies.size());
    InfoMessage response = (InfoMessage) replies.get(0);
    PingResponse pingResponse = (PingResponse) response.getData();
    Assert.assertNull(pingResponse.getError());
    Assert.assertNotNull(pingResponse.getMeters());
    Assert.assertEquals(payload.getPingId(), pingResponse.getPingId());
}
Also used : OfInput(org.openkilda.floodlight.model.OfInput) IPacket(net.floodlightcontroller.packet.IPacket) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) DatapathId(org.projectfloodlight.openflow.types.DatapathId) SwitchId(org.openkilda.model.SwitchId) PingResponse(org.openkilda.messaging.floodlight.response.PingResponse) SwitchManager(org.openkilda.floodlight.switchmanager.SwitchManager) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) PingData(org.openkilda.floodlight.model.PingData) InputService(org.openkilda.floodlight.service.of.InputService) PathVerificationService(org.openkilda.floodlight.pathverification.PathVerificationService) InfoMessage(org.openkilda.messaging.info.InfoMessage) PingService(org.openkilda.floodlight.service.ping.PingService) Ping(org.openkilda.messaging.model.Ping) Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Test(org.junit.Test)

Example 5 with InputService

use of org.openkilda.floodlight.service.of.InputService in project open-kilda by telstra.

the class SessionService method setup.

@Override
public void setup(FloodlightModuleContext moduleContext) {
    InputService inputService = moduleContext.getServiceImpl(InputService.class);
    inputService.addTranslator(OFType.ERROR, this);
    inputService.addTranslator(OFType.BARRIER_REPLY, this);
    new SwitchEventsTranslator(this, moduleContext.getServiceImpl(IOFSwitchService.class));
}
Also used : InputService(org.openkilda.floodlight.service.of.InputService) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService)

Aggregations

InputService (org.openkilda.floodlight.service.of.InputService)6 KafkaChannel (org.openkilda.floodlight.KafkaChannel)2 KafkaUtilityService (org.openkilda.floodlight.service.kafka.KafkaUtilityService)2 PingService (org.openkilda.floodlight.service.ping.PingService)2 Ping (org.openkilda.messaging.model.Ping)2 FloodlightContext (net.floodlightcontroller.core.FloodlightContext)1 IOFSwitchService (net.floodlightcontroller.core.internal.IOFSwitchService)1 FloodlightModuleException (net.floodlightcontroller.core.module.FloodlightModuleException)1 Ethernet (net.floodlightcontroller.packet.Ethernet)1 IPacket (net.floodlightcontroller.packet.IPacket)1 IRestApiService (net.floodlightcontroller.restserver.IRestApiService)1 Before (org.junit.Before)1 Test (org.junit.Test)1 KildaCore (org.openkilda.floodlight.KildaCore)1 KildaCoreConfig (org.openkilda.floodlight.KildaCoreConfig)1 InvalidSignatureConfigurationException (org.openkilda.floodlight.error.InvalidSignatureConfigurationException)1 OfInput (org.openkilda.floodlight.model.OfInput)1 PingData (org.openkilda.floodlight.model.PingData)1 PathVerificationService (org.openkilda.floodlight.pathverification.PathVerificationService)1 PathVerificationServiceWebRoutable (org.openkilda.floodlight.pathverification.web.PathVerificationServiceWebRoutable)1