Merge "Bug 6382 - add apidoc for latest restconf draft"
authorJakub Morvay <jmorvay@cisco.com>
Fri, 4 Nov 2016 08:47:06 +0000 (08:47 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 4 Nov 2016 08:47:06 +0000 (08:47 +0000)
121 files changed:
features/netconf-connector/pom.xml
features/netconf-connector/src/main/features/features.xml
features/netconf/pom.xml
features/netconf/src/main/features/features.xml
netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/aaa/odl/CredentialServiceAuthProvider.java
netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/yang/gen/v1/config/aaa/authn/netconf/plugin/rev150715/AuthProviderModule.java [deleted file]
netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/yang/gen/v1/config/aaa/authn/netconf/plugin/rev150715/AuthProviderModuleFactory.java [deleted file]
netconf/aaa-authn-odl-plugin/src/main/resources/org/opendaylight/blueprint/aaa-authn-netconf.xml [new file with mode: 0644]
netconf/aaa-authn-odl-plugin/src/main/yang/aaa-authn-netconf-plugin.yang [deleted file]
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/mapper/NetconfMdsalMapperModule.java [deleted file]
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/mapper/NetconfMdsalMapperModuleFactory.java [deleted file]
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/MdsalNetconfOperationServiceFactory.java
netconf/mdsal-netconf-connector/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-connector.xml [new file with mode: 0644]
netconf/mdsal-netconf-connector/src/main/yang/netconf-mdsal-mapper.yang [deleted file]
netconf/mdsal-netconf-impl/pom.xml [new file with mode: 0644]
netconf/mdsal-netconf-impl/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-impl.xml [new file with mode: 0755]
netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/MdSalMonitoringMapperFactory.java [new file with mode: 0644]
netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/MonitoringToMdsalWriter.java
netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/NetconfMdsalMonitoringMapperModule.java [deleted file]
netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/NetconfMdsalMonitoringMapperModuleFactory.java [deleted file]
netconf/mdsal-netconf-monitoring/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-monitoring.xml [new file with mode: 0644]
netconf/mdsal-netconf-monitoring/src/main/yang/netconf-mdsal-monitoring.yang [deleted file]
netconf/mdsal-netconf-monitoring/src/test/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/MonitoringToMdsalWriterTest.java
netconf/mdsal-netconf-notification/pom.xml
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/CapabilityChangeNotificationProducer.java
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NetconfMdsalNotificationMapperModule.java [deleted file]
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NetconfMdsalNotificationMapperModuleFactory.java [deleted file]
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NotificationToMdsalWriter.java
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/SessionNotificationProducer.java
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/netconf/mdsal/notification/NetconfNotificationOperationServiceFactory.java
netconf/mdsal-netconf-notification/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-notification.xml [new file with mode: 0755]
netconf/mdsal-netconf-notification/src/main/yang/netconf-mdsal-notification.yang [deleted file]
netconf/mdsal-netconf-notification/src/test/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/CapabilityChangeNotificationProducerTest.java
netconf/mdsal-netconf-notification/src/test/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NotificationToMdsalWriterTest.java
netconf/mdsal-netconf-notification/src/test/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/SessionNotificationProducerTest.java
netconf/mdsal-netconf-ssh/pom.xml [new file with mode: 0644]
netconf/mdsal-netconf-ssh/src/main/resources/org/opendaylight/blueprint/netconf-ssh.xml [new file with mode: 0755]
netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/yang/library/NetconfMdsalYanglibModule.java [deleted file]
netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/yang/library/NetconfMdsalYanglibModuleFactory.java [deleted file]
netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/netconf/mdsal/yang/library/SchemaServiceToMdsalWriter.java
netconf/mdsal-netconf-yang-library/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-yang-library.xml [new file with mode: 0755]
netconf/mdsal-netconf-yang-library/src/main/yang/netconf-mdsal-yang-library.yang [deleted file]
netconf/mdsal-netconf-yang-library/src/test/java/org/opendaylight/netconf/mdsal/yang/library/SchemaServiceToMdsalWriterTest.java
netconf/messagebus-netconf/pom.xml
netconf/messagebus-netconf/src/main/java/org/opendaylight/controller/config/yang/messagebus/netconf/MessageBusNetconfModule.java [deleted file]
netconf/messagebus-netconf/src/main/java/org/opendaylight/controller/config/yang/messagebus/netconf/MessageBusNetconfModuleFactory.java [deleted file]
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceManager.java
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceRegistration.java
netconf/messagebus-netconf/src/main/resources/initial/06-message-netconf.xml [deleted file]
netconf/messagebus-netconf/src/main/resources/org/opendaylight/blueprint/messagebus-netconf.xml [new file with mode: 0644]
netconf/messagebus-netconf/src/main/yang/messagebus-netconf.yang [deleted file]
netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceManagerTest.java
netconf/netconf-api/src/main/yang/netconf-northbound.yang
netconf/netconf-artifacts/pom.xml
netconf/netconf-auth/src/main/yang/netconf-auth.yang
netconf/netconf-client/pom.xml
netconf/netconf-client/src/main/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModule.java [new file with mode: 0644]
netconf/netconf-client/src/main/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModuleFactory.java [new file with mode: 0644]
netconf/netconf-client/src/main/resources/org/opendaylight/blueprint/netconf-client.xml [new file with mode: 0755]
netconf/netconf-client/src/main/yang/odl-netconf-cfg.yang [new file with mode: 0644]
netconf/netconf-client/src/main/yang/odl-netconfig-client-cfg.yang [new file with mode: 0644]
netconf/netconf-client/src/test/resources/helloMessage1.xml
netconf/netconf-config-dispatcher/pom.xml
netconf/netconf-config-dispatcher/src/main/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModule.java [deleted file]
netconf/netconf-config-dispatcher/src/main/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModuleFactory.java [deleted file]
netconf/netconf-config-dispatcher/src/main/yang/odl-netconf-cfg.yang
netconf/netconf-config-dispatcher/src/main/yang/odl-netconfig-client-cfg.yang
netconf/netconf-config-dispatcher/src/test/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModuleTest.java [deleted file]
netconf/netconf-config/src/main/resources/initial/01-netconf.xml
netconf/netconf-console/src/main/config/default-config.xml [deleted file]
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfCommandUtils.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfDisconnectDeviceCommand.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfListDevicesCommand.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfUpdateDeviceCommand.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/impl/NetconfCommandsImpl.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/impl/NetconfConsoleProvider.java [deleted file]
netconf/netconf-console/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/netconf/console/provider/impl/rev160323/NetconfConsoleProviderModule.java [deleted file]
netconf/netconf-console/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/netconf/console/provider/impl/rev160323/NetconfConsoleProviderModuleFactory.java [deleted file]
netconf/netconf-console/src/main/resources/OSGI-INF/blueprint/commands.xml [deleted file]
netconf/netconf-console/src/main/resources/org/opendaylight/blueprint/netconf-command.xml [new file with mode: 0755]
netconf/netconf-console/src/main/yang/netconf-console-provider-impl.yang [deleted file]
netconf/netconf-console/src/test/java/org/opendaylight/netconf/console/impl/NetconfCommandsImplTest.java
netconf/netconf-console/src/test/java/org/opendaylight/netconf/console/impl/NetconfConsoleProviderTest.java [deleted file]
netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfMapperAggregatorModule.java [deleted file]
netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfMapperAggregatorModuleFactory.java [deleted file]
netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfServerDispatcherModule.java [deleted file]
netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfServerDispatcherModuleFactory.java [deleted file]
netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfServerMonitoringModule.java [deleted file]
netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfServerMonitoringModuleFactory.java [deleted file]
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/NetconfServerSessionNegotiatorFactory.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/AggregatedNetconfOperationServiceFactory.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfCapabilityMonitoringService.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfMonitoringServiceImpl.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfOperationRouterImpl.java
netconf/netconf-impl/src/main/yang/netconf-northbound-impl.yang [deleted file]
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/NetconfServerSessionListenerTest.java [new file with mode: 0644]
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/NetconfServerSessionTest.java [new file with mode: 0644]
netconf/netconf-mapping-api/src/main/yang/netconf-northbound-mapper.yang
netconf/netconf-mdsal-config/pom.xml [deleted file]
netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml [deleted file]
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ThreadLocalTransformers.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiatorTest.java [new file with mode: 0644]
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionTest.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/TestingNetconfSession.java [new file with mode: 0644]
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/ThreadLocalTransformersTest.java [new file with mode: 0644]
netconf/netconf-notifications-api/src/main/yang/netconf-northbound-notification.yang
netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModule.java [deleted file]
netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModuleFactory.java [deleted file]
netconf/netconf-notifications-impl/src/main/yang/netconf-northbound-notification-impl.yang [deleted file]
netconf/netconf-ssh/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/ssh/NetconfNorthboundSshModule.java [deleted file]
netconf/netconf-ssh/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/ssh/NetconfNorthboundSshModuleFactory.java [deleted file]
netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/NetconfNorthboundSshServer.java [new file with mode: 0644]
netconf/netconf-ssh/src/main/yang/netconf-northbound-ssh.yang [deleted file]
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/tx/NetconfMasterDOMTransaction.java
netconf/netconf-topology/pom.xml
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfTopologyPathCreator.java [deleted file]
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/xml/XmlNetconfValidator.java [deleted file]
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/NetconfUtilTest.java
netconf/netconf-util/src/test/resources/sessions.xml [new file with mode: 0644]
netconf/pom.xml
netconf/sal-netconf-connector/pom.xml

index 9600b0ba5aa50cd7c8c73458da2c8ed50c608af4..681047f6600ddbfa5eb2f20758e33866150603f9 100644 (file)
@@ -36,7 +36,6 @@
     <config.netconf.client.configfile>01-netconf.xml</config.netconf.client.configfile>
     <config.netconf.topology.configfile>02-netconf-topology.xml</config.netconf.topology.configfile>
     <config.netconf.connector.configfile>99-netconf-connector.xml</config.netconf.connector.configfile>
-    <config.netconf.console.configfile>100-netconf-console.xml</config.netconf.console.configfile>
   </properties>
 
   <dependencyManagement>
       <groupId>org.opendaylight.netconf</groupId>
       <artifactId>messagebus-netconf</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.netconf</groupId>
-      <artifactId>messagebus-netconf</artifactId>
-      <type>xml</type>
-      <classifier>config</classifier>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-config-dispatcher</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-console</artifactId>
-      <version>${project.version}</version>
-    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>netconf-console</artifactId>
       <version>${project.version}</version>
-      <classifier>config</classifier>
-      <type>xml</type>
     </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
index 27c883f2211198353299047f1fa5da04474a23d3..10fbb4f03a59a5d19b5363259a70ae8acc77ca3c 100644 (file)
@@ -26,7 +26,6 @@
         <feature version='${project.version}'>odl-netconf-connector-all</feature>
         <feature version='${controller.mdsal.version}'>odl-message-bus-collector</feature>
         <bundle>mvn:org.opendaylight.netconf/messagebus-netconf/{{VERSION}}</bundle>
-        <configfile finalname="${config.configfile.directory}/06-message-netconf.xml">mvn:org.opendaylight.netconf/messagebus-netconf/{{VERSION}}/xml/config</configfile>
     </feature>
 
     <feature name='odl-netconf-connector' version='${project.version}' description="OpenDaylight :: Netconf Connector :: Netconf Connector">
@@ -39,7 +38,6 @@
         <bundle>mvn:org.opendaylight.controller.model/model-inventory/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.netconf/netconf-topology/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.netconf/sal-netconf-connector/{{VERSION}}</bundle>
-        <bundle>mvn:org.opendaylight.netconf/netconf-config-dispatcher/{{VERSION}}</bundle>
         <configfile finalname='${config.configfile.directory}/${config.netconf.client.configfile}'>mvn:org.opendaylight.netconf/netconf-config/{{VERSION}}/xml/config</configfile>
     </feature>
 
@@ -65,7 +63,6 @@
        <feature version='${project.version}'>odl-netconf-connector-all</feature>
        <feature version='${project.version}'>odl-netconf-topology</feature>
        <bundle>mvn:org.opendaylight.netconf/netconf-console/{{VERSION}}</bundle>
-       <configfile finalname='${config.configfile.directory}/${config.netconf.console.configfile}'>mvn:org.opendaylight.netconf/netconf-console/{{VERSION}}/xml/config</configfile>
     </feature>
 
 </features>
index b413f6b838d807eb4f1cc2fd2eb1e545b8db83e6..6656a4871f1a47c68fa6346687bde63d9d6c4057 100644 (file)
@@ -34,7 +34,6 @@
 
     <config.configfile.directory>etc/opendaylight/karaf</config.configfile.directory>
     <config.netconf.client.configfile>01-netconf.xml</config.netconf.client.configfile>
-    <config.netconf.mdsal.configfile>08-mdsal-netconf.xml</config.netconf.mdsal.configfile>
   </properties>
 
   <dependencyManagement>
       <groupId>${project.groupId}</groupId>
       <artifactId>netconf-impl</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.netconf</groupId>
-      <artifactId>netconf-config-dispatcher</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>config-manager-facade-xml</artifactId>
       <groupId>${project.groupId}</groupId>
       <artifactId>netconf-monitoring</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.netconf</groupId>
+      <artifactId>mdsal-netconf-ssh</artifactId>
+    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>mdsal-netconf-monitoring</artifactId>
       <artifactId>mdsal-netconf-yang-library</artifactId>
     </dependency>
     <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-mdsal-config</artifactId>
-      <classifier>config</classifier>
-      <type>xml</type>
+      <groupId>org.opendaylight.netconf</groupId>
+      <artifactId>mdsal-netconf-impl</artifactId>
     </dependency>
   </dependencies>
 
index b43653d2a05fd2c75bfdc294fe6b2d32c9dac2cf..175f417dd06e9da0761d7d1560617e0011038416 100644 (file)
@@ -92,7 +92,6 @@
     <feature version='${config.version}'>odl-config-netty</feature>
     <feature version='${project.version}'>odl-netconf-netty-util</feature>
     <bundle>mvn:org.opendaylight.netconf/netconf-client/{{VERSION}}</bundle>
-    <bundle>mvn:org.opendaylight.netconf/netconf-config-dispatcher/{{VERSION}}</bundle>
     <configfile finalname='${config.configfile.directory}/${config.netconf.client.configfile}'>mvn:org.opendaylight.netconf/netconf-config/{{VERSION}}/xml/config</configfile>
   </feature>
 
     <feature version='${project.version}'>odl-netconf-ssh</feature>
     <feature version='${project.version}'>odl-netconf-client</feature>
     <feature version='${controller.mdsal.version}'>odl-mdsal-broker</feature>
+    <bundle>mvn:org.opendaylight.netconf/mdsal-netconf-ssh/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.netconf/mdsal-netconf-notification/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.netconf/mdsal-netconf-connector/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.netconf/mdsal-netconf-monitoring/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.netconf/mdsal-netconf-yang-library/{{VERSION}}</bundle>
-    <configfile finalname='${config.configfile.directory}/${config.netconf.mdsal.configfile}'>mvn:org.opendaylight.netconf/netconf-mdsal-config/{{VERSION}}/xml/config</configfile>
+    <bundle>mvn:org.opendaylight.netconf/mdsal-netconf-impl/{{VERSION}}</bundle>
   </feature>
 
   <feature name='odl-aaa-netconf-plugin' description='OpenDaylight :: AAA :: ODL NETCONF Plugin'
index fe1f21c064e6cdc6a94463302cccb174ad072f7c..67ad6ebc572475dce506bc4aee96bdbf6b00254d 100644 (file)
@@ -88,8 +88,11 @@ public final class CredentialServiceAuthProvider implements AuthProvider, AutoCl
         return true;
     }
 
+    /**
+     * Invoke by blueprint
+     */
     @Override
-    public void close() throws Exception {
+    public void close() {
         listenerTracker.close();
         nullableCredService = null;
     }
diff --git a/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/yang/gen/v1/config/aaa/authn/netconf/plugin/rev150715/AuthProviderModule.java b/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/yang/gen/v1/config/aaa/authn/netconf/plugin/rev150715/AuthProviderModule.java
deleted file mode 100644 (file)
index e264881..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.yang.gen.v1.config.aaa.authn.netconf.plugin.rev150715;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.aaa.odl.CredentialServiceAuthProvider;
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.osgi.framework.BundleContext;
-
-public class AuthProviderModule extends org.opendaylight.yang.gen.v1.config.aaa.authn.netconf.plugin.rev150715.AbstractAuthProviderModule {
-
-    private BundleContext bundleContext;
-
-    public AuthProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public AuthProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.config.aaa.authn.netconf.plugin.rev150715.AuthProviderModule oldModule, AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    public AuthProviderModule(final ModuleIdentifier moduleIdentifier, final DependencyResolver dependencyResolver, final AuthProviderModule oldModule, final AutoCloseable oldInstance, final BundleContext bundleContext) {
-        this(moduleIdentifier, dependencyResolver, oldModule, oldInstance);
-        this.bundleContext = bundleContext;
-    }
-
-    public AuthProviderModule(final ModuleIdentifier moduleIdentifier, final DependencyResolver dependencyResolver, final BundleContext bundleContext) {
-        this(moduleIdentifier, dependencyResolver);
-        this.bundleContext = bundleContext;
-    }
-
-    @Override
-    public void customValidation() {
-        Preconditions.checkNotNull(bundleContext, "BundleContext was not properly set up");
-    }
-
-    @Override
-    public AutoCloseable createInstance() {
-       return new CredentialServiceAuthProvider(bundleContext);
-    }
-
-}
diff --git a/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/yang/gen/v1/config/aaa/authn/netconf/plugin/rev150715/AuthProviderModuleFactory.java b/netconf/aaa-authn-odl-plugin/src/main/java/org/opendaylight/yang/gen/v1/config/aaa/authn/netconf/plugin/rev150715/AuthProviderModuleFactory.java
deleted file mode 100644 (file)
index 495ac42..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: aaa-authn-netconf-plugin yang module local name: aaa-authn-netconf-plugin
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Jul 15 15:16:51 CEST 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.config.aaa.authn.netconf.plugin.rev150715;
-
-import java.util.Collections;
-import java.util.Set;
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.DependencyResolverFactory;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.osgi.framework.BundleContext;
-
-public class AuthProviderModuleFactory extends org.opendaylight.yang.gen.v1.config.aaa.authn.netconf.plugin.rev150715.AbstractAuthProviderModuleFactory {
-
-    private static final ModuleIdentifier DEFAULT_INSTANCE_ID = new ModuleIdentifier(NAME, "default-auth-provider");
-
-    @Override
-    public AuthProviderModule instantiateModule(final String instanceName, final DependencyResolver dependencyResolver, final AuthProviderModule oldModule, final AutoCloseable oldInstance, final BundleContext bundleContext) {
-        return new AuthProviderModule(
-                new ModuleIdentifier(NAME, instanceName), dependencyResolver, oldModule, oldInstance, bundleContext);
-    }
-
-    @Override
-    public AuthProviderModule instantiateModule(final String instanceName, final DependencyResolver dependencyResolver, final BundleContext bundleContext) {
-        return new AuthProviderModule(
-                new ModuleIdentifier(NAME, instanceName), dependencyResolver, bundleContext);
-    }
-
-    @Override
-    public Set<AuthProviderModule> getDefaultModules(final DependencyResolverFactory dependencyResolverFactory, final BundleContext bundleContext) {
-        // Config subsystem puts this instance into OSGi service registry automatically
-        final DependencyResolver dependencyResolver = dependencyResolverFactory.createDependencyResolver(DEFAULT_INSTANCE_ID);
-        return Collections.singleton(new AuthProviderModule(DEFAULT_INSTANCE_ID, dependencyResolver, bundleContext));
-    }
-}
diff --git a/netconf/aaa-authn-odl-plugin/src/main/resources/org/opendaylight/blueprint/aaa-authn-netconf.xml b/netconf/aaa-authn-odl-plugin/src/main/resources/org/opendaylight/blueprint/aaa-authn-netconf.xml
new file mode 100644 (file)
index 0000000..6e55371
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies Inc. 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           odl:use-default-for-reference-types="true">
+
+    <bean id="credentialServiceAuthProvider"
+          class="org.opendaylight.aaa.odl.CredentialServiceAuthProvider"
+          destroy-method="close">
+        <argument ref="blueprintBundleContext"/>
+    </bean>
+    <service ref="credentialServiceAuthProvider" interface="org.opendaylight.netconf.auth.AuthProvider"
+             odl:type="netconf-auth-provider"/>
+
+</blueprint>
\ No newline at end of file
diff --git a/netconf/aaa-authn-odl-plugin/src/main/yang/aaa-authn-netconf-plugin.yang b/netconf/aaa-authn-odl-plugin/src/main/yang/aaa-authn-netconf-plugin.yang
deleted file mode 100644 (file)
index ffa6d98..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-module aaa-authn-netconf-plugin {
-
-    yang-version 1;
-    namespace "config:aaa:authn:netconf:plugin";
-    prefix "aaa-authn-store-cfg";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import netconf-auth { prefix na; revision-date 2015-07-15; }
-
-    revision "2015-07-15" {
-        description
-            "Initial revision.";
-    }
-
-    identity aaa-authn-netconf-plugin {
-            base config:module-type;
-            config:java-name-prefix AuthProvider;
-            config:provided-service na:netconf-auth-provider;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case aaa-authn-netconf-plugin {
-            when "/config:modules/config:module/config:type = 'aaa-authn-netconf-plugin'";
-            // no config yet
-       }
-    }
-}
diff --git a/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/mapper/NetconfMdsalMapperModule.java b/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/mapper/NetconfMdsalMapperModule.java
deleted file mode 100644 (file)
index 23993cf..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.controller.config.yang.netconf.mdsal.mapper;
-
-import org.opendaylight.netconf.mdsal.connector.MdsalNetconfOperationServiceFactory;
-
-public class NetconfMdsalMapperModule extends org.opendaylight.controller.config.yang.netconf.mdsal.mapper.AbstractNetconfMdsalMapperModule{
-    public NetconfMdsalMapperModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public NetconfMdsalMapperModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.netconf.mdsal.mapper.NetconfMdsalMapperModule oldModule, java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        final MdsalNetconfOperationServiceFactory mdsalNetconfOperationServiceFactory =
-            new MdsalNetconfOperationServiceFactory(getRootSchemaServiceDependency(), getRootSchemaSourceProviderDependency()) {
-                @Override
-                public void close() throws Exception {
-                    super.close();
-                    getMapperAggregatorDependency().onRemoveNetconfOperationServiceFactory(this);
-                }
-            };
-        getDomBrokerDependency().registerConsumer(mdsalNetconfOperationServiceFactory);
-        getMapperAggregatorDependency().onAddNetconfOperationServiceFactory(mdsalNetconfOperationServiceFactory);
-        return mdsalNetconfOperationServiceFactory;
-    }
-
-}
diff --git a/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/mapper/NetconfMdsalMapperModuleFactory.java b/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/mapper/NetconfMdsalMapperModuleFactory.java
deleted file mode 100644 (file)
index 4eb0563..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: netconf-mdsal-mapper yang module local name: netconf-mdsal-mapper
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Jan 14 14:58:42 CET 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.netconf.mdsal.mapper;
-public class NetconfMdsalMapperModuleFactory extends org.opendaylight.controller.config.yang.netconf.mdsal.mapper.AbstractNetconfMdsalMapperModuleFactory {
-
-}
index b450a9d0c8310cc5fd9a738d5b179f8372eaa9ec..ef3bbf03e7c6eb75a03d33ef254efa8440779a71 100644 (file)
@@ -15,19 +15,16 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 import org.opendaylight.controller.config.util.capability.Capability;
 import org.opendaylight.controller.config.util.capability.YangModuleCapability;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
-import org.opendaylight.controller.sal.core.api.Consumer;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
+import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -38,19 +35,30 @@ import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class MdsalNetconfOperationServiceFactory implements NetconfOperationServiceFactory, Consumer, AutoCloseable {
+public class MdsalNetconfOperationServiceFactory implements NetconfOperationServiceFactory, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(MdsalNetconfOperationServiceFactory.class);
 
-    private ConsumerSession session = null;
-    private DOMDataBroker dataBroker = null;
-    private DOMRpcService rpcService = null;
+    private final DOMDataBroker dataBroker;
+    private final DOMRpcService rpcService;
+
     private final CurrentSchemaContext currentSchemaContext;
     private final SchemaSourceProvider<YangTextSchemaSource> rootSchemaSourceProviderDependency;
+    private final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener;
+
+    public MdsalNetconfOperationServiceFactory(final SchemaService schemaService,
+                                               final SchemaSourceProvider<YangTextSchemaSource> rootSchemaSourceProviderDependency,
+                                               final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener,
+                                               final DOMDataBroker dataBroker,
+                                               final DOMRpcService rpcService) {
+
+        this.dataBroker = dataBroker;
+        this.rpcService = rpcService;
 
-    public MdsalNetconfOperationServiceFactory(final SchemaService schemaService, final SchemaSourceProvider<YangTextSchemaSource> rootSchemaSourceProviderDependency) {
         this.rootSchemaSourceProviderDependency = rootSchemaSourceProviderDependency;
         this.currentSchemaContext = new CurrentSchemaContext(Preconditions.checkNotNull(schemaService), rootSchemaSourceProviderDependency);
+        this.netconfOperationServiceFactoryListener = netconfOperationServiceFactoryListener;
+        this.netconfOperationServiceFactoryListener.onAddNetconfOperationServiceFactory(this);
     }
 
     @Override
@@ -60,8 +68,15 @@ public class MdsalNetconfOperationServiceFactory implements NetconfOperationServ
     }
 
     @Override
-    public void close() throws Exception {
-        currentSchemaContext.close();
+    public void close() {
+        try {
+            currentSchemaContext.close();
+            if (netconfOperationServiceFactoryListener != null) {
+                netconfOperationServiceFactoryListener.onRemoveNetconfOperationServiceFactory(this);
+            }
+        } catch(Exception e) {
+            LOG.error("Failed to close resources correctly - ignore", e);
+        }
     }
 
     @Override
@@ -130,16 +145,4 @@ public class MdsalNetconfOperationServiceFactory implements NetconfOperationServ
     public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
         return currentSchemaContext.registerCapabilityListener(listener);
     }
-
-    @Override
-    public void onSessionInitiated(ConsumerSession session) {
-        this.session = Preconditions.checkNotNull(session);
-        this.dataBroker = this.session.getService(DOMDataBroker.class);
-        this.rpcService = this.session.getService(DOMRpcService.class);
-    }
-
-    @Override
-    public Collection<ConsumerFunctionality> getConsumerFunctionality() {
-        return Collections.emptySet();
-    }
 }
