summaryrefslogtreecommitdiffstats
path: root/share/starlingx_base/resource/capacity.py
diff options
context:
space:
mode:
authorXiaohua Zhang <xiaohua.zhang@windriver.com>2019-04-08 07:21:30 +0000
committerXiaohua Zhang <xiaohua.zhang@windriver.com>2019-04-08 07:21:30 +0000
commit34fe8cbca786d59ccc2550a1f20b4b7d20b3aae7 (patch)
tree67731896d13cbea643c681a70a3acf61cafa493c /share/starlingx_base/resource/capacity.py
parentdfad902004f1ff9b86651f10ae5cc13814d954a0 (diff)
Update API handler for multi-tenant supports
Change-Id: I5c46a71605ed9f5f9e4dfd04b0383c1d5874f3da Issue-ID: MULTICLOUD-543 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.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/share/starlingx_base/resource/capacity.py b/share/starlingx_base/resource/capacity.py
index 46e5eba5..cbdedaa3 100644
--- a/share/starlingx_base/resource/capacity.py
+++ b/share/starlingx_base/resource/capacity.py
@@ -41,7 +41,10 @@ class CapacityCheck(newton_capacity.CapacityCheck):
self._logger.debug("META> %s" % request.META)
try:
- hasEnoughResource = self.get_tenant_cap_info(vimid, request.data)
+
+ # Get the specified tenant id
+ specified_project_idorname = request.META.get("Project", None)
+ hasEnoughResource = self.get_tenant_cap_info(vimid, request.data, specified_project_idorname)
azCapInfo = self.get_az_cap_info(vimid)
self._logger.info("RESP with data> result:%s" % hasEnoughResource)
return Response(data={'result': hasEnoughResource, 'AZs': azCapInfo}, status=status.HTTP_200_OK)
@@ -52,15 +55,14 @@ class CapacityCheck(newton_capacity.CapacityCheck):
def get_az_cap_info(self, vimid):
azCapInfo = []
- viminfo = VimDriverUtils.get_vim_info(vimid)
- if not viminfo:
- self._logger.warn("azcap_audit no valid vimid: %s" % vimid)
- return
-
- session = VimDriverUtils.get_session(
- viminfo,
- tenant_name=viminfo['tenant']
- )
+ # viminfo = VimDriverUtils.get_vim_info(vimid)
+ # if not viminfo:
+ # self._logger.warn("azcap_audit no valid vimid: %s" % vimid)
+ # return
+ # session = VimDriverUtils.get_session(
+ # viminfo,
+ # tenant_name=viminfo.get('tenant', None)
+ # )
try:
# get list of AZ
vimAzCacheKey = "cap_azlist_" + vimid
@@ -87,7 +89,7 @@ class CapacityCheck(newton_capacity.CapacityCheck):
return azCapInfoList
except Exception as e:
return azCapInfo
- pass
+
class APIv1CapacityCheck(CapacityCheck):
def __init__(self):