Fixing ComponentConfigManager to preset values locally; not just in the distributed store.

Also added 'preset' usage to the 'cfg' command.

Change-Id: I90df276e68328716784ca1f8624d4d0b8266ad24
(cherry picked from commit 8c73019d271efd7975f1f94c2aa32456dd73c170)
diff --git a/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java b/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java
index b53646f..60feca0 100644
--- a/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java
+++ b/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java
@@ -244,6 +244,9 @@
                 return;
             }
         }
+
+        // If definition doesn't exist in local catalog, cache the property.
+        preSet(componentName, name, value);
     }
 
     // Locates the property in the component map and replaces it with an
@@ -262,6 +265,21 @@
         }
     }
 
+    // Stores non-existent property so that loadExistingValues() can load in future.
+    private void preSet(String componentName, String name, String value) {
+        try {
+            Configuration config = cfgAdmin.getConfiguration(componentName, null);
+            Dictionary<String, Object> props = config.getProperties();
+            if (props == null) {
+                props = new Hashtable<>();
+            }
+            props.put(name, value);
+            config.update(props);
+        } catch (IOException e) {
+            log.error("Failed to preset configuration for {}", componentName);
+        }
+    }
+
     // Checks whether the value of the specified configuration property is a valid one or not.
     private void checkValidity(String componentName, String name, String newValue) {
         Map<String, ConfigProperty> map = properties.get(componentName);