diff --git a/netconf/mdsal-netconf-connector/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-connector.xml b/netconf/mdsal-netconf-connector/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-connector.xml
new file mode 100644 (file)
index 0000000..63505e7
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies Inc. 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           odl:use-default-for-reference-types="true">
+
+    <reference id="domDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"/>
+    <reference id="domRpcService" interface="org.opendaylight.controller.md.sal.dom.api.DOMRpcService"/>
+    <reference id="schemaService"
+               interface="org.opendaylight.controller.sal.core.api.model.SchemaService"/>
+    <reference id="rootSchemaSourceProviderDependency"
+               interface="org.opendaylight.controller.sal.core.api.model.YangTextSourceProvider"/>
+    <reference id="netconfOperationServiceFactoryListener"
+               interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener"
+               odl:type="mapper-aggregator-registry"/>
+
+    <bean id="mdsalNetconfOperationServiceFactory"
+          class="org.opendaylight.netconf.mdsal.connector.MdsalNetconfOperationServiceFactory"
+          destroy-method="close">
+        <argument ref="schemaService"/>
+        <argument ref="rootSchemaSourceProviderDependency"/>
+        <argument ref="netconfOperationServiceFactoryListener"/>
+        <argument ref="domDataBroker"/>
+        <argument ref="domRpcService"/>
+    </bean>
+    <service ref="mdsalNetconfOperationServiceFactory"
+             interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory"
+             odl:type="mdsal-netconf-connector"/>
+
+</blueprint>
diff --git a/netconf/mdsal-netconf-connector/src/main/yang/netconf-mdsal-mapper.yang b/netconf/mdsal-netconf-connector/src/main/yang/netconf-mdsal-mapper.yang
deleted file mode 100644 (file)
index 633a930..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-module netconf-mdsal-mapper {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:mapper";
-    prefix "nmm";
-
-    import netconf-northbound-mapper { prefix nnm; revision-date 2015-01-14; }
-    import opendaylight-md-sal-dom { prefix md-sal-dom; revision-date 2013-10-28; }
-    import config { prefix config; revision-date 2013-04-05; }
-
-    organization "Cisco Systems, Inc.";
-
-    description
-        "This module contains the base YANG definitions for
-         an MD-SAL mapper implementation";
-
-    revision "2015-01-14" {
-        description
-            "Initial revision.";
-    }
-
-    identity netconf-mdsal-mapper {
-        base config:module-type;
-        config:provided-service nnm:netconf-northbound-mapper;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case netconf-mdsal-mapper {
-            when "/config:modules/config:module/config:type = 'netconf-mdsal-mapper'";
-
-            container root-schema-service {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity md-sal-dom:schema-service;
-                    }
-                }
-            }
-
-            container root-schema-source-provider {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity md-sal-dom:yang-text-source-provider;
-                    }
-                }
-            }
-
-            container dom-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-dom:dom-broker-osgi-registry;
-                    }
-                }
-            }
-
-            container mapper-aggregator {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity nnm:netconf-mapper-registry;
-                    }
-                }
-            }
-        }
-    }
-
-}
diff --git a/netconf/mdsal-netconf-impl/pom.xml b/netconf/mdsal-netconf-impl/pom.xml
new file mode 100644 (file)
index 0000000..882f939
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies 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
+-->
+<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.controller</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.6.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <groupId>org.opendaylight.netconf</groupId>
+  <artifactId>mdsal-netconf-impl</artifactId>
+  <version>1.2.0-SNAPSHOT</version>
+  <name>${project.artifactId}</name>
+  <packaging>bundle</packaging>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.opendaylight.netconf</groupId>
+        <artifactId>netconf-subsystem</artifactId>
+        <version>${project.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>netconf-impl</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+            <Embed-Dependency>netconf-impl</Embed-Dependency>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/netconf/mdsal-netconf-impl/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-impl.xml b/netconf/mdsal-netconf-impl/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-impl.xml
new file mode 100755 (executable)
index 0000000..f75383c
--- /dev/null
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies Inc. 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.3.0"
+           odl:restart-dependents-on-updates="true"
+           odl:use-default-for-reference-types="true">
+
+    <!--This is the MD-SAL netconf server implementation blueprint xml file-->
+
+    <reference id="globalBossGroup" interface="io.netty.channel.EventLoopGroup" odl:type="global-boss-group"/>
+    <reference id="globalWorkerGroup" interface="io.netty.channel.EventLoopGroup" odl:type="global-worker-group"/>
+    <reference id="global-timer" interface="io.netty.util.Timer" odl:type="global-timer"/>
+    <reference id="scheduledThreadPool" interface="org.opendaylight.controller.config.threadpool.ScheduledThreadPool"/>
+
+    <cm:property-placeholder persistent-id="org.opendaylight.netconf.impl" update-strategy="none">
+        <cm:default-properties>
+            <cm:property name="connection-timeout-millis" value="20000"/>
+            <cm:property name="monitoring-update-interval" value="6"/>
+        </cm:default-properties>
+    </cm:property-placeholder>
+
+    <!--NetconfMapperAggregator -->
+
+    <bean id="aggregatedNetconfOperationServiceFactory"
+          class="org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory"
+          destroy-method="close">
+    </bean>
+    <service ref="aggregatedNetconfOperationServiceFactory"
+             interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener"
+             odl:type="mapper-aggregator-registry">
+    </service>
+
+    <!--NetconfServerDispatcher -->
+
+    <bean id="sessionIdProvider"
+          class="org.opendaylight.netconf.impl.SessionIdProvider"/>
+
+    <bean id="aggregatedNetconfOperationServiceFactoryMappers"
+          class="org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory"
+          destroy-method="close">
+        <argument>
+            <list value-type="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory">
+                <ref component-id="aggregatedNetconfOperationServiceFactory"/>
+            </list>
+        </argument>
+    </bean>
+
+    <bean id="netconfServerSessionNegotiatorFactory"
+          class="org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorFactory">
+        <argument ref="global-timer"/>
+        <argument ref="aggregatedNetconfOperationServiceFactoryMappers"/>
+        <argument ref="sessionIdProvider"/>
+        <argument value="${connection-timeout-millis}"/>
+        <argument ref="netconfMonitoringService"/>
+        <argument><null/></argument><!--Base capabilities-->
+    </bean>
+
+    <bean id="serverChannelInitializer"
+          class="org.opendaylight.netconf.impl.NetconfServerDispatcherImpl.ServerChannelInitializer">
+        <argument ref="netconfServerSessionNegotiatorFactory"/>
+    </bean>
+
+    <bean id="netconfServerDispatcherImpl"
+          class="org.opendaylight.netconf.impl.NetconfServerDispatcherImpl">
+        <argument ref="serverChannelInitializer"/>
+        <argument ref="globalBossGroup"/>
+        <argument ref="globalWorkerGroup"/>
+    </bean>
+    <service ref="netconfServerDispatcherImpl"
+             interface="org.opendaylight.netconf.api.NetconfServerDispatcher"
+             odl:type="netconf-server-dispatcher">
+    </service>
+
+    <!--NetconfServerMonitoring -->
+
+    <bean id="netconfMonitoringService"
+          class="org.opendaylight.netconf.impl.osgi.NetconfMonitoringServiceImpl">
+        <argument ref="aggregatedNetconfOperationServiceFactory"/>
+        <argument ref="scheduledThreadPool"/>
+        <argument value="${monitoring-update-interval}"/>
+    </bean>
+    <service ref="netconfMonitoringService"
+             interface="org.opendaylight.netconf.api.monitoring.NetconfMonitoringService"
+             odl:type="netconf-server-monitoring">
+    </service>
+
+</blueprint>
diff --git a/netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/MdSalMonitoringMapperFactory.java b/netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/MdSalMonitoringMapperFactory.java
new file mode 100644 (file)
index 0000000..a80275d
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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
+ */
+package org.opendaylight.controller.config.yang.netconf.mdsal.monitoring;
+
+import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
+import org.opendaylight.netconf.api.monitoring.CapabilityListener;
+import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.netconf.mapping.api.NetconfOperation;
+import org.opendaylight.netconf.mapping.api.NetconfOperationService;
+import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
+import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener;
+import org.opendaylight.netconf.monitoring.GetSchema;
+
+import java.util.Collections;
+import java.util.Set;
+
+public class MdSalMonitoringMapperFactory implements NetconfOperationServiceFactory, AutoCloseable {
+
+    private final NetconfOperationService operationService;
+    private final MonitoringToMdsalWriter monitoringToMdsalWriter;
+    private final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener;
+
+    private static final Set<Capability> CAPABILITIES = Collections.emptySet();
+
+    public MdSalMonitoringMapperFactory(final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener,
+                                        final NetconfMonitoringService netconfMonitoringService,
+                                        final MonitoringToMdsalWriter monitoringToMdsalWriter) {
+
+        this.netconfOperationServiceFactoryListener = netconfOperationServiceFactoryListener;
+        this.monitoringToMdsalWriter = monitoringToMdsalWriter;
+
+        this.operationService = new NetconfOperationService() {
+            @Override
+            public Set<NetconfOperation> getNetconfOperations() {
+                return Collections.singleton(new GetSchema(netconfMonitoringService));
+            }
+
+            @Override
+            public void close() {
+                // NOOP
+            }
+        };
+
+        this.netconfOperationServiceFactoryListener.onAddNetconfOperationServiceFactory(this);
+    }
+
+    @Override
+    public NetconfOperationService createService(final String netconfSessionIdForReporting) {
+        return operationService;
+    }
+
+    @Override
+    public Set<Capability> getCapabilities() {
+        // TODO
+        // No capabilities exposed to prevent clashes with schemas from mdsal-netconf-connector (it exposes all the schemas)
+        // If the schemas exposed by mdsal-netconf-connector are filtered, this class would expose monitoring related models
+        return CAPABILITIES;
+    }
+
+    @Override
+    public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
+        return NoopAutoCloseable.INSTANCE;
+    }
+
+    /**
+     * Invoke using blueprint
+     */
+    @Override
+    public void close() {
+        monitoringToMdsalWriter.close();
+        netconfOperationServiceFactoryListener.onRemoveNetconfOperationServiceFactory(this);
+    }
+
+}
\ No newline at end of file
index 7c434f2813eae2916abd909a6f4d7882c440a6a8..3e487b4db6045c248891122be3a8336c6fe826f9 100644 (file)
@@ -17,8 +17,6 @@ import javax.annotation.Nullable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities;
@@ -32,8 +30,8 @@ import org.slf4j.LoggerFactory;
 /**
  * Writes netconf server state changes received from NetconfMonitoringService to netconf-state datastore subtree.
  */
