From 8e98be274ceac4aeced159de66d75f498e3adbdb Mon Sep 17 00:00:00 2001 From: zhongyehong Date: Wed, 24 Apr 2019 22:03:36 +0800 Subject: [PATCH] fix bugs --- src/master/httprest.py | 6 +----- src/master/vclustermgr.py | 6 ++++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/master/httprest.py b/src/master/httprest.py index ffbf567..07447aa 100755 --- a/src/master/httprest.py +++ b/src/master/httprest.py @@ -442,11 +442,7 @@ def migrate_host(user, beans, form): if src_host is None or dst_host_list is None: return json.dumps({'success':'false', 'message': 'src host or dst host list is null'}) - logger.info(str(src_host)) - logger.info(type(dst_host_list)) - logger.info(str(dst_host_list)) - #[status, msg] = G_vclustermgr.migrate_host(src_host, dst_host_list) - status = True + [status, msg] = G_vclustermgr.migrate_host(src_host, dst_host_list) if status: return json.dumps({'success': 'true', 'action': 'migrate_host'}) else: diff --git a/src/master/vclustermgr.py b/src/master/vclustermgr.py index ce2adca..a0cfb7b 100755 --- a/src/master/vclustermgr.py +++ b/src/master/vclustermgr.py @@ -796,7 +796,7 @@ class VclusterMgr(object): prestatus = info['status'] self.stop_cluster(clustername, username) for container in info['containers']: - if container['host'] == src_host: + if not container['host'] == src_host: continue random.shuffle(new_host_list) for new_host in new_host_list: @@ -817,7 +817,9 @@ class VclusterMgr(object): return [True, ""] def migrate_host(self, src_host, new_host_list): - vcluster_list = self.get_all_clusterinfo() + [status, vcluster_list] = self.get_all_clusterinfo() + if not status: + return [False, vcluster_list] auth_key = env.getenv('AUTH_KEY') res = post_to_user("/master/user/groupinfo/", {'auth_key':auth_key}) groups = json.loads(res['groups'])