diff options
author | zhouya <zhou.ya@zte.com.cn> | 2017-07-31 13:21:59 +0800 |
---|---|---|
committer | zhouya <zhou.ya@zte.com.cn> | 2017-07-31 13:43:55 +0800 |
commit | e47fc2d62d07633c1883253d42f8e2cade35e868 (patch) | |
tree | 58a3642fcc38c22f80b7fa7b2ca5f5ff94aa0e4b | |
parent | d0b28ef6d7cb12e1b70841991ff321cd6e7c1edf (diff) |
use only one file get_conf.py to get configuration data from deploy.yml
just move the code from get_para_from_deploy to get_conf file
no functionality change.
Change-Id: I86aa1325ff37cb2ae0784c9487e62e95cc23f644
Signed-off-by: zhouya <zhou.ya@zte.com.cn>
-rwxr-xr-x | ci/deploy/deploy.sh | 2 | ||||
-rwxr-xr-x | deploy/get_conf.py | 46 | ||||
-rw-r--r-- | deploy/get_para_from_deploy.py | 57 |
3 files changed, 47 insertions, 58 deletions
diff --git a/ci/deploy/deploy.sh b/ci/deploy/deploy.sh index 2451c3f2..bb6418df 100755 --- a/ci/deploy/deploy.sh +++ b/ci/deploy/deploy.sh @@ -165,7 +165,7 @@ done BMDEPLOY_DAISY_SERVER_NET=$WORKSPACE/templates/physical_environment/networks/daisy.xml BMDEPLOY_DAISY_SERVER_VM=$WORKSPACE/templates/physical_environment/vms/daisy.xml -PARAS_FROM_DEPLOY=`python $WORKSPACE/deploy/get_para_from_deploy.py --dha $DHA_CONF` +PARAS_FROM_DEPLOY=`python $WORKSPACE/deploy/get_conf.py --dha $DHA_CONF` TARGET_HOSTS_NUM=`echo $PARAS_FROM_DEPLOY | cut -d " " -f 1` DAISY_IP=`echo $PARAS_FROM_DEPLOY | cut -d " " -f 2` DAISY_PASSWD=`echo $PARAS_FROM_DEPLOY | cut -d " " -f 3` diff --git a/deploy/get_conf.py b/deploy/get_conf.py index 37da2beb..ca9e2cf6 100755 --- a/deploy/get_conf.py +++ b/deploy/get_conf.py @@ -9,6 +9,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## import yaml +from oslo_config import cfg +import sys + +_CLI_OPTS = [ + cfg.StrOpt('dha', + help='The dha file path'), +] def init(file): @@ -96,3 +103,42 @@ def config(dha_file, network_file): data = init(network_file) network_map, vip, interface_map = network_config_parse(data, network_file) return interface_map, hosts_name, network_map, vip, ceph_disk_name + + +def parse(conf, args): + conf.register_cli_opts(_CLI_OPTS) + conf(args=args) + + +def get_yml_para(dha_file): + data = init(dha_file) + disks = data.get("disks", 0) + daisyserver_size = disks.get("daisy", 0) + controller_node_size = disks.get("controller", 0) + compute_node_size = disks.get("compute", 0) + 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,\ + 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,\ + 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/get_para_from_deploy.py b/deploy/get_para_from_deploy.py deleted file mode 100644 index c75ba07b..00000000 --- a/deploy/get_para_from_deploy.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/python -############################################################################## -# Copyright (c) 2016 ZTE Coreporation and others. -# hu.zhijiang@zte.com.cn -# lu.yao135@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 -############################################################################## -import get_conf -from oslo_config import cfg -import sys - -_CLI_OPTS = [ - cfg.StrOpt('dha', - help='The dha file path'), -] - - -def parse(conf, args): - conf.register_cli_opts(_CLI_OPTS) - conf(args=args) - - -def get_yml_para(dha_file): - data = get_conf.init(dha_file) - disks = data.get("disks", 0) - daisyserver_size = disks.get("daisy", 0) - controller_node_size = disks.get("controller", 0) - compute_node_size = disks.get("compute", 0) - 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,\ - 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,\ - 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() |