Bug-8187: call home throwing exception on startup 66/54866/1
authorallan clarke <clarkea@brocade.com>
Fri, 7 Apr 2017 17:19:23 +0000 (12:19 -0500)
committerTomas Cere <tcere@cisco.com>
Wed, 12 Apr 2017 13:52:33 +0000 (13:52 +0000)
Remove distracting exception in log.
Restore ability to change the call home server port.
Move to using blueprint for configuration instead of
using ad hoc logic.

Change-Id: I273156ba13237b1ed8efc0e6ff9861b1aa5feb3b
Signed-off-by: allan clarke <clarkea@brocade.com>
(cherry picked from commit a03f9c965b43c9d7b78a78ab9e56935a5da07a88)

netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/Configuration.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java
netconf/callhome-provider/src/main/resources/org/opendaylight/blueprint/callhome-topology.xml

index f115b86b6a1a6435a80ed5ed50ea436529e91d75..bc00292a682764d1e876e37ab7ac381486ecffbf 100644 (file)
@@ -66,6 +66,11 @@ public class Configuration {
     private String path;
     private Properties properties;
 
+    public Configuration() {
+        path = "<no-path>";
+        properties = new Properties();
+    }
+
     public Configuration(String path) throws ConfigurationException {
         this.path = path;
         try {
@@ -91,7 +96,11 @@ public class Configuration {
         return properties;
     }
 
-    public String get(String key) {
+    public void set(String key, String value) {
+        properties.setProperty(key, value);
+    }
+
+    String get(String key) {
         String result = (String) properties.get(key);
         if (result == null)
             throw new MissingException(key);
index ca26f8606432136ee0ff8dc619ad701787d451b9..43479a0b3a5a12d3930a965fd0c467662b638940 100644 (file)
@@ -60,7 +60,6 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
     private ListenerRegistration<IetfZeroTouchCallHomeServerProvider> listenerReg = null;
 
     private static final String CALL_HOME_PORT_KEY = "DefaultCallHomePort";
-    private static String configurationPath = "etc" + File.pathSeparator + "ztp-callhome-config.cfg";
     private int port = 0; // 0 = use default in NetconfCallHomeBuilder
     private CallhomeStatusReporter statusReporter;
 
@@ -75,7 +74,6 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
         // Register itself as a listener to changes in Devices subtree
         try {
             LOG.info("Initializing provider for {}", APPNAME);
-            loadConfigurableValues(configurationPath);
             initializeServer();
             dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, ALL_DEVICES, this, AsyncDataBroker.DataChangeScope.SUBTREE);
             LOG.info("Initialization complete for {}", APPNAME);
@@ -84,13 +82,14 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
         }
     }
 
-    private void loadConfigurableValues(String configurationPath)
-            throws Configuration.ConfigurationException {
+    public void setPort(String portStr) {
         try {
-            Configuration configuration = new Configuration(configurationPath);
+            Configuration configuration = new Configuration();
+            configuration.set(CALL_HOME_PORT_KEY, portStr);
             port = configuration.getAsPort(CALL_HOME_PORT_KEY);
-        } catch (Configuration.ConfigurationException e) {
-            LOG.error("Problem trying to load configuration values from {}", configurationPath, e);
+            LOG.info("Setting port for call home server to {}", portStr);
+        } catch(Configuration.ConfigurationException e) {
+            LOG.error("Problem trying to set port for call home server {}", portStr, e);
         }
     }
 
index 657a4810e2334dc33f700f1d7d1ef02ab675030e..831980c33ebf3f3c726a113fec855d6ea968ec8f 100755 (executable)
@@ -37,6 +37,7 @@
           destroy-method="close" >
         <argument ref="dataBroker" />
         <argument ref="callhomeDispatcher" />
+        <property name="port" value="6666" />
     </bean>
 
     <bean id="callhomeDispatcher" class="org.opendaylight.netconf.callhome.mount.CallHomeMountDispatcher">