</testResource>
</testResources>
<plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.opendaylight.ovsdb.lib.*,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.library.impl.rev141210.*
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</broker>
</module>
</modules>
+ <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:library:impl">prefix:connection-service</type>
+ <instance>
+ <name>connection-service</name>
+ <provider>/modules/module[type='library'][name='library-default']</provider>
+ </instance>
+ </service>
+ </services>
</data>
</configuration>
</snapshot>
+++ /dev/null
-/*
- * Copyright © 2015 Red Hat, 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.ovsdb.lib;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.ovsdb.lib.impl.OvsdbConnectionService;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * "Configuration" activator for the OVSDB library.
- */
-public class ConfigActivator implements BundleActivator {
- /**
- * Logger.
- */
- private static final Logger LOG = LoggerFactory.getLogger(ConfigActivator.class);
-
- /**
- * Parent provider context.
- */
- private final BindingAwareBroker.ProviderContext providerContext;
-
- /**
- * Creates an instance of the activator.
- *
- * @param providerContext The parent provider context.
- */
- public ConfigActivator(BindingAwareBroker.ProviderContext providerContext) {
- LOG.info("OVSDB library ConfigActivator created.");
- this.providerContext = providerContext;
- }
-
- @Override
- public void start(BundleContext context) throws Exception {
- LOG.info("OVSDB library ConfigActivator starting.");
- context.registerService(OvsdbConnection.class, new OvsdbConnectionService(), null);
- // TODO Need to indicate that OvsdbConnectionListeners should register with the connection service
- // (if I've understood correctly, the old dependency manager would call registerConnectionListener()
- // whenever an instance of OvsdbConnection is retrieved, and unregisterConnectionListener() when it
- // is no longer used)
- // (All current users register manually...)
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- LOG.info("OVSDB library ConfigActivator stopping.");
- }
-}
*/
package org.opendaylight.ovsdb.lib.impl;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import java.net.InetAddress;
+import java.util.Collection;
+
+import javax.net.ssl.SSLContext;
+
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.opendaylight.ovsdb.lib.ConfigActivator;
+import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.lib.OvsdbConnection;
+import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class LibraryProvider implements BindingAwareProvider, AutoCloseable {
+public class LibraryProvider implements BindingAwareProvider, AutoCloseable, OvsdbConnection {
private static final Logger LOG = LoggerFactory.getLogger(LibraryProvider.class);
- private final BundleContext bundleContext;
- private DataBroker dataBroker;
- private ConfigActivator activator;
public LibraryProvider(BundleContext bundleContext) {
LOG.info("LibraryProvider: bundleContext: {}", bundleContext);
- this.bundleContext = bundleContext;
}
@Override
public void onSessionInitiated(ProviderContext providerContext) {
LOG.info("LibraryProvider Session Initiated");
- dataBroker = providerContext.getSALService(DataBroker.class);
- LOG.info("LibraryProvider: onSessionInitiated dataBroker: {}", dataBroker);
- this.activator = new ConfigActivator(providerContext);
- try {
- activator.start(bundleContext);
- } catch (Exception e) {
- LOG.warn("Failed to start LibraryProvider: ", e);
- }
}
@Override
public void close() throws Exception {
LOG.info("LibraryProvider Closed");
- if (activator != null) {
- activator.stop(bundleContext);
- }
}
+ @Override
+ public OvsdbClient connect(InetAddress address, int port) {
+ return OvsdbConnectionService.getService().connect(address, port);
+ }
+
+ @Override
+ public OvsdbClient connectWithSsl(
+ InetAddress address, int port, SSLContext sslContext) {
+ return OvsdbConnectionService.getService().connectWithSsl(address, port, sslContext);
+ }
+
+ @Override
+ public void disconnect(OvsdbClient client) {
+ OvsdbConnectionService.getService().disconnect(client);
+ }
+
+ @Override
+ public boolean startOvsdbManager(int ovsdbListenPort) {
+ return OvsdbConnectionService.getService().startOvsdbManager(ovsdbListenPort);
+ }
+
+ @Override
+ public boolean startOvsdbManagerWithSsl(int ovsdbListenPort, SSLContext sslContext) {
+ return OvsdbConnectionService.getService().startOvsdbManagerWithSsl(ovsdbListenPort, sslContext);
+ }
+
+ @Override
+ public void registerConnectionListener(OvsdbConnectionListener listener) {
+ OvsdbConnectionService.getService().registerConnectionListener(listener);
+ }
+
+ @Override
+ public void unregisterConnectionListener(OvsdbConnectionListener listener) {
+ OvsdbConnectionService.getService().unregisterConnectionListener(listener);
+ }
+
+ @Override
+ public Collection<OvsdbClient> getConnections() {
+ return OvsdbConnectionService.getService().getConnections();
+ }
}
identity library {
base config:module-type;
config:java-name-prefix Library;
+ config:provided-service connection-service;
+ }
+
+ identity connection-service {
+ base config:service-type;
+ config:java-class "org.opendaylight.ovsdb.lib.OvsdbConnection";
}
augment "/config:modules/config:module/config:configuration" {
<artifactId>southbound-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>library-features</artifactId>
+ <type>xml</type>
+ <classifier>features</classifier>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
<repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
<repository>mvn:org.opendaylight.netconf/features-restconf/${restconf.version}/xml/features</repository>
<repository>mvn:org.opendaylight.mdsal.model/features-mdsal-model/${mdsal.model.version}/xml/features</repository>
+ <repository>mvn:org.opendaylight.ovsdb/library-features/${project.version}/xml/features</repository>
<feature name='odl-ovsdb-southbound-api' version='${project.version}' description='OpenDaylight :: southbound :: api '>
<feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
<bundle>mvn:org.opendaylight.ovsdb/southbound-api/${project.version}</bundle>
<feature version='${mdsal.version}'>odl-mdsal-broker</feature>
<feature version='${project.version}'>odl-ovsdb-southbound-api</feature>
<bundle>mvn:org.opendaylight.ovsdb/southbound-impl/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/library/${project.version}</bundle>
<bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle>
<bundle>mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle>
<bundle>mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle>
<bundle>mvn:io.netty/netty-common/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-handler/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-transport/${netty.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/${project.version}/xml/config</configfile>
</feature>
<feature name='odl-ovsdb-southbound-impl-rest' version='${project.version}' description='OpenDaylight :: southbound :: impl :: REST '>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Private-Package>!org.opendaylight.ovsdb.lib.osgi,org.opendaylight.ovsdb.lib.*,org.opendaylight.ovsdb.schema.openvswitch</Private-Package>
- <Export-Package>org.opendaylight.ovsdb.southbound.*,org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.southbound.impl.rev141210</Export-Package>
+ <!--<Private-Package>!org.opendaylight.ovsdb.lib.osgi,org.opendaylight.ovsdb.lib.*,org.opendaylight.ovsdb.schema.openvswitch</Private-Package>-->
+ <Export-Package>org.opendaylight.ovsdb.southbound.*,org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.southbound.impl.rev141210.*</Export-Package>
</instructions>
</configuration>
</plugin>
-->
<snapshot>
<required-capabilities>
- <!--<capability>urn:opendaylight:params:xml:ns:yang:southbound:impl?module=southbound-impl&revision=2015-01-05</capability>-->
+ <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>
<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>
public SouthboundProvider(
- EntityOwnershipService entityOwnershipServiceDependency) {
+ EntityOwnershipService entityOwnershipServiceDependency,
+ OvsdbConnection ovsdbConnection) {
this.entityOwnershipService = entityOwnershipServiceDependency;
registration = null;
+ this.ovsdbConnection = ovsdbConnection;
+ LOG.info("SouthboundProvider ovsdbConnectionService: {}", ovsdbConnection);
}
@Override
if (ownershipStateOpt.isPresent()) {
EntityOwnershipState ownershipState = ownershipStateOpt.get();
if (ownershipState.hasOwner() && !ownershipState.isOwner()) {
- if (ovsdbConnection == null) {
- ovsdbConnection = new OvsdbConnectionService();
- ovsdbConnection.registerConnectionListener(cm);
- ovsdbConnection.startOvsdbManager(SouthboundConstants.DEFAULT_OVSDB_PORT);
- }
+ ovsdbConnection.registerConnectionListener(cm);
+ ovsdbConnection.startOvsdbManager(SouthboundConstants.DEFAULT_OVSDB_PORT);
}
}
} catch (CandidateAlreadyRegisteredException e) {
public java.lang.AutoCloseable createInstance() {
SouthboundUtil.setInstanceIdentifierCodec(new InstanceIdentifierCodec(getSchemaServiceDependency(),
getBindingNormalizedNodeSerializerDependency()));
- SouthboundProvider provider = new SouthboundProvider(getClusteringEntityOwnershipServiceDependency());
+ SouthboundProvider provider = new SouthboundProvider(getClusteringEntityOwnershipServiceDependency(),
+ getConnectionServiceDependency());
getBrokerDependency().registerProvider(provider);
return provider;
}
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";
}
}
}
+ container connection-service {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity library:connection-service;
+ }
+ }
+ }
}
}
}
private static final Logger LOG = LoggerFactory.getLogger(SouthboundIT.class);
private static final int OVSDB_UPDATE_TIMEOUT = 1000;
private static final String FORMAT_STR = "%s_%s_%d";
- public static final int NUM_THREADS = 4;
+ public static final int NUM_THREADS = 1;
private static String addressStr;
private static int portNumber;
private static String connectionType;