Add blueprint wiring for hwvtepsouthbound 38/40638/2
authorAlexis de Talhouët <adetalhouet@inocybe.com>
Tue, 21 Jun 2016 22:03:17 +0000 (18:03 -0400)
committerAlexis de Talhouët <adetalhouet@inocybe.com>
Tue, 21 Jun 2016 22:47:18 +0000 (22:47 +0000)
Change-Id: I973476d85f890f701b2b668dcebef61372e7aa58
Signed-off-by: Alexis de Talhouët <adetalhouet@inocybe.com>
hwvtepsouthbound/hwvtepsouthbound-features/pom.xml
hwvtepsouthbound/hwvtepsouthbound-features/src/main/features/features.xml
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/config/default-config.xml [deleted file]
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundProvider.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModule.java [deleted file]
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleFactory.java [deleted file]
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/resources/org/opendaylight/blueprint/hwvtepsouthbound.xml [new file with mode: 0644]
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/yang/hwvtepsouthbound-impl.yang [deleted file]
hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleFactoryTest.java [deleted file]
hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleTest.java [deleted file]

index d1c2348fbe873302283e67ec433ef3f1f96cf9b6..2b8f6f2d0e9fb485796d6afcf851cea960ebc72a 100644 (file)
@@ -93,13 +93,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <artifactId>hwvtepsouthbound-impl</artifactId>
       <version>${project.version}</version>
     </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>hwvtepsouthbound-impl</artifactId>
-      <version>${project.version}</version>
-      <type>xml</type>
-      <classifier>config</classifier>
-    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>hwvtepsouthbound-api</artifactId>
index 8334f5f1c10a4035a8aaa10fa00ddd7b98fb20c8..62b7b48434e37f0c2cdc24e8388532345cea8f77 100644 (file)
@@ -31,7 +31,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <!--<bundle>mvn:com.fasterxml.jackson.datatype/jackson-datatype-json-org/{{VERSION}}</bundle>-->
     <bundle>wrap:mvn:org.json/json/{{VERSION}}</bundle>
     <feature version='${project.version}'>odl-ovsdb-library</feature>
-    <configfile finalname="${configfile.directory}/hwvtepsouthbound.xml">mvn:org.opendaylight.ovsdb/hwvtepsouthbound-impl/{{VERSION}}/xml/config</configfile>
   </feature>
   <feature name='odl-ovsdb-hwvtepsouthbound-rest' version='${project.version}' description='OpenDaylight :: hwvtepsouthbound :: REST'>
     <feature version="${project.version}">odl-ovsdb-hwvtepsouthbound</feature>
diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/config/default-config.xml b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/config/default-config.xml
deleted file mode 100644 (file)
index bd70094..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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:hwvtepsouthbound:impl?module=hwvtepsouthbound-impl&amp;revision=2015-09-01</capability> -->
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</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:hwvtepsouthbound:impl">prefix:hwvtepsouthbound</type>
-          <name>hwvtepsouthbound-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 f59e5ff7080b48a5a4428cd7868b948d721022da..15c4cd3a5dcfe50630b1117e46e0de2c139ef298 100644 (file)
@@ -21,6 +21,7 @@ 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.hwvtepsouthbound.transactions.md.TransactionInvoker;
 import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionInvokerImpl;
 import org.opendaylight.ovsdb.lib.OvsdbConnection;
@@ -29,6 +30,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 +38,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 
-public class HwvtepSouthboundProvider implements BindingAwareProvider, AutoCloseable {
+public class HwvtepSouthboundProvider implements AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(HwvtepSouthboundProvider.class);
     private static final String ENTITY_TYPE = "ovsdb-hwvtepsouthbound-provider";
@@ -46,27 +48,35 @@ public class HwvtepSouthboundProvider implements BindingAwareProvider, AutoClose
     }
 
     private static DataBroker db;
+    private final EntityOwnershipService entityOwnershipService;
+    private final OvsdbConnection ovsdbConnection;
+
     private HwvtepConnectionManager cm;
-    private OvsdbConnection ovsdbConnection;
     private TransactionInvoker txInvoker;
-    private EntityOwnershipService entityOwnershipService;
     private EntityOwnershipCandidateRegistration registration;
     private HwvtepsbPluginInstanceEntityOwnershipListener providerOwnershipChangeListener;
     private HwvtepDataChangeListener hwvtepDTListener;
 