-final class MonitoringToMdsalWriter implements AutoCloseable, NetconfMonitoringService.CapabilitiesListener,
-        NetconfMonitoringService.SessionsListener, BindingAwareProvider {
+public final class MonitoringToMdsalWriter implements AutoCloseable, NetconfMonitoringService.CapabilitiesListener,
+        NetconfMonitoringService.SessionsListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(MonitoringToMdsalWriter.class);
 
@@ -45,12 +43,17 @@ final class MonitoringToMdsalWriter implements AutoCloseable, NetconfMonitoringS
             InstanceIdentifier.create(NetconfState.class).child(Sessions.class);
 
     private final NetconfMonitoringService serverMonitoringDependency;
-    private DataBroker dataBroker;
+    private final DataBroker dataBroker;
 
-    public MonitoringToMdsalWriter(final NetconfMonitoringService serverMonitoringDependency) {
+    public MonitoringToMdsalWriter(final NetconfMonitoringService serverMonitoringDependency,
+                                   final DataBroker dataBroker) {
         this.serverMonitoringDependency = serverMonitoringDependency;
+        this.dataBroker = dataBroker;
     }
 
+    /**
+     * Invoke using blueprint
+     */
     @Override
     public void close() {
         runTransaction((tx) -> tx.delete(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(NetconfState.class)));
@@ -85,9 +88,10 @@ final class MonitoringToMdsalWriter implements AutoCloseable, NetconfMonitoringS
         runTransaction((tx) -> tx.put(LogicalDatastoreType.OPERATIONAL, SCHEMAS_INSTANCE_IDENTIFIER, schemas));
     }
 
-    @Override
-    public void onSessionInitiated(final BindingAwareBroker.ProviderContext providerContext) {
-        dataBroker = providerContext.getSALService(DataBroker.class);
+    /**
+     * Invoke using blueprint
+     */
+    public void start() {
         serverMonitoringDependency.registerCapabilitiesListener(this);
         serverMonitoringDependency.registerSessionsListener(this);
     }
diff --git a/netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/NetconfMdsalMonitoringMapperModule.java b/netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/NetconfMdsalMonitoringMapperModule.java
deleted file mode 100644 (file)
index d335a28..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.controller.config.yang.netconf.mdsal.monitoring;
-
-import java.util.Collections;
-import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
-import org.opendaylight.netconf.api.monitoring.CapabilityListener;
-import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-import org.opendaylight.netconf.mapping.api.NetconfOperationService;
-import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-import org.opendaylight.netconf.monitoring.GetSchema;
-
-public class NetconfMdsalMonitoringMapperModule extends org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.AbstractNetconfMdsalMonitoringMapperModule {
-    public NetconfMdsalMonitoringMapperModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public NetconfMdsalMonitoringMapperModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.NetconfMdsalMonitoringMapperModule oldModule, final java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        final NetconfMonitoringService serverMonitoringDependency = getServerMonitoringDependency();
-
-        final MonitoringToMdsalWriter monitoringToMdsalWriter = new MonitoringToMdsalWriter(serverMonitoringDependency);
-        getBindingAwareBrokerDependency().registerProvider(monitoringToMdsalWriter);
-
-        final MdSalMonitoringMapperFactory mdSalMonitoringMapperFactory = new MdSalMonitoringMapperFactory(new MdsalMonitoringMapper(serverMonitoringDependency),
-                this, monitoringToMdsalWriter);
-
-        getAggregatorDependency().onAddNetconfOperationServiceFactory(mdSalMonitoringMapperFactory);
-        return mdSalMonitoringMapperFactory;
-
-    }
-
-    private static class MdSalMonitoringMapperFactory implements NetconfOperationServiceFactory, AutoCloseable {
-
-        private final NetconfOperationService operationService;
-        private final NetconfMdsalMonitoringMapperModule module;
-        private final MonitoringToMdsalWriter monitoringToMdsalWriter;
-
-        private static final Set<Capability> CAPABILITIES = Collections.emptySet();
-        private static final AutoCloseable AUTO_CLOSEABLE = new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                // NOOP
-            }
-        };
-
-        public MdSalMonitoringMapperFactory(
-                final NetconfOperationService operationService,
-                final NetconfMdsalMonitoringMapperModule module,
-                final MonitoringToMdsalWriter monitoringToMdsalWriter
-        ) {
-            this.operationService = operationService;
-            this.module = module;
-            this.monitoringToMdsalWriter = monitoringToMdsalWriter;
-        }
-
-        @Override
-        public NetconfOperationService createService(final String netconfSessionIdForReporting) {
-            return operationService;
-        }
-
-        @Override
-        public Set<Capability> getCapabilities() {
-            // TODO
-            // No capabilities exposed to prevent clashes with schemas from mdsal-netconf-connector (it exposes all the schemas)
-            // If the schemas exposed by mdsal-netconf-connector are filtered, this class would expose monitoring related models
-            return CAPABILITIES;
-        }
-
-        @Override
-        public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
-            return AUTO_CLOSEABLE;
-        }
-
-        @Override
-        public void close() {
-            monitoringToMdsalWriter.close();
-            module.getAggregatorDependency().onRemoveNetconfOperationServiceFactory(this);
-        }
-
-    }
-
-
-    private static class MdsalMonitoringMapper implements NetconfOperationService {
-
-        private final NetconfMonitoringService serverMonitoringDependency;
-
-        public MdsalMonitoringMapper(final NetconfMonitoringService serverMonitoringDependency) {
-            this.serverMonitoringDependency = serverMonitoringDependency;
-        }
-
-        @Override
-        public Set<NetconfOperation> getNetconfOperations() {
-            return Collections.<NetconfOperation>singleton(new GetSchema(serverMonitoringDependency));
-        }
-
-        @Override
-        public void close() {
-            // NOOP
-        }
-    }
-}
diff --git a/netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/NetconfMdsalMonitoringMapperModuleFactory.java b/netconf/mdsal-netconf-monitoring/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/monitoring/NetconfMdsalMonitoringMapperModuleFactory.java
deleted file mode 100644 (file)
index 026b415..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: netconf-mdsal-monitoring yang module local name: netconf-mdsal-monitoring-mapper
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Feb 18 10:22:17 CET 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.netconf.mdsal.monitoring;
-public class NetconfMdsalMonitoringMapperModuleFactory extends org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.AbstractNetconfMdsalMonitoringMapperModuleFactory {
-
-}
diff --git a/netconf/mdsal-netconf-monitoring/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-monitoring.xml b/netconf/mdsal-netconf-monitoring/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-monitoring.xml
new file mode 100644 (file)
index 0000000..13b2633
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies Inc. 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           odl:use-default-for-reference-types="true">
+
+    <reference id="dataBroker"
+               interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+               odl:type="default"/>
+    <reference id="netconfMonitoringService"
+               interface="org.opendaylight.netconf.api.monitoring.NetconfMonitoringService"
+               odl:type="netconf-server-monitoring"/>
+    <reference id="netconfOperationServiceFactoryListener"
+               interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener"
+               odl:type="mapper-aggregator-registry"/>
+
+    <bean id="monitoringToMdsalWriter"
+          class="org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.MonitoringToMdsalWriter"
+          init-method="start"
+          destroy-method="close">
+        <argument ref="netconfMonitoringService"/>
+        <argument ref="dataBroker"/>
+    </bean>
+
+    <bean id="mdsalMonitoringMapperFactory"
+          class="org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.MdSalMonitoringMapperFactory"
+          destroy-method="close">
+        <argument ref="netconfOperationServiceFactoryListener"/>
+        <argument ref="netconfMonitoringService"/>
+        <argument ref="monitoringToMdsalWriter"/>
+    </bean>
+
+</blueprint>
diff --git a/netconf/mdsal-netconf-monitoring/src/main/yang/netconf-mdsal-monitoring.yang b/netconf/mdsal-netconf-monitoring/src/main/yang/netconf-mdsal-monitoring.yang
deleted file mode 100644 (file)
index 68a248e..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-module netconf-mdsal-monitoring {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring";
-    prefix "nmmonitor";
-
-    import netconf-northbound-mapper { prefix nnm; revision-date 2015-01-14; }
-    import opendaylight-md-sal-binding {prefix md-sal-binding; revision-date 2013-10-28;}
-    import netconf-northbound { prefix nn; revision-date 2015-01-14; }
-    import config { prefix config; revision-date 2013-04-05; }
-
-    organization "Cisco Systems, Inc.";
-
-    description
-        "This module contains the base YANG definitions for
-         an MD-SAL monitoring mapper implementation";
-
-    revision "2015-02-18" {
-        description
-            "Initial revision.";
-    }
-
-    identity netconf-mdsal-monitoring-mapper {
-        base config:module-type;
-        config:provided-service nnm:netconf-northbound-mapper;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case netconf-mdsal-monitoring-mapper {
-            when "/config:modules/config:module/config:type = 'netconf-mdsal-monitoring-mapper'";
-
-            container server-monitoring {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity nn:netconf-server-monitoring;
-                    }
-                }
-            }
-
-            container aggregator {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity nnm:netconf-mapper-registry;
-                    }
-                }
-            }
-
-            container binding-aware-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
-                    }
-                }
-            }
-        }
-    }
-
-}
index ce52b2508e9e1b68357d630e1010ee714989e857..62551b4896f4e92a0f15086eb1c1d3665a9e2a86 100644 (file)
@@ -27,7 +27,6 @@ import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities;
@@ -46,8 +45,6 @@ public class MonitoringToMdsalWriterTest {
     @Mock
     private NetconfMonitoringService monitoring;
     @Mock
-    private BindingAwareBroker.ProviderContext context;
-    @Mock
     private DataBroker dataBroker;
     @Mock
     private WriteTransaction writeTransaction;
@@ -61,20 +58,18 @@ public class MonitoringToMdsalWriterTest {
         doReturn(null).when(monitoring).registerCapabilitiesListener(any());
         doReturn(null).when(monitoring).registerSessionsListener(any());
 
-        doReturn(dataBroker).when(context).getSALService(DataBroker.class);
-
         doReturn(writeTransaction).when(dataBroker).newWriteOnlyTransaction();
 
         doNothing().when(writeTransaction).put(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
         doNothing().when(writeTransaction).delete(eq(LogicalDatastoreType.OPERATIONAL), any());
         doReturn(Futures.immediateCheckedFuture(null)).when(writeTransaction).submit();
 
-        writer = new MonitoringToMdsalWriter(monitoring);
+        writer = new MonitoringToMdsalWriter(monitoring, dataBroker);
     }
 
     @Test
     public void testClose() throws Exception {
-        writer.onSessionInitiated(context);
+        writer.start();
         writer.close();
         InOrder inOrder = inOrder(writeTransaction);
         inOrder.verify(writeTransaction).delete(LogicalDatastoreType.OPERATIONAL, INSTANCE_IDENTIFIER);
@@ -84,7 +79,7 @@ public class MonitoringToMdsalWriterTest {
     @Test
     public void testOnCapabilityChanged() throws Exception {
         final InstanceIdentifier<Capabilities> capabilitiesId = InstanceIdentifier.create(NetconfState.class).child(Capabilities.class);
-        writer.onSessionInitiated(context);
+        writer.start();
         final Capabilities capabilities = new CapabilitiesBuilder().build();
         writer.onCapabilitiesChanged(capabilities);
         InOrder inOrder = inOrder(writeTransaction);
@@ -95,7 +90,7 @@ public class MonitoringToMdsalWriterTest {
     @Test
     public void testOnSchemasChanged() throws Exception {
         final InstanceIdentifier<Schemas> schemasId = InstanceIdentifier.create(NetconfState.class).child(Schemas.class);
-        writer.onSessionInitiated(context);
+        writer.start();
         final Schemas schemas = new SchemasBuilder().build();
         writer.onSchemasChanged(schemas);
         InOrder inOrder = inOrder(writeTransaction);
@@ -109,7 +104,7 @@ public class MonitoringToMdsalWriterTest {
                 .setSessionId(1L)
                 .build();
         final InstanceIdentifier<Session> id = InstanceIdentifier.create(NetconfState.class).child(Sessions.class).child(Session.class, session.getKey());
-        writer.onSessionInitiated(context);
+        writer.start();
         writer.onSessionStarted(session);
         InOrder inOrder = inOrder(writeTransaction);
         inOrder.verify(writeTransaction).put(LogicalDatastoreType.OPERATIONAL, id, session);
@@ -122,7 +117,7 @@ public class MonitoringToMdsalWriterTest {
                 .setSessionId(1L)
                 .build();
         final InstanceIdentifier<Session> id = InstanceIdentifier.create(NetconfState.class).child(Sessions.class).child(Session.class, session.getKey());
-        writer.onSessionInitiated(context);
+        writer.start();
         writer.onSessionEnded(session);
         InOrder inOrder = inOrder(writeTransaction);
         inOrder.verify(writeTransaction).delete(LogicalDatastoreType.OPERATIONAL, id);
@@ -142,7 +137,7 @@ public class MonitoringToMdsalWriterTest {
         sessions.add(session2);
         final InstanceIdentifier<Session> id1 = InstanceIdentifier.create(NetconfState.class).child(Sessions.class).child(Session.class, session1.getKey());
         final InstanceIdentifier<Session> id2 = InstanceIdentifier.create(NetconfState.class).child(Sessions.class).child(Session.class, session2.getKey());
-        writer.onSessionInitiated(context);
+        writer.start();
         writer.onSessionsUpdated(sessions);
         InOrder inOrder = inOrder(writeTransaction);
         inOrder.verify(writeTransaction).put(LogicalDatastoreType.OPERATIONAL, id1, session1);
@@ -152,7 +147,7 @@ public class MonitoringToMdsalWriterTest {
 
     @Test
     public void testOnSessionInitiated() throws Exception {
-        writer.onSessionInitiated(context);
+        writer.start();
         verify(monitoring).registerCapabilitiesListener(writer);
     }
 }
\ No newline at end of file
index d229c316a3cf6fa0467483a678ebaef14e8ea2ea..40b561c2a3901c727dec27a2a356ddb332755e7a 100644 (file)
             <artifactId>mockito-configuration</artifactId>
         </dependency>
     </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Embed-Dependency>netconf-notifications-impl</Embed-Dependency>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>
index 2fd48091e9d1934214f47c88062ff879afb050e3..35f5c805aecbfdf39cfdafb19db7751989439b13 100644 (file)
@@ -15,15 +15,18 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Set;
 import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
+import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.ChangedByBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.changed.by.server.or.user.ServerBuilder;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 
@@ -31,15 +34,19 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
  * Listens on capabilities changes in data store and publishes them to base
  * netconf notification stream listener.
  */
-final class CapabilityChangeNotificationProducer extends OperationalDatastoreListener<Capabilities> {
+public final class CapabilityChangeNotificationProducer extends OperationalDatastoreListener<Capabilities> {
 
     private static final InstanceIdentifier<Capabilities> CAPABILITIES_INSTANCE_IDENTIFIER =
             InstanceIdentifier.create(NetconfState.class).child(Capabilities.class);
+
     private final BaseNotificationPublisherRegistration baseNotificationPublisherRegistration;
+    private final ListenerRegistration capabilityChangeListenerRegistration;
 
-    public CapabilityChangeNotificationProducer(BaseNotificationPublisherRegistration baseNotificationPublisherRegistration) {
+    public CapabilityChangeNotificationProducer(final NetconfNotificationCollector netconfNotificationCollector,
+                                                final DataBroker dataBroker) {
         super(CAPABILITIES_INSTANCE_IDENTIFIER);
-        this.baseNotificationPublisherRegistration = baseNotificationPublisherRegistration;
+        this.baseNotificationPublisherRegistration = netconfNotificationCollector.registerBaseNotificationPublisher();
+        this.capabilityChangeListenerRegistration = registerOnChanges(dataBroker);
     }
 
     @Override
@@ -80,4 +87,16 @@ final class CapabilityChangeNotificationProducer extends OperationalDatastoreLis
         netconfCapabilityChangeBuilder.setModifiedCapability(Collections.<Uri>emptyList());
         baseNotificationPublisherRegistration.onCapabilityChanged(netconfCapabilityChangeBuilder.build());
     }
+
+    /**
+     * Invoke by blueprint
+     */
+    public void close() {
+        if (baseNotificationPublisherRegistration != null) {
+            baseNotificationPublisherRegistration.close();
+        }
+        if (capabilityChangeListenerRegistration != null) {
+            capabilityChangeListenerRegistration.close();
+        }
+    }
 }
diff --git a/netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NetconfMdsalNotificationMapperModule.java b/netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NetconfMdsalNotificationMapperModule.java
deleted file mode 100644 (file)
index 685e80f..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.controller.config.yang.netconf.mdsal.notification;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.netconf.mdsal.notification.NetconfNotificationOperationServiceFactory;
-import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
-public class NetconfMdsalNotificationMapperModule extends org.opendaylight.controller.config.yang.netconf.mdsal.notification.AbstractNetconfMdsalNotificationMapperModule {
-    public NetconfMdsalNotificationMapperModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public NetconfMdsalNotificationMapperModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.netconf.mdsal.notification.NetconfMdsalNotificationMapperModule oldModule, java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        final NetconfNotificationCollector notificationCollector = getNotificationCollectorDependency();
-
-        final NotificationToMdsalWriter notificationToMdsalWriter = new NotificationToMdsalWriter(notificationCollector);
-        getBindingAwareBrokerDependency().registerProvider(notificationToMdsalWriter);
-        final DataBroker dataBroker = getDataBrokerDependency();
-
-        final OperationalDatastoreListener capabilityNotificationProducer =
-                new CapabilityChangeNotificationProducer(notificationCollector.registerBaseNotificationPublisher());
-        final ListenerRegistration capabilityChangeListenerRegistration = capabilityNotificationProducer.registerOnChanges(dataBroker);
-
-        final OperationalDatastoreListener sessionNotificationProducer =
-                new SessionNotificationProducer(notificationCollector.registerBaseNotificationPublisher());
-        final ListenerRegistration sessionListenerRegistration = sessionNotificationProducer.registerOnChanges(dataBroker);
-
-        final NetconfNotificationOperationServiceFactory netconfNotificationOperationServiceFactory =
-            new NetconfNotificationOperationServiceFactory(getNotificationRegistryDependency()) {
-                @Override
-                public void close() {
-                    super.close();
-                    notificationToMdsalWriter.close();
-                    capabilityChangeListenerRegistration.close();
-                    sessionListenerRegistration.close();
-                    getAggregatorDependency().onRemoveNetconfOperationServiceFactory(this);
-                }
-            };
-
-        getAggregatorDependency().onAddNetconfOperationServiceFactory(netconfNotificationOperationServiceFactory);
-
-        return netconfNotificationOperationServiceFactory;
-    }
-}
diff --git a/netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NetconfMdsalNotificationMapperModuleFactory.java b/netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NetconfMdsalNotificationMapperModuleFactory.java
deleted file mode 100644 (file)
index c87382c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: netconf-mdsal-notification yang module local name: netconf-mdsal-notification-mapper
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Aug 05 10:21:08 CEST 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.netconf.mdsal.notification;
-
-public class NetconfMdsalNotificationMapperModuleFactory extends org.opendaylight.controller.config.yang.netconf.mdsal.notification.AbstractNetconfMdsalNotificationMapperModuleFactory {
-
-}
index 4a8c09ee24ee1ad9dd77a0e606598664dc0f099f..5ffe2c9ecddf383f51a37d44e4a141d5ceaac899 100644 (file)
@@ -15,8 +15,6 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
 import org.opendaylight.netconf.notifications.NotificationRegistration;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
@@ -32,16 +30,18 @@ import org.slf4j.LoggerFactory;
  * Listens on changes in netconf notification stream availability and writes
  * changes to the data store.
  */
-final class NotificationToMdsalWriter implements AutoCloseable, NetconfNotificationCollector.NetconfNotificationStreamListener, BindingAwareProvider {
+public final class NotificationToMdsalWriter implements AutoCloseable, NetconfNotificationCollector.NetconfNotificationStreamListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(NotificationToMdsalWriter.class);
 
     private final NetconfNotificationCollector netconfNotificationCollector;
+    private final DataBroker dataBroker;
     private NotificationRegistration notificationRegistration;
-    private DataBroker dataBroker;
 
-    public NotificationToMdsalWriter(NetconfNotificationCollector netconfNotificationCollector) {
+    public NotificationToMdsalWriter(final NetconfNotificationCollector netconfNotificationCollector,
+                                     final DataBroker dataBroker) {
         this.netconfNotificationCollector = netconfNotificationCollector;
+        this.dataBroker = dataBroker;
     }
 
     @Override
@@ -65,9 +65,10 @@ final class NotificationToMdsalWriter implements AutoCloseable, NetconfNotificat
         notificationRegistration.close();
     }
 
-    @Override
-    public void onSessionInitiated(BindingAwareBroker.ProviderContext session) {
-        dataBroker = session.getSALService(DataBroker.class);
+    /**
+     * Invoke by blueprint
+     */
+    public void start() {
         notificationRegistration = netconfNotificationCollector.registerStreamListener(this);
     }
 
index 54f67d39789233959e2b481723788bd2dc9699d3..f8d1b0edb6e7bb82f33f806daa419c1315fbe5f2 100644 (file)
@@ -10,9 +10,11 @@ package org.opendaylight.controller.config.yang.netconf.mdsal.notification;
 import com.google.common.base.Preconditions;
 import java.util.Collection;
 import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
+import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdOrZeroType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Sessions;
@@ -21,6 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.not
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionEndBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStartBuilder;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
@@ -31,11 +34,16 @@ public class SessionNotificationProducer extends OperationalDatastoreListener<Se
 
     private static final InstanceIdentifier<Session> SESSION_INSTANCE_IDENTIFIER =
             InstanceIdentifier.create(NetconfState.class).child(Sessions.class).child(Session.class);
+
     private final BaseNotificationPublisherRegistration baseNotificationPublisherRegistration;
+    private final ListenerRegistration sessionListenerRegistration;
 
-    public SessionNotificationProducer(BaseNotificationPublisherRegistration baseNotificationPublisherRegistration) {
+    public SessionNotificationProducer(final NetconfNotificationCollector netconfNotificationCollector,
+                                       final DataBroker dataBroker) {
         super(SESSION_INSTANCE_IDENTIFIER);
-        this.baseNotificationPublisherRegistration = baseNotificationPublisherRegistration;
+
+        this.baseNotificationPublisherRegistration = netconfNotificationCollector.registerBaseNotificationPublisher();
+        this.sessionListenerRegistration = registerOnChanges(dataBroker);
     }
 
     @Override
@@ -82,4 +90,16 @@ public class SessionNotificationProducer extends OperationalDatastoreListener<Se
         baseNotificationPublisherRegistration.onSessionEnded(sessionEnd);
     }
 
+
+    /**
+     * Invoke by blueprint
+     */
+    public void close() {
+        if (baseNotificationPublisherRegistration != null) {
+            baseNotificationPublisherRegistration.close();
+        }
+        if (sessionListenerRegistration != null) {
+            sessionListenerRegistration.close();
+        }
+    }
 }
index 7c82d640d73f51fe66a7db4014c8202daacbe9f7..41ae98e1a2822505f79cc314a11964784bcfa53d 100644 (file)
@@ -11,24 +11,24 @@ package org.opendaylight.netconf.mdsal.notification;
 import java.util.Collections;
 import java.util.Set;
 import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
+import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener;
 import org.opendaylight.netconf.notifications.NetconfNotificationRegistry;
 
 public class NetconfNotificationOperationServiceFactory implements NetconfOperationServiceFactory, AutoCloseable {
 
     private final NetconfNotificationRegistry netconfNotificationRegistry;
+    private final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener;
 
-    private static final AutoCloseable AUTO_CLOSEABLE = new AutoCloseable() {
-        @Override
-        public void close() throws Exception {
-            // NOOP
-        }
-    };
-
-    public NetconfNotificationOperationServiceFactory(NetconfNotificationRegistry netconfNotificationRegistry) {
+    public NetconfNotificationOperationServiceFactory(final NetconfNotificationRegistry netconfNotificationRegistry,
+                                                      final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener) {
         this.netconfNotificationRegistry = netconfNotificationRegistry;
+        this.netconfOperationServiceFactoryListener = netconfOperationServiceFactoryListener;
+
+        this.netconfOperationServiceFactoryListener.onAddNetconfOperationServiceFactory(this);
     }
 
     @Override
@@ -46,10 +46,11 @@ public class NetconfNotificationOperationServiceFactory implements NetconfOperat
 
     @Override
     public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
-        return AUTO_CLOSEABLE;
+        return NoopAutoCloseable.INSTANCE;
     }
 
     @Override
     public void close() {
+        this.netconfOperationServiceFactoryListener.onRemoveNetconfOperationServiceFactory(this);
     }
 }
diff --git a/netconf/mdsal-netconf-notification/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-notification.xml b/netconf/mdsal-netconf-notification/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-notification.xml
new file mode 100755 (executable)
index 0000000..5550de8
--- /dev/null
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies Inc. 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           odl:restart-dependents-on-updates="true">
+
+    <reference id="dataBroker"
+               interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+               odl:type="default"/>
+    <reference id="netconfOperationServiceFactoryListener"
+               interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener"
+               odl:type="mapper-aggregator-registry"/>
+
+    <!--This is the MD-SAL netconf server notification blueprint xml file-->
+
+    <bean id="netconfNotificationManager"
+          class="org.opendaylight.netconf.notifications.impl.NetconfNotificationManager"
+          destroy-method="close">
+    </bean>
+    <service ref="netconfNotificationManager"
+             interface="org.opendaylight.netconf.notifications.NetconfNotificationRegistry"
+             odl:type="netconf-notification-manager">
+    </service>
+    <service ref="netconfNotificationManager"
+             interface="org.opendaylight.netconf.notifications.NetconfNotificationCollector"
+             odl:type="netconf-notification-manager">
+    </service>
+
+    <bean id="notificationToMdsalWriter"
+          class="org.opendaylight.controller.config.yang.netconf.mdsal.notification.NotificationToMdsalWriter"
+          init-method="start"
+          destroy-method="close">
+        <argument ref="netconfNotificationManager"/>
+        <argument ref="dataBroker"/>
+    </bean>
+
+    <bean id="capabilityChangeNotificationProducer"
+          class="org.opendaylight.controller.config.yang.netconf.mdsal.notification.CapabilityChangeNotificationProducer"
+          destroy-method="close">
+        <argument ref="netconfNotificationManager"/>
+        <argument ref="dataBroker"/>
+    </bean>
+
+    <bean id="sessionNotificationProducer"
+          class="org.opendaylight.controller.config.yang.netconf.mdsal.notification.SessionNotificationProducer"
+          destroy-method="close">
+        <argument ref="netconfNotificationManager"/>
+        <argument ref="dataBroker"/>
+    </bean>
+
+    <bean id="netconfNotificationOperationServiceFactory"
+          class="org.opendaylight.netconf.mdsal.notification.NetconfNotificationOperationServiceFactory"
+          destroy-method="close">
+        <argument ref="netconfNotificationManager"/>
+        <argument ref="netconfOperationServiceFactoryListener"/>
+    </bean>
+    <service ref="netconfNotificationOperationServiceFactory"
+             interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory"
+             odl:type="mdsal-netconf-notification"/>
+</blueprint>
diff --git a/netconf/mdsal-netconf-notification/src/main/yang/netconf-mdsal-notification.yang b/netconf/mdsal-netconf-notification/src/main/yang/netconf-mdsal-notification.yang
deleted file mode 100644 (file)
index db4e8be..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-module netconf-mdsal-notification {
-     yang-version 1;
-     namespace "urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification";
-     prefix "nnotification";
-
-     import netconf-northbound-mapper { prefix nnm; revision-date 2015-01-14; }
-     import opendaylight-md-sal-dom { prefix md-sal-dom; revision-date 2013-10-28; }
-     import opendaylight-md-sal-binding {prefix md-sal-binding; revision-date 2013-10-28;}
-     import netconf-northbound-notification {prefix nnn; revision-date 2015-08-06;}
-     import config { prefix config; revision-date 2013-04-05; }
-
-
-     organization "Cisco Systems, Inc.";
-
-     description
-         "This module contains the base YANG definitions for
-         an SAL notification mapper implementation";
-
-     revision "2015-08-03" {
-         description
-         "Initial revision.";
-     }
-
-     identity netconf-mdsal-notification-mapper {
-         base config:module-type;
-         config:provided-service nnm:netconf-northbound-mapper;
-     }
-
-     augment "/config:modules/config:module/config:configuration" {
-         case netconf-mdsal-notification-mapper {
-             when "/config:modules/config:module/config:type = 'netconf-mdsal-notification-mapper'";
-
-             container aggregator {
-                 uses config:service-ref {
-                     refine type {
-                         mandatory true;
-                         config:required-identity nnm:netconf-mapper-registry;
-                         }
-                 }
-             }
-
-             container binding-aware-broker {
-                 uses config:service-ref {
-                     refine type {
-                         mandatory true;
-                         config:required-identity md-sal-binding:binding-broker-osgi-registry;
-                     }
-                 }
-             }
-
-             container data-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-async-data-broker;
-                    }
-                }
-             }
-
-             container notification-collector {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity nnn:netconf-notification-collector;
-                    }
-                }
-             }
-
-            container notification-registry {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity nnn:netconf-notification-registry;
-                    }
-                }
-            }
-        }
-    }
-}
\ No newline at end of file
index e2156413bcd178af85de108ff27ff84682940d60..2f9ae073c1818403f890d72d7762b7f863f756af 100644 (file)
@@ -23,9 +23,13 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
+import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities;
@@ -34,20 +38,35 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.not
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.ChangedByBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.changed.by.server.or.user.ServerBuilder;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class CapabilityChangeNotificationProducerTest {
 
+    private CapabilityChangeNotificationProducer capabilityChangeNotificationProducer;
+
     @Mock
     private BaseNotificationPublisherRegistration baseNotificationPublisherRegistration;
-    private CapabilityChangeNotificationProducer capabilityChangeNotificationProducer;
+    @Mock
+    private ListenerRegistration listenerRegistration;
+
+    @Mock
+    private NetconfNotificationCollector netconfNotificationCollector;
+    @Mock
+    private DataBroker dataBroker;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
+
+        doReturn(listenerRegistration).when(dataBroker).registerDataTreeChangeListener(any(DataTreeIdentifier.class), any(DataTreeChangeListener.class));
+
         doNothing().when(baseNotificationPublisherRegistration).onCapabilityChanged(any(NetconfCapabilityChange.class));
-        capabilityChangeNotificationProducer = new CapabilityChangeNotificationProducer(baseNotificationPublisherRegistration);
+
+        doReturn(baseNotificationPublisherRegistration).when(netconfNotificationCollector).registerBaseNotificationPublisher();
+
+        capabilityChangeNotificationProducer = new CapabilityChangeNotificationProducer(netconfNotificationCollector, dataBroker);
     }
 
     @Test
index 6084d92cca0a62952a1b2b9bbc19e06668f015d4..316d56c0d1f18b22010928ba501caadaaf5b4581 100644 (file)
@@ -61,8 +61,8 @@ public class NotificationToMdsalWriterTest {
         doReturn(Futures.immediateCheckedFuture(null)).when(tx).submit();
         doReturn(tx).when(dataBroker).newWriteOnlyTransaction();
 
-        writer = new NotificationToMdsalWriter(notificationCollector);
-        writer.onSessionInitiated(session);
+        writer = new NotificationToMdsalWriter(notificationCollector, dataBroker);
+        writer.start();
     }
 
     @Test
index 8e29ea79717c26da638bf19b9b82305d68f5fba2..cedebb4eeaca0fd97f22d416449b46bf62d80853 100644 (file)
@@ -21,28 +21,49 @@ import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
+import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.SessionBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionEnd;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.ZeroBasedCounter32;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 
 public class SessionNotificationProducerTest {
 
     private SessionNotificationProducer publisher;
+
     @Mock
     private BaseNotificationPublisherRegistration registration;
+    @Mock
+    private ListenerRegistration listenerRegistration;
+
+    @Mock
+    private NetconfNotificationCollector netconfNotificationCollector;
+    @Mock
+    private DataBroker dataBroker;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        publisher = new SessionNotificationProducer(registration);
+
+        doReturn(listenerRegistration).when(dataBroker).registerDataTreeChangeListener(any(DataTreeIdentifier.class), any(DataTreeChangeListener.class));
+
+        doNothing().when(registration).onCapabilityChanged(any(NetconfCapabilityChange.class));
         doNothing().when(registration).onSessionStarted(any());
         doNothing().when(registration).onSessionEnded(any());
+
+        doReturn(registration).when(netconfNotificationCollector).registerBaseNotificationPublisher();
+
+        publisher = new SessionNotificationProducer(netconfNotificationCollector, dataBroker);
     }
 
     @Test
diff --git a/netconf/mdsal-netconf-ssh/pom.xml b/netconf/mdsal-netconf-ssh/pom.xml
new file mode 100644 (file)
index 0000000..82c3292
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies 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
+-->
+<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.controller</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.6.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <groupId>org.opendaylight.netconf</groupId>
+  <artifactId>mdsal-netconf-ssh</artifactId>
+  <version>1.2.0-SNAPSHOT</version>
+  <name>${project.artifactId}</name>
+  <packaging>bundle</packaging>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.opendaylight.netconf</groupId>
+        <artifactId>netconf-subsystem</artifactId>
+        <version>${project.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>netconf-ssh</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+            <Embed-Dependency>netconf-ssh</Embed-Dependency>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/netconf/mdsal-netconf-ssh/src/main/resources/org/opendaylight/blueprint/netconf-ssh.xml b/netconf/mdsal-netconf-ssh/src/main/resources/org/opendaylight/blueprint/netconf-ssh.xml
new file mode 100755 (executable)
index 0000000..9d5d3ed
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies Inc. 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.3.0"
+           odl:restart-dependents-on-updates="true">
+
+    <reference id="netconfServerDispatcher" interface="org.opendaylight.netconf.api.NetconfServerDispatcher"/>
+    <reference id="globalWorkerGroup" interface="io.netty.channel.EventLoopGroup" odl:type="global-worker-group"/>
+    <reference id="executor" interface="io.netty.util.concurrent.EventExecutor" odl:type="global-event-executor"/>
+    <reference id="authProvider" interface="org.opendaylight.netconf.auth.AuthProvider" odl:type="netconf-auth-provider"/>
+
+    <!--    NETCONF server for MD-SAL (listening by default on port 2830)-->
+
+    <cm:property-placeholder persistent-id="org.opendaylight.netconf.ssh" update-strategy="none">
+        <cm:default-properties>
+            <cm:property name="bindingAddress" value="0.0.0.0"/>
+            <cm:property name="portNumber" value="2830"/>
+        </cm:default-properties>
+    </cm:property-placeholder>
+
+    <bean id="netconfMdsalServer"
+          class="org.opendaylight.netconf.ssh.NetconfNorthboundSshServer"
+          destroy-method="close">
+        <argument ref="netconfServerDispatcher"/>
+        <argument ref="globalWorkerGroup"/>
+        <argument ref="executor"/>
+        <argument value="${bindingAddress}"/>
+        <argument value="${portNumber}"/>
+        <argument ref="authProvider"/>
+    </bean>
+
+</blueprint>
diff --git a/netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/yang/library/NetconfMdsalYanglibModule.java b/netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/yang/library/NetconfMdsalYanglibModule.java
deleted file mode 100644 (file)
index 77492cb..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.controller.config.yang.netconf.mdsal.yang.library;
-
-import org.opendaylight.netconf.mdsal.yang.library.SchemaServiceToMdsalWriter;
-
-public class NetconfMdsalYanglibModule extends org.opendaylight.controller.config.yang.netconf.mdsal.yang.library.AbstractNetconfMdsalYanglibModule {
-    public NetconfMdsalYanglibModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public NetconfMdsalYanglibModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.netconf.mdsal.yang.library.NetconfMdsalYanglibModule oldModule, java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        // TODO Implement also yang-library-change notfication
-        final SchemaServiceToMdsalWriter schemaServiceToMdsalWriter =
-                new SchemaServiceToMdsalWriter(getRootSchemaServiceDependency());
-
-        getBindingAwareBrokerDependency().registerProvider(schemaServiceToMdsalWriter);
-
-        return schemaServiceToMdsalWriter;
-    }
-
-}
diff --git a/netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/yang/library/NetconfMdsalYanglibModuleFactory.java b/netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/yang/library/NetconfMdsalYanglibModuleFactory.java
deleted file mode 100644 (file)
index 739485b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: netconf-mdsal-yang-library yang module local name: netconf-mdsal-yanglib
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Sun Jun 19 15:28:13 CEST 2016
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.netconf.mdsal.yang.library;
-public class NetconfMdsalYanglibModuleFactory extends org.opendaylight.controller.config.yang.netconf.mdsal.yang.library.AbstractNetconfMdsalYanglibModuleFactory {
-
-}
index 44dbdc7cf2d06bc438ac4bb17318c66ec829b1ca..2360369e6af354a1a934dfde79f3867a927c0957 100644 (file)
@@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory;
  * Listens for updates on global schema context, transforms context to ietf-yang-library:modules-state and
  * writes this state to operational data store
  */
-public class SchemaServiceToMdsalWriter implements SchemaContextListener, BindingAwareProvider, AutoCloseable {
+public class SchemaServiceToMdsalWriter implements SchemaContextListener, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(SchemaServiceToMdsalWriter.class);
 
@@ -53,10 +53,12 @@ public class SchemaServiceToMdsalWriter implements SchemaContextListener, Bindin
 
     private final SchemaService schemaService;
     private final AtomicInteger moduleSetId;
-    private DataBroker dataBroker;
+    private final DataBroker dataBroker;
 
-    public SchemaServiceToMdsalWriter(final SchemaService schemaService) {
+    public SchemaServiceToMdsalWriter(final SchemaService schemaService,
+                                      final DataBroker dataBroker) {
         this.schemaService = schemaService;
+        this.dataBroker = dataBroker;
         this.moduleSetId = new AtomicInteger(0);
     }
 
@@ -65,9 +67,10 @@ public class SchemaServiceToMdsalWriter implements SchemaContextListener, Bindin
         // TODO Delete modules-state from operational data store
     }
 
-    @Override
-    public void onSessionInitiated(final BindingAwareBroker.ProviderContext providerContext) {
-        dataBroker = providerContext.getSALService(DataBroker.class);
+    /**
+     * Invoke by blueprint
+     */
+    public void start() {
         schemaService.registerSchemaContextListener(this);
     }
 
diff --git a/netconf/mdsal-netconf-yang-library/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-yang-library.xml b/netconf/mdsal-netconf-yang-library/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-yang-library.xml
new file mode 100755 (executable)
index 0000000..a4a2bf1
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies Inc. 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           odl:use-default-for-reference-types="true">
+
+    <reference id="dataBroker"
+               interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+               odl:type="default"/>
+    <reference id="schemaService"
+               interface="org.opendaylight.controller.sal.core.api.model.SchemaService" />
+
+    <bean id="schemaServiceToMdsalWriter"
+          class="org.opendaylight.netconf.mdsal.yang.library.SchemaServiceToMdsalWriter"
+          init-method="start"
+          destroy-method="close">
+        <argument ref="schemaService" />
+        <argument ref="dataBroker" />
+    </bean>
+
+</blueprint>
diff --git a/netconf/mdsal-netconf-yang-library/src/main/yang/netconf-mdsal-yang-library.yang b/netconf/mdsal-netconf-yang-library/src/main/yang/netconf-mdsal-yang-library.yang
deleted file mode 100644 (file)
index 407a76d..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-module netconf-mdsal-yang-library {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:yang:library";
-    prefix "nmyanglib";
-
-    import opendaylight-md-sal-dom { prefix md-sal-dom; revision-date 2013-10-28; }
-    import opendaylight-md-sal-binding {prefix md-sal-binding; revision-date 2013-10-28;}
-    import config { prefix config; revision-date 2013-04-05; }
-
-    organization "Cisco Systems, Inc.";
-
-    description
-        "This module contains the base YANG definitions for
-         MDSAL netconf yang module library implementation";
-
-    revision "2016-06-17" {
-        description
-            "Initial revision.";
-    }
-
-    identity netconf-mdsal-yanglib {
-        base config:module-type;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case netconf-mdsal-yanglib {
-            when "/config:modules/config:module/config:type = 'netconf-mdsal-yanglib'";
-
-            container root-schema-service {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity md-sal-dom:schema-service;
-                    }
-                }
-            }
-
-            container binding-aware-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
-                    }
-                }
-            }
-        }
-    }
-}
\ No newline at end of file
index 0e6e60907add2ef8d5c35595ed0fcc0c61afa73f..d531eb63caa4fa1e16bb7038047bde6099b14125 100644 (file)
@@ -81,12 +81,12 @@ public class SchemaServiceToMdsalWriterTest {
                 return null;
             }
         });
