diff options
author | Xiaohua Zhang <xiaohua.zhang@windriver.com> | 2019-04-10 08:51:19 +0000 |
---|---|---|
committer | Xiaohua Zhang <xiaohua.zhang@windriver.com> | 2019-04-10 09:48:26 +0000 |
commit | 2024bb59b1d4ec20300304aed3a69132b9c082bc (patch) | |
tree | 349a90cd5fc0c64335142c09bd76db86e3d2d7e7 /share/starlingx_base/resource/capacity.py | |
parent | 14132a2c06bc6b6431f5be90cecf303132d94103 (diff) |
Fix bug of AZ cap check
Fix bugs in restcall module
update the status code of workload api
Remove unused event api from lenovo
Change-Id: Iaa16bc3aca42c4583408384c73802ff4debe1b19
Issue-ID: MULTICLOUD-542
Signed-off-by: Xiaohua Zhang <xiaohua.zhang@windriver.com>
Diffstat (limited to 'share/starlingx_base/resource/capacity.py')
-rw-r--r-- | share/starlingx_base/resource/capacity.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/share/starlingx_base/resource/capacity.py b/share/starlingx_base/resource/capacity.py index cbdedaa3..861d4d50 100644 --- a/share/starlingx_base/resource/capacity.py +++ b/share/starlingx_base/resource/capacity.py @@ -67,27 +67,34 @@ class CapacityCheck(newton_capacity.CapacityCheck): # get list of AZ vimAzCacheKey = "cap_azlist_" + vimid vimAzListCacheStr = cache.get(vimAzCacheKey) + self._logger.debug("Found AZ list: %s" % vimAzListCacheStr) vimAzListCache = json.loads(vimAzListCacheStr) if vimAzListCacheStr else [] azCapInfoList = [] for azName in vimAzListCache: azCapCacheKey = "cap_" + vimid + "_" + azName azCapInfoCacheStr = cache.get(azCapCacheKey) + self._logger.debug("Found AZ info: %s, %s" % (azCapCacheKey, azCapInfoCacheStr)) 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) - azCapInfo["MemoryAvail"] = azCapInfoCache.get("vcpus", 0) - azCapInfo["MemoryTotal"] = azCapInfoCache.get("vcpus", 0) - azCapInfo["StorageAvail"] = azCapInfoCache.get("vcpus", 0) - azCapInfo["StorageTotal"] = azCapInfoCache.get("vcpus", 0) + # vcpu ratio: cpu_allocation_ratio=16 by default + azCapInfo["vCPUAvail"] = \ + (azCapInfoCache.get("vcpus", 0) + - azCapInfoCache.get("vcpus_used", 0)) * 16 + azCapInfo["vCPUTotal"] = azCapInfoCache.get("vcpus", 0) * 16 + # mem size in MB + azCapInfo["MemoryAvail"] = azCapInfoCache.get("free_ram_mb", 0) / 1024.0 + azCapInfo["MemoryTotal"] = azCapInfoCache.get("memory_mb", 0) / 1024.0 + azCapInfo["StorageAvail"] = azCapInfoCache.get("free_disk_gb", 0) + azCapInfo["StorageTotal"] = azCapInfoCache.get("local_gb", 0) azCapInfoList.append(azCapInfo) return azCapInfoList except Exception as e: + self._logger.error(traceback.format_exc()) return azCapInfo |