+-- openvswitch : Schema wrapper that represents http://openvswitch.org/ovs-vswitchd.conf.db.5.pdf
+-- hardwarevtep: Schema wrapper that represents http://openvswitch.org/docs/vtep.5.pdf
-- utils : MD-SAL OpenFlow utilities.
+- utils : MD-SAL OpenFlow and OVSDB common utilities.
HOW TO BUILD & RUN
==================
<schema.openvswitch.version>1.1.0-SNAPSHOT</schema.openvswitch.version>
<schema.hardwarevtep.version>1.1.0-SNAPSHOT</schema.hardwarevtep.version>
<ovsdb.ofextension.version>1.1.0-SNAPSHOT</ovsdb.ofextension.version>
- <utils.mdsal.openflow>1.1.0-SNAPSHOT</utils.mdsal.openflow>
+ <ovsdb.utils.config.version>1.1.0-SNAPSHOT</ovsdb.utils.config.version>
+ <utils.mdsal.openflow.version>1.1.0-SNAPSHOT</utils.mdsal.openflow.version>
<ovsdb.ovssfc.version>0.1.0-SNAPSHOT</ovsdb.ovssfc.version>
<!-- Skip Coverage and IT by default -->
<skip.coverage>true</skip.coverage>
<packaging>bundle</packaging>
<dependencies>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.config</artifactId>
+ <version>${ovsdb.utils.config.version}</version>
+ </dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
org.osgi.framework,
javax.net.ssl,
*</Import-Package>
- <Bundle-Activator>org.opendaylight.ovsdb.lib.Activator</Bundle-Activator>
+ <Embed-Dependency>utils.config;type=!pom;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
+ <Bundle-Activator>org.opendaylight.ovsdb.lib.Activator</Bundle-Activator>
<Export-Package>
org.opendaylight.ovsdb.lib,
org.opendaylight.ovsdb.lib.error,
import org.opendaylight.ovsdb.lib.jsonrpc.JsonRpcEndpoint;
import org.opendaylight.ovsdb.lib.jsonrpc.JsonRpcServiceBinderHandler;
import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
+import org.opendaylight.ovsdb.utils.config.ConfigProperties;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* be overridden using the ovsdb.listenPort system property.
*/
private static void startOvsdbManager() {
- String portString = getProperty(OvsdbConnectionService.class, OVSDB_LISTENPORT);
+ String portString = ConfigProperties.getProperty(OvsdbConnectionService.class, OVSDB_LISTENPORT);
if (portString != null) {
ovsdbListenPort = Integer.decode(portString).intValue();
}
}.start();
}
- // TODO: move getProperty() to a common module
- private static String getProperty(Class<?> classParam, final String propertyStr) {
- String value = null;
- Bundle bundle = FrameworkUtil.getBundle(classParam);
-
- if (bundle != null) {
- BundleContext bundleContext = bundle.getBundleContext();
- if (bundleContext != null) {
- value = bundleContext.getProperty(propertyStr);
- }
- }
- if (value == null) {
- value = System.getProperty(propertyStr);
- }
- return value;
- }
-
/**
* OVSDB Passive listening thread that uses Netty ServerBootstrap to open passive connection
* and handle channel callbacks.
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>openstack.net-virt</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.config</artifactId>
+ <version>${ovsdb.utils.config.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>utils.mdsal-openflow</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>${utils.mdsal.openflow.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
org.osgi.framework,
*
</Import-Package>
- <Embed-Dependency>utils.mdsal-openflow;type=!pom;inline=false</Embed-Dependency>
+ <Embed-Dependency>utils.config,utils.mdsal-openflow;type=!pom;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Bundle-Activator>org.opendaylight.ovsdb.openstack.netvirt.providers.Activator</Bundle-Activator>
</instructions>
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>schema.openvswitch</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.config</artifactId>
+ <version>${ovsdb.utils.config.version}</version>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
org.slf4j,
org.osgi.framework,
*</Import-Package>
- <Export-Package>
+ <Embed-Dependency>utils.config;type=!pom;inline=false</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ <Export-Package>
org.opendaylight.ovsdb.openstack.netvirt.api
</Export-Package>
<Bundle-Activator>org.opendaylight.ovsdb.openstack.netvirt.Activator</Bundle-Activator>
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
+import org.opendaylight.ovsdb.utils.config.ConfigProperties;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public String getOpenflowVersion(Node node) {
- String configuredVersion = System.getProperty("ovsdb.of.version", "1.3");
+ String configuredVersion = ConfigProperties.getProperty(this.getClass(), "ovsdb.of.version", "1.3");
if (configuredVersion != null){
switch (configuredVersion){
case "1.0":
@Override
public String getDefaultGatewayMacAddress(Node node) {
final String l3gatewayForNode =
- node != null ? getProperty(this.getClass(), "ovsdb.l3gateway.mac." + node.getNodeIDString()) : null;
- return l3gatewayForNode != null ? l3gatewayForNode : getProperty(this.getClass(), "ovsdb.l3gateway.mac");
- }
-
- // TODO: move getProperty() to a common module
- private static String getProperty(Class<?> classParam, final String propertyStr) {
- String value = null;
- Bundle bundle = FrameworkUtil.getBundle(classParam);
-
- if (bundle != null) {
- BundleContext bundleContext = bundle.getBundleContext();
- if (bundleContext != null) {
- value = bundleContext.getProperty(propertyStr);
- }
- }
- if (value == null) {
- value = System.getProperty(propertyStr);
- }
- return value;
+ node != null ?
+ ConfigProperties.getProperty(this.getClass(), "ovsdb.l3gateway.mac." + node.getNodeIDString()) : null;
+ return l3gatewayForNode != null ?
+ l3gatewayForNode : ConfigProperties.getProperty(this.getClass(), "ovsdb.l3gateway.mac");
}
}
import org.opendaylight.ovsdb.openstack.netvirt.api.OutboundNatProvider;
import org.opendaylight.ovsdb.openstack.netvirt.api.RoutingProvider;
import org.opendaylight.ovsdb.schema.openvswitch.Interface;
+import org.opendaylight.ovsdb.utils.config.ConfigProperties;
import com.google.common.base.Preconditions;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private Boolean enabled = false;
void init() {
- final String enabledPropertyStr = getProperty(this.getClass(), "ovsdb.l3.fwd.enabled");
+ final String enabledPropertyStr = ConfigProperties.getProperty(this.getClass(), "ovsdb.l3.fwd.enabled");
if (enabledPropertyStr != null && enabledPropertyStr.equalsIgnoreCase("yes")) {
this.inboundIpRewriteCache = new HashSet<>();
this.outboundIpRewriteCache = new HashSet<>();
}
}
- // TODO: move getProperty() to a common module
- private static String getProperty(Class<?> classParam, final String propertyStr) {
- String value = null;
- Bundle bundle = FrameworkUtil.getBundle(classParam);
-
- if (bundle != null) {
- BundleContext bundleContext = bundle.getBundleContext();
- if (bundleContext != null) {
- value = bundleContext.getProperty(propertyStr);
- }
- }
- if (value == null) {
- value = System.getProperty(propertyStr);
- }
- return value;
- }
-
//
// Callbacks from OVSDB's northbound handlers
//
// TODO: As of Helium, mac address for default gateway is required (bug 1705).
if (defaultGatewayMacAddress == null) {
logger.error("ProgramDefaultRoute mac not provided. gatewayIp:{} node:{} action:{}",
- defaultGatewayMacAddress, gatewayIp, node, actionForNodeDefaultRoute);
+ gatewayIp, node, actionForNodeDefaultRoute);
return new Status(StatusCode.NOTIMPLEMENTED); // Bug 1705
}
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>plugin</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.config</artifactId>
+ <version>${ovsdb.utils.config.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>utils.mdsal-openflow</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>${utils.mdsal.openflow.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.sfc</groupId>
<extensions>true</extensions>
<configuration>
<instructions>
- <Embed-Dependency>utils.mdsal-openflow;type=!pom;inline=false</Embed-Dependency>
+ <Embed-Dependency>utils.config,utils.mdsal-openflow;type=!pom;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Include-Resource>
/OSGI-OPT/ovs-sfc/53-ovssfc-provider.xml=${project.basedir}/src/main/resources/initial/53-ovssfc-provider.xml,{maven-resources}
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>schema.openvswitch</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.config</artifactId>
+ <version>${ovsdb.utils.config.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>schema.hardwarevtep</artifactId>
javax.net.ssl,
*
</Import-Package>
- <Embed-Dependency>commons-codec,javax.servlet-api,portlet-api,commons-collections;type=!pom;inline=false</Embed-Dependency>
+ <Embed-Dependency>commons-codec,javax.servlet-api,portlet-api,commons-collections,utils.config;type=!pom;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Bundle-Activator>org.opendaylight.ovsdb.plugin.internal.Activator</Bundle-Activator>
<Private-Package>
package org.opendaylight.ovsdb.plugin;
+import org.opendaylight.ovsdb.utils.config.ConfigProperties;
+
import com.google.common.collect.Maps;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
import java.util.Map;
addParentColumnToMutate("Manager", "Open_vSwitch", "manager_options");
addParentColumnToMutate("Controller", "Bridge", "controller");
// Keep the default value if the property is not set
- final String autoConfigureControllerStr = getProperty(OvsVswitchdSchemaConstants.class, OVSDB_AUTOCONFIGURECONTROLLER);
+ final String autoConfigureControllerStr =
+ ConfigProperties.getProperty(OvsVswitchdSchemaConstants.class, OVSDB_AUTOCONFIGURECONTROLLER);
if (autoConfigureControllerStr != null) {
autoConfigureController = Boolean.getBoolean(autoConfigureControllerStr);
}
}
- // TODO: move getProperty() to a common module
- private static String getProperty(Class<?> classParam, final String propertyStr) {
- String value = null;
- Bundle bundle = FrameworkUtil.getBundle(classParam);
-
- if (bundle != null) {
- BundleContext bundleContext = bundle.getBundleContext();
- if (bundleContext != null) {
- value = bundleContext.getProperty(propertyStr);
- }
- }
- if (value == null) {
- value = System.getProperty(propertyStr);
- }
- return value;
- }
-
public static boolean shouldConfigureController (String databaseName, String tableName) {
if (autoConfigureController && databaseName.equals(DATABASE_NAME) && tableName.equals("Bridge")) return true;
return false;
package org.opendaylight.ovsdb.plugin.api;
+import org.opendaylight.ovsdb.utils.config.ConfigProperties;
+
import java.util.Map;
import com.google.common.collect.Maps;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
public final class OvsVswitchdSchemaConstants {
public static String DATABASE_NAME = "Open_vSwitch";
addParentColumnToMutate("Manager", "Open_vSwitch", "manager_options");
addParentColumnToMutate("Controller", "Bridge", "controller");
// Keep the default value if the property is not set
- final String autoConfigureControllerStr = getProperty(OvsVswitchdSchemaConstants.class, OVSDB_AUTOCONFIGURECONTROLLER);
+ final String autoConfigureControllerStr =
+ ConfigProperties.getProperty(OvsVswitchdSchemaConstants.class, OVSDB_AUTOCONFIGURECONTROLLER);
if (autoConfigureControllerStr != null) {
autoConfigureController = Boolean.getBoolean(autoConfigureControllerStr);
}
}
- // TODO: move getProperty() to a common module
- private static String getProperty(Class<?> classParam, final String propertyStr) {
- String value = null;
- Bundle bundle = FrameworkUtil.getBundle(classParam);
-
- if (bundle != null) {
- BundleContext bundleContext = bundle.getBundleContext();
- if (bundleContext != null) {
- value = bundleContext.getProperty(propertyStr);
- }
- }
- if (value == null) {
- value = System.getProperty(propertyStr);
- }
- return value;
- }
-
public static void setAutoConfigureController(boolean autoConfigure) {
autoConfigureController = autoConfigure;
}
import org.opendaylight.ovsdb.schema.openvswitch.Manager;
import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
import org.opendaylight.ovsdb.schema.openvswitch.Port;
+import org.opendaylight.ovsdb.utils.config.ConfigProperties;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
private InetAddress getControllerIPAddress(Connection connection) {
InetAddress controllerIP = null;
- String addressString = getProperty(this.getClass(), "ovsdb.controller.address");
+ String addressString = ConfigProperties.getProperty(this.getClass(), "ovsdb.controller.address");
if (addressString != null) {
try {
}
}
- addressString = getProperty(this.getClass(), "of.address");
+ addressString = ConfigProperties.getProperty(this.getClass(), "of.address");
if (addressString != null) {
try {
private short getControllerOFPort() {
Short defaultOpenFlowPort = 6633;
Short openFlowPort = defaultOpenFlowPort;
- String portString = getProperty(this.getClass(), "of.listenPort");
+ String portString = ConfigProperties.getProperty(this.getClass(), "of.listenPort");
if (portString != null) {
try {
openFlowPort = Short.decode(portString).shortValue();
return openFlowPort;
}
- // TODO: move getProperty() to a common module
- private static String getProperty(Class<?> classParam, final String propertyStr) {
- String value = null;
- Bundle bundle = FrameworkUtil.getBundle(classParam);
-
- if (bundle != null) {
- BundleContext bundleContext = bundle.getBundleContext();
- if (bundleContext != null) {
- value = bundleContext.getProperty(propertyStr);
- }
- }
- if (value == null) {
- value = System.getProperty(propertyStr);
- }
- return value;
- }
-
private UUID getCurrentControllerUuid(Node node, final String controllerTableName, final String target) {
ConcurrentMap<String, Row> rows = this.getRows(node, controllerTableName);
<module>plugin-shell</module>
<module>plugin-mdsal-adapter</module>
<module>northbound</module>
+ <module>utils/config</module>
<module>utils/mdsal-openflow</module>
<module>openstack/net-virt</module>
<module>openstack/net-virt-providers</module>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>commons</artifactId>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <version>1.3.0-SNAPSHOT</version>
+ <relativePath>../../commons/parent/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>utils.config</artifactId>
+ <name>OpenDaylight OVS common utility</name>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.dependencymanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * 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
+ *
+ * Authors : Flavio Fernandes, Sam Hague, Srini Seetharaman
+ */
+
+package org.opendaylight.ovsdb.utils.config;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+
+public class ConfigProperties {
+
+ public static String getProperty(Class<?> classParam, final String propertyStr) {
+ return getProperty(classParam, propertyStr, null);
+ }
+
+ public static String getProperty(Class<?> classParam, final String propertyStr, final String defaultValue) {
+ String value = null;
+ Bundle bundle = FrameworkUtil.getBundle(classParam);
+
+ if (bundle != null) {
+ BundleContext bundleContext = bundle.getBundleContext();
+ if (bundleContext != null) {
+ value = bundleContext.getProperty(propertyStr);
+ }
+ }
+ if (value == null) {
+ value = System.getProperty(propertyStr, defaultValue);
+ }
+ return value;
+ }
+}