Use SouthboundUtils in SouthboundIT 83/30983/2
authorStephen Kitt <skitt@redhat.com>
Tue, 8 Dec 2015 08:08:17 +0000 (09:08 +0100)
committerStephen Kitt <skitt@redhat.com>
Tue, 8 Dec 2015 16:55:41 +0000 (17:55 +0100)
Change-Id: I2fd8466e650df77af031f75cfa36a04275847124
Signed-off-by: Stephen Kitt <skitt@redhat.com>
southbound/southbound-features/pom.xml
southbound/southbound-features/src/main/features/features.xml
southbound/southbound-it/pom.xml
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/MdsalUtils.java [deleted file]
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundIT.java
utils/southbound-utils/src/main/java/org/opendaylight/ovsdb/utils/southbound/utils/SouthboundUtils.java

index bd899a50236ac17a9fc10e8eb77fef2f253d179b..a101bfe36c7a48bbcf9160fa316115a7cdc00d71 100644 (file)
@@ -119,6 +119,16 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <artifactId>southbound-api</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>utils.southbound-utils</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>utils.mdsal-utils</artifactId>
+      <version>${project.version}</version>
+    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>library-features</artifactId>
index 7e2b90b81b2e6e89d3e652aaa9d5c7f09b816abb..0fbba27f2d06675e04500b8b70751d4d691384cb 100644 (file)
@@ -48,4 +48,9 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <feature version="${restconf.version}">odl-mdsal-apidocs</feature>
     <feature version="${mdsal.version}">odl-mdsal-xsql</feature>
   </feature>
+  <feature name='odl-ovsdb-southbound-test' version='${project.version}' description='OpenDaylight :: southbound :: test'>
+    <feature version="${project.version}">odl-ovsdb-southbound-impl</feature>
+    <bundle>mvn:org.opendaylight.ovsdb/utils.mdsal-utils/{{VERSION}}</bundle>
+    <bundle>mvn:org.opendaylight.ovsdb/utils.southbound-utils/{{VERSION}}</bundle>
+  </feature>
 </features>
index 0192b015003a4003a8bac0d66ab96bddd2b98ec2..47ad4b3a7b15d3ce12263bf83472dcdf6d01c84d 100644 (file)
@@ -84,6 +84,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>config-util</artifactId>
     </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>utils.southbound-utils</artifactId>
+      <version>${project.version}</version>
+    </dependency>
     <!-- Dependencies for pax exam karaf container -->
     <dependency>
       <groupId>org.ops4j.pax.exam</groupId>
