diff options
author | chenshuai@huawei.com <chenshuai@huawei.com> | 2016-02-16 18:29:55 +0800 |
---|---|---|
committer | chenshuai@huawei.com <chenshuai@huawei.com> | 2016-02-17 16:26:31 +0800 |
commit | b67c6b64b8e2c08f40051adf5a839241e78dca7d (patch) | |
tree | 975c0d2ee62087f850ff09b60c014870afd1b74e /deploy/reset_compute.py | |
parent | 00ba12cbc900cb1cb38bee938544cc95583ab416 (diff) |
Improvement: reset compute nodes for opencontrail
JIRA: COMPASS-317
Change-Id: I27b6bb3aa8707f02a51951eed83646a78dafc841
Signed-off-by: chenshuai@huawei.com <chenshuai@huawei.com>
Diffstat (limited to 'deploy/reset_compute.py')
-rw-r--r-- | deploy/reset_compute.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/deploy/reset_compute.py b/deploy/reset_compute.py new file mode 100644 index 00000000..717e8833 --- /dev/null +++ b/deploy/reset_compute.py @@ -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) + |