summaryrefslogtreecommitdiffstats
path: root/newton
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-03-28 10:57:58 +0800
committerYun Huang <yun.huang@windriver.com>2018-03-28 10:57:58 +0800
commit1365689c286369ed403142fe79d80464f0c124a5 (patch)
treec731d85de079fb1465e57b719958cf5f1126026b /newton
parent3b46940db33ea1a111c7290c2be64ac434056a3c (diff)
Fix bug of capacity_check for newton
Change-Id: Ic2a5a85a4a68d64dd136ab4853ff5348ef87e3e5 Issue-ID: MULTICLOUD-168 Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'newton')
-rw-r--r--newton/newton/resource/views/capacity.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/newton/newton/resource/views/capacity.py b/newton/newton/resource/views/capacity.py
index d73cc0fb..8ea37062 100644
--- a/newton/newton/resource/views/capacity.py
+++ b/newton/newton/resource/views/capacity.py
@@ -77,20 +77,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):
n236'>236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322