diff --git a/southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/MdsalUtils.java b/southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/MdsalUtils.java
deleted file mode 100644 (file)
index 8aa7b61..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2015 Red Hat, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.ovsdb.southbound.it;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Utility class for mdsal transactions.
- *
- * @author Sam Hague (shague@redhat.com)
- */
-public class MdsalUtils {
-    private static final Logger LOG = LoggerFactory.getLogger(MdsalUtils.class);
-    private DataBroker databroker = null;
-
-    /**
-     * Class constructor setting the data broker.
-     *
-     * @param dataBroker the {@link DataBroker}
-     */
-    public MdsalUtils(DataBroker dataBroker) {
-        this.databroker = dataBroker;
-    }
-
-    /**
-     * Executes delete as a blocking transaction.
-     *
-     * @param store {@link LogicalDatastoreType} which should be modified
-     * @param path {@link InstanceIdentifier} to read from
-     * @param <D> the data object type
-     * @return the result of the request
-     */
-    public <D extends org.opendaylight.yangtools.yang.binding.DataObject> boolean delete(
-            final LogicalDatastoreType store, final InstanceIdentifier<D> path)  {
-        boolean result = false;
-        final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
-        transaction.delete(store, path);
-        CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
-        try {
-            future.checkedGet();
-            result = true;
-        } catch (TransactionCommitFailedException e) {
-            LOG.warn("Failed to delete {} ", path, e);
-        }
-        return result;
-    }
-
-    /**
-     * Executes merge as a blocking transaction.
-     *
-     * @param logicalDatastoreType {@link LogicalDatastoreType} which should be modified
-     * @param path {@link InstanceIdentifier} for path to read
-     * @param <D> the data object type
-     * @return the result of the request
-     */
-    public <D extends org.opendaylight.yangtools.yang.binding.DataObject> boolean merge(
-            final LogicalDatastoreType logicalDatastoreType, final InstanceIdentifier<D> path, D data)  {
-        boolean result = false;
-        final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
-        transaction.merge(logicalDatastoreType, path, data, true);
-        CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
-        try {
-            future.checkedGet();
-            result = true;
-        } catch (TransactionCommitFailedException e) {
-            LOG.warn("Failed to merge {} ", path, e);
-        }
-        return result;
-    }
-
-    /**
-     * Executes put as a blocking transaction.
-     *
-     * @param logicalDatastoreType {@link LogicalDatastoreType} which should be modified
-     * @param path {@link InstanceIdentifier} for path to read
-     * @param <D> the data object type
-     * @return the result of the request
-     */
-    public <D extends org.opendaylight.yangtools.yang.binding.DataObject> boolean put(
-            final LogicalDatastoreType logicalDatastoreType, final InstanceIdentifier<D> path, D data)  {
-        boolean result = false;
-        final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
-        transaction.put(logicalDatastoreType, path, data, true);
-        CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
-        try {
-            future.checkedGet();
-            result = true;
-        } catch (TransactionCommitFailedException e) {
-            LOG.warn("Failed to put {} ", path, e);
-        }
-        return result;
-    }
-
-    /**
-     * Executes read as a blocking transaction.
-     *
-     * @param store {@link LogicalDatastoreType} to read
-     * @param path {@link InstanceIdentifier} for path to read
-     * @param <D> the data object type
-     * @return the result as the data object requested
-     */
-    public <D extends org.opendaylight.yangtools.yang.binding.DataObject> D read(
-            final LogicalDatastoreType store, final InstanceIdentifier<D> path)  {
-        D result = null;
-        final ReadOnlyTransaction transaction = databroker.newReadOnlyTransaction();
-        Optional<D> optionalDataObject;
-        CheckedFuture<Optional<D>, ReadFailedException> future = transaction.read(store, path);
-        try {
-            optionalDataObject = future.checkedGet();
-            if (optionalDataObject.isPresent()) {
-                result = optionalDataObject.get();
-            } else {
-                LOG.debug("{}: Failed to read {}",
-                        Thread.currentThread().getStackTrace()[1], path);
-            }
-        } catch (ReadFailedException e) {
-            LOG.warn("Failed to read {} ", path, e);
-        }
-        transaction.close();
-        return result;
-    }
-}
index 4c71b499d782ee5c089dc11c254e0008b0ece38d..1f7f36546266b648805b02cc8fb1a352da567a5f 100644 (file)
@@ -12,16 +12,13 @@ import static org.junit.Assert.fail;
 import static org.ops4j.pax.exam.CoreOptions.composite;
 import static org.ops4j.pax.exam.CoreOptions.maven;
 import static org.ops4j.pax.exam.CoreOptions.vmOption;
-import static org.ops4j.pax.exam.CoreOptions.when;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
 
 import com.google.common.collect.ImmutableBiMap;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 
-import java.io.File;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
@@ -48,6 +45,8 @@ import org.opendaylight.ovsdb.southbound.SouthboundConstants;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 import org.opendaylight.ovsdb.southbound.SouthboundProvider;
 import org.opendaylight.ovsdb.southbound.SouthboundUtil;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
@@ -60,7 +59,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.re
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbFailModeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbPortInterfaceAttributes.VlanMode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
@@ -108,7 +106,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
 import org.ops4j.pax.exam.karaf.options.LogLevelOption;
 import org.ops4j.pax.exam.options.MavenUrlReference;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
