From d2f163d1a3ae80b616dd6ac97ba67b9654d9e21d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20de=20Talhou=C3=ABt?= Date: Tue, 21 Jun 2016 18:03:17 -0400 Subject: [PATCH] Add blueprint wiring for hwvtepsouthbound MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I973476d85f890f701b2b668dcebef61372e7aa58 Signed-off-by: Alexis de Talhouët --- .../hwvtepsouthbound-features/pom.xml | 7 -- .../src/main/features/features.xml | 1 - .../src/main/config/default-config.xml | 47 ------------- .../HwvtepSouthboundProvider.java | 28 +++++--- .../rev150901/HwvtepSouthboundModule.java | 39 ----------- .../HwvtepSouthboundModuleFactory.java | 13 ---- .../blueprint/hwvtepsouthbound.xml | 27 +++++++ .../src/main/yang/hwvtepsouthbound-impl.yang | 70 ------------------- .../HwvtepSouthboundModuleFactoryTest.java | 18 ----- .../rev150901/HwvtepSouthboundModuleTest.java | 57 --------------- 10 files changed, 46 insertions(+), 261 deletions(-) delete mode 100644 hwvtepsouthbound/hwvtepsouthbound-impl/src/main/config/default-config.xml delete mode 100644 hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModule.java delete mode 100644 hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleFactory.java create mode 100644 hwvtepsouthbound/hwvtepsouthbound-impl/src/main/resources/org/opendaylight/blueprint/hwvtepsouthbound.xml delete mode 100644 hwvtepsouthbound/hwvtepsouthbound-impl/src/main/yang/hwvtepsouthbound-impl.yang delete mode 100644 hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleFactoryTest.java delete mode 100644 hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleTest.java diff --git a/hwvtepsouthbound/hwvtepsouthbound-features/pom.xml b/hwvtepsouthbound/hwvtepsouthbound-features/pom.xml index d1c2348fb..2b8f6f2d0 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-features/pom.xml +++ b/hwvtepsouthbound/hwvtepsouthbound-features/pom.xml @@ -93,13 +93,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL hwvtepsouthbound-impl ${project.version} - - ${project.groupId} - hwvtepsouthbound-impl - ${project.version} - xml - config - ${project.groupId} hwvtepsouthbound-api diff --git a/hwvtepsouthbound/hwvtepsouthbound-features/src/main/features/features.xml b/hwvtepsouthbound/hwvtepsouthbound-features/src/main/features/features.xml index 8334f5f1c..62b7b4843 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-features/src/main/features/features.xml +++ b/hwvtepsouthbound/hwvtepsouthbound-features/src/main/features/features.xml @@ -31,7 +31,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html wrap:mvn:org.json/json/{{VERSION}} odl-ovsdb-library - mvn:org.opendaylight.ovsdb/hwvtepsouthbound-impl/{{VERSION}}/xml/config odl-ovsdb-hwvtepsouthbound 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 index bd7009489..000000000 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/config/default-config.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28 - urn:opendaylight:params:xml:ns:yang:library:impl?module=library&revision=2014-12-10 - - - - - - - prefix:hwvtepsouthbound - hwvtepsouthbound-default - - binding:binding-broker-osgi-registry - binding-osgi-broker - - - dom:schema-service - yang-schema-service - - - binding:binding-normalized-node-serializer - runtime-mapping-singleton - - - ns:entity-ownership-service - entity-ownership-service - - - prefix:connection-service - connection-service - - - - - - diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundProvider.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundProvider.java index f59e5ff70..15c4cd3a5 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundProvider.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundProvider.java @@ -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 index d88718838..000000000 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModule.java +++ /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 index 38ca0646c..000000000 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleFactory.java +++ /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 index 000000000..dba7238a1 --- /dev/null +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/resources/org/opendaylight/blueprint/hwvtepsouthbound.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + 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 index f0823322d..000000000 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/yang/hwvtepsouthbound-impl.yang +++ /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 index 74a4d7d90..000000000 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleFactoryTest.java +++ /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 index 6f49c4c92..000000000 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/hwvtepsouthbound/impl/rev150901/HwvtepSouthboundModuleTest.java +++ /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(); - } -} -- 2.36.6