Add blueprint wiring for southbound 39/40639/4
authorAlexis de Talhouët <adetalhouet@inocybe.com>
Tue, 21 Jun 2016 22:39:49 +0000 (18:39 -0400)
committerAlexis de Talhouët <adetalhouet@inocybe.com>
Wed, 22 Jun 2016 12:39:15 +0000 (08:39 -0400)
Change-Id: I6e5cea49f584cc93a2842533287e950eadfabb40
Signed-off-by: Alexis de Talhouët <adetalhouet@inocybe.com>
southbound/southbound-features/pom.xml
southbound/southbound-features/src/main/features/features.xml
southbound/southbound-impl/src/main/config/default-config.xml [deleted file]
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundProvider.java
southbound/southbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/southbound/impl/rev141210/SouthboundImplModule.java [deleted file]
southbound/southbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/southbound/impl/rev141210/SouthboundImplModuleFactory.java [deleted file]
southbound/southbound-impl/src/main/resources/org/opendaylight/blueprint/southbound.xml [new file with mode: 0644]
southbound/southbound-impl/src/main/yang/southbound-impl.yang [deleted file]
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/SouthboundProviderTest.java
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundIT.java

index 989df44ab8ae15961548fa8d102c20fc7981400a..f53849323509ed68d06b31d7077a88ff8f10ac6f 100644 (file)
@@ -106,13 +106,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <artifactId>southbound-impl</artifactId>
       <version>${project.version}</version>
     </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>southbound-impl</artifactId>
-      <version>${project.version}</version>
-      <type>xml</type>
-      <classifier>config</classifier>
-    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>southbound-api</artifactId>
index 04e467b77452805a3ab65e076567945d7a516843..6299ca83fc577000df3e10b80d520c4fe5e0bfff 100644 (file)
@@ -38,7 +38,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <bundle>mvn:io.netty/netty-handler/{{VERSION}}</bundle>
     <bundle>mvn:io.netty/netty-transport/{{VERSION}}</bundle>
     <feature version="${project.version}">odl-ovsdb-library</feature>
-    <configfile finalname="etc/opendaylight/karaf/southbound-impl-default-config.xml">mvn:org.opendaylight.ovsdb/southbound-impl/{{VERSION}}/xml/config</configfile>
   </feature>
   <feature name='odl-ovsdb-southbound-impl-rest' version='${project.version}' description='OpenDaylight :: southbound :: impl :: REST '>
     <feature version="${project.version}">odl-ovsdb-southbound-impl</feature>
diff --git a/southbound/southbound-impl/src/main/config/default-config.xml b/southbound/southbound-impl/src/main/config/default-config.xml
deleted file mode 100644 (file)
index 92e91c2..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-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
--->
-<snapshot>
-  <required-capabilities>
-    <capability>urn:opendaylight:params:xml:ns:yang:southbound:impl?module=southbound-impl&amp;revision=2014-12-10</capability>
-    <capability>urn:opendaylight:params:xml:ns:yang:library:impl?module=library&amp;revision=2014-12-10</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:params:xml:ns:yang:southbound:impl">prefix:southbound-impl</type>
-          <name>southbound-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>
-          <schema-service>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
-            <name>yang-schema-service</name>
-          </schema-service>
-          <binding-normalized-node-serializer>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-normalized-node-serializer</type>
-            <name>runtime-mapping-singleton</name>
-          </binding-normalized-node-serializer>
-          <clustering-entity-ownership-service>
-             <type xmlns:ns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:entity-ownership-service">ns:entity-ownership-service</type>
-             <name>entity-ownership-service</name>
-          </clustering-entity-ownership-service>
-          <connection-service>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:library:impl">prefix:connection-service</type>
-            <name>connection-service</name>
-          </connection-service>
-        </module>
-      </modules>
-    </data>
-  </configuration>
-</snapshot>
index 28e93c4e44d496c64024ed9941d41890be3d10ca..5f5bad6d4a369ceb6287c67ff0ff5cb83683625c 100644 (file)
@@ -19,8 +19,7 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipS
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.ovsdb.lib.OvsdbConnection;
 import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
 import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvokerImpl;
