client IP/port definition in configuration separation 52/3452/2
authorMartin Bobak <mbobak@cisco.com>
Wed, 4 Dec 2013 14:09:42 +0000 (15:09 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 4 Dec 2013 15:00:16 +0000 (15:00 +0000)
new netconf.client properties added to integration tests

Change-Id: Ic9517d19ec00b8656c29528903d538d32674a5e9
Signed-off-by: Martin Bobak <mbobak@cisco.com>
opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini
opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java
opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfImplActivator.java
opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/osgi/NetconfSSHActivator.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/osgi/NetconfConfigUtil.java

index b9b9c7337d8922e82b8f1f8927c40be8422d8d51..7d57e6005e65774519d579838c90c9cbd4f8fe85 100644 (file)
@@ -17,6 +17,9 @@ osgi.bundles=\
 netconf.tcp.address=0.0.0.0
 netconf.tcp.port=8383
 
+netconf.tcp.client.address=127.0.0.1
+netconf.tcp.client.port=8383
+
 netconf.ssh.address=0.0.0.0
 netconf.ssh.port=1830
 
index 4ef9d80b02c2f34a34de5f7e6360857565bb71fe..49781ce11630a7f589dda76922e1107025b9abba 100644 (file)
@@ -111,6 +111,8 @@ public class TestHelper {
 
                 systemProperty("netconf.tcp.address").value("0.0.0.0"), //
                 systemProperty("netconf.tcp.port").value("18383"), //
+                systemProperty("netconf.tcp.client.address").value("127.0.0.1"), //
+                systemProperty("netconf.tcp.client.port").value("18383"), //
                 systemProperty("netconf.config.persister.active").value("1"), //
                 systemProperty("netconf.config.persister.1.storageAdapterClass").value(
                         "org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter"), //
index 41ae52b3bf0ff5da3cfb3adcffb6ccfbeb4ac491..fda1e264e6babd472799340faeda579174c497b8 100644 (file)
@@ -151,6 +151,9 @@ public class ServiceProviderController {
                 systemProperty("netconf.tcp.address").value("127.0.0.1"),
                 systemProperty("netconf.tcp.port").value("8383"),
 
+                systemProperty("netconf.tcp.client.address").value("127.0.0.1"),
+                systemProperty("netconf.tcp.client.port").value("8383"),
+
                 // Set the systemPackages (used by clustering)
                 systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
 
index 5fa0b49d7b954434e88220f5378ccc89d0f51f8d..e7916c2d5f3d041ee315e03335586d533c76206e 100644 (file)
@@ -53,7 +53,7 @@ public class ConfigPersisterActivator implements BundleActivator {
         PersisterAggregator persister = PersisterAggregator.createFromProperties(propertiesProvider);
 
         InetSocketAddress address = NetconfConfigUtil.extractTCPNetconfAddress(context,
-                "Netconf is not configured, persister is not operational");
+                "Netconf is not configured, persister is not operational",true);
         configPersisterNotificationHandler = new ConfigPersisterNotificationHandler(persister, address,
                 platformMBeanServer, ignoredMissingCapabilityRegex);
 
index 1d18f063bcc062ed64fb077d7cc34d07369a8d2e..b30c80b43d964426839306477a3c84a4d28084fd 100644 (file)
@@ -34,7 +34,8 @@ public class NetconfImplActivator implements BundleActivator {
 
     @Override
     public void start(final BundleContext context) throws Exception {
-        InetSocketAddress address = NetconfConfigUtil.extractTCPNetconfAddress(context, "TCP is not configured, netconf not available.");
+        InetSocketAddress address = NetconfConfigUtil.extractTCPNetconfAddress(context,
+                "TCP is not configured, netconf not available.", false);
 
         NetconfOperationServiceFactoryListenerImpl factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
         factoriesTracker = new NetconfOperationServiceFactoryTracker(context, factoriesListener);
index 6f164f93d9c9482613a286352a6868e41cf649c3..b91824866a107ffef75290f3a52af53318dca7a5 100644 (file)
@@ -38,7 +38,8 @@ public class NetconfSSHActivator implements BundleActivator{
         logger.trace("Starting netconf SSH  bridge.");
 
         Optional<InetSocketAddress> sshSocketAddressOptional = NetconfConfigUtil.extractSSHNetconfAddress(context,EXCEPTION_MESSAGE);
-        InetSocketAddress tcpSocketAddress = NetconfConfigUtil.extractTCPNetconfAddress(context,EXCEPTION_MESSAGE);
+        InetSocketAddress tcpSocketAddress = NetconfConfigUtil.extractTCPNetconfAddress(context,
+                EXCEPTION_MESSAGE, true);
 
         if (sshSocketAddressOptional.isPresent()){
             server = NetconfSSHServer.start(sshSocketAddressOptional.get().getPort(),tcpSocketAddress);
index b1d902d6341f83415b8be25509bc6e1dc27000c2..987708d67ed03db1276a6459ad47c75f7eabf0bf 100644 (file)
@@ -8,12 +8,12 @@
 
 package org.opendaylight.controller.netconf.util.osgi;
 
-import com.google.common.base.Optional;
-import java.net.InetSocketAddress;
-import org.osgi.framework.BundleContext;
-import static com.google.common.base.Preconditions.checkNotNull;
+        import com.google.common.base.Optional;
+        import java.net.InetSocketAddress;
+        import org.osgi.framework.BundleContext;
+        import static com.google.common.base.Preconditions.checkNotNull;
 
-    public class NetconfConfigUtil {
+public class NetconfConfigUtil {
     private static final String PREFIX_PROP = "netconf.";
 
     private enum InfixProp {
@@ -22,10 +22,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
 
     private static final String PORT_SUFFIX_PROP = ".port";
     private static final String ADDRESS_SUFFIX_PROP = ".address";
+    private static final String CLIENT_PROP = ".client";
 
-    public static InetSocketAddress extractTCPNetconfAddress(BundleContext context, String exceptionMessageIfNotFound) {
+    public static InetSocketAddress extractTCPNetconfAddress(BundleContext context, String exceptionMessageIfNotFound, boolean forClient) {
 
-        Optional<InetSocketAddress> inetSocketAddressOptional = extractSomeNetconfAddress(context, InfixProp.tcp, exceptionMessageIfNotFound);
+        Optional<InetSocketAddress> inetSocketAddressOptional = extractSomeNetconfAddress(context, InfixProp.tcp, exceptionMessageIfNotFound, forClient);
 
         if (inetSocketAddressOptional.isPresent() == false) {
             throw new IllegalStateException("Netconf tcp address not found." + exceptionMessageIfNotFound);
@@ -34,7 +35,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
     }
 
     public static Optional<InetSocketAddress> extractSSHNetconfAddress(BundleContext context, String exceptionMessage) {
-        return extractSomeNetconfAddress(context, InfixProp.ssh, exceptionMessage);
+        return extractSomeNetconfAddress(context, InfixProp.ssh, exceptionMessage, false);
     }
 
     /**
@@ -47,14 +48,28 @@ import static com.google.common.base.Preconditions.checkNotNull;
      *             if address or port are invalid, or configuration is missing
      */
     private static Optional<InetSocketAddress> extractSomeNetconfAddress(BundleContext context,
-            InfixProp infixProp, String exceptionMessage) {
-        String address = context.getProperty(PREFIX_PROP + infixProp + ADDRESS_SUFFIX_PROP);
-        if (address == null) {
+                                                                         InfixProp infixProp,
+                                                                         String exceptionMessage,
+                                                                         boolean client) {
+        String address = "";
+        if (client) {
+            address = context.getProperty(PREFIX_PROP + infixProp + CLIENT_PROP + ADDRESS_SUFFIX_PROP);
+        }
+        if (address == null || address.equals("")){
+            address = context.getProperty(PREFIX_PROP + infixProp + ADDRESS_SUFFIX_PROP);
+        }
+        if (address == null || address.equals("")) {
             throw new IllegalStateException("Cannot find initial netconf configuration for parameter    "
                     +PREFIX_PROP + infixProp + ADDRESS_SUFFIX_PROP
                     +" in config.ini. "+exceptionMessage);
         }
-        String portKey = PREFIX_PROP + infixProp + PORT_SUFFIX_PROP;
+        String portKey = "";
+        if (client) {
+            portKey = PREFIX_PROP + infixProp + CLIENT_PROP + PORT_SUFFIX_PROP;
+        }
+        if (portKey == null || portKey.equals("")){
+            portKey = PREFIX_PROP + infixProp + PORT_SUFFIX_PROP;
+        }
         String portString = context.getProperty(portKey);
         checkNotNull(portString, "Netconf port must be specified in properties file with " + portKey);
         try {