@@ -137,12 +134,6 @@ public class SouthboundIT extends AbstractMdsalTestBase {
     private static MdsalUtils mdsalUtils = null;
     private static Node ovsdbNode;
 
-    // TODO Constants copied from AbstractConfigTestBase, need to be removed (see TODO below)
-    private static final String PAX_EXAM_UNPACK_DIRECTORY = "target/exam";
-    private static final String KARAF_DEBUG_PORT = "5005";
-    private static final String KARAF_DEBUG_PROP = "karaf.debug";
-    private static final String KEEP_UNPACK_DIRECTORY_PROP = "karaf.keep.unpack";
-
     @Inject
     private BundleContext bundleContext;
 
@@ -198,16 +189,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
 
     @Configuration
     public Option[] config() {
-        // TODO Figure out how to use the parent Karaf setup, then just use super.config()
-        Option[] options = new Option[] {
-                when(Boolean.getBoolean(KARAF_DEBUG_PROP))
-                        .useOptions(KarafDistributionOption.debugConfiguration(KARAF_DEBUG_PORT, true)),
-                karafDistributionConfiguration().frameworkUrl(getKarafDistro())
-                        .unpackDirectory(new File(PAX_EXAM_UNPACK_DIRECTORY))
-                        .useDeployFolder(false),
-                when(Boolean.getBoolean(KEEP_UNPACK_DIRECTORY_PROP)).useOptions(keepRuntimeFolder()),
-                // Works only if we don't specify the feature repo and name
-                getLoggingOption()};
+        Option[] options = super.config();
         Option[] propertyOptions = getPropertiesOptions();
         Option[] otherOptions = getOtherOptions();
         Option[] combinedOptions = new Option[options.length + propertyOptions.length + otherOptions.length];
@@ -257,7 +239,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
 
     @Override
     public String getFeatureName() {
-        return "odl-ovsdb-southbound-impl-ui";
+        return "odl-ovsdb-southbound-test";
     }
 
     protected String usage() {
@@ -334,7 +316,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
 
         mdsalUtils = new MdsalUtils(dataBroker);
         final ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
-        final InstanceIdentifier<Node> iid = createInstanceIdentifier(connectionInfo);
+        final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
         dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
                 iid, CONFIGURATION_LISTENER, AsyncDataBroker.DataChangeScope.SUBTREE);
         dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
@@ -378,11 +360,6 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         return connectionInfo;
     }
 
-    private static String connectionInfoToString(final ConnectionInfo connectionInfo) {
-        return String.valueOf(
-                connectionInfo.getRemoteIp().getValue()) + ":" + connectionInfo.getRemotePort().getValue();
-    }
-
     @Test
     public void testNetworkTopology() throws InterruptedException {
         NetworkTopology networkTopology = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION,
@@ -412,21 +389,14 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 topology);
     }
 
-    private static InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo connectionInfo) {
-        return InstanceIdentifier
-                .create(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
-                .child(Node.class,
-                        createNodeKey(connectionInfo.getRemoteIp(), connectionInfo.getRemotePort()));
-    }
-
     private Node connectOvsdbNode(final ConnectionInfo connectionInfo) throws InterruptedException {
-        final InstanceIdentifier<Node> iid = createInstanceIdentifier(connectionInfo);
-        Assert.assertTrue(mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, iid, createNode(connectionInfo)));
+        final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
+        Assert.assertTrue(
+                mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, iid, SouthboundUtils.createNode(connectionInfo)));
         waitForOperationalCreation(iid);
         Node node = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, iid);
         Assert.assertNotNull(node);
-        LOG.info("Connected to {}", connectionInfoToString(connectionInfo));
+        LOG.info("Connected to {}", SouthboundUtils.connectionInfoToString(connectionInfo));
         return node;
     }
 
@@ -467,12 +437,12 @@ public class SouthboundIT extends AbstractMdsalTestBase {
     }
 
     private static void disconnectOvsdbNode(final ConnectionInfo connectionInfo) throws InterruptedException {
-        final InstanceIdentifier<Node> iid = createInstanceIdentifier(connectionInfo);
+        final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
         Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, iid));
         waitForOperationalDeletion(iid);
         Node node = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, iid);
         Assert.assertNull(node);
-        LOG.info("Disconnected from {}", connectionInfoToString(connectionInfo));
+        LOG.info("Disconnected from {}", SouthboundUtils.connectionInfoToString(connectionInfo));
     }
 
     @Test
