Migrate from adsal Node to mdsal Node 97/15997/3
authorSam Hague <shague@redhat.com>
Wed, 4 Mar 2015 00:41:13 +0000 (19:41 -0500)
committerSam Hague <shague@redhat.com>
Wed, 4 Mar 2015 13:21:40 +0000 (08:21 -0500)
This is a large commit becuase the sal Node is used all over the code. There is no way to build without doing it all in once shot.

Patch Set 2,3: No changes, just testing openstack integration. Something was broken in controller code causing failures. A rebuild this morning pulled in numerous new artifacts and cleared up the issue.

Change-Id: I9e53f61ad82dc0c6c1c447d9a7d4f2bcf11dbca0
Signed-off-by: Sam Hague <shague@redhat.com>
41 files changed:
commons/integrationtest/pom.xml
features/ovsdb/src/main/resources/features.xml
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/CompatOvsdbIntegrationTestBase.java [new file with mode: 0644]
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/ConfigurationBundles.java
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/OvsdbIntegrationTestBase.java
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/library/OvsdbLibraryIT.java
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/neutron/NeutronIT.java
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/northbound/OvsdbNorthboundV2IT.java
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/plugin/OvsdbPluginIT.java
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/plugin/OvsdbPluginV3CompatIT.java [new file with mode: 0644]
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/plugin/OvsdbPluginV3IT.java
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/schema/hardwarevtep/HardwareVTEPIT.java
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/schema/openvswitch/OpenVSwitchIT.java
northbound/pom.xml
northbound/src/main/java/org/opendaylight/ovsdb/northbound/NodeResource.java
northbound/src/main/java/org/opendaylight/ovsdb/northbound/OvsdbNorthboundV2.java
northbound/src/main/java/org/opendaylight/ovsdb/northbound/RowResource.java
northbound/src/test/java/org/opendaylight/ovsdb/northbound/NodeResourceTest.java
ovsdb-plugin-compatibility-layer/pom.xml
ovsdb-plugin-compatibility-layer/src/main/java/org/opendaylight/ovsdb/compatibility/plugin/api/NodeUtils.java [new file with mode: 0644]
ovsdb-plugin-compatibility-layer/src/main/java/org/opendaylight/ovsdb/compatibility/plugin/impl/ConfigurationServiceImpl.java
ovsdb-plugin-compatibility-layer/src/main/java/org/opendaylight/ovsdb/compatibility/plugin/impl/ConnectionServiceImpl.java
ovsdb-plugin-compatibility-layer/src/main/java/org/opendaylight/ovsdb/compatibility/plugin/impl/InventoryServiceImpl.java
ovsdb-plugin-compatibility-layer/src/main/java/org/opendaylight/ovsdb/compatibility/plugin/internal/Activator.java
ovsdb-plugin-compatibility-layer/src/test/java/org/opendaylight/ovsdb/compatibility/plugin/impl/ConnectionServiceImplTest.java [new file with mode: 0644]
ovsdb-plugin-compatibility-layer/src/test/java/org/opendaylight/ovsdb/compatibility/plugin/impl/NodeFactoryTest.java [deleted file]
plugin-shell/src/main/java/org/opendaylight/ovsdb/plugin/shell/PrintCache.java
plugin-shell/src/test/java/org/opendaylight/ovsdb/plugin/shell/PrintCacheTest.java
plugin/pom.xml
plugin/src/main/java/org/opendaylight/ovsdb/plugin/api/Connection.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/api/OvsdbConfigurationService.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/api/OvsdbConnectionService.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/api/OvsdbInventoryListener.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/api/OvsdbInventoryService.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/ConfigurationServiceImpl.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/ConnectionServiceImpl.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/InventoryServiceImpl.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/internal/Activator.java
plugin/src/test/java/org/opendaylight/ovsdb/plugin/impl/ConnectionServiceImplTest.java
plugin/src/test/java/org/opendaylight/ovsdb/plugin/impl/NodeFactoryTest.java [deleted file]
pom.xml

index ccaf699e93e48ee94b94cdc139f0e39c08228820..58cf3feab15c81598fe9e00313c6054fd06deb6c 100644 (file)
@@ -515,6 +515,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <artifactId>sal.implementation</artifactId>
       <version>${sal.implementation.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-binding-it</artifactId>
+      <version>${mdsal.version}</version>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>security</artifactId>
index b35bdb6bda4ee73ae4679f45e4fcea30da43f892..11b46225058ecb00f1c972da7f743fdfb7442dda 100644 (file)
@@ -33,6 +33,7 @@
 
     <feature name="odl-ovsdb-plugin" description="OpenDaylight :: OVSDB :: Plugin" version='${ovsdb.plugin.version}'>
         <feature version="${sal.version}">odl-adsal-all</feature>
+        <feature version="${openflowplugin.version}">odl-openflowplugin-nsf-services</feature>
         <feature version="${ovsdb.library.version}">odl-ovsdb-library</feature>
         <feature version="${schema.openvswitch.version}">odl-ovsdb-schema-openvswitch</feature>
         <feature version="${schema.hardwarevtep.version}">odl-ovsdb-schema-hardwarevtep</feature>
     <feature name="odl-ovsdb-northbound" description="OpenDaylight :: OVSDB :: Northbound" version='${ovsdb.northbound.version}'>
         <feature version="${ovsdb.plugin.version}">odl-ovsdb-plugin</feature>
         <feature version="${nsf.version}">odl-adsal-northbound</feature>
+        <feature version="${openflowplugin.version}">odl-openflowplugin-nsf-services</feature>
         <bundle>mvn:org.opendaylight.ovsdb/northbound/${ovsdb.northbound.version}</bundle>
     </feature>
 
     <feature name="odl-ovsdb-compatibility-layer" description="OpenDaylight :: OVSDB :: Plugin Compatibility Layer" version='${ovsdb.plugin.compatibility.layer.version}'>
+        <feature version="${openflowplugin.version}">odl-openflowplugin-nsf-services</feature>
         <feature version="${ovsdb.plugin.version}">odl-ovsdb-plugin</feature>
         <bundle>mvn:org.opendaylight.ovsdb/ovsdb-plugin-compatibility-layer/${ovsdb.plugin.compatibility.layer.version}</bundle>
     </feature>
diff --git a/integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/CompatOvsdbIntegrationTestBase.java b/integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/CompatOvsdbIntegrationTestBase.java
new file mode 100644 (file)
index 0000000..ac21fa7
--- /dev/null
@@ -0,0 +1,60 @@
+package org.opendaylight.ovsdb.integrationtest;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.utils.ServiceHelper;
+import org.opendaylight.ovsdb.plugin.api.ConnectionConstants;
+import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConnectionService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class CompatOvsdbIntegrationTestBase extends OvsdbIntegrationTestBase {
+    private static final Logger LOG = LoggerFactory.getLogger(OvsdbIntegrationTestBase.class);
+
+    public Node getCompatPluginTestConnection() throws IOException,
+            InterruptedException, ExecutionException, TimeoutException {
+        Properties props = loadProperties();
+        String addressStr = props.getProperty(SERVER_IPADDRESS);
+        String portStr = props.getProperty(SERVER_PORT, DEFAULT_SERVER_PORT);
+        String connectionType = props.getProperty(CONNECTION_TYPE, "active");
+        org.opendaylight.controller.sal.core.Node node = null;
+
+        OvsdbConnectionService connection = (OvsdbConnectionService)
+                ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
+        // If the connection type is active, controller connects to the ovsdb-server
+        if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_ACTIVE)) {
+            if (addressStr == null) {
+                fail(usage());
+            }
+
+            Map<ConnectionConstants, String> params = new HashMap<ConnectionConstants, String>();
+            params.put(ConnectionConstants.ADDRESS, addressStr);
+            params.put(ConnectionConstants.PORT, portStr);
+            node = connection.connect(IDENTIFIER, params);
+        }  else if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_PASSIVE)) {
+            // Wait for CONNECTION_INIT_TIMEOUT for the Passive connection to be initiated by the ovsdb-server.
+            Thread.sleep(CONNECTION_INIT_TIMEOUT);
+            List<Node> nodes = connection.getNodes();
+            assertNotNull(nodes);
+            assertTrue(nodes.size() > 0);
+            node = nodes.get(0);
+        }
+
+        if (node != null) {
+            LOG.info("getPluginTestConnection: Successfully connected to {}", node);
+        } else {
+            fail("Connection parameter (" + CONNECTION_TYPE + ") must be active or passive");
+        }
+        return node;
+    }
+}
index f4a1e189ccbd7d287a799b18b54a0d6065dca1f1..329edb14470204784f5145ca2b2a0b5422169c9f 100644 (file)
@@ -14,6 +14,7 @@ import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.systemPackages;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
+import org.opendaylight.controller.test.sal.binding.it.TestHelper;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.options.DefaultCompositeOption;
 
@@ -206,4 +207,14 @@ public class ConfigurationBundles {
         );
     }
 
+    public static Option mdsalBundles() {
+        return new DefaultCompositeOption(
+                //TestHelper.mdSalCoreBundles(),
+                //TestHelper.bindingAwareSalBundles(),
+                TestHelper.configMinumumBundles(),
+                TestHelper.baseModelBundles(),
+                TestHelper.flowCapableModelBundles(),
+                TestHelper.junitAndMockitoBundles()
+        );
+    }
 }
index df3000bd972e416a9bfb02c0a0edb16ce1b7d285..28718944797fbc5f120fd5e6a898cbc8034a9de3 100644 (file)
@@ -29,8 +29,8 @@ import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.lib.OvsdbConnection;
 import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
index 66f8d5dad2c24e056ca3f230bc310114a3ff8a1a..4d5ea56b1bba632f7a1e8ffb9acb5509fe962490 100644 (file)
@@ -15,7 +15,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
 import static org.opendaylight.ovsdb.lib.operations.Operations.op;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 import static org.ops4j.pax.exam.CoreOptions.options;
 import static org.ops4j.pax.exam.CoreOptions.propagateSystemProperty;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
