<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>
<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">
<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>
<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>
<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>
<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'
return true;
}
+ /**
+ * Invoke by blueprint
+ */
@Override
- public void close() throws Exception {
+ public void close() {
listenerTracker.close();
nullableCredService = null;
}
+++ /dev/null
-/*
- * 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);
- }
-
-}
+++ /dev/null
-/*
- * 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));
- }
-}
--- /dev/null
+<?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
+++ /dev/null
-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
- }
- }
-}
+++ /dev/null
-/*
- * 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;
- }
-
-}
+++ /dev/null
-/*
- * 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 {
-
-}
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;
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
}
@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
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();
- }
}
--- /dev/null
+<?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>
+++ /dev/null
-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;
- }
- }
- }
- }
- }
-
-}
--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+/*
+ * 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
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;
/**
* 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);
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)));
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);
}
+++ /dev/null
-/*
- * 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
- }
- }
-}
+++ /dev/null
-/*
- * 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 {
-
-}
--- /dev/null
+<?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>
+++ /dev/null
-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;
- }
- }
- }
- }
- }
-
-}
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;
@Mock
private NetconfMonitoringService monitoring;
@Mock
- private BindingAwareBroker.ProviderContext context;
- @Mock
private DataBroker dataBroker;
@Mock
private WriteTransaction writeTransaction;
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);
@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);
@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);
.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);
.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);
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);
@Test
public void testOnSessionInitiated() throws Exception {
- writer.onSessionInitiated(context);
+ writer.start();
verify(monitoring).registerCapabilitiesListener(writer);
}
}
\ No newline at end of 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>
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;
* 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
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();
+ }
+ }
}
+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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 {
-
-}
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;
* 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
notificationRegistration.close();
}
- @Override
- public void onSessionInitiated(BindingAwareBroker.ProviderContext session) {
- dataBroker = session.getSALService(DataBroker.class);
+ /**
+ * Invoke by blueprint
+ */
+ public void start() {
notificationRegistration = netconfNotificationCollector.registerStreamListener(this);
}
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;
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;
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
baseNotificationPublisherRegistration.onSessionEnded(sessionEnd);
}
+
+ /**
+ * Invoke by blueprint
+ */
+ public void close() {
+ if (baseNotificationPublisherRegistration != null) {
+ baseNotificationPublisherRegistration.close();
+ }
+ if (sessionListenerRegistration != null) {
+ sessionListenerRegistration.close();
+ }
+ }
}
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
@Override
public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
- return AUTO_CLOSEABLE;
+ return NoopAutoCloseable.INSTANCE;
}
@Override
public void close() {
+ this.netconfOperationServiceFactoryListener.onRemoveNetconfOperationServiceFactory(this);
}
}
--- /dev/null
+<?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>
+++ /dev/null
-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
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;
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
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
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
--- /dev/null
+<?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>
--- /dev/null
+<?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>
+++ /dev/null
-/*
- * 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;
- }
-
-}
+++ /dev/null
-/*
- * 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 {
-
-}
* 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);
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);
}
// 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);
}
--- /dev/null
+<?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>
+++ /dev/null
-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
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()));
<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>
+++ /dev/null
-/*
- * 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());
- }
-
-}
+++ /dev/null
-/*
- * 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 {
-
-}
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;
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,
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);
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;
}
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;
+++ /dev/null
-<?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&revision=2015-07-28</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:messagebus:spi:eventsourceregistry?module=messagebus-event-source-registry&revision=2015-04-02</capability>
- </required-capabilities>
-</snapshot>
--- /dev/null
+<?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
+++ /dev/null
-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
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;
AsyncDataChangeEvent asyncDataChangeEventMock;
RpcProviderRegistry rpcProviderRegistryMock;
EventSourceRegistry eventSourceRegistry;
+
@BeforeClass
public static void initTestClass() throws IllegalAccessException, InstantiationException {
}
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(
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
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
<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>
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
<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>
--- /dev/null
+/*
+ * 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 {
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+<?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>
--- /dev/null
+// 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
--- /dev/null
+// 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
<capability>urn:ietf:params:xml:ns:yang:ietf-network-topology?module=ietf-network-topology&revision=2015-06-08</capability>
<capability>urn:ietf:params:xml:ns:yang:ietf-netconf-notifications?module=ietf-netconf-notifications&revision=2012-02-06</capability>
<capability>urn:TBD:params:xml:ns:yang:ospf-topology?module=ospf-topology&revision=2013-10-21</capability>
- <capability>config:aaa:authn:netconf:plugin?module=aaa-authn-netconf-plugin&revision=2015-07-15</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:config:netconf:auth?module=netconf-auth&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&revision=2014-06-17</capability>
<capability>urn:ietf:params:xml:ns:yang:ospf-topology?module=ospf-topology&revision=2013-07-12</capability>
-->
<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>
+++ /dev/null
-/*
- * 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());
- }
-}
+++ /dev/null
-/*
- * 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
-{
-
-
-}
// 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";
}
identity netconf-client-dispatcher {
-
base "config:service-type";
config:java-class "org.opendaylight.netconf.client.NetconfClientDispatcher";
}
// 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";
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;
- }
- }
- }
}
}
+++ /dev/null
-/*
- * 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;
- }
-}
<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 -->
+++ /dev/null
-<?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&revision=2016-03-23</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&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
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(
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 {
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;
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;
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;
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);
+++ /dev/null
-/*
- * 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();
- }
-}
+++ /dev/null
-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;
- }
-}
+++ /dev/null
-/*
-* 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 {
-
-}
+++ /dev/null
-<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
--- /dev/null
+<?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>
+++ /dev/null
-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
bindingToNormalized.onGlobalContextUpdated(schemaContext);
dataBroker = new BindingDOMDataBrokerAdapter(cDOMDataBroker, bindingToNormalized);
- final MountPointService mountPointService = mock(MountPointService.class);
- netconfCommands = new NetconfCommandsImpl(dataBroker, mountPointService);
+ netconfCommands = new NetconfCommandsImpl(dataBroker);
}
@Test
+++ /dev/null
-/*
- * 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));
-
- }
-}
+++ /dev/null
-/*
- * 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();
- }
-
-}
+++ /dev/null
-/*
- * 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 {
-
-}
+++ /dev/null
-/*
- * 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;
- }
-
-
-}
+++ /dev/null
-/*
- * 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 {
-
-}
+++ /dev/null
-/*
- * 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());
- }
-
-}
+++ /dev/null
-/*
- * 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 {
-
-}
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;
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;
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) {
}
@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());
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;
}
};
- 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) {
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) {
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;
+++ /dev/null
-// 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
--- /dev/null
+/*
+ * 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" +
+ "<bad-rpc/>\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
--- /dev/null
+/*
+ * 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
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
+++ /dev/null
-<?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>
+++ /dev/null
-<?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&revision=2015-01-14</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring?module=netconf-mdsal-monitoring&revision=2015-02-18</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh?module=netconf-northbound-ssh&revision=2015-01-14</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:tcp?module=netconf-northbound-tcp&revision=2015-04-23</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl?module=netconf-northbound-impl&revision=2015-01-12</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:scheduled?module=threadpool-impl-scheduled&revision=2013-12-01</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification?module=netconf-mdsal-notification&revision=2015-08-03</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:yang:library?module=netconf-mdsal-yang-library&revision=2016-06-17</capability>
- </required-capabilities>
-</snapshot>
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() {
*
* @return A transformer with default configuration based on the default implementation.
*/
- public static Transformer getDefaultTransformer() {
+ static Transformer getDefaultTransformer() {
return DEFAULT_TRANSFORMER.get();
}
*
* @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);
+ }
+ }
}
--- /dev/null
+/*
+ * 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
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
@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));
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();
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
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
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
--- /dev/null
+/*
+ * 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() {
+ }
+}
--- /dev/null
+/*
+ * 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
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
+++ /dev/null
-/*
- * 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();
- }
-
-}
+++ /dev/null
-/*
- * 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 {
-
-}
+++ /dev/null
-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
+++ /dev/null
-/*
- * 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);
- }
- }
- }
-}
+++ /dev/null
-/*
- * 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 {
-
-}
--- /dev/null
+/*
+ * 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);
+ }
+ }
+}
+++ /dev/null
-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;
- }
- }
- }
-
- }
- }
-
-}
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();
<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>
+++ /dev/null
-/*
- * 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;
- }
-
-}
+++ /dev/null
-/*
- * 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);
- }
-}
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());
+ }
}
--- /dev/null
+<!--
+ ~ 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
<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>
</dependencyManagement>
<dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-config-dispatcher</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-common-util</artifactId>