diff options
author | Yun Huang <yun.huang@windriver.com> | 2018-03-28 10:55:06 +0800 |
---|---|---|
committer | Yun Huang <yun.huang@windriver.com> | 2018-03-28 10:55:06 +0800 |
commit | 3b46940db33ea1a111c7290c2be64ac434056a3c (patch) | |
tree | 1b68b6f55a6508070436afa6a38367b264b70685 | |
parent | a3b7ac14b562270157bf6fe7a91666449244d126 (diff) |
Fix bug of capacity_check for TC
Change-Id: I6644e83643bc4aecf5856dd733403bbc72ca3375
Issue-ID: MULTICLOUD-168
Signed-off-by: Yun Huang <yun.huang@windriver.com>
-rw-r--r-- | windriver/titanium_cloud/resource/views/capacity.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/windriver/titanium_cloud/resource/views/capacity.py b/windriver/titanium_cloud/resource/views/capacity.py index 0d44d0c4..11c831fd 100644 --- a/windriver/titanium_cloud/resource/views/capacity.py +++ b/windriver/titanium_cloud/resource/views/capacity.py @@ -86,20 +86,20 @@ class CapacityCheck(APIView): # compute actual available resource for this tenant remainVCPU = compute_limits['maxTotalCores'] - compute_limits['totalCoresUsed'] + remainHypervisorVCPU = hypervisor_statistics['vcpus'] - hypervisor_statistics['vcpus_used'] - if (compute_limits['maxTotalCores'] > hypervisor_statistics['vcpus']): - if hypervisor_statistics['vcpus'] > compute_limits['totalCoresUsed']: - remainVCPU = hypervisor_statistics['vcpus'] - compute_limits['totalCoresUsed'] - else: - remainVCPU = 0 + if (remainVCPU > remainHypervisorVCPU): + remainVCPU = remainHypervisorVCPU remainMEM = compute_limits['maxTotalRAMSize'] - compute_limits['totalRAMUsed'] - if hypervisor_statistics['free_ram_mb'] > remainMEM: - remainMEM = hypervisor_statistics['free_ram_mb'] + remainHypervisorMEM = hypervisor_statistics['free_ram_mb'] + if remainMEM > remainHypervisorMEM: + remainMEM = remainHypervisorMEM remainStorage = storage_limits['maxTotalVolumeGigabytes'] - storage_limits['totalGigabytesUsed'] - if (remainStorage < hypervisor_statistics['free_disk_gb']): - remainStorage = hypervisor_statistics['free_disk_gb'] + remainHypervisorStorage = hypervisor_statistics['free_disk_gb'] + if (remainStorage > remainHypervisorStorage): + remainStorage = remainHypervisorStorage # compare resource demanded with available if (int(resource_demand['vCPU']) >= remainVCPU): |