@@ -75,10 +74,10 @@ public class OvsdbLibraryIT extends OvsdbIntegrationTestBase {
             propagateSystemProperty("ovsdbserver.ipaddress"),
             propagateSystemProperty("ovsdbserver.port"),
 
+            ConfigurationBundles.mdsalBundles(),
             ConfigurationBundles.controllerBundles(),
             ConfigurationBundles.ovsdbLibraryBundles(),
-            ConfigurationBundles.ovsdbDefaultSchemaBundles(),
-            junitBundles()
+            ConfigurationBundles.ovsdbDefaultSchemaBundles()
         );
     }
 
index b5908772b5b7fc18d7bb768ee48361c7735d1746..8ae8a716bf36faa6bda0d719ae3d90395ce442e4 100644 (file)
@@ -13,14 +13,13 @@ package org.opendaylight.ovsdb.integrationtest.neutron;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 import static org.ops4j.pax.exam.CoreOptions.options;
 import static org.ops4j.pax.exam.CoreOptions.propagateSystemProperty;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.neutron.spi.NeutronNetwork;
+import org.opendaylight.ovsdb.compatibility.plugin.api.NodeUtils;
 import org.opendaylight.ovsdb.integrationtest.ConfigurationBundles;
 import org.opendaylight.ovsdb.integrationtest.OvsdbIntegrationTestBase;
 import org.opendaylight.ovsdb.lib.notation.Row;
@@ -34,6 +33,7 @@ import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
 import org.opendaylight.ovsdb.schema.openvswitch.Interface;
 import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 
 import com.google.common.collect.ImmutableMap;
 
@@ -102,12 +102,12 @@ public class NeutronIT extends OvsdbIntegrationTestBase {
                 propagateSystemProperty("ovsdbserver.ipaddress"),
                 propagateSystemProperty("ovsdbserver.port"),
 
+                ConfigurationBundles.mdsalBundles(),
                 ConfigurationBundles.controllerBundles(),
                 ConfigurationBundles.ovsdbLibraryBundles(),
                 ConfigurationBundles.ovsdbDefaultSchemaBundles(),
                 ConfigurationBundles.ovsdbPluginBundles(),
-                ConfigurationBundles.ovsdbNeutronBundles(),
-                junitBundles()
+                ConfigurationBundles.ovsdbNeutronBundles()
         );
     }
 