-        schemaServiceToMdsalWriter = new SchemaServiceToMdsalWriter(schemaService);
+        schemaServiceToMdsalWriter = new SchemaServiceToMdsalWriter(schemaService, dataBroker);
     }
 
     @Test
     public void testOnGlobalContextUpdated() {
-        schemaServiceToMdsalWriter.onSessionInitiated(context);
+        schemaServiceToMdsalWriter.start();
 
         schemaServiceToMdsalWriter.onGlobalContextUpdated(getSchema());
         verify(writeTransaction).put(eq(LogicalDatastoreType.OPERATIONAL), eq(MODULES_STATE_INSTANCE_IDENTIFIER), eq(createTestModuleState()));
index b8946c8f2c0443fcdcb387f0a40fb7534df726a3..1dfd073103af5d0b5ceae3e50e3d994aa9ad28d7 100644 (file)
@@ -93,43 +93,4 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
             <artifactId>hamcrest-core</artifactId>
         </dependency>
     </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>add-source</id>
-                        <phase>generate-sources</phase>
-                        <goals>
-                            <goal>add-source</goal>
-                        </goals>
-                        <configuration>
-                            <sources>
-                                <source>${project.build.directory}/generated-sources/config</source>
-                            </sources>
-                        </configuration>
-                    </execution>
-                    <execution>
-                        <id>attach-artifacts</id>
-                        <goals>
-                            <goal>attach-artifact</goal>
-                        </goals>
-                        <phase>package</phase>
-                        <configuration>
-                            <artifacts>
-                                <artifact>
-                                    <file>${project.build.directory}/classes/initial/06-message-netconf.xml</file>
-                                    <type>xml</type>
-                                    <classifier>config</classifier>
-                                </artifact>
-                            </artifacts>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
 </project>
diff --git a/netconf/messagebus-netconf/src/main/java/org/opendaylight/controller/config/yang/messagebus/netconf/MessageBusNetconfModule.java b/netconf/messagebus-netconf/src/main/java/org/opendaylight/controller/config/yang/messagebus/netconf/MessageBusNetconfModule.java
deleted file mode 100644 (file)
index 19761d4..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.controller.config.yang.messagebus.netconf;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService;
-import org.opendaylight.controller.messagebus.app.util.Providers;
-import org.opendaylight.netconf.messagebus.eventsources.netconf.NetconfEventSourceManager;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.core.api.Broker;
-
-public class MessageBusNetconfModule extends org.opendaylight.controller.config.yang.messagebus.netconf.AbstractMessageBusNetconfModule {
-    public MessageBusNetconfModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public MessageBusNetconfModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.messagebus.netconf.MessageBusNetconfModule oldModule, java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {}
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        final BindingAwareBroker.ProviderContext bindingCtx = getBindingBrokerDependency().registerProvider(new Providers.BindingAware());
-        final Broker.ProviderSession domCtx = getDomBrokerDependency().registerProvider(new Providers.BindingIndependent());
-
-        final MountPointService mountPointService = bindingCtx.getSALService(MountPointService.class);
-        final DataBroker dataBroker = bindingCtx.getSALService(DataBroker.class);
-
-        final DOMNotificationPublishService domPublish = domCtx.getService(DOMNotificationPublishService.class);
-        final DOMMountPointService domMount = domCtx.getService(DOMMountPointService.class);
-
-        return NetconfEventSourceManager.create(dataBroker, domPublish, domMount,
-            mountPointService, getEventSourceRegistryDependency(), getNamespaceToStream());
-    }
-
-}
diff --git a/netconf/messagebus-netconf/src/main/java/org/opendaylight/controller/config/yang/messagebus/netconf/MessageBusNetconfModuleFactory.java b/netconf/messagebus-netconf/src/main/java/org/opendaylight/controller/config/yang/messagebus/netconf/MessageBusNetconfModuleFactory.java
deleted file mode 100644 (file)
index fe41f43..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: messagebus-netconf yang module local name: messagebus-netconf
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Jul 29 14:15:30 CEST 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.messagebus.netconf;
-public class MessageBusNetconfModuleFactory extends org.opendaylight.controller.config.yang.messagebus.netconf.AbstractMessageBusNetconfModuleFactory {
-
-}
index f7b60e9b11754c033521b38a35c8b976d973e0fe..cdbd8d4e4386dba9cb104a74744073be57ccac46 100644 (file)
@@ -9,14 +9,10 @@
 package org.opendaylight.netconf.messagebus.eventsources.netconf;
 
 import com.google.common.base.Preconditions;
-import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import org.opendaylight.controller.config.yang.messagebus.netconf.NamespaceToStream;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -48,42 +44,32 @@ public final class NetconfEventSourceManager implements DataChangeListener, Auto
     private static final InstanceIdentifier<Node> NETCONF_DEVICE_PATH = InstanceIdentifier.create(NetworkTopology.class)
         .child(Topology.class, NETCONF_TOPOLOGY_KEY).child(Node.class);
 
-    private final Map<String, String> streamMap;
+    private Map<String, String> streamMap;
     private final ConcurrentHashMap<InstanceIdentifier<?>, NetconfEventSourceRegistration> registrationMap = new ConcurrentHashMap<>();
     private final DOMNotificationPublishService publishService;
     private final DOMMountPointService domMounts;
     private ListenerRegistration<DataChangeListener> listenerRegistration;
     private final EventSourceRegistry eventSourceRegistry;
+    private final DataBroker dataBroker;
 
-    public static NetconfEventSourceManager create(final DataBroker dataBroker,
-        final DOMNotificationPublishService domPublish, final DOMMountPointService domMount,
-        final MountPointService bindingMount, final EventSourceRegistry eventSourceRegistry,
-        final List<NamespaceToStream> namespaceMapping) {
-
-        final NetconfEventSourceManager eventSourceManager = new NetconfEventSourceManager(domPublish, domMount,
-            bindingMount, eventSourceRegistry, namespaceMapping);
-
-        eventSourceManager.initialize(dataBroker);
-
-        return eventSourceManager;
-
-    }
-
-    private NetconfEventSourceManager(final DOMNotificationPublishService domPublish,
-        final DOMMountPointService domMount, final MountPointService bindingMount,
-        final EventSourceRegistry eventSourceRegistry, final List<NamespaceToStream> namespaceMapping) {
-
+    public NetconfEventSourceManager(final DataBroker dataBroker,
+                                     final DOMNotificationPublishService domPublish,
+                                     final DOMMountPointService domMount,
+                                     final EventSourceRegistry eventSourceRegistry) {
+        Preconditions.checkNotNull(dataBroker);
         Preconditions.checkNotNull(domPublish);
         Preconditions.checkNotNull(domMount);
         Preconditions.checkNotNull(eventSourceRegistry);
-        Preconditions.checkNotNull(namespaceMapping);
-        this.streamMap = namespaceToStreamMapping(namespaceMapping);
+        this.dataBroker = dataBroker;
         this.domMounts = domMount;
         this.publishService = domPublish;
         this.eventSourceRegistry = eventSourceRegistry;
     }
 
-    private void initialize(final DataBroker dataBroker) {
+    /**
+     * Invoke by blueprint
+     */
+    public void initialize() {
         Preconditions.checkNotNull(dataBroker);
         listenerRegistration = dataBroker
             .registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, NETCONF_DEVICE_PATH, this,
@@ -91,16 +77,6 @@ public final class NetconfEventSourceManager implements DataChangeListener, Auto
         LOG.info("NetconfEventSourceManager initialized.");
     }
 
-    private Map<String, String> namespaceToStreamMapping(final List<NamespaceToStream> namespaceMapping) {
-        final Map<String, String> streamMap = new HashMap<>(namespaceMapping.size());
-
-        for (final NamespaceToStream nToS : namespaceMapping) {
-            streamMap.put(nToS.getUrnPrefix(), nToS.getStreamName());
-        }
-
-        return streamMap;
-    }
-
     @Override public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event) {
 
         LOG.debug("[DataChangeEvent<InstanceIdentifier<?>, DataObject>: {}]", event);
@@ -189,6 +165,14 @@ public final class NetconfEventSourceManager implements DataChangeListener, Auto
         return eventSourceRegistry;
     }
 
+    /**
+     * Invoke by blueprint
+     * @param streamMap
+     */
+    public void setStreamMap(Map<String, String> streamMap) {
+        this.streamMap = streamMap;
+    }
+
     private boolean isNetconfNode(final Node node) {
         return node.getAugmentation(NetconfNode.class) != null;
     }
index 8fcb44cfc120ff6f29fcfc4c1c5a3c6f6a809feb..c667976989922feccb06fc57c9c28ff5ac8b81f9 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.netconf.messagebus.eventsources.netconf;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.List;
-import org.opendaylight.controller.md.sal.binding.api.MountPoint;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
 import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
diff --git a/netconf/messagebus-netconf/src/main/resources/initial/06-message-netconf.xml b/netconf/messagebus-netconf/src/main/resources/initial/06-message-netconf.xml
deleted file mode 100644 (file)
index 421085a..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2015 Cisco Systems, Inc. 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
--->
-<snapshot>
-    <configuration>
-      <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-          <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-              <module>
-                  <name>messagebus-netconf</name>
-                  <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:messagebus:netconf">binding-impl:messagebus-netconf</type>
-                  <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:messagebus:netconf">
-                      <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-                      <name>dom-broker</name>
-                  </dom-broker>
-                  <binding-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:messagebus:netconf">
-                      <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
-                      <name>binding-osgi-broker</name>
-                  </binding-broker>
-                  <event-source-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:messagebus:netconf">
-                      <type xmlns:mb-esr="urn:opendaylight:params:xml:ns:yang:controller:messagebus:spi:eventsourceregistry">mb-esr:event-source-registry</type>
-                      <name>messagebus-app-impl</name>
-                  </event-source-registry>
-                  <namespace-to-stream xmlns="urn:opendaylight:params:xml:ns:yang:controller:messagebus:netconf">
-                      <urn-prefix>urn:ietf:params:xml:ns:yang:smiv2</urn-prefix>
-                      <stream-name>SNMP</stream-name>
-                  </namespace-to-stream>
-                  <namespace-to-stream xmlns="urn:opendaylight:params:xml:ns:yang:controller:messagebus:netconf">
-                      <urn-prefix>urn:ietf:params:xml:ns:yang:ietf-syslog-notification</urn-prefix>
-                      <stream-name>SYSLOG</stream-name>
-                  </namespace-to-stream>
-              </module>
-          </modules>
-      </data>
-  </configuration>
-  <required-capabilities>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:messagebus:netconf?module=messagebus-netconf&amp;revision=2015-07-28</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:messagebus:spi:eventsourceregistry?module=messagebus-event-source-registry&amp;revision=2015-04-02</capability>
-  </required-capabilities>
-</snapshot>
diff --git a/netconf/messagebus-netconf/src/main/resources/org/opendaylight/blueprint/messagebus-netconf.xml b/netconf/messagebus-netconf/src/main/resources/org/opendaylight/blueprint/messagebus-netconf.xml
new file mode 100644 (file)
index 0000000..028c20e
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies Inc. 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           odl:use-default-for-reference-types="true">
+
+    <reference id="dataBroker"
+               interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+               odl:type="default"/>
+    <reference id="domMountPointService"
+               interface="org.opendaylight.controller.md.sal.dom.api.DOMMountPointService" />
+    <reference id="domNotificationPublishService"
+               interface="org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService" />
+    <reference id="eventSourceRegistry"
+               interface="org.opendaylight.controller.messagebus.spi.EventSourceRegistry" />
+
+    <bean id="netconfEventSourceManager"
+          class="org.opendaylight.netconf.messagebus.eventsources.netconf.NetconfEventSourceManager"
+          init-method="initialize"
+          destroy-method="close">
+        <argument ref="dataBroker" />
+        <argument ref="domNotificationPublishService" />
+        <argument ref="domMountPointService" />
+        <argument ref="eventSourceRegistry" />
+        <property name="streamMap">
+            <map>
+                <entry key="urn:ietf:params:xml:ns:yang:smiv2" value="SNMP"/>
+                <entry key="urn:ietf:params:xml:ns:yang:ietf-syslog-notification" value="SYSLOG"/>
+            </map>
+        </property>
+    </bean>
+
+</blueprint>
\ No newline at end of file
diff --git a/netconf/messagebus-netconf/src/main/yang/messagebus-netconf.yang b/netconf/messagebus-netconf/src/main/yang/messagebus-netconf.yang
deleted file mode 100644 (file)
index 780175b..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-module messagebus-netconf {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:controller:messagebus:netconf";
-    prefix "msgb-netconf";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import opendaylight-md-sal-binding {prefix sal;}
-    import opendaylight-md-sal-dom {prefix dom;}
-    import messagebus-event-source-registry {prefix esr;}
-
-    description
-        "Message bus netconf event source";
-
-    revision "2015-07-28" {
-        description "Message bus netconf event source initial definition";
-    }
-
-    identity messagebus-netconf {
-        base config:module-type;
-        config:java-name-prefix MessageBusNetconf;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case messagebus-netconf {
-            when "/config:modules/config:module/config:type = 'messagebus-netconf'";
-
-            container event-source-registry {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity esr:event-source-registry;
-                    }
-                }
-            }
-
-            container dom-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity dom:dom-broker-osgi-registry;
-                    }
-                }
-            }
-
-            container binding-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity sal:binding-broker-osgi-registry;
-                    }
-                }
-            }
-
-            list namespace-to-stream {
-                key urn-prefix;
-
-                leaf urn-prefix {
-                    type string;
-                }
-
-                leaf stream-name {
-                    type string;
-                }
-            }
-
-        }
-    }
-}
\ No newline at end of file
index 39cdb10975d6faacff255971aa25fbd0a4a56edc..13b855107d8d9a7ef9c2e2f95668e1c485e86600 100644 (file)
@@ -18,14 +18,11 @@ import static org.mockito.Mockito.verify;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.controller.config.yang.messagebus.netconf.NamespaceToStream;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
@@ -62,6 +59,7 @@ public class NetconfEventSourceManagerTest {
     AsyncDataChangeEvent asyncDataChangeEventMock;
     RpcProviderRegistry rpcProviderRegistryMock;
     EventSourceRegistry eventSourceRegistry;
+
     @BeforeClass
     public static void initTestClass() throws IllegalAccessException, InstantiationException {
     }
@@ -74,7 +72,6 @@ public class NetconfEventSourceManagerTest {
         eventSourceTopologyMock = mock(EventSourceRegistry.class);
         rpcProviderRegistryMock = mock(RpcProviderRegistry.class);
         eventSourceRegistry = mock(EventSourceRegistry.class);
-        List<NamespaceToStream> namespaceToStreamList = new ArrayList<>();
 
         listenerRegistrationMock = mock(ListenerRegistration.class);
         doReturn(listenerRegistrationMock).when(dataBrokerMock).registerDataChangeListener(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class), any(NetconfEventSourceManager.class), eq(
@@ -95,10 +92,9 @@ public class NetconfEventSourceManagerTest {
         YangInstanceIdentifier pathStream = YangInstanceIdentifier.builder().node(Netconf.QNAME).node(Streams.QNAME).build();
         doReturn(checkFeature).when(rtx).read(LogicalDatastoreType.OPERATIONAL, pathStream);
 
-        netconfEventSourceManager =
-                NetconfEventSourceManager
-                    .create(dataBrokerMock, domNotificationPublishServiceMock, domMountPointServiceMock,
-                        mountPointServiceMock, eventSourceRegistry, namespaceToStreamList);
+        netconfEventSourceManager = new NetconfEventSourceManager(dataBrokerMock,
+                domNotificationPublishServiceMock, domMountPointServiceMock, eventSourceRegistry);
+        netconfEventSourceManager.setStreamMap(new HashMap<>());
     }
 
     @Test
index 658b2cab2774885709ea0565a1335561b9981a05..121a4d6fc8d916cd0fdc292f891197cd2c9e43c3 100644 (file)
@@ -17,11 +17,15 @@ module netconf-northbound {
     identity netconf-server-dispatcher {
         base "config:service-type";
         config:java-class "org.opendaylight.netconf.api.NetconfServerDispatcher";
+        config:disable-osgi-service-registration;
+        status deprecated;
     }
 
     identity netconf-server-monitoring {
         base "config:service-type";
         config:java-class "org.opendaylight.netconf.api.monitoring.NetconfMonitoringService";
+        config:disable-osgi-service-registration;
+        status deprecated;
     }
 
 }
\ No newline at end of file
index 7102db1cb25db4a9b25fc1c357d57b50a4153631..0057b35c53806961809097dd0cdf277b5dc61a34 100644 (file)
                 <artifactId>aaa-authn-odl-plugin</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}</groupId>
-                <artifactId>netconf-config-dispatcher</artifactId>
-                <version>${project.version}</version>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>config-netconf-connector</artifactId>
                 <type>xml</type>
                 <classifier>config</classifier>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}</groupId>
-                <artifactId>netconf-mdsal-config</artifactId>
-                <version>${project.version}</version>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>mdsal-netconf-connector</artifactId>
                 <artifactId>mdsal-netconf-yang-library</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.opendaylight.netconf</groupId>
+                <artifactId>mdsal-netconf-impl</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>netconf-netty-util</artifactId>
                 <classifier>config</classifier>
                 <type>cfg</type>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}</groupId>
-                <artifactId>netconf-mdsal-config</artifactId>
-                <version>${project.version}</version>
-                <classifier>config</classifier>
-                <type>xml</type>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>sal-netconf-connector</artifactId>
                 <artifactId>messagebus-netconf</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}</groupId>
-                <artifactId>messagebus-netconf</artifactId>
-                <version>${project.version}</version>
-                <classifier>config</classifier>
-                <type>xml</type>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>features-netconf-connector</artifactId>
             </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
-                <artifactId>netconf-topology</artifactId>
+                <artifactId>mdsal-netconf-ssh</artifactId>
                 <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
-                <artifactId>netconf-topology-config</artifactId>
+                <artifactId>netconf-topology</artifactId>
                 <version>${project.version}</version>
-                <classifier>config</classifier>
-                <type>xml</type>
             </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
-                <artifactId>yanglib-config</artifactId>
+                <artifactId>netconf-topology-config</artifactId>
                 <version>${project.version}</version>
                 <classifier>config</classifier>
                 <type>xml</type>
index 8f975ced2be7c491a09d42bbe45320ab1abf7a56..97213b5d466ebb229c6c5a8fffd7e9a45fb7bcf1 100644 (file)
@@ -17,6 +17,8 @@ module netconf-auth {
     identity netconf-auth-provider {
         base "config:service-type";
         config:java-class "org.opendaylight.netconf.auth.AuthProvider";
+        config:disable-osgi-service-registration;
+        status deprecated;
     }
 
 }
\ No newline at end of file
index 0683845b4077b19d459321a4b009734cc0091117..dffdfac52ef9c80f35d539c6310ed20cc347e618 100644 (file)
@@ -10,9 +10,9 @@
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
-    <groupId>org.opendaylight.odlparent</groupId>
-    <artifactId>bundle-parent</artifactId>
-    <version>1.8.0-SNAPSHOT</version>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.6.0-SNAPSHOT</version>
     <relativePath/>
   </parent>
 
diff --git a/netconf/netconf-client/src/main/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModule.java b/netconf/netconf-client/src/main/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModule.java
new file mode 100644 (file)
index 0000000..6bde635
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. 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
+ */
+package org.opendaylight.controller.config.yang.config.netconf.client.dispatcher;
+
+import com.google.common.reflect.AbstractInvocationHandler;
+import com.google.common.reflect.Reflection;
+import java.lang.reflect.Method;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.netconf.client.NetconfClientDispatcher;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public final class NetconfClientDispatcherModule extends org.opendaylight.controller.config.yang.config.netconf.client.dispatcher.AbstractNetconfClientDispatcherModule {
+
+    private BundleContext bundleContext;
+
+    public NetconfClientDispatcherModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public NetconfClientDispatcherModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            NetconfClientDispatcherModule oldModule, java.lang.AutoCloseable oldInstance) {
+
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    protected void customValidation(){
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        final WaitingServiceTracker<NetconfClientDispatcher> tracker =
+                WaitingServiceTracker.create(NetconfClientDispatcher.class, bundleContext, "(type=netconf-client-dispatcher)");
+        final NetconfClientDispatcher service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+        return Reflection.newProxy(AutoCloseableNetconfClientDispatcher.class, new AbstractInvocationHandler() {
+            @Override
+            protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
+                if (method.getName().equals("close")) {
+                    tracker.close();
+                    return null;
+                } else {
+                    return method.invoke(service, args);
+                }
+            }
+        });
+    }
+
+    void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    private static interface AutoCloseableNetconfClientDispatcher extends NetconfClientDispatcher, AutoCloseable {
+    }
+}
diff --git a/netconf/netconf-client/src/main/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModuleFactory.java b/netconf/netconf-client/src/main/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModuleFactory.java
new file mode 100644 (file)
index 0000000..f361ed2
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. 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
+ */
+package org.opendaylight.controller.config.yang.config.netconf.client.dispatcher;
+
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class NetconfClientDispatcherModuleFactory extends AbstractNetconfClientDispatcherModuleFactory {
+    @Override
+    public NetconfClientDispatcherModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+                                                           NetconfClientDispatcherModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+        NetconfClientDispatcherModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule,
+                oldInstance, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+
+    @Override
+    public NetconfClientDispatcherModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+                                                      BundleContext bundleContext) {
+        NetconfClientDispatcherModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+}
diff --git a/netconf/netconf-client/src/main/resources/org/opendaylight/blueprint/netconf-client.xml b/netconf/netconf-client/src/main/resources/org/opendaylight/blueprint/netconf-client.xml
new file mode 100755 (executable)
index 0000000..fb2b56b
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies Inc. 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           odl:use-default-for-reference-types="true">
+
+    <reference id="globalBossGroup" interface="io.netty.channel.EventLoopGroup" odl:type="global-boss-group"/>
+    <reference id="globalWorkerGroup" interface="io.netty.channel.EventLoopGroup" odl:type="global-worker-group"/>
+    <reference id="timer" interface="io.netty.util.Timer" odl:type="global-timer"/>
+
+    <bean id="netconfClientDispatcherImpl"
+          class="org.opendaylight.netconf.client.NetconfClientDispatcherImpl">
+        <argument ref="globalBossGroup"/>
+        <argument ref="globalWorkerGroup"/>
+        <argument ref="timer"/>
+    </bean>
+    <service ref="netconfClientDispatcherImpl"
+             interface="org.opendaylight.netconf.client.NetconfClientDispatcher"
+             odl:type="netconf-client-dispatcher">
+        <service-properties>
+        <entry key="config-module-namespace" value="urn:opendaylight:params:xml:ns:yang:controller:config:netconf"/>
+        <entry key="config-module-name" value="netconf-client-dispatcher"/>
+        <entry key="config-instance-name" value="global-netconf-dispatcher"/>
+        </service-properties>
+    </service>
+
+</blueprint>
diff --git a/netconf/netconf-client/src/main/yang/odl-netconf-cfg.yang b/netconf/netconf-client/src/main/yang/odl-netconf-cfg.yang
new file mode 100644 (file)
index 0000000..21e6242
--- /dev/null
@@ -0,0 +1,35 @@
+// vi: set smarttab et sw=4 tabstop=4:
+module odl-netconf-cfg {
+
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:config:netconf";
+    prefix "cfg-net";
+
+    import config { prefix config; revision-date 2013-04-05; }
+
+    description
+        "This module contains the base YANG definitions for
+        netconf related services.
+
+        Copyright (c)2013 Cisco Systems, Inc. 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";
+
+    revision "2014-04-08" {
+        description
+            "Initial revision.";
+    }
+
+    // We keep this as sal-netconf-connector and netconf-topology need it.
+    // Once they will be moved to blueprint, it will be safe to delete all
+    // together the netconf-config-dispatcher bundle.
+    identity netconf-client-dispatcher {
+        base "config:service-type";
+        config:java-class "org.opendaylight.netconf.client.NetconfClientDispatcher";
+        config:disable-osgi-service-registration;
+        status deprecated;
+    }
+}
\ No newline at end of file
diff --git a/netconf/netconf-client/src/main/yang/odl-netconfig-client-cfg.yang b/netconf/netconf-client/src/main/yang/odl-netconfig-client-cfg.yang
new file mode 100644 (file)
index 0000000..64343a0
--- /dev/null
@@ -0,0 +1,40 @@
+// vi: set smarttab et sw=4 tabstop=4:
+module odl-netconfig-client-cfg {
+
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher";
+    prefix "cfg-net-client";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import odl-netconf-cfg { prefix cfg-net; revision-date 2014-04-08; }
+    import netty {prefix netty; }
+
+    description
+        "This module contains the base YANG definitions for
+        netconf-client-dispatcher implementation.
+
+        Copyright (c)2013 Cisco Systems, Inc. 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";
+
+    revision "2014-04-08" {
+        description
+            "Initial revision.";
+    }
+
+    identity netconf-client-dispatcher {
+            base config:module-type;
+            config:provided-service cfg-net:netconf-client-dispatcher;
+            config:java-name-prefix NetconfClientDispatcher;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case netconf-client-dispatcher {
+            when "/config:modules/config:module/config:type = 'netconf-client-dispatcher'";
+        }
+    }
+
+}
\ No newline at end of file
index 9cc3feb8494e30cb3f455119f320de279a87852c..7179c8de25aad4c4efd5afc2b3e15b2a9a7687ce 100644 (file)
@@ -24,7 +24,6 @@
         <capability>urn:ietf:params:xml:ns:yang:ietf-network-topology?module=ietf-network-topology&amp;revision=2015-06-08</capability>
         <capability>urn:ietf:params:xml:ns:yang:ietf-netconf-notifications?module=ietf-netconf-notifications&amp;revision=2012-02-06</capability>
         <capability>urn:TBD:params:xml:ns:yang:ospf-topology?module=ospf-topology&amp;revision=2013-10-21</capability>
