summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2019-04-03 09:21:26 +0000
committerBin Yang <bin.yang@windriver.com>2019-04-03 09:24:09 +0000
commit8a67ca0851e4af20791c74d7f6595f631f7130b4 (patch)
tree382f1a7b6b8747df373ddbfa658c32837097e0d2 /share
parent218da6448f00c5d071561186d335f5560138ef19 (diff)
Fix capacity_check error
Change-Id: Ib317e2a655d571b7cfefc1dbe8631ed77acc4b81 Issue-ID: MULTICLOUD-542 Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'share')
-rw-r--r--share/starlingx_base/resource/capacity.py7
1 files changed, 6 insertions, 1 deletions
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