<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>
<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>
+++ /dev/null
-<?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&revision=2014-12-10</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:library:impl?module=library&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>
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;
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;
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";
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);
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.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;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-/*
-* Generated file
-*
-* Generated from: yang module name: 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 {
-
-}
--- /dev/null
+<?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>
+++ /dev/null
-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;
- }
- }
- }
- }
- }
-}
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;
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;
}
@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));
@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());
}
@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");
.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,
.getURL();
}
- @Override
- public String getModuleName() {
- return "southbound-impl";
- }
-
- @Override
- public String getInstanceName() {
- return "southbound-default";
- }
-
@Override
public MavenUrlReference getFeatureRepo() {
return maven()