Bug-8187: call home throwing exception on startup
[netconf.git] / netconf / callhome-provider / src / main / java / org / opendaylight / netconf / callhome / mount / IetfZeroTouchCallHomeServerProvider.java
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);
         }
     }