From f1403325f2d498678a711590b0d1b7b088727275 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20de=20Talhou=C3=ABt?= Date: Wed, 2 Nov 2016 16:26:15 -0400 Subject: [PATCH] Add blueprint wiring for netconf-topology MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch also moves api interface under the api package. So api and impl are seperated, package-wise Change-Id: Id80290e108b30e524f985044c66a1bea057c24c5 Signed-off-by: Alexis de Talhouët --- features/netconf-connector/pom.xml | 3 - .../src/main/features/features.xml | 2 +- netconf/netconf-artifacts/pom.xml | 2 - netconf/netconf-topology-config/pom.xml | 53 +++++---- .../resources/initial/02-netconf-topology.xml | 63 ---------- .../blueprint/netconf-topology.xml | 51 ++++++++ .../topology/NetconfTopologyModule.java | 35 ------ .../NetconfTopologyModuleFactory.java | 21 ---- .../SchemaRepositoryImplModule.java | 51 -------- .../SchemaRepositoryImplModuleFactory.java | 36 ------ .../topology/AbstractNetconfTopology.java | 37 ++---- .../topology/{ => api}/NetconfTopology.java | 2 +- .../{ => api}/SchemaRepositoryProvider.java | 2 +- .../topology/impl/NetconfTopologyImpl.java | 20 ++-- .../impl/SchemaRepositoryProviderImpl.java | 25 ++++ .../src/main/yang/netconf-topology.yang | 111 ------------------ .../main/yang/shared-schema-repository.yang | 41 ------- .../impl/NetconfTopologyImplTest.java | 27 +++-- 18 files changed, 146 insertions(+), 436 deletions(-) delete mode 100644 netconf/netconf-topology-config/src/main/resources/initial/02-netconf-topology.xml create mode 100755 netconf/netconf-topology-config/src/main/resources/org/opendaylight/blueprint/netconf-topology.xml delete mode 100644 netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/NetconfTopologyModule.java delete mode 100644 netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/NetconfTopologyModuleFactory.java delete mode 100644 netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/shared/schema/repository/SchemaRepositoryImplModule.java delete mode 100644 netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/shared/schema/repository/SchemaRepositoryImplModuleFactory.java rename netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/{ => api}/NetconfTopology.java (94%) rename netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/{ => api}/SchemaRepositoryProvider.java (91%) create mode 100644 netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/impl/SchemaRepositoryProviderImpl.java delete mode 100644 netconf/netconf-topology/src/main/yang/netconf-topology.yang delete mode 100644 netconf/netconf-topology/src/main/yang/shared-schema-repository.yang diff --git a/features/netconf-connector/pom.xml b/features/netconf-connector/pom.xml index 681047f660..ecd3e5abe6 100644 --- a/features/netconf-connector/pom.xml +++ b/features/netconf-connector/pom.xml @@ -34,7 +34,6 @@ features.xml etc/opendaylight/karaf 01-netconf.xml - 02-netconf-topology.xml 99-netconf-connector.xml @@ -100,8 +99,6 @@ ${project.groupId} netconf-topology-config - config - xml ${project.groupId} diff --git a/features/netconf-connector/src/main/features/features.xml b/features/netconf-connector/src/main/features/features.xml index 10fbb4f03a..a911dcf565 100644 --- a/features/netconf-connector/src/main/features/features.xml +++ b/features/netconf-connector/src/main/features/features.xml @@ -49,7 +49,7 @@ odl-netconf-ssh odl-netconf-connector - mvn:org.opendaylight.netconf/netconf-topology-config/{{VERSION}}/xml/config + mvn:org.opendaylight.netconf/netconf-topology-config/{{VERSION}} diff --git a/netconf/netconf-artifacts/pom.xml b/netconf/netconf-artifacts/pom.xml index a2c0ee79e1..32bcf637d3 100644 --- a/netconf/netconf-artifacts/pom.xml +++ b/netconf/netconf-artifacts/pom.xml @@ -233,8 +233,6 @@ ${project.groupId} netconf-topology-config ${project.version} - config - xml ${project.groupId} diff --git a/netconf/netconf-topology-config/pom.xml b/netconf/netconf-topology-config/pom.xml index 75113816f3..2a0e0d982d 100644 --- a/netconf/netconf-topology-config/pom.xml +++ b/netconf/netconf-topology-config/pom.xml @@ -13,7 +13,7 @@ org.opendaylight.odlparent - odlparent-lite + bundle-parent 1.8.0-SNAPSHOT @@ -22,33 +22,40 @@ netconf-topology-config 1.2.0-SNAPSHOT Configuration files for netconf topology - jar + bundle + + + + + org.opendaylight.netconf + netconf-subsystem + ${project.version} + pom + import + + + + + + + ${project.groupId} + netconf-topology + + - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/initial/02-netconf-topology.xml - xml - config - - - - - + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + netconf-topology + + - diff --git a/netconf/netconf-topology-config/src/main/resources/initial/02-netconf-topology.xml b/netconf/netconf-topology-config/src/main/resources/initial/02-netconf-topology.xml deleted file mode 100644 index 27e061781c..0000000000 --- a/netconf/netconf-topology-config/src/main/resources/initial/02-netconf-topology.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - prefix:netconf-topology-impl - default-netconf-topology - topology-netconf - - prefix:netty-event-executor - global-event-executor - - - prefix:binding-broker-osgi-registry - binding-osgi-broker - - - prefix:dom-broker-osgi-registry - dom-broker - - - prefix:netconf-client-dispatcher - global-netconf-dispatcher - - - prefix:threadpool - global-netconf-processing-executor - - - prefix:scheduled-threadpool - global-netconf-ssh-scheduled-executor - - - prefix:shared-schema-repository - default-shared-schema-repository - - - - - - - prefix:netconf-topology - - default-netconf-topology - /modules/module[type='netconf-topology-impl'][name='default-netconf-topology'] - - - - - - - urn:opendaylight:params:xml:ns:yang:controller:netconf:topology?module=netconf-topology&revision=2015-07-27 - - \ No newline at end of file diff --git a/netconf/netconf-topology-config/src/main/resources/org/opendaylight/blueprint/netconf-topology.xml b/netconf/netconf-topology-config/src/main/resources/org/opendaylight/blueprint/netconf-topology.xml new file mode 100755 index 0000000000..cf04017727 --- /dev/null +++ b/netconf/netconf-topology-config/src/main/resources/org/opendaylight/blueprint/netconf-topology.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/NetconfTopologyModule.java b/netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/NetconfTopologyModule.java deleted file mode 100644 index e4321b7898..0000000000 --- a/netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/NetconfTopologyModule.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.config.yang.netconf.topology; - -import org.opendaylight.netconf.topology.impl.NetconfTopologyImpl; - -public class NetconfTopologyModule extends org.opendaylight.controller.config.yang.netconf.topology.AbstractNetconfTopologyModule { - public NetconfTopologyModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public NetconfTopologyModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.netconf.topology.NetconfTopologyModule oldModule, AutoCloseable oldInstance) { - super(identifier, dependencyResolver, oldModule, oldInstance); - } - - @Override - public void customValidation() { - // add custom validation form module attributes here. - this.getClientDispatcherDependency(); - } - - @Override - public AutoCloseable createInstance() { - return new NetconfTopologyImpl(getTopologyId(), getClientDispatcherDependency(), getBindingRegistryDependency(), - getDomRegistryDependency(), getEventExecutorDependency(), getKeepaliveExecutorDependency(), - getProcessingExecutorDependency(), getSharedSchemaRepositoryDependency()); - } - -} diff --git a/netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/NetconfTopologyModuleFactory.java b/netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/NetconfTopologyModuleFactory.java deleted file mode 100644 index f8dd1991de..0000000000 --- a/netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/NetconfTopologyModuleFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -/* -* Generated file -* -* Generated from: yang module name: netconf-topology yang module local name: netconf-topology-impl -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Tue Jul 28 15:33:44 CEST 2015 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.controller.config.yang.netconf.topology; - -public class NetconfTopologyModuleFactory extends org.opendaylight.controller.config.yang.netconf.topology.AbstractNetconfTopologyModuleFactory { - -} diff --git a/netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/shared/schema/repository/SchemaRepositoryImplModule.java b/netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/shared/schema/repository/SchemaRepositoryImplModule.java deleted file mode 100644 index c4f5f98820..0000000000 --- a/netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/shared/schema/repository/SchemaRepositoryImplModule.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.config.yang.netconf.topology.shared.schema.repository; - -import org.opendaylight.netconf.topology.SchemaRepositoryProvider; -import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository; - -public class SchemaRepositoryImplModule extends org.opendaylight.controller.config.yang.netconf.topology.shared.schema.repository.AbstractSchemaRepositoryImplModule { - public SchemaRepositoryImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public SchemaRepositoryImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.netconf.topology.shared.schema.repository.SchemaRepositoryImplModule 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 SchemaRepositoryProviderAutoCloseAble(this); - } - - private static class SchemaRepositoryProviderAutoCloseAble implements SchemaRepositoryProvider, AutoCloseable { - - private final SharedSchemaRepository schemaRepository; - - public SchemaRepositoryProviderAutoCloseAble(SchemaRepositoryImplModule module) { - schemaRepository = new SharedSchemaRepository(module.getIdentifier().getInstanceName()); - } - - @Override - public void close() throws Exception { - //NOOP - } - - @Override - public SharedSchemaRepository getSharedSchemaRepository() { - return schemaRepository; - } - } -} diff --git a/netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/shared/schema/repository/SchemaRepositoryImplModuleFactory.java b/netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/shared/schema/repository/SchemaRepositoryImplModuleFactory.java deleted file mode 100644 index 9cf6e1cc6a..0000000000 --- a/netconf/netconf-topology/src/main/java/org/opendaylight/controller/config/yang/netconf/topology/shared/schema/repository/SchemaRepositoryImplModuleFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -/* -* Generated file -* -* Generated from: yang module name: shared-schema-repository yang module local name: shared-schema-repository-impl -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Tue Sep 08 13:43:39 CEST 2015 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.controller.config.yang.netconf.topology.shared.schema.repository; - -import com.google.common.collect.Sets; -import java.util.Set; -import org.opendaylight.controller.config.api.DependencyResolverFactory; -import org.opendaylight.controller.config.api.ModuleIdentifier; -import org.osgi.framework.BundleContext; - -public class SchemaRepositoryImplModuleFactory extends org.opendaylight.controller.config.yang.netconf.topology.shared.schema.repository.AbstractSchemaRepositoryImplModuleFactory { - - public static final ModuleIdentifier defaultInstanceId = new ModuleIdentifier(NAME, "default-shared-schema-repository"); - - @Override - public Set getDefaultModules(DependencyResolverFactory dependencyResolverFactory, BundleContext bundleContext) { - SchemaRepositoryImplModule defaultModule = new SchemaRepositoryImplModule( - defaultInstanceId, dependencyResolverFactory.createDependencyResolver(defaultInstanceId)); - return Sets.newHashSet(defaultModule); - } -} diff --git a/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java b/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java index 7174c53be5..997d6cb011 100644 --- a/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java +++ b/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java @@ -20,8 +20,6 @@ import java.io.File; import java.math.BigDecimal; import java.net.InetSocketAddress; import java.net.URL; -import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -30,11 +28,7 @@ import org.opendaylight.controller.config.threadpool.ThreadPool; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; import org.opendaylight.controller.sal.core.api.Broker; -import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; -import org.opendaylight.controller.sal.core.api.Provider; import org.opendaylight.netconf.api.NetconfMessage; import org.opendaylight.netconf.client.NetconfClientDispatcher; import org.opendaylight.netconf.client.NetconfClientSessionListener; @@ -57,6 +51,8 @@ import org.opendaylight.netconf.sal.connect.netconf.listener.UserPreferences; import org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade; import org.opendaylight.netconf.sal.connect.netconf.schema.YangLibrarySchemaYangSourceProvider; import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; +import org.opendaylight.netconf.topology.api.NetconfTopology; +import org.opendaylight.netconf.topology.api.SchemaRepositoryProvider; import org.opendaylight.protocol.framework.ReconnectStrategy; import org.opendaylight.protocol.framework.ReconnectStrategyFactory; import org.opendaylight.protocol.framework.TimedReconnectStrategy; @@ -81,7 +77,7 @@ import org.opendaylight.yangtools.yang.parser.util.TextToASTTransformer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class AbstractNetconfTopology implements NetconfTopology, BindingAwareProvider, Provider { +public abstract class AbstractNetconfTopology implements NetconfTopology { private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfTopology.class); @@ -164,19 +160,20 @@ public abstract class AbstractNetconfTopology implements NetconfTopology, Bindin protected final ScheduledThreadPool keepaliveExecutor; protected final ThreadPool processingExecutor; protected final SharedSchemaRepository sharedSchemaRepository; + protected final DataBroker dataBroker; + protected final DOMMountPointService mountPointService; protected SchemaSourceRegistry schemaRegistry = DEFAULT_SCHEMA_REPOSITORY; protected SchemaRepository schemaRepository = DEFAULT_SCHEMA_REPOSITORY; protected SchemaContextFactory schemaContextFactory = DEFAULT_SCHEMA_CONTEXT_FACTORY; - protected DOMMountPointService mountPointService = null; - protected DataBroker dataBroker = null; protected final HashMap activeConnectors = new HashMap<>(); protected AbstractNetconfTopology(final String topologyId, final NetconfClientDispatcher clientDispatcher, final BindingAwareBroker bindingAwareBroker, final Broker domBroker, final EventExecutor eventExecutor, final ScheduledThreadPool keepaliveExecutor, - final ThreadPool processingExecutor, final SchemaRepositoryProvider schemaRepositoryProvider) { + final ThreadPool processingExecutor, final SchemaRepositoryProvider schemaRepositoryProvider, + final DataBroker dataBroker, final DOMMountPointService mountPointService) { this.topologyId = topologyId; this.clientDispatcher = clientDispatcher; this.bindingAwareBroker = bindingAwareBroker; @@ -185,11 +182,8 @@ public abstract class AbstractNetconfTopology implements NetconfTopology, Bindin this.keepaliveExecutor = keepaliveExecutor; this.processingExecutor = processingExecutor; this.sharedSchemaRepository = schemaRepositoryProvider.getSharedSchemaRepository(); - } - - protected void registerToSal(BindingAwareProvider baProvider, Provider provider) { - domBroker.registerProvider(provider); - bindingAwareBroker.registerProvider(baProvider); + this.dataBroker = dataBroker; + this.mountPointService = mountPointService; } public void setSchemaRegistry(final SchemaSourceRegistry schemaRegistry) { @@ -200,9 +194,6 @@ public abstract class AbstractNetconfTopology implements NetconfTopology, Bindin this.schemaContextFactory = schemaContextFactory; } - @Override - public abstract void onSessionInitiated(ProviderContext session); - @Override public ListenableFuture connectNode(NodeId nodeId, Node configNode) { LOG.info("Connecting RemoteDevice{{}} , with config {}", nodeId, configNode); @@ -438,16 +429,6 @@ public abstract class AbstractNetconfTopology implements NetconfTopology, Bindin protected abstract RemoteDeviceHandler createSalFacade(final RemoteDeviceId id, final Broker domBroker, final BindingAwareBroker bindingBroker); - @Override - public void onSessionInitiated(ProviderSession session) { - mountPointService = session.getService(DOMMountPointService.class); - } - - @Override - public Collection getProviderFunctionality() { - return Collections.emptySet(); - } - private InetSocketAddress getSocketAddress(final Host host, int port) { if(host.getDomainName() != null) { return new InetSocketAddress(host.getDomainName().getValue(), port); diff --git a/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/NetconfTopology.java b/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/api/NetconfTopology.java similarity index 94% rename from netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/NetconfTopology.java rename to netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/api/NetconfTopology.java index b275c7584d..d69e2e272b 100644 --- a/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/NetconfTopology.java +++ b/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/api/NetconfTopology.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.netconf.topology; +package org.opendaylight.netconf.topology.api; import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities; diff --git a/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/SchemaRepositoryProvider.java b/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/api/SchemaRepositoryProvider.java similarity index 91% rename from netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/SchemaRepositoryProvider.java rename to netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/api/SchemaRepositoryProvider.java index e4664d6f3b..2ceee2bd07 100644 --- a/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/SchemaRepositoryProvider.java +++ b/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/api/SchemaRepositoryProvider.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.netconf.topology; +package org.opendaylight.netconf.topology.api; import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository; diff --git a/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImpl.java b/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImpl.java index 0553a5aa5b..9b02f0b3d1 100644 --- a/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImpl.java +++ b/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImpl.java @@ -22,8 +22,8 @@ import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; 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.dom.api.DOMMountPointService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.controller.sal.core.api.Broker; import org.opendaylight.netconf.client.NetconfClientDispatcher; import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler; @@ -31,7 +31,7 @@ import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPrefe import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceSalFacade; import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.opendaylight.netconf.topology.AbstractNetconfTopology; -import org.opendaylight.netconf.topology.SchemaRepositoryProvider; +import org.opendaylight.netconf.topology.api.SchemaRepositoryProvider; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopologyBuilder; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; @@ -48,16 +48,16 @@ public class NetconfTopologyImpl extends AbstractNetconfTopology implements Data private static final Logger LOG = LoggerFactory.getLogger(NetconfTopologyImpl.class); - private ListenerRegistration datastoreListenerRegistration = null; + private ListenerRegistration datastoreListenerRegistration = null; public NetconfTopologyImpl(final String topologyId, final NetconfClientDispatcher clientDispatcher, final BindingAwareBroker bindingAwareBroker, final Broker domBroker, final EventExecutor eventExecutor, final ScheduledThreadPool keepaliveExecutor, - final ThreadPool processingExecutor, final SchemaRepositoryProvider schemaRepositoryProvider) { + final ThreadPool processingExecutor, final SchemaRepositoryProvider schemaRepositoryProvider, + final DataBroker dataBroker, final DOMMountPointService mountPointService) { super(topologyId, clientDispatcher, bindingAwareBroker, domBroker, eventExecutor, - keepaliveExecutor, processingExecutor, schemaRepositoryProvider); - registerToSal(this, this); + keepaliveExecutor, processingExecutor, schemaRepositoryProvider, dataBroker, mountPointService); } @Override @@ -79,10 +79,10 @@ public class NetconfTopologyImpl extends AbstractNetconfTopology implements Data return new NetconfDeviceSalFacade(id, domBroker, bindingAwareBroker); } - @Override - public void onSessionInitiated(ProviderContext session) { - dataBroker = session.getSALService(DataBroker.class); - + /** + * Invoke by blueprint + */ + public void init() { final WriteTransaction wtx = dataBroker.newWriteOnlyTransaction(); initTopology(wtx, LogicalDatastoreType.CONFIGURATION); initTopology(wtx, LogicalDatastoreType.OPERATIONAL); diff --git a/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/impl/SchemaRepositoryProviderImpl.java b/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/impl/SchemaRepositoryProviderImpl.java new file mode 100644 index 0000000000..9fc5bee107 --- /dev/null +++ b/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/impl/SchemaRepositoryProviderImpl.java @@ -0,0 +1,25 @@ +/* + * 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.topology.impl; + +import org.opendaylight.netconf.topology.api.SchemaRepositoryProvider; +import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository; + +public class SchemaRepositoryProviderImpl implements SchemaRepositoryProvider { + + private final SharedSchemaRepository schemaRepository; + + public SchemaRepositoryProviderImpl(final String moduleName) { + schemaRepository = new SharedSchemaRepository(moduleName); + } + + @Override + public SharedSchemaRepository getSharedSchemaRepository() { + return schemaRepository; + } +} \ No newline at end of file diff --git a/netconf/netconf-topology/src/main/yang/netconf-topology.yang b/netconf/netconf-topology/src/main/yang/netconf-topology.yang deleted file mode 100644 index 8f55e63768..0000000000 --- a/netconf/netconf-topology/src/main/yang/netconf-topology.yang +++ /dev/null @@ -1,111 +0,0 @@ -module netconf-topology { - - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:netconf:topology"; - prefix "nt"; - - import config { prefix config; revision-date 2013-04-05; } - import threadpool {prefix th;} - import netty {prefix netty;} - import opendaylight-md-sal-dom {prefix dom;} - import opendaylight-md-sal-binding {prefix md-sal-binding; revision-date 2013-10-28;} - import odl-netconf-cfg { prefix cfg-net; revision-date 2014-04-08; } - import shared-schema-repository { prefix sh; revision-date 2015-07-27; } - - description - "Module definition for Netconf topolgy. Netconf topology provides a set of common configuration "; - - revision "2015-07-27" { - description - "Initial revision"; - } - - identity netconf-topology { - base config:service-type; - config:java-class "org.opendaylight.netconf.topology.NetconfTopology"; - } - - identity netconf-topology-impl { - base config:module-type; - config:java-name-prefix NetconfTopology; - config:provided-service netconf-topology; - } - - augment "/config:modules/config:module/config:configuration" { - case netconf-topology-impl { - when "/config:modules/config:module/config:type = 'netconf-topology-impl'"; - - leaf topology-id { - mandatory true; - type string; - } - - container dom-registry { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity dom:dom-broker-osgi-registry; - } - } - } - - container binding-registry { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity md-sal-binding:binding-broker-osgi-registry; - } - } - } - - container event-executor { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity netty:netty-event-executor; - } - } - } - - container processing-executor { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity th:threadpool; - } - } - - description "Makes up for flaws in netty threading design"; - } - - container client-dispatcher { - uses config:service-ref { - refine type { - mandatory false; - config:required-identity cfg-net:netconf-client-dispatcher; - } - } - } - - container keepalive-executor { - uses config:service-ref { - refine type { - mandatory false; - config:required-identity th:scheduled-threadpool; - } - } - - description "Dedicated solely to keepalive execution"; - } - - container shared-schema-repository { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity sh:shared-schema-repository; - } - } - } - } - } -} \ No newline at end of file diff --git a/netconf/netconf-topology/src/main/yang/shared-schema-repository.yang b/netconf/netconf-topology/src/main/yang/shared-schema-repository.yang deleted file mode 100644 index e5d1f07807..0000000000 --- a/netconf/netconf-topology/src/main/yang/shared-schema-repository.yang +++ /dev/null @@ -1,41 +0,0 @@ -module shared-schema-repository { - - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:netconf:topology:shared:schema:repository"; - prefix "ssr"; - - import config { prefix config; revision-date 2013-04-05; } - - description - "Module definition for Shared schema repository."; - - revision "2015-07-27" { - description - "Initial revision"; - } - - identity shared-schema-repository { - base "config:service-type"; - config:java-class "org.opendaylight.netconf.topology.SchemaRepositoryProvider"; - } - - identity shared-schema-repository-impl { - base "config:module-type"; - config:provided-service shared-schema-repository; - config:java-name-prefix SchemaRepositoryImpl; - } - - augment "/config:modules/config:module/config:configuration" { - case shared-schema-repository-impl { - when "/config:modules/config:module/config:type = 'shared-schema-repository-impl'"; - - container schema-repository-fallbacks { - list schema-repository-fallback { - leaf repository-url { - type string; - } - } - } - } - } -} \ No newline at end of file diff --git a/netconf/netconf-topology/src/test/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImplTest.java b/netconf/netconf-topology/src/test/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImplTest.java index 2a2f2f4125..ceb5cf0784 100644 --- a/netconf/netconf-topology/src/test/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImplTest.java +++ b/netconf/netconf-topology/src/test/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImplTest.java @@ -37,12 +37,13 @@ import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; 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.md.sal.dom.api.DOMMountPointService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.controller.sal.core.api.Broker; import org.opendaylight.netconf.client.NetconfClientDispatcher; import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration; import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities; -import org.opendaylight.netconf.topology.SchemaRepositoryProvider; +import org.opendaylight.netconf.topology.api.SchemaRepositoryProvider; 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.inet.types.rev130715.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; @@ -90,6 +91,11 @@ public class NetconfTopologyImplTest { @Mock private SchemaRepositoryProvider mockedSchemaRepositoryProvider; + @Mock + private DataBroker dataBroker; + + @Mock + private DOMMountPointService domMountPointService; private TestingNetconfTopologyImpl topology; private TestingNetconfTopologyImpl spyTopology; @@ -104,21 +110,19 @@ public class NetconfTopologyImplTest { when(mockedClientDispatcher.createReconnectingClient(any(NetconfReconnectingClientConfiguration.class))).thenReturn(future); topology = new TestingNetconfTopologyImpl(TOPOLOGY_ID, mockedClientDispatcher, mockedBindingAwareBroker, - mockedDataBroker, mockedEventExecutor, mockedKeepaliveExecutor, mockedProcessingExecutor, mockedSchemaRepositoryProvider); + mockedDataBroker, mockedEventExecutor, mockedKeepaliveExecutor, mockedProcessingExecutor, mockedSchemaRepositoryProvider, + dataBroker, domMountPointService); spyTopology = spy(topology); } @Test - public void testOnSessionInitiated() { - BindingAwareBroker.ProviderContext session = mock(BindingAwareBroker.ProviderContext.class); - DataBroker dataBroker = mock(DataBroker.class); - when(session.getSALService(DataBroker.class)).thenReturn(dataBroker); + public void testInit() { WriteTransaction wtx = mock(WriteTransaction.class); when(dataBroker.newWriteOnlyTransaction()).thenReturn(wtx); doNothing().when(wtx).merge(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class)); when(wtx.submit()).thenReturn(Futures.immediateCheckedFuture(null)); - topology.onSessionInitiated(session); + topology.init(); //verify initialization of topology final InstanceIdentifier networkTopologyId = InstanceIdentifier.builder(NetworkTopology.class).build(); @@ -185,8 +189,13 @@ public class NetconfTopologyImplTest { public static class TestingNetconfTopologyImpl extends NetconfTopologyImpl { - public TestingNetconfTopologyImpl(String topologyId, NetconfClientDispatcher clientDispatcher, BindingAwareBroker bindingAwareBroker, Broker domBroker, EventExecutor eventExecutor, ScheduledThreadPool keepaliveExecutor, ThreadPool processingExecutor, SchemaRepositoryProvider schemaRepositoryProvider) { - super(topologyId, clientDispatcher, bindingAwareBroker, domBroker, eventExecutor, keepaliveExecutor, processingExecutor, schemaRepositoryProvider); + public TestingNetconfTopologyImpl(String topologyId, NetconfClientDispatcher clientDispatcher, + BindingAwareBroker bindingAwareBroker, Broker domBroker, + EventExecutor eventExecutor, ScheduledThreadPool keepaliveExecutor, + ThreadPool processingExecutor, SchemaRepositoryProvider schemaRepositoryProvider, + DataBroker dataBroker, DOMMountPointService domMountPointService) { + super(topologyId, clientDispatcher, bindingAwareBroker, domBroker, eventExecutor, keepaliveExecutor, + processingExecutor, schemaRepositoryProvider, dataBroker, domMountPointService); } @Override -- 2.36.6