From a03f9c965b43c9d7b78a78ab9e56935a5da07a88 Mon Sep 17 00:00:00 2001 From: allan clarke Date: Fri, 7 Apr 2017 12:19:23 -0500 Subject: [PATCH] Bug-8187: call home throwing exception on startup 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 --- .../netconf/callhome/mount/Configuration.java | 11 ++++++++++- .../mount/IetfZeroTouchCallHomeServerProvider.java | 13 ++++++------- .../opendaylight/blueprint/callhome-topology.xml | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/Configuration.java b/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/Configuration.java index f115b86b6a..bc00292a68 100644 --- a/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/Configuration.java +++ b/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/Configuration.java @@ -66,6 +66,11 @@ public class Configuration { private String path; private Properties properties; + public Configuration() { + 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); diff --git a/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java b/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java index ca26f86064..43479a0b3a 100644 --- a/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java +++ b/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java @@ -60,7 +60,6 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC private ListenerRegistration 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); } } diff --git a/netconf/callhome-provider/src/main/resources/org/opendaylight/blueprint/callhome-topology.xml b/netconf/callhome-provider/src/main/resources/org/opendaylight/blueprint/callhome-topology.xml index 657a4810e2..831980c33e 100755 --- a/netconf/callhome-provider/src/main/resources/org/opendaylight/blueprint/callhome-topology.xml +++ b/netconf/callhome-provider/src/main/resources/org/opendaylight/blueprint/callhome-topology.xml @@ -37,6 +37,7 @@ destroy-method="close" > + -- 2.36.6