From 34fe8cbca786d59ccc2550a1f20b4b7d20b3aae7 Mon Sep 17 00:00:00 2001 From: Xiaohua Zhang Date: Mon, 8 Apr 2019 07:21:30 +0000 Subject: Update API handler for multi-tenant supports Change-Id: I5c46a71605ed9f5f9e4dfd04b0383c1d5874f3da Issue-ID: MULTICLOUD-543 Signed-off-by: Xiaohua Zhang --- share/starlingx_base/resource/capacity.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'share/starlingx_base/resource/capacity.py') 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): -- cgit 1.2.3-korg