--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright © 2021 Orange and others. All rights reserved. This program
+ and the accompanying materials are made available under the terms of the
+ Eclipse Public License v1.0 which accompanies this distribution, and is available
+ at http://www.eclipse.org/legal/epl-v10.html INTERNAL -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>single-feature-parent</artifactId>
+ <version>8.1.0</version>
+ <relativePath />
+ </parent>
+
+ <groupId>org.opendaylight.transportpce</groupId>
+ <artifactId>odl-transportpce-nbinotifications</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <packaging>feature</packaging>
+
+ <name>OpenDaylight :: transportpce :: nbinotifications</name>
+ <properties>
+ <!-- skipped because we are using config file as artifact and it is not installed before running test -->
+ <skip.karaf.featureTest>true</skip.karaf.featureTest>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.transportpce</groupId>
+ <artifactId>odl-transportpce</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>transportpce-nbinotifications</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-dmaap-artifact</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${basedir}/src/main/resources/org.opendaylight.transportpce.nbinotifications.cfg</file>
+ <type>cfg</type>
+ <classifier>config</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Copyright © 2021 Orange and others. All rights reserved. This program
+ and the accompanying materials are made available under the terms of the
+ Eclipse Public License v1.0 which accompanies this distribution, and is available
+ at http://www.eclipse.org/legal/epl-v10.html INTERNAL -->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-transportpce-nbinotifications">
+ <feature name="odl-transportpce-nbinotifications">
+ <configfile finalname="etc/org.opendaylight.transportpce.nbinotififications.cfg" override="false">
+ mvn:${project.groupId}/${project.artifactId}/${project.version}/cfg/config
+ </configfile>
+ </feature>
+</features>
\ No newline at end of file
--- /dev/null
+suscriber.server=${env:KAFKA_SERVER:-localhost:9092}
+publisher.server=${env:KAFKA_SERVER:-localhost:9092}
<module>odl-transportpce</module>
<module>odl-transportpce-tapi</module>
<module>odl-transportpce-inventory</module>
+ <module>odl-transportpce-nbinotifications</module>
</modules>
</project>
<type>xml</type>
<scope>runtime</scope>
</dependency>
-
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>odl-transportpce-nbinotifications</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
<build>
</properties>
<dependencies>
+ <!-- for parsing command line arguments -->
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.4</version>
+ </dependency>
<!-- TPCE Models - BEGIN -->
<dependency>
<artifactId>transportpce-tapi</artifactId>
<version>${transportpce.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.transportpce</groupId>
+ <artifactId>transportpce-nbinotifications</artifactId>
+ <version>${transportpce.version}</version>
+ </dependency>
<!-- TPCE bundles - END -->
<dependency>
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.ExecutionException;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Main {
+ private static final String RESTCONF_OPTION_NAME = "restconf";
+
+ private static final String NBINOTIFICATION_OPTION_NAME = "nbinotification";
+
private static final Logger LOG = LoggerFactory.getLogger(Main.class);
private ShutdownHook shutdownHook;
public void start() {
- start(new String[] {}, false);
+ start(null, false, false);
}
@SuppressWarnings("checkstyle:Illegalcatch")
- public void start(String[] args, boolean registerShutdownHook) {
+ public void start(String restConfConfigurationFile, boolean activateNbiNotification, boolean registerShutdownHook) {
long startTime = System.nanoTime();
TpceBanner.print();
RestConfConfiguration restConfConfig = null;
ControllerConfiguration singleNodeConfiguration = ControllerConfigUtils
.getDefaultSingleNodeConfiguration(TPCEUtils.getYangModels());
// 2. get RESTCONF NBP configuration
- if (args.length == 1) {
- Path configPath = Paths.get(args[0]);
+ if (restConfConfigurationFile != null) {
+ Path configPath = Paths.get(restConfConfigurationFile);
LOG.info("Using restconf configuration from file {} ...", configPath);
restConfConfig = RestConfConfigUtils.getRestConfConfiguration(Files.newInputStream(configPath));
restConfConfig.setJsonRestconfServiceType(JsonRestConfServiceType.DRAFT_02);
// 3. NETCONF SBP configuration
NetconfConfiguration netconfSBPConfig = NetconfConfigUtils.createDefaultNetconfConfiguration();
- startLighty(singleNodeConfiguration, restConfConfig, netconfSBPConfig, registerShutdownHook);
+ startLighty(singleNodeConfiguration, restConfConfig, netconfSBPConfig, registerShutdownHook, activateNbiNotification);
float duration = (System.nanoTime() - startTime) / 1_000_000f;
LOG.info("lighty.io and RESTCONF-NETCONF started in {}ms", duration);
} catch (ConfigurationException | ExecutionException | IOException e) {
}
}
+ /**
+ * Build options for command line arguments
+ * @return
+ */
+ private static Options builOptions() {
+ Option rescontFileOption = Option.builder(RESTCONF_OPTION_NAME)
+ .desc("Restconf configuration file")
+ .argName(RESTCONF_OPTION_NAME)
+ .hasArg(true)
+ .required(false)
+ .build();
+ Option useNbiNotificationsOption = Option.builder(NBINOTIFICATION_OPTION_NAME)
+ .desc("Activate NBI notifications feature")
+ .argName(NBINOTIFICATION_OPTION_NAME)
+ .hasArg(false)
+ .required(false)
+ .build();
+ Options options = new Options();
+ options.addOption(rescontFileOption);
+ options.addOption(useNbiNotificationsOption);
+ return options;
+ }
+
private void startLighty(ControllerConfiguration controllerConfiguration,
RestConfConfiguration restConfConfiguration, NetconfConfiguration netconfSBPConfiguration,
- boolean registerShutdownHook) throws ConfigurationException, ExecutionException, InterruptedException {
+ boolean registerShutdownHook, boolean activateNbiNotification)
+ throws ConfigurationException, ExecutionException, InterruptedException {
// 1. initialize and start Lighty controller (MD-SAL, Controller, YangTools,
// Akka)
netconfSouthboundPlugin.start().get();
// 4. start TransportPCE beans
- TransportPCE transportPCE = new TransportPCEImpl(lightyController.getServices());
+ TransportPCE transportPCE = new TransportPCEImpl(lightyController.getServices(), activateNbiNotification);
transportPCE.start().get();
// 5. Register shutdown hook for graceful shutdown.
}
public static void main(String[] args) {
- Main app = new Main();
- app.start(args, true);
+ Options options = builOptions();
+ try {
+ CommandLine commandLine = new DefaultParser().parse(options, args);
+ String restConfConfigurationFile = commandLine.getOptionValue(RESTCONF_OPTION_NAME, null);
+ boolean useNbiNotifications = commandLine.hasOption(NBINOTIFICATION_OPTION_NAME);
+ Main app = new Main();
+ app.start(restConfConfigurationFile, useNbiNotifications, true);
+ } catch (ParseException e) {
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp(
+ "java -ms128m -mx512m -XX:MaxMetaspaceSize=128m -jar tpce.jar "
+ + "[-restconf rescontConfigurationFile] [-nbinotification]",
+ options);
+ System.exit(1);
+ }
}
private static class ShutdownHook extends Thread {
import io.lighty.core.controller.api.AbstractLightyModule;
import io.lighty.core.controller.api.LightyServices;
+
+import java.util.Arrays;
+import java.util.List;
+
import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl;
import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl121;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl121;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl221;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl710;
+import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider;
import org.opendaylight.transportpce.networkmodel.NetConfTopologyListener;
import org.opendaylight.transportpce.networkmodel.NetworkModelProvider;
import org.opendaylight.transportpce.networkmodel.NetworkUtilsImpl;
private final TapiProvider tapiProvider;
// service-handler beans
private final ServicehandlerProvider servicehandlerProvider;
+ // nbi-notifications beans
+ private NbiNotificationsProvider nbiNotificationsProvider;
+ /**
+ * List of publisher topics.
+ */
+ private final List<String> publisherTopicList =
+ Arrays.asList("PceListener", "ServiceHandlerOperations", "ServiceHandler", "RendererListener");
- public TransportPCEImpl(LightyServices lightyServices) {
+ public TransportPCEImpl(LightyServices lightyServices, boolean activateNbiNotification) {
LOG.info("Initializing transaction providers ...");
deviceTransactionManager = new DeviceTransactionManagerImpl(lightyServices.getBindingMountPointService(),
MAX_DURATION_TO_SUBMIT_TRANSACTION);
serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
servicehandler);
tapiProvider = initTapi(lightyServices, servicehandler);
+ if(activateNbiNotification) {
+ LOG.info("Creating nbi-notifications beans ...");
+ nbiNotificationsProvider = new NbiNotificationsProvider(
+ publisherTopicList, null, null, lightyServices.getRpcProviderService(),
+ lightyServices.getNotificationService(), lightyServices.getAdapterContext().currentSerializer());
+ }
}
@Override
servicehandlerProvider.init();
LOG.info("Initializing tapi provider ...");
tapiProvider.init();
+ LOG.info("Initializing nbi-notifications provider ...");
+ nbiNotificationsProvider.init();
LOG.info("Init done.");
return true;
}
@Override
protected boolean stopProcedure() {
+ nbiNotificationsProvider.close();
+ LOG.info("Shutting down nbi-notifications provider ...");
tapiProvider.close();
LOG.info("Shutting down service-handler provider ...");
servicehandlerProvider.close();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.$YangModuleInfoImpl
.getInstance(),
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev180928.$YangModuleInfoImpl
+ .getInstance(),
+ org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.$YangModuleInfoImpl
.getInstance());
private static final Set<YangModuleInfo> TPCE_YANG_MODEL = Stream.concat(
@Test
public void startNoConfigFileTest() throws Exception {
- main.start(new String[0], true);
+ main.start(null, false, true);
ContentResponse response = client.GET("http://localhost:8181/restconf/config/ietf-network:networks/network/openroadm-topology");
assertEquals("Response code should be 200", 200, response.getStatus());
}
@Test
public void startConfigFileTest() throws Exception {
File configFile = new File("src/test/resources/config.json");
- String[] args = {configFile.getAbsolutePath()};
- main.start(args, true);
+ main.start(configFile.getAbsolutePath(), false, true);
ContentResponse response = client.GET("http://localhost:8888/restconfCustom/config/ietf-network:networks/network/openroadm-topology");
assertEquals("Response code should be 200", 200, response.getStatus());
}