-        <capability>config:aaa:authn:netconf:plugin?module=aaa-authn-netconf-plugin&amp;revision=2015-07-15</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:config:netconf:auth?module=netconf-auth&amp;revision=2015-07-15</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store?module=opendaylight-operational-dom-datastore&amp;revision=2014-06-17</capability>
         <capability>urn:ietf:params:xml:ns:yang:ospf-topology?module=ospf-topology&amp;revision=2013-07-12</capability>
index fabef7d7ab7a79e24a22c4bca44e9ec09c067e9e..f9e27324bf006de746b9a271f9fab09cbd6035ef 100644 (file)
@@ -8,12 +8,14 @@
 -->
 <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/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.opendaylight.controller</groupId>
-    <artifactId>config-parent</artifactId>
-    <version>0.6.0-SNAPSHOT</version>
-    <relativePath/>
-  </parent>
+    <parent>
+        <groupId>org.opendaylight.mdsal</groupId>
+        <artifactId>binding-parent</artifactId>
+        <version>0.10.0-SNAPSHOT</version>
+        <relativePath/>
+    </parent>
+
+  <!--TODO Delete this bundle as soon as https://git.opendaylight.org/gerrit/#/c/46621/ is merged.-->
 
   <groupId>org.opendaylight.netconf</groupId>
   <artifactId>netconf-config-dispatcher</artifactId>
diff --git a/netconf/netconf-config-dispatcher/src/main/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModule.java b/netconf/netconf-config-dispatcher/src/main/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModule.java
deleted file mode 100644 (file)
index c48e039..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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
- */
-package org.opendaylight.controller.config.yang.config.netconf.client.dispatcher;
-
-import org.opendaylight.netconf.client.NetconfClientDispatcherImpl;
-
-/**
-*
-*/
-public final class NetconfClientDispatcherModule extends org.opendaylight.controller.config.yang.config.netconf.client.dispatcher.AbstractNetconfClientDispatcherModule {
-
-    public NetconfClientDispatcherModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public NetconfClientDispatcherModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
-            NetconfClientDispatcherModule oldModule, java.lang.AutoCloseable oldInstance) {
-
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    protected void customValidation(){
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        return new NetconfClientDispatcherImpl(getBossThreadGroupDependency(), getWorkerThreadGroupDependency(), getTimerDependency());
-    }
-}
diff --git a/netconf/netconf-config-dispatcher/src/main/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModuleFactory.java b/netconf/netconf-config-dispatcher/src/main/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModuleFactory.java
deleted file mode 100644 (file)
index cfd4ef6..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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
- */
-package org.opendaylight.controller.config.yang.config.netconf.client.dispatcher;
-
-/**
-*
-*/
-public class NetconfClientDispatcherModuleFactory extends org.opendaylight.controller.config.yang.config.netconf.client.dispatcher.AbstractNetconfClientDispatcherModuleFactory
-{
-
-
-}
index a3c575dc80315880ebf47e0998e7dc12e9211a2c..be1f08c5bcc59620ef5c0dd5e77ea2d77c08ff31 100644 (file)
@@ -1,6 +1,10 @@
 // vi: set smarttab et sw=4 tabstop=4:
 module odl-netconf-cfg {
 
+/**
+* TODO Delete this YANG file as soon as https://git.opendaylight.org/gerrit/#/c/46621/ is merged.
+*/
+
     yang-version 1;
     namespace "urn:opendaylight:params:xml:ns:yang:controller:config:netconf";
     prefix "cfg-net";
@@ -24,7 +28,6 @@ module odl-netconf-cfg {
     }
 
     identity netconf-client-dispatcher {
-
         base "config:service-type";
         config:java-class "org.opendaylight.netconf.client.NetconfClientDispatcher";
     }
index e00bdeb687dc3825d7549a94cf84ddeda886fa33..caa400abb8171a8d1dbcfcb66d7aa629b2f50acf 100644 (file)
@@ -1,6 +1,10 @@
 // vi: set smarttab et sw=4 tabstop=4:
 module odl-netconfig-client-cfg {
 
+/**
+* TODO Delete this YANG file as soon as https://git.opendaylight.org/gerrit/#/c/46621/ is merged.
+*/
+
     yang-version 1;
     namespace "urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher";
     prefix "cfg-net-client";
@@ -34,30 +38,6 @@ module odl-netconfig-client-cfg {
     augment "/config:modules/config:module/config:configuration" {
         case netconf-client-dispatcher {
             when "/config:modules/config:module/config:type = 'netconf-client-dispatcher'";
-
-            container boss-thread-group {
-                uses config:service-ref {
-                    refine type {
-                        config:required-identity netty:netty-threadgroup;
-                    }
-                }
-            }
-
-            container worker-thread-group {
-                uses config:service-ref {
-                    refine type {
-                        config:required-identity netty:netty-threadgroup;
-                    }
-                }
-            }
-
-            container timer {
-                uses config:service-ref {
-                    refine type {
-                        config:required-identity netty:netty-timer;
-                    }
-                }
-            }
         }
     }
 
diff --git a/netconf/netconf-config-dispatcher/src/test/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModuleTest.java b/netconf/netconf-config-dispatcher/src/test/java/org/opendaylight/controller/config/yang/config/netconf/client/dispatcher/NetconfClientDispatcherModuleTest.java
deleted file mode 100644 (file)
index e9adb4c..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.controller.config.yang.config.netconf.client.dispatcher;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.contains;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.opendaylight.controller.config.api.ConflictingVersionException;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleFactory;
-import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleMXBean;
-import org.opendaylight.controller.config.yang.netty.timer.HashedWheelTimerModuleFactory;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import io.netty.channel.EventLoopGroup;
-import io.netty.util.Timer;
-
-public class NetconfClientDispatcherModuleTest extends AbstractConfigTest{
-
-    private NetconfClientDispatcherModuleFactory factory;
-    private final String instanceName = "dispatch";
-
-    @Before
-    public void setUp() throws Exception {
-        factory = new NetconfClientDispatcherModuleFactory();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory,
-                new NettyThreadgroupModuleFactory(),
-                new HashedWheelTimerModuleFactory()));
-
-        doAnswer(new Answer<Filter>() {
-            @Override
-            public Filter answer(InvocationOnMock invocation) {
-                String str = invocation.getArgumentAt(0, String.class);
-                Filter mockFilter = mock(Filter.class);
-                doReturn(str).when(mockFilter).toString();
-                return mockFilter;
-            }
-        }).when(mockedContext).createFilter(anyString());
-        doNothing().when(mockedContext).addServiceListener(any(ServiceListener.class), anyString());
-
-        setupMockService(EventLoopGroup.class);
-        setupMockService(Timer.class);
-    }
-
-    private void setupMockService(Class<?> serviceInterface) throws Exception {
-        ServiceReference<?> mockServiceRef = mock(ServiceReference.class);
-        doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext).
-                getServiceReferences(anyString(), contains(serviceInterface.getName()));
-        doReturn(mock(serviceInterface)).when(mockedContext).getService(mockServiceRef);
-    }
-
-    @Test
-    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException, ConflictingVersionException {
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-
-        createInstance(transaction, instanceName, "timer", "thGroup");
-        createInstance(transaction, instanceName + 2, "timer2", "thGroup2");
-        transaction.validateConfig();
-        CommitStatus status = transaction.commit();
-
-        assertBeanCount(2, factory.getImplementationName());
-        assertStatus(status, 2 + 4, 0, 0);
-    }
-
-    @Test
-    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException {
-
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-        createInstance(transaction, instanceName, "timer", "thGroup");
-
-        transaction.commit();
-
-        transaction = configRegistryClient.createTransaction();
-        assertBeanCount(1, factory.getImplementationName());
-        CommitStatus status = transaction.commit();
-
-        assertBeanCount(1, factory.getImplementationName());
-        assertStatus(status, 0, 0, 3);
-    }
-
-    @Test
-    public void testReconfigure() throws InstanceAlreadyExistsException, ConflictingVersionException,
-            ValidationException, InstanceNotFoundException {
-
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-        createInstance(transaction, instanceName, "timer", "thGroup");
-
-        transaction.commit();
-
-        transaction = configRegistryClient.createTransaction();
-        assertBeanCount(1, factory.getImplementationName());
-        NetconfClientDispatcherModuleMXBean mxBean = transaction.newMBeanProxy(
-                transaction.lookupConfigBean(NetconfClientDispatcherModuleFactory.NAME, instanceName),
-                NetconfClientDispatcherModuleMXBean.class);
-        mxBean.setBossThreadGroup(getThreadGroup(transaction, "group2"));
-        CommitStatus status = transaction.commit();
-
-        assertBeanCount(1, factory.getImplementationName());
-        assertStatus(status, 1, 1, 2);
-    }
-
-    private ObjectName createInstance(ConfigTransactionJMXClient transaction, String instanceName, String timerName, String threadGroupName)
-            throws InstanceAlreadyExistsException {
-        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
-        NetconfClientDispatcherModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated, NetconfClientDispatcherModuleMXBean.class);
-        ObjectName thGroup = getThreadGroup(transaction, threadGroupName);
-        mxBean.setBossThreadGroup(thGroup);
-        mxBean.setWorkerThreadGroup(thGroup);
-        mxBean.setTimer(getTimer(transaction, timerName));
-        return nameCreated;
-    }
-
-    private ObjectName getTimer(ConfigTransactionJMXClient transaction, String name) throws InstanceAlreadyExistsException {
-        return transaction.createModule(HashedWheelTimerModuleFactory.NAME, name);
-    }
-
-    private ObjectName getThreadGroup(ConfigTransactionJMXClient transaction, String name) throws InstanceAlreadyExistsException {
-        ObjectName nameCreated = transaction.createModule(NettyThreadgroupModuleFactory.NAME, name);
-        NettyThreadgroupModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, NettyThreadgroupModuleMXBean.class);
-        mxBean.setThreadCount(1);
-        return nameCreated;
-    }
-}
index a2e8f4092243fd3a96118a2e905346d1dbad5632..e641ac549c504588b19d735d97717009d6ae1121 100644 (file)
         <module>
           <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">prefix:netconf-client-dispatcher</type>
           <name>global-netconf-dispatcher</name>
-          <boss-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
-            <name>global-boss-group</name>
-          </boss-thread-group>
-          <worker-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
-            <name>global-worker-group</name>
-          </worker-thread-group>
-          <timer xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-timer</type>
-            <name>global-timer</name>
-          </timer>
         </module>
 
         <!-- Thread factory to be used by all threadpools in netconf-connectors -->
diff --git a/netconf/netconf-console/src/main/config/default-config.xml b/netconf/netconf-console/src/main/config/default-config.xml
deleted file mode 100644 (file)
index 4f27421..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2016 Inocybe Technologies. 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
--->
-<snapshot>
-  <required-capabilities>
-      <capability>urn:opendaylight:netconf:console:provider:impl?module=netconf-console-provider-impl&amp;revision=2016-03-23</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
-  </required-capabilities>
-
-  <configuration>
-    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-      <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-        <module>
-          <type xmlns:prefix="urn:opendaylight:netconf:console:provider:impl">prefix:netconf-console-provider-impl</type>
-          <name>netconf-console-default</name>
-          <broker>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
-            <name>binding-osgi-broker</name>
-          </broker>
-        </module>
-      </modules>
-    </data>
-  </configuration>
-</snapshot>
\ No newline at end of file
index 40ac48f17c633613afc9a1dd9be39db3ae5d86d0..96715193b5a2928e0dc3ecf8acfe38368ff7d22b 100644 (file)
@@ -8,11 +8,10 @@
 
 package org.opendaylight.netconf.console.commands;
 
+import com.google.common.base.Strings;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import com.google.common.base.Strings;
-
 public class NetconfCommandUtils {
 
     private static final Pattern IP_PATTERN = Pattern.compile(
index b1abf2fa254d7a9f2bac9009245a99f1e0f48211..20f1234ac90dc9af0ebf30353370d5916d695648 100644 (file)
@@ -9,13 +9,12 @@
 package org.opendaylight.netconf.console.commands;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Strings;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.commands.Option;
 import org.apache.karaf.shell.console.AbstractAction;
 import org.opendaylight.netconf.console.api.NetconfCommands;
 
-import com.google.common.base.Strings;
-
 @Command(name = "netconf:disconnect-device", scope = "netconf", description = "Disconnect netconf device.")
 public class NetconfDisconnectDeviceCommand extends AbstractAction {
 
index fd52e651e2ff7d9fce9704057ce5306688e1f8fc..7a1ec73f45ec67a99d77a7b04621fe968b98ab7a 100644 (file)
@@ -9,9 +9,7 @@
 package org.opendaylight.netconf.console.commands;
 
 import java.util.Map;
-
 import javax.annotation.Nonnull;
-
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.console.AbstractAction;
 import org.apache.karaf.shell.table.ShellTable;
index 08a8a1e202e366a5db796fe390e3d11e6ffdf06e..df2f6584bf9bbf3aa77fc58689be5d7648a535cc 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.netconf.console.commands;
 import com.google.common.annotations.VisibleForTesting;
 import java.util.HashMap;
 import java.util.Map;
-
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.commands.Option;
 import org.apache.karaf.shell.console.AbstractAction;
index 48d21c331d1ad2bfb009479abd6de082bd50cdff..95f0917dc92e9dc432c997c444a41a0f4cb0823c 100644 (file)
@@ -19,7 +19,6 @@ import java.util.Map;
 import java.util.UUID;
 import java.util.stream.Collectors;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
@@ -50,17 +49,18 @@ public class NetconfCommandsImpl implements NetconfCommands {
     private static final Logger LOG = LoggerFactory.getLogger(NetconfCommandsImpl.class);
 
     private final DataBroker dataBroker;
-    private final MountPointService mountPointService;
 
-    public NetconfCommandsImpl(final DataBroker db, final MountPointService mountPointService) {
+    public NetconfCommandsImpl(final DataBroker db) {
         LOG.debug("NetconfConsoleProviderImpl initialized");
         this.dataBroker = db;
-        this.mountPointService = mountPointService;
     }
 
     @Override
     public Map<String, Map<String, String>> listDevices() {
         final Topology topology = NetconfConsoleUtils.read(LogicalDatastoreType.OPERATIONAL, NetconfIidFactory.NETCONF_TOPOLOGY_IID, dataBroker);
+        if (topology == null) {
+            return new HashMap<>();
+        }
         final Map<String, Map<String, String>> netconfNodes = new HashMap<>();
         for (final Node node : topology.getNode()) {
             final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
diff --git a/netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/impl/NetconfConsoleProvider.java b/netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/impl/NetconfConsoleProvider.java
deleted file mode 100644 (file)
index 0f15ef4..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2016 Inocybe Technologies 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
- */
-
-package org.opendaylight.netconf.console.impl;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.opendaylight.netconf.console.api.NetconfCommands;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NetconfConsoleProvider implements BindingAwareProvider, AutoCloseable {
-
-    private static final Logger LOG = LoggerFactory.getLogger(NetconfConsoleProvider.class);
-    private ServiceRegistration<NetconfCommands> netconfConsoleRegistration;
-
-    @Override
-    public void onSessionInitiated(ProviderContext session) {
-        LOG.info("NetconfProvider Session Initiated");
-
-        // Retrieve DataBroker service to interact with md-sal
-        final DataBroker dataBroker =  session.getSALService(DataBroker.class);
-
-        // Retrieve MountPointService to interact with NETCONF remote devices connected to ODL and register it
-        final MountPointService mountService = session.getSALService(MountPointService.class);
-        final BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
-
-        // Initialization of NETCONF Console Provider service implementation
-        initializeNetconfConsoleProvider(dataBroker, context, mountService);
-    }
-
-    private void initializeNetconfConsoleProvider(DataBroker dataBroker, BundleContext context, MountPointService mountService) {
-        // Initialize NetconfConsoleProviderImpl class
-        final NetconfCommandsImpl consoleProvider = new NetconfCommandsImpl(dataBroker, mountService);
-
-        // Register the NetconfConsoleProvider service
-        netconfConsoleRegistration = context.registerService(NetconfCommands.class, consoleProvider, null);
-    }
-
-    @Override
-    public void close() throws Exception {
-        LOG.info("NetconfProvider closed.");
-        netconfConsoleRegistration.unregister();
-    }
-}
diff --git a/netconf/netconf-console/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/netconf/console/provider/impl/rev160323/NetconfConsoleProviderModule.java b/netconf/netconf-console/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/netconf/console/provider/impl/rev160323/NetconfConsoleProviderModule.java
deleted file mode 100644 (file)
index 39f5409..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.console.provider.impl.rev160323;
-
-import org.opendaylight.netconf.console.impl.NetconfConsoleProvider;
-
-public class NetconfConsoleProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.console.provider.impl.rev160323.AbstractNetconfConsoleProviderModule {
-    public NetconfConsoleProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public NetconfConsoleProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.console.provider.impl.rev160323.NetconfConsoleProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        final NetconfConsoleProvider provider = new NetconfConsoleProvider();
-        getBrokerDependency().registerProvider(provider);
-        return provider;
-    }
-}
diff --git a/netconf/netconf-console/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/netconf/console/provider/impl/rev160323/NetconfConsoleProviderModuleFactory.java b/netconf/netconf-console/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/netconf/console/provider/impl/rev160323/NetconfConsoleProviderModuleFactory.java
deleted file mode 100644 (file)
index 01c4b5f..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-* Generated file
-*
-* Generated from: yang module name: netconf-console-provider-impl yang module local name: netconf-console-provider-impl
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Mar 23 18:01:12 EDT 2016
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.console.provider.impl.rev160323;
-public class NetconfConsoleProviderModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.console.provider.impl.rev160323.AbstractNetconfConsoleProviderModuleFactory {
-
-}
diff --git a/netconf/netconf-console/src/main/resources/OSGI-INF/blueprint/commands.xml b/netconf/netconf-console/src/main/resources/OSGI-INF/blueprint/commands.xml
deleted file mode 100644 (file)
index 51e07b0..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-    <reference id="netconfConsoleProvider" availability="mandatory"
-        activation="eager" interface="org.opendaylight.netconf.console.api.NetconfCommands">
-    </reference>
-    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
-        <command name="netconf:connect-device">
-            <action class="org.opendaylight.netconf.console.commands.NetconfConnectDeviceCommand">
-                <argument ref="netconfConsoleProvider"/>
-            </action>
-        </command>
-        <command name="netconf:list-devices">
-            <action class="org.opendaylight.netconf.console.commands.NetconfListDevicesCommand">
-                <argument ref="netconfConsoleProvider"/>
-            </action>
-        </command>
-        <command name="netconf:show-device">
-            <action class="org.opendaylight.netconf.console.commands.NetconfShowDeviceCommand">
-                <argument ref="netconfConsoleProvider"/>
-            </action>
-        </command>
-        <command name="netconf:disconnect-device">
-            <action class="org.opendaylight.netconf.console.commands.NetconfDisconnectDeviceCommand">
-                <argument ref="netconfConsoleProvider"/>
-            </action>
-        </command>
-        <command name="netconf:update-device">
-            <action class="org.opendaylight.netconf.console.commands.NetconfUpdateDeviceCommand">
-                <argument ref="netconfConsoleProvider"/>
-            </action>
-        </command>
-    </command-bundle>
-</blueprint>
\ No newline at end of file
diff --git a/netconf/netconf-console/src/main/resources/org/opendaylight/blueprint/netconf-command.xml b/netconf/netconf-console/src/main/resources/org/opendaylight/blueprint/netconf-command.xml
new file mode 100755 (executable)
index 0000000..68d319d
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies Inc. 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           odl:use-default-for-reference-types="true">
+
+    <reference id="dataBroker"
+               interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+               odl:type="default"/>
+
+    <bean id="netconfCommandsImpl" class="org.opendaylight.netconf.console.impl.NetconfCommandsImpl">
+        <argument ref="dataBroker"/>
+    </bean>
+    <service ref="netconfCommandsImpl" interface="org.opendaylight.netconf.console.api.NetconfCommands" />
+
+    <!--Karaf CLI-->
+
+    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
+        <command name="netconf:connect-device">
+            <action class="org.opendaylight.netconf.console.commands.NetconfConnectDeviceCommand">
+                <argument ref="netconfCommandsImpl"/>
+            </action>
+        </command>
+        <command name="netconf:list-devices">
+            <action class="org.opendaylight.netconf.console.commands.NetconfListDevicesCommand">
+                <argument ref="netconfCommandsImpl"/>
+            </action>
+        </command>
+        <command name="netconf:show-device">
+            <action class="org.opendaylight.netconf.console.commands.NetconfShowDeviceCommand">
+                <argument ref="netconfCommandsImpl"/>
+            </action>
+        </command>
+        <command name="netconf:disconnect-device">
+            <action class="org.opendaylight.netconf.console.commands.NetconfDisconnectDeviceCommand">
+                <argument ref="netconfCommandsImpl"/>
+            </action>
+        </command>
+        <command name="netconf:update-device">
+            <action class="org.opendaylight.netconf.console.commands.NetconfUpdateDeviceCommand">
+                <argument ref="netconfCommandsImpl"/>
+            </action>
+        </command>
+    </command-bundle>
+
+</blueprint>
diff --git a/netconf/netconf-console/src/main/yang/netconf-console-provider-impl.yang b/netconf/netconf-console/src/main/yang/netconf-console-provider-impl.yang
deleted file mode 100644 (file)
index bbe7ea6..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-module netconf-console-provider-impl {
-    namespace "urn:opendaylight:netconf:console:provider:impl";
-    prefix "netconf-console-provider-impl";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
-
-    revision 2016-03-23 {
-        description "Initial revision";
-    }
-
-    identity netconf-console-provider-impl {
-        base config:module-type;
-        config:java-name-prefix NetconfConsoleProvider;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case netconf-console-provider-impl {
-            when "/config:modules/config:module/config:type = 'netconf-console-provider-impl'";
-            container broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity mdsal:binding-broker-osgi-registry;
-                    }
-                }
-            }
-        }
-    }
-}
\ No newline at end of file
index 6fdf0a6c12a0407518a9fca579de3c8f862c9254..83e21cfcd1b8c7de74a6ee695d6fd371e4996b1e 100644 (file)
@@ -121,8 +121,7 @@ public class NetconfCommandsImplTest {
         bindingToNormalized.onGlobalContextUpdated(schemaContext);
         dataBroker = new BindingDOMDataBrokerAdapter(cDOMDataBroker, bindingToNormalized);
 
-        final MountPointService mountPointService = mock(MountPointService.class);
-        netconfCommands = new NetconfCommandsImpl(dataBroker, mountPointService);
+        netconfCommands = new NetconfCommandsImpl(dataBroker);
     }
 
     @Test
diff --git a/netconf/netconf-console/src/test/java/org/opendaylight/netconf/console/impl/NetconfConsoleProviderTest.java b/netconf/netconf-console/src/test/java/org/opendaylight/netconf/console/impl/NetconfConsoleProviderTest.java
deleted file mode 100644 (file)
index ef20f81..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.netconf.console.impl;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.powermock.api.mockito.PowerMockito.when;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.BDDMockito;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.netconf.console.api.NetconfCommands;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(FrameworkUtil.class)
-public class NetconfConsoleProviderTest {
-
-    @Test
-    public void testProvider() throws Exception {
-        final NetconfConsoleProvider netconfConsoleProvider = new NetconfConsoleProvider();
-
-        PowerMockito.mockStatic(FrameworkUtil.class);
-
-        final BindingAwareBroker.ProviderContext session = mock(BindingAwareBroker.ProviderContext.class);
-        final MountPointService mountPointService = mock(MountPointService.class);
-        final BundleContext bundleContext = mock(BundleContext.class);
-        final DataBroker dataBroker = mock(DataBroker.class);
-        final Bundle bundle = mock(Bundle.class);
-
-        doReturn(dataBroker).when(session).getSALService(DataBroker.class);
-        doReturn(mountPointService).when(session).getSALService(MountPointService.class);
-        BDDMockito.given(FrameworkUtil.getBundle(any())).willReturn(bundle);
-        when(bundle.getBundleContext()).thenReturn(bundleContext);
-
-        netconfConsoleProvider.onSessionInitiated(session);
-
-        verify(bundleContext, times(1)).registerService(eq(NetconfCommands.class), any(NetconfCommandsImpl.class), eq(null));
-
-    }
-}
diff --git a/netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfMapperAggregatorModule.java b/netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfMapperAggregatorModule.java
deleted file mode 100644 (file)
index 4b49941..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.controller.config.yang.config.netconf.northbound.impl;
-
-import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
-
-public class NetconfMapperAggregatorModule extends org.opendaylight.controller.config.yang.config.netconf.northbound.impl.AbstractNetconfMapperAggregatorModule {
-    public NetconfMapperAggregatorModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public NetconfMapperAggregatorModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final org.opendaylight.controller.config.yang.config.netconf.northbound.impl.NetconfMapperAggregatorModule oldModule, final java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {}
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        return new AggregatedNetconfOperationServiceFactory();
-    }
-
-}
diff --git a/netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfMapperAggregatorModuleFactory.java b/netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfMapperAggregatorModuleFactory.java
deleted file mode 100644 (file)
index 8a8ffb7..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: netconf-northbound-impl yang module local name: netconf-mapper-aggregator
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Tue Feb 17 17:24:19 CET 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.config.netconf.northbound.impl;
-public class NetconfMapperAggregatorModuleFactory extends org.opendaylight.controller.config.yang.config.netconf.northbound.impl.AbstractNetconfMapperAggregatorModuleFactory {
-
-}
diff --git a/netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfServerDispatcherModule.java b/netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfServerDispatcherModule.java
deleted file mode 100644 (file)
index 6383b18..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.controller.config.yang.config.netconf.northbound.impl;
-
-import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-import org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorFactoryBuilder;
-import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
-import org.opendaylight.netconf.impl.NetconfServerDispatcherImpl;
-import org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorFactory;
-import org.opendaylight.netconf.impl.SessionIdProvider;
-import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
-
-public class NetconfServerDispatcherModule extends AbstractNetconfServerDispatcherModule {
-    public NetconfServerDispatcherModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public NetconfServerDispatcherModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, NetconfServerDispatcherModule oldModule, AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        JmxAttributeValidationException.checkCondition(getConnectionTimeoutMillis() > 0, "Invalid connection timeout", connectionTimeoutMillisJmxAttribute);
-    }
-
-    @Override
-    public AutoCloseable createInstance() {
-
-        final AggregatedNetconfOperationServiceFactory aggregatedOpProvider = getAggregatedOpProvider();
-        final NetconfMonitoringService monitoringService = getServerMonitorDependency();
-
-        final NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactoryBuilder()
-                .setAggregatedOpService(aggregatedOpProvider)
-                .setTimer(getTimerDependency())
-                .setIdProvider(new SessionIdProvider())
-                .setMonitoringService(monitoringService)
-                .setConnectionTimeoutMillis(getConnectionTimeoutMillis())
-                .build();
-        final NetconfServerDispatcherImpl.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcherImpl.ServerChannelInitializer(
-                serverNegotiatorFactory);
-
-        return new NetconfServerDispatcherImpl(serverChannelInitializer, getBossThreadGroupDependency(), getWorkerThreadGroupDependency()) {
-
-            @Override
-            public void close() {
-                // NOOP, close should not be present here, the deprecated method closes injected evet loop groups
-            }
-        };
-
-    }
-
-    private AggregatedNetconfOperationServiceFactory getAggregatedOpProvider() {
-        final AggregatedNetconfOperationServiceFactory netconfOperationProvider = new AggregatedNetconfOperationServiceFactory();
-        for (final NetconfOperationServiceFactory netconfOperationServiceFactory : getMappersDependency()) {
-            netconfOperationProvider.onAddNetconfOperationServiceFactory(netconfOperationServiceFactory);
-        }
-        return netconfOperationProvider;
-    }
-
-
-}
diff --git a/netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfServerDispatcherModuleFactory.java b/netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfServerDispatcherModuleFactory.java
deleted file mode 100644 (file)
index 61c0c71..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: netconf-northbound-impl yang module local name: netconf-server-dispatcher-impl
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Thu Feb 12 11:32:29 CET 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.config.netconf.northbound.impl;
-public class NetconfServerDispatcherModuleFactory extends org.opendaylight.controller.config.yang.config.netconf.northbound.impl.AbstractNetconfServerDispatcherModuleFactory {
-
-}
diff --git a/netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfServerMonitoringModule.java b/netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfServerMonitoringModule.java
deleted file mode 100644 (file)
index 02521e8..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.controller.config.yang.config.netconf.northbound.impl;
-
-import com.google.common.base.Optional;
-import org.opendaylight.netconf.impl.osgi.NetconfMonitoringServiceImpl;
-
-public class NetconfServerMonitoringModule extends org.opendaylight.controller.config.yang.config.netconf.northbound.impl.AbstractNetconfServerMonitoringModule {
-    public NetconfServerMonitoringModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public NetconfServerMonitoringModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.netconf.northbound.impl.NetconfServerMonitoringModule oldModule, java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        return new NetconfMonitoringServiceImpl(getAggregatorDependency(),
-                Optional.fromNullable(getScheduledThreadpoolDependency()),
-                getMonitoringUpdateInterval());
-    }
-
-}
diff --git a/netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfServerMonitoringModuleFactory.java b/netconf/netconf-impl/src/main/java/org/opendaylight/controller/config/yang/config/netconf/northbound/impl/NetconfServerMonitoringModuleFactory.java
deleted file mode 100644 (file)
index 8b4cb65..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: netconf-northbound-impl yang module local name: netconf-server-monitoring-impl
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Tue Feb 17 17:24:19 CET 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.config.netconf.northbound.impl;
-public class NetconfServerMonitoringModuleFactory extends org.opendaylight.controller.config.yang.config.netconf.northbound.impl.AbstractNetconfServerMonitoringModuleFactory {
-
-}
index bd26baa6190e8d3080072df10e66e6c339dbd367..44e2d4e8145e6a0124271da2af1635d6f94e20da 100644 (file)
@@ -52,7 +52,7 @@ public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorF
     private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSessionNegotiatorFactory.class);
     private final Set<String> baseCapabilities;
 
