Clarify the config file to dha file 97/11397/1
authorgrakiss <grakiss.wanglei@huawei.com>
Thu, 17 Mar 2016 06:39:36 +0000 (02:39 -0400)
committergrakiss <grakiss.wanglei@huawei.com>
Thu, 17 Mar 2016 06:41:11 +0000 (02:41 -0400)
JIRA:COMPASS-344
  - make it easy

Change-Id: I6e29136670f7a9f75ff90e893eff865d77235b31
Signed-off-by: grakiss <grakiss.wanglei@huawei.com>
deploy/config_parse.py
deploy/network.sh

index 21fe76d..ba677ad 100644 (file)
@@ -34,7 +34,7 @@ def hostroles(s, seq, host=None):
 def hostmacs(s, seq, host=None):
     return host.get('mac', '')
 
-def export_config_file(s, config_file, conf_dir, ofile):
+def export_dha_file(s, dha_file, conf_dir, ofile):
     env = {}
     env.update(s)
     if env.get('hosts', []):
@@ -44,7 +44,7 @@ def export_config_file(s, config_file, conf_dir, ofile):
     env.update({'FLAVOR': s.get('FLAVOR', "cluster")})
     env.update({'HOSTNAMES': hostnames(s, ',')})
     env.update({'HOST_ROLES': hostroles(s, ';')})
-    env.update({'DHA': config_file})
+    env.update({'DHA': dha_file})
 
     value = hostmacs(s, ',')
     if len(value) > 0:
@@ -72,15 +72,15 @@ if __name__ == "__main__":
         print("parameter wrong%d %s" % (len(sys.argv), sys.argv))
         sys.exit(1)
 
-    _, config_file, conf_dir, tmpl_dir, output_dir, output_file = sys.argv
+    _, dha_file, conf_dir, tmpl_dir, output_dir, output_file = sys.argv
 
-    if not os.path.exists(config_file):
-        print("%s is not exist" % config_file)
+    if not os.path.exists(dha_file):
+        print("%s is not exist" % dha_file)
         sys.exit(1)
 
-    data = init(config_file)
+    data = init(dha_file)
 
-    export_config_file(data, config_file, conf_dir, os.path.join(output_dir, output_file))
+    export_dha_file(data, dha_file, conf_dir, os.path.join(output_dir, output_file))
     export_reset_file(data, tmpl_dir, output_dir, os.path.join(output_dir, output_file))
 
     sys.exit(0)
index 67769c9..7e2649c 100755 (executable)
@@ -92,15 +92,23 @@ function setup_nat_net() {
     sudo virsh net-start $net_name
 }
 
+
+function setup_virtual_net() {
+  setup_nat_net install $INSTALL_GW $INSTALL_MASK
+}
+
+function setup_baremetal_net() {
+  if [[ -z $INSTALL_NIC ]]; then
+    exit 1
+  fi
+  setup_bridge_net install $INSTALL_NIC
+}
+
 function create_nets() {
     setup_nat_net mgmt $MGMT_GW $MGMT_MASK $MGMT_IP_START $MGMT_IP_END
 
     # create install network
-    if [[ -n $INSTALL_NIC ]]; then
-        setup_bridge_net install $INSTALL_NIC
-    else
-        setup_nat_net install $INSTALL_GW $INSTALL_MASK
-    fi
+    setup_"$TYPE"_net
 
     # create external network
     setup_bridge_external