@@ -497,9 +467,9 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 LOG.info("dp type is {}", dpTypeStr);
                 if (dpTypeStr.equals(NETDEV_DP_TYPE)) {
                     LOG.info("Found a DPDK node; adding a corresponding netdev device");
-                    InstanceIdentifier<Node> bridgeIid = createInstanceIdentifier(connectionInfo,
+                    InstanceIdentifier<Node> bridgeIid = SouthboundUtils.createInstanceIdentifier(connectionInfo,
                             new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME));
-                    NodeId bridgeNodeId = createManagedNodeId(bridgeIid);
+                    NodeId bridgeNodeId = SouthboundUtils.createManagedNodeId(bridgeIid);
                     try (TestBridge testBridge = new TestBridge(connectionInfo, bridgeIid,
                             SouthboundITConstants.BRIDGE_NAME, bridgeNodeId, false, null, true, dpType, null, null,
                             null)) {
@@ -615,7 +585,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
 
     private static void setManagedBy(final OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder,
                               final ConnectionInfo connectionInfo) {
-        InstanceIdentifier<Node> connectionNodePath = createInstanceIdentifier(connectionInfo);
+        InstanceIdentifier<Node> connectionNodePath = SouthboundUtils.createInstanceIdentifier(connectionInfo);
         ovsdbBridgeAugmentationBuilder.setManagedBy(new OvsdbNodeRef(connectionNodePath));
     }
 
@@ -708,7 +678,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             this.bridgeName = bridgeName;
             NodeBuilder bridgeNodeBuilder = new NodeBuilder();
             if (bridgeIid == null) {
-                bridgeIid = createInstanceIdentifier(connectionInfo, new OvsdbBridgeName(bridgeName));
+                bridgeIid = SouthboundUtils.createInstanceIdentifier(connectionInfo, new OvsdbBridgeName(bridgeName));
             }
             if (bridgeNodeId == null) {
                 bridgeNodeId = SouthboundMapper.createManagedNodeId(bridgeIid);
@@ -746,7 +716,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         @Override
         public void close() {
             final InstanceIdentifier<Node> iid =
-                    createInstanceIdentifier(connectionInfo, new OvsdbBridgeName(bridgeName));
+                    SouthboundUtils.createInstanceIdentifier(connectionInfo, new OvsdbBridgeName(bridgeName));
             Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, iid));
             try {
                 Thread.sleep(OVSDB_UPDATE_TIMEOUT);
@@ -802,8 +772,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
      */
     private Node getBridgeNode(ConnectionInfo connectionInfo, String bridgeName, LogicalDatastoreType store) {
         InstanceIdentifier<Node> bridgeIid =
-                createInstanceIdentifier(connectionInfo,
-                        new OvsdbBridgeName(bridgeName));
+                SouthboundUtils.createInstanceIdentifier(connectionInfo, new OvsdbBridgeName(bridgeName));
         return mdsalUtils.read(store, bridgeIid);
     }
 
@@ -831,8 +800,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
     }
 
     private InstanceIdentifier<Node> getTpIid(ConnectionInfo connectionInfo, OvsdbBridgeAugmentation bridge) {
-        return createInstanceIdentifier(connectionInfo,
-                bridge.getBridgeName());
+        return SouthboundUtils.createInstanceIdentifier(connectionInfo, bridge.getBridgeName());
     }
 
     /**
@@ -866,7 +834,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
             Assert.assertNotNull(bridge);
             LOG.info("bridge: {}", bridge);
-            NodeId nodeId = SouthboundMapper.createManagedNodeId(createInstanceIdentifier(
+            NodeId nodeId = SouthboundMapper.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
                     connectionInfo, bridge.getBridgeName()));
             OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
                     createGenericOvsdbTerminationPointAugmentationBuilder();
@@ -911,7 +879,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
             OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
             Assert.assertNotNull(bridge);
-            NodeId nodeId = createManagedNodeId(createInstanceIdentifier(
+            NodeId nodeId = SouthboundUtils.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
                     connectionInfo, bridge.getBridgeName()));
             OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
                     createGenericOvsdbTerminationPointAugmentationBuilder();
@@ -943,9 +911,8 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             }
 
             // UPDATE- Not Applicable.  From the OpenVSwitch documentation:
-            //   "A client should ideally set this column’s value in the same database transaction that it uses to create
-
-            //   the interface. "
+            //   "A client should ideally set this column’s value in the same database transaction that it uses to
+            //   create the interface. "
 
             // DELETE handled by TestBridge
         }
@@ -989,8 +956,9 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 try (TestBridge testBridge = new TestBridge(connectionInfo, null, testBridgeAndPortName, null, true,
                         SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"), true, null, null, null,
                         null)) {
-                    NodeId testBridgeNodeId = createManagedNodeId(createInstanceIdentifier(
-                            connectionInfo, new OvsdbBridgeName(testBridgeAndPortName)));
+                    NodeId testBridgeNodeId = SouthboundUtils.createManagedNodeId(
+                            SouthboundUtils.createInstanceIdentifier(connectionInfo,
+                                    new OvsdbBridgeName(testBridgeAndPortName)));
                     OvsdbTerminationPointAugmentationBuilder tpCreateAugmentationBuilder =
                             createGenericOvsdbTerminationPointAugmentationBuilder();
                     tpCreateAugmentationBuilder.setName(testBridgeAndPortName);
@@ -1024,7 +992,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                     helper.writeValues(tpUpdateAugmentationBuilder, updateToTestCase.inputValues);
                     InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
                     NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
-                    NodeId portUpdateNodeId = createManagedNodeId(portIid);
+                    NodeId portUpdateNodeId = SouthboundUtils.createManagedNodeId(portIid);
                     portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
                     TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
                     tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(testBridgeAndPortName)));
@@ -1130,7 +1098,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
             OvsdbBridgeAugmentation bridge = getBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME);
             Assert.assertNotNull(bridge);
-            NodeId nodeId = createManagedNodeId(createInstanceIdentifier(
+            NodeId nodeId = SouthboundUtils.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
                     connectionInfo, bridge.getBridgeName()));
             OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
                     createGenericOvsdbTerminationPointAugmentationBuilder();
@@ -1163,7 +1131,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             tpUpdateAugmentationBuilder.setVlanTag(new VlanId(UPDATED_VLAN_ID));
             InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
             NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
-            NodeId portUpdateNodeId = createManagedNodeId(portIid);
+            NodeId portUpdateNodeId = SouthboundUtils.createManagedNodeId(portIid);
             portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
             TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
             tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(portName)));
@@ -1203,7 +1171,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
                 OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
                 Assert.assertNotNull(bridge);
-                NodeId nodeId = createManagedNodeId(createInstanceIdentifier(
+                NodeId nodeId = SouthboundUtils.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
                         connectionInfo, bridge.getBridgeName()));
                 OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
                         createGenericOvsdbTerminationPointAugmentationBuilder();
@@ -1233,7 +1201,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 tpUpdateAugmentationBuilder.setVlanMode(UPDATED_VLAN_MODE);
                 InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
                 NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
-                NodeId portUpdateNodeId = createManagedNodeId(portIid);
+                NodeId portUpdateNodeId = SouthboundUtils.createManagedNodeId(portIid);
                 portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
                 TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
                 tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(portName)));
@@ -1294,8 +1262,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
                 OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
                 Assert.assertNotNull(bridge);
-                NodeId nodeId = createManagedNodeId(createInstanceIdentifier(
-                        connectionInfo, bridge.getBridgeName()));
+                NodeId nodeId = SouthboundUtils.createManagedNodeId(connectionInfo, bridge.getBridgeName());
                 OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
                         createGenericOvsdbTerminationPointAugmentationBuilder();
                 String portName = "testTerminationPointVlanTrunks" + testCase;
@@ -1328,7 +1295,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 tpUpdateAugmentationBuilder.setTrunks(UPDATED_TRUNKS);
                 InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
                 NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
-                NodeId portUpdateNodeId = createManagedNodeId(portIid);
+                NodeId portUpdateNodeId = SouthboundUtils.createManagedNodeId(portIid);
                 portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
                 TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
                 tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(portName)));
@@ -1365,7 +1332,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID));
 
         Topology topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, topologyPath);
-        InstanceIdentifier<Node> expectedNodeIid = createInstanceIdentifier(connectionInfo);
+        InstanceIdentifier<Node> expectedNodeIid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
         NodeId expectedNodeId = expectedNodeIid.firstKeyOf(Node.class, NodeKey.class).getNodeId();
         Node foundNode = null;
         Assert.assertNotNull("Expected to find topology: " + topologyPath, topology);
@@ -1407,7 +1374,8 @@ public class SouthboundIT extends AbstractMdsalTestBase {
 
                 // CREATE: Create the test bridge
                 final OvsdbBridgeName ovsdbBridgeName = new OvsdbBridgeName(testBridgeName);
-                final InstanceIdentifier<Node> bridgeIid = createInstanceIdentifier(connectionInfo, ovsdbBridgeName);
+                final InstanceIdentifier<Node> bridgeIid =
+                        SouthboundUtils.createInstanceIdentifier(connectionInfo, ovsdbBridgeName);
                 final NodeId bridgeNodeId = SouthboundMapper.createManagedNodeId(bridgeIid);
                 final NodeBuilder bridgeCreateNodeBuilder = new NodeBuilder();
                 bridgeCreateNodeBuilder.setNodeId(bridgeNodeId);
@@ -1475,48 +1443,6 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 new BridgeExternalIdsSouthboundHelper());
     }
 
-    public static InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo key,OvsdbBridgeName bridgeName) {
-        return SouthboundMapper.createInstanceIdentifier(createManagedNodeId(key, bridgeName));
-    }
-
-    public static NodeId createManagedNodeId(ConnectionInfo key, OvsdbBridgeName bridgeName) {
-        return createManagedNodeId(key.getRemoteIp(), key.getRemotePort(), bridgeName);
-    }
-
-    public static NodeId createManagedNodeId(IpAddress ip, PortNumber port, OvsdbBridgeName bridgeName) {
-        return new NodeId(createNodeId(ip,port).getValue()
-                + "/" + SouthboundConstants.BRIDGE_URI_PREFIX + "/" + bridgeName.getValue());
-    }
-
-    public static NodeId createNodeId(IpAddress ip, PortNumber port) {
-        String uriString = SouthboundConstants.OVSDB_URI_PREFIX + "://"
-                + String.valueOf(ip.getValue()) + ":" + port.getValue();
-        Uri uri = new Uri(uriString);
-        return new NodeId(uri);
-    }
-
-    public static NodeKey createNodeKey(IpAddress ip, PortNumber port) {
-        return new NodeKey(createNodeId(ip,port));
-    }
-
-    public static Node createNode(ConnectionInfo key) {
-        NodeBuilder nodeBuilder = new NodeBuilder();
-        nodeBuilder.setNodeId(createNodeId(key.getRemoteIp(),key.getRemotePort()));
-        nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class, createOvsdbAugmentation(key));
-        return nodeBuilder.build();
-    }
-
-    public static OvsdbNodeAugmentation createOvsdbAugmentation(ConnectionInfo key) {
-        OvsdbNodeAugmentationBuilder ovsdbNodeBuilder = new OvsdbNodeAugmentationBuilder();
-        ovsdbNodeBuilder.setConnectionInfo(key);
-        return ovsdbNodeBuilder.build();
-    }
-
-    public static NodeId createManagedNodeId(InstanceIdentifier<Node> iid) {
-        NodeKey nodeKey = iid.firstKeyOf(Node.class, NodeKey.class);
-        return nodeKey.getNodeId();
-    }
-
     /**
      * <p>
      * Representation of a southbound test case. Each test case has a name, a list of input values and a list of
index 978c5223b5384d2c8a330abc6c4bc6885742d1e6..e3eb3a29c4d0d8a474737c45e6b0ad28ffd44ab6 100644 (file)
@@ -84,31 +84,31 @@ public class SouthboundUtils {
             .put("dpdkvhostuser", InterfaceTypeDpdkvhostuser.class)
             .build();
 
-    public NodeId createNodeId(IpAddress ip, PortNumber port) {
+    public static NodeId createNodeId(IpAddress ip, PortNumber port) {
         String uriString = SouthboundConstants.OVSDB_URI_PREFIX + "://"
                 + String.valueOf(ip.getValue()) + ":" + port.getValue();
         Uri uri = new Uri(uriString);
         return new NodeId(uri);
     }
 
-    public Node createNode(ConnectionInfo key) {
+    public static Node createNode(ConnectionInfo key) {
         NodeBuilder nodeBuilder = new NodeBuilder();
         nodeBuilder.setNodeId(createNodeId(key.getRemoteIp(), key.getRemotePort()));
         nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class, createOvsdbAugmentation(key));
         return nodeBuilder.build();
     }
 
-    public OvsdbNodeAugmentation createOvsdbAugmentation(ConnectionInfo key) {
+    public static OvsdbNodeAugmentation createOvsdbAugmentation(ConnectionInfo key) {
         OvsdbNodeAugmentationBuilder ovsdbNodeBuilder = new OvsdbNodeAugmentationBuilder();
         ovsdbNodeBuilder.setConnectionInfo(key);
         return ovsdbNodeBuilder.build();
     }
 
-    public InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo key) {
+    public static InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo key) {
         return createInstanceIdentifier(key.getRemoteIp(), key.getRemotePort());
     }
 
-    public InstanceIdentifier<Node> createInstanceIdentifier(IpAddress ip, PortNumber port) {
+    public static InstanceIdentifier<Node> createInstanceIdentifier(IpAddress ip, PortNumber port) {
         InstanceIdentifier<Node> path = InstanceIdentifier
                 .create(NetworkTopology.class)
                 .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
@@ -117,7 +117,7 @@ public class SouthboundUtils {
         return path;
     }
 
-    public InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo key,OvsdbBridgeName bridgeName) {
+    public static InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo key,OvsdbBridgeName bridgeName) {
         return SouthboundMapper.createInstanceIdentifier(createManagedNodeId(key, bridgeName));
     }
 
@@ -133,20 +133,25 @@ public class SouthboundUtils {
         return terminationPointPath;
     }
 
-    public NodeKey createNodeKey(IpAddress ip, PortNumber port) {
+    public static NodeKey createNodeKey(IpAddress ip, PortNumber port) {
         return new NodeKey(createNodeId(ip, port));
     }
 
-    public NodeId createManagedNodeId(ConnectionInfo key, OvsdbBridgeName bridgeName) {
+    public static NodeId createManagedNodeId(ConnectionInfo key, OvsdbBridgeName bridgeName) {
         return createManagedNodeId(key.getRemoteIp(), key.getRemotePort(), bridgeName);
     }
 
-    public NodeId createManagedNodeId(IpAddress ip, PortNumber port, OvsdbBridgeName bridgeName) {
+    public static NodeId createManagedNodeId(IpAddress ip, PortNumber port, OvsdbBridgeName bridgeName) {
         return new NodeId(createNodeId(ip,port).getValue()
                 + "/" + SouthboundConstants.BRIDGE_URI_PREFIX + "/" + bridgeName.getValue());
     }
 
-    public ConnectionInfo getConnectionInfo(final String addressStr, final String portStr) {
+    public static NodeId createManagedNodeId(InstanceIdentifier<Node> iid) {
+        NodeKey nodeKey = iid.firstKeyOf(Node.class, NodeKey.class);
+        return nodeKey.getNodeId();
+    }
+
+    public static ConnectionInfo getConnectionInfo(final String addressStr, final String portStr) {
         InetAddress inetAddress = null;
         try {
             inetAddress = InetAddress.getByName(addressStr);
@@ -167,7 +172,7 @@ public class SouthboundUtils {
                 .build();
     }
 
-    public String connectionInfoToString(final ConnectionInfo connectionInfo) {
+    public static String connectionInfoToString(final ConnectionInfo connectionInfo) {
         return String.valueOf(
                 connectionInfo.getRemoteIp().getValue()) + ":" + connectionInfo.getRemotePort().getValue();
     }