-    protected NetconfServerSessionNegotiatorFactory(final Timer timer, final NetconfOperationServiceFactory netconfOperationProvider,
+    public NetconfServerSessionNegotiatorFactory(final Timer timer, final NetconfOperationServiceFactory netconfOperationProvider,
                                                  final SessionIdProvider idProvider, final long connectionTimeoutMillis,
                                                  final NetconfMonitoringService monitoringService, final Set<String> baseCapabilities) {
         this.timer = timer;
index d526678fde739cc4e3456ef63fa33f609570fc12..938aec869f9cee8ebf4a355dcf8fa03008c48f66 100644 (file)
@@ -13,8 +13,11 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ImmutableSet.Builder;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Multimap;
+import com.google.common.collect.Multimaps;
 import com.google.common.collect.Sets;
+import io.netty.util.internal.ConcurrentSet;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.opendaylight.controller.config.util.capability.Capability;
@@ -34,9 +37,16 @@ public class AggregatedNetconfOperationServiceFactory implements NetconfOperatio
 
     private static final Logger LOG = LoggerFactory.getLogger(AggregatedNetconfOperationServiceFactory.class);
 
-    private final Set<NetconfOperationServiceFactory> factories = new HashSet<>();
-    private final Multimap<NetconfOperationServiceFactory, AutoCloseable> registrations = HashMultimap.create();
-    private final Set<CapabilityListener> listeners = Sets.newHashSet();
+    private final Set<NetconfOperationServiceFactory> factories = new ConcurrentSet<>();
+    private final Multimap<NetconfOperationServiceFactory, AutoCloseable> registrations = Multimaps.synchronizedMultimap(HashMultimap.create());
+    private final Set<CapabilityListener> listeners = new ConcurrentSet<>();
+
+    public AggregatedNetconfOperationServiceFactory() {
+    }
+
+    public AggregatedNetconfOperationServiceFactory(final List<NetconfOperationServiceFactory> mappers) {
+        mappers.forEach(this::onAddNetconfOperationServiceFactory);
+    }
 
     @Override
     public synchronized void onAddNetconfOperationServiceFactory(NetconfOperationServiceFactory service) {
@@ -64,7 +74,7 @@ public class AggregatedNetconfOperationServiceFactory implements NetconfOperatio
     }
 
     @Override
-    public synchronized Set<Capability> getCapabilities() {
+    public Set<Capability> getCapabilities() {
         final HashSet<Capability> capabilities = Sets.newHashSet();
         for (final NetconfOperationServiceFactory factory : factories) {
             capabilities.addAll(factory.getCapabilities());
index 59d9a56276e4305aa09c6177abdeec943db0c650..edd3c36bde39ae97b33b5fa1daa8befb6ce97892 100644 (file)
@@ -16,14 +16,15 @@ import com.google.common.collect.ImmutableList.Builder;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
+import io.netty.util.internal.ConcurrentSet;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import org.opendaylight.controller.config.util.capability.BasicCapability;
 import org.opendaylight.controller.config.util.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
@@ -57,13 +58,13 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
         }
     };
 
-    private final Set<NetconfManagementSession> sessions = new HashSet<>();
+    private final Set<NetconfManagementSession> sessions = new ConcurrentSet<>();
     private final NetconfOperationServiceFactory netconfOperationProvider;
-    private final Map<Uri, Capability> capabilities = new HashMap<>();
-    private final Map<String, Map<String, String>> mappedModulesToRevisionToSchema = Maps.newHashMap();
+    private final Map<Uri, Capability> capabilities = new ConcurrentHashMap<>();
+    private final Map<String, Map<String, String>> mappedModulesToRevisionToSchema = new ConcurrentHashMap<>();
 
 
-    private final Set<NetconfMonitoringService.CapabilitiesListener> listeners = Sets.newHashSet();
+    private final Set<NetconfMonitoringService.CapabilitiesListener> listeners = new ConcurrentSet<>();
     private volatile BaseNotificationPublisherRegistration notificationPublisher;
 
     NetconfCapabilityMonitoringService(final NetconfOperationServiceFactory netconfOperationProvider) {
index 9c8905afffc451e1b809c8f2d5ec7258d8812414..5c4c508f31b6d4e422af4b0954191f80ccd5622d 100644 (file)
@@ -26,6 +26,12 @@ public class NetconfMonitoringServiceImpl implements NetconfMonitoringService, A
         this(opProvider, Optional.absent(), 0);
     }
 
+    public NetconfMonitoringServiceImpl(NetconfOperationServiceFactory opProvider,
+                                        ScheduledThreadPool threadPool,
+                                        long updateInterval) {
+        this(opProvider, Optional.fromNullable(threadPool), updateInterval);
+    }
+
     public NetconfMonitoringServiceImpl(NetconfOperationServiceFactory opProvider,
                                         Optional<ScheduledThreadPool> threadPool,
                                         long updateInterval) {
index 432390bc12a5b4d44f89153754ea81c6c13f3478..1e118129242522058a5deedef766136ae0d216ae 100644 (file)
@@ -148,21 +148,6 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
         return sortedPriority;
     }
 
-    public static final NetconfOperationChainedExecution EXECUTION_TERMINATION_POINT = new NetconfOperationChainedExecution() {
-        @Override
-        public boolean isExecutionTermination() {
-            return true;
-        }
-
-        @Override
-        public Document execute(final Document requestMessage) throws DocumentedException {
-            throw new DocumentedException("This execution represents the termination point in operation execution and cannot be executed itself",
-                    DocumentedException.ErrorType.APPLICATION,
-                    DocumentedException.ErrorTag.OPERATION_FAILED,
-                    DocumentedException.ErrorSeverity.ERROR);
-        }
-    };
-
     private static class NetconfOperationExecution implements NetconfOperationChainedExecution {
         private final NetconfOperation netconfOperation;
         private final NetconfOperationChainedExecution subsequentExecution;
diff --git a/netconf/netconf-impl/src/main/yang/netconf-northbound-impl.yang b/netconf/netconf-impl/src/main/yang/netconf-northbound-impl.yang
deleted file mode 100644 (file)
index aa6485a..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-// vi: set smarttab et sw=4 tabstop=4:
-module netconf-northbound-impl {
-
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl";
-    prefix "cfg-net-s-i";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import netconf-northbound-mapper { prefix nnm; revision-date 2015-01-14; }
-    import netconf-northbound { prefix nn; revision-date 2015-01-14; }
-    import netty {prefix netty; }
-    import threadpool {prefix th;}
-
-    description
-        "This module contains the base YANG definitions for
-        netconf-server-dispatcher implementation.
-
-        Copyright (c)2013 Cisco Systems, Inc. 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";
-
-    revision "2015-01-12" {
-        description
-            "Initial revision.";
-    }
-
-    identity netconf-server-dispatcher-impl {
-            base config:module-type;
-            config:provided-service nn:netconf-server-dispatcher;
-            config:java-name-prefix NetconfServerDispatcher;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case netconf-server-dispatcher-impl {
-            when "/config:modules/config:module/config:type = 'netconf-server-dispatcher-impl'";
-
-            leaf connection-timeout-millis {
-                description "Specifies timeout in milliseconds after which connection must be established.";
-                type uint32;
-                default 20000;
-            }
-
-            container boss-thread-group {
-                uses config:service-ref {
-                    refine type {
-                        config:required-identity netty:netty-threadgroup;
-                    }
-                }
-            }
-
-            container worker-thread-group {
-                uses config:service-ref {
-                    refine type {
-                        config:required-identity netty:netty-threadgroup;
-                    }
-                }
-            }
-
-            list mappers {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity nnm:netconf-northbound-mapper;
-                    }
-                }
-            }
-
-            container server-monitor {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity nn:netconf-server-monitoring;
-                    }
-                }
-            }
-
-            container timer {
-                uses config:service-ref {
-                    refine type {
-                        config:required-identity netty:netty-timer;
-                    }
-                }
-            }
-        }
-    }
-
-
-    identity netconf-server-monitoring-impl {
-            base config:module-type;
-            config:provided-service nn:netconf-server-monitoring;
-            config:java-name-prefix NetconfServerMonitoring;
-    }
-
-    // TODO Monitoring could expose the monitoring data over JMX...
-
-    augment "/config:modules/config:module/config:configuration" {
-        case netconf-server-monitoring-impl {
-            when "/config:modules/config:module/config:type = 'netconf-server-monitoring-impl'";
-
-            container aggregator {
-                uses config:service-ref {
-                    refine type {
-                        config:required-identity nnm:netconf-northbound-mapper;
-                    }
-                }
-            }
-            container scheduled-threadpool {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity th:scheduled-threadpool;
-                    }
-                }
-                description "Dedicated to update netconf-state/sessions subtree on session change.";
-            }
-            leaf monitoring-update-interval {
-                description "Specifies interval in seconds after which session stats are updated. If zero, stats won't be updated.";
-                type uint32;
-                default 0;
-            }
-
-        }
-    }
-
-    identity netconf-mapper-aggregator {
-        base config:module-type;
-        config:provided-service nnm:netconf-northbound-mapper;
-        config:provided-service nnm:netconf-mapper-registry;
-        config:java-name-prefix NetconfMapperAggregator;
-        description "Aggregated operation provider for netconf servers. Joins all the operations and capabilities of all the mappers it aggregates and exposes them as a single service. The dependency orientation is reversed in order to prevent cyclic dependencies when monitoring service is considered";
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case netconf-mapper-aggregator {
-            when "/config:modules/config:module/config:type = 'netconf-mapper-aggregator'";
-
-        }
-    }
-
-}
\ No newline at end of file
diff --git a/netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/NetconfServerSessionListenerTest.java b/netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/NetconfServerSessionListenerTest.java
new file mode 100644 (file)
index 0000000..af514d1
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. 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
+ */
+
+package org.opendaylight.netconf.impl;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.verify;
+
+import io.netty.channel.embedded.EmbeddedChannel;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.hamcrest.CustomMatcher;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.NetconfTerminationReason;
+import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.netconf.api.monitoring.SessionEvent;
+import org.opendaylight.netconf.api.monitoring.SessionListener;
+import org.opendaylight.netconf.impl.osgi.NetconfOperationRouter;
+import org.opendaylight.netconf.notifications.NetconfNotification;
+import org.w3c.dom.Document;
+
+public class NetconfServerSessionListenerTest {
+
+    @Mock
+    private NetconfOperationRouter router;
+    @Mock
+    private NetconfMonitoringService monitoring;
+    @Mock
+    private AutoCloseable closeable;
+    @Mock
+    private SessionListener monitoringListener;
+    private NetconfServerSession session;
+    private EmbeddedChannel channel;
+    private NetconfServerSessionListener listener;
+
+    @BeforeClass
+    public static void classSetUp() throws Exception {
+        XMLUnit.setIgnoreWhitespace(true);
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        doReturn(monitoringListener).when(monitoring).getSessionListener();
+        doNothing().when(monitoringListener).onSessionUp(any());
+        doNothing().when(monitoringListener).onSessionDown(any());
+        doNothing().when(monitoringListener).onSessionEvent(any());
+        channel = new EmbeddedChannel();
+        session = new NetconfServerSession(null, channel, 0L, null);
+        listener = new NetconfServerSessionListener(router, monitoring, closeable);
+    }
+
+    @Test
+    public void testOnSessionUp() throws Exception {
+        listener.onSessionUp(session);
+        verify(monitoringListener).onSessionUp(session);
+    }
+
+    @Test
+    public void testOnSessionDown() throws Exception {
+        final Exception cause = new RuntimeException("cause");
+        listener.onSessionDown(session, cause);
+        verify(monitoringListener).onSessionDown(session);
+        verify(closeable).close();
+        verify(router).close();
+    }
+
+    @Test
+    public void testOnSessionTerminated() throws Exception {
+        listener.onSessionTerminated(session, new NetconfTerminationReason("reason"));
+        verify(monitoringListener).onSessionDown(session);
+        verify(closeable).close();
+        verify(router).close();
+    }
+
+    @Test
+    public void testOnMessage() throws Exception {
+        final Document reply = XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\" " +
+                "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><example/></rpc-reply>");
+        doReturn(reply).when(router).onNetconfMessage(any(), any());
+        final NetconfMessage msg = new NetconfMessage(XmlUtil.readXmlToDocument("<rpc message-id=\"101\" " +
+                "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><example/></rpc>"));
+        listener.onMessage(session, msg);
+        verify(monitoringListener).onSessionEvent(argThat(sessionEventIs(SessionEvent.Type.IN_RPC_SUCCESS)));
+        channel.runPendingTasks();
+        final NetconfMessage sentMsg = (NetconfMessage) channel.readOutbound();
+        final Diff diff = XMLUnit.compareXML(reply, sentMsg.getDocument());
+        Assert.assertTrue(diff.toString(), diff.similar());
+    }
+
+    @Test
+    public void testOnMessageRuntimeFail() throws Exception {
+        doThrow(new RuntimeException("runtime fail")).when(router).onNetconfMessage(any(), any());
+        final Document reply =
+                XmlUtil.readXmlToDocument("<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+                        "<example/></rpc>");
+        final NetconfMessage msg = new NetconfMessage(reply);
+        try {
+            listener.onMessage(session, msg);
+            Assert.fail("Expected exception " + IllegalStateException.class);
+        } catch (final IllegalStateException e) {
+            verify(monitoringListener).onSessionEvent(argThat(sessionEventIs(SessionEvent.Type.IN_RPC_FAIL)));
+        }
+    }
+
+    @Test
+    public void testOnMessageDocumentedFail() throws Exception {
+        final Document reply =
+                XmlUtil.readXmlToDocument("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+                        "<rpc-error>\n" +
+                        "<error-type>PROTOCOL</error-type>\n" +
+                        "<error-tag>unknown-element</error-tag>\n" +
+                        "<error-severity>ERROR</error-severity>\n" +
+                        "<error-message>Unknown tag bad-rpc in message:\n" +
+                        "&lt;bad-rpc/&gt;\n" +
+                        "</error-message>\n" +
+                        "<error-info>\n" +
+                        "<bad-element>bad-rpc</bad-element>\n" +
+                        "</error-info>\n" +
+                        "</rpc-error>\n" +
+                        "</rpc-reply>");
+        final NetconfMessage msg = new NetconfMessage(XmlUtil.readXmlToDocument("<bad-rpc/>"));
+        listener.onMessage(session, msg);
+        verify(monitoringListener).onSessionEvent(argThat(sessionEventIs(SessionEvent.Type.IN_RPC_FAIL)));
+        verify(monitoringListener).onSessionEvent(argThat(sessionEventIs(SessionEvent.Type.OUT_RPC_ERROR)));
+        channel.runPendingTasks();
+        final NetconfMessage sentMsg = (NetconfMessage) channel.readOutbound();
+        System.out.println(XmlUtil.toString(sentMsg.getDocument()));
+        System.out.println(XmlUtil.toString(reply));
+        final Diff diff = XMLUnit.compareXML(reply, sentMsg.getDocument());
+        Assert.assertTrue(diff.toString(), diff.similar());
+    }
+
+    @Test
+    public void testOnNotification() throws Exception {
+        listener.onNotification(session, new NetconfNotification(XmlUtil.readXmlToDocument("<notification/>")));
+        verify(monitoringListener).onSessionEvent(argThat(sessionEventIs(SessionEvent.Type.NOTIFICATION)));
+    }
+
+    private CustomMatcher<SessionEvent> sessionEventIs(final SessionEvent.Type type) {
+        return new CustomMatcher<SessionEvent>(type.name()) {
+            @Override
+            public boolean matches(final Object item) {
+                if (!(item instanceof SessionEvent)) {
+                    return false;
+                }
+                final SessionEvent e = (SessionEvent) item;
+                return e.getType().equals(type) && e.getSession().equals(session);
+            }
+        };
+    }
+
+}
\ No newline at end of file
diff --git a/netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/NetconfServerSessionTest.java b/netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/NetconfServerSessionTest.java
new file mode 100644 (file)
index 0000000..84603bc
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. 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
+ */
+
+package org.opendaylight.netconf.impl;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.verify;
+
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.channel.ChannelOutboundHandlerAdapter;
+import io.netty.channel.embedded.EmbeddedChannel;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
+import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer;
+import org.opendaylight.netconf.nettyutil.handler.NetconfEXICodec;
+import org.opendaylight.netconf.nettyutil.handler.NetconfEXIToMessageDecoder;
+import org.opendaylight.netconf.nettyutil.handler.NetconfMessageToEXIEncoder;
+import org.opendaylight.netconf.nettyutil.handler.NetconfMessageToXMLEncoder;
+import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder;
+import org.opendaylight.netconf.notifications.NetconfNotification;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.NetconfTcp;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfSsh;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
+import org.openexi.proc.common.EXIOptions;
+import org.w3c.dom.Document;
+
+public class NetconfServerSessionTest {
+
+    private static final String HOST = "127.0.0.1";
+    private static final String PORT = "17830";
+    private static final String SSH_TRANSPORT = "ssh";
+    private static final String TCP_TRANSPORT = "tcp";
+    private static final String SESSION_ID = "1";
+    private static final String USER = "admin";
+    private NetconfServerSession session;
+    private EmbeddedChannel channel;
+    private NetconfMessage msg;
+    @Mock
+    private NetconfServerSessionListener listener;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        final NetconfHelloMessageAdditionalHeader header =
+                new NetconfHelloMessageAdditionalHeader(USER, HOST, PORT, SSH_TRANSPORT, SESSION_ID);
+        channel = new EmbeddedChannel();
+        session = new NetconfServerSession(listener, channel, 1L, header);
+        doNothing().when(listener).onSessionUp(any());
+        msg = new NetconfMessage(XmlUtil.readXmlToDocument("<rpc-reply></rpc-reply>"));
+    }
+
+    @Test
+    public void testSessionUp() throws Exception {
+        session.sessionUp();
+        verify(listener).onSessionUp(session);
+    }
+
+    @Test
+    public void testDelayedClose() throws Exception {
+        doNothing().when(listener).onSessionTerminated(eq(session), any());
+        session.delayedClose();
+        session.sendMessage(msg);
+        channel.runPendingTasks();
+        final Object o = channel.readOutbound();
+        Assert.assertEquals(msg, o);
+        verify(listener).onSessionTerminated(eq(session), any());
+    }
+
+    @Test
+    public void testSendMessage() throws Exception {
+        session.sendMessage(msg);
+        channel.runPendingTasks();
+        final Object o = channel.readOutbound();
+        Assert.assertEquals(msg, o);
+    }
+
+    @Test
+    public void testSendNotification() throws Exception {
+        doNothing().when(listener).onNotification(any(), any());
+        final Document msgDoc = XmlUtil.readXmlToDocument("<notification></notification>");
+        final NetconfNotification msg = new NetconfNotification(msgDoc);
+        session.sendMessage(msg);
+        channel.runPendingTasks();
+        final Object o = channel.readOutbound();
+        Assert.assertEquals(msg, o);
+        verify(listener).onNotification(session, msg);
+    }
+
+    @Test
+    public void testOnIncommingRpcSuccess() throws Exception {
+        session.sessionUp();
+        final Session managementSession = this.session.toManagementSession();
+        this.session.onIncommingRpcSuccess();
+        final Session afterRpcSuccess = this.session.toManagementSession();
+        Assert.assertEquals(managementSession.getInRpcs().getValue() + 1,
+                afterRpcSuccess.getInRpcs().getValue().longValue());
+    }
+
+    @Test
+    public void testOnIncommingRpcFail() throws Exception {
+        session.sessionUp();
+        final Session managementSession = this.session.toManagementSession();
+        this.session.onIncommingRpcFail();
+        final Session afterRpcSuccess = this.session.toManagementSession();
+        Assert.assertEquals(managementSession.getInBadRpcs().getValue() + 1,
+                afterRpcSuccess.getInBadRpcs().getValue().longValue());
+    }
+
+    @Test
+    public void testOnOutgoingRpcError() throws Exception {
+        session.sessionUp();
+        final Session managementSession = this.session.toManagementSession();
+        this.session.onOutgoingRpcError();
+        final Session afterRpcSuccess = this.session.toManagementSession();
+        Assert.assertEquals(managementSession.getOutRpcErrors().getValue() + 1,
+                afterRpcSuccess.getOutRpcErrors().getValue().longValue());
+    }
+
+    @Test
+    public void testToManagementSession() throws Exception {
+        final NetconfHelloMessageAdditionalHeader header =
+                new NetconfHelloMessageAdditionalHeader(USER, HOST, PORT, TCP_TRANSPORT, SESSION_ID);
+        final EmbeddedChannel channel = new EmbeddedChannel();
+        final NetconfServerSession tcpSession = new NetconfServerSession(listener, channel, 1L, header);
+        tcpSession.sessionUp();
+        final Session managementSession = tcpSession.toManagementSession();
+        Assert.assertEquals(new String(managementSession.getSourceHost().getValue()), HOST);
+        Assert.assertEquals(managementSession.getUsername(), USER);
+        Assert.assertEquals(managementSession.getSessionId().toString(), SESSION_ID);
+        Assert.assertEquals(managementSession.getTransport(), NetconfTcp.class);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testToManagementSessionUnknownTransport() throws Exception {
+        final NetconfHelloMessageAdditionalHeader header =
+                new NetconfHelloMessageAdditionalHeader(USER, HOST, PORT, "http", SESSION_ID);
+        final EmbeddedChannel channel = new EmbeddedChannel();
+        final NetconfServerSession tcpSession = new NetconfServerSession(listener, channel, 1L, header);
+        tcpSession.sessionUp();
+        tcpSession.toManagementSession();
+    }
+
+    @Test
+    public void testToManagementSessionIpv6() throws Exception {
+        final NetconfHelloMessageAdditionalHeader header =
+                new NetconfHelloMessageAdditionalHeader(USER, "::1", PORT, SSH_TRANSPORT, SESSION_ID);
+        final EmbeddedChannel channel = new EmbeddedChannel();
+        final NetconfServerSession tcpSession = new NetconfServerSession(listener, channel, 1L, header);
+        tcpSession.sessionUp();
+        final Session managementSession = tcpSession.toManagementSession();
+        Assert.assertEquals(new String(managementSession.getSourceHost().getValue()), "::1");
+        Assert.assertEquals(managementSession.getUsername(), USER);
+        Assert.assertEquals(managementSession.getSessionId().toString(), SESSION_ID);
+        Assert.assertEquals(managementSession.getTransport(), NetconfSsh.class);
+    }
+
+    @Test
+    public void testThisInstance() throws Exception {
+        Assert.assertEquals(session, session.thisInstance());
+    }
+
+    @Test
+    public void testAddExiHandlers() throws Exception {
+        channel.pipeline().addLast(AbstractChannelInitializer.NETCONF_MESSAGE_DECODER,
+                new NetconfXMLToMessageDecoder());
+        channel.pipeline().addLast(AbstractChannelInitializer.NETCONF_MESSAGE_ENCODER,
+                new NetconfMessageToXMLEncoder());
+        final NetconfEXICodec codec = new NetconfEXICodec(new EXIOptions());
+        session.addExiHandlers(NetconfEXIToMessageDecoder.create(codec), NetconfMessageToEXIEncoder.create(codec));
+    }
+
+    @Test
+    public void testStopExiCommunication() throws Exception {
+        channel.pipeline().addLast(AbstractChannelInitializer.NETCONF_MESSAGE_DECODER,
+                new ChannelInboundHandlerAdapter());
+        channel.pipeline().addLast(AbstractChannelInitializer.NETCONF_MESSAGE_ENCODER,
+                new ChannelOutboundHandlerAdapter());
+        session.stopExiCommunication();
+        //handler is replaced only after next send message call
+        final ChannelHandler exiEncoder = channel.pipeline().get(AbstractChannelInitializer.NETCONF_MESSAGE_ENCODER);
+        Assert.assertTrue(ChannelOutboundHandlerAdapter.class.equals(exiEncoder.getClass()));
+        session.sendMessage(msg);
+        channel.runPendingTasks();
+        final ChannelHandler decoder = channel.pipeline().get(AbstractChannelInitializer.NETCONF_MESSAGE_DECODER);
+        Assert.assertTrue(NetconfXMLToMessageDecoder.class.equals(decoder.getClass()));
+        final ChannelHandler encoder = channel.pipeline().get(AbstractChannelInitializer.NETCONF_MESSAGE_ENCODER);
+        Assert.assertTrue(NetconfMessageToXMLEncoder.class.equals(encoder.getClass()));
+    }
+
+}
\ No newline at end of file
index b4ec7eca3a7c6c494fe66891b1d3365f5f2eebcf..211f1f88b554dd3ceb905b32dc764a4747c0b921 100644 (file)
@@ -17,11 +17,15 @@ module netconf-northbound-mapper {
     identity netconf-northbound-mapper {
         base "config:service-type";
         config:java-class "org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory";
+        config:disable-osgi-service-registration;
+        status deprecated;
     }
 
     identity netconf-mapper-registry {
         base "config:service-type";
         config:java-class "org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener";
+        config:disable-osgi-service-registration;
+        status deprecated;
     }
 
 }
