From 3b6f139b066fa61df852f480be3a583479c78eb6 Mon Sep 17 00:00:00 2001 From: Zhou Ya Date: Thu, 9 Feb 2017 16:19:19 +0800 Subject: Baremetal Deployment on zte-pod2 JIRA: DAISY-30 Change-Id: Ie34180b9d036797d310f612caa189b0a06efb732 Signed-off-by: Zhou Ya --- deploy/check_os_progress.sh | 50 ++++++++- .../bm_environment/zte-baremetal1/deploy.yml | 23 ++++ .../bm_environment/zte-baremetal1/network.yml | 59 +++++++++++ .../config/vm_environment/zte-virtual1/deploy.yml | 25 ++--- .../config/vm_environment/zte-virtual1/network.yml | 118 ++++++++++----------- deploy/get_para_from_deploy.py | 19 ++-- deploy/tempest.py | 41 ++++--- 7 files changed, 240 insertions(+), 95 deletions(-) create mode 100644 deploy/config/bm_environment/zte-baremetal1/deploy.yml create mode 100644 deploy/config/bm_environment/zte-baremetal1/network.yml mode change 100755 => 100644 deploy/get_para_from_deploy.py mode change 100755 => 100644 deploy/tempest.py (limited to 'deploy') diff --git a/deploy/check_os_progress.sh b/deploy/check_os_progress.sh index bf44fe28..abbd7e5a 100755 --- a/deploy/check_os_progress.sh +++ b/deploy/check_os_progress.sh @@ -1,20 +1,62 @@ #!/bin/bash +usage() +{ + cat << EOF +USAGE: `basename $0` [-d deploy_env] [-n hosts_num] + +OPTIONS: + -d deploy environment of daisy(0:virtual or 1:baremetal) + -n target node numbers + +EXAMPLE: + sudo `basename $0` -d 1 -n 5 +EOF +} + +while getopts "d:n:h" OPTION +do + case $OPTION in + d) + deploy_env=${OPTARG} + ;; + n) + hosts_num=${OPTARG} + ;; + h) + usage + exit 0 + ;; + *) + echo "${OPTION} is not a valid argument" + usage + exit 0 + ;; + esac +done + source /root/daisyrc_admin cluster_id=`daisy cluster-list | awk -F "|" '{print $2}' | sed -n '4p'` -daisy install $cluster_id --skip-pxe-ipmi true +skip=false +if [ $deploy_env == 0 ];then + skip=true +fi + +echo "run daisy install command" +daisy install $cluster_id --skip-pxe-ipmi $skip + echo "check os installing progress..." while true; do os_install_active=`daisy host-list --cluster-id $cluster_id | awk -F "|" '{print $8}' | grep -c "active" ` os_install_failed=`daisy host-list --cluster-id $cluster_id | awk -F "|" '{print $8}' | grep -c "install-failed" ` - if [ $os_install_active -eq 1 ]; then + if [ $os_install_active -eq $hosts_num ]; then echo "os installing successful ..." break elif [ $os_install_failed -gt 0 ]; then echo "os installing have failed..." exit 1 else - progress=`daisy host-list --cluster-id $cluster_id |grep DISCOVERY_SUCCESSFUL |awk -F "|" '{print $7}'|sed s/[[:space:]]//g` - echo "os in installing, the progress is $progress%" + progress=`daisy host-list --cluster-id $cluster_id |grep DISCOVERY_SUCCESSFUL |awk -F "|" '{print $7}'|sed s/[[:space:]]//g|sed ':a;N;$ s/\n/ /g;ba'` + echo "os in installing, the progress of each node is $progress%" sleep 10 fi done diff --git a/deploy/config/bm_environment/zte-baremetal1/deploy.yml b/deploy/config/bm_environment/zte-baremetal1/deploy.yml new file mode 100644 index 00000000..eafff5fd --- /dev/null +++ b/deploy/config/bm_environment/zte-baremetal1/deploy.yml @@ -0,0 +1,23 @@ +hosts: +- name: 'controller01' + roles: + - 'CONTROLLER_LB' +- name: 'controller02' + roles: + - 'CONTROLLER_LB' +- name: 'controller03' + roles: + - 'CONTROLLER_LB' +- name: 'computer01' + roles: + - 'COMPUTER' +- name: 'computer02' + roles: + - 'COMPUTER' +disks: + daisy: 50 + controller: 50 + compute: 50 +daisy_passwd: 'r00tme' +daisy_ip: '10.20.7.3' +daisy_gateway: '10.20.7.1' diff --git a/deploy/config/bm_environment/zte-baremetal1/network.yml b/deploy/config/bm_environment/zte-baremetal1/network.yml new file mode 100644 index 00000000..53f21d90 --- /dev/null +++ b/deploy/config/bm_environment/zte-baremetal1/network.yml @@ -0,0 +1,59 @@ +############################################################################## +# Copyright (c) 2017 ZTE Coreporation and others. +# hu.zhijiang@zte.com.cn +# sun.jing22@zte.com.cn +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +network-config-metadata: + title: 'zte-bm-deploy network config' + version: '0.1' + created: 'Mon Oct 31 2016' + comment: +networks: + - cidr: '10.20.7.0/24' + gateway: '10.20.7.1' + ip_ranges: + - 'start': '10.20.7.4' + 'end': '10.20.7.11' + name: 'MANAGEMENT' + - cidr: '10.20.7.0/24' + gateway: '10.20.7.1' + ip_ranges: + - start: '10.20.7.4' + end: '10.20.7.11' + name: 'STORAGE' + - cidr: '172.10.101.0/24' + gateway: '172.10.101.0' + ip_ranges: + - 'start': '172.10.101.1' + 'end': '172.10.101.10' + 'name': 'EXTERNAL' + - cidr: '10.20.7.0/24' + gateway: '10.20.7.1' + ip_ranges: + - 'start': '10.20.7.4' + 'end': '10.20.7.11' + name: 'PUBLICAPI' + - cidr: '10.20.7.0/24' + gateway: '10.20.7.1' + ip_ranges: + - 'start': '10.20.7.4' + 'end': '10.20.7.11' + name: 'TENANT' +interfaces: + - name: 'EXTERNAL' + interface: 'ens12f1' + - name: 'MANAGEMENT' + interface: 'ens4f0' + - name: 'PUBLICAPI' + interface: 'ens4f0' + - name: 'STORAGE' + interface: 'ens4f0' + - name: 'TENANT' + interface: 'ens4f0' +internal_vip: '10.20.7.12' +public_vip: '10.20.7.12' diff --git a/deploy/config/vm_environment/zte-virtual1/deploy.yml b/deploy/config/vm_environment/zte-virtual1/deploy.yml index b0949476..1bf254f5 100644 --- a/deploy/config/vm_environment/zte-virtual1/deploy.yml +++ b/deploy/config/vm_environment/zte-virtual1/deploy.yml @@ -1,12 +1,13 @@ -hosts: -- name: 'all_in_one' - roles: - - 'CONTROLLER_LB' - - 'COMPUTER' -disks: - daisy: 50 - controller: 50 - compute: 50 -daisy_passwd: 'r00tme' -daisy_ip: '10.20.11.2' -daisy_gateway: '10.20.11.1' +hosts: +- name: 'all_in_one' + roles: + - 'CONTROLLER_LB' + - 'COMPUTER' +disks: + daisy: 50 + controller: 50 + compute: 50 +daisy_passwd: 'r00tme' +daisy_ip: '10.20.11.2' +daisy_gateway: '10.20.11.1' +deploy_env: 'virtual' \ No newline at end of file diff --git a/deploy/config/vm_environment/zte-virtual1/network.yml b/deploy/config/vm_environment/zte-virtual1/network.yml index 36863882..7d746be6 100644 --- a/deploy/config/vm_environment/zte-virtual1/network.yml +++ b/deploy/config/vm_environment/zte-virtual1/network.yml @@ -1,59 +1,59 @@ -############################################################################## -# Copyright (c) 2016 ZTE Coreporation and others. -# hu.zhijiang@zte.com.cn -# sun.jing22@zte.com.cn -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -network-config-metadata: - title: 'zte-virtual1 network config' - version: '0.1' - created: 'Mon Oct 31 2016' - comment: -networks: - - cidr: '10.20.11.0/24' - gateway: '10.20.11.1' - ip_ranges: - - 'start': '10.20.11.3' - 'end': '10.20.11.10' - name: 'MANAGEMENT' - - cidr: '10.20.11.0/24' - gateway: '10.20.11.1' - ip_ranges: - - start: '10.20.11.3' - end: '10.20.11.10' - name: 'STORAGE' - - cidr: '172.10.101.0/24' - gateway: '172.10.101.0' - ip_ranges: - - 'start': '172.10.101.1' - 'end': '172.10.101.10' - 'name': 'EXTERNAL' - - cidr: '10.20.11.0/24' - gateway: '10.20.11.1' - ip_ranges: - - 'start': '10.20.11.3' - 'end': '10.20.11.10' - name: 'PUBLICAPI' - - cidr: '10.20.11.0/24' - gateway: '10.20.11.1' - ip_ranges: - - 'start': '10.20.11.3' - 'end': '10.20.11.10' - name: 'TENANT' -interfaces: - - name: 'EXTERNAL' - interface: 'ens8' - - name: 'MANAGEMENT' - interface: 'ens3' - - name: 'PUBLICAPI' - interface: 'ens3' - - name: 'STORAGE' - interface: 'ens3' - - name: 'TENANT' - interface: 'ens3' -internal_vip: '10.20.11.11' -public_vip: '10.20.11.11' +############################################################################## +# Copyright (c) 2016 ZTE Coreporation and others. +# hu.zhijiang@zte.com.cn +# sun.jing22@zte.com.cn +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +network-config-metadata: + title: 'zte-virtual1 network config' + version: '0.1' + created: 'Mon Oct 31 2016' + comment: +networks: + - cidr: '10.20.11.0/24' + gateway: '10.20.11.1' + ip_ranges: + - 'start': '10.20.11.3' + 'end': '10.20.11.10' + name: 'MANAGEMENT' + - cidr: '10.20.11.0/24' + gateway: '10.20.11.1' + ip_ranges: + - start: '10.20.11.3' + end: '10.20.11.10' + name: 'STORAGE' + - cidr: '172.10.101.0/24' + gateway: '172.10.101.0' + ip_ranges: + - 'start': '172.10.101.1' + 'end': '172.10.101.10' + 'name': 'EXTERNAL' + - cidr: '10.20.11.0/24' + gateway: '10.20.11.1' + ip_ranges: + - 'start': '10.20.11.3' + 'end': '10.20.11.10' + name: 'PUBLICAPI' + - cidr: '10.20.11.0/24' + gateway: '10.20.11.1' + ip_ranges: + - 'start': '10.20.11.3' + 'end': '10.20.11.10' + name: 'TENANT' +interfaces: + - name: 'EXTERNAL' + interface: 'ens8' + - name: 'MANAGEMENT' + interface: 'ens3' + - name: 'PUBLICAPI' + interface: 'ens3' + - name: 'STORAGE' + interface: 'ens3' + - name: 'TENANT' + interface: 'ens3' +internal_vip: '10.20.11.11' +public_vip: '10.20.11.11' diff --git a/deploy/get_para_from_deploy.py b/deploy/get_para_from_deploy.py old mode 100755 new mode 100644 index d142af3a..c75ba07b --- a/deploy/get_para_from_deploy.py +++ b/deploy/get_para_from_deploy.py @@ -32,19 +32,26 @@ def get_yml_para(dha_file): daisy_passwd = data.get("daisy_passwd", "") daisy_ip = data.get("daisy_ip", "") daisy_gateway = data.get("daisy_gateway", "") + daisy_target_node = data.get("hosts", "") + hosts_num = len(daisy_target_node) return daisyserver_size, controller_node_size,\ - compute_node_size, daisy_passwd, daisy_ip, daisy_gateway + compute_node_size, daisy_passwd, daisy_ip, daisy_gateway,\ + hosts_num def get_conf_from_deploy(): conf = cfg.ConfigOpts() parse(conf, sys.argv[1:]) daisyserver_size, controller_node_size, compute_node_size,\ - daisy_passwd, daisy_ip, daisy_gateway = get_yml_para(conf['dha']) - print "{ip} {passwd} -s {size} -g {gateway}".format(passwd=daisy_passwd, - size=daisyserver_size, - ip=daisy_ip, - gateway=daisy_gateway) + daisy_passwd, daisy_ip, daisy_gateway,\ + hosts_num = get_yml_para(conf['dha']) + print "{hosts_num} {ip} {passwd} -s {size} -g {gateway}".format( + hosts_num=hosts_num, + passwd=daisy_passwd, + size=daisyserver_size, + ip=daisy_ip, + gateway=daisy_gateway) + if __name__ == "__main__": get_conf_from_deploy() diff --git a/deploy/tempest.py b/deploy/tempest.py old mode 100755 new mode 100644 index 3459cb07..34af9b5a --- a/deploy/tempest.py +++ b/deploy/tempest.py @@ -31,6 +31,8 @@ _CLI_OPTS = [ help='Config cluster'), cfg.StrOpt('host', help='Config host'), + cfg.StrOpt('env', + help='deploy environment'), ] @@ -82,9 +84,10 @@ def prepare_install(): hosts_info = get_hosts() cluster_info = get_cluster() cluster_id = cluster_info.id - add_hosts_interface(cluster_id, hosts_info, + add_hosts_interface(cluster_id, hosts_info, hosts_name, host_interface_map, vip) - build_pxe_for_os(cluster_id) + if conf['env'] and conf['env'] == 0: + build_pxe_for_os(cluster_id) except Exception: print("Deploy failed!!!.%s." % traceback.format_exc()) else: @@ -143,15 +146,16 @@ def get_cluster(): return cluster_info -def add_hosts_interface(cluster_id, hosts_info, host_interface_map, +def add_hosts_interface(cluster_id, hosts_info, hosts_name, host_interface_map, vip): - for host in hosts_info: + for host_name, host in zip(hosts_name, hosts_info): host = host.to_dict() host['cluster'] = cluster_id for interface in host['interfaces']: interface_name = interface['name'] - interface['assigned_networks'] = \ - host_interface_map[interface_name] + if interface_name in host_interface_map: + interface['assigned_networks'] = \ + host_interface_map[interface_name] pathlist = os.listdir(iso_path) for filename in pathlist: if filename.endswith('iso'): @@ -160,10 +164,10 @@ def add_hosts_interface(cluster_id, hosts_info, host_interface_map, print("do not have os iso file in /var/lib/daisy/kolla/.") client.hosts.update(host['id'], **host) print("update role...") - add_host_role(cluster_id, host['id'], host['name'], vip) + add_host_role(cluster_id, host['id'], host_name, host['name'], vip) -def add_host_role(cluster_id, host_id, host_name, vip): +def add_host_role(cluster_id, host_id, host_exp_name, host_real_name, vip): role_meta = {'filters': {'cluster_id': cluster_id}} role_list_generator = client.roles.list(**role_meta) role_list = [role for role in role_list_generator] @@ -171,12 +175,21 @@ def add_host_role(cluster_id, host_id, host_name, vip): role.name == "CONTROLLER_LB"][0] computer_role_id = [role.id for role in role_list if role.name == "COMPUTER"][0] - role_lb_update_meta = {'nodes': [host_id], - 'cluster_id': cluster_id, 'vip': vip} - client.roles.update(lb_role_id, **role_lb_update_meta) - role_computer_update_meta = {'nodes': [host_id], - 'cluster_id': cluster_id} - client.roles.update(computer_role_id, **role_computer_update_meta) + if host_exp_name in ['all_in_one']: + role_lb_update_meta = {'nodes': [host_id], + 'cluster_id': cluster_id, 'vip': vip} + client.roles.update(lb_role_id, **role_lb_update_meta) + role_computer_update_meta = {'nodes': [host_id], + 'cluster_id': cluster_id} + client.roles.update(computer_role_id, **role_computer_update_meta) + if host_exp_name in ['controller01', 'controller02', 'controller03']: + role_lb_update_meta = {'nodes': [host_id], + 'cluster_id': cluster_id, 'vip': vip} + client.roles.update(lb_role_id, **role_lb_update_meta) + if host_exp_name in ['computer01', 'computer02']: + role_computer_update_meta = {'nodes': [host_id], + 'cluster_id': cluster_id} + client.roles.update(computer_role_id, **role_computer_update_meta) if __name__ == "__main__": -- cgit 1.2.3-korg