summaryrefslogtreecommitdiffstats
path: root/share/starlingx_base
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2020-03-25 09:28:25 +0800
committerBin Yang <bin.yang@windriver.com>2020-03-25 09:51:46 +0800
commited01f456ac1abc0b6ecff90e846d9b54e4172c88 (patch)
treebad9b663377454d8cb776b06d0cded3c189e2845 /share/starlingx_base
parent6d5abf915fcce40e23469d9dbd2bdedf411cd899 (diff)
Disable Resource Capacity audition by default
Allow user to enable it by setting capacity_auditor_enabled:true Fix esr-system-info-id updating issue Issue-ID: MULTICLOUD-1038 Change-Id: I734f7ce614787a04e37b8707ed9be3675c5db629 Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'share/starlingx_base')
-rw-r--r--share/starlingx_base/registration/registration.py81
1 files changed, 47 insertions, 34 deletions
diff --git a/share/starlingx_base/registration/registration.py b/share/starlingx_base/registration/registration.py
index 9fb0f57d..58d1c12d 100644
--- a/share/starlingx_base/registration/registration.py
+++ b/share/starlingx_base/registration/registration.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2017-2018 Wind River Systems, Inc.
+# Copyright (c) 2017-2020 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -51,23 +51,27 @@ class APIv0Registry(newton_registration.Registry):
def post(self, request, vimid=""):
self._logger.info("registration with : %s" % vimid)
- # Get the specified tenant id
- specified_project_idorname = request.META.get("Project", None)
-
- # vim registration will trigger the start the audit of AZ capacity
- worker_self = InfraResourceAuditor(
- settings.MULTICLOUD_API_V1_PREFIX,
- settings.AAI_BASE_URL
- )
- backlog_item = {
- "id": vimid,
- "worker": worker_self.azcap_audit,
- "payload": (vimid, specified_project_idorname),
- "repeat": 10*1000000, # repeat every 10 seconds
- }
- gAZCapAuditThread.add(backlog_item)
- if 0 == gAZCapAuditThread.state():
- gAZCapAuditThread.start()
+ # check if auditor is enabled
+ viminfo = VimDriverUtils.get_vim_info(vimid)
+ cloud_extra_info = viminfo.get("cloud_extra_info_json",{})
+ if cloud_extra_info.get("capacity_auditor_enabled", False):
+ # Get the specified tenant id
+ specified_project_idorname = request.META.get("Project", None)
+
+ # vim registration will trigger the start the audit of AZ capacity
+ worker_self = InfraResourceAuditor(
+ settings.MULTICLOUD_API_V1_PREFIX,
+ settings.AAI_BASE_URL
+ )
+ backlog_item = {
+ "id": vimid,
+ "worker": worker_self.azcap_audit,
+ "payload": (vimid, specified_project_idorname),
+ "repeat": 10*1000000, # repeat every 10 seconds
+ }
+ gAZCapAuditThread.add(backlog_item)
+ if 0 == gAZCapAuditThread.state():
+ gAZCapAuditThread.start()
return super(APIv0Registry, self).post(request, vimid)
def delete(self, request, vimid=""):
@@ -104,20 +108,23 @@ class APIv1Registry(newton_registration.Registry):
vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
- # vim registration will trigger the start the audit of AZ capacity
- worker_self = InfraResourceAuditor(
- settings.MULTICLOUD_API_V1_PREFIX,
- settings.AAI_BASE_URL
- )
- backlog_item = {
- "id": vimid,
- "worker": worker_self.azcap_audit,
- "payload": (vimid, specified_project_idorname),
- "repeat": 5 * 1000000, # repeat every 5 seconds
- }
- gAZCapAuditThread.add(backlog_item)
- if 0 == gAZCapAuditThread.state():
- gAZCapAuditThread.start()
+ viminfo = VimDriverUtils.get_vim_info(vimid)
+ cloud_extra_info = viminfo.get("cloud_extra_info_json",{})
+ if cloud_extra_info.get("capacity_auditor_enabled", False):
+ # vim registration will trigger the start the audit of AZ capacity
+ worker_self = InfraResourceAuditor(
+ settings.MULTICLOUD_API_V1_PREFIX,
+ settings.AAI_BASE_URL
+ )
+ backlog_item = {
+ "id": vimid,
+ "worker": worker_self.azcap_audit,
+ "payload": (vimid, specified_project_idorname),
+ "repeat": 5 * 1000000, # repeat every 5 seconds
+ }
+ gAZCapAuditThread.add(backlog_item)
+ if 0 == gAZCapAuditThread.state():
+ gAZCapAuditThread.start()
return super(APIv1Registry, self).post(request, vimid)
@@ -372,7 +379,7 @@ class RegistryHelper(newton_registration.RegistryHelper):
# get the resource first
resource_url = ("/cloud-infrastructure/cloud-regions/"
- "cloud-region/%(cloud_owner)s/%(cloud_region_id)s"
+ "cloud-region/%(cloud_owner)s/%(cloud_region_id)s?depth=1"
% {
"cloud_owner": cloud_owner,
"cloud_region_id": cloud_region_id
@@ -385,7 +392,13 @@ class RegistryHelper(newton_registration.RegistryHelper):
# add resource-version
if retcode == 0 and content:
content = json.JSONDecoder().decode(content)
- # resource_info["resource-version"] = content["resource-version"]
+ # now take care of esr-system-info
+ esrinfo = content.get("esr-system-info-list",{}).get("esr-system-info",[{}])[0]
+ if esrinfo:
+ # keep esr-system-info-id intact
+ resource_info[esr-system-info-list]["esr-system-info"]["esr-system-info-id"] \
+ = esrinfo.get("esr-system-info-id", str(uuid.uuid4()))
+
content.update(resource_info)
resource_info = content