@@ -29,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 
-public class SouthboundProvider implements BindingAwareProvider, AutoCloseable {
+public class SouthboundProvider implements AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(SouthboundProvider.class);
     private static final String ENTITY_TYPE = "ovsdb-southbound-provider";
@@ -54,20 +54,26 @@ public class SouthboundProvider implements BindingAwareProvider, AutoCloseable {
     private SouthboundPluginInstanceEntityOwnershipListener providerOwnershipChangeListener;
     private OvsdbConnection ovsdbConnection;
 
-
-    public SouthboundProvider(
-            EntityOwnershipService entityOwnershipServiceDependency,
-            OvsdbConnection ovsdbConnection) {
+    public SouthboundProvider(final DataBroker dataBroker,
+            final EntityOwnershipService entityOwnershipServiceDependency,
+            final OvsdbConnection ovsdbConnection,
+            final SchemaService schemaService,
+            final BindingNormalizedNodeSerializer bindingNormalizedNodeSerializer) {
+        this.db = dataBroker;
         this.entityOwnershipService = entityOwnershipServiceDependency;
         registration = null;
         this.ovsdbConnection = ovsdbConnection;
+
+        SouthboundUtil.setInstanceIdentifierCodec(new InstanceIdentifierCodec(schemaService,
+                bindingNormalizedNodeSerializer));
         LOG.info("SouthboundProvider ovsdbConnectionService: {}", ovsdbConnection);
     }
 
-    @Override
-    public void onSessionInitiated(ProviderContext session) {
+    /**
+     * Used by blueprint when starting the container.
+     */
+    public void init() {
         LOG.info("SouthboundProvider Session Initiated");
-        db = session.getSALService(DataBroker.class);
         this.txInvoker = new TransactionInvokerImpl(db);
         cm = new OvsdbConnectionManager(db,txInvoker,entityOwnershipService, ovsdbConnection);
         ovsdbDataTreeChangeListener = new OvsdbDataTreeChangeListener(db, cm);
diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/southbound/impl/rev141210/SouthboundImplModule.java b/southbound/southbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/southbound/impl/rev141210/SouthboundImplModule.java
deleted file mode 100644 (file)
index 5c543df..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.southbound.impl.rev141210;
-
-import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec;
-import org.opendaylight.ovsdb.southbound.SouthboundProvider;
-import org.opendaylight.ovsdb.southbound.SouthboundUtil;
-
-public class SouthboundImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.southbound.impl.rev141210.AbstractSouthboundImplModule {
-
-
-    public SouthboundImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public SouthboundImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.southbound.impl.rev141210.SouthboundImplModule 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() {
-        SouthboundUtil.setInstanceIdentifierCodec(new InstanceIdentifierCodec(getSchemaServiceDependency(),
-                getBindingNormalizedNodeSerializerDependency()));
-        SouthboundProvider provider = new SouthboundProvider(getClusteringEntityOwnershipServiceDependency(),
-                getConnectionServiceDependency());
-        getBrokerDependency().registerProvider(provider);
-        return provider;
-    }
-
-}
diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/southbound/impl/rev141210/SouthboundImplModuleFactory.java b/southbound/southbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/southbound/impl/rev141210/SouthboundImplModuleFactory.java
deleted file mode 100644 (file)
index 1af1601..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-/*
-* Generated file
-*
-* Generated from: yang module name: southbound yang module local name: southbound
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Fri Jan 02 13:49:24 CST 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.southbound.impl.rev141210;
-public class SouthboundImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.southbound.impl.rev141210.AbstractSouthboundImplModuleFactory {
-
-}
diff --git a/southbound/southbound-impl/src/main/resources/org/opendaylight/blueprint/southbound.xml b/southbound/southbound-impl/src/main/resources/org/opendaylight/blueprint/southbound.xml
new file mode 100644 (file)
index 0000000..8e0dfd5
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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="eos"
+    interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService" />
+  <reference id="ovsdbConnection" interface="org.opendaylight.ovsdb.lib.OvsdbConnection" />
+  <reference id="schemaService"
+    interface="org.opendaylight.controller.sal.core.api.model.SchemaService" />
+  <reference id="bindingNormalizedNodeSerializer"
+    interface="org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer" />
+
+  <bean id="southboundProvider"
+    class="org.opendaylight.ovsdb.southbound.SouthboundProvider"
+    init-method="init" destroy-method="close">
+    <argument ref="dataBroker" />
+    <argument ref="eos" />
+    <argument ref="ovsdbConnection" />
+    <argument ref="schemaService" />
+    <argument ref="bindingNormalizedNodeSerializer" />
+  </bean>
+
+</blueprint>
diff --git a/southbound/southbound-impl/src/main/yang/southbound-impl.yang b/southbound/southbound-impl/src/main/yang/southbound-impl.yang
deleted file mode 100644 (file)
index f4c98d4..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-module southbound-impl {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:southbound:impl";
-    prefix "southbound-impl";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
-    import opendaylight-md-sal-dom {prefix dom; revision-date 2013-10-28;}
-    import opendaylight-entity-ownership-service {prefix eos; revision-date 2015-08-10;}
-    import library { prefix library; revision-date 2014-12-10; }
-
-    description
-        "Service definition for southbound project";
-
-    revision "2014-12-10" {
-        description
-            "Initial revision";
-    }
-
-    identity southbound-impl {
-        base config:module-type;
-        config:java-name-prefix SouthboundImpl;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case southbound-impl {
-            when "/config:modules/config:module/config:type = 'southbound-impl'";
-            container broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
-                    }
-                }
-            }
-            container binding-normalized-node-serializer {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-normalized-node-serializer;
-                    }
-                }
-            }
-            container schema-service {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity dom:schema-service;
-                    }
-                }
-            }
-            container clustering-entity-ownership-service {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity eos:entity-ownership-service;
-                    }
-                }
-            }
-            container connection-service {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity library:connection-service;
-                    }
-                }
-            }
-        }
-    }
-}
index 85989d3e51008635279c574da376930b8063b6cb..743355c4e15837c1d187fbce0afb0ef121d6f890 100644 (file)
@@ -20,7 +20,7 @@ import static org.mockito.Mockito.when;
 
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.mockito.Mockito;
 import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
 import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
@@ -32,11 +32,12 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipS
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.ovsdb.lib.OvsdbConnection;
 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.network.topology.Topology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
@@ -55,22 +56,24 @@ public class SouthboundProviderTest extends AbstractDataBrokerTest {
     }
 
     @Test
-    public void testOnSessionInitiated() throws CandidateAlreadyRegisteredException {
-        ProviderContext session = mock(ProviderContext.class);
-        when(session.getSALService(DataBroker.class)).thenReturn(getDataBroker());
-
+    public void testInit() throws CandidateAlreadyRegisteredException {
         // Indicate that this is the owner
         when(entityOwnershipService.getOwnershipState(any(Entity.class))).thenReturn(
                 Optional.of(new EntityOwnershipState(true, true)));
 
-        try (SouthboundProvider southboundProvider = new SouthboundProvider(entityOwnershipService,
-                mock(OvsdbConnection.class))) {
+        try (SouthboundProvider southboundProvider = new SouthboundProvider(
+                getDataBroker(),
+                entityOwnershipService,
+                Mockito.mock(OvsdbConnection.class),
+                Mockito.mock(SchemaService.class),
+                Mockito.mock(BindingNormalizedNodeSerializer.class))) {
+
             // Initiate the session
-            southboundProvider.onSessionInitiated(session);
+            southboundProvider.init();
 
             // Verify that at least one listener was registered
-            verify(entityOwnershipService, atLeastOnce()).registerListener(anyString(),
-                    any(EntityOwnershipListener.class));
+            verify(entityOwnershipService, atLeastOnce()).registerListener(
+                    anyString(), any(EntityOwnershipListener.class));
 
             // Verify that a candidate was registered
             verify(entityOwnershipService).registerCandidate(any(Entity.class));
@@ -79,13 +82,17 @@ public class SouthboundProviderTest extends AbstractDataBrokerTest {
 
     @Test
     public void testGetDb() {
-        ProviderContext session = mock(ProviderContext.class);
-        when(session.getSALService(DataBroker.class)).thenReturn(getDataBroker());
         when(entityOwnershipService.getOwnershipState(any(Entity.class))).thenReturn(
                 Optional.of(new EntityOwnershipState(true, true)));
-        try (SouthboundProvider southboundProvider = new SouthboundProvider(entityOwnershipService,
-                mock(OvsdbConnection.class))) {
-            southboundProvider.onSessionInitiated(session);
+
+        try (SouthboundProvider southboundProvider = new SouthboundProvider(
+                getDataBroker(),
+                entityOwnershipService,
+                Mockito.mock(OvsdbConnection.class),
+                Mockito.mock(SchemaService.class),
+                Mockito.mock(BindingNormalizedNodeSerializer.class))) {
+
+            southboundProvider.init();
 
             assertEquals(getDataBroker(), SouthboundProvider.getDb());
         }
@@ -93,9 +100,6 @@ public class SouthboundProviderTest extends AbstractDataBrokerTest {
 
     @Test
     public void testHandleOwnershipChange() throws ReadFailedException {
-        // Start as slave
-        ProviderContext session = mock(ProviderContext.class);
-        when(session.getSALService(DataBroker.class)).thenReturn(getDataBroker());
         when(entityOwnershipService.getOwnershipState(any(Entity.class))).thenReturn(
                 Optional.of(new EntityOwnershipState(false, true)));
         Entity entity = new Entity("ovsdb-southbound-provider", "ovsdb-southbound-provider");
@@ -103,9 +107,14 @@ public class SouthboundProviderTest extends AbstractDataBrokerTest {
                 .create(NetworkTopology.class)
                 .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID));
 
-        try (SouthboundProvider southboundProvider = new SouthboundProvider(entityOwnershipService,
-                mock(OvsdbConnection.class))) {
-            southboundProvider.onSessionInitiated(session);
+        try (SouthboundProvider southboundProvider = new SouthboundProvider(
+                getDataBroker(),
+                entityOwnershipService,
+                Mockito.mock(OvsdbConnection.class),
+                Mockito.mock(SchemaService.class),
+                Mockito.mock(BindingNormalizedNodeSerializer.class))) {
+
+            southboundProvider.init();
 
             // At this point the OVSDB topology must not be present in either tree
             assertFalse(getDataBroker().newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION,
index eb0824c57a03e6b95567c931d371832095c7662c..c04c6961185d0e1223a7c86cdaefb4ab258148af 100644 (file)
@@ -315,16 +315,6 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 .getURL();
     }
 
-    @Override
-    public String getModuleName() {
-        return "southbound-impl";
-    }
-
-    @Override
-    public String getInstanceName() {
-        return "southbound-default";
-    }
-
     @Override
     public MavenUrlReference getFeatureRepo() {
         return maven()