From 468567824ebdc6a64fb62be4962fd7d75e9c9a20 Mon Sep 17 00:00:00 2001
From: zhouya <zhou.ya@zte.com.cn>
Date: Thu, 16 Mar 2017 09:36:20 +0800
Subject: distinguish virtual and bm deploy

Change-Id: I9fcc4f08283c832d32c22c2195401dd86ecf9dc5
Signed-off-by: zhouya <zhou.ya@zte.com.cn>
---
 ci/deploy/deploy.sh         |  6 ++++--
 deploy/check_os_progress.sh |  7 -------
 deploy/tempest.py           | 29 ++++++++++++++++++++++-------
 3 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/ci/deploy/deploy.sh b/ci/deploy/deploy.sh
index f81afe95..c14c9d8d 100755
--- a/ci/deploy/deploy.sh
+++ b/ci/deploy/deploy.sh
@@ -314,12 +314,14 @@ else
 fi
 
 echo "======prepare host and pxe==========="
-ssh $SSH_PARAS $DAISY_IP "python ${REMOTE_SPACE}/deploy/tempest.py  --dha $DHA --network $NETWORK --host 'yes' --env $IS_BARE"
+ssh $SSH_PARAS $DAISY_IP "python ${REMOTE_SPACE}/deploy/tempest.py  --dha $DHA --network $NETWORK --host 'yes' --isbare $IS_BARE"
 
-echo "======daisy deploy os and openstack==========="
+echo "======daisy virtual-deploy os and openstack==========="
 if [ $IS_BARE == 0 ];then
     virsh destroy all_in_one
     virsh start all_in_one
+    sleep 20
+    ssh $SSH_PARAS $DAISY_IP "python ${REMOTE_SPACE}/deploy/tempest.py  --install 'yes'"
 fi
 
 echo "===========check install progress==========="
diff --git a/deploy/check_os_progress.sh b/deploy/check_os_progress.sh
index bb2b3340..e742467c 100755
--- a/deploy/check_os_progress.sh
+++ b/deploy/check_os_progress.sh
@@ -43,13 +43,6 @@ if [ $deploy_env == 0 ];then
         echo "detail info of host $host_id:"
         daisy host-detail $host_id
     done
-else
-    for host_id in $hosts_id;
-    do
-        echo "update host $host_id ipmi user and passwd"
-        daisy host-update $host_id --ipmi-user zteroot --ipmi-passwd superuser
-    done
-    echo "update all hosts ipmi user and passwd ok!"
 fi
 
 echo "check os installing progress..."
diff --git a/deploy/tempest.py b/deploy/tempest.py
index f01aa77b..6e626c71 100644
--- a/deploy/tempest.py
+++ b/deploy/tempest.py
@@ -31,7 +31,9 @@ _CLI_OPTS = [
                help='Config cluster'),
     cfg.StrOpt('host',
                help='Config host'),
-    cfg.IntOpt('env',
+    cfg.StrOpt('install',
+               help='install daisy'),
+    cfg.IntOpt('isbare',
                help='deploy environment'),
 ]
 
@@ -86,10 +88,14 @@ def prepare_install():
             cluster_id = cluster_info.id
             add_hosts_interface(cluster_id, hosts_info, hosts_name,
                                 host_interface_map, vip)
-            if 'env' in conf and conf['env'] == 0:
-                build_pxe_without_ipmi(cluster_id)
+            if 'isbare' in conf and conf['isbare'] == 0:
+                install_os_for_vm_step1(cluster_id)
             else:
-                build_pxe_with_ipmi(cluster_id)
+                print("daisy baremetal deploy start")
+                install_os_for_bm_oneshot(cluster_id)
+        elif conf['install'] and conf['install'] == 'yes':
+            install_os_for_vm_step2(cluster_id)
+
     except Exception:
         print("Deploy failed!!!.%s." % traceback.format_exc())
     else:
@@ -102,15 +108,22 @@ def build_pxe_for_discover(cluster_id):
     client.install.install(**cluster_meta)
 
 
-def build_pxe_without_ipmi(cluster_id):
+def install_os_for_vm_step1(cluster_id):
     cluster_meta = {'cluster_id': cluster_id,
                     'pxe_only': "true"}
     client.install.install(**cluster_meta)
 
 
-def build_pxe_with_ipmi(cluster_id):
+def install_os_for_bm_oneshot(cluster_id):
+    cluster_meta = {'cluster_id': cluster_id,
+                    'pxe_only': "false",
+                    'skip_pxe_ipmi': "false"}
+    client.install.install(**cluster_meta)
+
+
+def install_os_for_vm_step2(cluster_id):
     cluster_meta = {'cluster_id': cluster_id,
-                    'pxe_only': "false"}
+                    'skip_pxe_ipmi': "true"}
     client.install.install(**cluster_meta)
 
 
@@ -159,6 +172,8 @@ def add_hosts_interface(cluster_id, hosts_info, hosts_name, host_interface_map,
     for host_name, host in zip(hosts_name, hosts_info):
         host = host.to_dict()
         host['cluster'] = cluster_id
+        host['ipmi_user'] = 'zteroot'
+        host['ipmi_passwd'] = 'superuser'
         for interface in host['interfaces']:
             interface_name = interface['name']
             if interface_name in host_interface_map:
-- 
cgit 1.2.3-korg