Support VTN Neutron User Configurable Properties 85/29285/6
authorgvrangan <venkatrangang@hcl.com>
Wed, 4 Nov 2015 18:31:05 +0000 (10:31 -0800)
committerVenkatrangan Govindarajan <venkatrangang@hcl.com>
Thu, 12 Nov 2015 18:32:30 +0000 (18:32 +0000)
 * Earlier vtn.ini file was used
 * Values can now be modified in 90-vtn.xml

Change-Id: I426c55b492a6fb53a3170b0e5d68824beef77cab
Signed-off-by: gvrangan <venkatrangang@hcl.com>
manager/neutron/src/main/config/default-config.xml
manager/neutron/src/main/java/org/opendaylight/vtn/manager/neutron/OVSDBEventHandler.java
manager/neutron/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/vtn/neutron/rev150922/VTNNeutronModule.java
manager/neutron/src/main/yang/vtn-neutron.yang

index e95c0518e90dc6d98dd466b24868f060466afdd3..238c4c27c85a50d13b176917aeb294ba48eec587 100644 (file)
             <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
             <name>binding-osgi-broker</name>
           </broker>
-
-        </module>
+            <bridgeName>br-int</bridgeName>
+            <portName>ens33</portName>
+            <protocol>openflow13</protocol>
+            <failMode>secure</failMode>
+          </module>
       </modules>
     </data>
   </configuration>
index 943c1f2a50584ca9f157a8b3fb4c883d9c6920a9..a061718e3bf3ae14c446943197706de8f9372a6c 100644 (file)
@@ -8,13 +8,10 @@
 
 package org.opendaylight.vtn.manager.neutron;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.net.HttpURLConnection;
 import java.security.InvalidParameterException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Properties;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -79,18 +76,7 @@ public class OVSDBEventHandler extends VTNNeutronUtils {
      */
     static final Logger LOG = LoggerFactory.getLogger(OVSDBEventHandler.class);
 
-    /**
-     * The name of the configuration directory.
-     */
-    private static final String  CONFIG_DIR = "configuration";
-
-    /**
-     * The name of the configuration file.
-     */
-    private static final String  VTN_INI_NAME = "vtn.ini";
-
-
-    /**
+     /**
      * identifier for the integration bridge name.
      */
     private String integrationBridgeName;
@@ -191,6 +177,27 @@ public class OVSDBEventHandler extends VTNNeutronUtils {
      * VTN identifiers in neutron port object.
      */
     private static final int VTN_IDENTIFIERS_IN_PORT = 3;
+
+    /**
+     * identifiers for OVSDB Port Name.
+     */
+    public static String ovsdbPortName;
+
+    /**
+     * identifiers for OVSDB Bridge Name.
+     */
+    public static String ovsdbBridgeName;
+
+    /**
+     * identifiers for OVSDB Protocol.
+     */
+    public static String ovsdbProtocol;
+
+    /**
+     * identifiers for OVSDB Failmode.
+     */
+    public static String ovsdbFailMode;
+
     /**
      * Method invoked when the open flow switch is Added.
      * @param dataBroker Instance of DataBroker object to be added.
@@ -234,35 +241,28 @@ public class OVSDBEventHandler extends VTNNeutronUtils {
     }
 
     /**
-     * Read the parameters configured in configuration file(vtn.ini).
+     * Read the parameters configured in configuration file(default.config).
      * @param node instance of Node
      */
     public void getSystemProperties(Node node) {
-        File f = new File(new File(CONFIG_DIR), VTN_INI_NAME);
-        FileInputStream in = null;
-        Properties prop = new Properties();
-        try {
-            in = new FileInputStream(f);
-            prop.load(in);
-            LOG.trace("loaded Integration bridge Configuring details from vtn.ini");
-        } catch (Exception e) {
-            LOG.debug("Exception occurred while reading SystemProperties", e);
-        } finally {
-            if (in != null) {
-                try {
-                    in.close();
-                } catch (Exception e) {
-                    LOG.warn("Exception occurred while closing file", e);
-                }
-                in = null;
-            }
+        LOG.trace("System properties from default config : {},{},{},{}:",
+                  ovsdbBridgeName, ovsdbPortName, ovsdbProtocol, ovsdbFailMode);
+        integrationBridgeName = ovsdbBridgeName;
+        if (integrationBridgeName == null) {
+            integrationBridgeName = DEFAULT_INTEGRATION_BRIDGENAME;
+        }
+        portname = ovsdbPortName;
+        if (portname == null) {
+            portname = DEFAULT_PORTNAME;
+        }
+        failmode = ovsdbFailMode;
+        if (failmode == null) {
+            failmode = DEFAULT_FAILMODE;
+        }
+        protocols = ovsdbProtocol;
+        if (protocols == null) {
+            protocols = DEFAULT_PROTOCOLS;
         }
-        integrationBridgeName =
-            prop.getProperty(CONFIG_INTEGRATION_BRIDGENAME,
-                             DEFAULT_INTEGRATION_BRIDGENAME);
-        failmode = prop.getProperty(CONFIG_FAILMODE, DEFAULT_FAILMODE);
-        protocols = prop.getProperty(CONFIG_PROTOCOLS, DEFAULT_PROTOCOLS);
-        portname = prop.getProperty(CONFIG_PORTNAME, DEFAULT_PORTNAME);
         LOG.trace("System properties values : {},{},{},{}:",
                   integrationBridgeName, failmode, protocols, portname);
         if (null != integrationBridgeName) {
index c68afa7d141f367b7d259d6093fb76f1d92ba973..411b063d13d7f00112a2bca0462514d4ba8b060e 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.vtn.manager.neutron.NeutronProvider;
 
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.vtn.manager.neutron.OVSDBEventHandler;
 
 public class VTNNeutronModule extends AbstractVTNNeutronModule {
     private static final Logger LOG =
@@ -40,8 +41,13 @@ public class VTNNeutronModule extends AbstractVTNNeutronModule {
 
     @Override
     public java.lang.AutoCloseable createInstance() {
+        OVSDBEventHandler.ovsdbPortName = getPortName();
+        OVSDBEventHandler.ovsdbBridgeName = getBridgeName();
+        OVSDBEventHandler.ovsdbProtocol = getProtocol();
+        OVSDBEventHandler.ovsdbFailMode = getFailMode();
         NeutronProvider provider = new NeutronProvider();
         getBrokerDependency().registerProvider(provider);
+
         return provider;
     }
 }
index 0ddafa2b087eaf92053dbb00df21a63ca7a29ec6..91a34d483d872a3873e96020c40ee2e7af7b631a 100644 (file)
@@ -41,6 +41,23 @@ module vtn-neutron {
                     }
                 }
             }
+
+            leaf bridgeName {
+                description "name of the vBridge.";
+                type string;
+            }
+            leaf portName {
+                description "portName of the vBridge.";
+                type string;
+            }
+            leaf protocol {
+                description "protocol of the vBridge.";
+                type string;
+            }
+            leaf failMode {
+                description "failMode of the vBridge.";
+                type string;
+            }
         }
     }
 }