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/registration | |
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/registration')
-rw-r--r-- | share/starlingx_base/registration/registration.py | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/share/starlingx_base/registration/registration.py b/share/starlingx_base/registration/registration.py index cf0281f7..dd71c1b4 100644 --- a/share/starlingx_base/registration/registration.py +++ b/share/starlingx_base/registration/registration.py @@ -165,6 +165,7 @@ class RegistryHelper(newton_registration.RegistryHelper): multi_region_discovery = cloud_extra_info.get( "multi-region-discovery", None) if cloud_extra_info else None + sess = None if project_idorname: try: # check if specified with tenant id @@ -406,6 +407,7 @@ class InfraResourceAuditor(newton_registration.RegistryHelper): self._logger.warn("azcap_audit no valid vimid: %s" % vimid) return + sess = None if project_idorname: try: # check if specified with tenant id @@ -459,9 +461,8 @@ class InfraResourceAuditor(newton_registration.RegistryHelper): viminfo, vimid, "availabilityZoneInfo"): az_info = { - 'availability-zone-name': az['zoneName'], - 'operational-status': az['zoneState']['available'] - if az.get('zoneState') else '', + 'availability-zone-name': az.get('zoneName', ""), + 'operational-status': az.get('zoneState', {}).get('available', ""), 'hypervisor-type': '', } # filter out the default az: "internal" and "nova" @@ -480,7 +481,7 @@ class InfraResourceAuditor(newton_registration.RegistryHelper): # Get current cap info of azName azCapCacheKey = "cap_" + vimid + "_" + azName azCapInfoCacheStr = cache.get(azCapCacheKey) - azCapInfoCache = json.loads(azCapInfoCacheStr) if azCapInfoCacheStr else None + azCapInfoCache = json.loads(azCapInfoCacheStr) if azCapInfoCacheStr else {} for psname in pservers_info: psinfo = hypervisors_dict.get(psname, None) @@ -490,7 +491,7 @@ class InfraResourceAuditor(newton_registration.RegistryHelper): # get current pserver cap info psCapInfoCacheKey = "cap_" + vimid + "_" + psname psCapInfoCacheStr = cache.get(psCapInfoCacheKey) - psCapInfoCache = json.loads(psCapInfoCacheStr) if psCapInfoCacheStr else None + psCapInfoCache = json.loads(psCapInfoCacheStr) if psCapInfoCacheStr else {} # compare latest info with cached one vcpu_delta = 0 @@ -523,19 +524,21 @@ class InfraResourceAuditor(newton_registration.RegistryHelper): localstorage_free_delta += psinfo.get("free_disk_gb", 0)\ - psCapInfoCache.get("free_disk_gb", 0) psCapInfoCache["free_disk_gb"] = psinfo.get("free_disk_gb", 0) - pass - # now apply the delta to azCapInfo - azCapInfoCache["vcpus"] = azCapInfoCache.get("vcpus", 0) + vcpu_delta - azCapInfoCache["memory_mb"] = azCapInfoCache.get("memory_mb", 0) + mem_delta - azCapInfoCache["local_gb"] = azCapInfoCache.get("local_gb", 0) + localstorage_delta - azCapInfoCache["vcpus_used"] = azCapInfoCache.get("vcpus_used", 0) + vcpu_used_delta - azCapInfoCache["free_ram_mb"] = azCapInfoCache.get("free_ram_mb", 0) + mem_free_delta - azCapInfoCache["free_disk_gb"] = azCapInfoCache.get("free_disk_gb", 0) + localstorage_free_delta + cache.set(psCapInfoCacheKey, json.dumps(psCapInfoCache), 3600 * 24) + + # now apply the delta to azCapInfo + azCapInfoCache["vcpus"] = azCapInfoCache.get("vcpus", 0) + vcpu_delta + azCapInfoCache["memory_mb"] = azCapInfoCache.get("memory_mb", 0) + mem_delta + azCapInfoCache["local_gb"] = azCapInfoCache.get("local_gb", 0) + localstorage_delta + azCapInfoCache["vcpus_used"] = azCapInfoCache.get("vcpus_used", 0) + vcpu_used_delta + azCapInfoCache["free_ram_mb"] = azCapInfoCache.get("free_ram_mb", 0) + mem_free_delta + azCapInfoCache["free_disk_gb"] = azCapInfoCache.get("free_disk_gb", 0) + localstorage_free_delta + pass # update the cache cache.set(azCapCacheKey, json.dumps(azCapInfoCache), 3600 * 24) - cache.set(vimAzCacheKey, vimAzList, 3600 * 24) + cache.set(vimAzCacheKey, json.dumps(vimAzList), 3600 * 24) except Exception as e: self._logger.error("azcap_audit raise exception: %s" % e) pass |