diff --git a/dsms_deploy/dsms-deploy.py b/dsms_deploy/dsms-deploy.py index bf237ab8f9b39472aaa8741bf66fb5b5246f7ab3..5f974f207af1956d932cfafc55afcaede4910666 100755 --- a/dsms_deploy/dsms-deploy.py +++ b/dsms_deploy/dsms-deploy.py @@ -475,7 +475,15 @@ def configure_cluster(nodes): allow_agent=False, look_for_keys=False) logger.info(f"set {ip} hostname to {hostname}") command = f"hostnamectl set-hostname {hostname}" - client.exec_command(command) + stdin, stdout, stderr = client.exec_command(command) + exit_code = stdout.channel.recv_exit_status() + if exit_code == 0: + logger.info(f"{ip} set {hostname} success") + else: + for line in stderr: + error_message = io.StringIO() + error_message.write(line) + raise Exception(f'{ip} set {hostname} failed,{error_message.getvalue()}') # Add all hostnames and IPs to /etc/hosts for s in nodes.values(): @@ -695,14 +703,14 @@ def command_remove_node(args): def command_rm_cluster(args): # Removing the dsms-storage cluster and uninstall package logger.info('Removing the dsms-storage cluster...') - nodes = read_cluster_conf(DEPLOY_PACKAGE + '/' + CLUSTER_CONF) + cluster_nodes = read_cluster_conf(DEPLOY_PACKAGE + '/' + CLUSTER_CONF) + leader = cluster_nodes.get(LEADER_NODE) - for node in nodes.values(): + for node in cluster_nodes.values(): logger.info(f'Starting remove node: {node.hostname}') - run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f'ceph-deploy purge {node.hostname}') - run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f'ceph-deploy purgedata {node.hostname}') - run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f'rm -rf {INIT_DIR}/*') - run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f'rm -rf {DEPLOY_PACKAGE}/*') + run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, f'ceph-deploy purge {node.hostname}') + run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, f'ceph-deploy purgedata {node.hostname}') + run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, f'rm -rf {INIT_DIR}/*') logger.info('Removed the dsms-storage cluster success') @@ -762,7 +770,8 @@ if __name__ == '__main__': if not av: sys.stderr.write('No command specified; pass -h or --help for usage\n') sys.exit(1) - # dsms_require_root() + + dsms_require_root() # init log if not os.path.exists(LOG_DIR):