Update 13/8/2019: lighty TransportPCE Controller is now available in the OpenDaylight upstream.

Overview

Migrating an OpenDaylight application to lighty.io follows a clear pattern. The major part of the work is removing hard dependencies on OSGi / Karaf. This is actually good for the original project too — those dependencies shouldn't exist in the first place, and removing them produces cleaner upstream code.

Since TransportPCE has no OSGi dependencies, we can focus on the remaining steps: identifying module dependencies and wiring them via lighty.io's module system.

Step 1: Initialize the Controller

// Initialize and start OpenDaylight controller (MD-SAL, Controller, YangTools)
final LightyControllerBuilder lightyControllerBuilder = new LightyControllerBuilder();
final LightyController lightyController = lightyControllerBuilder
    .from(controllerConfiguration)
    .build();
lightyController.start().get();

Step 2: Find Blueprint Dependencies

Go to the original OpenDaylight project and find all the blueprint files. These specify the dependency references your lighty.io module constructor needs. Look for autowire.xml in:

target/generated-sources/blueprint/OSGI-INF.blueprint/autowire.xml
src/main/resources/OSGI-INF.blueprint/

For TransportPCE, the blueprint specifies beans for TransportpceProvider, RendererProvider, OlmProvider, and others — with their init and destroy methods.

Step 3: Extend AbstractLightyModule

Create a class extending AbstractLightyModule and override initProcedure() and stopProcedure():

@Override
protected boolean initProcedure() {
    final long startTime = System.nanoTime();
    transportpceProvider =
            new TransportpceProvider(dataBroker, mountPointService);
    transportpceProvider.init();

    rendererProvider = new RendererProvider(dataBroker, mountPointService,
            rpcProviderRegistry);
    rendererProvider.init();

    olmProvider = new OlmProvider(dataBroker, mountPointService, rpcProviderRegistry);
    olmProvider.init();

    servicehandlerProvider = new ServicehandlerProvider(dataBroker, rpcProviderRegistry,
            notificationService, notificationPublishService);
    servicehandlerProvider.init();

    final float delay = (System.nanoTime() - startTime) / 1_000_000f;
    LOG.info("Lighty transportpce started in {}ms", delay);
    return true;
}

Step 4: Implement stopProcedure

@Override
protected boolean stopProcedure() {
    if (transportpceProvider != null) {
        transportpceProvider.close();
    }
    if (olmProvider != null) {
        olmProvider.close();
    }
    if (rendererProvider != null) {
        rendererProvider.close();
    }
    if (servicehandlerProvider != null) {
        servicehandlerProvider.close();
    }
    return true;
}

Step 5: Build and Start

final TransportPceBuilder lightyTransportPceBuilder = new TransportPceBuilder();
final LightyTransportPce lightyTransportPce = lightyTransportPceBuilder
    .from(lightyController.getServices())
    .build();
lightyTransportPce.start().get();
Important: Your controller must have access to all YANG model artifacts your project uses. If the schema context is missing a model, some bean objects will fail silently. Always verify your YANG model classpath.

Key Takeaway

These steps are simple and straightforward. If all OpenDaylight projects were as clean as TransportPCE, a simple script could automate the migration. The pattern generalizes to any ODL project — see the ODL module integration guide for a more complex example using the OpenFlow plugin.