\ No newline at end of file
diff --git a/netconf/netconf-mdsal-config/pom.xml b/netconf/netconf-mdsal-config/pom.xml
deleted file mode 100644 (file)
index 3a45520..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Copyright (c) 2015 Cisco Systems, Inc. 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
-  -->
-<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>odlparent-lite</artifactId>
-    <version>1.8.0-SNAPSHOT</version>
-    <relativePath/>
-  </parent>
-
-  <groupId>org.opendaylight.netconf</groupId>
-  <artifactId>netconf-mdsal-config</artifactId>
-  <version>1.2.0-SNAPSHOT</version>
-  <description>Configuration files for netconf for mdsal</description>
-  <packaging>jar</packaging>
-
-  <build>
-    <plugins>
-        <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>attach-artifacts</id>
-            <goals>
-              <goal>attach-artifact</goal>
-            </goals>
-            <phase>package</phase>
-            <configuration>
-              <artifacts>
-                <artifact>
-                  <file>${project.build.directory}/classes/initial/08-netconf-mdsal.xml</file>
-                  <type>xml</type>
-                  <classifier>config</classifier>
-                </artifact>
-              </artifacts>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-</project>
diff --git a/netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml b/netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml
deleted file mode 100644 (file)
index 4826035..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Copyright (c) 2015 Cisco Systems, Inc. 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
-  -->
-
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-
-<snapshot>
-  <configuration>
-    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-      <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-
-          <module>
-              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:mapper">prefix:netconf-mdsal-mapper</type>
-              <name>netconf-mdsal-mapper</name>
-              <root-schema-service>
-                  <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
-                  <name>yang-schema-service</name>
-              </root-schema-service>
-              <root-schema-source-provider>
-                  <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:yang-text-source-provider</type>
-                  <name>yang-text-source-provider</name>
-              </root-schema-source-provider>
-              <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:mapper">
-                  <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-                  <name>dom-broker</name>
-              </dom-broker>
-              <mapper-aggregator xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:mapper">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper">prefix:netconf-mapper-registry</type>
-                  <name>mapper-aggregator-registry</name>
-              </mapper-aggregator>
-          </module>
-
-          <module>
-              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl">prefix:netconf-server-dispatcher-impl</type>
-              <name>netconf-mdsal-server-dispatcher</name>
-              <mappers xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl">
-                  <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper">dom:netconf-northbound-mapper</type>
-                  <name>mapper-aggregator</name>
-              </mappers>
-              <server-monitor xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound">prefix:netconf-server-monitoring</type>
-                  <name>server-monitor</name>
-              </server-monitor>
-              <boss-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
-                  <name>global-boss-group</name>
-              </boss-thread-group>
-              <worker-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
-                  <name>global-worker-group</name>
-              </worker-thread-group>
-              <timer xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-timer</type>
-                  <name>global-timer</name>
-              </timer>
-          </module>
-
-          <module>
-              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring">prefix:netconf-mdsal-monitoring-mapper</type>
-              <name>netconf-mdsal-monitoring-mapper</name>
-              <server-monitoring xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound">prefix:netconf-server-monitoring</type>
-                  <name>server-monitor</name>
-              </server-monitoring>
-              <binding-aware-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
-                  <name>binding-osgi-broker</name>
-              </binding-aware-broker>
-              <aggregator xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper">prefix:netconf-mapper-registry</type>
-                  <name>mapper-aggregator-registry</name>
-              </aggregator>
-          </module>
-
-          <module>
-              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl">prefix:netconf-mapper-aggregator</type>
-              <name>mapper-aggregator</name>
-          </module>
-
-          <module>
-              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl">prefix:netconf-server-monitoring-impl</type>
-              <name>server-monitor</name>
-              <aggregator xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl">
-                  <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper">dom:netconf-northbound-mapper</type>
-                  <name>mapper-aggregator</name>
-              </aggregator>
-              <scheduled-threadpool xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
-                  <name>global-netconf-ssh-scheduled-executor</name>
-              </scheduled-threadpool>
-              <monitoring-update-interval xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl">6</monitoring-update-interval>
-          </module>
-
-          <module>
-              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh">prefix:netconf-northbound-ssh</type>
-              <name>netconf-mdsal-ssh-server</name>
-
-              <event-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-event-executor</type>
-                  <name>global-event-executor</name>
-              </event-executor>
-              <worker-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
-                  <name>global-worker-group</name>
-              </worker-thread-group>
-              <processing-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
-                  <name>global-netconf-ssh-scheduled-executor</name>
-              </processing-executor>
-              <dispatcher xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound">prefix:netconf-server-dispatcher</type>
-                  <name>netconf-mdsal-server-dispatcher</name>
-              </dispatcher>
-              <auth-provider xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:auth">prefix:netconf-auth-provider</type>
-                  <name>default-auth-provider</name>
-              </auth-provider>
-          </module>
-
-          <module>
-              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification:impl">prefix:netconf-notification-manager</type>
-              <name>netconf-notification-manager</name>
-          </module>
-
-          <module>
-              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">prefix:netconf-mdsal-notification-mapper</type>
-              <name>netconf-mdsal-notification-mapper</name>
-              <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">
-                  <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
-                  <name>binding-data-broker</name>
-              </data-broker>
-              <binding-aware-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
-                  <name>binding-osgi-broker</name>
-              </binding-aware-broker>
-              <aggregator xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper">prefix:netconf-mapper-registry</type>
-                  <name>mapper-aggregator-registry</name>
-              </aggregator>
-              <notification-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification">prefix:netconf-notification-registry</type>
-                  <name>netconf-notification-manager</name>
-              </notification-registry>
-              <notification-collector>
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification">prefix:netconf-notification-collector</type>
-                  <name>netconf-notification-manager</name>
-              </notification-collector>
-          </module>
-
-          <module>
-              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:yang:library">prefix:netconf-mdsal-yanglib</type>
-              <name>netconf-mdsal-yanglib</name>
-              <binding-aware-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:yang:library">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
-                  <name>binding-osgi-broker</name>
-              </binding-aware-broker>
-              <root-schema-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:yang:library">
-              <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
-              <name>yang-schema-service</name>
-          </root-schema-service>
-          </module>
-
-
-
-          <!--TCP endpoint for MD-SAL netconf server -->
-          <!--<module>-->
-              <!--<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:tcp">prefix:netconf-northbound-tcp</type>-->
-              <!--<name>netconf-mdsal-tcp-server</name>-->
-              <!--<dispatcher xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:tcp">-->
-                  <!--<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound">prefix:netconf-server-dispatcher</type>-->
-                  <!--<name>netconf-mdsal-server-dispatcher</name>-->
-              <!--</dispatcher>-->
-          <!--</module>-->
-
-      </modules>
-
-        <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-            <service>
-                <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound">prefix:netconf-server-monitoring</type>
-                <instance>
-                    <name>server-monitor</name>
-                    <provider>/modules/module[type='netconf-server-monitoring-impl'][name='server-monitor']</provider>
-                </instance>
-            </service>
-            <service>
-                <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper">prefix:netconf-northbound-mapper</type>
-                <instance>
-                    <name>netconf-mdsal-mapper</name>
-                    <provider>/modules/module[type='netconf-mdsal-mapper'][name='netconf-mdsal-mapper']</provider>
-                </instance>
-            </service>
-            <service>
-                <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper">prefix:netconf-northbound-mapper</type>
-                <instance>
-                    <name>mapper-aggregator</name>
-                    <provider>/modules/module[type='netconf-mapper-aggregator'][name='mapper-aggregator']</provider>
-                </instance>
-            </service>
-            <service>
-                <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper">prefix:netconf-mapper-registry</type>
-                <instance>
-                    <name>mapper-aggregator-registry</name>
-                    <provider>/modules/module[type='netconf-mapper-aggregator'][name='mapper-aggregator']</provider>
-                </instance>
-            </service>
-            <service>
-                <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound">prefix:netconf-server-dispatcher</type>
-                <instance>
-                    <name>netconf-mdsal-server-dispatcher</name>
-                    <provider>/modules/module[type='netconf-server-dispatcher-impl'][name='netconf-mdsal-server-dispatcher']</provider>
-                </instance>
-            </service>
-            <service>
-                <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper">prefix:netconf-northbound-mapper</type>
-                <instance>
-                    <name>netconf-mdsal-notification-mapper</name>
-                    <provider>/modules/module[type='netconf-mdsal-notification-mapper'][name='netconf-mdsal-notification-mapper']</provider>
-                </instance>
-            </service>
-            <service>
-                <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification">prefix:netconf-notification-collector</type>
-                <instance>
-                    <name>netconf-notification-manager</name>
-                    <provider>/modules/module[type='netconf-notification-manager'][name='netconf-notification-manager']</provider>
-                </instance>
-            </service>
-            <service>
-                <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification">prefix:netconf-notification-registry</type>
-                <instance>
-                    <name>netconf-notification-manager</name>
-                    <provider>/modules/module[type='netconf-notification-manager'][name='netconf-notification-manager']</provider>
-                </instance>
-            </service>
-        </services>
-
-    </data>
-  </configuration>
-  <required-capabilities>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:mapper?module=netconf-mdsal-mapper&amp;revision=2015-01-14</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring?module=netconf-mdsal-monitoring&amp;revision=2015-02-18</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh?module=netconf-northbound-ssh&amp;revision=2015-01-14</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:tcp?module=netconf-northbound-tcp&amp;revision=2015-04-23</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl?module=netconf-northbound-impl&amp;revision=2015-01-12</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:scheduled?module=threadpool-impl-scheduled&amp;revision=2013-12-01</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification?module=netconf-mdsal-notification&amp;revision=2015-08-03</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:yang:library?module=netconf-mdsal-yang-library&amp;revision=2016-06-17</capability>
-  </required-capabilities>
-</snapshot>
index b8161f0bc1c1af6da7a6134a4466638688d21786..35146e1f1029a5cec4e6b334a26b7ef0e273759f 100644 (file)
@@ -22,39 +22,28 @@ final class ThreadLocalTransformers {
     private static final ThreadLocal<Transformer> DEFAULT_TRANSFORMER = new ThreadLocal<Transformer>() {
         @Override
         protected Transformer initialValue() {
-            try {
-                return FACTORY.newTransformer();
-            } catch (TransformerConfigurationException | TransformerFactoryConfigurationError e) {
-                throw new IllegalStateException("Unexpected error while instantiating a Transformer", e);
-            }
-        };
+            return createTransformer();
+        }
 
         @Override
         public void set(final Transformer value) {
             throw new UnsupportedOperationException();
-        };
+        }
     };
 
     private static final ThreadLocal<Transformer> PRETTY_TRANSFORMER = new ThreadLocal<Transformer>() {
         @Override
         protected Transformer initialValue() {
-            final Transformer ret;
-
-            try {
-                ret = FACTORY.newTransformer();
-            } catch (TransformerConfigurationException | TransformerFactoryConfigurationError e) {
-                throw new IllegalStateException("Unexpected error while instantiating a Transformer", e);
-            }
-
+            final Transformer ret = createTransformer();
             ret.setOutputProperty(OutputKeys.INDENT, "yes");
             ret.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
             return ret;
-        };
+        }
 
         @Override
         public void set(final Transformer value) {
             throw new UnsupportedOperationException();
-        };
+        }
     };
 
     private ThreadLocalTransformers() {
@@ -66,7 +55,7 @@ final class ThreadLocalTransformers {
      *
      * @return A transformer with default configuration based on the default implementation.
      */
-    public static Transformer getDefaultTransformer() {
+    static Transformer getDefaultTransformer() {
         return DEFAULT_TRANSFORMER.get();
     }
 
@@ -76,7 +65,15 @@ final class ThreadLocalTransformers {
      *
      * @return A transformer with human-friendly configuration.
      */
-    public static Transformer getPrettyTransformer() {
+    static Transformer getPrettyTransformer() {
         return PRETTY_TRANSFORMER.get();
     }
+
+    private static Transformer createTransformer() {
+        try {
+            return FACTORY.newTransformer();
+        } catch (TransformerConfigurationException | TransformerFactoryConfigurationError e) {
+            throw new IllegalStateException("Unexpected error while instantiating a Transformer", e);
+        }
+    }
 }
diff --git a/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiatorTest.java b/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiatorTest.java
new file mode 100644 (file)
index 0000000..4da5b2c
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. 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
+ */
+
+package org.opendaylight.netconf.nettyutil;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.opendaylight.netconf.nettyutil.AbstractChannelInitializer.NETCONF_MESSAGE_AGGREGATOR;
+import static org.opendaylight.netconf.nettyutil.AbstractChannelInitializer.NETCONF_MESSAGE_FRAME_ENCODER;
+
+import com.google.common.base.Optional;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.channel.ChannelOutboundHandler;
+import io.netty.channel.ChannelOutboundHandlerAdapter;
+import io.netty.channel.embedded.EmbeddedChannel;
+import io.netty.handler.ssl.SslHandler;
+import io.netty.util.HashedWheelTimer;
+import io.netty.util.Timer;
+import io.netty.util.concurrent.Future;
+import io.netty.util.concurrent.Promise;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.netconf.api.NetconfDocumentedException;
+import org.opendaylight.netconf.api.NetconfSessionListener;
+import org.opendaylight.netconf.api.NetconfSessionPreferences;
+import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
+import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.nettyutil.handler.ChunkedFramingMechanismEncoder;
+import org.opendaylight.netconf.nettyutil.handler.EOMFramingMechanismEncoder;
+import org.opendaylight.netconf.nettyutil.handler.FramingMechanismHandlerFactory;
+import org.opendaylight.netconf.nettyutil.handler.NetconfChunkAggregator;
+import org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator;
+import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
+import org.opendaylight.netconf.util.messages.FramingMechanism;
+
+public class AbstractNetconfSessionNegotiatorTest {
+
+    @Mock
+    private NetconfSessionListener<TestingNetconfSession> listener;
+    @Mock
+    private Promise<TestingNetconfSession> promise;
+    @Mock
+    private SslHandler sslHandler;
+    private EmbeddedChannel channel;
+    private AbstractNetconfSessionNegotiator negotiator;
+    private NetconfHelloMessage hello;
+    private NetconfHelloMessage helloBase11;
+    private NetconfXMLToHelloMessageDecoder xmlToHello;
+    private NetconfSessionPreferences prefs;
+
+    @Before
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        channel = new EmbeddedChannel();
+        xmlToHello = new NetconfXMLToHelloMessageDecoder();
+        channel.pipeline().addLast(AbstractChannelInitializer.NETCONF_MESSAGE_ENCODER, new ChannelInboundHandlerAdapter());
+        channel.pipeline().addLast(AbstractChannelInitializer.NETCONF_MESSAGE_DECODER, xmlToHello);
+        channel.pipeline().addLast(NETCONF_MESSAGE_FRAME_ENCODER, FramingMechanismHandlerFactory.createHandler(FramingMechanism.EOM));
+        channel.pipeline().addLast(NETCONF_MESSAGE_AGGREGATOR, new NetconfEOMAggregator());
+        hello = NetconfHelloMessage.createClientHello(Collections.emptySet(), Optional.absent());
+        helloBase11 = NetconfHelloMessage.createClientHello(Collections.singleton(XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_1), Optional.absent());
+        prefs = new NetconfSessionPreferences(helloBase11);
+        doReturn(promise).when(promise).setFailure(any());
+        doReturn(promise).when(promise).setSuccess(any());
+        negotiator = new TestSessionNegotiator(prefs, promise, channel, new HashedWheelTimer(), listener, 100L);
+    }
+
+    @Test
+    public void testStartNegotiation() throws Exception {
+        negotiator.startNegotiation();
+        Assert.assertEquals(helloBase11, channel.readOutbound());
+    }
+
+    @Test
+    public void testStartNegotiationSsl() throws Exception {
+        doReturn(true).when(sslHandler).isSharable();
+        doNothing().when(sslHandler).handlerAdded(any());
+        doNothing().when(sslHandler).write(any(), any(), any());
+        final Future<EmbeddedChannel> handshakeFuture = channel.eventLoop().newSucceededFuture(channel);
+        doReturn(handshakeFuture).when(sslHandler).handshakeFuture();
+        channel.pipeline().addLast(sslHandler);
+        negotiator.startNegotiation();
+        verify(sslHandler, timeout(1000)).write(any(), eq(helloBase11), any());
+
+    }
+
+    @Test
+    public void testStartNegotiationNotEstablished() throws Exception {
+        final ChannelOutboundHandler closedDetector = Mockito.spy(new ChannelOutboundHandlerAdapter());
+        channel.pipeline().addLast("closedDetector", closedDetector);
+        doReturn(false).when(promise).isDone();
+        doReturn(false).when(promise).isCancelled();
+        negotiator.startNegotiation();
+        verify(closedDetector, timeout(2000)).close(any(), any());
+    }
+
+    @Test
+    public void testGetSessionPreferences() throws Exception {
+        Assert.assertEquals(prefs, negotiator.getSessionPreferences());
+    }
+
+    @Test
+    public void testGetSessionForHelloMessage() throws Exception {
+        negotiator.startNegotiation();
+        final AbstractNetconfSession session = negotiator.getSessionForHelloMessage(hello);
+        Assert.assertNotNull(session);
+        Assert.assertTrue(channel.pipeline().get(NETCONF_MESSAGE_AGGREGATOR) instanceof NetconfEOMAggregator);
+        Assert.assertTrue(channel.pipeline().get(NETCONF_MESSAGE_FRAME_ENCODER) instanceof EOMFramingMechanismEncoder);
+    }
+
+    @Test
+    public void testGetSessionForHelloMessageBase11() throws Exception {
+        negotiator.startNegotiation();
+        final AbstractNetconfSession session = negotiator.getSessionForHelloMessage(helloBase11);
+        Assert.assertNotNull(session);
+        Assert.assertTrue(channel.pipeline().get(NETCONF_MESSAGE_AGGREGATOR) instanceof NetconfChunkAggregator);
+        Assert.assertTrue(channel.pipeline().get(NETCONF_MESSAGE_FRAME_ENCODER) instanceof ChunkedFramingMechanismEncoder);
+    }
+
+    @Test
+    public void testReplaceHelloMessageInboundHandler() throws Exception {
+        final List<Object> out = new ArrayList<>();
+        final byte[] msg = "<rpc/>".getBytes();
+        final ByteBuf msgBuf = Unpooled.wrappedBuffer(msg);
+        final ByteBuf helloBuf = Unpooled.wrappedBuffer(XmlUtil.toString(hello.getDocument()).getBytes());
+        negotiator.startNegotiation();
+        xmlToHello.decode(null, helloBuf, out);
+        xmlToHello.decode(null, msgBuf, out);
+        final AbstractNetconfSession session = mock(AbstractNetconfSession.class);
+        doNothing().when(session).handleMessage(any());
+        negotiator.replaceHelloMessageInboundHandler(session);
+        verify(session, times(1)).handleMessage(any());
+    }
+
+    @Test
+    public void testNegotiationFail() throws Exception {
+        negotiator.startNegotiation();
+        final RuntimeException cause = new RuntimeException("failure cause");
+        channel.pipeline().fireExceptionCaught(cause);
+        verify(promise).setFailure(cause);
+    }
+
+    private static class TestSessionNegotiator extends
+            AbstractNetconfSessionNegotiator<NetconfSessionPreferences,
+                    TestingNetconfSession, NetconfSessionListener<TestingNetconfSession>> {
+
+
+        TestSessionNegotiator(final NetconfSessionPreferences sessionPreferences,
+                              final Promise<TestingNetconfSession> promise, final Channel channel,
+                              final Timer timer,
+                              final NetconfSessionListener<TestingNetconfSession> sessionListener,
+                              final long connectionTimeoutMillis) {
+            super(sessionPreferences, promise, channel, timer, sessionListener, connectionTimeoutMillis);
+        }
+
+        @Override
+        protected TestingNetconfSession getSession(final NetconfSessionListener sessionListener, final Channel channel,
+                                                   final NetconfHelloMessage message) throws NetconfDocumentedException {
+            return new TestingNetconfSession(sessionListener, channel, 0L);
+        }
+
+        @Override
+        protected void handleMessage(final NetconfHelloMessage netconfHelloMessage) throws Exception {
+
+        }
+    }
+
+
+}
\ No newline at end of file
index 5c2bb755b1befe22128f1e901b752476724a5b9e..8edfca9296bb7df336415822dc5622e6fd5af912 100644 (file)
@@ -38,18 +38,17 @@ import org.mockito.MockitoAnnotations;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.netconf.api.NetconfMessage;
-import org.opendaylight.netconf.api.NetconfSession;
 import org.opendaylight.netconf.api.NetconfSessionListener;
 import org.opendaylight.netconf.api.NetconfTerminationReason;
-import org.opendaylight.netconf.nettyutil.handler.exi.NetconfStartExiMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
+import org.opendaylight.netconf.nettyutil.handler.exi.NetconfStartExiMessage;
 import org.openexi.proc.common.EXIOptions;
 
 public class AbstractNetconfSessionTest {
 
     @Mock
-    private NetconfSessionListener<NetconfSession> listener;
+    private NetconfSessionListener<TestingNetconfSession> listener;
     @Mock
     private Channel channel;
     @Mock
@@ -64,10 +63,10 @@ public class AbstractNetconfSessionTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        doNothing().when(listener).onMessage(any(NetconfSession.class), any(NetconfMessage.class));
-        doNothing().when(listener).onSessionUp(any(NetconfSession.class));
-        doNothing().when(listener).onSessionDown(any(NetconfSession.class), any(Exception.class));
-        doNothing().when(listener).onSessionTerminated(any(NetconfSession.class), any(NetconfTerminationReason.class));
+        doNothing().when(listener).onMessage(any(TestingNetconfSession.class), any(NetconfMessage.class));
+        doNothing().when(listener).onSessionUp(any(TestingNetconfSession.class));
+        doNothing().when(listener).onSessionDown(any(TestingNetconfSession.class), any(Exception.class));
+        doNothing().when(listener).onSessionTerminated(any(TestingNetconfSession.class), any(NetconfTerminationReason.class));
 
         doReturn(writeFuture).when(writeFuture).addListener(any(GenericFutureListener.class));
 
@@ -81,7 +80,7 @@ public class AbstractNetconfSessionTest {
         doReturn(eventLoop).when(channel).eventLoop();
         doAnswer(new Answer<Void>() {
             @Override
-            public Void answer(InvocationOnMock invocation) throws Throwable {
+            public Void answer(final InvocationOnMock invocation) throws Throwable {
                 final Object[] args = invocation.getArguments();
                 final Runnable runnable = (Runnable) args[0];
                 runnable.run();
@@ -113,7 +112,7 @@ public class AbstractNetconfSessionTest {
         testingNetconfSession.sessionUp();
         testingNetconfSession.close();
         verify(channel).close();
-        verify(listener).onSessionTerminated(any(NetconfSession.class), any(NetconfTerminationReason.class));
+        verify(listener).onSessionTerminated(any(TestingNetconfSession.class), any(NetconfTerminationReason.class));
     }
 
     @Test
@@ -149,7 +148,7 @@ public class AbstractNetconfSessionTest {
         verifyZeroInteractions(listener);
         testingNetconfSession.sessionUp();
         testingNetconfSession.endOfInput();
-        verify(listener).onSessionDown(any(NetconfSession.class), any(Exception.class));
+        verify(listener).onSessionDown(any(TestingNetconfSession.class), any(Exception.class));
     }
 
     @Test
@@ -160,21 +159,4 @@ public class AbstractNetconfSessionTest {
         verify(channel).writeAndFlush(clientHello);
     }
 
-    private static class TestingNetconfSession extends AbstractNetconfSession<NetconfSession, NetconfSessionListener<NetconfSession>> {
-
-        protected TestingNetconfSession(final NetconfSessionListener<NetconfSession> sessionListener, final Channel channel, final long sessionId) {
-            super(sessionListener, channel, sessionId);
-        }
-
-        @Override
-        protected NetconfSession thisInstance() {
-            return this;
-        }
-
-        @Override
-        protected void addExiHandlers(final ByteToMessageDecoder decoder, final MessageToByteEncoder<NetconfMessage> encoder) {}
-
-        @Override
-        public void stopExiCommunication() {}
-    }
 }
\ No newline at end of file
diff --git a/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/TestingNetconfSession.java b/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/TestingNetconfSession.java
new file mode 100644 (file)
index 0000000..b7a1c6c
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. 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
+ */
+
+package org.opendaylight.netconf.nettyutil;
+
+import io.netty.channel.Channel;
+import io.netty.handler.codec.ByteToMessageDecoder;
+import io.netty.handler.codec.MessageToByteEncoder;
+import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.NetconfSessionListener;
+
+class TestingNetconfSession extends AbstractNetconfSession<TestingNetconfSession, NetconfSessionListener<TestingNetconfSession>> {
+
+    TestingNetconfSession(final NetconfSessionListener<TestingNetconfSession> sessionListener, final Channel channel, final long sessionId) {
+        super(sessionListener, channel, sessionId);
+    }
+
+    @Override
+    protected TestingNetconfSession thisInstance() {
+        return this;
+    }
+
+    @Override
+    protected void addExiHandlers(final ByteToMessageDecoder decoder, final MessageToByteEncoder<NetconfMessage> encoder) {
+    }
+
+    @Override
+    public void stopExiCommunication() {
+    }
+}
diff --git a/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/ThreadLocalTransformersTest.java b/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/ThreadLocalTransformersTest.java
new file mode 100644 (file)
index 0000000..456663b
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. 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
+ */
+
+package org.opendaylight.netconf.nettyutil.handler;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import javax.xml.transform.Transformer;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ThreadLocalTransformersTest {
+
+    private ExecutorService executorService;
+
+    @Before
+    public void setUp() throws Exception {
+        executorService = Executors.newSingleThreadExecutor();
+    }
+
+    @Test
+    public void testGetDefaultTransformer() throws Exception {
+        final Transformer t1 = ThreadLocalTransformers.getDefaultTransformer();
+        final Transformer t2 = ThreadLocalTransformers.getDefaultTransformer();
+        Assert.assertSame(t1, t2);
+        final Future<Transformer> future = executorService.submit(ThreadLocalTransformers::getDefaultTransformer);
+        Assert.assertNotSame(t1, future.get());
+    }
+
+    @Test
+    public void testGetPrettyTransformer() throws Exception {
+        final Transformer t1 = ThreadLocalTransformers.getPrettyTransformer();
+        final Transformer t2 = ThreadLocalTransformers.getPrettyTransformer();
+        Assert.assertSame(t1, t2);
+        final Future<Transformer> future = executorService.submit(ThreadLocalTransformers::getPrettyTransformer);
+        Assert.assertNotSame(t1, future.get());
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        executorService.shutdown();
+    }
+}
\ No newline at end of file
index fe0e09e8a787d6ca27777eec0c3d790dc3034bd3..f821a31dc88d83068de697dd0e276faa565338fe 100644 (file)
@@ -16,10 +16,14 @@ module netconf-northbound-notification {
     identity netconf-notification-collector {
             base "config:service-type";
             config:java-class "org.opendaylight.netconf.notifications.NetconfNotificationCollector";
+            config:disable-osgi-service-registration;
+            status deprecated;
         }
 
     identity netconf-notification-registry {
            base "config:service-type";
            config:java-class "org.opendaylight.netconf.notifications.NetconfNotificationRegistry";
+           config:disable-osgi-service-registration;
+           status deprecated;
     }
 }
\ No newline at end of file
diff --git a/netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModule.java b/netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModule.java
deleted file mode 100644 (file)
index d9dce4b..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.controller.config.yang.netconf.northbound.notification.impl;
-
-import org.opendaylight.netconf.notifications.impl.NetconfNotificationManager;
-
-public class NetconfNotificationManagerModule extends org.opendaylight.controller.config.yang.netconf.northbound.notification.impl.AbstractNetconfNotificationManagerModule {
-    public NetconfNotificationManagerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public NetconfNotificationManagerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.netconf.northbound.notification.impl.NetconfNotificationManagerModule oldModule, java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        return new NetconfNotificationManager();
-    }
-
-}
diff --git a/netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModuleFactory.java b/netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModuleFactory.java
deleted file mode 100644 (file)
index dadf756..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: netconf-northbound-notification-impl yang module local name: netconf-notification-manager
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Fri Aug 07 17:09:20 CEST 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.netconf.northbound.notification.impl;
-public class NetconfNotificationManagerModuleFactory extends org.opendaylight.controller.config.yang.netconf.northbound.notification.impl.AbstractNetconfNotificationManagerModuleFactory {
-
-}
diff --git a/netconf/netconf-notifications-impl/src/main/yang/netconf-northbound-notification-impl.yang b/netconf/netconf-notifications-impl/src/main/yang/netconf-northbound-notification-impl.yang
deleted file mode 100644 (file)
index 4b5fb35..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-module netconf-northbound-notification-impl {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification:impl";
-    prefix "nnnimpl";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import netconf-northbound-notification { prefix nnn; revision-date 2015-08-06; }
-
-    description
-        "This module contains the base YANG definitions for
-         netconf northbound notifications implementation";
-
-    revision "2015-08-07"{
-        description "Initial revision.";
-    }
-
-    identity netconf-notification-manager {
-        base config:module-type;
-        config:provided-service nnn:netconf-notification-collector;
-        config:provided-service nnn:netconf-notification-registry;
-        config:java-name-prefix NetconfNotificationManager;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case netconf-notification-manager {
-            when "/config:modules/config:module/config:type = 'netconf-notification-manager'";
-        }
-    }
-}
\ No newline at end of file
diff --git a/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/ssh/NetconfNorthboundSshModule.java b/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/ssh/NetconfNorthboundSshModule.java
deleted file mode 100644 (file)
index be457f9..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.controller.config.yang.netconf.northbound.ssh;
-
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.local.LocalAddress;
-import io.netty.util.concurrent.GenericFutureListener;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.UnknownHostException;
-import java.util.concurrent.Executors;
-import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
-import org.opendaylight.netconf.api.NetconfServerDispatcher;
-import org.opendaylight.netconf.ssh.SshProxyServer;
-import org.opendaylight.netconf.ssh.SshProxyServerConfigurationBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NetconfNorthboundSshModule extends org.opendaylight.controller.config.yang.netconf.northbound.ssh.AbstractNetconfNorthboundSshModule {
-
-    private static final Logger LOG = LoggerFactory.getLogger(NetconfNorthboundSshModule.class);
-
-    public NetconfNorthboundSshModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public NetconfNorthboundSshModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final org.opendaylight.controller.config.yang.netconf.northbound.ssh.NetconfNorthboundSshModule oldModule, final java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        final NetconfServerDispatcher dispatch = getDispatcherDependency();
-
-        final LocalAddress localAddress = new LocalAddress(getPort().toString());
-        final ChannelFuture localServer = dispatch.createLocalServer(localAddress);
-
-        final SshProxyServer sshProxyServer = new SshProxyServer(Executors.newScheduledThreadPool(1), getWorkerThreadGroupDependency(), getEventExecutorDependency());
-
-        final InetSocketAddress bindingAddress = getInetAddress();
-        final SshProxyServerConfigurationBuilder sshProxyServerConfigurationBuilder = new SshProxyServerConfigurationBuilder();
-        sshProxyServerConfigurationBuilder.setBindingAddress(bindingAddress);
-        sshProxyServerConfigurationBuilder.setLocalAddress(localAddress);
-        sshProxyServerConfigurationBuilder.setAuthenticator(getAuthProviderDependency());
-        sshProxyServerConfigurationBuilder.setIdleTimeout(Integer.MAX_VALUE);
-        sshProxyServerConfigurationBuilder.setKeyPairProvider(new PEMGeneratorHostKeyProvider());
-
-        localServer.addListener(new GenericFutureListener<ChannelFuture>() {
-
-            @Override
-            public void operationComplete(final ChannelFuture future) {
-                if(future.isDone() && !future.isCancelled()) {
-                    try {
-                        sshProxyServer.bind(sshProxyServerConfigurationBuilder.createSshProxyServerConfiguration());
-                        LOG.info("Netconf SSH endpoint started successfully at {}", bindingAddress);
-                    } catch (final IOException e) {
-                        throw new RuntimeException("Unable to start SSH netconf server", e);
-                    }
-                } else {
-                    LOG.warn("Unable to start SSH netconf server at {}", bindingAddress, future.cause());
-                    throw new RuntimeException("Unable to start SSH netconf server", future.cause());
-                }
-            }
-        });
-
-        return new NetconfServerCloseable(localServer, sshProxyServer);
-    }
-
-    private InetSocketAddress getInetAddress() {
-        try {
-            final InetAddress inetAd = InetAddress.getByName(getBindingAddress().getIpv4Address() == null ? getBindingAddress().getIpv6Address().getValue() : getBindingAddress().getIpv4Address().getValue());
-            return new InetSocketAddress(inetAd, getPort().getValue());
-        } catch (final UnknownHostException e) {
-            throw new IllegalArgumentException("Unable to bind netconf endpoint to address " + getBindingAddress(), e);
-        }
-    }
-
-    private static final class NetconfServerCloseable implements AutoCloseable {
-        private final ChannelFuture localServer;
-        private final SshProxyServer sshProxyServer;
-
-        public NetconfServerCloseable(final ChannelFuture localServer, final SshProxyServer sshProxyServer) {
-            this.localServer = localServer;
-            this.sshProxyServer = sshProxyServer;
-        }
-
-        @Override
-        public void close() throws Exception {
-            sshProxyServer.close();
-
-            if(localServer.isDone()) {
-                localServer.channel().close();
-            } else {
-                localServer.cancel(true);
-            }
-        }
-    }
-}
diff --git a/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/ssh/NetconfNorthboundSshModuleFactory.java b/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/ssh/NetconfNorthboundSshModuleFactory.java
deleted file mode 100644 (file)
index 88ad64b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: netconf-northbound-ssh yang module local name: netconf-northbound-ssh
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Mon Feb 09 14:09:07 CET 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.netconf.northbound.ssh;
-public class NetconfNorthboundSshModuleFactory extends org.opendaylight.controller.config.yang.netconf.northbound.ssh.AbstractNetconfNorthboundSshModuleFactory {
-
-}
diff --git a/netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/NetconfNorthboundSshServer.java b/netconf/netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/NetconfNorthboundSshServer.java
new file mode 100644 (file)
index 0000000..fca99e0
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2016 Inocybe Technologies 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
+ */
+package org.opendaylight.netconf.ssh;
+
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.local.LocalAddress;
+import io.netty.util.concurrent.EventExecutor;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
+import java.util.concurrent.Executors;
+import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
+import org.opendaylight.netconf.api.NetconfServerDispatcher;
+import org.opendaylight.netconf.auth.AuthProvider;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NetconfNorthboundSshServer {
+
+    private static final Logger LOG = LoggerFactory.getLogger(NetconfNorthboundSshServer.class);
+
+    private final ChannelFuture localServer;
+    private final SshProxyServer sshProxyServer;
+
+    public NetconfNorthboundSshServer(final NetconfServerDispatcher netconfServerDispatcher,
+                                      final EventLoopGroup workerGroup,
+                                      final EventExecutor eventExecutor,
+                                      final String bindingAddress,
+                                      final String portNumber,
+                                      final AuthProvider authProvider) {
+
+        final LocalAddress localAddress = new LocalAddress(portNumber);
+
+        localServer = netconfServerDispatcher.createLocalServer(localAddress);
+        sshProxyServer = new SshProxyServer(Executors.newScheduledThreadPool(1), workerGroup, eventExecutor);
+
+        final InetSocketAddress inetAddress = getInetAddress(bindingAddress, portNumber);
+        final SshProxyServerConfigurationBuilder sshProxyServerConfigurationBuilder = new SshProxyServerConfigurationBuilder();
+        sshProxyServerConfigurationBuilder.setBindingAddress(inetAddress);
+        sshProxyServerConfigurationBuilder.setLocalAddress(localAddress);
+        sshProxyServerConfigurationBuilder.setAuthenticator(authProvider);
+        sshProxyServerConfigurationBuilder.setIdleTimeout(Integer.MAX_VALUE);
+        sshProxyServerConfigurationBuilder.setKeyPairProvider(new PEMGeneratorHostKeyProvider());
+
+        localServer.addListener(future -> {
+            if (future.isDone() && !future.isCancelled()) {
+                try {
+                    sshProxyServer.bind(sshProxyServerConfigurationBuilder.createSshProxyServerConfiguration());
+                    LOG.info("Netconf SSH endpoint started successfully at {}", bindingAddress);
+                } catch (final IOException e) {
+                    throw new RuntimeException("Unable to start SSH netconf server", e);
+                }
+            } else {
+                LOG.warn("Unable to start SSH netconf server at {}", bindingAddress, future.cause());
+                throw new RuntimeException("Unable to start SSH netconf server", future.cause());
+            }
+        });
+    }
+
+    private InetSocketAddress getInetAddress(final String bindingAddress, final String portNumber) {
+        try {
+            IpAddress ipAddress= IpAddressBuilder.getDefaultInstance(bindingAddress);
+            final InetAddress inetAd = InetAddress.getByName(ipAddress.getIpv4Address() == null ? ipAddress.getIpv6Address().getValue() : ipAddress.getIpv4Address().getValue());
+            return new InetSocketAddress(inetAd, Integer.valueOf(portNumber));
+        } catch (final UnknownHostException e) {
+            throw new IllegalArgumentException("Unable to bind netconf endpoint to address " + bindingAddress, e);
+        }
+    }
+
+    public void close() {
+        sshProxyServer.close();
+
+        if (localServer.isDone()) {
+            localServer.channel().close();
+        } else {
+            localServer.cancel(true);
+        }
+    }
+}
diff --git a/netconf/netconf-ssh/src/main/yang/netconf-northbound-ssh.yang b/netconf/netconf-ssh/src/main/yang/netconf-northbound-ssh.yang
deleted file mode 100644 (file)
index 0f4da44..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-module netconf-northbound-ssh {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh";
-    prefix "nni";
-
-    import netconf-northbound-mapper { prefix nnm; revision-date 2015-01-14; }
-    import netconf-northbound { prefix nn; revision-date 2015-01-14; }
-    import config { prefix config; revision-date 2013-04-05; }
-    import threadpool {prefix th;}
-    import netty {prefix netty;}
-    import ietf-inet-types { prefix inet; revision-date 2013-07-15; }
-    import netconf-auth { prefix na; revision-date 2015-07-15; }
-
-    organization "Cisco Systems, Inc.";
-
-    description
-        "This module contains the base YANG definitions for
-         a default implementation of netconf northbound server";
-
-    revision "2015-01-14" {
-        description
-            "Initial revision.";
-    }
-
-    identity netconf-northbound-ssh {
-        base config:module-type;
-        config:java-name-prefix NetconfNorthboundSsh;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case netconf-northbound-ssh {
-            when "/config:modules/config:module/config:type = 'netconf-northbound-ssh'";
-
-            leaf port {
-                type inet:port-number;
-                default 2830;
-            }
-
-            leaf binding-address {
-                type inet:ip-address;
-                default "0.0.0.0";
-            }
-
-            container processing-executor {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity th:scheduled-threadpool;
-                    }
-                }
-
-                description "Required by the mina-ssh library used in SSH endpoint";
-            }
-
-            container event-executor {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity netty:netty-event-executor;
-                    }
-                }
-            }
-
-            container worker-thread-group {
-                uses config:service-ref {
-                    refine type {
-                        config:required-identity netty:netty-threadgroup;
-                    }
-                }
-            }
-
-            container dispatcher {
-                uses config:service-ref {
-                    refine type {
-                        config:required-identity nn:netconf-server-dispatcher;
-                    }
-                }
-            }
-
-            container auth-provider {
-                uses config:service-ref {
-                    refine type {
-                        config:required-identity na:netconf-auth-provider;
-                    }
-                }
-            }
-
-        }
-    }
-
-}
index 33680f2dfc2701212e17ae068b54a82f04528d74..356b3bf705d7decb20887922211cf679ae059145 100644 (file)
@@ -152,18 +152,18 @@ public class NetconfMasterDOMTransaction implements NetconfDOMTransaction {
         LOG.trace("{}: Submit[{}} via NETCONF", id, writeTx.getIdentifier());
 
         final CheckedFuture<Void, TransactionCommitFailedException> submitFuture = writeTx.submit();
+        writeTx = null;
+
         final DefaultPromise<Void> promise = new DefaultPromise<>();
         Futures.addCallback(submitFuture, new FutureCallback<Void>() {
             @Override
             public void onSuccess(final Void result) {
                 promise.success(result);
-                writeTx = null;
             }
 
             @Override
             public void onFailure(@Nonnull final Throwable throwable) {
                 promise.failure(throwable);
-                writeTx = null;
             }
         });
         return promise.future();
index f0839ae945f914aabd912ff2b405decab5aec4f9..5ffd6d8d37aa1c1df9ad5bd54bc24cd0cf3537e5 100644 (file)
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>mdsal-binding-generator-impl</artifactId>
         </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>netconf-config-dispatcher</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal-core-api</artifactId>
diff --git a/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfTopologyPathCreator.java b/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfTopologyPathCreator.java
deleted file mode 100644 (file)
index 1a16eca..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.netconf.util;
-
-public class NetconfTopologyPathCreator {
-
-    public static final String CLUSTERED_DEVICE_SOURCES_RESOLVER = "clusteredDeviceSourcesResolver";
-    public static final String MASTER_SOURCE_PROVIDER
-            = "masterSourceProvider";
-
-    private static final String USER = "/user/";
-
-    private String mainPath;
-
-    public NetconfTopologyPathCreator(final String topologyId) {
-        mainPath = createMainPath("", topologyId);
-    }
-
-    public NetconfTopologyPathCreator(final String memberAddress, final String topologyId) {
-        mainPath = createMainPath(memberAddress, topologyId);
-    }
-
-    private String createMainPath(final String memberAddress, final String topologyId) {
-        return memberAddress + USER + topologyId;
-    }
-
-    public NetconfTopologyPathCreator withSuffix(final String suffix) {
-        mainPath += "/"+suffix;
-        return this;
-    }
-
-    public String build(){
-        return mainPath;
-    }
-
-}
diff --git a/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/xml/XmlNetconfValidator.java b/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/xml/XmlNetconfValidator.java
deleted file mode 100644 (file)
index eeb9126..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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
- */
-
-package org.opendaylight.netconf.util.xml;
-
-import com.google.common.base.Preconditions;
-import java.io.IOException;
-import java.io.InputStream;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.Validator;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-public final class XmlNetconfValidator {
-
-    private static final Schema SCHEMA;
-
-    private XmlNetconfValidator() {}
-
-    static {
-        final InputStream xmlSchema = XmlNetconfValidator.class.getResourceAsStream("/xml.xsd");
-        Preconditions.checkNotNull(xmlSchema, "Cannot find xml.xsd");
-
-        final InputStream rfc4714Schema = XmlNetconfValidator.class.getResourceAsStream("/rfc4741.xsd");
-        Preconditions.checkNotNull(rfc4714Schema, "Cannot find rfc4741.xsd");
-        SCHEMA = XmlUtil.loadSchema(xmlSchema, rfc4714Schema);
-    }
-
-    public static void validate(Document inputDocument) throws SAXException, IOException {
-        final Validator validator = SCHEMA.newValidator();
-        final Source source = new DOMSource(inputDocument);
-        validator.validate(source);
-    }
-}
index 098002b3b0713d6c8e31d14546745ad719541b08..4f5ca39acc925a5f282188a34cb4c002de67b588 100644 (file)
@@ -11,20 +11,75 @@ import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
+import java.util.Collections;
+import javax.xml.transform.dom.DOMResult;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.Assert;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.$YangModuleInfoImpl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Sessions;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
+import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.w3c.dom.Document;
 
 public class NetconfUtilTest {
 
+    @BeforeClass
+    public static void classSetUp() {
+        XMLUnit.setIgnoreWhitespace(true);
+    }
+
     @Test
     public void testConflictingVersionDetection() throws Exception {
-        Document document = XmlUtil.readXmlToDocument(getClass().getResourceAsStream("/netconfMessages/conflictingversion/conflictingVersionResponse.xml"));
+        final Document document = XmlUtil.readXmlToDocument(getClass().getResourceAsStream("/netconfMessages/conflictingversion/conflictingVersionResponse.xml"));
         try{
             NetconfUtil.checkIsMessageOk(document);
             fail();
-        }catch(IllegalStateException e){
+        } catch (final IllegalStateException e) {
             assertThat(e.getMessage(), containsString("Optimistic lock failed. Expected parent version 21, was 18"));
         }
     }
+
+    @Test
+    public void testWriteNormalizedNode() throws Exception {
+        final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
+        moduleInfoBackedContext.addModuleInfos(Collections.singletonList($YangModuleInfoImpl.getInstance()));
+        final SchemaContext context = moduleInfoBackedContext.getSchemaContext();
+        final LeafNode username = Builders.leafBuilder()
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(Session.QNAME, "username")))
+                .withValue("admin")
+                .build();
+        final MapEntryNode session1 = Builders.mapEntryBuilder()
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifierWithPredicates(Session.QNAME, QName.create(Session.QNAME, "session-id"), 1L))
+                .withChild(username)
+                .build();
+        final MapNode sessionList = Builders.mapBuilder()
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(Session.QNAME))
+                .withChild(session1)
+                .build();
+        final ContainerNode sessions = Builders.containerBuilder()
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(Sessions.QNAME))
+                .withChild(sessionList)
+                .build();
+        final DOMResult result = new DOMResult(XmlUtil.newDocument());
+        final SchemaPath path = SchemaPath.create(true, NetconfState.QNAME);
+        NetconfUtil.writeNormalizedNode(sessions, result, path, context);
+        final Document expected = XmlUtil.readXmlToDocument(getClass().getResourceAsStream("/sessions.xml"));
+        final Document actual = (Document) result.getNode();
+        final Diff diff = XMLUnit.compareXML(expected, actual);
+        Assert.assertTrue(diff.toString(), diff.similar());
+    }
 }
