diff options
author | carey.xu <carey.xuhan@huawei.com> | 2016-01-04 15:21:16 +0800 |
---|---|---|
committer | carey.xu <carey.xuhan@huawei.com> | 2016-01-04 16:30:17 +0800 |
commit | 0b4b86d37c6fd0946737d59bf1093398dde09670 (patch) | |
tree | 32fdc0152fb754cf145391c6f396cd9a26ef97d5 /deploy | |
parent | 021013f290a360493960d8039d8e0fcc6a5883a5 (diff) |
improve: display ansible install log on client side
JIRA: COMPASS-219
Change-Id: Id134c312a25a48ee32ab8755def35b8041f47f62
Signed-off-by: carey.xu <carey.xuhan@huawei.com>
Diffstat (limited to 'deploy')
-rw-r--r-- | deploy/client.py | 37 | ||||
-rwxr-xr-x | deploy/deploy_host.sh | 4 |
2 files changed, 32 insertions, 9 deletions
diff --git a/deploy/client.py b/deploy/client.py index b9cfd7fe..9bb0c5ed 100644 --- a/deploy/client.py +++ b/deploy/client.py @@ -25,6 +25,7 @@ import netaddr import requests import json import itertools +import threading from collections import defaultdict from restful import Client @@ -231,6 +232,9 @@ opts = [ cfg.StrOpt('deploy_flag', help='deploy flag', default='deploy'), + cfg.StrOpt('rsa_file', + help='ssh rsa key file', + default=''), ] CONF.register_cli_opts(opts) @@ -836,31 +840,40 @@ class CompassClient(object): deployment_timeout = time.time() + 60 * float( CONF.deployment_timeout) - current_time = time.time() + current_time = time.time deployment_failed = True - while current_time < deployment_timeout: + while current_time() < deployment_timeout: status, cluster_state = self.client.get_cluster_state(cluster_id) - LOG.info( - 'get cluster %s state status %s: %s', - cluster_id, status, cluster_state - ) if not self.is_ok(status): raise RuntimeError("can not get cluster state") if cluster_state['state'] in ['UNINITIALIZED', 'INITIALIZED']: - if current_time >= action_timeout: + if current_time() >= action_timeout: deployment_failed = True + LOG.info( + 'get cluster %s state status %s: %s, successful', + cluster_id, status, cluster_state + ) break else: continue elif cluster_state['state'] == 'SUCCESSFUL': deployment_failed = False + LOG.info( + 'get cluster %s state status %s: %s, successful', + cluster_id, status, cluster_state + ) break elif cluster_state['state'] == 'ERROR': deployment_failed = True + LOG.info( + 'get cluster %s state status %s: %s, error', + cluster_id, status, cluster_state + ) break + kill_print_proc() if deployment_failed: raise RuntimeError("deploy cluster failed") @@ -886,6 +899,12 @@ class CompassClient(object): raise Exception(msg) +def print_ansible_log(): + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i %s root@192.168.200.2 \ + 'while ! tail -f /var/ansible/run/openstack_liberty-opnfv2/ansible.log 2>/dev/null; do :; sleep 1; done'" % CONF.rsa_file) + +def kill_print_proc(): + os.system("ps aux|grep -v grep|grep -E 'ssh.+root@192.168.200.2'|awk '{print $2}'|xargs kill -9") def deploy(): client = CompassClient() @@ -907,7 +926,9 @@ def deploy(): client.set_all_hosts_roles(cluster_id) client.deploy_clusters(cluster_id) - client.get_installing_progress(cluster_id) + threading.Thread(target=client.get_installing_progress, args=(cluster_id,)).start() + LOG.info("compass OS installtion is begin") + print_ansible_log() client.check_dashboard_links(cluster_id) def redeploy(): diff --git a/deploy/deploy_host.sh b/deploy/deploy_host.sh index b87a74d3..f8feacbf 100755 --- a/deploy/deploy_host.sh +++ b/deploy/deploy_host.sh @@ -1,4 +1,5 @@ #!/bin/bash +rsa_file=$compass_vm_dir/boot.rsa function deploy_host(){ ssh $ssh_args root@${MGMT_IP} mkdir -p /opt/compass/bin/ansible_callbacks @@ -30,6 +31,7 @@ function deploy_host(){ --machines=${machines//\'} --switch_credential="${SWITCH_CREDENTIAL}" --deploy_type="${TYPE}" \ --deployment_timeout="${DEPLOYMENT_TIMEOUT}" --${POLL_SWITCHES_FLAG} --dashboard_url="${DASHBOARD_URL}" \ --cluster_vip="${VIP}" --network_cfg="$NETWORK" --neutron_cfg="$NEUTRON" \ - --enable_secgroup="${ENABLE_SECGROUP}" --enable_fwaas="${ENABLE_FWAAS}" --enable_vpnaas="${ENABLE_VPNAAS}" + --enable_secgroup="${ENABLE_SECGROUP}" --enable_fwaas="${ENABLE_FWAAS}" \ + --rsa_file="$rsa_file" --enable_vpnaas="${ENABLE_VPNAAS}" } |