From 8a67ca0851e4af20791c74d7f6595f631f7130b4 Mon Sep 17 00:00:00 2001 From: Bin Yang Date: Wed, 3 Apr 2019 09:21:26 +0000 Subject: Fix capacity_check error Change-Id: Ib317e2a655d571b7cfefc1dbe8631ed77acc4b81 Issue-ID: MULTICLOUD-542 Signed-off-by: Bin Yang --- share/starlingx_base/resource/capacity.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'share/starlingx_base/resource') diff --git a/share/starlingx_base/resource/capacity.py b/share/starlingx_base/resource/capacity.py index fc926d00..46e5eba5 100644 --- a/share/starlingx_base/resource/capacity.py +++ b/share/starlingx_base/resource/capacity.py @@ -66,11 +66,15 @@ class CapacityCheck(newton_capacity.CapacityCheck): vimAzCacheKey = "cap_azlist_" + vimid vimAzListCacheStr = cache.get(vimAzCacheKey) vimAzListCache = json.loads(vimAzListCacheStr) if vimAzListCacheStr else [] + azCapInfoList = [] for azName in vimAzListCache: azCapCacheKey = "cap_" + vimid + "_" + azName azCapInfoCacheStr = cache.get(azCapCacheKey) + if not azCapInfoCacheStr: + continue azCapInfoCache = json.loads(azCapInfoCacheStr) if azCapInfoCacheStr else None + azCapInfo = {} azCapInfo["availability-zone-name"] = azName azCapInfo["vCPUAvail"] = azCapInfoCache.get("vcpus", 0) + azCapInfoCache.get("vcpus_used", 0) azCapInfo["vCPUTotal"] = azCapInfoCache.get("vcpus", 0) @@ -78,8 +82,9 @@ class CapacityCheck(newton_capacity.CapacityCheck): azCapInfo["MemoryTotal"] = azCapInfoCache.get("vcpus", 0) azCapInfo["StorageAvail"] = azCapInfoCache.get("vcpus", 0) azCapInfo["StorageTotal"] = azCapInfoCache.get("vcpus", 0) + azCapInfoList.append(azCapInfo) - return azCapInfo + return azCapInfoList except Exception as e: return azCapInfo pass -- cgit 1.2.3-korg