Improvement: reset compute nodes for opencontrail 51/10051/7
authorchenshuai@huawei.com <chenshuai@huawei.com>
Tue, 16 Feb 2016 10:29:55 +0000 (18:29 +0800)
committerchenshuai@huawei.com <chenshuai@huawei.com>
Wed, 17 Feb 2016 08:26:31 +0000 (16:26 +0800)
JIRA: COMPASS-317

Change-Id: I27b6bb3aa8707f02a51951eed83646a78dafc841
Signed-off-by: chenshuai@huawei.com <chenshuai@huawei.com>
deploy.sh
deploy/conf/hardware_environment/huawei-us-deploy-bare-1/os-ocl-nofeature-ha.yml
deploy/conf/hardware_environment/intel-pod8/os-ocl-nofeature-ha.yml
deploy/conf/vm_environment/os-ocl-nofeature-ha.yml
deploy/deploy_host.sh
deploy/launch.sh
deploy/reset_compute.py [new file with mode: 0644]

index 8e362b0..a596896 100755 (executable)
--- a/deploy.sh
+++ b/deploy.sh
@@ -17,3 +17,4 @@ if [[ -z $DEPLOY_COMPASS && -z $DEPLOY_HOST && -z $REDEPLOY_HOST ]]; then
 fi
 
 $COMPASS_DIR/deploy/launch.sh $*
+
index 7606687..0492efd 100644 (file)
@@ -16,7 +16,7 @@ hosts:
     roles:
       - controller
       - ha
-      - open-contrail
+      - opencontrail
 
   - name: host2
     mac: 'D8:49:0B:DA:5A:B7'
@@ -25,9 +25,7 @@ hosts:
     ipmiIp: 172.16.130.27
     ipmiPass: huawei@123
     roles:
-      - controller
-      - ha
-      - open-contrail
+      - compute
 
   - name: host3
     mac: 'D8:49:0B:DA:2A:28'
@@ -36,9 +34,7 @@ hosts:
     ipmiIp: 172.16.130.29
     ipmiPass: Huawei@123
     roles:
-      - controller
-      - ha
-      - open-contrail
+      - compute
 
   - name: host4
     mac: 'D8:49:0B:DA:5B:5D'
@@ -48,7 +44,6 @@ hosts:
     ipmiPass: Huawei@123
     roles:
       - compute
-      - open-contrail
 
   - name: host5
     mac: 'D8:49:0B:DA:56:85'
@@ -58,5 +53,4 @@ hosts:
     ipmiPass: Huawei@123
     roles:
       - compute
-      - open-contrail
 
index 75872ef..7892a0b 100644 (file)
@@ -17,7 +17,7 @@ hosts:
     roles:
       - controller
       - ha
-      - open-contrail
+      - opencontrail
 
   - name: host2
     mac: '00:1E:67:D4:39:B5'
@@ -26,9 +26,7 @@ hosts:
       - eth3: '00:1E:67:C5:52:25'
     ipmiIp: 10.2.117.129
     roles:
-      - controller
-      - ha
-      - open-contrail
+      - compute
 
   - name: host3
     mac: '00:1E:67:D4:31:B2'
@@ -37,9 +35,7 @@ hosts:
       - eth3: '00:1E:67:C1:FA:E1'
     ipmiIp: 10.2.117.131
     roles:
-      - controller
-      - ha
-      - open-contrail
+      - compute
 
   - name: host4
     mac: '00:1E:67:D4:34:67'
@@ -49,7 +45,6 @@ hosts:
     ipmiIp: 10.2.117.133
     roles:
       - compute
-      - open-contrail
 
   - name: host5
     mac: '00:1E:67:D4:38:42'
@@ -59,5 +54,4 @@ hosts:
     ipmiIp: 10.2.117.135
     roles:
       - compute
-      - open-contrail
 
index 5f4890d..bdcada8 100644 (file)
@@ -8,30 +8,24 @@ hosts:
       - ha
       - ceph-adm
       - ceph-mon
-      - open-contrail
+      - opencontrail
 
   - name: host2
     roles:
-      - controller
-      - ha
+      - compute
       - ceph-mon
-      - open-contrail
 
   - name: host3
     roles:
-      - controller
-      - ha
+      - compute
       - ceph-mon
-      - open-contrail
 
   - name: host4
     roles:
       - compute
       - ceph-osd
-      - open-contrail
 
   - name: host5
     roles:
       - compute
       - ceph-osd
-      - open-contrail
index 8274874..306f936 100755 (executable)
@@ -49,5 +49,9 @@ function deploy_host(){
 
     RET=$?
     sleep $((AYNC_TIMEOUT+5))
-    exit $RET
+    if [[ $RET ]]; then
+       /bin/true
+    else
+       /bin/false
+    fi
 }
index 8ee70e4..f9d915b 100755 (executable)
@@ -78,6 +78,14 @@ if [[ "$DEPLOY_HOST" == "true" || $REDEPLOY_HOST == "true" ]]; then
     if ! deploy_host;then
          exit 1
     fi
+    echo $HOST_ROLES
+    echo $TYPE
+    echo $DHA
+    if [[ `echo $HOST_ROLES | grep opencontrail` ]]; then
+        sleep 60
+        python ${COMPASS_DIR}/deploy/reset_compute.py $TYPE $DHA
+        sleep 600
+    fi
 fi
 
 figlet -ctf slant Installation Complete!
diff --git a/deploy/reset_compute.py b/deploy/reset_compute.py
new file mode 100644 (file)
index 0000000..717e883
--- /dev/null
@@ -0,0 +1,59 @@
+import os
+import sys
+import yaml
+
+def exec_cmd(cmd):
+    print cmd
+    os.system(cmd)
+
+def reset_baremetal(dha_info):
+    print "reset_baremetal"
+
+    hosts_info = yaml.load(open(dha_info))
+    #print hosts_info
+
+    ipmiUserDf = hosts_info.get('ipmiUser', 'root')
+    ipmiPassDf = hosts_info.get('ipmiPass', 'Huawei@123')
+    print ipmiUserDf
+    print ipmiPassDf
+
+    hosts_list = hosts_info.get('hosts', [])
+    #print hosts_list
+    
+    for host in hosts_list:
+        print host
+        if ('compute' in host['roles']):
+            ipmiUser = host.get('ipmiUser', ipmiUserDf)
+            ipmiPass = host.get('ipmiPass', ipmiPassDf)
+            ipmiIp = host['ipmiIp']
+            print ipmiUser
+            print ipmiPass
+            print ipmiIp
+            exec_cmd("ipmitool -I lanplus -H %s -U %s -P %s chassis power reset >/dev/null" % (ipmiIp, ipmiUser, ipmiPass))
+
+
+def reset_virtual(dha_info):
+    print "reset_virtual"
+
+    hosts_info = yaml.load(open(dha_info))
+    print hosts_info
+
+    hosts_list = hosts_info.get('hosts', [])
+
+    for host in hosts_list:
+        print host
+        if ('compute' in host['roles']):
+            name = host['name']
+            exec_cmd("virsh destroy %s" % name)
+            exec_cmd("virsh start %s" % name) 
+
+if __name__ == "__main__":
+    deploy_type=sys.argv[1]
+    dha_info=sys.argv[2]
+    print deploy_type
+    print dha_info
+    if (deploy_type == 'baremetal') :
+        reset_baremetal(dha_info)
+    elif (deploy_type == 'virtual') :
+        reset_virtual(dha_info)
+