From 0cf2574d1486e0a6e653da3804b6fd6da2e51b1b Mon Sep 17 00:00:00 2001 From: Firmlyzhu Date: Wed, 19 Dec 2018 16:00:15 +0800 Subject: [PATCH] Fix a bug of data read from file in container.py --- src/worker/container.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/worker/container.py b/src/worker/container.py index 9a530fa..af891f4 100755 --- a/src/worker/container.py +++ b/src/worker/container.py @@ -6,6 +6,7 @@ from utils import env, imagemgr from utils.lvmtool import sys_run, check_volume from worker.monitor import Container_Collector, History_Manager import lxc +from utils import model class Container(object): def __init__(self, addr, etcdclient): @@ -320,17 +321,11 @@ IP=%s # list containers in FS_PREFIX/global/... on this host as global def diff_containers(self): [status, localcontainers] = self.list_containers() - globalpath = self.fspath+"/global/users/" - users = os.listdir(globalpath) + containers = model.Container.query.all() globalcontainers = [] - for user in users: - clusters = os.listdir(globalpath+user+"/clusters") - for cluster in clusters: - clusterfile = open(globalpath+user+"/clusters/"+cluster, 'r') - clusterinfo = json.loads(clusterfile.read()) - for container in clusterinfo['containers']: - if container['host'] == self.addr: - globalcontainers.append(container['containername']) + for con in containers: + if con.host == self.addr: + globalcontainers.append(con.containername) both = [] onlylocal = [] onlyglobal = []