@@ -156,7 +156,7 @@ public class NeutronIT extends OvsdbIntegrationTestBase {
         Thread.sleep(5000);
 
         // Create the integration bridge
-        bridgeConfigurationManager.prepareNode(node);
+        bridgeConfigurationManager.prepareNode(NodeUtils.getSalNode(node));
 
         Map<String, Row>
                 bridgeRows =
@@ -166,7 +166,8 @@ public class NeutronIT extends OvsdbIntegrationTestBase {
         Bridge bridgeRow = ovsdbConfigurationService.getTypedRow(node, Bridge.class, bridgeRows.values().iterator().next());
         Assert.assertEquals(netVirtConfigurationService.getIntegrationBridgeName(), bridgeRow.getName());
 
-        String uuid = bridgeConfigurationManager.getBridgeUuid(node, netVirtConfigurationService.getIntegrationBridgeName());
+        String uuid = bridgeConfigurationManager.getBridgeUuid(NodeUtils.getSalNode(node),
+                netVirtConfigurationService.getIntegrationBridgeName());
         Assert.assertEquals(uuid, bridgeRow.getUuid().toString());
 
         tearDownBridge = true;
@@ -184,7 +185,7 @@ public class NeutronIT extends OvsdbIntegrationTestBase {
                                                             OpenVSwitch.class,
                                                             ovsRows.values().iterator().next());
 
-        Assert.assertEquals(null, netVirtConfigurationService.getTunnelEndPoint(node));
+        Assert.assertEquals(null, netVirtConfigurationService.getTunnelEndPoint(NodeUtils.getSalNode(node)));
         final UUID originalVersion = ovsRow.getVersion();
 
         OpenVSwitch updateOvsRow = ovsdbConfigurationService.createTypedRow(node, OpenVSwitch.class);
@@ -203,11 +204,13 @@ public class NeutronIT extends OvsdbIntegrationTestBase {
                                                           ovsRow.getOtherConfigColumn().getData());
 
         // Make sure tunnel end point was set
-        Assert.assertEquals(InetAddress.getByName(endpointAddress), netVirtConfigurationService.getTunnelEndPoint(node));
+        Assert.assertEquals(InetAddress.getByName(endpointAddress),
+                netVirtConfigurationService.getTunnelEndPoint(NodeUtils.getSalNode(node)));
 
         // Fetch rows again, and compare tunnel end point values
         ovsRows = ovsdbConfigurationService.getRows(node,
-                                                    ovsdbConfigurationService.getTableName(node, OpenVSwitch.class));
+                                                    ovsdbConfigurationService.getTableName(node,
+                                                            OpenVSwitch.class));
         ovsRow = ovsdbConfigurationService.getTypedRow(node,
                                                        OpenVSwitch.class,
                                                        ovsRows.values().iterator().next());
@@ -224,14 +227,16 @@ public class NeutronIT extends OvsdbIntegrationTestBase {
 
         Version ovsVersion = this.getOvsVersion();
         if (ovsVersion.compareTo(Constants.OPENFLOW13_SUPPORTED) >= 0) {
-            Assert.assertEquals(Constants.OPENFLOW13, netVirtConfigurationService.getOpenflowVersion(node));
+            Assert.assertEquals(Constants.OPENFLOW13,
+                    netVirtConfigurationService.getOpenflowVersion(NodeUtils.getSalNode(node)));
         }
     }
 
     @Test
     public void testGetDefaultGatewayMacAddress() throws Exception {
         // Thread.sleep(5000);
-        String defaultGatewayMacAddress = netVirtConfigurationService.getDefaultGatewayMacAddress(node);
+        String defaultGatewayMacAddress = netVirtConfigurationService.
+                getDefaultGatewayMacAddress(NodeUtils.getSalNode(node));
 
         if (defaultGatewayMacAddress != null) {
             String[] splits = defaultGatewayMacAddress.split(":");
@@ -246,8 +251,8 @@ public class NeutronIT extends OvsdbIntegrationTestBase {
 
         if (tearDownBridge) {
             try {
-                String uuid = bridgeConfigurationManager.getBridgeUuid(node,
-                                                                       netVirtConfigurationService.getIntegrationBridgeName());
+                String uuid = bridgeConfigurationManager.getBridgeUuid(NodeUtils.getSalNode(node),
+                        netVirtConfigurationService.getIntegrationBridgeName());
                 ovsdbConfigurationService.deleteRow(node, ovsdbConfigurationService.getTableName(node, Bridge.class), uuid);
             } catch (Exception e) {
                 log.error("tearDownBridge Exception : " + e.getMessage());
@@ -306,23 +311,25 @@ public class NeutronIT extends OvsdbIntegrationTestBase {
         }
 
         @Override
-        public Status handleInterfaceUpdate(NeutronNetwork network, Node source, Interface intf) {
+        public Status handleInterfaceUpdate(NeutronNetwork network,
+                                            org.opendaylight.controller.sal.core.Node source, Interface intf) {
             return null;
         }
 
         @Override
-        public Status handleInterfaceDelete(String tunnelType, NeutronNetwork network, Node source, Interface intf,
+        public Status handleInterfaceDelete(String tunnelType, NeutronNetwork network,
+                                            org.opendaylight.controller.sal.core.Node source, Interface intf,
                                             boolean isLastInstanceOnNode) {
             return null;
         }
 
         @Override
-        public void initializeFlowRules(Node node) {
+        public void initializeFlowRules(org.opendaylight.controller.sal.core.Node node) {
 
         }
 
         @Override
-        public void initializeOFFlowRules(Node openflowNode) {
+        public void initializeOFFlowRules(org.opendaylight.controller.sal.core.Node openflowNode) {
 
         }
     }
index 29d01aecf8af6662ee900a7677d335b9b8b83b68..adbdbce5ce7733856b7b9cc8053fc4c02da4d7b2 100644 (file)
@@ -15,7 +15,6 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-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.propagateSystemProperty;
@@ -36,7 +35,7 @@ import org.junit.runners.Parameterized;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.usermanager.IUserManager;
 import org.opendaylight.ovsdb.integrationtest.ConfigurationBundles;
-import org.opendaylight.ovsdb.integrationtest.OvsdbIntegrationTestBase;
+import org.opendaylight.ovsdb.integrationtest.CompatOvsdbIntegrationTestBase;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExamParameterized;
@@ -60,7 +59,7 @@ import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
 
 @RunWith(PaxExamParameterized.class)
 @ExamReactorStrategy(PerClass.class)
-public class OvsdbNorthboundV2IT extends OvsdbIntegrationTestBase {
+public class OvsdbNorthboundV2IT extends CompatOvsdbIntegrationTestBase {
 
     private Logger log = LoggerFactory.getLogger(OvsdbNorthboundV2IT.class);
     public static final String USERNAME = "admin";
@@ -90,6 +89,7 @@ public class OvsdbNorthboundV2IT extends OvsdbIntegrationTestBase {
         for (Map<String, Object> o : object){
             Object[] l = o.values().toArray();
             parameters.add(l);
+            break;
         }
 
         return parameters;
@@ -245,7 +245,7 @@ public class OvsdbNorthboundV2IT extends OvsdbIntegrationTestBase {
         assertTrue(this.userManager != null);
 
         try {
-            node = getPluginTestConnection();
+            node = getCompatPluginTestConnection();
         } catch (Exception e) {
             fail("Exception : "+e.getMessage());
         }
@@ -272,13 +272,13 @@ public class OvsdbNorthboundV2IT extends OvsdbIntegrationTestBase {
                 propagateSystemProperty("ovsdbserver.ipaddress"),
                 propagateSystemProperty("ovsdbserver.port"),
 
+                ConfigurationBundles.mdsalBundles(),
                 ConfigurationBundles.controllerBundles(),
                 ConfigurationBundles.controllerNorthboundBundles(),
                 ConfigurationBundles.ovsdbLibraryBundles(),
                 ConfigurationBundles.ovsdbDefaultSchemaBundles(),
-                mavenBundle("org.opendaylight.ovsdb", "plugin").versionAsInProject(),
-                mavenBundle("org.opendaylight.ovsdb", "northbound").versionAsInProject(),
-                junitBundles()
+                ConfigurationBundles.ovsdbPluginBundles(),
+                mavenBundle("org.opendaylight.ovsdb", "northbound").versionAsInProject()
         );
     }
 }
index bb56ea881ce06365acc6b9d7b1cdb873084d5ef2..3bc3f92e019cec75d5eea4f1e0407fa98922768c 100644 (file)
@@ -21,7 +21,6 @@ import static org.ops4j.pax.exam.CoreOptions.propagateSystemProperty;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
 import org.junit.After;
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
 import org.opendaylight.ovsdb.integrationtest.ConfigurationBundles;
 import org.opendaylight.ovsdb.integrationtest.OvsdbIntegrationTestBase;
@@ -37,6 +36,8 @@ import org.opendaylight.ovsdb.plugin.api.Status;
 import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
 import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Sets;
@@ -47,6 +48,8 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
@@ -92,11 +95,11 @@ public class OvsdbPluginIT extends OvsdbIntegrationTestBase {
             propagateSystemProperty("ovsdbserver.ipaddress"),
             propagateSystemProperty("ovsdbserver.port"),
 
+            ConfigurationBundles.mdsalBundles(),
             ConfigurationBundles.controllerBundles(),
             ConfigurationBundles.ovsdbLibraryBundles(),
             ConfigurationBundles.ovsdbDefaultSchemaBundles(),
-            ConfigurationBundles.ovsdbPluginBundles(),
-            junitBundles()
+            ConfigurationBundles.ovsdbPluginBundles()
         );
     }
 
@@ -179,15 +182,20 @@ public class OvsdbPluginIT extends OvsdbIntegrationTestBase {
         componentB.setImplementation(listenerB);
         dm.add(componentB);
 
-        Node newNode = Node.fromString("OVS|10.10.10.10:65342");
+        NodeId nodeId = new NodeId("OVS|10.10.10.10:65342");
+        NodeKey nodeKey = new NodeKey(nodeId);
+        node = new NodeBuilder()
+                .setId(nodeId)
+                .setKey(nodeKey)
+                .build();
         InetAddress address = InetAddress.getByName("10.10.10.10");
         int port = 65342;
 
         // Trigger event
-        ovsdbInventoryService.notifyNodeAdded(newNode, address, port);
+        ovsdbInventoryService.notifyNodeAdded(node, address, port);
 
-        Mockito.verify(listenerA, Mockito.times(1)).nodeAdded(newNode, address, port);
-        Mockito.verify(listenerB, Mockito.times(1)).nodeAdded(newNode, address, port);
+        Mockito.verify(listenerA, Mockito.times(1)).nodeAdded(node, address, port);
+        Mockito.verify(listenerB, Mockito.times(1)).nodeAdded(node, address, port);
 
         dm.remove(componentA);
         dm.remove(componentB);
diff --git a/integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/plugin/OvsdbPluginV3CompatIT.java b/integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/plugin/OvsdbPluginV3CompatIT.java
new file mode 100644 (file)
index 0000000..af70d7b
--- /dev/null
@@ -0,0 +1,284 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Authors : Madhu Venugopal
+ */
+package org.opendaylight.ovsdb.integrationtest.plugin;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.propagateSystemProperty;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Sets;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.List;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
+import javax.inject.Inject;
+import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.opendaylight.controller.sal.core.ConstructionException;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.utils.ServiceHelper;
+import org.opendaylight.ovsdb.integrationtest.CompatOvsdbIntegrationTestBase;
+import org.opendaylight.ovsdb.integrationtest.ConfigurationBundles;
+import org.opendaylight.ovsdb.lib.OvsdbClient;
+import org.opendaylight.ovsdb.lib.OvsdbConnectionInfo;
+import org.opendaylight.ovsdb.lib.notation.Row;
+import org.opendaylight.ovsdb.lib.notation.UUID;
+import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
+import org.opendaylight.ovsdb.plugin.api.Connection;
+import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConfigurationService;
+import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConnectionService;
+import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbInventoryListener;
+import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbInventoryService;
+import org.opendaylight.controller.sal.utils.StatusCode;
+import org.opendaylight.ovsdb.compatibility.plugin.api.StatusWithUuid;
+import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
+import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerSuite;
+import org.ops4j.pax.exam.util.PathUtils;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerSuite.class)
+public class OvsdbPluginV3CompatIT extends CompatOvsdbIntegrationTestBase {
+    private Logger log = LoggerFactory.getLogger(OvsdbPluginV3CompatIT.class);
+    @Inject
+    private BundleContext bc;
+    private OvsdbConfigurationService ovsdbConfigurationService = null;
+    private String databaseName = "Open_vSwitch";
+
+    private Node node = null;
+    private OvsdbClient client = 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"),
+
+            propagateSystemProperty("ovsdbserver.ipaddress"),
+            propagateSystemProperty("ovsdbserver.port"),
+
+            ConfigurationBundles.mdsalBundles(),
+            ConfigurationBundles.controllerBundles(),
+            ConfigurationBundles.ovsdbLibraryBundles(),
+            ConfigurationBundles.ovsdbDefaultSchemaBundles(),
+            ConfigurationBundles.ovsdbPluginBundles()
+        );
+    }
+
+    @Before
+    public void setUp () throws ExecutionException, InterruptedException, IOException {
+        areWeReady(bc);
+    }
+
+    public void getConnection () throws InterruptedException {
+        try {
+            node = getCompatPluginTestConnection();
+        } catch (Exception e) {
+            fail("Exception : "+e.getMessage());
+        }
+        this.ovsdbConfigurationService = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class, this);
+    }
+
+    @Test
+    public void apiTests() throws Exception {
+        getConnection();
+        assertNotNull("Node should not be null", node);
+        assertNotNull("OvsdbConfigurationService should not be null", ovsdbConfigurationService);
+
+        Thread.sleep(1000);
+        OvsdbConnectionService
+                connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
+
+        // Check for the ovsdb Connection as seen by the Plugin layer
+        assertNotNull(connectionService.getNodes());
+        assertTrue(connectionService.getNodes().size() > 0);
+        Node node = connectionService.getNodes().get(0);
+        Connection connection = connectionService.getConnection(node);
+        OvsdbConnectionInfo connectionInfo = connection.getClient().getConnectionInfo();
+        String identifier = IDENTIFIER;
+        if (connectionInfo.getType().equals(OvsdbConnectionInfo.ConnectionType.PASSIVE)) {
+            identifier = connectionInfo.getRemoteAddress().getHostAddress()+":"+connectionInfo.getRemotePort();
+        }
+        assertEquals(node, connectionService.getNode("OVS|" + identifier));
+        log.info("Nodes = "+ connectionService.getNodes());
+        /*
+         * Test sequence :
+         * 1. Print Cache and Assert to make sure the bridge is not created yet.
+         * 2. Create a bridge with a valid parent_uuid & Assert to make sure the return status is success.
+         * 3. Assert to make sure the bridge is created with a valid Uuid.
+         * 4. Delete the bridge & Assert to make sure the return status is success.
+         * 5. Assert to make sure the bridge is deleted
+         */
+
+        this.endToEndApiTest(connection, getOpenVSwitchTableUUID(connection));
+    }
+
+    @Test
+    public void testInventoryListeners() throws UnknownHostException {
+        DependencyManager dm = new DependencyManager(bc);
+
+        OvsdbInventoryListener listenerA = Mockito.mock(FakeListener.class);
+        OvsdbInventoryListener listenerB = Mockito.mock(FakeListener.class);
+
+        Component componentA = dm.createComponent();
+        componentA.setInterface(OvsdbInventoryListener.class.getName(), null);
+        componentA.setImplementation(listenerA);
+        dm.add(componentA);
+
+        Component componentB = dm.createComponent();
+        componentB.setInterface(OvsdbInventoryListener.class.getName(), null);
+        componentB.setImplementation(listenerB);
+        dm.add(componentB);
+
+        try {
+            node = new Node("OVS", "10.10.10.10:65342");
+        } catch (ConstructionException e) {
+            log.error("Failed to allocate sal Node", e);
+        }
+        InetAddress address = InetAddress.getByName("10.10.10.10");
+        int port = 65342;
+
+        // Trigger event
+        OvsdbInventoryService
+               ovsdbInventoryService = (OvsdbInventoryService)ServiceHelper
+                .getGlobalInstance(OvsdbInventoryService.class, this);
+        ovsdbInventoryService.notifyNodeAdded(node, address, port);
+
+        Mockito.verify(listenerA, Mockito.times(1)).nodeAdded(node, address, port);
+        Mockito.verify(listenerB, Mockito.times(1)).nodeAdded(node, address, port);
+
+        dm.remove(componentA);
+        dm.remove(componentB);
+
+    }
+
+    public void endToEndApiTest(Connection connection, String parentUuid) throws Exception {
+        // 1. Print Cache and Assert to make sure the bridge is not created yet.
+        printCache();
+
+        // 2. Create a bridge with a valid parent_uuid & Assert to make sure the return status is success.
+        StatusWithUuid status = insertBridge(connection, parentUuid);
+        assertTrue(status.isSuccess());
+
+        // 3. Assert to make sure the bridge is created with a valid Uuid.
+        printCache();
+        Bridge bridge = connection.getClient().getTypedRowWrapper(Bridge.class, null);
+        Row bridgeRow = ovsdbConfigurationService.getRow(node, databaseName, bridge.getSchema().getName(), status.getUuid());
+        assertNotNull(bridgeRow);
+        bridge = connection.getClient().getTypedRowWrapper(Bridge.class, bridgeRow);
+        log.info("Bridge UUID "+bridge.getUuid()+" Status Uuid "+status.getUuid());
+        assertEquals(bridge.getUuid(), status.getUuid());
+
+        bridge = connection.getClient().createTypedRowWrapper(Bridge.class);
+        bridge.setDatapathType("netdev");
+        try {
+            ovsdbConfigurationService.updateRow(node, databaseName, bridge.getSchema().getName(), status.getUuid(), bridge.getRow(), false);
+        } catch (Exception e) {
+            fail("Failed to updated Bridge "+e.getMessage());
+        }
+
+        // 4. Delete the bridge & Assert to make sure the return status is success.
+        try {
+            ovsdbConfigurationService.deleteRow(node, databaseName, bridge.getSchema().getName(), null, new UUID(parentUuid) ,null, status.getUuid());
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+
+        // 5. Assert to make sure the bridge is deleted
+        bridgeRow = ovsdbConfigurationService.getRow(node, databaseName, bridge.getSchema().getName(), status.getUuid());
+        assertNull(bridgeRow);
+    }
+
+    public StatusWithUuid insertBridge(Connection connection, String parentUuid) throws Exception {
+        Bridge bridge = connection.getClient().createTypedRowWrapper(Bridge.class);
+        bridge.setName("br_test1");
+        bridge.setStatus(ImmutableMap.of("key", "value"));
+        bridge.setFloodVlans(Sets.newHashSet(34L));
+        try {
+        Row<GenericTableSchema> row = ovsdbConfigurationService.insertTree(node, databaseName, bridge.getSchema().getName(), new UUID(parentUuid), bridge.getRow());
+        bridge = connection.getClient().getTypedRowWrapper(Bridge.class, row);
+        return new StatusWithUuid(StatusCode.SUCCESS, bridge.getUuid());
+        } catch (Exception e) {
+            return new StatusWithUuid(StatusCode.INTERNALERROR);
+        }
+    }
+
+    public String getOpenVSwitchTableUUID(Connection connection) throws Exception {
+        OpenVSwitch openVSwitch = connection.getClient().getTypedRowWrapper(OpenVSwitch.class, null);
+        ConcurrentMap<UUID, Row<GenericTableSchema>> rows = ovsdbConfigurationService.getRows(node, databaseName, openVSwitch.getSchema().getName());
+        if (rows == null || rows.size() == 0) return null;
+        return rows.keySet().toArray()[0].toString();
+    }
+
+    public void printCache() throws Exception {
+        List<String> tables = ovsdbConfigurationService.getTables(node, databaseName);
+        log.info("Tables = "+tables);
+        assertNotNull(tables);
+        for (String table : tables) {
+            log.info("Table "+table);
+            ConcurrentMap<UUID, Row<GenericTableSchema>> rows = ovsdbConfigurationService.getRows(node, databaseName, table);
+            log.info(rows.toString());
+        }
+    }
+
+    public class FakeListener implements OvsdbInventoryListener {
+
+        @Override
+        public void nodeAdded(Node node, InetAddress address, int port) {
+
+        }
+
+        @Override
+        public void nodeRemoved(Node node) {
+
+        }
+
+        @Override
+        public void rowAdded(Node node, String tableName, String uuid, Row row) {
+
+        }
+
+        @Override
+        public void rowUpdated(Node node, String tableName, String uuid, Row old, Row row) {
+
+        }
+
+        @Override
+        public void rowRemoved(Node node, String tableName, String uuid, Row row, Object context) {
+
+        }
+    }
+
+}
index 4431268c40bcf741f550aa1cb0f72a81c7464bda..7c7b13bdda7d57563e0745dfa50415dcdebd8852 100644 (file)
@@ -14,7 +14,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 import static org.ops4j.pax.exam.CoreOptions.options;
 import static org.ops4j.pax.exam.CoreOptions.propagateSystemProperty;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
@@ -34,7 +33,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
 import org.opendaylight.ovsdb.integrationtest.ConfigurationBundles;
 import org.opendaylight.ovsdb.integrationtest.OvsdbIntegrationTestBase;
@@ -52,6 +50,10 @@ import org.opendaylight.ovsdb.plugin.api.StatusCode;
 import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
 import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
@@ -95,11 +97,11 @@ public class OvsdbPluginV3IT extends OvsdbIntegrationTestBase {
             propagateSystemProperty("ovsdbserver.ipaddress"),
             propagateSystemProperty("ovsdbserver.port"),
 
+            ConfigurationBundles.mdsalBundles(),
             ConfigurationBundles.controllerBundles(),
             ConfigurationBundles.ovsdbLibraryBundles(),
             ConfigurationBundles.ovsdbDefaultSchemaBundles(),
-            ConfigurationBundles.ovsdbPluginBundles(),
-            junitBundles()
+            ConfigurationBundles.ovsdbPluginBundles()
         );
     }
 
@@ -168,19 +170,24 @@ public class OvsdbPluginV3IT extends OvsdbIntegrationTestBase {
         componentB.setImplementation(listenerB);
         dm.add(componentB);
 
-        Node newNode = Node.fromString("OVS|10.10.10.10:65342");
+        NodeId nodeId = new NodeId("OVS|10.10.10.10:65342");
+        NodeKey nodeKey = new NodeKey(nodeId);
+        node = new NodeBuilder()
+                .setId(nodeId)
+                .setKey(nodeKey)
+                .build();
+
         InetAddress address = InetAddress.getByName("10.10.10.10");
         int port = 65342;
 
         // Trigger event
-        ovsdbInventoryService.notifyNodeAdded(newNode, address, port);
+        ovsdbInventoryService.notifyNodeAdded(node, address, port);
 
-        Mockito.verify(listenerA, Mockito.times(1)).nodeAdded(newNode, address, port);
-        Mockito.verify(listenerB, Mockito.times(1)).nodeAdded(newNode, address, port);
+        Mockito.verify(listenerA, Mockito.times(1)).nodeAdded(node, address, port);
+        Mockito.verify(listenerB, Mockito.times(1)).nodeAdded(node, address, port);
 
         dm.remove(componentA);
         dm.remove(componentB);
-
     }
 
     public void endToEndApiTest(Connection connection, String parentUuid) throws Exception {
index 202f92d37036b8fef4eb65119236cc781a409ec4..18e566bba4cb79593b02d142dbebdde3bebe4ccc 100644 (file)
@@ -109,10 +109,10 @@ public class HardwareVTEPIT  extends OvsdbIntegrationTestBase {
                 propagateSystemProperty("ovsdbserver.ipaddress"),
                 propagateSystemProperty("ovsdbserver.port"),
 
+                ConfigurationBundles.mdsalBundles(),
                 ConfigurationBundles.controllerBundles(),
                 ConfigurationBundles.ovsdbLibraryBundles(),
-                ConfigurationBundles.ovsdbDefaultSchemaBundles(),
-                junitBundles()
+                ConfigurationBundles.ovsdbDefaultSchemaBundles()
         );
     }
 
index 17f6e05361a99725270d123466f5af580747404c..e98074cc486b491dea69cdcb3f4f525a71c93813 100644 (file)
@@ -151,10 +151,10 @@ public class OpenVSwitchIT extends OvsdbIntegrationTestBase {
                 propagateSystemProperty("ovsdbserver.ipaddress"),
                 propagateSystemProperty("ovsdbserver.port"),
 
+                ConfigurationBundles.mdsalBundles(),
                 ConfigurationBundles.controllerBundles(),
                 ConfigurationBundles.ovsdbLibraryBundles(),
-                ConfigurationBundles.ovsdbDefaultSchemaBundles(),
-                junitBundles()
+                ConfigurationBundles.ovsdbDefaultSchemaBundles()
         );
     }
 
index 594fd4cc583d6dca8b105d1b157c291c4254e3da..91b51573ddab0e8f1d3a0bd49cf5427699658267 100644 (file)
@@ -83,6 +83,10 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+    </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
index 3cdf0f126d5fe6a455231cda71547ceb7b01e259..dff799e442c781a088eb0387d604b219ecf7be64 100644 (file)
@@ -18,11 +18,11 @@ import javax.ws.rs.core.Response;
 import org.opendaylight.controller.northbound.commons.RestMessages;
 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
 import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
 import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.plugin.api.Connection;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.DeserializationFeature;
index 9cba35579eeb35154a6fd54cd25bda21eaef80f5..fa25baf9241ab7a86e522f1ed50a92fdbeddbc7d 100644 (file)
@@ -37,7 +37,6 @@ import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailab
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
 import org.opendaylight.ovsdb.plugin.api.Status;
 import org.opendaylight.ovsdb.lib.OvsdbClient;
@@ -48,6 +47,7 @@ import org.opendaylight.ovsdb.plugin.api.OvsVswitchdSchemaConstants;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
 import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index 038a0b597a17e4a1fe8c38e868ef5e8c2d2b849a..c6c1ae397f5865981c06c964f060542a5132b107 100644 (file)
@@ -21,7 +21,6 @@ import javax.ws.rs.core.Response;
 import org.opendaylight.controller.northbound.commons.RestMessages;
 import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
 import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
 import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.lib.notation.Row;
@@ -29,6 +28,7 @@ import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
 import org.opendaylight.ovsdb.plugin.api.OvsVswitchdSchemaConstants;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.DeserializationFeature;
index 159c9d25329ee4d40e28230b2ad900a83aa80642..9c98e78bfa0fded71ef7e9338afd0c7ee93c41f5 100644 (file)
@@ -20,12 +20,11 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
 import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
 import org.opendaylight.ovsdb.plugin.api.Connection;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
 import org.opendaylight.ovsdb.plugin.impl.ConnectionServiceImpl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.powermock.api.mockito.PowerMockito;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
@@ -40,8 +39,6 @@ public class NodeResourceTest {
 
     @Test
     public void testGetOvsdbNode () {
-        Node.NodeIDType.registerIDType(OVS, String.class);
-        NodeConnector.NodeConnectorIDType.registerIDType(OVS, String.class, OVS);
         ConnectionServiceImpl connectionService = new ConnectionServiceImpl();
         Connection connection = new Connection(IDENTIFIER, null);
         connectionService.putOvsdbConnection(IDENTIFIER, connection);
@@ -73,8 +70,6 @@ public class NodeResourceTest {
 
     @Test
     public void testGetOvsdbConnection () {
-        Node.NodeIDType.registerIDType(OVS, String.class);
-        NodeConnector.NodeConnectorIDType.registerIDType(OVS, String.class, OVS);
         ConnectionServiceImpl connectionService = new ConnectionServiceImpl();
         Connection connection = new Connection(IDENTIFIER, null);
         connectionService.putOvsdbConnection(IDENTIFIER, connection);
index 5debf86328d1bd51c8de7efc812442b1970aac82..32d625fd77662b11f84a45a015b3f7e1f4e3f8ee 100755 (executable)
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.powermock</groupId>
+      <artifactId>powermock-module-junit4</artifactId>
+      <version>1.5.4</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
diff --git a/ovsdb-plugin-compatibility-layer/src/main/java/org/opendaylight/ovsdb/compatibility/plugin/api/NodeUtils.java b/ovsdb-plugin-compatibility-layer/src/main/java/org/opendaylight/ovsdb/compatibility/plugin/api/NodeUtils.java
new file mode 100644 (file)
index 0000000..0e28de8
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2015 Red Hat, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Authors : Sam Hague
+ */
+package org.opendaylight.ovsdb.compatibility.plugin.api;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.controller.sal.core.ConstructionException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NodeUtils {
+    protected static final Logger LOG = LoggerFactory.getLogger(NodeUtils.class);
+
+    public static String getId (String identifier) {
+        String id = identifier;
+
+        String[] pair = identifier.split("\\|");
+        if (pair[0].equals("OVS")) {
+            id = pair[1];
+        }
+        return id;
+    }
+
+    public static Node getMdsalNode (org.opendaylight.controller.sal.core.Node salNode) {
+        String identifier = salNode.getNodeIDString();
+
+        NodeId nodeId = new NodeId("OVS" + "|" + identifier);
+        NodeKey nodeKey = new NodeKey(nodeId);
+        Node node = new NodeBuilder()
+                .setId(nodeId)
+                .setKey(nodeKey)
+                .build();
+
+        return node;
+    }
+
+    public static org.opendaylight.controller.sal.core.Node getSalNode (Node mdsalNode) {
+        String identifier = NodeUtils.getId(mdsalNode.getId().getValue());
+        org.opendaylight.controller.sal.core.Node node = null;
+
+        try {
+            node = new org.opendaylight.controller.sal.core.Node("OVS", identifier);
+        } catch (ConstructionException e) {
+            LOG.error("Failed to allocate sal Node", e);
+        }
+
+        return node;
+    }
+
+    public static List<org.opendaylight.controller.sal.core.Node> getSalNodes (List<Node> mdsalNodes) {
+        List<org.opendaylight.controller.sal.core.Node> nodes = new ArrayList<>();
+
+        for (Node mdsalNode : mdsalNodes) {
+            nodes.add(NodeUtils.getSalNode(mdsalNode));
+        }
+        return nodes;
+    }
+}
index 5137fcd1fdb2c3ec0c5ecf81b78f9532d0c4a000..628e6798d16862110f22efd4ce8aed3540d3d5e6 100644 (file)
@@ -13,6 +13,7 @@ import java.util.concurrent.ExecutionException;
 
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.ovsdb.compatibility.plugin.api.NodeUtils;
 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConfigurationService;
 import org.opendaylight.ovsdb.compatibility.plugin.api.StatusWithUuid;
 import org.opendaylight.ovsdb.compatibility.plugin.error.OvsdbPluginException;
@@ -31,7 +32,7 @@ import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
  */
 public class ConfigurationServiceImpl implements OvsdbConfigurationService
 {
-    org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService pluginOvsdbConfigurationService;
+    private volatile org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService pluginOvsdbConfigurationService;
 
     void init() {
     }
@@ -74,59 +75,64 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
 
     @Override
     public StatusWithUuid insertRow(Node node, String tableName, String parentUuid, Row<GenericTableSchema> row) {
-       return StatusConvertorUtil.convertOvsdbStatusWithUuidToCompLayerStatusWithUuid(pluginOvsdbConfigurationService.insertRow(node, tableName, parentUuid, row));
+        return StatusConvertorUtil.convertOvsdbStatusWithUuidToCompLayerStatusWithUuid(pluginOvsdbConfigurationService.insertRow(NodeUtils.getMdsalNode(node), tableName, parentUuid, row));
     }
 
     @Override
     public Status updateRow (Node node, String tableName, String parentUUID, String rowUUID, Row row) {
-       return StatusConvertorUtil.convertOvsdbStatusToSalStatus(pluginOvsdbConfigurationService.updateRow(node, tableName, parentUUID, rowUUID, row));
+        return StatusConvertorUtil
+                .convertOvsdbStatusToSalStatus(pluginOvsdbConfigurationService
+                        .updateRow(NodeUtils.getMdsalNode(node), tableName, parentUUID, rowUUID, row));
     }
 
     @Override
     public Status deleteRow(Node node, String tableName, String uuid) {
-       return StatusConvertorUtil.convertOvsdbStatusToSalStatus(pluginOvsdbConfigurationService.deleteRow(node, tableName, uuid));
+        return StatusConvertorUtil
+                .convertOvsdbStatusToSalStatus(pluginOvsdbConfigurationService.
+                        deleteRow(NodeUtils.getMdsalNode(node), tableName, uuid));
     }
 
     @Override
     public ConcurrentMap<String, Row> getRows(Node node, String tableName) {
-        return pluginOvsdbConfigurationService.getRows(node, tableName);
+        return pluginOvsdbConfigurationService.getRows(NodeUtils.getMdsalNode(node), tableName);
     }
 
     @Override
     public Row getRow(Node node, String tableName, String uuid) {
-        return pluginOvsdbConfigurationService.getRow(node, tableName, uuid);
+        return pluginOvsdbConfigurationService.getRow(NodeUtils.getMdsalNode(node), tableName, uuid);
     }
 
     @Override
     public List<String> getTables(Node node) {
-        return pluginOvsdbConfigurationService.getTables(node);
+        return pluginOvsdbConfigurationService.getTables(NodeUtils.getMdsalNode(node));
     }
 
     @Override
     public Boolean setOFController(Node node, String bridgeUUID) throws InterruptedException, ExecutionException {
-       return pluginOvsdbConfigurationService.setOFController(node, bridgeUUID);
+        return pluginOvsdbConfigurationService.setOFController(NodeUtils.getMdsalNode(node), bridgeUUID);
     }
 
     @Override
     public <T extends TypedBaseTable<?>> String getTableName(Node node, Class<T> typedClass) {
-       return pluginOvsdbConfigurationService.getTableName(node, typedClass);
+        return pluginOvsdbConfigurationService.getTableName(NodeUtils.getMdsalNode(node), typedClass);
     }
 
     @Override
     public <T extends TypedBaseTable<?>> T getTypedRow(Node node, Class<T> typedClass, Row row) {
-       return pluginOvsdbConfigurationService.getTypedRow(node, typedClass, row);
+        return pluginOvsdbConfigurationService.getTypedRow(NodeUtils.getMdsalNode(node), typedClass, row);
     }
 
     @Override
     public <T extends TypedBaseTable<?>> T createTypedRow(Node node, Class<T> typedClass) {
-       return pluginOvsdbConfigurationService.createTypedRow(node, typedClass);
+        return pluginOvsdbConfigurationService.createTypedRow(NodeUtils.getMdsalNode(node), typedClass);
     }
 
     @Override
     public UUID insertRow(Node node, String databaseName, String tableName, String parentTable, UUID parentUuid,
                           String parentColumn, Row<GenericTableSchema> row) throws OvsdbPluginException {
-       return pluginOvsdbConfigurationService.insertRow(node, databaseName, tableName, parentTable, parentUuid,
-                parentColumn, row);
+        return pluginOvsdbConfigurationService
+                .insertRow(NodeUtils.getMdsalNode(node), databaseName, tableName, parentTable, parentUuid,
+                        parentColumn, row);
     }
 
     @Override
@@ -139,7 +145,9 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
     @Override
     public Row<GenericTableSchema> insertTree(Node node, String databaseName, String tableName, String parentTable, UUID parentUuid,
                                               String parentColumn, Row<GenericTableSchema> row) throws OvsdbPluginException {
-        return pluginOvsdbConfigurationService.insertTree(node, databaseName, tableName, parentTable, parentUuid, parentColumn, row);
+        return pluginOvsdbConfigurationService
+                .insertTree(NodeUtils.getMdsalNode(node), databaseName, tableName, parentTable,
+                        parentUuid, parentColumn, row);
     }
 
     @Override
@@ -153,13 +161,16 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
     public Row<GenericTableSchema> updateRow(Node node, String databaseName,
             String tableName, UUID rowUuid, Row<GenericTableSchema> row,
             boolean overwrite) throws OvsdbPluginException {
-        return pluginOvsdbConfigurationService.updateRow(node, databaseName, tableName, rowUuid, row, overwrite);
+        return pluginOvsdbConfigurationService
+                .updateRow(NodeUtils.getMdsalNode(node), databaseName, tableName, rowUuid, row, overwrite);
     }
 
     @Override
     public void deleteRow(Node node, String databaseName, String tableName, String parentTable, UUID parentRowUuid,
             String parentColumn, UUID rowUuid) throws OvsdbPluginException {
-        pluginOvsdbConfigurationService.deleteRow(node, databaseName, tableName, parentTable, parentRowUuid, parentColumn, rowUuid);
+        pluginOvsdbConfigurationService
+                .deleteRow(NodeUtils.getMdsalNode(node), databaseName, tableName, parentTable,
+                        parentRowUuid, parentColumn, rowUuid);
     }
 
     @Override
@@ -170,13 +181,15 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
     @Override
     public Row<GenericTableSchema> getRow(Node node, String databaseName,
             String tableName, UUID uuid) throws OvsdbPluginException {
-        return pluginOvsdbConfigurationService.getRow(node, databaseName, tableName, uuid);
+        return pluginOvsdbConfigurationService
+                .getRow(NodeUtils.getMdsalNode(node), databaseName, tableName, uuid);
     }
 
     @Override
     public ConcurrentMap<UUID, Row<GenericTableSchema>> getRows(Node node,
             String databaseName, String tableName) throws OvsdbPluginException {
-        return pluginOvsdbConfigurationService.getRows(node, databaseName, tableName);
+        return pluginOvsdbConfigurationService
+                .getRows(NodeUtils.getMdsalNode(node), databaseName, tableName);
     }
 
     @Override
@@ -188,6 +201,6 @@ public class ConfigurationServiceImpl implements OvsdbConfigurationService
 
     @Override
     public List<String> getTables(Node node, String databaseName) throws OvsdbPluginException {
-        return pluginOvsdbConfigurationService.getTables(node, databaseName);
+        return pluginOvsdbConfigurationService.getTables(NodeUtils.getMdsalNode(node), databaseName);
     }
 }
index 25fb245a1442fed2a12258fb7bfdc07d846c489d..db6daa05d260bc37d009de2ae03f7552c596a068 100644 (file)
@@ -11,6 +11,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.ovsdb.compatibility.plugin.api.NodeUtils;
 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConnectionService;
 import org.opendaylight.ovsdb.plugin.api.Connection;
 import org.opendaylight.ovsdb.plugin.api.ConnectionConstants;
@@ -28,7 +29,7 @@ import org.slf4j.LoggerFactory;
 public class ConnectionServiceImpl implements OvsdbConnectionService{
     protected static final Logger logger = LoggerFactory.getLogger(ConnectionServiceImpl.class);
 
-    org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService pluginOvsdbConnectionService;
+    private volatile org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService pluginOvsdbConnectionService;
 
     public void init() {
     }
@@ -66,22 +67,22 @@ public class ConnectionServiceImpl implements OvsdbConnectionService{
     }
     @Override
     public Connection getConnection(Node node) {
-        return pluginOvsdbConnectionService.getConnection(node);
+        return pluginOvsdbConnectionService.getConnection(NodeUtils.getMdsalNode(node));
     }
 
     @Override
     public Node getNode (String identifier) {
-        return pluginOvsdbConnectionService.getNode(identifier);
+        return NodeUtils.getSalNode(pluginOvsdbConnectionService.getNode(identifier));
     }
 
     @Override
     public List<Node> getNodes() {
-        return pluginOvsdbConnectionService.getNodes();
+        return NodeUtils.getSalNodes(pluginOvsdbConnectionService.getNodes());
     }
 
     @Override
     public Node connect(String identifier, Map<ConnectionConstants, String> params) {
-        return pluginOvsdbConnectionService.connect(identifier, params);
+        return NodeUtils.getSalNode(pluginOvsdbConnectionService.connect(identifier, params));
     }
 
 }
index e5413c23650b110f5cacdd6f580fe9c2326b266f..5e7e7d8d3ca021667b77066910c4fdadf45edb09 100644 (file)
@@ -14,6 +14,7 @@ import java.util.concurrent.ConcurrentMap;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
+import org.opendaylight.ovsdb.compatibility.plugin.api.NodeUtils;
 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbInventoryListener;
 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbInventoryService;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
@@ -31,8 +32,9 @@ import com.google.common.collect.Sets;
  * @author Anil Vishnoi (vishnoianil@gmail.com)
  *
  */
-public class InventoryServiceImpl implements OvsdbInventoryService, org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener {
-    org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService pluginOvsdbInventoryService;
+public class InventoryServiceImpl implements OvsdbInventoryService,
+        org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener {
+    private volatile org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService pluginOvsdbInventoryService;
 
     private Set<OvsdbInventoryListener> ovsdbInventoryListeners = Sets.newCopyOnWriteArraySet();
 
@@ -91,94 +93,98 @@ public class InventoryServiceImpl implements OvsdbInventoryService, org.opendayl
 
     @Override
     public ConcurrentMap<String, ConcurrentMap<String, Row>> getCache(Node n, String databaseName) {
-        return pluginOvsdbInventoryService.getCache(n, databaseName);
+        return pluginOvsdbInventoryService.getCache(NodeUtils.getMdsalNode(n), databaseName);
     }
 
 
     @Override
     public ConcurrentMap<String, Row> getTableCache(Node n, String databaseName, String tableName) {
-        return pluginOvsdbInventoryService.getTableCache(n, databaseName, tableName);
+        return pluginOvsdbInventoryService.getTableCache(NodeUtils.getMdsalNode(n), databaseName, tableName);
     }
 
 
     @Override
     public Row getRow(Node n, String databaseName, String tableName, String uuid) {
-        return pluginOvsdbInventoryService.getRow(n, databaseName, tableName, uuid);
+        return pluginOvsdbInventoryService.getRow(NodeUtils.getMdsalNode(n), databaseName, tableName, uuid);
     }
 
     @Override
     public void updateRow(Node n, String databaseName, String tableName, String uuid, Row row) {
-        pluginOvsdbInventoryService.updateRow(n, databaseName, tableName, uuid, row);
+        pluginOvsdbInventoryService.updateRow(NodeUtils.getMdsalNode(n), databaseName, tableName, uuid, row);
     }
 
     @Override
     public void removeRow(Node n, String databaseName, String tableName, String uuid) {
-        pluginOvsdbInventoryService.removeRow(n, databaseName, tableName, uuid);
+        pluginOvsdbInventoryService.removeRow(NodeUtils.getMdsalNode(n), databaseName, tableName, uuid);
     }
 
     @Override
     public void processTableUpdates(Node n, String databaseName, TableUpdates tableUpdates) {
-        pluginOvsdbInventoryService.processTableUpdates(n, databaseName, tableUpdates);
+        pluginOvsdbInventoryService.processTableUpdates(NodeUtils.getMdsalNode(n), databaseName, tableUpdates);
     }
 
     @Override
     public void printCache(Node n) {
-        pluginOvsdbInventoryService.printCache(n);
+        pluginOvsdbInventoryService.printCache(NodeUtils.getMdsalNode(n));
     }
 
     @Override
     public void addNode(Node node, Set<Property> props) {
-        pluginOvsdbInventoryService.addNode(node, props);
+        pluginOvsdbInventoryService.addNode(NodeUtils.getMdsalNode(node), props);
     }
 
     @Override
     public void notifyNodeAdded(Node node, InetAddress address, int port) {
-        pluginOvsdbInventoryService.notifyNodeAdded(node, address, port);
+        pluginOvsdbInventoryService.notifyNodeAdded(NodeUtils.getMdsalNode(node), address, port);
     }
 
     @Override
     public void addNodeProperty(Node node, UpdateType type, Set<Property> props) {
-        pluginOvsdbInventoryService.addNodeProperty(node, type, props);
+        pluginOvsdbInventoryService.addNodeProperty(NodeUtils.getMdsalNode(node), type, props);
     }
 
     @Override
     public void removeNode(Node node) {
-        pluginOvsdbInventoryService.removeNode(node);
+        pluginOvsdbInventoryService.removeNode(NodeUtils.getMdsalNode(node));
     }
 
     @Override
-    public void nodeAdded(Node node, InetAddress address, int port) {
+    public void nodeAdded(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node node,
+                          InetAddress address, int port) {
         for(OvsdbInventoryListener listener : this.ovsdbInventoryListeners)
-            listener.nodeAdded(node, address, port);
+            listener.nodeAdded(NodeUtils.getSalNode(node), address, port);
 
     }
 
     @Override
-    public void nodeRemoved(Node node) {
+    public void nodeRemoved(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node node) {
         for(OvsdbInventoryListener listener : this.ovsdbInventoryListeners)
-            listener.nodeRemoved(node);
+            listener.nodeRemoved(NodeUtils.getSalNode(node));
 
     }
 
     @Override
-    public void rowAdded(Node node, String tableName, String uuid, Row row) {
+    public void rowAdded(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node node,
+                         String tableName, String uuid, Row row) {
         for(OvsdbInventoryListener listener : this.ovsdbInventoryListeners)
-            listener.rowAdded(node, tableName, uuid, row);
+            listener.rowAdded(NodeUtils.getSalNode(node), tableName, uuid, row);
 
     }
 
     @Override
-    public void rowUpdated(Node node, String tableName, String uuid, Row old,
+    public void rowUpdated(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node node,
+                           String tableName, String uuid, Row old,
             Row row) {
         for(OvsdbInventoryListener listener : this.ovsdbInventoryListeners)
-            listener.rowUpdated(node, tableName, uuid, old, row);
+            listener.rowUpdated(NodeUtils.getSalNode(node), tableName, uuid, old, row);
 
     }
 
     @Override
-    public void rowRemoved(Node node, String tableName, String uuid, Row row,
+    public void rowRemoved(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node node,
+                           String tableName, String uuid, Row row,
             Object context) {
         for(OvsdbInventoryListener listener : this.ovsdbInventoryListeners)
-            listener.rowRemoved(node, tableName, uuid, row, context);
+            listener.rowRemoved(NodeUtils.getSalNode(node), tableName, uuid, row, context);
     }
 }
index 68df6cb08ef8c068d49dc94c2eaa5f1226a94bfc..70a01e6269f6ed84d3c1f3e5cd9439bab9e1fc81 100644 (file)
@@ -12,6 +12,7 @@ import java.util.Hashtable;
 
 import org.apache.felix.dm.Component;
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
+import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConfigurationService;
 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConnectionService;
 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbInventoryListener;
@@ -39,6 +40,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      */
     @Override
     public void init() {
+        Node.NodeIDType.registerIDType("OVS", String.class);
     }
 
     /**
@@ -48,6 +50,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      */
     @Override
     public void destroy() {
+        Node.NodeIDType.unRegisterIDType("OVS");
     }
     @Override
     public Object[] getGlobalImplementations() {
diff --git a/ovsdb-plugin-compatibility-layer/src/test/java/org/opendaylight/ovsdb/compatibility/plugin/impl/ConnectionServiceImplTest.java b/ovsdb-plugin-compatibility-layer/src/test/java/org/opendaylight/ovsdb/compatibility/plugin/impl/ConnectionServiceImplTest.java
new file mode 100644 (file)
index 0000000..694d6b3
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ *  Copyright (C) 2015 Red Hat, Inc.
+ *
+ *  This program and the accompanying materials are made available under the
+ *  terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ *  and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ *  Authors : Sam Hague
+ */
+package org.opendaylight.ovsdb.compatibility.plugin.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.sal.core.ConstructionException;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.ovsdb.plugin.api.Connection;
+
+public class ConnectionServiceImplTest {
+    private static final String OVS = "OVS";
+    private static final String IDENTIFIER = "192.168.120.31:45001";
+    private static final String OVS_IDENTIFIER = OVS + "|" + IDENTIFIER;
+    private static final String BAD_IDENTIFIER = "BAD" + "|" + IDENTIFIER;
+    private static org.opendaylight.ovsdb.plugin.impl.ConnectionServiceImpl pluginConnectionService;
+    private static ConnectionServiceImpl connectionService;
+
+    @BeforeClass
+    public static void setUp () {
+        Node.NodeIDType.registerIDType(OVS, String.class);
+        NodeConnector.NodeConnectorIDType.registerIDType(OVS, String.class, OVS);
+        pluginConnectionService = new org.opendaylight.ovsdb.plugin.impl.ConnectionServiceImpl();
+        Connection connection = new Connection(IDENTIFIER, null);
+        pluginConnectionService.putOvsdbConnection(IDENTIFIER, connection);
+
+        connectionService = new ConnectionServiceImpl();
+        connectionService.setOvsdbConnectionService(pluginConnectionService);
+    }
+
+    @Test
+    public void testGetNode () {
+        Node node = connectionService.getNode(IDENTIFIER);
+        assertNotNull("Node " + IDENTIFIER + " is null", node);
+
+        node = connectionService.getNode(OVS_IDENTIFIER);
+        assertNotNull("Node " + OVS_IDENTIFIER + " is null", node);
+
+        try {
+            node = connectionService.getNode(BAD_IDENTIFIER);
+            fail("Expected a NullPointerException to be thrown");
+        } catch (NullPointerException e) {
+            assertSame(NullPointerException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void testGetConnection () {
+        Node node = connectionService.getNode(IDENTIFIER);
+        assertNotNull("Node " + IDENTIFIER + " is null", node);
+
+        Connection connection = connectionService.getConnection(node);
+        assertNotNull("Connection " + IDENTIFIER + " is null", connection);
+
+        try {
+            connection = connectionService.getConnection(null);
+            fail("Expected a NullPointerException to be thrown");
+        } catch (NullPointerException e) {
+            assertSame(NullPointerException.class, e.getClass());
+        }
+
+        try {
+            node = new Node("OVS", BAD_IDENTIFIER);
+        } catch (ConstructionException e) {
+            fail("Exception should not have occurred" + e);
+        }
+        connection = connectionService.getConnection(node);
+        assertNull("Connection " + BAD_IDENTIFIER + " is not null", connection);
+    }
+}
diff --git a/ovsdb-plugin-compatibility-layer/src/test/java/org/opendaylight/ovsdb/compatibility/plugin/impl/NodeFactoryTest.java b/ovsdb-plugin-compatibility-layer/src/test/java/org/opendaylight/ovsdb/compatibility/plugin/impl/NodeFactoryTest.java
deleted file mode 100644 (file)
index d4855e5..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- *  Copyright (C) 2014 Red Hat, Inc.
- *
- *  This program and the accompanying materials are made available under the
- *  terms of the Eclipse Public License v1.0 which accompanies this distribution,
- *  and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- *  Authors : Sam Hague
- */
-package org.opendaylight.ovsdb.compatibility.plugin.impl;
-
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-
-public class NodeFactoryTest {
-
-    @Test
-    public void testFromString () {
-        assertTrue(true);
-    }
-}
index 9dc951db5fc0eac913ce9c041ff449eed4e2530f..420f016c426876d58efd0644dfea31c23b4b145e 100644 (file)
@@ -12,8 +12,11 @@ package org.opendaylight.ovsdb.plugin.shell;
 import org.apache.felix.gogo.commands.Argument;
 import org.apache.felix.gogo.commands.Command;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 
 @Command(scope = "ovs", name = "printCache", description="Prints OVSDB Cache")
 public class PrintCache extends OsgiCommandSupport{
@@ -24,7 +27,12 @@ public class PrintCache extends OsgiCommandSupport{
 
     @Override
     protected Object doExecute() throws Exception {
-        Node node = Node.fromString(nodeName);
+        NodeId nodeId = new NodeId(nodeName);
+        NodeKey nodeKey = new NodeKey(nodeId);
+        Node node = new NodeBuilder()
+                .setId(nodeId)
+                .setKey(nodeKey)
+                .build();
         ovsdbInventory.printCache(node);
         return null;
     }
index 7629a24b052effebddbab31af855bd2ef2240519..0e34a6e1704b8e58c3e8ab93a17c7d694f13e0bf 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.ovsdb.plugin.shell;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.when;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -20,10 +19,7 @@ import java.io.InputStream;
 import java.io.PrintStream;
 import java.lang.reflect.Field;
 import java.util.Set;
-import org.junit.runner.RunWith;
 import org.junit.Test;
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.ovsdb.lib.notation.Column;
 import org.opendaylight.ovsdb.lib.notation.Row;
 import org.opendaylight.ovsdb.lib.notation.UUID;
@@ -33,14 +29,13 @@ import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
 import org.opendaylight.ovsdb.plugin.api.OvsVswitchdSchemaConstants;
 import org.opendaylight.ovsdb.plugin.impl.InventoryServiceImpl;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(Node.class)
 public class PrintCacheTest {
-    private static final String NODESTRING = "OVS:10.10.10.10:65342";
+    private static final String NODESTRING = "OVS|10.10.10.10:65342";
     private static final String BRIDGES = "bridges";
     private static final String OVS = "OVS";
     private static final String BRIDGE = "bridge1";
@@ -61,13 +56,6 @@ public class PrintCacheTest {
         assertNotNull(schema);
         assertEquals(Version.fromString("6.12.0"), schema.getVersion());
 
-        // mock a node since PrintCache requires a Node
-        Node.NodeIDType.registerIDType(OVS, String.class);
-        NodeConnector.NodeConnectorIDType.registerIDType(OVS, String.class, OVS);
-        Node node = new Node(OVS, "1");
-        PowerMockito.mockStatic(Node.class);
-        when(Node.fromString(NODESTRING)).thenReturn(node);
-
         // Add params to PrintCache
         PrintCache printCacheTest = new PrintCache();
         Field cNField = printCacheTest.getClass().getDeclaredField("nodeName");
@@ -91,6 +79,13 @@ public class PrintCacheTest {
         Column column = new Column(bridges, new UUID(BRIDGE).toString());
         Row row = new Row(ovsTable);
         row.addColumn(BRIDGES, column);
+
+        NodeId nodeId = new NodeId(NODESTRING);
+        NodeKey nodeKey = new NodeKey(nodeId);
+        Node node = new NodeBuilder()
+                .setId(nodeId)
+                .setKey(nodeKey)
+                .build();
         inventoryService.updateRow(node, OvsVswitchdSchemaConstants.DATABASE_NAME, OPENVSWITCH, new UUID("1").toString(), row);
 
         // Test that a populated cache is printed correctly
index ea28686db277bb4a55edea67355e7db1a53c70fe..1a533e3a70aa76bb194f931f2ac048ebcd5acd5b 100755 (executable)
@@ -69,10 +69,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <artifactId>utils.config</artifactId>
       <version>${ovsdb.utils.config.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller.model</groupId>
+      <artifactId>model-inventory</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+    </dependency>
   </dependencies>
 
   <build>
index 1dc1e8f1ee73deb660ea9e5bff3d45daebbf597a..c7091a61106d5764fd91f5acc166b30527033c01 100644 (file)
@@ -9,9 +9,12 @@
  */
 package org.opendaylight.ovsdb.plugin.api;
 
-import org.opendaylight.controller.sal.core.ConstructionException;
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.ovsdb.lib.OvsdbClient;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -33,17 +36,17 @@ public class Connection {
     private static final Logger logger = LoggerFactory.getLogger(Connection.class);
 
     public Connection(String identifier, OvsdbClient client) {
-
         super();
 
         this.identifier = identifier;
         this.client = client;
         this.idCounter = 0L;
-        try {
-            node = new Node("OVS", identifier);
-        } catch (ConstructionException e) {
-            logger.error("Error creating OVS node with identifier " + identifier, e);
-        }
+        NodeId nodeId = new NodeId("OVS" + "|" + identifier);
+        NodeKey nodeKey = new NodeKey(nodeId);
+        node = new NodeBuilder()
+                .setId(nodeId)
+                .setKey(nodeKey)
+                .build();
     }
 
     public String getIdentifier() {
index a2293934121edab476d5148b75fecd8bbe0aa929..ff63d5cd111af585e51c7216eded6e305eb89277 100644 (file)
@@ -13,13 +13,12 @@ import java.util.List;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutionException;
 
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.ovsdb.plugin.api.Status;
 import org.opendaylight.ovsdb.lib.notation.Row;
 import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
 import org.opendaylight.ovsdb.plugin.error.OvsdbPluginException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 
 public interface OvsdbConfigurationService {
 
index 4270cea0e69f5fcfc0c58de8e03d72efb95a3fb6..9b2d17f7ceec97519b2ee91d631ab80e606b2ec1 100644 (file)
@@ -12,7 +12,7 @@ package org.opendaylight.ovsdb.plugin.api;
 import java.util.List;
 import java.util.Map;
 
-import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 
 public interface OvsdbConnectionService {
     public Connection getConnection(Node node);
index cf61202d9bc7758eb8ba21039a024bbd602450e9..3461ede74c523daa4cd3434f16b55c99a071c068 100644 (file)
@@ -9,8 +9,8 @@
  */
 package org.opendaylight.ovsdb.plugin.api;
 
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.ovsdb.lib.notation.Row;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 
 import java.net.InetAddress;
 
index 5d4d3d2035480870894cfa85abebf6d2325e26f5..11fb684202447cd0fc0a76ac2f9e786cf9f79bcf 100644 (file)
@@ -13,11 +13,11 @@ import java.net.InetAddress;
 import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
 
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.notation.Row;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 
 public interface OvsdbInventoryService {
     public ConcurrentMap<String, ConcurrentMap<String, Row>> getCache(Node n, String databaseName);
index 276d013d62764a245fb1debf3e6f519124d7baaa..9bb2ab250ec8ce7eef4c3315e544fe7814cc85f7 100644 (file)
@@ -22,7 +22,6 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutionException;
 
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.ovsdb.plugin.api.Status;
 import org.opendaylight.ovsdb.plugin.api.StatusCode;
 import org.opendaylight.ovsdb.lib.OvsdbClient;
@@ -55,6 +54,7 @@ import org.opendaylight.ovsdb.schema.openvswitch.Controller;
 import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
 import org.opendaylight.ovsdb.schema.openvswitch.Port;
 import org.opendaylight.ovsdb.utils.config.ConfigProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index deddb2b9669a1a7c51619b219627b26dc2880ce4..a2d8403769e6f379f25b56f1df86d382ac055f14 100644 (file)
@@ -23,7 +23,6 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutionException;
 
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.ovsdb.lib.MonitorCallBack;
 import org.opendaylight.ovsdb.lib.OvsdbClient;
@@ -46,6 +45,7 @@ import org.opendaylight.ovsdb.plugin.internal.L4PortProperty;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService;
 import org.opendaylight.ovsdb.utils.config.ConfigProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -130,10 +130,9 @@ public class ConnectionServiceImpl implements OvsdbConnectionService,
     }
 
     public Status disconnect(Node node) {
-        String identifier = (String) node.getID();
-        Connection connection = ovsdbConnections.get(identifier);
+        Connection connection = getConnection(node);
         if (connection != null) {
-            ovsdbConnections.remove(identifier);
+            ovsdbConnections.remove(normalizeId(node.getId().getValue()));
             connection.disconnect();
             ovsdbInventoryService.removeNode(node);
             return new Status(StatusCode.SUCCESS);
@@ -179,14 +178,7 @@ public class ConnectionServiceImpl implements OvsdbConnectionService,
         this.handlers = handlers;
     }
 
-    @Override
-    public Connection getConnection(Node node) {
-        String identifier = (String) node.getID();
-        return ovsdbConnections.get(identifier);
-    }
-
-    @Override
-    public Node getNode (String identifier) {
+    private String normalizeId (String identifier) {
         String id = identifier;
 
         String[] pair = identifier.split("\\|");
@@ -194,7 +186,17 @@ public class ConnectionServiceImpl implements OvsdbConnectionService,
             id = pair[1];
         }
 
-        Connection connection = ovsdbConnections.get(id);
+        return id;
+    }
+
+    @Override
+    public Connection getConnection(Node node) {
+        return ovsdbConnections.get(normalizeId(node.getId().getValue()));
+    }
+
+    @Override
+    public Node getNode (String identifier) {
+        Connection connection = ovsdbConnections.get(normalizeId(identifier));
         if (connection != null) {
             return connection.getNode();
         } else {
@@ -276,8 +278,7 @@ public class ConnectionServiceImpl implements OvsdbConnectionService,
     }
 
     public TableUpdates monitorTables(Node node, DatabaseSchema dbSchema) throws ExecutionException, InterruptedException, IOException {
-        String identifier = (String) node.getID();
-        Connection connection = ovsdbConnections.get(identifier);
+        Connection connection = getConnection(node);
         OvsdbClient client = connection.getClient();
         if (dbSchema == null) {
             logger.error("Unable to get Database Schema for the ovsdb connection : {}", client.getConnectionInfo());
index 3693e167da3ca1c73e61e42008580fee10c8ad0b..b5f6d2ea8c8840c587aa9b36863b97087486cb05 100644 (file)
@@ -19,8 +19,6 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 import org.opendaylight.ovsdb.lib.message.TableUpdate;
@@ -32,6 +30,7 @@ import org.opendaylight.ovsdb.plugin.api.OvsVswitchdSchemaConstants;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 
 import com.google.common.collect.Sets;
 import org.slf4j.Logger;
index fd208b14375e86a71bac88e0abda550d94b4355d..4f0212852d8e0edc1df67a8204cd5dcfb21bb0a5 100644 (file)
@@ -11,8 +11,6 @@ package org.opendaylight.ovsdb.plugin.internal;
 
 import org.apache.felix.dm.DependencyActivatorBase;
 import org.apache.felix.dm.DependencyManager;
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.ovsdb.lib.OvsdbConnection;
 import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
@@ -38,9 +36,6 @@ public class Activator extends DependencyActivatorBase {
 
     @Override
     public void init(BundleContext context, DependencyManager manager) throws Exception {
-        Node.NodeIDType.registerIDType("OVS", String.class);
-        NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
-
         manager.add(createComponent()
                         .setInterface(OvsdbConfigurationService.class.getName(), null)
                         .setImplementation(ConfigurationServiceImpl.class)
@@ -77,7 +72,5 @@ public class Activator extends DependencyActivatorBase {
 
     @Override
     public void destroy(BundleContext context, DependencyManager manager) throws Exception {
-        Node.NodeIDType.unRegisterIDType("OVS");
-        NodeConnector.NodeConnectorIDType.unRegisterIDType("OVS");
     }
 }
index 815a06824c24c53a6fa5ed5cbd17f2ce3d769be1..ed46c3ffdec3d303fb9d88bcae5fb547f0c75cfc 100644 (file)
@@ -11,10 +11,12 @@ package org.opendaylight.ovsdb.plugin.impl;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
 
+import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.ovsdb.plugin.api.Connection;
 
 public class ConnectionServiceImplTest {
@@ -22,15 +24,17 @@ public class ConnectionServiceImplTest {
     private static final String IDENTIFIER = "192.168.120.31:45001";
     private static final String OVS_IDENTIFIER = OVS + "|" + IDENTIFIER;
     private static final String BAD_IDENTIFIER = "BAD" + "|" + IDENTIFIER;
+    private static ConnectionServiceImpl connectionService;
 
-    @Test
-    public void testGetNode () {
-        Node.NodeIDType.registerIDType(OVS, String.class);
-        NodeConnector.NodeConnectorIDType.registerIDType(OVS, String.class, OVS);
-        ConnectionServiceImpl connectionService = new ConnectionServiceImpl();
+    @BeforeClass
+    public static void setUp () {
+        connectionService = new ConnectionServiceImpl();
         Connection connection = new Connection(IDENTIFIER, null);
         connectionService.putOvsdbConnection(IDENTIFIER, connection);
+    }
 
+    @Test
+    public void testGetNode () {
         Node node = connectionService.getNode(IDENTIFIER);
         assertNotNull("Node " + IDENTIFIER + " is null", node);
 
@@ -40,4 +44,20 @@ public class ConnectionServiceImplTest {
         node = connectionService.getNode(IDENTIFIER + "extra");
         assertNull("Node " + BAD_IDENTIFIER + " is not null", node);
     }
+
+    @Test
+    public void testGetConnection () {
+        Node node = connectionService.getNode(IDENTIFIER);
+        assertNotNull("Node " + IDENTIFIER + " is null", node);
+
+        Connection connection = connectionService.getConnection(node);
+        assertNotNull("Connection " + IDENTIFIER + " is null", connection);
+
+        try {
+            connection = connectionService.getConnection(null);
+            fail("Expected a NullPointerException to be thrown");
+        } catch (NullPointerException e) {
+            assertSame(NullPointerException.class, e.getClass());
+        }
+    }
 }
diff --git a/plugin/src/test/java/org/opendaylight/ovsdb/plugin/impl/NodeFactoryTest.java b/plugin/src/test/java/org/opendaylight/ovsdb/plugin/impl/NodeFactoryTest.java
deleted file mode 100644 (file)
index 10761d5..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- *  Copyright (C) 2014 Red Hat, Inc.
- *
- *  This program and the accompanying materials are made available under the
- *  terms of the Eclipse Public License v1.0 which accompanies this distribution,
- *  and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- *  Authors : Sam Hague
- */
-package org.opendaylight.ovsdb.plugin.impl;
-
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-
-public class NodeFactoryTest {
-
-    @Test
-    public void testFromString () {
-        assertTrue(true);
-    }
-}
diff --git a/pom.xml b/pom.xml
index 7df618cd639b95aa41759ffc619324d43809d69b..9b4ee9cf1fbd58cfe245afd2b73f77563cef6e80 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -42,7 +42,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <module>plugin</module>
     <module>ovsdb-plugin-compatibility-layer</module>
     <module>plugin-shell</module>
-    <module>plugin-mdsal-adapter</module>
     <module>schemas/hardwarevtep</module>
     <module>schemas/openvswitch</module>
     <module>southbound</module>