diff --git a/netconf/netconf-util/src/test/resources/sessions.xml b/netconf/netconf-util/src/test/resources/sessions.xml
new file mode 100644 (file)
index 0000000..398b537
--- /dev/null
@@ -0,0 +1,14 @@
+<!--
+  ~ Copyright (c) 2016 Cisco Systems, Inc. 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
+  -->
+
+<sessions xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
+    <session>
+        <session-id>1</session-id>
+        <username>admin</username>
+    </session>
+</sessions>
\ No newline at end of file
index 925488cc637dd78e57a7df7336610a538a216089..56887d08f41418af8e9fcefbd7bda2980d5fd49d 100644 (file)
     <module>netconf-config</module>
     <module>netconf-impl</module>
     <module>config-netconf-connector</module>
+    <module>mdsal-netconf-ssh</module>
     <module>mdsal-netconf-connector</module>
     <module>mdsal-netconf-monitoring</module>
     <module>mdsal-netconf-notification</module>
     <module>mdsal-netconf-yang-library</module>
+    <module>mdsal-netconf-impl</module>
     <module>netconf-util</module>
     <module>netconf-netty-util</module>
     <module>netconf-mapping-api</module>
     <module>netconf-client</module>
+    <!--TODO Delete netconf-config-dispatcher bundle as soon as https://git.opendaylight.org/gerrit/#/c/46621/ is merged.-->
     <module>netconf-config-dispatcher</module>
     <module>netconf-ssh</module>
     <module>netconf-tcp</module>
     <module>netconf-monitoring</module>
     <module>netconf-connector-config</module>
-    <module>netconf-mdsal-config</module>
     <module>netconf-auth</module>
     <module>aaa-authn-odl-plugin</module>
     <module>netconf-notifications-impl</module>
index 9adcf03eb64f716cc55dd7b152132a5d7b9c3b2a..6129d4050ff8b3a96fa21f91d37ede0bf2fb3650 100644 (file)
   </dependencyManagement>
 
   <dependencies>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>netconf-config-dispatcher</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-common-util</artifactId>