-    public HwvtepSouthboundProvider(
-            EntityOwnershipService entityOwnershipServiceDependency,
-            OvsdbConnection ovsdbConnection) {
+    public HwvtepSouthboundProvider(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;
+
+        HwvtepSouthboundUtil.setInstanceIdentifierCodec(new InstanceIdentifierCodec(schemaService,
+                bindingNormalizedNodeSerializer));
         LOG.info("HwvtepSouthboundProvider ovsdbConnectionService: {}", ovsdbConnection);
     }
 
-    @Override
-    public void onSessionInitiated(ProviderContext session) {
+    /**
+     * Used by blueprint when starting the container.
+     */
+    public void init() {
         LOG.info("HwvtepSouthboundProvider Session Initiated");
-        db = session.getSALService(DataBroker.class);
         txInvoker = new TransactionInvokerImpl(db);
         cm = new HwvtepConnectionManager(db, txInvoker, entityOwnershipService);
         hwvtepDTListener = new HwvtepDataChangeListener(db, cm);
diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModule.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModule.java
deleted file mode 100644 (file)
index d887188..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.hwvtepsouthbound.impl.rev150901;
-
-import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundProvider;
-import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundUtil;
-import org.opendaylight.ovsdb.hwvtepsouthbound.InstanceIdentifierCodec;
-
-public class HwvtepSouthboundModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hwvtepsouthbound.impl.rev150901.AbstractHwvtepSouthboundModule {
-    public HwvtepSouthboundModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public HwvtepSouthboundModule(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.hwvtepsouthbound.impl.rev150901.HwvtepSouthboundModule 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() {
-        HwvtepSouthboundUtil.setInstanceIdentifierCodec(new InstanceIdentifierCodec(getSchemaServiceDependency(),
-                        getBindingNormalizedNodeSerializerDependency()));
-        HwvtepSouthboundProvider provider = new HwvtepSouthboundProvider(getClusteringEntityOwnershipServiceDependency(),
-                        getConnectionServiceDependency());
-        getBrokerDependency().registerProvider(provider);
-        return provider;
-    }
-
-}
diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleFactory.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleFactory.java
deleted file mode 100644 (file)
index 38ca064..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-* Generated file
-*
-* Generated from: yang module name: hwvtepsouthbound-impl yang module local name: hwvtepsouthbound
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Tue Sep 01 21:41:01 IST 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.hwvtepsouthbound.impl.rev150901;
-public class HwvtepSouthboundModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hwvtepsouthbound.impl.rev150901.AbstractHwvtepSouthboundModuleFactory {
-
-}
diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/resources/org/opendaylight/blueprint/hwvtepsouthbound.xml b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/resources/org/opendaylight/blueprint/hwvtepsouthbound.xml
new file mode 100644 (file)
index 0000000..dba7238
--- /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="hwvtepProvider"
+    class="org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundProvider"
+    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/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/yang/hwvtepsouthbound-impl.yang b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/yang/hwvtepsouthbound-impl.yang
deleted file mode 100644 (file)
index f082332..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-module hwvtepsouthbound-impl {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:hwvtepsouthbound:impl";
-    prefix "hwvtepsouthbound-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-entity-ownership-service {prefix eos; revision-date 2015-08-10;}
-    import opendaylight-md-sal-dom {prefix dom; revision-date 2013-10-28;}
-    import library { prefix library; revision-date 2014-12-10; }
-
-    description
-        "Service definition for hwvtepsouthbound project";
-
-    revision "2015-09-01" {
-        description
-            "Initial revision";
-    }
-
-    identity hwvtepsouthbound {
-        base config:module-type;
-        config:java-name-prefix HwvtepSouthbound;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case hwvtepsouthbound {
-            when "/config:modules/config:module/config:type = 'hwvtepsouthbound'";
-            container broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
-                    }
-                }
-            }
-            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 binding-normalized-node-serializer {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-normalized-node-serializer;
-                    }
-                }
-            }
-            container connection-service {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity library:connection-service;
-                    }
-                }
-            }
-        }
-    }
-}
diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleFactoryTest.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleFactoryTest.java
deleted file mode 100644 (file)
index 74a4d7d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.hwvtepsouthbound.impl.rev150901;
-
-import org.junit.Test;
-
-public class HwvtepSouthboundModuleFactoryTest {
-    @Test
-    public void testFactoryConstructor() {
-        // ensure no exceptions on construction
-        new HwvtepSouthboundModuleFactory();
-    }
-}
diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleTest.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleTest.java
deleted file mode 100644 (file)
index 6f49c4c..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.hwvtepsouthbound.impl.rev150901;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.JmxAttribute;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundProvider;
-
-import javax.management.ObjectName;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class HwvtepSouthboundModuleTest {
-    @Test
-    public void testCustomValidation() {
-        HwvtepSouthboundModule module = new HwvtepSouthboundModule(mock(ModuleIdentifier.class), mock(DependencyResolver.class));
-
-        // ensure no exceptions on validation
-        // currently this method is empty
-        module.customValidation();
-    }
-
-    //TODO: Ignore for now, will be replaced with better UT
-    @Ignore
-    @Test
-    public void testCreateInstance() throws Exception {
-        // configure mocks
-        DependencyResolver dependencyResolver = mock(DependencyResolver.class);
-        BindingAwareBroker broker = mock(BindingAwareBroker.class);
-        when(dependencyResolver.resolveInstance(eq(BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class))).thenReturn(broker);
-
-        // create instance of module with injected mocks
-        HwvtepSouthboundModule module = new HwvtepSouthboundModule(mock(ModuleIdentifier.class), dependencyResolver);
-
-        // getInstance calls resolveInstance to get the broker dependency and then calls createInstance
-        AutoCloseable closeable = module.getInstance();
-
-        // verify that the module registered the returned provider with the broker
-        verify(broker).registerProvider((HwvtepSouthboundProvider)closeable);
-
-        // ensure no exceptions on close
-        closeable.close();
-    }
-}