<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.opendaylight</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <artifactId>commons.integrationtest</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ <relativePath>../../commons/integrationtest</relativePath>
</parent>
<artifactId>clustering.services.integrationtest</artifactId>
-package org.opendaylight.controller.clustering.services_implementation.internal;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.systemPackages;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-
-import java.net.InetAddress;
-import java.util.HashSet;
-import java.util.List;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.inject.Inject;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
-import org.opendaylight.controller.clustering.services.CacheListenerAddException;
-import org.opendaylight.controller.clustering.services.IClusterServices;
-import org.opendaylight.controller.clustering.services.IClusterServices.cacheMode;
-import org.opendaylight.controller.clustering.services.IGetUpdates;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.util.PathUtils;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@RunWith(PaxExam.class)
-public class ClusteringServicesIntegrationTest {
- private Logger log = LoggerFactory
- .getLogger(ClusteringServicesIntegrationTest.class);
- // get the OSGI bundle context
- @Inject
- private BundleContext bc;
-
- private IClusterServices clusterServices = null;
-
- // Configure the OSGi container
- @Configuration
- public Option[] config() {
- return options(
- //
- systemProperty("logback.configurationFile").value(
- "file:" + PathUtils.getBaseDir()
- + "/src/test/resources/logback.xml"),
- // To start OSGi console for inspection remotely
- systemProperty("osgi.console").value("2401"),
- // Set the systemPackages (used by clustering)
- systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
- // List framework bundles
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.console",
- "1.0.0.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.util",
- "1.0.400.v20120522-2049"),
- mavenBundle("equinoxSDK381", "org.eclipse.osgi.services",
- "3.3.100.v20120522-1822"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds",
- "1.4.0.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command",
- "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime",
- "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",
- "0.8.0.v201110170705"),
- // List logger bundles
- mavenBundle("org.slf4j", "slf4j-api", "1.7.2"),
- mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"),
- mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),
- mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),
- // List all the bundles on which the test case depends
- mavenBundle("org.opendaylight.controller",
- "clustering.services", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller",
- "clustering.services-implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "sal",
- "0.5.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller",
- "sal.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.jboss.spec.javax.transaction",
- "jboss-transaction-api_1.1_spec", "1.0.1.Final"),
- mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
- mavenBundle("org.apache.felix",
- "org.apache.felix.dependencymanager", "3.1.0"),
- junitBundles());
- }
-
- private String stateToString(int state) {
- switch (state) {
- case Bundle.ACTIVE:
- return "ACTIVE";
- case Bundle.INSTALLED:
- return "INSTALLED";
- case Bundle.RESOLVED:
- return "RESOLVED";
- case Bundle.UNINSTALLED:
- return "UNINSTALLED";
- default:
- return "Not CONVERTED";
- }
- }
-
- @Before
- public void areWeReady() {
- assertNotNull(bc);
- boolean debugit = false;
- Bundle b[] = bc.getBundles();
- for (int i = 0; i < b.length; i++) {
- int state = b[i].getState();
- if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {
- log.debug("Bundle:" + b[i].getSymbolicName() + " state:"
- + stateToString(state));
- debugit = true;
- }
- }
- if (debugit) {
- log.debug("Do some debugging because some bundle is "
- + "unresolved");
- }
-
- // Assert if true, if false we are good to go!
- assertFalse(debugit);
-
- ServiceReference r = bc.getServiceReference(IClusterServices.class
- .getName());
- if (r != null) {
- this.clusterServices = (IClusterServices) bc.getService(r);
- }
- assertNotNull(this.clusterServices);
-
- }
-
- @Test
- public void clusterTest() throws CacheExistException, CacheConfigException,
- CacheListenerAddException {
-
- String container1 = "Container1";
- String container2 = "Container2";
- String cache1 = "Cache1";
- String cache2 = "Cache2";
- String cache3 = "Cache3";
-
- HashSet<cacheMode> cacheModeSet = new HashSet<cacheMode>();
- cacheModeSet.add(cacheMode.NON_TRANSACTIONAL);
- ConcurrentMap cm11 = this.clusterServices.createCache(container1,
- cache1, cacheModeSet);
- assertNotNull(cm11);
-
- assertNull(this.clusterServices.getCache(container2, cache2));
- assertEquals(cm11, this.clusterServices.getCache(container1, cache1));
-
- assertFalse(this.clusterServices.existCache(container2, cache2));
- assertTrue(this.clusterServices.existCache(container1, cache1));
-
- ConcurrentMap cm12 = this.clusterServices.createCache(container1,
- cache2, cacheModeSet);
- ConcurrentMap cm23 = this.clusterServices.createCache(container2,
- cache3, cacheModeSet);
-
- HashSet<String> cacheList = (HashSet<String>) this.clusterServices
- .getCacheList(container1);
- assertEquals(2, cacheList.size());
- assertTrue(cacheList.contains(cache1));
- assertTrue(cacheList.contains(cache2));
- assertFalse(cacheList.contains(cache3));
-
- assertNotNull(this.clusterServices.getCacheProperties(container1,
- cache1));
-
- HashSet<IGetUpdates<?, ?>> listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices
- .getListeners(container1, cache1);
- assertEquals(0, listeners.size());
-
- IGetUpdates<?, ?> getUpdate1 = new GetUpdates();
- this.clusterServices.addListener(container1, cache1, getUpdate1);
- listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices
- .getListeners(container1, cache1);
- assertEquals(1, listeners.size());
- this.clusterServices.addListener(container1, cache1, new GetUpdates());
- listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices
- .getListeners(container1, cache1);
- assertEquals(2, listeners.size());
-
- listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices
- .getListeners(container2, cache3);
- assertEquals(0, listeners.size());
-
- this.clusterServices.removeListener(container1, cache1, getUpdate1);
- listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices
- .getListeners(container1, cache1);
- assertEquals(1, listeners.size());
-
- InetAddress addr = this.clusterServices.getMyAddress();
- assertNotNull(addr);
-
- List<InetAddress> addrList = this.clusterServices
- .getClusteredControllers();
-
- this.clusterServices.destroyCache(container1, cache1);
- assertFalse(this.clusterServices.existCache(container1, cache1));
-
- }
-
- private class GetUpdates implements IGetUpdates<Integer, String> {
-
- @Override
- public void entryCreated(Integer key, String containerName,
- String cacheName, boolean originLocal) {
- return;
- }
-
- @Override
- public void entryUpdated(Integer key, String new_value,
- String containerName, String cacheName, boolean originLocal) {
- return;
- }
-
- @Override
- public void entryDeleted(Integer key, String containerName,
- String cacheName, boolean originLocal) {
- return;
- }
- }
-}
+package org.opendaylight.controller.clustering.services_implementation.internal;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertFalse;\r
+import static org.junit.Assert.assertNotNull;\r
+import static org.junit.Assert.assertNull;\r
+import static org.junit.Assert.assertTrue;\r
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;\r
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;\r
+import static org.ops4j.pax.exam.CoreOptions.options;\r
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;\r
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;\r
+\r
+import java.net.InetAddress;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.concurrent.ConcurrentMap;\r
+\r
+import javax.inject.Inject;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.opendaylight.controller.clustering.services.CacheConfigException;\r
+import org.opendaylight.controller.clustering.services.CacheExistException;\r
+import org.opendaylight.controller.clustering.services.CacheListenerAddException;\r
+import org.opendaylight.controller.clustering.services.IClusterServices;\r
+import org.opendaylight.controller.clustering.services.IClusterServices.cacheMode;\r
+import org.opendaylight.controller.clustering.services.IGetUpdates;\r
+import org.ops4j.pax.exam.Option;\r
+import org.ops4j.pax.exam.junit.Configuration;\r
+import org.ops4j.pax.exam.junit.PaxExam;\r
+import org.ops4j.pax.exam.util.PathUtils;\r
+import org.osgi.framework.Bundle;\r
+import org.osgi.framework.BundleContext;\r
+import org.osgi.framework.ServiceReference;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+@RunWith(PaxExam.class)\r
+public class ClusteringServicesIT {\r
+ private Logger log = LoggerFactory\r
+ .getLogger(ClusteringServicesIT.class);\r
+ // get the OSGI bundle context\r
+ @Inject\r
+ private BundleContext bc;\r
+\r
+ private IClusterServices clusterServices = null;\r
+\r
+ // Configure the OSGi container\r
+ @Configuration\r
+ public Option[] config() {\r
+ return options(\r
+ //\r
+ systemProperty("logback.configurationFile").value(\r
+ "file:" + PathUtils.getBaseDir()\r
+ + "/src/test/resources/logback.xml"),\r
+ // To start OSGi console for inspection remotely\r
+ systemProperty("osgi.console").value("2401"),\r
+ // Set the systemPackages (used by clustering)\r
+ systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),\r
+ // List framework bundles\r
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.console",\r
+ "1.0.0.v20120522-1841"),\r
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.util",\r
+ "1.0.400.v20120522-2049"),\r
+ mavenBundle("equinoxSDK381", "org.eclipse.osgi.services",\r
+ "3.3.100.v20120522-1822"),\r
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds",\r
+ "1.4.0.v20120522-1841"),\r
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command",\r
+ "0.8.0.v201108120515"),\r
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime",\r
+ "0.8.0.v201108120515"),\r
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",\r
+ "0.8.0.v201110170705"),\r
+ // List logger bundles\r
+ mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),\r
+ mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(),\r
+ mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(),\r
+ mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(),\r
+ // List all the bundles on which the test case depends\r
+ mavenBundle("org.opendaylight.controller",\r
+ "clustering.services").versionAsInProject(),\r
+ mavenBundle("org.opendaylight.controller",\r
+ "clustering.services-implementation").versionAsInProject(),\r
+ mavenBundle("org.opendaylight.controller", "sal").versionAsInProject(),\r
+ mavenBundle("org.opendaylight.controller",\r
+ "sal.implementation").versionAsInProject(),\r
+ mavenBundle("org.jboss.spec.javax.transaction",\r
+ "jboss-transaction-api_1.1_spec").versionAsInProject(),\r
+ mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(),\r
+ mavenBundle("org.apache.felix",\r
+ "org.apache.felix.dependencymanager").versionAsInProject(),\r
+ junitBundles());\r
+ }\r
+\r
+ private String stateToString(int state) {\r
+ switch (state) {\r
+ case Bundle.ACTIVE:\r
+ return "ACTIVE";\r
+ case Bundle.INSTALLED:\r
+ return "INSTALLED";\r
+ case Bundle.RESOLVED:\r
+ return "RESOLVED";\r
+ case Bundle.UNINSTALLED:\r
+ return "UNINSTALLED";\r
+ default:\r
+ return "Not CONVERTED";\r
+ }\r
+ }\r
+\r
+ @Before\r
+ public void areWeReady() {\r
+ assertNotNull(bc);\r
+ boolean debugit = false;\r
+ Bundle b[] = bc.getBundles();\r
+ for (int i = 0; i < b.length; i++) {\r
+ int state = b[i].getState();\r
+ if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {\r
+ log.debug("Bundle:" + b[i].getSymbolicName() + " state:"\r
+ + stateToString(state));\r
+ debugit = true;\r
+ }\r
+ }\r
+ if (debugit) {\r
+ log.debug("Do some debugging because some bundle is "\r
+ + "unresolved");\r
+ }\r
+\r
+ // Assert if true, if false we are good to go!\r
+ assertFalse(debugit);\r
+\r
+ ServiceReference r = bc.getServiceReference(IClusterServices.class\r
+ .getName());\r
+ if (r != null) {\r
+ this.clusterServices = (IClusterServices) bc.getService(r);\r
+ }\r
+ assertNotNull(this.clusterServices);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void clusterTest() throws CacheExistException, CacheConfigException,\r
+ CacheListenerAddException {\r
+\r
+ String container1 = "Container1";\r
+ String container2 = "Container2";\r
+ String cache1 = "Cache1";\r
+ String cache2 = "Cache2";\r
+ String cache3 = "Cache3";\r
+\r
+ HashSet<cacheMode> cacheModeSet = new HashSet<cacheMode>();\r
+ cacheModeSet.add(cacheMode.NON_TRANSACTIONAL);\r
+ ConcurrentMap cm11 = this.clusterServices.createCache(container1,\r
+ cache1, cacheModeSet);\r
+ assertNotNull(cm11);\r
+\r
+ assertNull(this.clusterServices.getCache(container2, cache2));\r
+ assertEquals(cm11, this.clusterServices.getCache(container1, cache1));\r
+\r
+ assertFalse(this.clusterServices.existCache(container2, cache2));\r
+ assertTrue(this.clusterServices.existCache(container1, cache1));\r
+\r
+ ConcurrentMap cm12 = this.clusterServices.createCache(container1,\r
+ cache2, cacheModeSet);\r
+ ConcurrentMap cm23 = this.clusterServices.createCache(container2,\r
+ cache3, cacheModeSet);\r
+\r
+ HashSet<String> cacheList = (HashSet<String>) this.clusterServices\r
+ .getCacheList(container1);\r
+ assertEquals(2, cacheList.size());\r
+ assertTrue(cacheList.contains(cache1));\r
+ assertTrue(cacheList.contains(cache2));\r
+ assertFalse(cacheList.contains(cache3));\r
+\r
+ assertNotNull(this.clusterServices.getCacheProperties(container1,\r
+ cache1));\r
+\r
+ HashSet<IGetUpdates<?, ?>> listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices\r
+ .getListeners(container1, cache1);\r
+ assertEquals(0, listeners.size());\r
+\r
+ IGetUpdates<?, ?> getUpdate1 = new GetUpdates();\r
+ this.clusterServices.addListener(container1, cache1, getUpdate1);\r
+ listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices\r
+ .getListeners(container1, cache1);\r
+ assertEquals(1, listeners.size());\r
+ this.clusterServices.addListener(container1, cache1, new GetUpdates());\r
+ listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices\r
+ .getListeners(container1, cache1);\r
+ assertEquals(2, listeners.size());\r
+\r
+ listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices\r
+ .getListeners(container2, cache3);\r
+ assertEquals(0, listeners.size());\r
+\r
+ this.clusterServices.removeListener(container1, cache1, getUpdate1);\r
+ listeners = (HashSet<IGetUpdates<?, ?>>) this.clusterServices\r
+ .getListeners(container1, cache1);\r
+ assertEquals(1, listeners.size());\r
+\r
+ InetAddress addr = this.clusterServices.getMyAddress();\r
+ assertNotNull(addr);\r
+\r
+ List<InetAddress> addrList = this.clusterServices\r
+ .getClusteredControllers();\r
+\r
+ this.clusterServices.destroyCache(container1, cache1);\r
+ assertFalse(this.clusterServices.existCache(container1, cache1));\r
+\r
+ }\r
+\r
+ private class GetUpdates implements IGetUpdates<Integer, String> {\r
+\r
+ @Override\r
+ public void entryCreated(Integer key, String containerName,\r
+ String cacheName, boolean originLocal) {\r
+ return;\r
+ }\r
+\r
+ @Override\r
+ public void entryUpdated(Integer key, String new_value,\r
+ String containerName, String cacheName, boolean originLocal) {\r
+ return;\r
+ }\r
+\r
+ @Override\r
+ public void entryDeleted(Integer key, String containerName,\r
+ String cacheName, boolean originLocal) {\r
+ return;\r
+ }\r
+ }\r
+}\r
javax.transaction,
org.eclipse.osgi.framework.console,
ch.qos.logback.classic,
- org.opendaylight.controller.clustering.services
+ org.opendaylight.controller.clustering.services,
+ org.opendaylight.controller.sal.core,
+ org.apache.felix.dm
</Import-Package>
- <Service-Component>
- OSGI-INF/component.xml
- </Service-Component>
+ <Bundle-Activator>
+ org.opendaylight.controller.clustering.test.internal.Activator
+ </Bundle-Activator>
</instructions>
<manifestLocation>${project.basedir}/META-INF</manifestLocation>
</configuration>
<artifactId>clustering.services</artifactId>
<version>0.4.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
--- /dev/null
+
+/*
+ * Copyright (c) 2013 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.controller.clustering.test.internal;
+
+import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
+import org.opendaylight.controller.clustering.services.IClusterServices;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.felix.dm.Component;
+
+public class Activator extends ComponentActivatorAbstractBase {
+ protected static final Logger logger = LoggerFactory
+ .getLogger(Activator.class);
+
+ /**
+ * Function called when the activator starts just after some
+ * initializations are done by the
+ * ComponentActivatorAbstractBase.
+ *
+ */
+ public void init() {
+ }
+
+ /**
+ * Function called when the activator stops just before the
+ * cleanup done by ComponentActivatorAbstractBase
+ *
+ */
+ public void destroy() {
+ }
+
+ /**
+ * Function that is used to communicate to dependency manager the
+ * list of known implementations for services inside a container
+ *
+ *
+ * @return An array containing all the CLASS objects that will be
+ * instantiated in order to get an fully working implementation
+ * Object
+ */
+ public Object[] getGlobalImplementations() {
+ Object[] res = { SimpleClient.class };
+ return res;
+ }
+
+ /**
+ * Function that is called when configuration of the dependencies
+ * is required.
+ *
+ * @param c dependency manager Component object, used for
+ * configuring the dependencies exported and imported
+ * @param imp Implementation class that is being configured,
+ * needed as long as the same routine can configure multiple
+ * implementations
+ */
+ public void configureGlobalInstance(Component c, Object imp) {
+ if (imp.equals(SimpleClient.class)) {
+ // export the service for Apps and Plugins
+ c.setInterface(new String[] { org.eclipse.osgi.framework.console.CommandProvider.class.getName() },
+ null);
+ c.add(createServiceDependency().setService(IClusterServices.class)
+ .setCallbacks("setIClusterServices", "unsetIClusterServices")
+ .setRequired(true));
+ }
+ }
+}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
- activate="startUp"
- deactivate="shutDown"
- name="org.opendaylight.controller.clustering.test.internal.SimpleClient">
- <implementation class="org.opendaylight.controller.clustering.test.internal.SimpleClient"/>
-
- <service>
- <!-- Exports, can be multiple-->
- <provide interface="org.eclipse.osgi.framework.console.CommandProvider"/>
- </service>
-
- <!-- Imports, can be multiple -->
- <reference name="IClusterServices"
- bind="setIClusterServices"
- unbind="unsetIClusterServices"
- cardinality="1..1"
- interface="org.opendaylight.controller.clustering.services.IClusterServices"/>
-</scr:component>
<extensions>true</extensions>\r
<configuration>\r
<instructions>\r
- <Import-Package>\r
- org.slf4j,\r
- org.osgi.framework,\r
- org.apache.commons.lang3.builder,\r
- org.apache.felix.dm,\r
- org.apache.commons.lang3.tuple,\r
- javax.xml.bind.annotation,\r
- javax.xml.bind.annotation.adapters\r
- </Import-Package>\r
<Export-Package>\r
org.opendaylight.controller.concepts.transform\r
</Export-Package>\r
* and is available at http://www.eclipse.org/legal/epl-v10.html\r
*/\r
\r
-package org.opendaylight.controller.concepts.tranform;\r
+package org.opendaylight.controller.concepts.transform;\r
\r
public interface Acceptor<I> {\r
\r
* and is available at http://www.eclipse.org/legal/epl-v10.html\r
*/\r
\r
-package org.opendaylight.controller.concepts.tranform;\r
+package org.opendaylight.controller.concepts.transform;\r
\r
import java.util.Collection;\r
/**\r
* and is available at http://www.eclipse.org/legal/epl-v10.html\r
*/\r
\r
-package org.opendaylight.controller.concepts.tranform;\r
+package org.opendaylight.controller.concepts.transform;\r
\r
import java.util.ArrayList;\r
import java.util.Collection;\r
* and is available at http://www.eclipse.org/legal/epl-v10.html\r
*/\r
\r
-package org.opendaylight.controller.concepts.tranform;\r
+package org.opendaylight.controller.concepts.transform;\r
\r
import java.util.ArrayList;\r
import java.util.Collection;\r
/**\r
* Composite transformer which aggregates multiple implementation and selects\r
* the one which accepts the input.\r
- * \r
- * \r
+ *\r
+ *\r
* @author Tony Tkacik\r
- * \r
+ *\r
* @param <I>\r
* Input class for transformation\r
* @param <P>\r
@Override\r
public int compare(TransformerWithPriority<I, P> o1,\r
TransformerWithPriority<I, P> o2) {\r
- return Integer.compare(o1.priority, o2.priority);\r
+ return Integer.valueOf(o1.priority).compareTo(Integer.valueOf(o2.priority));\r
}\r
\r
};\r
SimpleConditionalTransformer<I, P> {\r
final int priority;\r
final SimpleConditionalTransformer<I, P> transformer;\r
- \r
+\r
public TransformerWithPriority(\r
SimpleConditionalTransformer<I, P> transformer, int priority) {\r
this.priority = priority;\r
this.transformer = transformer;\r
}\r
- \r
+\r
@Override\r
public int hashCode() {\r
final int prime = 31;\r
+ ((transformer == null) ? 0 : transformer.hashCode());\r
return result;\r
}\r
- \r
+\r
@Override\r
public boolean equals(Object obj) {\r
if (this == obj)\r
return false;\r
return true;\r
}\r
- \r
+\r
@Override\r
public boolean isAcceptable(I input) {\r
return transformer.isAcceptable(input);\r
}\r
- \r
+\r
@Override\r
public P transform(I input) {\r
return transformer.transform(input);\r
}\r
- \r
- \r
- \r
- \r
- \r
+\r
+\r
+\r
+\r
+\r
}\r
}\r
* and is available at http://www.eclipse.org/legal/epl-v10.html\r
*/\r
\r
-package org.opendaylight.controller.concepts.tranform;\r
+package org.opendaylight.controller.concepts.transform;\r
\r
/**\r
* Input class based transformer\r
* and is available at http://www.eclipse.org/legal/epl-v10.html\r
*/\r
\r
-package org.opendaylight.controller.concepts.tranform;\r
+package org.opendaylight.controller.concepts.transform;\r
\r
import java.util.Set;\r
\r
* and is available at http://www.eclipse.org/legal/epl-v10.html\r
*/\r
\r
-package org.opendaylight.controller.concepts.tranform;\r
+package org.opendaylight.controller.concepts.transform;\r
\r
/**\r
* Simple condition-based transformer\r
* and is available at http://www.eclipse.org/legal/epl-v10.html\r
*/\r
\r
-package org.opendaylight.controller.concepts.tranform;\r
+package org.opendaylight.controller.concepts.transform;\r
\r
/**\r
* Factory which produces product based on input object\r
--- /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">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.opendaylight</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../../commons/opendaylight</relativePath>
+ </parent>
+
+ <artifactId>commons.integrationtest</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.equinox.console</artifactId>
+ <version>1.0.0.v20120522-1841</version>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.equinox.util</artifactId>
+ <version>1.0.400.v20120522-2049</version>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi.services</artifactId>
+ <version>3.3.100.v20120522-1822</version>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.equinox.ds</artifactId>
+ <version>1.4.0.v20120522-1841</version>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.apache.felix.gogo.command</artifactId>
+ <version>0.8.0.v201108120515</version>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.apache.felix.gogo.runtime</artifactId>
+ <version>0.8.0.v201108120515</version>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.apache.felix.gogo.shell</artifactId>
+ <version>0.8.0.v201110170705</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>maven-paxexam-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-config</id>
+ <goals>
+ <goal>generate-depends-file</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
<configFile>${project.parent.relativePath}/sun_coding_style.xml</configFile>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>2.14.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<pluginManagement>
<plugins>
<ignore/>
</action>
</pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>maven-paxexam-plugin</artifactId>
+ <versionRange>[1.2.4,)</versionRange>
+ <goals>
+ <goal>generate-depends-file</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
<booleanAttribute key="default" value="true"/>
<booleanAttribute key="default_auto_start" value="true"/>
<intAttribute key="default_start_level" value="4"/>
+<stringAttribute key="deselected_workspace_plugins" value="org.opendaylight.controller.clustering.stub,org.opendaylight.controller.protocol_plugins.stub"/>
<booleanAttribute key="includeOptional" value="false"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dorg.osgi.framework.system.packages.extra=sun.reflect,sun.reflect.misc,sun.misc -Dosgi.hook.configurators.include=org.eclipse.virgo.kernel.equinox.extensions.hooks.ExtensionsHookConfigurator -Dlogback.configurationFile=${project_loc:/distribution.opendaylight}/src/main/resources/configuration/logback.xml -Dorg.eclipse.gemini.web.tomcat.config.path=${project_loc:/distribution.opendaylight}/src/main/resources/configuration/tomcat-server.xml -Dosgi.frameworkClassPath=file:${project_loc:/distribution.opendaylight}/../p2site/target/repository/plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar,file:${project_loc:/distribution.opendaylight}/../p2site/target/repository/plugins/org.eclipse.virgo.kernel.equinox.extensions_3.6.0.RELEASE.jar,file:${project_loc:/distribution.opendaylight}/../p2site/target/repository/plugins/org.eclipse.osgi_3.8.1.v20120830-144521.jar"/>
<stringAttribute key="pde.version" value="3.3"/>
<booleanAttribute key="show_selected_only" value="false"/>
-<stringAttribute key="target_bundles" value="ch.qos.logback.classic@default:default,ch.qos.logback.core@default:default,chameleon-mbeans@default:default,com.google.gson@default:default,com.springsource.org.aopalliance@default:default,com.sun.jersey.client@default:default,com.sun.jersey.core@default:default,com.sun.jersey.jersey-server@default:default,com.sun.jersey.json@default:default,jackson-core-asl@default:default,jackson-jaxrs@default:default,jackson-mapper-asl@default:default,javax.activation@default:default,javax.annotation@default:default,javax.ejb@default:default,javax.el@default:default,javax.mail.glassfish@default:default,javax.persistence@default:default,javax.servlet.jsp.jstl.impl@default:default,javax.servlet.jsp.jstl@default:default,javax.servlet.jsp@default:default,javax.servlet@default:default,javax.xml.rpc@default:default,jcl.over.slf4j@default:default,log4j.over.slf4j@default:default,org.apache.catalina.ha@default:false,org.apache.catalina.tribes@default:false,org.apache.catalina@default:default,org.apache.commons.fileupload@default:default,org.apache.commons.io@default:default,org.apache.commons.lang3@default:default,org.apache.coyote@default:false,org.apache.el@default:default,org.apache.felix.dependencymanager.shell@default:default,org.apache.felix.dependencymanager@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.apache.jasper@default:false,org.apache.juli.extras@default:default,org.apache.tomcat.api@default:default,org.apache.tomcat.util@default:false,org.codehaus.jettison.jettison@default:default,org.eclipse.equinox.cm@default:default,org.eclipse.equinox.console@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.util@default:default,org.eclipse.gemini.web.core@default:default,org.eclipse.gemini.web.extender@default:default,org.eclipse.gemini.web.tomcat@default:default,org.eclipse.jdt.core.compiler.batch@default:default,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.virgo.kernel.equinox.extensions@default:false,org.eclipse.virgo.util.common@default:default,org.eclipse.virgo.util.io@default:default,org.eclipse.virgo.util.math@default:default,org.eclipse.virgo.util.osgi.manifest@default:default,org.eclipse.virgo.util.osgi@default:default,org.eclipse.virgo.util.parser.manifest@default:default,org.jboss.spec.javax.transaction.jboss-transaction-api_1.1_spec@default:default,org.springframework.aop@default:default,org.springframework.asm@default:default,org.springframework.beans@default:default,org.springframework.context.support@default:default,org.springframework.context@default:default,org.springframework.core@default:default,org.springframework.expression@default:default,org.springframework.security.config@default:default,org.springframework.security.core@default:default,org.springframework.security.taglibs@default:default,org.springframework.security.web@default:default,org.springframework.transaction@default:default,org.springframework.web.servlet@default:default,org.springframework.web@default:default,slf4j.api@default:default"/>
+<stringAttribute key="target_bundles" value="ch.qos.logback.classic@default:default,ch.qos.logback.core@default:default,chameleon-mbeans@default:default,com.google.gson@default:default,com.springsource.org.aopalliance@default:default,com.sun.jersey.client@1:default,com.sun.jersey.core@1:default,com.sun.jersey.jersey-server@1:default,com.sun.jersey.json@1:default,jackson-core-asl@default:default,jackson-jaxrs@default:default,jackson-mapper-asl@default:default,javax.activation@default:default,javax.annotation@default:default,javax.ejb@default:default,javax.el@default:default,javax.mail.glassfish@default:default,javax.persistence@default:default,javax.servlet.jsp.jstl.impl@default:default,javax.servlet.jsp.jstl@default:default,javax.servlet.jsp@default:default,javax.servlet@default:default,javax.xml.rpc@default:default,jcl.over.slf4j@default:default,log4j.over.slf4j@default:default,org.apache.catalina.ha@default:false,org.apache.catalina.tribes@default:false,org.apache.catalina@default:default,org.apache.commons.fileupload@default:default,org.apache.commons.io@default:default,org.apache.commons.lang3@default:default,org.apache.coyote@default:false,org.apache.el@default:default,org.apache.felix.dependencymanager.shell@default:default,org.apache.felix.dependencymanager@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.apache.jasper@default:false,org.apache.juli.extras@default:default,org.apache.tomcat.api@default:default,org.apache.tomcat.util@default:false,org.codehaus.jettison.jettison@default:default,org.eclipse.equinox.cm@default:default,org.eclipse.equinox.console@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.util@default:default,org.eclipse.gemini.web.core@default:default,org.eclipse.gemini.web.extender@default:default,org.eclipse.gemini.web.tomcat@default:default,org.eclipse.jdt.core.compiler.batch@default:default,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.virgo.kernel.equinox.extensions@default:false,org.eclipse.virgo.util.common@default:default,org.eclipse.virgo.util.io@default:default,org.eclipse.virgo.util.math@default:default,org.eclipse.virgo.util.osgi.manifest@default:default,org.eclipse.virgo.util.osgi@default:default,org.eclipse.virgo.util.parser.manifest@default:default,org.jboss.spec.javax.transaction.jboss-transaction-api_1.1_spec@default:default,org.springframework.aop@default:default,org.springframework.asm@default:default,org.springframework.beans@default:default,org.springframework.context.support@default:default,org.springframework.context@default:default,org.springframework.core@default:default,org.springframework.expression@default:default,org.springframework.security.config@default:default,org.springframework.security.core@default:default,org.springframework.security.taglibs@default:default,org.springframework.security.web@default:default,org.springframework.transaction@default:default,org.springframework.web.servlet@default:default,org.springframework.web@default:default,slf4j.api@default:default"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
<booleanAttribute key="useDefaultConfigArea" value="true"/>
-<stringAttribute key="workspace_bundles" value="org.opendaylight.controller.arphandler@default:default,org.opendaylight.controller.clustering.services-implementation@default:default,org.opendaylight.controller.clustering.services@default:default,org.opendaylight.controller.clustering.stub@default:default,org.opendaylight.controller.clustering.test@default:default,org.opendaylight.controller.commons.northbound@default:default,org.opendaylight.controller.configuration.implementation@default:default,org.opendaylight.controller.configuration@default:default,org.opendaylight.controller.containermanager.implementation@default:default,org.opendaylight.controller.containermanager@default:default,org.opendaylight.controller.devices.web@default:default,org.opendaylight.controller.flowprogrammer.northbound@default:default,org.opendaylight.controller.flows.web@default:default,org.opendaylight.controller.forwarding.staticrouting.northbound@default:default,org.opendaylight.controller.forwarding.staticrouting@default:default,org.opendaylight.controller.forwardingrulesmanager.implementation@default:default,org.opendaylight.controller.forwardingrulesmanager@default:default,org.opendaylight.controller.hosttracker.implementation@default:default,org.opendaylight.controller.hosttracker.northbound@default:default,org.opendaylight.controller.hosttracker@default:default,org.opendaylight.controller.logging.bridge@default:default,org.opendaylight.controller.protocol_plugins.openflow@default:default,org.opendaylight.controller.protocol_plugins.stub@default:default,org.opendaylight.controller.routing.dijkstra_implementation@default:default,org.opendaylight.controller.sal.implementation@default:default,org.opendaylight.controller.sal@default:default,org.opendaylight.controller.samples.loadbalancer.northbound@default:default,org.opendaylight.controller.samples.loadbalancer@default:default,org.opendaylight.controller.samples.simpleforwarding@default:default,org.opendaylight.controller.security@default:false,org.opendaylight.controller.statistics.northbound@default:default,org.opendaylight.controller.statisticsmanager.implementation@default:default,org.opendaylight.controller.statisticsmanager@default:default,org.opendaylight.controller.subnets.northbound@default:default,org.opendaylight.controller.switchmanager.implementation@default:default,org.opendaylight.controller.switchmanager.northbound@default:default,org.opendaylight.controller.switchmanager@default:default,org.opendaylight.controller.thirdparty.com.sun.jersey.jersey-servlet@default:default,org.opendaylight.controller.thirdparty.net.sf.jung2@default:default,org.opendaylight.controller.thirdparty.org.openflow.openflowj@default:default,org.opendaylight.controller.topology.northbound@default:default,org.opendaylight.controller.topology.web@default:default,org.opendaylight.controller.topologymanager@default:default,org.opendaylight.controller.troubleshoot.web@default:default,org.opendaylight.controller.usermanager@default:default,org.opendaylight.controller.web@default:default"/>
+<stringAttribute key="workspace_bundles" value="org.opendaylight.controller.arphandler@default:default,org.opendaylight.controller.clustering.services-implementation@default:default,org.opendaylight.controller.clustering.services@default:default,org.opendaylight.controller.clustering.test@default:default,org.opendaylight.controller.commons.northbound@default:default,org.opendaylight.controller.concepts@default:default,org.opendaylight.controller.configuration.implementation@default:default,org.opendaylight.controller.configuration@default:default,org.opendaylight.controller.containermanager.implementation@default:default,org.opendaylight.controller.containermanager@default:default,org.opendaylight.controller.devices.web@default:default,org.opendaylight.controller.flowprogrammer.northbound@default:default,org.opendaylight.controller.flows.web@default:default,org.opendaylight.controller.forwarding.staticrouting.northbound@default:default,org.opendaylight.controller.forwarding.staticrouting@default:default,org.opendaylight.controller.forwardingrulesmanager.implementation@default:default,org.opendaylight.controller.forwardingrulesmanager@default:default,org.opendaylight.controller.hosttracker.implementation@default:default,org.opendaylight.controller.hosttracker.northbound@default:default,org.opendaylight.controller.hosttracker@default:default,org.opendaylight.controller.logging.bridge@default:default,org.opendaylight.controller.protocol_plugins.openflow@default:default,org.opendaylight.controller.routing.dijkstra_implementation@default:default,org.opendaylight.controller.sal.implementation@default:default,org.opendaylight.controller.sal@default:default,org.opendaylight.controller.samples.loadbalancer.northbound@default:default,org.opendaylight.controller.samples.loadbalancer@default:default,org.opendaylight.controller.samples.simpleforwarding@default:default,org.opendaylight.controller.security@default:false,org.opendaylight.controller.statistics.northbound@default:default,org.opendaylight.controller.statisticsmanager.implementation@default:default,org.opendaylight.controller.statisticsmanager@default:default,org.opendaylight.controller.subnets.northbound@default:default,org.opendaylight.controller.switchmanager.implementation@default:default,org.opendaylight.controller.switchmanager.northbound@default:default,org.opendaylight.controller.switchmanager@default:default,org.opendaylight.controller.thirdparty.com.sun.jersey.jersey-servlet@default:default,org.opendaylight.controller.thirdparty.net.sf.jung2@default:default,org.opendaylight.controller.thirdparty.org.openflow.openflowj@default:default,org.opendaylight.controller.topology.northbound@default:default,org.opendaylight.controller.topology.web@default:default,org.opendaylight.controller.topologymanager@default:default,org.opendaylight.controller.troubleshoot.web@default:default,org.opendaylight.controller.usermanager@default:default,org.opendaylight.controller.web@default:default"/>
</launchConfiguration>
<booleanAttribute key="default" value="true"/>
<booleanAttribute key="default_auto_start" value="true"/>
<intAttribute key="default_start_level" value="4"/>
+<stringAttribute key="deselected_workspace_plugins" value="org.opendaylight.controller.clustering.stub,org.opendaylight.controller.protocol_plugins.stub"/>
<booleanAttribute key="includeOptional" value="false"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dorg.osgi.framework.system.packages.extra=sun.reflect,sun.reflect.misc,sun.misc -Dosgi.hook.configurators.include=org.eclipse.virgo.kernel.equinox.extensions.hooks.ExtensionsHookConfigurator -Dlogback.configurationFile=${project_loc:/distribution.opendaylight}/src/main/resources/configuration/logback.xml -Dorg.eclipse.gemini.web.tomcat.config.path=${project_loc:/distribution.opendaylight}/src/main/resources/configuration/tomcat-server.xml -Dosgi.frameworkClassPath=file:${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar,file:${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.virgo.kernel.equinox.extensions_3.6.0.RELEASE.jar,file:${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.osgi_3.8.1.v20120830-144521.jar"/>
<stringAttribute key="pde.version" value="3.3"/>
<booleanAttribute key="show_selected_only" value="false"/>
-<stringAttribute key="target_bundles" value="ch.qos.logback.classic@default:default,ch.qos.logback.core@default:default,chameleon-mbeans@default:default,com.google.gson@default:default,com.springsource.org.aopalliance@default:default,com.sun.jersey.client@default:default,com.sun.jersey.core@default:default,com.sun.jersey.jersey-server@default:default,com.sun.jersey.json@default:default,jackson-core-asl@default:default,jackson-jaxrs@default:default,jackson-mapper-asl@default:default,javax.activation@default:default,javax.annotation@default:default,javax.ejb@default:default,javax.el@default:default,javax.mail.glassfish@default:default,javax.persistence@default:default,javax.servlet.jsp.jstl.impl@default:default,javax.servlet.jsp.jstl@default:default,javax.servlet.jsp@default:default,javax.servlet@default:default,javax.xml.rpc@default:default,jcl.over.slf4j@default:default,log4j.over.slf4j@default:default,org.apache.catalina.ha@default:false,org.apache.catalina.tribes@default:false,org.apache.catalina@default:default,org.apache.commons.fileupload@default:default,org.apache.commons.io@default:default,org.apache.commons.lang3@default:default,org.apache.coyote@default:false,org.apache.el@default:default,org.apache.felix.dependencymanager.shell@default:default,org.apache.felix.dependencymanager@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.apache.jasper@default:false,org.apache.juli.extras@default:default,org.apache.tomcat.api@default:default,org.apache.tomcat.util@default:false,org.codehaus.jettison.jettison@default:default,org.eclipse.equinox.cm@default:default,org.eclipse.equinox.console@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.util@default:default,org.eclipse.gemini.web.core@default:default,org.eclipse.gemini.web.extender@default:default,org.eclipse.gemini.web.tomcat@default:default,org.eclipse.jdt.core.compiler.batch@default:default,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.virgo.kernel.equinox.extensions@default:false,org.eclipse.virgo.util.common@default:default,org.eclipse.virgo.util.io@default:default,org.eclipse.virgo.util.math@default:default,org.eclipse.virgo.util.osgi.manifest@default:default,org.eclipse.virgo.util.osgi@default:default,org.eclipse.virgo.util.parser.manifest@default:default,org.jboss.spec.javax.transaction.jboss-transaction-api_1.1_spec@default:default,org.springframework.aop@default:default,org.springframework.asm@default:default,org.springframework.beans@default:default,org.springframework.context.support@default:default,org.springframework.context@default:default,org.springframework.core@default:default,org.springframework.expression@default:default,org.springframework.security.config@default:default,org.springframework.security.core@default:default,org.springframework.security.taglibs@default:default,org.springframework.security.web@default:default,org.springframework.transaction@default:default,org.springframework.web.servlet@default:default,org.springframework.web@default:default,slf4j.api@default:default"/>
+<stringAttribute key="target_bundles" value="ch.qos.logback.classic@default:default,ch.qos.logback.core@default:default,chameleon-mbeans@default:default,com.google.gson@default:default,com.springsource.org.aopalliance@default:default,com.sun.jersey.client@1:default,com.sun.jersey.core@1:default,com.sun.jersey.jersey-server@1:default,com.sun.jersey.json@1:default,jackson-core-asl@default:default,jackson-jaxrs@default:default,jackson-mapper-asl@default:default,javax.activation@default:default,javax.annotation@default:default,javax.ejb@default:default,javax.el@default:default,javax.mail.glassfish@default:default,javax.persistence@default:default,javax.servlet.jsp.jstl.impl@default:default,javax.servlet.jsp.jstl@default:default,javax.servlet.jsp@default:default,javax.servlet@default:default,javax.xml.rpc@default:default,jcl.over.slf4j@default:default,log4j.over.slf4j@default:default,org.apache.catalina.ha@default:false,org.apache.catalina.tribes@default:false,org.apache.catalina@default:default,org.apache.commons.fileupload@default:default,org.apache.commons.io@default:default,org.apache.commons.lang3@default:default,org.apache.coyote@default:false,org.apache.el@default:default,org.apache.felix.dependencymanager.shell@default:default,org.apache.felix.dependencymanager@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.apache.jasper@default:false,org.apache.juli.extras@default:default,org.apache.tomcat.api@default:default,org.apache.tomcat.util@default:false,org.codehaus.jettison.jettison@default:default,org.eclipse.equinox.cm@default:default,org.eclipse.equinox.console@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.util@default:default,org.eclipse.gemini.web.core@default:default,org.eclipse.gemini.web.extender@default:default,org.eclipse.gemini.web.tomcat@default:default,org.eclipse.jdt.core.compiler.batch@default:default,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.virgo.kernel.equinox.extensions@default:false,org.eclipse.virgo.util.common@default:default,org.eclipse.virgo.util.io@default:default,org.eclipse.virgo.util.math@default:default,org.eclipse.virgo.util.osgi.manifest@default:default,org.eclipse.virgo.util.osgi@default:default,org.eclipse.virgo.util.parser.manifest@default:default,org.jboss.spec.javax.transaction.jboss-transaction-api_1.1_spec@default:default,org.springframework.aop@default:default,org.springframework.asm@default:default,org.springframework.beans@default:default,org.springframework.context.support@default:default,org.springframework.context@default:default,org.springframework.core@default:default,org.springframework.expression@default:default,org.springframework.security.config@default:default,org.springframework.security.core@default:default,org.springframework.security.taglibs@default:default,org.springframework.security.web@default:default,org.springframework.transaction@default:default,org.springframework.web.servlet@default:default,org.springframework.web@default:default,slf4j.api@default:default"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
<booleanAttribute key="useDefaultConfigArea" value="true"/>
-<stringAttribute key="workspace_bundles" value="org.opendaylight.controller.arphandler@default:default,org.opendaylight.controller.clustering.services-implementation@default:default,org.opendaylight.controller.clustering.services@default:default,org.opendaylight.controller.clustering.stub@default:default,org.opendaylight.controller.clustering.test@default:default,org.opendaylight.controller.commons.northbound@default:default,org.opendaylight.controller.configuration.implementation@default:default,org.opendaylight.controller.configuration@default:default,org.opendaylight.controller.containermanager.implementation@default:default,org.opendaylight.controller.containermanager@default:default,org.opendaylight.controller.devices.web@default:default,org.opendaylight.controller.flowprogrammer.northbound@default:default,org.opendaylight.controller.flows.web@default:default,org.opendaylight.controller.forwarding.staticrouting.northbound@default:default,org.opendaylight.controller.forwarding.staticrouting@default:default,org.opendaylight.controller.forwardingrulesmanager.implementation@default:default,org.opendaylight.controller.forwardingrulesmanager@default:default,org.opendaylight.controller.hosttracker.implementation@default:default,org.opendaylight.controller.hosttracker.northbound@default:default,org.opendaylight.controller.hosttracker@default:default,org.opendaylight.controller.logging.bridge@default:default,org.opendaylight.controller.protocol_plugins.openflow@default:default,org.opendaylight.controller.protocol_plugins.stub@default:default,org.opendaylight.controller.routing.dijkstra_implementation@default:default,org.opendaylight.controller.sal.implementation@default:default,org.opendaylight.controller.sal@default:default,org.opendaylight.controller.samples.loadbalancer.northbound@default:default,org.opendaylight.controller.samples.loadbalancer@default:default,org.opendaylight.controller.samples.simpleforwarding@default:default,org.opendaylight.controller.security@default:false,org.opendaylight.controller.statistics.northbound@default:default,org.opendaylight.controller.statisticsmanager.implementation@default:default,org.opendaylight.controller.statisticsmanager@default:default,org.opendaylight.controller.subnets.northbound@default:default,org.opendaylight.controller.switchmanager.implementation@default:default,org.opendaylight.controller.switchmanager.northbound@default:default,org.opendaylight.controller.switchmanager@default:default,org.opendaylight.controller.thirdparty.com.sun.jersey.jersey-servlet@default:default,org.opendaylight.controller.thirdparty.net.sf.jung2@default:default,org.opendaylight.controller.thirdparty.org.openflow.openflowj@default:default,org.opendaylight.controller.topology.northbound@default:default,org.opendaylight.controller.topology.web@default:default,org.opendaylight.controller.topologymanager@default:default,org.opendaylight.controller.troubleshoot.web@default:default,org.opendaylight.controller.usermanager@default:default,org.opendaylight.controller.web@default:default"/>
+<stringAttribute key="workspace_bundles" value="org.opendaylight.controller.arphandler@default:default,org.opendaylight.controller.clustering.services-implementation@default:default,org.opendaylight.controller.clustering.services@default:default,org.opendaylight.controller.commons.northbound@default:default,org.opendaylight.controller.concepts@default:default,org.opendaylight.controller.configuration.implementation@default:default,org.opendaylight.controller.configuration@default:default,org.opendaylight.controller.containermanager.implementation@default:default,org.opendaylight.controller.containermanager@default:default,org.opendaylight.controller.devices.web@default:default,org.opendaylight.controller.flowprogrammer.northbound@default:default,org.opendaylight.controller.flows.web@default:default,org.opendaylight.controller.forwarding.staticrouting.northbound@default:default,org.opendaylight.controller.forwarding.staticrouting@default:default,org.opendaylight.controller.forwardingrulesmanager.implementation@default:default,org.opendaylight.controller.forwardingrulesmanager@default:default,org.opendaylight.controller.hosttracker.implementation@default:default,org.opendaylight.controller.hosttracker.northbound@default:default,org.opendaylight.controller.hosttracker@default:default,org.opendaylight.controller.logging.bridge@default:default,org.opendaylight.controller.protocol_plugins.openflow@default:default,org.opendaylight.controller.routing.dijkstra_implementation@default:default,org.opendaylight.controller.sal.implementation@default:default,org.opendaylight.controller.sal@default:default,org.opendaylight.controller.samples.loadbalancer.northbound@default:default,org.opendaylight.controller.samples.loadbalancer@default:default,org.opendaylight.controller.samples.simpleforwarding@default:default,org.opendaylight.controller.security@default:false,org.opendaylight.controller.statistics.northbound@default:default,org.opendaylight.controller.statisticsmanager.implementation@default:default,org.opendaylight.controller.statisticsmanager@default:default,org.opendaylight.controller.subnets.northbound@default:default,org.opendaylight.controller.switchmanager.implementation@default:default,org.opendaylight.controller.switchmanager.northbound@default:default,org.opendaylight.controller.switchmanager@default:default,org.opendaylight.controller.thirdparty.com.sun.jersey.jersey-servlet@default:default,org.opendaylight.controller.thirdparty.net.sf.jung2@default:default,org.opendaylight.controller.thirdparty.org.openflow.openflowj@default:default,org.opendaylight.controller.topology.northbound@default:default,org.opendaylight.controller.topology.web@default:default,org.opendaylight.controller.topologymanager@default:default,org.opendaylight.controller.troubleshoot.web@default:default,org.opendaylight.controller.usermanager@default:default,org.opendaylight.controller.web@default:default"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="opendaylight" sequenceNumber="3">
+<?pde version="3.8"?><target name="opendaylight" sequenceNumber="4">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
-<unit id="com.springsource.org.aopalliance" version="1.0.0"/>
+<unit id="org.apache.jasper" version="7.0.32.v201211201952"/>
+<unit id="javax.servlet.jsp.jstl.impl" version="1.2.0.v201210211230"/>
+<unit id="org.springframework.context" version="3.1.3.RELEASE"/>
+<unit id="org.eclipse.gemini.web.extender" version="2.2.0.RELEASE"/>
+<unit id="jackson-jaxrs" version="1.9.8"/>
+<unit id="com.sun.jersey.jersey-server" version="1.17.0"/>
+<unit id="org.eclipse.jdt.core.compiler.batch" version="3.8.0.I20120518-2145"/>
+<unit id="org.springframework.web" version="3.1.3.RELEASE"/>
+<unit id="com.google.gson" version="2.1.0"/>
+<unit id="org.springframework.security.config" version="3.1.3.RELEASE"/>
+<unit id="org.springframework.transaction" version="3.1.3.RELEASE"/>
+<unit id="org.eclipse.virgo.util.math" version="3.6.0.RELEASE"/>
<unit id="org.apache.el" version="7.0.32.v201211081135"/>
-<unit id="org.apache.felix.dependencymanager" version="3.1.0"/>
+<unit id="org.springframework.web.servlet" version="3.1.3.RELEASE"/>
<unit id="org.apache.felix.dependencymanager.shell" version="3.0.1"/>
+<unit id="log4j.over.slf4j" version="1.7.2"/>
+<unit id="com.springsource.org.aopalliance" version="1.0.0"/>
+<unit id="javax.annotation" version="1.1.0.v201209060031"/>
+<unit id="jcl.over.slf4j" version="1.7.2"/>
+<unit id="javax.mail.glassfish" version="1.4.1.v201108011116"/>
+<unit id="slf4j.api" version="1.7.2"/>
+<unit id="org.springframework.expression" version="3.1.3.RELEASE"/>
+<unit id="jackson-mapper-asl" version="1.9.8"/>
+<unit id="org.eclipse.gemini.web.tomcat" version="2.2.0.RELEASE"/>
<unit id="org.apache.felix.gogo.command" version="0.8.0.v201108120515"/>
+<unit id="org.springframework.asm" version="3.1.3.RELEASE"/>
+<unit id="org.eclipse.equinox.ds" version="1.4.0.v20120522-1841"/>
+<unit id="org.eclipse.equinox.console" version="1.0.0.v20120522-1841"/>
+<unit id="org.apache.catalina" version="7.0.32.v201211201336"/>
+<unit id="chameleon-mbeans" version="1.0.0"/>
+<unit id="javax.servlet.jsp.jstl" version="1.2.0.v201105211821"/>
<unit id="org.apache.felix.gogo.runtime" version="0.8.0.v201108120515"/>
-<unit id="org.apache.felix.gogo.shell" version="0.8.0.v201110170705"/>
+<unit id="org.apache.tomcat.util" version="7.0.32.v201211201952"/>
+<unit id="jackson-core-asl" version="1.9.8"/>
<unit id="javax.activation" version="1.1.0.v201211130549"/>
-<unit id="org.apache.jasper" version="7.0.32.v201211201952"/>
-<unit id="org.apache.juli.extras" version="7.0.32.v201211081135"/>
+<unit id="org.eclipse.gemini.web.core" version="2.2.0.RELEASE"/>
+<unit id="org.eclipse.virgo.util.osgi" version="3.6.0.RELEASE"/>
+<unit id="org.apache.commons.io" version="2.3.0"/>
+<unit id="javax.servlet.jsp" version="2.2.0.v201112011158"/>
<unit id="org.apache.tomcat.api" version="7.0.32.v201211081135"/>
-<unit id="org.apache.catalina" version="7.0.32.v201211201336"/>
-<unit id="org.apache.catalina.ha" version="7.0.32.v201211201952"/>
-<unit id="org.apache.catalina.tribes" version="7.0.32.v201211201952"/>
+<unit id="com.sun.jersey.core" version="1.17.0"/>
+<unit id="org.springframework.security.taglibs" version="3.1.3.RELEASE"/>
+<unit id="org.springframework.security.web" version="3.1.3.RELEASE"/>
+<unit id="com.sun.jersey.client" version="1.17.0"/>
+<unit id="org.springframework.aop" version="3.1.3.RELEASE"/>
<unit id="org.apache.coyote" version="7.0.32.v201211201952"/>
-<unit id="org.apache.tomcat.util" version="7.0.32.v201211201952"/>
+<unit id="org.eclipse.virgo.kernel.equinox.extensions" version="3.6.0.RELEASE"/>
+<unit id="org.eclipse.osgi.services" version="3.3.100.v20120522-1822"/>
<unit id="org.eclipse.virgo.util.common" version="3.6.0.RELEASE"/>
+<unit id="com.sun.jersey.json" version="1.17.0"/>
+<unit id="org.eclipse.equinox.util" version="1.0.400.v20120522-2049"/>
+<unit id="org.springframework.core" version="3.1.3.RELEASE"/>
<unit id="org.apache.commons.fileupload" version="1.2.2"/>
-<unit id="org.apache.commons.io" version="2.3.0"/>
+<unit id="org.codehaus.jettison.jettison" version="1.3.3"/>
+<unit id="org.eclipse.virgo.util.io" version="3.6.0.RELEASE"/>
+<unit id="org.apache.felix.gogo.shell" version="0.8.0.v201110170705"/>
<unit id="org.apache.commons.lang3" version="3.1.0"/>
<unit id="org.eclipse.equinox.cm" version="1.0.400.v20120522-1841"/>
-<unit id="org.eclipse.equinox.console" version="1.0.0.v20120522-1841"/>
-<unit id="jackson-mapper-asl" version="1.9.8"/>
-<unit id="org.eclipse.equinox.ds" version="1.4.0.v20120522-1841"/>
-<unit id="org.eclipse.jdt.core.compiler.batch" version="3.8.0.I20120518-2145"/>
+<unit id="org.springframework.beans" version="3.1.3.RELEASE"/>
+<unit id="javax.servlet" version="3.0.0.v201112011016"/>
<unit id="org.eclipse.equinox.launcher" version="1.3.0.v20120522-1813"/>
-<unit id="org.eclipse.virgo.kernel.equinox.extensions" version="3.6.0.RELEASE"/>
-<unit id="org.eclipse.equinox.util" version="1.0.400.v20120522-2049"/>
-<unit id="org.eclipse.gemini.web.core" version="2.2.0.RELEASE"/>
-<unit id="org.eclipse.gemini.web.extender" version="2.2.0.RELEASE"/>
-<unit id="org.eclipse.gemini.web.tomcat" version="2.2.0.RELEASE"/>
-<unit id="com.google.gson" version="2.1.0"/>
-<unit id="org.eclipse.virgo.util.io" version="3.6.0.RELEASE"/>
-<unit id="jackson-core-asl" version="1.9.8"/>
-<unit id="javax.ejb" version="3.1.1.v201204261316"/>
-<unit id="org.eclipse.virgo.util.parser.manifest" version="3.6.0.RELEASE"/>
<unit id="javax.persistence" version="2.0.4.v201112161009"/>
-<unit id="javax.servlet.jsp.jstl" version="1.2.0.v201105211821"/>
-<unit id="org.jboss.spec.javax.transaction.jboss-transaction-api_1.1_spec" version="1.0.1.Final"/>
-<unit id="javax.servlet.jsp.jstl.impl" version="1.2.0.v201210211230"/>
-<unit id="javax.el" version="2.2.0.v201108011116"/>
-<unit id="javax.annotation" version="1.1.0.v201209060031"/>
-<unit id="javax.mail.glassfish" version="1.4.1.v201108011116"/>
-<unit id="javax.xml.rpc" version="1.1.0.v201005080400"/>
-<unit id="jackson-jaxrs" version="1.9.8"/>
-<unit id="jcl.over.slf4j" version="1.7.2"/>
-<unit id="com.sun.jersey.client" version="1.17.0"/>
-<unit id="com.sun.jersey.core" version="1.17.0"/>
-<unit id="com.sun.jersey.json" version="1.17.0"/>
-<unit id="com.sun.jersey.jersey-server" version="1.17.0"/>
-<unit id="org.codehaus.jettison.jettison" version="1.3.3"/>
-<unit id="javax.servlet.jsp" version="2.2.0.v201112011158"/>
-<unit id="log4j.over.slf4j" version="1.7.2"/>
-<unit id="ch.qos.logback.classic" version="1.0.9"/>
-<unit id="ch.qos.logback.core" version="1.0.9"/>
-<unit id="org.eclipse.virgo.util.math" version="3.6.0.RELEASE"/>
-<unit id="org.eclipse.virgo.util.osgi.manifest" version="3.6.0.RELEASE"/>
-<unit id="org.eclipse.osgi.services" version="3.3.100.v20120522-1822"/>
<unit id="org.eclipse.osgi" version="3.8.1.v20120830-144521"/>
-<unit id="org.eclipse.virgo.util.osgi" version="3.6.0.RELEASE"/>
-<unit id="chameleon-mbeans" version="1.0.0"/>
-<unit id="javax.servlet" version="3.0.0.v201112011016"/>
-<unit id="slf4j.api" version="1.7.2"/>
-<unit id="org.springframework.aop" version="3.1.3.RELEASE"/>
-<unit id="org.springframework.asm" version="3.1.3.RELEASE"/>
-<unit id="org.springframework.beans" version="3.1.3.RELEASE"/>
-<unit id="org.springframework.context" version="3.1.3.RELEASE"/>
+<unit id="ch.qos.logback.core" version="1.0.9"/>
+<unit id="javax.ejb" version="3.1.1.v201204261316"/>
+<unit id="org.apache.catalina.ha" version="7.0.32.v201211201952"/>
<unit id="org.springframework.context.support" version="3.1.3.RELEASE"/>
-<unit id="org.springframework.core" version="3.1.3.RELEASE"/>
-<unit id="org.springframework.expression" version="3.1.3.RELEASE"/>
+<unit id="org.eclipse.virgo.util.osgi.manifest" version="3.6.0.RELEASE"/>
+<unit id="javax.xml.rpc" version="1.1.0.v201005080400"/>
+<unit id="ch.qos.logback.classic" version="1.0.9"/>
<unit id="org.springframework.security.core" version="3.1.3.RELEASE"/>
-<unit id="org.springframework.security.config" version="3.1.3.RELEASE"/>
-<unit id="org.springframework.security.taglibs" version="3.1.3.RELEASE"/>
-<unit id="org.springframework.security.web" version="3.1.3.RELEASE"/>
-<unit id="org.springframework.transaction" version="3.1.3.RELEASE"/>
-<unit id="org.springframework.web" version="3.1.3.RELEASE"/>
-<unit id="org.springframework.web.servlet" version="3.1.3.RELEASE"/>
-<repository location="https://jenkins.opendaylight.org/controller/job/controller-merge/lastSuccessfulBuild/artifact/opendaylight/distribution/p2site/target/repository/"/>
+<unit id="javax.el" version="2.2.0.v201108011116"/>
+<unit id="org.apache.juli.extras" version="7.0.32.v201211081135"/>
+<unit id="org.jboss.spec.javax.transaction.jboss-transaction-api_1.1_spec" version="1.0.1.Final"/>
+<unit id="org.apache.catalina.tribes" version="7.0.32.v201211201952"/>
+<unit id="org.eclipse.virgo.util.parser.manifest" version="3.6.0.RELEASE"/>
+<unit id="org.apache.felix.dependencymanager" version="3.1.0"/>
+<repository location="http://nexus.opendaylight.org/content/repositories/controllerp2site/"/>
</location>
</locations>
</target>
<module>../../samples/loadbalancer</module>
<module>../../samples/northbound/loadbalancer</module>
<module>../../commons/concepts</module>
+ <module>../../commons/integrationtest</module>
+
</modules>
<build>
import org.opendaylight.controller.sal.action.PopVlan;
import org.opendaylight.controller.sal.action.SetDlDst;
import org.opendaylight.controller.sal.action.SetDlSrc;
+import org.opendaylight.controller.sal.action.SetNextHop;
import org.opendaylight.controller.sal.action.SetNwDst;
import org.opendaylight.controller.sal.action.SetNwSrc;
import org.opendaylight.controller.sal.action.SetNwTos;
ANY, V4, V6;
};
- private enum SetNextHopType {
- CISCO_EXTENSION("Cisco NextHop Extension"), RESOLVE_L2RW(
- "Resolve L2 Rewrite");
-
- private SetNextHopType(String name) {
- this.name = name;
- }
-
- private String name;
-
- public String toString() {
- return name;
- }
-
- public boolean equals(String type) {
- if (type.trim().equalsIgnoreCase(name))
- return true;
- return false;
- }
- }
-
public FlowConfig() {
}
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
FlowConfig other = (FlowConfig) obj;
if (actions == null) {
- if (other.actions != null)
+ if (other.actions != null) {
return false;
- } else if (!actions.equals(other.actions))
+ }
+ } else if (!actions.equals(other.actions)) {
return false;
+ }
if (cookie == null) {
- if (other.cookie != null)
+ if (other.cookie != null) {
return false;
- } else if (!cookie.equals(other.cookie))
+ }
+ } else if (!cookie.equals(other.cookie)) {
return false;
+ }
if (dlDst == null) {
- if (other.dlDst != null)
+ if (other.dlDst != null) {
return false;
- } else if (!dlDst.equals(other.dlDst))
+ }
+ } else if (!dlDst.equals(other.dlDst)) {
return false;
+ }
if (dlSrc == null) {
- if (other.dlSrc != null)
+ if (other.dlSrc != null) {
return false;
- } else if (!dlSrc.equals(other.dlSrc))
+ }
+ } else if (!dlSrc.equals(other.dlSrc)) {
return false;
- if (dynamic != other.dynamic)
+ }
+ if (dynamic != other.dynamic) {
return false;
+ }
if (etherType == null) {
- if (other.etherType != null)
+ if (other.etherType != null) {
return false;
- } else if (!etherType.equals(other.etherType))
+ }
+ } else if (!etherType.equals(other.etherType)) {
return false;
+ }
if (ingressPort == null) {
- if (other.ingressPort != null)
+ if (other.ingressPort != null) {
return false;
- } else if (!ingressPort.equals(other.ingressPort))
+ }
+ } else if (!ingressPort.equals(other.ingressPort)) {
return false;
+ }
if (name == null) {
- if (other.name != null)
+ if (other.name != null) {
return false;
- } else if (!name.equals(other.name))
+ }
+ } else if (!name.equals(other.name)) {
return false;
+ }
if (nwDst == null) {
- if (other.nwDst != null)
+ if (other.nwDst != null) {
return false;
- } else if (!nwDst.equals(other.nwDst))
+ }
+ } else if (!nwDst.equals(other.nwDst)) {
return false;
+ }
if (nwSrc == null) {
- if (other.nwSrc != null)
+ if (other.nwSrc != null) {
return false;
- } else if (!nwSrc.equals(other.nwSrc))
+ }
+ } else if (!nwSrc.equals(other.nwSrc)) {
return false;
+ }
if (portGroup == null) {
- if (other.portGroup != null)
+ if (other.portGroup != null) {
return false;
- } else if (!portGroup.equals(other.portGroup))
+ }
+ } else if (!portGroup.equals(other.portGroup)) {
return false;
+ }
if (priority == null) {
- if (other.priority != null)
+ if (other.priority != null) {
return false;
- } else if (!priority.equals(other.priority))
+ }
+ } else if (!priority.equals(other.priority)) {
return false;
+ }
if (protocol == null) {
- if (other.protocol != null)
+ if (other.protocol != null) {
return false;
- } else if (!protocol.equals(other.protocol))
+ }
+ } else if (!protocol.equals(other.protocol)) {
return false;
+ }
if (node == null) {
- if (other.node != null)
+ if (other.node != null) {
return false;
- } else if (!node.equals(other.node))
+ }
+ } else if (!node.equals(other.node)) {
return false;
+ }
if (tosBits == null) {
- if (other.tosBits != null)
+ if (other.tosBits != null) {
return false;
- } else if (!tosBits.equals(other.tosBits))
+ }
+ } else if (!tosBits.equals(other.tosBits)) {
return false;
+ }
if (tpDst == null) {
- if (other.tpDst != null)
+ if (other.tpDst != null) {
return false;
- } else if (!tpDst.equals(other.tpDst))
+ }
+ } else if (!tpDst.equals(other.tpDst)) {
return false;
+ }
if (tpSrc == null) {
- if (other.tpSrc != null)
+ if (other.tpSrc != null) {
return false;
- } else if (!tpSrc.equals(other.tpSrc))
+ }
+ } else if (!tpSrc.equals(other.tpSrc)) {
return false;
+ }
if (vlanId == null) {
- if (other.vlanId != null)
+ if (other.vlanId != null) {
return false;
- } else if (!vlanId.equals(other.vlanId))
+ }
+ } else if (!vlanId.equals(other.vlanId)) {
return false;
+ }
if (vlanPriority == null) {
- if (other.vlanPriority != null)
+ if (other.vlanPriority != null) {
return false;
- } else if (!vlanPriority.equals(other.vlanPriority))
+ }
+ } else if (!vlanPriority.equals(other.vlanPriority)) {
return false;
+ }
if (idleTimeout == null) {
- if (other.idleTimeout != null)
+ if (other.idleTimeout != null) {
return false;
- } else if (!idleTimeout.equals(other.idleTimeout))
+ }
+ } else if (!idleTimeout.equals(other.idleTimeout)) {
return false;
+ }
if (hardTimeout == null) {
- if (other.hardTimeout != null)
+ if (other.hardTimeout != null) {
return false;
- } else if (!hardTimeout.equals(other.hardTimeout))
- return false;
- return true;
- }
-
- public InetAddress getNextHopAddressForL2RWAction() {
- if (actions != null) {
- Matcher sstr;
- for (String actiongrp : actions) {
- sstr = Pattern.compile("SET_NEXT_HOP=(.*)").matcher(actiongrp);
- if (sstr.matches()) {
- SetNextHopType setNHType = SetNextHopType.CISCO_EXTENSION;
- String nextHopInfo = sstr.group(1);
- String values[] = nextHopInfo.split("//");
- String address = values[0].trim();
- String type = null;
- if (values.length > 1) {
- type = values[1].trim();
- }
-
- if (type != null) {
- for (SetNextHopType nh : SetNextHopType.values()) {
- if (nh.equals(type))
- setNHType = nh;
- }
- }
-
- log.debug("Get Nexthop address = {} Type = {}", address,
- setNHType.toString());
- if (setNHType == SetNextHopType.RESOLVE_L2RW) {
- try {
- return InetAddress.getByName(address);
- } catch (Exception e) {
- log.debug(
- "Exception during nextHopAddress resolution : ",
- e);
- }
- }
- }
}
+ } else if (!hardTimeout.equals(other.hardTimeout)) {
+ return false;
}
- return null;
- }
-
- public String getNextHopL2RWUsageError() {
- return "Could not resolve NextHop IP Address for the selected Switch.<br>"
- + "Please Check the following configurations.<br>"
- + "1. Is the NextHop IP address directly connected to the Selected Switch<br>"
- + "2. If appropriate Subnet Configurations are done in the Switch Manager<br>"
- + "3. If the Nexthop IP-Address is Correct";
+ return true;
}
public boolean isL2AddressValid(String mac) {
}
// make sure it's a valid number
- if (cookie != null)
+ if (cookie != null) {
Long.decode(cookie);
+ }
if (ingressPort != null) {
Short port = Short.decode(ingressPort);
"Ethernet type %s is not valid", etherType));
return false;
} else {
- if (type == 0x800)
+ if (type == 0x800) {
etype = EtherIPType.V4;
- else if (type == 0x86dd)
+ } else if (type == 0x86dd) {
etype = EtherIPType.V6;
+ }
}
}
ActionType.SET_NEXT_HOP.toString() + "=(.*)")
.matcher(actiongrp);
if (sstr.matches()) {
- String nextHopInfo = sstr.group(1);
- String values[] = nextHopInfo.split("//");
- String address = values[0].trim();
-
- if ((address == null) || !isOutputNextHopValid(address)) {
+ if (!NetUtils.isIPAddressValid(sstr.group(1))) {
resultStr.append(String.format(
- "next hop %s is not valid", sstr.group(1)));
+ "IP destination address %s is not valid",
+ sstr.group(1)));
return false;
}
continue;
return flow;
}
- public boolean isOutputNextHopValid(String onh) {
- if (onh == null) {
- return false;
- }
- /*
- * For now, only takes IPv4 or IPv6 address
- */
- return (NetUtils.isIPv4AddressValid(onh) || NetUtils
- .isIPv6AddressValid(onh));
- }
-
public boolean isByNameAndNodeIdEqual(FlowConfig that) {
return (this.name.equals(that.name) && this.node.equals(that.node));
}
return this.node.equals(node);
}
- public static List<String> getSupportedNextHopTypes() {
- List<String> s = new ArrayList<String>();
- for (SetNextHopType nh : SetNextHopType.values()) {
- s.add(nh.toString());
- }
- return s;
- }
-
public void toggleStatus() {
installInHw = (installInHw == null) ? "true" : (installInHw
.equals("true")) ? "false" : "true";
ActionType.SET_NEXT_HOP.toString() + "=(.*)").matcher(
actiongrp);
if (sstr.matches()) {
- log.warn("We do not handle next hop action yet....");
+ actionList.add(new SetNextHop(NetUtils.parseInetAddress(sstr
+ .group(1))));
continue;
}
}
}
- @Test
- public void testFlowConfigNextHopValidity() throws UnknownHostException {
- FlowConfig fc = new FlowConfig();
- Assert.assertFalse(fc.isOutputNextHopValid(null));
- Assert.assertFalse(fc.isOutputNextHopValid("abc"));
- Assert.assertFalse(fc.isOutputNextHopValid("1.1.1"));
- Assert.assertFalse(fc.isOutputNextHopValid("1.1.1.1/49"));
-
- Assert.assertTrue(fc.isOutputNextHopValid("1.1.1.1"));
- Assert.assertTrue(fc.isOutputNextHopValid("1.1.1.1/32"));
- Assert.assertTrue(fc
- .isOutputNextHopValid("2001:420:281:1004:407a:57f4:4d15:c355"));
-
- }
-
@Test
public void testFlowConfigEqualities() throws UnknownHostException {
FlowConfig fc = new FlowConfig();
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.opendaylight</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <artifactId>commons.integrationtest</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ <relativePath>../../commons/integrationtest</relativePath>
</parent>
<artifactId>forwardingrulesmanager.integrationtest</artifactId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
import org.ops4j.pax.exam.util.PathUtils;
@RunWith(PaxExam.class)
-public class FRMIntegrationTest {
- private Logger log = LoggerFactory.getLogger(FRMIntegrationTest.class);
+public class ForwardingRulesManagerIT {
+ private Logger log = LoggerFactory.getLogger(ForwardingRulesManagerIT.class);
// get the OSGI bundle context
@Inject
private BundleContext bc;
mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",
"0.8.0.v201110170705"),
// List logger bundles
- mavenBundle("org.slf4j", "slf4j-api", "1.7.2"),
- mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"),
- mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),
- mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),
+ mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
+ mavenBundle("org.slf4j", "log4j-over-slf4j")
+ .versionAsInProject(),
+ mavenBundle("ch.qos.logback", "logback-core")
+ .versionAsInProject(),
+ mavenBundle("ch.qos.logback", "logback-classic")
+ .versionAsInProject(),
// List all the bundles on which the test case depends
- mavenBundle("org.opendaylight.controller", "sal",
- "0.5.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller",
- "sal.implementation", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "sal")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "sal.implementation")
+ .versionAsInProject(),
mavenBundle("org.opendaylight.controller",
- "protocol_plugins.stub", "0.4.0-SNAPSHOT"),
-
- mavenBundle("org.opendaylight.controller", "containermanager",
- "0.4.0-SNAPSHOT"),
+ "protocol_plugins.stub").versionAsInProject(),
+
+ mavenBundle("org.opendaylight.controller", "containermanager")
+ .versionAsInProject(),
mavenBundle("org.opendaylight.controller",
- "containermanager.implementation", "0.4.0-SNAPSHOT"),
+ "containermanager.implementation").versionAsInProject(),
mavenBundle("org.opendaylight.controller",
- "forwardingrulesmanager", "0.4.0-SNAPSHOT"),
+ "forwardingrulesmanager").versionAsInProject(),
mavenBundle("org.opendaylight.controller",
- "forwardingrulesmanager.implementation",
- "0.4.0-SNAPSHOT"),
+ "forwardingrulesmanager.implementation")
+ .versionAsInProject(),
mavenBundle("org.opendaylight.controller",
- "clustering.services", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "clustering.stub",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "switchmanager",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "switchmanager.implementation",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "configuration",
- "0.4.0-SNAPSHOT"),
+ "clustering.services").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "clustering.stub")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "switchmanager")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller",
+ "switchmanager.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "configuration")
+ .versionAsInProject(),
mavenBundle("org.opendaylight.controller",
- "configuration.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "hosttracker",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "hosttracker.implementation",
- "0.4.0-SNAPSHOT"),
+ "configuration.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "hosttracker")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller",
+ "hosttracker.implementation").versionAsInProject(),
// needed by hosttracker
- mavenBundle("org.opendaylight.controller", "topologymanager",
- "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "topologymanager")
+ .versionAsInProject(),
mavenBundle("org.jboss.spec.javax.transaction",
- "jboss-transaction-api_1.1_spec", "1.0.1.Final"),
- mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
+ "jboss-transaction-api_1.1_spec").versionAsInProject(),
+ mavenBundle("org.apache.commons", "commons-lang3")
+ .versionAsInProject(),
mavenBundle("org.apache.felix",
- "org.apache.felix.dependencymanager", "3.1.0"),
- junitBundles());
+ "org.apache.felix.dependencymanager")
+ .versionAsInProject(), junitBundles());
}
private String stateToString(int state) {
return this.nodeConnector.getNode();
}
- /**
- * @return the NodeId
- */
- public Long getnodeconnectornodeId() {
- return (Long) this.nodeConnector.getNode().getID();
- }
-
- /**
- * @return the port
- */
- public Short getnodeconnectorportId() {
- return (Short) this.nodeConnector.getID();
- }
-
/**
* @return the DataLayerAddress
*/
Assert.assertTrue(hostnodeconnector_2.isV6Host());\r
Assert.assertTrue(hostnodeconnector_2.getnodeConnector().equals(nc1));\r
Assert.assertTrue(hostnodeconnector_2.getnodeconnectorNode().equals(node));\r
- Assert.assertTrue(node.getID().equals(hostnodeconnector_2.getnodeconnectornodeId()));\r
- Assert.assertTrue(hostnodeconnector_2.getnodeconnectorportId().equals((short)2));\r
+ Assert.assertTrue(node.equals(hostnodeconnector_2.getnodeconnectorNode()));\r
} catch (ConstructionException e) {\r
Assert.assertTrue(false);\r
}\r
* wasn't created for this host in the controller. This would cause
* arphandler not to know where to send the ARP 2. The host facing port is
* down 3. The IP host doesn't exist or is not responding to ARP requests
- *
+ *
* Conditions 1 and 2 above can be recovered if ARP is sent when the
* relevant L3 interface is added or the port facing host comes up. Whenever
* L3 interface is added or host facing port comes up, ARP will be sent to
* hosts in this list.
- *
+ *
* We can't recover from condition 3 above
*/
private ArrayList<ARPPending> failedARPReqList = new ArrayList<HostTracker.ARPPending>();
* When a new Host is learnt by the hosttracker module, it places the
* directly connected Node in Tier-1 & using this function, updates the Tier
* value for all other Nodes in the network hierarchy.
- *
+ *
* This is a recursive function and it takes care of updating the Tier value
* for all the connected and eligible Nodes.
- *
+ *
* @param n
* Node that represents one of the Vertex in the Topology Graph.
* @param currentTier
* Internal convenience routine to check the eligibility of a Switch for a
* Tier update. Any Node with Tier=0 or a Tier value that is greater than
* the new Tier Value is eligible for the update.
- *
+ *
* @param n
* Node for which the Tier update eligibility is checked
* @param tier
* that returns the Network Hierarchy for a given Host. This API is
* typically used by applications like Hadoop for Rack Awareness
* functionality.
- *
+ *
* @param hostAddress
* IP-Address of the host/node.
* @return Network Hierarchies represented by an Array of Array (of
* is used as the network for Hadoop Demos & in order to give a meaningful
* rack-awareness switch names, the DPID is organized in ASCII Characters
* and retrieved as string.
- *
+ *
* @param dpid
* Switch DataPath Id
* @return Ascii String represented by the DPID.
/**
* A convenient recursive routine to obtain the Hierarchy of Switches.
- *
+ *
* @param node
* Current Node in the Recursive routine.
* @param currHierarchy
/**
* Inform the controller IP to MAC binding of a host and its connectivity to
* an openflow switch in terms of Node, port, and VLAN.
- *
+ *
* @param networkAddr
* IP address of the host
* @param dataLayer
* Port of the switch to which host is connected
* @param vlan
* Vlan of which this host is member of
- *
+ *
* @return Status The status object as described in {@code Status}
* indicating the result of this action.
*/
/**
* Update the controller IP to MAC binding of a host and its connectivity to
* an openflow switch in terms of switch id, switch port, and VLAN.
- *
+ *
* @param networkAddr
* IP address of the host
* @param dataLayer
* Port of the switch to which host is connected
* @param vlan
* Vlan of which this host is member of
- *
+ *
* @return boolean true if the host was added successfully, false otherwise
*/
public boolean updateHostReq(InetAddress networkAddr,
/**
* Remove from the controller IP to MAC binding of a host and its
* connectivity to an openflow switch
- *
+ *
* @param networkAddr
* IP address of the host
- *
+ *
* @return boolean true if the host was removed successfully, false
* otherwise
*/
switch (type) {
case REMOVED:
- long sid = (Long) node.getID();
- if (logger.isDebugEnabled()) {
- logger.debug("Received removedSwitch for sw id {}",
- HexEncode.longToHexString(sid));
- }
+ logger.debug("Received removed node {}", node);
for (Entry<InetAddress, HostNodeConnector> entry : hostsDB
.entrySet()) {
HostNodeConnector host = entry.getValue();
- if (host.getnodeconnectornodeId() == sid) {
- logger.debug("Switch: {} is down, remove from Hosts_DB",
- sid);
+ if (host.getnodeconnectorNode().equals(node)) {
+ logger.debug("Node: {} is down, remove from Hosts_DB", node);
removeKnownHost(entry.getKey());
notifyHostLearnedOrRemoved(host, false);
}
}
private void handleNodeConnectorStatusDown(NodeConnector nodeConnector) {
- long sid = (Long) nodeConnector.getNode().getID();
- short port = (Short) nodeConnector.getID();
-
logger.debug("handleNodeConnectorStatusDown {}", nodeConnector);
for (Entry<InetAddress, HostNodeConnector> entry : hostsDB.entrySet()) {
HostNodeConnector host = entry.getValue();
- if ((host.getnodeconnectornodeId() == sid)
- && (host.getnodeconnectorportId() == port)) {
- logger.debug(
- "Switch: {}, Port: {} is down, remove from Hosts_DB",
- sid, port);
+ if (host.getnodeConnector().equals(nodeConnector)) {
+ logger.debug(" NodeConnector: {} is down, remove from Hosts_DB", nodeConnector);
removeKnownHost(entry.getKey());
notifyHostLearnedOrRemoved(host, false);
}
/**
* Function called by the dependency manager when all the required
* dependencies are satisfied
- *
+ *
*/
void init(Component c) {
Dictionary<?, ?> props = c.getServiceProperties();
* Function called by the dependency manager when at least one dependency
* become unsatisfied or when the component is shutting down because for
* example bundle is being stopped.
- *
+ *
*/
void destroy() {
destroyCache();
/**
* Function called by dependency manager after "init ()" is called and after
* the services provided by the class are registered in the service registry
- *
+ *
*/
void start() {
}
* Function called by the dependency manager before the services exported by
* the component are unregistered, this will be followed by a "destroy ()"
* calls
- *
+ *
*/
void stop() {
}
<modelVersion>4.0.0</modelVersion>\r
<parent>\r
<groupId>org.opendaylight.controller</groupId>\r
- <artifactId>commons.opendaylight</artifactId>\r
- <version>1.4.0-SNAPSHOT</version>\r
- <relativePath>../../../opendaylight/commons/opendaylight</relativePath>\r
+ <artifactId>commons.integrationtest</artifactId>\r
+ <version>0.5.0-SNAPSHOT</version>\r
+ <relativePath>../../commons/integrationtest</relativePath>\r
</parent>\r
\r
<artifactId>hosttracker.integrationtest</artifactId>\r
-\r
/*\r
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
*\r
\r
package org.opendaylight.controller.hosttracker.internal;\r
\r
-\r
import java.net.InetAddress;\r
import java.net.UnknownHostException;\r
import java.util.ArrayList;\r
import org.ops4j.pax.exam.spi.reactors.PerClass;\r
\r
@RunWith(PaxExam.class)\r
-public class HostTrackerIntegrationTest {\r
+public class HostTrackerIT {\r
private Logger log = LoggerFactory\r
- .getLogger(HostTrackerIntegrationTest.class);\r
+ .getLogger(HostTrackerIT.class);\r
// get the OSGI bundle context\r
@Inject\r
private BundleContext bc;\r
- \r
+\r
private IfIptoHost hosttracker = null;\r
private ISwitchManagerAware switchManagerAware = null;\r
private IInventoryListener invtoryListener = null;\r
private IfHostListener hostListener = null;\r
private ITopologyManagerAware topologyManagerAware = null;\r
- \r
+\r
// Configure the OSGi container\r
@Configuration\r
public Option[] config() {\r
mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",\r
"0.8.0.v201110170705"),\r
// List logger bundles\r
- mavenBundle("org.slf4j", "slf4j-api", "1.7.2"),\r
- mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"),\r
- mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),\r
- mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),\r
- \r
+ mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),\r
+ mavenBundle("org.slf4j", "log4j-over-slf4j")\r
+ .versionAsInProject(),\r
+ mavenBundle("ch.qos.logback", "logback-core")\r
+ .versionAsInProject(),\r
+ mavenBundle("ch.qos.logback", "logback-classic")\r
+ .versionAsInProject(),\r
+\r
// List all the bundles on which the test case depends\r
- mavenBundle("org.opendaylight.controller", "sal",\r
- "0.5.0-SNAPSHOT"),\r
- mavenBundle("org.opendaylight.controller", "sal.implementation",\r
- "0.4.0-SNAPSHOT"),\r
-\r
- // needed by statisticsmanager\r
- mavenBundle("org.opendaylight.controller", "containermanager",\r
- "0.4.0-SNAPSHOT"),\r
- mavenBundle("org.opendaylight.controller", "containermanager.implementation",\r
- "0.4.0-SNAPSHOT"),\r
- \r
- mavenBundle("org.opendaylight.controller",\r
- "clustering.services", "0.4.0-SNAPSHOT"),\r
- mavenBundle("org.opendaylight.controller",\r
- "clustering.stub", "0.4.0-SNAPSHOT"),\r
+ mavenBundle("org.opendaylight.controller", "sal")\r
+ .versionAsInProject(),\r
+ mavenBundle("org.opendaylight.controller", "sal.implementation")\r
+ .versionAsInProject(),\r
+\r
+ // needed by statisticsmanager\r
+ mavenBundle("org.opendaylight.controller", "containermanager")\r
+ .versionAsInProject(),\r
+ mavenBundle("org.opendaylight.controller",\r
+ "containermanager.implementation").versionAsInProject(),\r
+\r
+ mavenBundle("org.opendaylight.controller",\r
+ "clustering.services").versionAsInProject(),\r
+ mavenBundle("org.opendaylight.controller", "clustering.stub")\r
+ .versionAsInProject(),\r
\r
// needed by forwardingrulesmanager\r
- mavenBundle("org.opendaylight.controller", "switchmanager",\r
- "0.4.0-SNAPSHOT"),\r
- mavenBundle("org.opendaylight.controller", "switchmanager.implementation",\r
- "0.4.0-SNAPSHOT"),\r
- mavenBundle("org.opendaylight.controller", "configuration",\r
- "0.4.0-SNAPSHOT"),\r
+ mavenBundle("org.opendaylight.controller", "switchmanager")\r
+ .versionAsInProject(),\r
+ mavenBundle("org.opendaylight.controller",\r
+ "switchmanager.implementation").versionAsInProject(),\r
+ mavenBundle("org.opendaylight.controller", "configuration")\r
+ .versionAsInProject(),\r
mavenBundle("org.opendaylight.controller",\r
- "configuration.implementation", "0.4.0-SNAPSHOT"),\r
- mavenBundle("org.opendaylight.controller", "hosttracker",\r
- "0.4.0-SNAPSHOT"),\r
- mavenBundle("org.opendaylight.controller", "hosttracker.implementation",\r
- "0.4.0-SNAPSHOT"),\r
+ "configuration.implementation").versionAsInProject(),\r
+ mavenBundle("org.opendaylight.controller", "hosttracker")\r
+ .versionAsInProject(),\r
+ mavenBundle("org.opendaylight.controller",\r
+ "hosttracker.implementation").versionAsInProject(),\r
\r
// needed by hosttracker\r
- mavenBundle("org.opendaylight.controller", "topologymanager",\r
- "0.4.0-SNAPSHOT"),\r
- mavenBundle("org.opendaylight.controller", "arphandler",\r
- "0.4.0-SNAPSHOT"),\r
-\r
+ mavenBundle("org.opendaylight.controller", "topologymanager")\r
+ .versionAsInProject(),\r
+ mavenBundle("org.opendaylight.controller", "arphandler")\r
+ .versionAsInProject(),\r
\r
mavenBundle("org.jboss.spec.javax.transaction",\r
- "jboss-transaction-api_1.1_spec", "1.0.1.Final"),\r
- mavenBundle("org.apache.commons", "commons-lang3", "3.1"),\r
+ "jboss-transaction-api_1.1_spec").versionAsInProject(),\r
+ mavenBundle("org.apache.commons", "commons-lang3")\r
+ .versionAsInProject(),\r
mavenBundle("org.apache.felix",\r
- "org.apache.felix.dependencymanager", "3.1.0"),\r
- junitBundles());\r
+ "org.apache.felix.dependencymanager")\r
+ .versionAsInProject(), junitBundles());\r
}\r
\r
private String stateToString(int state) {\r
// Assert if true, if false we are good to go!\r
assertFalse(debugit);\r
\r
- // Now lets create a hosttracker for testing purpose\r
- ServiceReference s = bc\r
- .getServiceReference(IfIptoHost.class.getName());\r
- if (s != null) {\r
- this.hosttracker = (IfIptoHost)bc.getService(s);\r
- this.switchManagerAware = (ISwitchManagerAware) this.hosttracker;\r
- this.invtoryListener = (IInventoryListener) this.hosttracker;\r
- this.hostListener = (IfHostListener) this.hosttracker;\r
- this.topologyManagerAware = (ITopologyManagerAware) this.hosttracker;\r
- }\r
-\r
- // If StatisticsManager is null, cannot run tests.\r
- assertNotNull(this.hosttracker);\r
+ // Now lets create a hosttracker for testing purpose\r
+ ServiceReference s = bc.getServiceReference(IfIptoHost.class.getName());\r
+ if (s != null) {\r
+ this.hosttracker = (IfIptoHost) bc.getService(s);\r
+ this.switchManagerAware = (ISwitchManagerAware) this.hosttracker;\r
+ this.invtoryListener = (IInventoryListener) this.hosttracker;\r
+ this.hostListener = (IfHostListener) this.hosttracker;\r
+ this.topologyManagerAware = (ITopologyManagerAware) this.hosttracker;\r
+ }\r
+\r
+ // If StatisticsManager is null, cannot run tests.\r
+ assertNotNull(this.hosttracker);\r
}\r
- \r
- \r
+\r
@Test\r
public void testStaticHost() throws UnknownHostException {\r
String ip;\r
- \r
+\r
assertNotNull(this.hosttracker);\r
- \r
+\r
// create one node and two node connectors\r
Node node1 = NodeCreator.createOFNode(1L);\r
- NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector((short) 1, node1);\r
- NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector((short) 2, node1);\r
- \r
- // test addStaticHost(), store into inactive host DB \r
- Status st = this.hosttracker.addStaticHost("192.168.0.8", "11:22:33:44:55:66",\r
- nc1_1, "0");\r
+ NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector(\r
+ (short) 1, node1);\r
+ NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector(\r
+ (short) 2, node1);\r
+\r
+ // test addStaticHost(), store into inactive host DB\r
+ Status st = this.hosttracker.addStaticHost("192.168.0.8",\r
+ "11:22:33:44:55:66", nc1_1, "0");\r
Assert.assertTrue(st.isSuccess());\r
- st = this.hosttracker.addStaticHost("192.168.0.13", "11:22:33:44:55:77",\r
- nc1_2, "0");\r
+ st = this.hosttracker.addStaticHost("192.168.0.13",\r
+ "11:22:33:44:55:77", nc1_2, "0");\r
Assert.assertTrue(st.isSuccess());\r
- \r
+\r
// check inactive DB\r
- Iterator<HostNodeConnector> hnci = this.hosttracker.getInactiveStaticHosts().iterator();\r
+ Iterator<HostNodeConnector> hnci = this.hosttracker\r
+ .getInactiveStaticHosts().iterator();\r
while (hnci.hasNext()) {\r
ip = hnci.next().getNetworkAddressAsString();\r
- Assert.assertTrue(ip.equals("192.168.0.8") || ip.equals("192.168.0.13"));\r
+ Assert.assertTrue(ip.equals("192.168.0.8")\r
+ || ip.equals("192.168.0.13"));\r
}\r
- \r
+\r
// check active host DB\r
hnci = this.hosttracker.getActiveStaticHosts().iterator();\r
Assert.assertFalse(hnci.hasNext());\r
- \r
+\r
// test removeStaticHost()\r
st = this.hosttracker.removeStaticHost("192.168.0.8");\r
Assert.assertTrue(st.isSuccess());\r
ip = hnci.next().getNetworkAddressAsString();\r
Assert.assertTrue(ip.equals("192.168.0.13"));\r
}\r
- } \r
- \r
+ }\r
\r
- \r
@Test\r
public void testNotifyNodeConnector() throws UnknownHostException {\r
String ip;\r
- \r
+\r
assertNotNull(this.invtoryListener);\r
\r
// create one node and two node connectors\r
Node node1 = NodeCreator.createOFNode(1L);\r
- NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector((short) 1, node1);\r
- NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector((short) 2, node1);\r
- \r
+ NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector(\r
+ (short) 1, node1);\r
+ NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector(\r
+ (short) 2, node1);\r
+\r
// test addStaticHost(), put into inactive host DB if not verifiable\r
- Status st = this.hosttracker.addStaticHost("192.168.0.8", "11:22:33:44:55:66",\r
- nc1_1, "0");\r
- st = this.hosttracker.addStaticHost("192.168.0.13", "11:22:33:44:55:77",\r
- nc1_2, "0");\r
- \r
- this.invtoryListener.notifyNodeConnector(nc1_1,\r
- UpdateType.ADDED, null);\r
+ Status st = this.hosttracker.addStaticHost("192.168.0.8",\r
+ "11:22:33:44:55:66", nc1_1, "0");\r
+ st = this.hosttracker.addStaticHost("192.168.0.13",\r
+ "11:22:33:44:55:77", nc1_2, "0");\r
+\r
+ this.invtoryListener.notifyNodeConnector(nc1_1, UpdateType.ADDED, null);\r
\r
// check all host list\r
- Iterator<HostNodeConnector> hnci = this.hosttracker\r
- .getAllHosts().iterator();\r
+ Iterator<HostNodeConnector> hnci = this.hosttracker.getAllHosts()\r
+ .iterator();\r
while (hnci.hasNext()) {\r
ip = hnci.next().getNetworkAddressAsString();\r
Assert.assertTrue(ip.equals("192.168.0.8"));\r
}\r
- \r
+\r
// check active host DB\r
hnci = this.hosttracker.getActiveStaticHosts().iterator();\r
while (hnci.hasNext()) {\r
ip = hnci.next().getNetworkAddressAsString();\r
Assert.assertTrue(ip.equals("192.168.0.8"));\r
}\r
- \r
+\r
// check inactive host DB\r
hnci = this.hosttracker.getInactiveStaticHosts().iterator();\r
while (hnci.hasNext()) {\r
Assert.assertTrue(ip.equals("192.168.0.13"));\r
}\r
}\r
- \r
- \r
- \r
+\r
@Test\r
public void testHostFind() throws UnknownHostException {\r
- \r
+\r
assertNotNull(this.invtoryListener);\r
\r
// create one node and two node connectors\r
Node node1 = NodeCreator.createOFNode(1L);\r
- NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector((short) 1, node1);\r
- NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector((short) 2, node1);\r
- \r
+ NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector(\r
+ (short) 1, node1);\r
+ NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector(\r
+ (short) 2, node1);\r
+\r
// test addStaticHost(), put into inactive host DB if not verifiable\r
- Status st = this.hosttracker.addStaticHost(\r
- "192.168.0.8", "11:22:33:44:55:66", nc1_1, "0");\r
- st = this.hosttracker.addStaticHost(\r
- "192.168.0.13", "11:22:33:44:55:77", nc1_2, "0");\r
- \r
- HostNodeConnector hnc_1 = this.hosttracker\r
- .hostFind(InetAddress.getByName("192.168.0.8"));\r
+ Status st = this.hosttracker.addStaticHost("192.168.0.8",\r
+ "11:22:33:44:55:66", nc1_1, "0");\r
+ st = this.hosttracker.addStaticHost("192.168.0.13",\r
+ "11:22:33:44:55:77", nc1_2, "0");\r
+\r
+ HostNodeConnector hnc_1 = this.hosttracker.hostFind(InetAddress\r
+ .getByName("192.168.0.8"));\r
assertNull(hnc_1);\r
- \r
- this.invtoryListener.notifyNodeConnector(nc1_1,\r
- UpdateType.ADDED, null);\r
+\r
+ this.invtoryListener.notifyNodeConnector(nc1_1, UpdateType.ADDED, null);\r
\r
hnc_1 = this.hosttracker.hostFind(InetAddress.getByName("192.168.0.8"));\r
assertNotNull(hnc_1);\r
- \r
+\r
}\r
- \r
+\r
}\r
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Bundle;
import javax.inject.Inject;
+
import org.junit.Assert;
import org.junit.Test;
import org.junit.Before;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLConnection;
import java.nio.charset.Charset;
import java.util.Arrays;
import org.opendaylight.controller.switchmanager.IInventoryListener;
import org.opendaylight.controller.usermanager.IUserManager;
+
@RunWith(PaxExam.class)
-public class NorthboundIntegrationTest {
+public class NorthboundIT {
private Logger log = LoggerFactory
- .getLogger(NorthboundIntegrationTest.class);
+ .getLogger(NorthboundIT.class);
// get the OSGI bundle context
@Inject
private BundleContext bc;
r = bc.getServiceReference(IfIptoHost.class.getName());
if (r != null) {
- this.invtoryListener = (IInventoryListener)bc.getService(r);
+ this.invtoryListener = (IInventoryListener) bc.getService(r);
}
// If inventoryListener is null, cannot run hosttracker tests.
assertNotNull(this.invtoryListener);
-
+
}
// static variable to pass response code from getJsonResult()
private static Integer httpResponseCode = null;
private String getJsonResult(String restUrl) {
- return getJsonResult(restUrl, "GET");
+ return getJsonResult(restUrl, "GET", null);
}
private String getJsonResult(String restUrl, String method) {
+ return getJsonResult(restUrl, method, null);
+ }
+
+ private String getJsonResult(String restUrl, String method, String body) {
// initialize response code to indicate error
httpResponseCode = 400;
try {
URL url = new URL(restUrl);
-
this.users.getAuthorizationList();
this.users.authenticate("admin", "admin");
String authString = "admin:admin";
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Accept", "application/json");
+ if (body != null) {
+ connection.setDoOutput(true);
+ OutputStreamWriter wr = new OutputStreamWriter(
+ connection.getOutputStream());
+ wr.write(body);
+ wr.flush();
+ }
connection.connect();
connection.getContentType();
// Response code for success should be 2xx
httpResponseCode = connection.getResponseCode();
+ if (httpResponseCode > 299)
+ return httpResponseCode.toString();
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is,
} catch (Exception e) {
return null;
}
-
}
@Test
String result = getJsonResult(baseURL + "flowstats");
JSONTokener jt = new JSONTokener(result);
JSONObject json = new JSONObject(jt);
- JSONObject flowStatistics =
- getJsonInstance (json, "flowStatistics", 0xCAFE);
+ JSONObject flowStatistics = getJsonInstance(json, "flowStatistics",
+ 0xCAFE);
JSONObject node = flowStatistics.getJSONObject("node");
// test that node was returned properly
Assert.assertTrue(node.getInt("@id") == 0xCAFE);
result = getJsonResult(baseURL + "portstats");
jt = new JSONTokener(result);
json = new JSONObject(jt);
- JSONObject portStatistics =
- getJsonInstance (json, "portStatistics", 0xCAFE);
+ JSONObject portStatistics = getJsonInstance(json, "portStatistics",
+ 0xCAFE);
JSONObject node2 = portStatistics.getJSONObject("node");
// test that node was returned properly
Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
}
}
+ @Test
+ public void testFlowProgrammer() {
+ try {
+ String baseURL = "http://127.0.0.1:8080/controller/nb/v2/flow/default/";
+ // Attempt to get a flow that doesn't exit. Should return 404
+ // status.
+ String result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
+ Assert.assertTrue(result.equals("404"));
+
+ // test add flow1
+ String fc = "{\"dynamic\":\"false\", \"name\":\"test1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
+ result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
+ Assert.assertTrue(httpResponseCode == 201);
+
+ // test get returns flow that was added.
+ result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
+ // check that result came out fine.
+ Assert.assertTrue(httpResponseCode == 200);
+ JSONTokener jt = new JSONTokener(result);
+ JSONObject json = new JSONObject(jt);
+ Assert.assertTrue(json.getString("name").equals("test1"));
+ Assert.assertTrue(json.getString("actions").equals("DROP"));
+ Assert.assertTrue(json.getString("installInHw").equals("true"));
+ JSONObject node = json.getJSONObject("node");
+ Assert.assertTrue(node.getString("@type").equals("STUB"));
+ Assert.assertTrue(node.getString("@id").equals("51966"));
+ // test adding same flow again fails due to repeat name..return 409
+ // code
+ result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
+ Assert.assertTrue(result.equals("409"));
+
+ fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
+ result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
+ // test should return 500 for error due to same flow being added.
+ Assert.assertTrue(result.equals("500"));
+
+ // add second flow that's different
+ fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"nwSrc\":\"1.1.1.1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
+ result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
+ Assert.assertTrue(httpResponseCode == 201);
+
+ // check that request returns both flows given node.
+ result = getJsonResult(baseURL + "STUB/51966/", "GET");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ Assert.assertTrue(json.get("flowConfig") instanceof JSONArray);
+ JSONArray ja = json.getJSONArray("flowConfig");
+ Integer count = ja.length();
+ Assert.assertTrue(count == 2);
+
+ // check that request returns both flows given just container.
+ result = getJsonResult(baseURL);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ Assert.assertTrue(json.get("flowConfig") instanceof JSONArray);
+ ja = json.getJSONArray("flowConfig");
+ count = ja.length();
+ Assert.assertTrue(count == 2);
+
+ // delete a flow, check that it's no longer in list.
+ result = getJsonResult(baseURL + "STUB/51966/test2", "DELETE");
+ Assert.assertTrue(httpResponseCode == 200);
+
+ result = getJsonResult(baseURL + "STUB/51966/test2", "GET");
+ Assert.assertTrue(result.equals("404"));
+
+ } catch (Exception e) {
+ Assert.assertTrue(false);
+ }
+
+ }
+
// method to extract a JSONObject with specified node ID from a JSONObject
- // that may contain an array of JSONObjects
- // This is specifically written for statistics manager northbound REST interface
+ // that may contain an array of JSONObjects
+ // This is specifically written for statistics manager northbound REST
+ // interface
// array_name should be either "flowStatistics" or "portStatistics"
- private JSONObject getJsonInstance (JSONObject json, String array_name, Integer nodeId) throws JSONException
- {
+ private JSONObject getJsonInstance(JSONObject json, String array_name,
+ Integer nodeId) throws JSONException {
JSONObject result = null;
- if (json.get(array_name) instanceof JSONArray){
+ if (json.get(array_name) instanceof JSONArray) {
JSONArray json_array = json.getJSONArray(array_name);
for (int i = 0; i < json_array.length(); i++) {
result = json_array.getJSONObject(i);
Integer nid = result.getJSONObject("node").getInt("@id");
- if ( nid.equals(nodeId) ) break;
+ if (nid.equals(nodeId))
+ break;
}
- }
- else {
+ } else {
result = json.getJSONObject(array_name);
Integer nid = result.getJSONObject("node").getInt("@id");
- if ( ! nid.equals(nodeId) ) result = null;
+ if (!nid.equals(nodeId))
+ result = null;
}
return result;
}
-
// a class to construct query parameter for HTTP request
private class QueryParameter {
StringBuilder queryString = null;
-
+
// constructor
- QueryParameter (String key, String value) {
+ QueryParameter(String key, String value) {
queryString = new StringBuilder();
queryString.append("?").append(key).append("=").append(value);
}
-
+
// method to add more query parameter
- QueryParameter add (String key, String value){
+ QueryParameter add(String key, String value) {
this.queryString.append("&").append(key).append("=").append(value);
return this;
}
-
+
// method to get the query parameter string
- String getString (){
+ String getString() {
return this.queryString.toString();
}
}
-
-
+
@Test
public void testHostTracker() {
String nodeConnectorType_1 = "STUB";
Integer nodeConnectorId_1 = 12;
String vlan_1 = "4";
-
-
+
// 2nd host
String networkAddress_2 = "10.1.1.1";
String dataLayerAddress_2 = "1A:2B:3C:4D:5E:6F";
String nodeConnectorType_2 = "STUB";
Integer nodeConnectorId_2 = 34;
String vlan_2 = "0";
-
+
String baseURL = "http://127.0.0.1:8080/controller/nb/v2/host/default";
// test POST method: addHost()
try {
- String queryParameter =
- new QueryParameter("dataLayerAddress", dataLayerAddress_1)
- .add("nodeType", nodeType_1)
+ String queryParameter = new QueryParameter("dataLayerAddress",
+ dataLayerAddress_1).add("nodeType", nodeType_1)
.add("nodeId", nodeId_1.toString())
.add("nodeConnectorType", nodeConnectorType_1)
.add("nodeConnectorId", nodeConnectorId_1.toString())
- .add("vlan", vlan_1)
- .getString();
+ .add("vlan", vlan_1).getString();
- String result = getJsonResult(baseURL +"/" + networkAddress_1 + queryParameter, "POST");
- Assert.assertTrue (httpResponseCode.intValue() == (Integer) 201);
-
- // vlan is not passed through query parameter but should be defaulted to "0"
- queryParameter =
- new QueryParameter("dataLayerAddress", dataLayerAddress_2)
- .add("nodeType", nodeType_2)
+ String result = getJsonResult(baseURL + "/" + networkAddress_1
+ + queryParameter, "POST");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 201);
+
+ // vlan is not passed through query parameter but should be
+ // defaulted to "0"
+ queryParameter = new QueryParameter("dataLayerAddress",
+ dataLayerAddress_2).add("nodeType", nodeType_2)
.add("nodeId", nodeId_2.toString())
.add("nodeConnectorType", nodeConnectorType_2)
.add("nodeConnectorId", nodeConnectorId_2.toString())
.getString();
- result = getJsonResult(baseURL +"/" + networkAddress_2 + queryParameter, "POST");
- Assert.assertTrue (httpResponseCode.intValue() == (Integer) 201);
+ result = getJsonResult(baseURL + "/" + networkAddress_2
+ + queryParameter, "POST");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 201);
} catch (Exception e) {
// Got an unexpected exception
Assert.assertTrue(false);
}
-
+
// define variables for decoding returned strings
String networkAddress;
JSONObject host_jo, dl_jo, nc_jo, node_jo;
-
+
// the two hosts should be in inactive host DB
// test GET method: getInactiveHosts()
try {
- String result = getJsonResult(baseURL +"/inactive", "GET");
- Assert.assertTrue (httpResponseCode.intValue() == (Integer) 200);
-
+ String result = getJsonResult(baseURL + "/inactive", "GET");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+
JSONTokener jt = new JSONTokener(result);
JSONObject json = new JSONObject(jt);
// there should be at least two hosts in the DB
- Assert.assertTrue (json.get("host") instanceof JSONArray);
+ Assert.assertTrue(json.get("host") instanceof JSONArray);
JSONArray ja = json.getJSONArray("host");
Integer count = ja.length();
- Assert.assertTrue (count == 2);
-
- for ( int i = 0; i < count; i++) {
+ Assert.assertTrue(count == 2);
+
+ for (int i = 0; i < count; i++) {
host_jo = ja.getJSONObject(i);
dl_jo = host_jo.getJSONObject("dataLayerAddress");
nc_jo = host_jo.getJSONObject("nodeConnector");
node_jo = nc_jo.getJSONObject("node");
-
+
networkAddress = host_jo.getString("networkAddress");
if (networkAddress.equalsIgnoreCase(networkAddress_1)) {
- Assert.assertTrue (dl_jo.getString("macAddress").equalsIgnoreCase(dataLayerAddress_1));
- Assert.assertTrue (nc_jo.getString("@type").equalsIgnoreCase(nodeConnectorType_1));
- Assert.assertTrue (Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
- Assert.assertTrue (node_jo.getString("@type").equalsIgnoreCase(nodeType_1));
- Assert.assertTrue (Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
- Assert.assertTrue (host_jo.getString("vlan").equalsIgnoreCase(vlan_1));
- }
- else if (networkAddress.equalsIgnoreCase(networkAddress_2)) {
- Assert.assertTrue (dl_jo.getString("macAddress").equalsIgnoreCase(dataLayerAddress_2));
- Assert.assertTrue (nc_jo.getString("@type").equalsIgnoreCase(nodeConnectorType_2));
- Assert.assertTrue (Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_2);
- Assert.assertTrue (node_jo.getString("@type").equalsIgnoreCase(nodeType_2));
- Assert.assertTrue (Integer.parseInt(node_jo.getString("@id")) == nodeId_2);
- Assert.assertTrue (host_jo.getString("vlan").equalsIgnoreCase(vlan_2));
- }
- else {
+ Assert.assertTrue(dl_jo.getString("macAddress")
+ .equalsIgnoreCase(dataLayerAddress_1));
+ Assert.assertTrue(nc_jo.getString("@type")
+ .equalsIgnoreCase(nodeConnectorType_1));
+ Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
+ Assert.assertTrue(node_jo.getString("@type")
+ .equalsIgnoreCase(nodeType_1));
+ Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
+ Assert.assertTrue(host_jo.getString("vlan")
+ .equalsIgnoreCase(vlan_1));
+ } else if (networkAddress.equalsIgnoreCase(networkAddress_2)) {
+ Assert.assertTrue(dl_jo.getString("macAddress")
+ .equalsIgnoreCase(dataLayerAddress_2));
+ Assert.assertTrue(nc_jo.getString("@type")
+ .equalsIgnoreCase(nodeConnectorType_2));
+ Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_2);
+ Assert.assertTrue(node_jo.getString("@type")
+ .equalsIgnoreCase(nodeType_2));
+ Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_2);
+ Assert.assertTrue(host_jo.getString("vlan")
+ .equalsIgnoreCase(vlan_2));
+ } else {
Assert.assertTrue(false);
}
}
// Got an unexpected exception
Assert.assertTrue(false);
}
-
+
// test GET method: getActiveHosts() - no host expected
try {
String result = getJsonResult(baseURL, "GET");
- Assert.assertTrue (httpResponseCode.intValue() == (Integer) 200);
-
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+
JSONTokener jt = new JSONTokener(result);
JSONObject json = new JSONObject(jt);
Assert.assertFalse(hostInJson(json, networkAddress_1));
// Got an unexpected exception
Assert.assertTrue(false);
}
-
+
// put the 1st host into active host DB
Node nd;
NodeConnector ndc;
try {
nd = new Node(nodeType_1, nodeId_1);
ndc = new NodeConnector(nodeConnectorType_1, nodeConnectorId_1, nd);
- this.invtoryListener.notifyNodeConnector(ndc,
- UpdateType.ADDED, null);
- }catch(ConstructionException e){
+ this.invtoryListener.notifyNodeConnector(ndc, UpdateType.ADDED,
+ null);
+ } catch (ConstructionException e) {
ndc = null;
nd = null;
}
-
+
// verify the host shows up in active host DB
try {
String result = getJsonResult(baseURL, "GET");
- Assert.assertTrue (httpResponseCode.intValue() == (Integer) 200);
-
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+
JSONTokener jt = new JSONTokener(result);
JSONObject json = new JSONObject(jt);
-
+
Assert.assertTrue(hostInJson(json, networkAddress_1));
} catch (Exception e) {
// Got an unexpected exception
Assert.assertTrue(false);
}
-
-
+
// test GET method for getHostDetails()
try {
- String result = getJsonResult(baseURL+"/"+networkAddress_1, "GET");
- Assert.assertTrue (httpResponseCode.intValue() == (Integer) 200);
-
+ String result = getJsonResult(baseURL + "/" + networkAddress_1,
+ "GET");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+
JSONTokener jt = new JSONTokener(result);
JSONObject json = new JSONObject(jt);
Assert.assertFalse(json.length() == 0);
-
+
dl_jo = json.getJSONObject("dataLayerAddress");
nc_jo = json.getJSONObject("nodeConnector");
node_jo = nc_jo.getJSONObject("node");
-
- Assert.assertTrue (json.getString("networkAddress").equalsIgnoreCase(networkAddress_1));
- Assert.assertTrue (dl_jo.getString("macAddress").equalsIgnoreCase(dataLayerAddress_1));
- Assert.assertTrue (nc_jo.getString("@type").equalsIgnoreCase(nodeConnectorType_1));
- Assert.assertTrue (Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
- Assert.assertTrue (node_jo.getString("@type").equalsIgnoreCase(nodeType_1));
- Assert.assertTrue (Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
- Assert.assertTrue (json.getString("vlan").equalsIgnoreCase(vlan_1));
+
+ Assert.assertTrue(json.getString("networkAddress")
+ .equalsIgnoreCase(networkAddress_1));
+ Assert.assertTrue(dl_jo.getString("macAddress").equalsIgnoreCase(
+ dataLayerAddress_1));
+ Assert.assertTrue(nc_jo.getString("@type").equalsIgnoreCase(
+ nodeConnectorType_1));
+ Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
+ Assert.assertTrue(node_jo.getString("@type").equalsIgnoreCase(
+ nodeType_1));
+ Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
+ Assert.assertTrue(json.getString("vlan").equalsIgnoreCase(vlan_1));
} catch (Exception e) {
// Got an unexpected exception
Assert.assertTrue(false);
}
-
+
// test DELETE method for deleteFlow()
try {
- String result = getJsonResult(baseURL+"/"+networkAddress_1, "DELETE");
- Assert.assertTrue (httpResponseCode.intValue() == (Integer) 200);
-
+ String result = getJsonResult(baseURL + "/" + networkAddress_1,
+ "DELETE");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+
} catch (Exception e) {
// Got an unexpected exception
Assert.assertTrue(false);
}
-
+
// verify host_1 removed from active host DB
// test GET method: getActiveHosts() - no host expected
try {
String result = getJsonResult(baseURL, "GET");
- Assert.assertTrue (httpResponseCode.intValue() == (Integer) 200);
-
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+
JSONTokener jt = new JSONTokener(result);
JSONObject json = new JSONObject(jt);
-
+
Assert.assertFalse(hostInJson(json, networkAddress_1));
} catch (Exception e) {
// Got an unexpected exception
Assert.assertTrue(false);
}
- }
-
- private Boolean hostInJson (JSONObject json, String hostIp) throws JSONException {
- // input JSONObject may be empty
- if ( json.length() == 0 ) {
+ }
+
+ private Boolean hostInJson(JSONObject json, String hostIp)
+ throws JSONException {
+ // input JSONObject may be empty
+ if (json.length() == 0) {
return false;
}
- if (json.get("host") instanceof JSONArray){
+ if (json.get("host") instanceof JSONArray) {
JSONArray ja = json.getJSONArray("host");
for (int i = 0; i < ja.length(); i++) {
String na = ja.getJSONObject(i).getString("networkAddress");
if (na.equalsIgnoreCase(hostIp))
return true;
- }
+ }
return false;
- }
- else {
+ } else {
String na = json.getJSONObject("host").getString("networkAddress");
return (na.equalsIgnoreCase(hostIp)) ? true : false;
}
}
-
// Configure the OSGi container
@Configuration
public Option[] config() {
/**
* Returns the match in OF 1.0 (OFMatch) form or OF 1.0 + IPv6 extensions
* form (V6Match)
- *
+ *
* @return
*/
public OFMatch getOFMatch() {
* actually the DSCP field followed by a zero ECN
*/
byte tos = (Byte) match.getField(MatchType.NW_TOS).getValue();
- byte dscp = (byte) ((int) tos << 2);
+ byte dscp = (byte) (tos << 2);
if (!isIPv6) {
ofMatch.setNetworkTypeOfService(dscp);
wildcards &= ~OFMatch.OFPFW_NW_TOS;
/**
* Returns the list of actions in OF 1.0 form
- *
+ *
* @return
*/
public List<OFAction> getOFActions() {
continue;
}
if (action.getType() == ActionType.SET_NEXT_HOP) {
- // TODO
+ logger.info("Unsupported action: {}", action);
continue;
}
}
/**
* Utility to convert a SAL flow to an OF 1.0 (OFFlowMod) or to an OF 1.0 +
* IPv6 extension (V6FlowMod) Flow modifier Message
- *
+ *
* @param sw
* @param command
* @param port
if (ofMatch.getInputPort() != 0) {
salMatch.setField(new MatchField(MatchType.IN_PORT,
NodeConnectorCreator.createNodeConnector(
- (Short) ofMatch.getInputPort(), node)));
+ ofMatch.getInputPort(), node)));
}
if (ofMatch.getDataLayerSource() != null
&& !NetUtils
}
if (ofMatch.getTransportSource() != 0) {
salMatch.setField(MatchType.TP_SRC,
- ((Short) ofMatch.getTransportSource()));
+ ofMatch.getTransportSource());
}
if (ofMatch.getTransportDestination() != 0) {
salMatch.setField(MatchType.TP_DST,
- ((Short) ofMatch.getTransportDestination()));
+ ofMatch.getTransportDestination());
}
} else {
// Compute OF1.0 + IPv6 extensions Match
// Mask on input port is not defined
salMatch.setField(new MatchField(MatchType.IN_PORT,
NodeConnectorCreator.createOFNodeConnector(
- (Short) v6Match.getInputPort(), node)));
+ v6Match.getInputPort(), node)));
}
if (v6Match.getDataLayerSource() != null
&& !NetUtils
}
if (v6Match.getTransportSource() != 0) {
salMatch.setField(MatchType.TP_SRC,
- ((Short) v6Match.getTransportSource()));
+ (v6Match.getTransportSource()));
}
if (v6Match.getTransportDestination() != 0) {
salMatch.setField(MatchType.TP_DST,
- ((Short) v6Match.getTransportDestination()));
+ (v6Match.getTransportDestination()));
}
}
}
import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimInternalListener;
import org.opendaylight.controller.protocol_plugin.openflow.core.IController;
import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
-import org.opendaylight.controller.sal.core.Actions;
-import org.opendaylight.controller.sal.core.Buffers;
-import org.opendaylight.controller.sal.core.Capabilities;
import org.opendaylight.controller.sal.core.ConstructionException;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.Node.NodeIDType;
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.core.Property;
-import org.opendaylight.controller.sal.core.Tables;
-import org.opendaylight.controller.sal.core.TimeStamp;
import org.opendaylight.controller.sal.core.UpdateType;
import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
*/
@Override
public ConcurrentMap<Node, Map<String, Property>> getNodeProps() {
- if (nodeProps == null)
- return null;
- Map<Long, ISwitch> switches = controller.getSwitches();
- for (Map.Entry<Long, ISwitch> entry : switches.entrySet()) {
- ISwitch sw = entry.getValue();
- Node node = OFSwitchToNode(sw);
- Map<String, Property> propMap = null;
- if (isDefaultContainer) {
- propMap = new HashMap<String, Property>();
- byte tables = sw.getTables();
- Tables t = new Tables(tables);
- if (t != null) {
- propMap.put(Tables.TablesPropName, t);
- }
- int cap = sw.getCapabilities();
- Capabilities c = new Capabilities(cap);
- if (c != null) {
- propMap.put(Capabilities.CapabilitiesPropName, c);
- }
- int act = sw.getActions();
- Actions a = new Actions(act);
- if (a != null) {
- propMap.put(Actions.ActionsPropName, a);
- }
- int buffers = sw.getBuffers();
- Buffers b = new Buffers(buffers);
- if (b != null) {
- propMap.put(Buffers.BuffersPropName, b);
- }
- Date connectedSince = sw.getConnectedDate();
- Long connectedSinceTime = (connectedSince == null) ? 0
- : connectedSince.getTime();
- TimeStamp timeStamp = new TimeStamp(connectedSinceTime,
- "connectedSince");
- propMap.put(TimeStamp.TimeStampPropName, timeStamp);
- nodeProps.put(node, propMap);
- }
- }
return nodeProps;
}
--- /dev/null
+package org.opendaylight.controller.sal.action;
+
+import java.net.InetAddress;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class SetNextHop extends Action {
+ @XmlElement
+ private InetAddress address;
+
+ /* Dummy constructor for JAXB */
+ @SuppressWarnings("unused")
+ private SetNextHop() {
+ }
+
+ public SetNextHop(InetAddress address) {
+ type = ActionType.SET_NEXT_HOP;
+ this.address = address;
+ }
+
+ public InetAddress getAddress() {
+ return address;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((address == null) ? 0 : address.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ SetNextHop other = (SetNextHop) obj;
+ if (address == null) {
+ if (other.address != null) {
+ return false;
+ }
+ } else if (!address.equals(other.address)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return type + "[" + address.toString() + "]";
+ }
+}
} else if (typeStr.equals(NodeIDType.PRODUCTION)) {
this.nodeID = IDStr;
} else {
- // We need to lookup via OSGi service registry for an
- // handler for this
+ //Use plugin's method to get appropriate conversion from IDStr to nodeID
+ INodeFactory f = (INodeFactory) ServiceHelper
+ .getGlobalInstance(INodeFactory.class, new Node(), "(protocolName="+typeStr+")");
+ if(f!=null){
+ Node n = f.fromString(typeStr, IDStr);
+ this.nodeID = n.nodeID;
+ }
}
}
import java.util.LinkedHashMap;
import java.util.Map;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@Override
public int hashCode() {
- return HashCodeBuilder.reflectionHashCode(this);
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result
+ + ((fieldValues == null) ? 0 : fieldValues.hashCode());
+ return result;
}
@Override
public boolean equals(Object obj) {
- return EqualsBuilder.reflectionEquals(this, obj);
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ARP other = (ARP) obj;
+ if (fieldValues == null) {
+ if (other.fieldValues != null)
+ return false;
+ } else if (!fieldValues.equals(other.fieldValues))
+ return false;
+ return true;
}
}
* Deriving the Total Length here
*/
int payloadLength = 0;
- try {
- payloadLength = payload.serialize().length;
- } catch (PacketException e) {
- logger.error("", e);
+ if (payload != null) {
+ try {
+ payloadLength = payload.serialize().length;
+ } catch (PacketException e) {
+ logger.error("", e);
+ }
}
this.setTotalLength((short) (this.getHeaderLen() + payloadLength));
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
-import java.util.HashMap;
-
import java.util.Arrays;
+import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
+
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.opendaylight.controller.sal.utils.HexEncode;
@Override
public int hashCode() {
- return HashCodeBuilder.reflectionHashCode(this);
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result
+ + ((fieldValues == null) ? 0 : fieldValues.hashCode());
+ return result;
}
@Override
public boolean equals(Object obj) {
- return EqualsBuilder.reflectionEquals(this, obj);
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ LLDPTLV other = (LLDPTLV) obj;
+ if (fieldValues == null) {
+ if (other.fieldValues != null)
+ return false;
+ } else if (!fieldValues.equals(other.fieldValues))
+ return false;
+ return true;
}
@Override
/**
* Returns the size in bits of the whole TLV
- *
+ *
* @return int - size in bits of full TLV
*/
public int getTLVSize() {
/**
* Creates the ChassisID TLV value including the subtype and ChassisID
* string
- *
+ *
* @param nodeId
* node identifier string
* @return the ChassisID TLV value in byte array
/**
* Creates the PortID TLV value including the subtype and PortID string
- *
+ *
* @param portId
* port identifier string
* @return the PortID TLV value in byte array
/**
* Creates the custom TLV value including OUI, subtype and custom string
- *
+ *
* @param portId
* port identifier string
* @return the custom TLV value in byte array
/**
* Retrieves the string from TLV value and returns it in HexString format
- *
+ *
* @param tlvValue
* the TLV value
* @param tlvLen
/**
* Retrieves the string from TLV value
- *
+ *
* @param tlvValue
* the TLV value
* @param tlvLen
/**
* Retrieves the custom string from the Custom TLV value which includes OUI,
* subtype and custom string
- *
+ *
* @param customTlvValue
* the custom TLV value
* @param customTlvLen
/**
* This method deserializes the data bits obtained from the wire into the
* respective header and payload which are of type Packet
- *
+ *
* @param byte[] data - data from wire to deserialize
* @param int bitOffset bit position where packet header starts in data
* array
/**
* This method serializes the header and payload from the respective
* packet class, into a single stream of bytes to be sent on the wire
- *
+ *
* @return The byte array representing the serialized Packet
* @throws PacketException
*/
* byte stream which cannot be done or cannot be done efficiently during the
* normal Packet.serialize() path. An example is the checksum computation
* for IPv4
- *
+ *
* @param byte[] - serialized bytes
* @throws PacketException
*/
* of checksum varies based on the protocol, this method is overridden.
* Currently only IPv4 and ICMP do checksum computation and validation. TCP
* and UDP need to implement these if required.
- *
+ *
* @param byte[] data The byte stream representing the Ethernet frame
* @param int startBitOffset The bit offset from where the byte array corresponding to this Packet starts in the frame
* @throws PacketException
/**
* Gets the header length in bits
- *
+ *
* @return int the header length in bits
*/
public int getHeaderSize() {
* This method fetches the start bit offset for header field specified by
* 'fieldname'. The offset is present in the hdrFieldCoordMap of the
* respective packet class
- *
+ *
* @param String
* fieldName
* @return Integer - startOffset of the requested field
* This method fetches the number of bits for header field specified by
* 'fieldname'. The numBits are present in the hdrFieldCoordMap of the
* respective packet class
- *
+ *
* @param String
* fieldName
* @return Integer - number of bits of the requested field
/**
* Returns the raw payload carried by this packet in case payload was not
* parsed. Caller can call this function in case the getPaylod() returns null.
- *
+ *
* @return The raw payload if not parsable as an array of bytes, null otherwise
*/
public byte[] getRawPayload() {
/**
* Set a raw payload in the packet class
- *
+ *
* @param payload The raw payload as byte array
*/
public void setRawPayload(byte[] payload) {
* packet received from wire is not equal to the checksum read from the
* stream. For the Packet class which do not have a checksum field, this
* function will always return false.
- *
- *
+ *
+ *
* @return true if the deserialized packet's recomputed checksum is not
* equal to the packet carried checksum
*/
* @return the integer number
*/
public static int byteArray4ToInt(byte[] ba) {
- if (ba == null || ba.length != 4)
+ if (ba == null || ba.length != 4) {
return 0;
- return (int) ((0xff & ba[0]) << 24 | (0xff & ba[1]) << 16
- | (0xff & ba[2]) << 8 | (0xff & ba[3]));
+ }
+ return (0xff & ba[0]) << 24 | (0xff & ba[1]) << 16
+ | (0xff & ba[2]) << 8 | (0xff & ba[3]);
}
/**
int intMask = 0;
int numBytes = prefixMask.length;
for (int i = 0; i < numBytes; i++) {
- intMask |= ((int) prefixMask[i] & 0xff) << (8 * (numBytes - 1 - i));
+ intMask |= (prefixMask[i] & 0xff) << (8 * (numBytes - 1 - i));
}
int bit = 1;
if (isAny(testAddress) || isAny(filterAddress)) {
return false;
}
-
+
int testMaskLen = (testMask != null) ? NetUtils.getSubnetMaskLength(testMask.getAddress()) : 0;
int filterMaskLen = (filterMask != null) ? NetUtils.getSubnetMaskLength(filterMask.getAddress()) : 0;
-
+
int testPrefixLen = (testAddress instanceof Inet6Address) ? (128 - testMaskLen) : (32 - testMaskLen);
int filterPrefixLen = (filterAddress instanceof Inet6Address) ? (128 - filterMaskLen) : (32 - filterMaskLen);
-
+
// Mask length check. Test mask has to be more specific than filter one
if (testPrefixLen < filterPrefixLen) {
return true;
* @return
*/
public static boolean isIPv4AddressValid(String cidr) {
- if (cidr == null)
+ if (cidr == null) {
return false;
+ }
String values[] = cidr.split("/");
Pattern ipv4Pattern = Pattern
* @return
*/
public static boolean isIPv6AddressValid(String cidr) {
- if (cidr == null)
+ if (cidr == null) {
return false;
+ }
String values[] = cidr.split("/");
try {
}
return true;
}
-
+
+ /**
+ * Checks if the passed IP address in string form is a valid v4 or v6
+ * address. The address may specify a mask at the end as "/MMM"
+ *
+ * @param cidr
+ * the v4 or v6 address as IP/MMM
+ * @return
+ */
+ public static boolean isIPAddressValid(String cidr) {
+ return NetUtils.isIPv4AddressValid(cidr)
+ || NetUtils.isIPv6AddressValid(cidr);
+ }
+
/*
- * Following utilities are useful when you need to
+ * Following utilities are useful when you need to
* compare or bit shift java primitive type variable
* which are inerently signed
*/
/**
* Returns the unsigned value of the passed byte variable
- *
+ *
* @param b the byte value
* @return the int variable containing the unsigned byte value
*/
public static int getUnsignedByte(byte b) {
- return (b > 0)? (int)b : ((int)b & 0x7F | 0x80);
+ return (b > 0)? (int)b : (b & 0x7F | 0x80);
}
-
+
/**
* Return the unsigned value of the passed short variable
- *
+ *
* @param s the short value
* @return the int variable containing the unsigned short value
*/
public static int getUnsignedShort(short s) {
- return (s > 0)? (int)s : ((int)s & 0x7FFF | 0x8000);
+ return (s > 0)? (int)s : (s & 0x7FFF | 0x8000);
}
}
try {
ip = InetAddress.getByName("2001:420:281:1003:f2de:f1ff:fe71:728d");
} catch (UnknownHostException e) {
- logger.error("",e);
+ logger.error("", e);
}
action = new SetNwSrc(ip);
Assert.assertTrue(action.isValid());
action = new SetNwTos(0x40);
Assert.assertFalse(action.isValid());
-
+
action = new SetNwTos(0xff1);
Assert.assertFalse(action.isValid());
Assert.assertFalse(action.isValid());
}
+ @Test
+ public void testNextHopActionCreation() {
+ SetNextHop action = null;
+
+ InetAddress ip = null;
+ try {
+ ip = InetAddress.getByName("171.71.9.52");
+ } catch (UnknownHostException e) {
+ logger.error("", e);
+ }
+
+ action = new SetNextHop(ip);
+ Assert.assertTrue(action.getAddress().equals(ip));
+
+ try {
+ ip = InetAddress.getByName("2001:420:281:1003:f2de:f1ff:fe71:728d");
+ } catch (UnknownHostException e) {
+ logger.error("", e);
+ }
+ action = new SetNextHop(ip);
+ Assert.assertTrue(action.getAddress().equals(ip));
+ }
+
@Test
public void testActionList() {
List<Action> actions = new ArrayList<Action>();
.isIPv6AddressValid("fe80:::0:0:0:204:61ff:fe9d/-1")); //not valid both
}
-
+
@Test
public void testInetAddressConflict() throws UnknownHostException {
InetAddress.getByName("255.255.0.0")));
}
+
+ @Test
+ public void testIPAddressValidity() {
+ Assert.assertFalse(NetUtils.isIPAddressValid(null));
+ Assert.assertFalse(NetUtils.isIPAddressValid("abc"));
+ Assert.assertFalse(NetUtils.isIPAddressValid("1.1.1"));
+ Assert.assertFalse(NetUtils.isIPAddressValid("1.1.1.1/49"));
+
+ Assert.assertTrue(NetUtils.isIPAddressValid("1.1.1.1"));
+ Assert.assertTrue(NetUtils.isIPAddressValid("1.1.1.1/32"));
+ Assert.assertTrue(NetUtils
+ .isIPAddressValid("2001:420:281:1004:407a:57f4:4d15:c355"));
+ }
}
.getGlobalInstance(IUserManager.class, this);
if (userManager != null) {
return userManager.getPassword(username);
- } else
+ } else {
throw new RuntimeException("User Manager reference is null");
+ }
}
@Override
IUserManager userManager = (IUserManager) ServiceHelper
.getGlobalInstance(IUserManager.class, this);
if (userManager != null) {
- final List<String> levels = new ArrayList<String>();
- UserLevel level = userManager.getUserLevel(username);
- if (level == null) level = UserLevel.NOUSER;
- levels.add(level.toString());
- return new GenericPrincipal(username, "", levels);
- } else
+ List<String> controllerRoles = new ArrayList<String>();
+ for (UserLevel level : userManager.getUserLevels(username)) {
+ controllerRoles.add(level.toString());
+ }
+ return new GenericPrincipal(username, "", controllerRoles);
+ } else {
throw new RuntimeException("User Manager reference is null");
-
+ }
}
@Override
logger.error("Authentication failed for user " + username);
return null;
}
- } else
+ } else {
throw new RuntimeException("User Manager reference is null");
+ }
}
}
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.opendaylight</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <artifactId>commons.integrationtest</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ <relativePath>../../commons/integrationtest</relativePath>
</parent>
<artifactId>statisticsmanager.integrationtest</artifactId>
<version>0.4.0-SNAPSHOT</version>
import org.ops4j.pax.exam.util.PathUtils;
@RunWith(PaxExam.class)
-public class StatisticsManagerIntegrationTest {
+public class StatisticsManagerIT {
private Logger log = LoggerFactory
- .getLogger(StatisticsManagerIntegrationTest.class);
+ .getLogger(StatisticsManagerIT.class);
// get the OSGI bundle context
@Inject
private BundleContext bc;
mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",
"0.8.0.v201110170705"),
// List logger bundles
- mavenBundle("org.slf4j", "slf4j-api", "1.7.2"),
- mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"),
- mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),
- mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),
+ mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
+ mavenBundle("org.slf4j", "log4j-over-slf4j")
+ .versionAsInProject(),
+ mavenBundle("ch.qos.logback", "logback-core")
+ .versionAsInProject(),
+ mavenBundle("ch.qos.logback", "logback-classic")
+ .versionAsInProject(),
// List all the bundles on which the test case depends
- mavenBundle("org.opendaylight.controller", "sal",
- "0.5.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "sal")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "sal.implementation")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "statisticsmanager")
+ .versionAsInProject(),
mavenBundle("org.opendaylight.controller",
- "sal.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "statisticsmanager",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "statisticsmanager.implementation",
- "0.4.0-SNAPSHOT"),
+ "statisticsmanager.implementation")
+ .versionAsInProject(),
mavenBundle("org.opendaylight.controller",
- "protocol_plugins.stub", "0.4.0-SNAPSHOT"),
+ "protocol_plugins.stub").versionAsInProject(),
// needed by statisticsmanager
- mavenBundle("org.opendaylight.controller", "containermanager",
- "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "containermanager")
+ .versionAsInProject(),
mavenBundle("org.opendaylight.controller",
- "containermanager.implementation", "0.4.0-SNAPSHOT"),
+ "containermanager.implementation").versionAsInProject(),
mavenBundle("org.opendaylight.controller",
- "forwardingrulesmanager", "0.4.0-SNAPSHOT"),
+ "forwardingrulesmanager").versionAsInProject(),
mavenBundle("org.opendaylight.controller",
- "clustering.services", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller",
- "clustering.stub", "0.4.0-SNAPSHOT"),
+ "clustering.services").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "clustering.stub")
+ .versionAsInProject(),
// needed by forwardingrulesmanager
- mavenBundle("org.opendaylight.controller", "switchmanager",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "configuration",
- "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "switchmanager")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "configuration")
+ .versionAsInProject(),
mavenBundle("org.opendaylight.controller",
- "configuration.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "hosttracker",
- "0.4.0-SNAPSHOT"),
+ "configuration.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "hosttracker")
+ .versionAsInProject(),
// needed by hosttracker
- mavenBundle("org.opendaylight.controller", "topologymanager",
- "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "topologymanager")
+ .versionAsInProject(),
mavenBundle("org.jboss.spec.javax.transaction",
- "jboss-transaction-api_1.1_spec", "1.0.1.Final"),
- mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
+ "jboss-transaction-api_1.1_spec").versionAsInProject(),
+ mavenBundle("org.apache.commons", "commons-lang3")
+ .versionAsInProject(),
mavenBundle("org.apache.felix",
- "org.apache.felix.dependencymanager", "3.1.0"),
- junitBundles());
+ "org.apache.felix.dependencymanager")
+ .versionAsInProject(), junitBundles());
}
private String stateToString(int state) {
Match match = new Match();
try {
- match.setField(MatchType.NW_DST, InetAddress.getByName("1.1.1.1"));
+ match.setField(MatchType.NW_DST,
+ InetAddress.getByName("1.1.1.1"));
} catch (UnknownHostException e) {
fail("Couldn't create match");
}
Assert.assertTrue(match.equals(fn.getFlow().getMatch()));
- Assert.assertTrue(fn.getFlow().getActions().get(0).equals(new Drop()));
+ Assert.assertTrue(fn.getFlow().getActions().get(0)
+ .equals(new Drop()));
} catch (ConstructionException e) {
// Got an unexpected exception
Assert.assertTrue(false);
}
-
+
}
@Test
actions.add(action);
flow.setActions(actions);
- try{
+ try {
Node node = new Node("STUB", 0xCAFE);
FlowEntry fe = new FlowEntry("g1", "f1", flow, node);
List<FlowEntry> list = new ArrayList<FlowEntry>();
list.add(fe);
FlowEntry fe2 = new FlowEntry("g1", "f2", flow, node);
list.add(fe2);
-
+
Map<Node, List<FlowOnNode>> result = this.manager
.getFlowStatisticsForFlowList(null);
Assert.assertTrue(result.isEmpty());
Assert.assertTrue(fn.getTableId() == (byte) 0x1);
Assert.assertTrue(fn.getPacketCount() == 200);
Assert.assertTrue(fn.getFlow().equals(flow));
- }catch(ConstructionException e){
+ } catch (ConstructionException e) {
Assert.assertTrue(false);
}
@Test
public void testGetFlowsNumber() {
- try{
+ try {
Node node = new Node("STUB", 0xCAFE);
- Assert.assertTrue(this.manager.getFlowsNumber(node) == 21);
+ Assert.assertEquals(21, this.manager.getFlowsNumber(node));
}catch(ConstructionException e){
Assert.assertTrue(false);
}
@Test
public void testGetNodeDescription() {
- try{
+ try {
Node node = new Node("STUB", 0xCAFE);
NodeDescription desc = this.manager.getNodeDescription(node);
Assert.assertTrue(desc.getDescription().equals(
Assert.assertTrue(desc.getSoftware().equals("stub software"));
Assert.assertTrue(desc.getSerialNumber().equals("123"));
Assert.assertTrue(desc.getManufacturer().equals("opendaylight"));
- }catch(ConstructionException e){
+ } catch (ConstructionException e) {
Assert.assertTrue(false);
}
@Test
public void testGetNodeConnectorStatistics() {
- try{
+ try {
Node node = new Node("STUB", 0xCAFE);
List<NodeConnectorStatistics> stats = this.manager
.getNodeConnectorStatistics(node);
Assert.assertTrue(ns.getTransmitDropCount() == 50);
Assert.assertTrue(ns.getTransmitErrorCount() == 10);
Assert.assertTrue(ns.getTransmitPacketCount() == 500);
-
+
NodeConnector nc = ns.getNodeConnector();
NodeConnectorStatistics ns2 = this.manager
.getNodeConnectorStatistics(nc);
Assert.assertTrue(ns2.getTransmitDropCount() == 50);
Assert.assertTrue(ns2.getTransmitErrorCount() == 10);
Assert.assertTrue(ns2.getTransmitPacketCount() == 500);
-
- }catch(ConstructionException e){
+
+ } catch (ConstructionException e) {
Assert.assertTrue(false);
}
}
-}
+}
\ No newline at end of file
@Override
public byte[] getNodeMAC(Node node) {
- MacAddress mac = (MacAddress) nodeProps.get(MacAddress.name);
+ MacAddress mac = (MacAddress) this.getNodeProp(node,
+ MacAddress.name);
return (mac != null) ? mac.getMacAddress() : null;
}
List<NodeConnector> ncLists = new ArrayList<NodeConnector>();
for (NodeConnector nodeConnector : nodeConncetors) {
- if (!spanNodeConnectors.contains(nodeConnector)) {
+ if (spanNodeConnectors.contains(nodeConnector)) {
ncLists.add(nodeConnector);
}
}
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.opendaylight</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- <relativePath>../../../opendaylight/commons/opendaylight</relativePath>
+ <artifactId>commons.integrationtest</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ <relativePath>../../commons/integrationtest</relativePath>
</parent>
<artifactId>switchmanager.integrationtest</artifactId>
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
package org.opendaylight.controller.switchmanager.internal;
-
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import org.ops4j.pax.exam.spi.reactors.PerClass;
@RunWith(PaxExam.class)
-public class SwitchmanagerIntegrationTest {
- private Logger log = LoggerFactory
- .getLogger(SwitchmanagerIntegrationTest.class);
+public class SwitchManagerIT {
+ private Logger log = LoggerFactory.getLogger(SwitchManagerIT.class);
// get the OSGI bundle context
@Inject
private BundleContext bc;
mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",
"0.8.0.v201110170705"),
// List logger bundles
- mavenBundle("org.slf4j", "slf4j-api", "1.7.2"),
- mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"),
- mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),
- mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),
-
- mavenBundle("org.opendaylight.controller", "switchmanager",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "switchmanager.implementation",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "sal",
- "0.5.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "sal.implementation",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "containermanager",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "containermanager.implementation",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "clustering.services",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "clustering.stub",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "configuration",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "configuration.implementation",
- "0.4.0-SNAPSHOT"),
+ mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
+ mavenBundle("org.slf4j", "log4j-over-slf4j")
+ .versionAsInProject(),
+ mavenBundle("ch.qos.logback", "logback-core")
+ .versionAsInProject(),
+ mavenBundle("ch.qos.logback", "logback-classic")
+ .versionAsInProject(),
+
+ mavenBundle("org.opendaylight.controller", "switchmanager")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller",
+ "switchmanager.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "sal")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "sal.implementation")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "containermanager")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller",
+ "containermanager.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller",
+ "clustering.services").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "clustering.stub")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "configuration")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller",
+ "configuration.implementation").versionAsInProject(),
mavenBundle("org.opendaylight.controller",
- "protocol_plugins.stub", "0.4.0-SNAPSHOT"),
+ "protocol_plugins.stub").versionAsInProject(),
mavenBundle("org.jboss.spec.javax.transaction",
- "jboss-transaction-api_1.1_spec", "1.0.1.Final"),
- mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
+ "jboss-transaction-api_1.1_spec").versionAsInProject(),
+ mavenBundle("org.apache.commons", "commons-lang3")
+ .versionAsInProject(),
mavenBundle("org.apache.felix",
- "org.apache.felix.dependencymanager", "3.1.0"),
- junitBundles());
+ "org.apache.felix.dependencymanager")
+ .versionAsInProject(), junitBundles());
}
private String stateToString(int state) {
// Assert if true, if false we are good to go!
assertFalse(debugit);
- // Now lets create a hosttracker for testing purpose
- ServiceReference s = bc
- .getServiceReference(ISwitchManager.class.getName());
- if (s != null) {
- this.switchManager = (ISwitchManager)bc.getService(s);
- }
+ // Now lets create a hosttracker for testing purpose
+ ServiceReference s = bc.getServiceReference(ISwitchManager.class
+ .getName());
+ if (s != null) {
+ this.switchManager = (ISwitchManager) bc.getService(s);
+ }
- // If StatisticsManager is null, cannot run tests.
- assertNotNull(this.switchManager);
+ // If StatisticsManager is null, cannot run tests.
+ assertNotNull(this.switchManager);
}
-
@Test
public void testNodeProp() throws UnknownHostException {
assertNotNull(this.switchManager);
Node node;
- try{
+ try {
node = new Node("STUB", new Integer(0xCAFE));
- }catch(ConstructionException e){
- //test failed if node cannot be created.
+ } catch (ConstructionException e) {
+ // test failed if node cannot be created.
node = null;
Assert.assertTrue(false);
}
Map<String, Property> propMap = this.switchManager.getNodeProps(node);
Assert.assertFalse(propMap.isEmpty());
- Assert.assertTrue(this.switchManager.getNodeProp
- (node, Capabilities.CapabilitiesPropName)
- .equals(new Capabilities((int)3)));
- Assert.assertTrue(this.switchManager.getNodeProp
- (node, Actions.ActionsPropName)
- .equals(new Actions((int)2)));
- Assert.assertTrue(this.switchManager.getNodeProp
- (node, Buffers.BuffersPropName)
- .equals(new Buffers((int)1)));
- Assert.assertTrue(this.switchManager.getNodeProp
- (node, TimeStamp.TimeStampPropName)
- .equals(new TimeStamp(100000L, "connectedSince")));
+ Assert.assertTrue(this.switchManager.getNodeProp(node,
+ Capabilities.CapabilitiesPropName).equals(
+ new Capabilities((int) 3)));
+ Assert.assertTrue(this.switchManager.getNodeProp(node,
+ Actions.ActionsPropName).equals(new Actions((int) 2)));
+ Assert.assertTrue(this.switchManager.getNodeProp(node,
+ Buffers.BuffersPropName).equals(new Buffers((int) 1)));
+ Assert.assertTrue(this.switchManager.getNodeProp(node,
+ TimeStamp.TimeStampPropName).equals(
+ new TimeStamp(100000L, "connectedSince")));
}
@Test
try {
node = new Node("STUB", 0xCAFE);
nc = new NodeConnector("STUB", 0xCAFE, node);
- }
- catch(ConstructionException e){
+ } catch (ConstructionException e) {
node = null;
nc = null;
Assert.assertTrue(false);
}
- Map<String, Property> propMap = this.switchManager.getNodeConnectorProps(nc);
+ Map<String, Property> propMap = this.switchManager
+ .getNodeConnectorProps(nc);
Assert.assertFalse(propMap.isEmpty());
- Assert.assertTrue(this.switchManager.getNodeConnectorProp
- (nc, Capabilities.CapabilitiesPropName)
- .equals(new Capabilities
- (CapabilitiesType.FLOW_STATS_CAPABILITY.getValue())));
- Assert.assertTrue(this.switchManager.getNodeConnectorProp
- (nc, Bandwidth.BandwidthPropName)
- .equals(new Bandwidth (Bandwidth.BW1Gbps)));
- Assert.assertTrue(this.switchManager.getNodeConnectorProp
- (nc, State.StatePropName)
- .equals(new State (State.EDGE_UP)));
+ Assert.assertTrue(this.switchManager.getNodeConnectorProp(nc,
+ Capabilities.CapabilitiesPropName).equals(
+ new Capabilities(CapabilitiesType.FLOW_STATS_CAPABILITY
+ .getValue())));
+ Assert.assertTrue(this.switchManager.getNodeConnectorProp(nc,
+ Bandwidth.BandwidthPropName).equals(
+ new Bandwidth(Bandwidth.BW1Gbps)));
+ Assert.assertTrue(this.switchManager.getNodeConnectorProp(nc,
+ State.StatePropName).equals(new State(State.EDGE_UP)));
}
}
@XmlAccessorType(XmlAccessType.NONE)
public class TopologyUserLinkConfig implements Serializable {
private static final long serialVersionUID = 1L;
- private static final String regexDatapathID = "^([0-9a-fA-F]{1,2}[:-]){7}[0-9a-fA-F]{1,2}$";
- private static final String regexDatapathIDLong = "^[0-9a-fA-F]{1,16}$";
- private static final String guiFields[] = { GUIField.STATUS.toString(),
- GUIField.NAME.toString(), GUIField.SRCNODE.toString(),
- GUIField.SRCPORT.toString(), GUIField.DSTNODE.toString(),
- GUIField.DSTPORT.toString() };
- private static final Logger logger = LoggerFactory
- .getLogger(TopologyUserLinkConfig.class);
+ private static final Logger logger = LoggerFactory.getLogger(TopologyUserLinkConfig.class);
public enum STATUS {
SUCCESS("Success"), LINKDOWN("Link Down"), INCORRECT(
@XmlElement
private String name;
@XmlElement
- private String srcNodeIDType;
+ private String srcNodeConnector;
@XmlElement
- private String srcSwitchId;
- @XmlElement
- private String srcNodeConnectorIDType;
- @XmlElement
- private String srcPort;
- @XmlElement
- private String dstNodeIDType;
- @XmlElement
- private String dstSwitchId;
- @XmlElement
- private String dstNodeConnectorIDType;
- @XmlElement
- private String dstPort;
+ private String dstNodeConnector;
public TopologyUserLinkConfig() {
super();
status = STATUS.LINKDOWN.toString();
}
- public TopologyUserLinkConfig(String name, String srcNodeIDType,
- String srcSwitchId, String srcNodeConnectorIDType, String srcPort,
- String dstNodeIDType, String dstSwitchId,
- String dstNodeConnectorIDType, String dstPort) {
+ public TopologyUserLinkConfig(String name, String srcNodeConnector, String dstNodeConnector) {
super();
this.name = name;
- this.srcNodeIDType = srcNodeIDType;
- this.srcSwitchId = srcSwitchId;
- this.dstNodeIDType = dstNodeIDType;
- this.dstSwitchId = dstSwitchId;
- this.srcNodeConnectorIDType = srcNodeConnectorIDType;
- this.srcPort = srcPort;
- this.dstNodeConnectorIDType = dstNodeConnectorIDType;
- this.dstPort = dstPort;
+ this.srcNodeConnector = srcNodeConnector;
+ this.dstNodeConnector = dstNodeConnector;
}
- public String getSrcNodeIDType() {
- return srcNodeIDType;
- }
-
- public void setSrcNodeIDType(String srcNodeIDType) {
- this.srcNodeIDType = srcNodeIDType;
- }
-
- public String getSrcNodeConnectorIDType() {
- return srcNodeConnectorIDType;
- }
- public void setSrcNodeConnectorIDType(String srcNodeConnectorIDType) {
- this.srcNodeConnectorIDType = srcNodeConnectorIDType;
- }
-
- public String getDstNodeIDType() {
- return dstNodeIDType;
- }
-
- public void setDstNodeIDType(String dstNodeIDType) {
- this.dstNodeIDType = dstNodeIDType;
- }
-
- public String getDstNodeConnectorIDType() {
- return dstNodeConnectorIDType;
- }
-
- public void setDstNodeConnectorIDType(String dstNodeConnectorIDType) {
- this.dstNodeConnectorIDType = dstNodeConnectorIDType;
- }
-
- public String getName() {
+ public String getName() {
return name;
}
this.name = name;
}
- public String getSrcSwitchId() {
- return srcSwitchId;
- }
-
- public long getSrcSwitchIDLong() {
- return getSwitchIDLong(srcSwitchId);
- }
-
- public void setSrcSwitchId(String srcSwitchId) {
- this.srcSwitchId = srcSwitchId;
- }
-
- public String getDstSwitchId() {
- return dstSwitchId;
- }
-
- public long getDstSwitchIDLong() {
- return getSwitchIDLong(dstSwitchId);
- }
-
- public void setDstSwitchId(String dstSwitchId) {
- this.dstSwitchId = dstSwitchId;
- }
-
- public String getSrcPort() {
- return srcPort;
- }
-
- public void setSrcPort(String srcPort) {
- this.srcPort = srcPort;
- }
-
- public String getDstPort() {
- return dstPort;
- }
-
- public void setDstPort(String dstPort) {
- this.dstPort = dstPort;
- }
public STATUS getStatus() {
return STATUS.fromString(status);
this.status = s.toString();
}
- private boolean isValidSwitchId(String switchId) {
- return (switchId != null && (switchId.matches(regexDatapathID) || switchId
- .matches(regexDatapathIDLong)));
+ public String getSrcNodeConnector() {
+ return srcNodeConnector;
}
- private boolean isValidSwitchId(String switchId, String typeStr) {
- if (typeStr.equals(NodeIDType.OPENFLOW)) {
- return isValidSwitchId(switchId);
- } else if (typeStr.equals(NodeIDType.ONEPK) ||
- typeStr.equals(NodeIDType.PCEP) ||
- typeStr.equals(NodeIDType.PRODUCTION)) {
- return true;
- } else {
- logger.warn("Invalid node id type {}", typeStr);
- return false;
- }
+ public void setSrcNodeConnector(String srcNodeConnector) {
+ this.srcNodeConnector = srcNodeConnector;
}
- private boolean isValidPortId(String portId, String nodeConnectorType) {
- if (NodeConnectorIDType.getClassType(nodeConnectorType) == null) {
- logger.warn("Invalid node connector id type {}", nodeConnectorType);
- return false;
- }
-
- return true;
- }
-
- private long getSwitchIDLong(String switchId) {
- int radix = 16;
- String switchString = "0";
-
- if (isValidSwitchId(switchId)) {
- if (switchId.contains(":")) {
- // Handle the 00:00:AA:BB:CC:DD:EE:FF notation
- switchString = switchId.replace(":", "");
- } else if (switchId.contains("-")) {
- // Handle the 00-00-AA-BB-CC-DD-EE-FF notation
- switchString = switchId.replace("-", "");
- } else {
- // Handle the 0123456789ABCDEF notation
- switchString = switchId;
- }
- }
- return Long.parseLong(switchString, radix);
+ public String getDstNodeConnector() {
+ return dstNodeConnector;
}
- public boolean isValid() {
- if (name == null || srcSwitchId == null || dstSwitchId == null
- || srcPort == null || dstPort == null || srcNodeIDType == null
- || dstNodeIDType == null || srcNodeConnectorIDType == null
- || dstNodeConnectorIDType == null) {
- return false;
- }
-
- if (!isValidSwitchId(srcSwitchId, srcNodeIDType) ||
- !isValidSwitchId(dstSwitchId, dstNodeIDType)) {
- logger.warn("Invalid switch id");
- return false;
- }
-
- if (!isValidPortId(srcPort, srcNodeConnectorIDType) ||
- !isValidPortId(dstPort, dstNodeConnectorIDType)) {
- logger.warn("Invalid port id");
- return false;
- }
-
- return true;
+ public void setDstNodeConnector(String dstNodeConnector) {
+ this.dstNodeConnector = dstNodeConnector;
}
- public boolean isSrcPortByName() {
- try {
- Short.parseShort(srcPort);
- } catch (Exception e) {
- return true;
- }
- return false;
+ public boolean isValidNodeConnector(String nodeConnectorStr) {
+ NodeConnector nc = NodeConnector.fromString(nodeConnectorStr);
+ if (nc == null) return false;
+ return true;
}
- public boolean isDstPortByName() {
- try {
- Short.parseShort(dstPort);
- } catch (Exception e) {
- return true;
+ public boolean isValid() {
+ if (name == null || srcNodeConnector == null || dstNodeConnector == null) {
+ return false;
}
- return false;
- }
- public static List<String> getGuiFieldsNames() {
- List<String> fieldList = new ArrayList<String>();
- for (String str : guiFields) {
- fieldList.add(str);
+ if (!isValidNodeConnector(srcNodeConnector) ||
+ !isValidNodeConnector(dstNodeConnector)) {
+ logger.warn("Invalid NodeConnector");
+ return false;
}
- return fieldList;
- }
- @Override
- public String toString() {
- return "ITopologyUserLinkConfig [status=" + status + ", name=" + name
- + ", srcNodeIDType=" + srcNodeIDType + ", srcSwitchId="
- + srcSwitchId + ", srcNodeConnectorIDType="
- + srcNodeConnectorIDType + ", srcPort=" + srcPort
- + ", dstNodeIDType=" + dstNodeIDType + ", dstId="
- + dstSwitchId + ", dstNodeConnectorIDType="
- + dstNodeConnectorIDType + ", dstPort=" + dstPort + "]";
+ return true;
}
@Override
public int hashCode() {
- return HashCodeBuilder.reflectionHashCode(this);
- }
-
- public boolean equals(Long srcNid, String srcPortName, Long dstNid,
- String dstPortName) {
- if (srcNid.equals(getSrcSwitchIDLong())
- && dstNid.equals(getDstSwitchIDLong())
- && srcPortName.equals(getSrcPort())
- && dstPortName.equals(getDstPort())) {
- return true;
- }
- return false;
+ final int prime = 31;
+ int result = 1;
+ result = prime
+ * result
+ + ((dstNodeConnector == null) ? 0 : dstNodeConnector.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime
+ * result
+ + ((srcNodeConnector == null) ? 0 : srcNodeConnector.hashCode());
+ return result;
}
@Override
if (getClass() != obj.getClass())
return false;
TopologyUserLinkConfig other = (TopologyUserLinkConfig) obj;
- if (dstPort == null) {
- if (other.dstPort != null)
+ if (dstNodeConnector == null) {
+ if (other.dstNodeConnector != null)
return false;
- } else if (!dstPort.equals(other.dstPort))
+ } else if (!dstNodeConnector.equals(other.dstNodeConnector))
return false;
- if (dstSwitchId == null) {
- if (other.dstSwitchId != null)
+ if (srcNodeConnector == null) {
+ if (other.srcNodeConnector != null)
return false;
- } else if (!dstSwitchId.equals(other.dstSwitchId))
- return false;
- if (srcPort == null) {
- if (other.srcPort != null)
- return false;
- } else if (!srcPort.equals(other.srcPort))
- return false;
- if (srcSwitchId == null) {
- if (other.srcSwitchId != null)
- return false;
- } else if (!srcSwitchId.equals(other.srcSwitchId))
+ } else if (!srcNodeConnector.equals(other.srcNodeConnector))
return false;
return true;
}
-}
+
+ @Override
+ public String toString() {
+ return "TopologyUserLinkConfig [status=" + status + ", name=" + name
+ + ", srcNodeConnector=" + srcNodeConnector
+ + ", dstNodeConnector=" + dstNodeConnector + "]";
+ }
+}
\ No newline at end of file
* topology database and notifies all the listeners of topology changes.
*/
public class TopologyManagerImpl implements ITopologyManager,
- IConfigurationContainerAware, IListenTopoUpdates, IObjectReader,
- CommandProvider {
+IConfigurationContainerAware, IListenTopoUpdates, IObjectReader,
+CommandProvider {
private static final Logger log = LoggerFactory
.getLogger(TopologyManagerImpl.class);
private ITopologyService topoService = null;
this.clusterContainerService.destroyCache("topologymanager.hostsDB");
this.hostsDB = null;
this.clusterContainerService
- .destroyCache("topologymanager.nodeConnectorDB");
+ .destroyCache("topologymanager.nodeConnectorDB");
this.nodeConnectorsDB = null;
log.debug("Topology Manager DB Deallocated");
}
private Edge getReverseLinkTuple(TopologyUserLinkConfig link) {
TopologyUserLinkConfig rLink = new TopologyUserLinkConfig(
- link.getName(), link.getDstNodeIDType(), link.getDstSwitchId(),
- link.getDstNodeConnectorIDType(), link.getDstPort(),
- link.getSrcNodeIDType(), link.getSrcSwitchId(),
- link.getSrcNodeConnectorIDType(), link.getSrcPort());
+ link.getName(), link.getDstNodeConnector(), link.getSrcNodeConnector());
return getLinkTuple(rLink);
}
+
private Edge getLinkTuple(TopologyUserLinkConfig link) {
Edge linkTuple = null;
-
- // if atleast 1 link exists for the srcPort and atleast 1 link exists
- // for the dstPort
- // that makes it ineligible for the Manual link addition
- // This is just an extra protection to avoid mis-programming.
- boolean srcLinkExists = false;
- boolean dstLinkExists = false;
- // TODO check a way to validate the port with inventory services
- // if (srcSw.getPorts().contains(srcPort) &&
- // dstSw.getPorts().contains(srcPort) &&
- if (!srcLinkExists && !dstLinkExists) {
- Node sNode = null;
- Node dNode = null;
- NodeConnector sPort = null;
- NodeConnector dPort = null;
- linkTuple = null;
- String srcNodeIDType = link.getSrcNodeIDType();
- String srcNodeConnectorIDType = link.getSrcNodeConnectorIDType();
- String dstNodeIDType = link.getDstNodeIDType();
- String dstNodeConnectorIDType = link.getDstNodeConnectorIDType();
- try {
- if (srcNodeIDType.equals(NodeIDType.OPENFLOW)) {
- sNode = new Node(srcNodeIDType, link.getSrcSwitchIDLong());
- } else {
- sNode = new Node(srcNodeIDType, link.getSrcSwitchId());
- }
-
- if (dstNodeIDType.equals(NodeIDType.OPENFLOW)) {
- dNode = new Node(dstNodeIDType, link.getDstSwitchIDLong());
- } else {
- dNode = new Node(dstNodeIDType, link.getDstSwitchId());
- }
-
- if (srcNodeConnectorIDType.equals(NodeConnectorIDType.OPENFLOW)) {
- Short srcPort = Short.valueOf((short) 0);
- if (!link.isSrcPortByName()) {
- srcPort = Short.parseShort(link.getSrcPort());
- }
- sPort = new NodeConnector(srcNodeConnectorIDType, srcPort,
- sNode);
- } else {
- sPort = new NodeConnector(srcNodeConnectorIDType,
- link.getSrcPort(), sNode);
- }
-
- if (dstNodeConnectorIDType.equals(NodeConnectorIDType.OPENFLOW)) {
- Short dstPort = Short.valueOf((short) 0);
- if (!link.isDstPortByName()) {
- dstPort = Short.parseShort(link.getDstPort());
- }
- dPort = new NodeConnector(dstNodeConnectorIDType, dstPort,
- dNode);
- } else {
- dPort = new NodeConnector(dstNodeConnectorIDType,
- link.getDstPort(), dNode);
- }
- linkTuple = new Edge(sPort, dPort);
- } catch (ConstructionException cex) {
- log.warn("Caught exception ", cex);
- }
- return linkTuple;
- }
-
- if (srcLinkExists && dstLinkExists) {
- link.setStatus(TopologyUserLinkConfig.STATUS.INCORRECT);
+ NodeConnector srcNodeConnector = NodeConnector.fromString(link.getSrcNodeConnector());
+ NodeConnector dstNodeConnector = NodeConnector.fromString(link.getDstNodeConnector());
+ if (srcNodeConnector == null || dstNodeConnector == null) return null;
+ try {
+ linkTuple = new Edge(srcNodeConnector, dstNodeConnector);
+ } catch (Exception e) {
}
- return null;
+ return linkTuple;
}
@Override
return;
}
- String nodeType1 = nc1.getNode().getType().toString();
- String nid1 = nc1.getNode().getID().toString();
- String ncType1 = nc1.getType().toString();
- String ncid1 = nc1.getID().toString();
-
- String nodeType2 = nc2.getNode().getType().toString();
- String nid2 = nc2.getNode().getID().toString();
- String ncType2 = nc2.getType().toString();
- String ncid2 = nc2.getID().toString();
-
- TopologyUserLinkConfig config = new TopologyUserLinkConfig(name,
- nodeType1, nid1, ncType1, ncid1, nodeType2, nid2, ncType2,
- ncid2);
+ TopologyUserLinkConfig config = new TopologyUserLinkConfig(name, ncStr1, ncStr2);
ci.println(this.addUserLink(config));
}
.equals(nodeId + 10))
|| (headNcId.equals(nodeId + 10) && tailNcId
.equals(nodeId))
- || (headNcId.equals(nodeId + 1) && tailNcId
- .equals(nodeId + 11))
- || (headNcId.equals(nodeId + 11) && tailNcId
- .equals(nodeId + 1)));
+ || (headNcId.equals(nodeId + 1) && tailNcId
+ .equals(nodeId + 11))
+ || (headNcId.equals(nodeId + 11) && tailNcId
+ .equals(nodeId + 1)));
} else if (nodeId == 11 || nodeId == 13 || nodeId == 15) {
Assert.assertTrue((headNcId.equals(nodeId) && tailNcId
.equals(nodeId - 10))
|| (headNcId.equals(nodeId) && tailNcId
.equals(nodeId - 10))
- || (headNcId.equals(nodeId - 9) && tailNcId
- .equals(nodeId + 1))
- || (headNcId.equals(nodeId + 1) && tailNcId
- .equals(nodeId - 9)));
+ || (headNcId.equals(nodeId - 9) && tailNcId
+ .equals(nodeId + 1))
+ || (headNcId.equals(nodeId + 1) && tailNcId
+ .equals(nodeId - 9)));
}
}
i.remove();
.equals(headNodeId + 10))
|| (headNcId.equals(headNodeId + 10) && tailNcId
.equals(headNodeId))
- || (headNcId.equals(headNodeId + 1) && tailNcId
- .equals(headNodeId + 11))
- || (headNcId.equals(headNodeId + 11) && tailNcId
- .equals(headNodeId + 1)));
+ || (headNcId.equals(headNodeId + 1) && tailNcId
+ .equals(headNodeId + 11))
+ || (headNcId.equals(headNodeId + 11) && tailNcId
+ .equals(headNodeId + 1)));
} else if (headNodeId == 11 || headNodeId == 13 || headNodeId == 15) {
Assert.assertTrue((headNcId.equals(headNodeId) && tailNcId
.equals(headNodeId - 10))
|| (headNcId.equals(headNodeId) && tailNcId
.equals(headNodeId - 10))
- || (headNcId.equals(headNodeId - 9) && tailNcId
- .equals(headNodeId + 1))
- || (headNcId.equals(headNodeId + 1) && tailNcId
- .equals(headNodeId - 9)));
+ || (headNcId.equals(headNodeId - 9) && tailNcId
+ .equals(headNodeId + 1))
+ || (headNcId.equals(headNodeId + 1) && tailNcId
+ .equals(headNodeId - 9)));
}
Set<Property> prop = entry.getValue();
@Test
public void testAddDeleteUserLink() {
TopologyUserLinkConfig link1 = new TopologyUserLinkConfig("default1",
- "OF", "1", "OF", "2", "OF", "1", "OF", "2");
+ "OF|1@OF|2", "OF|1@OF|2");
TopologyUserLinkConfig link2 = new TopologyUserLinkConfig("default1",
- "OF", "10", "OF", "20", "OF", "10", "OF", "20");
+ "OF|10@OF|20", "OF|10@OF|20");
TopologyUserLinkConfig link3 = new TopologyUserLinkConfig("default2",
- "OF", "1", "OF", "2", "OF", "1", "OF", "2");
+ "OF|1@OF|2", "OF|1@OF|2");
TopologyUserLinkConfig link4 = new TopologyUserLinkConfig("default20",
- "OF", "10", "OF", "20", "OF", "10", "OF", "20");
+ "OF|10@OF|20", "OF|10@OF|20");
TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
topoManagerImpl.nonClusterObjectCreate();
TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
topoManagerImpl.nonClusterObjectCreate();
- String name = null;
- String srcNodeIDType = null;
+ String name = "Test";
String srcSwitchId = null;
String srcNodeConnectorIDType = null;
String srcPort = null;
+ String srcNodeIDType = null;
String dstNodeIDType = null;
String dstSwitchId = null;
String dstNodeConnectorIDType = null;
String dstPort = null;
+ String srcNodeConnector = null;
+ String dstNodeConnector = null;
/* Creating userlinks and checking for their validity */
- link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId,
- srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId,
- dstNodeConnectorIDType, dstPort);
+ link[0] = new TopologyUserLinkConfig(name, srcNodeConnector, dstNodeConnector);
Assert.assertTrue(link[0].isValid() == false);
- srcSwitchId = "1";
- link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId,
- srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId,
- dstNodeConnectorIDType, dstPort);
+ srcNodeConnector = "OF|1@OF|1";
+ link[0] = new TopologyUserLinkConfig(name, srcNodeConnector, dstNodeConnector);
Assert.assertTrue(link[0].isValid() == false);
- dstSwitchId = "2";
- link[0] = new TopologyUserLinkConfig(name, srcNodeIDType, srcSwitchId,
- srcNodeConnectorIDType, srcPort, dstNodeIDType, dstSwitchId,
- dstNodeConnectorIDType, dstPort);
- Assert.assertTrue(link[0].isValid() == false);
+ dstNodeConnector = "OF|1@OF|2";
+ link[0] = new TopologyUserLinkConfig(name, srcNodeConnector, dstNodeConnector);
+ Assert.assertTrue(link[0].isValid() == true);
Integer i;
for (i = 0; i < 5; i++) {
- link[i] = new TopologyUserLinkConfig(name, srcNodeIDType,
- srcSwitchId, srcNodeConnectorIDType, srcPort,
- dstNodeIDType, dstSwitchId, dstNodeConnectorIDType, dstPort);
+ link[i] = new TopologyUserLinkConfig();
name = Integer.toString(i + 1);
srcSwitchId = Integer.toString(i + 1);
dstPort = Integer.toString((i + 1) * 10);
link[i].setName(name);
- link[i].setSrcSwitchId(srcSwitchId);
- link[i].setSrcPort(srcPort);
- link[i].setDstSwitchId(dstSwitchId);
- link[i].setDstPort(dstPort);
+ srcNodeConnectorIDType = dstNodeConnectorIDType = "INCORRECT";
+ srcNodeConnector = srcNodeConnectorIDType+"|"+srcSwitchId+"@"+srcNodeConnectorIDType+"|"+srcPort;
+ dstNodeConnector = dstNodeConnectorIDType+"|"+dstSwitchId+"@"+dstNodeConnectorIDType+"|"+dstPort;
+ link[i].setSrcNodeConnector(srcNodeConnector);
Assert.assertTrue(link[i].isValid() == false);
- link[i].setSrcNodeIDType("OF");
- link[i].setSrcNodeConnectorIDType("OF");
-
+ srcNodeConnectorIDType = "OF";
+ srcNodeConnector = srcNodeConnectorIDType+"|"+srcSwitchId+"@"+srcNodeConnectorIDType+"|"+srcPort;
+ link[i].setSrcNodeConnector(srcNodeConnector);
Assert.assertTrue(link[i].isValid() == false);
- link[i].setDstNodeIDType("OF");
- link[i].setDstNodeConnectorIDType("OF");
-
+ dstNodeConnectorIDType = "OF";
+ dstNodeConnector = dstNodeConnectorIDType+"|"+dstSwitchId+"@"+dstNodeConnectorIDType+"|"+dstPort;
+ link[i].setDstNodeConnector(dstNodeConnector);
Assert.assertTrue(link[i].isValid() == true);
- reverseLink[i] = new TopologyUserLinkConfig(name, dstNodeIDType,
- dstSwitchId, dstNodeConnectorIDType, dstPort,
- srcNodeIDType, srcSwitchId, srcNodeConnectorIDType, srcPort);
-
+ reverseLink[i] = new TopologyUserLinkConfig(name, dstNodeConnector, srcNodeConnector);
topoManagerImpl.addUserLink(link[i]);
}
+
ConcurrentMap<String, TopologyUserLinkConfig> userLinks = topoManagerImpl
.getUserLinks();
TopologyUserLinkConfig resultLink;
Assert.assertTrue(resultLink.getName().equals(
reverseLink[i].getName()));
- Assert.assertTrue(resultLink.getDstSwitchId().equals(
- reverseLink[i].getSrcSwitchId()));
- Assert.assertTrue(resultLink.getDstPort().equals(
- reverseLink[i].getSrcPort()));
- Assert.assertTrue(resultLink.getSrcSwitchId().equals(
- reverseLink[i].getDstSwitchId()));
- Assert.assertTrue(resultLink.getSrcPort().equals(
- reverseLink[i].getDstPort()));
+ Assert.assertTrue(resultLink.getDstNodeConnector().equals(
+ reverseLink[i].getSrcNodeConnector()));
+ Assert.assertTrue(resultLink.getSrcNodeConnector().equals(
+ reverseLink[i].getDstNodeConnector()));
}
}
@Test
public void testHostLinkMethods() throws ConstructionException,
- UnknownHostException {
+ UnknownHostException {
TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
topoManagerImpl.nonClusterObjectCreate();
int hostCounter = 0;
nc[i] = NodeConnectorCreator.createOFNodeConnector((short) (i + 1),
NodeCreator.createOFNode((long) (i + 1)));
topoManagerImpl
- .updateHostLink(nc[i], h[i], UpdateType.ADDED, props);
+ .updateHostLink(nc[i], h[i], UpdateType.ADDED, props);
}
for (int i = 0; i < 5; i++) {
/**
* Returns the list of roles associated to the passed user name
- *
+ *
* @param userName
* @return the role associated to the user name
*/
/**
* Authenticate user with AAA server and return authentication and
* authorization info
- *
+ *
* @param username
* the username
* @param password
/**
* Add/remove AAA server
- *
+ *
* @param configObject
* {@link org.opendaylight.controller.usermanager.internal.ServerConfig}
* Server Configuration
/**
* Remove AAA server
- *
+ *
* @param configObject
* refer to
* {@link org.opendaylight.controller.usermanager.internal.ServerConfig}
/**
* Add a local user
- *
+ *
* @param configObject
* {@link org.opendaylight.controller.usermanager.internal.UserConfig}
* User Configuration
/**
* Remove a local user
- *
+ *
* @param configObject
* {@link org.opendaylight.controller.usermanager.internal.UserConfig}
* UserConfig
/**
* Remove a local user
- *
+ *
* @param userName
* the user name
* @return {@link org.opendaylight.controller.sal.utils.Status}
/**
* Add the authorization information for a user that gets authenticated
* remotely
- *
+ *
* @param AAAconf
* {@link org.opendaylight.controller.usermanager.internal.AuthorizationConfig}
* Authorization Resources
/**
* Remove the authorization information for a user that gets authenticated
* remotely
- *
+ *
* @param AAAconf
* {@link org.opendaylight.controller.usermanager.internal.AuthorizationConfig}
* Authorization Resource
/**
* Return the list of authorization resources
- *
+ *
* @return {@link org.opendaylight.controller.usermanager.internal.AuthorizationConfig}
* List of Authorization Resource
*/
/**
* Returns a list of AAA Providers.
- *
+ *
* @return Set of provider names.
*/
public Set<String> getAAAProviderNames();
/**
* Change the current password for a locally configured user
- *
+ *
* @param user
* the username
* @param curPasssword
/**
* Return a list of AAA servers currently configured
- *
+ *
* @return {@link org.opendaylight.controller.usermanager.internal.ServerConfig}
* List of ServerConfig
*/
/**
* Return a list of local users
- *
+ *
* @return {@link org.opendaylight.controller.usermanager.internal.UserConfig}
* List of UserConfig
*/
/**
* Save the local users to disk
- *
+ *
* @return {@link org.opendaylight.controller.sal.utils.Status}
* status of this action
*/
/**
* Save the AAA server configurations to disk
- *
+ *
* @return {@link org.opendaylight.controller.sal.utils.Status}
* status of this action
*/
/**
* Save the Authorization configurations to disk
- *
+ *
* @return {@link org.opendaylight.controller.sal.utils.Status}
* status code
*/
/**
* Remove user profile when user logs out
- *
+ *
* @param username
* the user name
*/
/**
* Remove user profile when user times out
- *
+ *
* @param username
* the user name
*/
/**
* Get the list of users currently logged in
- *
+ *
* @return the list of users along with their administrative roles
*/
public Map<String, List<String>> getUserLoggedIn();
/**
* Get date and time user was successfully authenticated
- *
+ *
* @param user
* @return Date in String format
*/
public String getAccessDate(String user);
/**
- * Returns the user level for the passed user name. It checks the roles
+ * Returns the highest user level for the passed user name. It checks the roles
* assigned to this user and checks against the well known Controller user
* roles to determines the highest user level associated with the user
- *
+ *
* @param userName
* the user name
* @return {@link org.opendaylight.controller.sal.authorization.UserLevel}
*/
public UserLevel getUserLevel(String userName);
+ /**
+ * Returns the list of user level for the passed user name. It checks the roles
+ * assigned to this user and checks against the well known Controller user
+ * roles to determines the corresponding list of user level associated with the user
+ *
+ * @param userName
+ * the user name
+ * @return
+ * the list of user level for this user
+ */
+ public List<UserLevel> getUserLevels(String userName);
+
/**
* Returns the Security Context
- *
+ *
* @returns {@link org.springframework.security.web.context.SecurityContextRepository}
* Security Context
*/
/**
* Returns the Session Manager Interface Handler
- *
+ *
* @return {@link org.opendaylight.controller.usermanager.ISessionManager}
* session manager interface handler
*/
/* non-Javadoc
* Returns the password for a given user
- *
+ *
* @param username
* the user name
* @return password for the username
private ConcurrentMap<String, UserConfig> localUserConfigList;
private ConcurrentMap<String, ServerConfig> remoteServerConfigList;
// local authorization info for remotely authenticated users
- private ConcurrentMap<String, AuthorizationConfig> authorizationConfList;
+ private ConcurrentMap<String, AuthorizationConfig> authorizationConfList;
private ConcurrentMap<String, AuthenticatedUser> activeUsers;
private ConcurrentMap<String, IAAAProvider> authProviders;
private ConcurrentMap<Long, String> localUserListSaveConfigEvent,
- remoteServerSaveConfigEvent, authorizationSaveConfigEvent;
+ remoteServerSaveConfigEvent, authorizationSaveConfigEvent;
private IClusterGlobalServices clusterGlobalService = null;
private SecurityContextRepository securityContextRepo = new UserSecurityContextRepository();
private IContainerAuthorization containerAuthorizationClient;
return authProviders.get(name);
}
+ @Override
public Set<String> getAAAProviderNames() {
return authProviders.keySet();
}
} else if (rcResponse.getStatus() == AuthResultEnum.AUTH_REJECT) {
logger.info(
"Remote Authentication Rejected User: \"{}\", from Server: {}, Reason:{}",
- new Object[] {userName, aaaServer.getAddress(),
- rcResponse.getStatus().toString()});
+ new Object[] { userName, aaaServer.getAddress(),
+ rcResponse.getStatus().toString() });
} else {
logger.info(
"Remote Authentication Failed for User: \"{}\", from Server: {}, Reason:{}",
- new Object[] {userName, aaaServer.getAddress(),
- rcResponse.getStatus().toString()});
+ new Object[] { userName, aaaServer.getAddress(),
+ rcResponse.getStatus().toString() });
}
}
}
putUserInActiveList(userName, result);
if (authorized) {
logger.info("User \"{}\" authorized for the following role(s): {}",
- userName, result.getUserRoles());
+ userName, result.getUserRoles());
} else {
logger.info("User \"{}\" Not Authorized for any role ", userName);
}
activeUsers.remove(user);
}
+ @Override
public Status saveLocalUserList() {
// Publish the save config event to the cluster nodes
localUserListSaveConfigEvent.put(new Date().getTime(), SAVE);
localUserConfigList), usersFileName);
}
+ @Override
public Status saveAAAServerList() {
// Publish the save config event to the cluster nodes
remoteServerSaveConfigEvent.put(new Date().getTime(), SAVE);
remoteServerConfigList), serversFileName);
}
+ @Override
public Status saveAuthorizationList() {
// Publish the save config event to the cluster nodes
authorizationSaveConfigEvent.put(new Date().getTime(), SAVE);
return status;
}
// Trigger cluster update
- localUserConfigList.put(user, targetConfigEntry);
+ localUserConfigList.put(user, targetConfigEntry);
logger.info("Password changed for User \"{}\"", user);
String userName = ci.nextArgument();
String password = ci.nextArgument();
String role = ci.nextArgument();
-
+
List<String> roles = new ArrayList<String>();
while (role != null) {
if (!role.trim().isEmpty()) {
if (target == null) {
ci.println("User not found");
return;
- }
+ }
ci.println(this.removeLocalUser(target));
}
/**
* Function called by the dependency manager when all the required
* dependencies are satisfied
- *
+ *
*/
void init() {
}
* Function called by the dependency manager when at least one dependency
* become unsatisfied or when the component is shutting down because for
* example bundle is being stopped.
- *
+ *
*/
void destroy() {
}
/**
* Function called by dependency manager after "init ()" is called and after
* the services provided by the class are registered in the service registry
- *
+ *
*/
void start() {
authProviders = new ConcurrentHashMap<String, IAAAProvider>();
* Function called by the dependency manager before the services exported by
* the component are unregistered, this will be followed by a "destroy ()"
* calls
- *
+ *
*/
void stop() {
}
return UserLevel.NOUSER;
}
+
+ @Override
+ public List<UserLevel> getUserLevels(String username) {
+ // Returns the controller well-know user levels for the passed user
+ List<String> rolesNames = null;
+ List<UserLevel> levels = new ArrayList<UserLevel>();
+
+ if (activeUsers.containsKey(username)) {
+ List<String> roles = activeUsers.get(username).getUserRoles();
+ rolesNames = (roles == null || roles.isEmpty()) ? null : roles;
+ } else if (localUserConfigList.containsKey(username)) {
+ UserConfig config = localUserConfigList.get(username);
+ rolesNames = (config == null) ? null : config.getRoles();
+ }
+
+ if (rolesNames == null) {
+ return levels;
+ }
+
+ // Check against the well known controller roles first
+ if (rolesNames.contains(UserLevel.SYSTEMADMIN.toString())) {
+ levels.add(UserLevel.SYSTEMADMIN);
+ }
+ if (rolesNames.contains(UserLevel.NETWORKADMIN.toString())) {
+ levels.add(UserLevel.NETWORKADMIN);
+ }
+ if (rolesNames.contains(UserLevel.NETWORKOPERATOR.toString())) {
+ levels.add(UserLevel.NETWORKOPERATOR);
+ }
+ // Check if container user now
+ if (containerAuthorizationClient != null) {
+ for (String roleName : rolesNames) {
+ if (containerAuthorizationClient.isApplicationRole(roleName)) {
+ levels.add(UserLevel.CONTAINERUSER);
+ break;
+ }
+ }
+ }
+ // Finally check if application user
+ if (applicationAuthorizationClients != null) {
+ for (String roleName : rolesNames) {
+ for (IResourceAuthorization client : this.applicationAuthorizationClients) {
+ if (client.isApplicationRole(roleName)) {
+ levels.add(UserLevel.APPUSER);
+ break;
+ }
+ }
+ }
+ }
+ return levels;
+ }
+
@Override
public Status saveConfiguration() {
boolean success = true;
.getPassword(), enabled, accountNonExpired,
credentialsNonExpired, accountNonLocked,
user.getGrantedAuthorities(getUserLevel(username)));
- } else
+ } else {
throw new UsernameNotFoundException("User not found " + username);
+ }
}
@Override
.getName())));
return authentication;
- } else
+ } else {
throw new BadCredentialsException(
"Username or credentials did not match");
+ }
}
this.sessionMgr = sessionMgr;
}
+ @Override
public String getPassword(String username) {
return localUserConfigList.get(username).getPassword();
}