mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 23:25:24 +00:00
fix cpu_usage waiting for instance creation.
This commit is contained in:
parent
54954137c2
commit
91ec098aa0
2 changed files with 4 additions and 2 deletions
|
@ -51,7 +51,7 @@ class Compute(Model):
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def cpu_usage(self):
|
def cpu_usage(self):
|
||||||
return round(self.proxy.get_cpu_usage().get('usage'))
|
return round(self.proxy.get_cpu_usage(diff=False).get('usage'))
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def ram_size(self):
|
def ram_size(self):
|
||||||
|
|
|
@ -27,7 +27,7 @@ class wvmHostDetails(wvmConnect):
|
||||||
else:
|
else:
|
||||||
return {"total": None, "usage": None, "percent": None}
|
return {"total": None, "usage": None, "percent": None}
|
||||||
|
|
||||||
def get_cpu_usage(self):
|
def get_cpu_usage(self, diff=True):
|
||||||
"""
|
"""
|
||||||
Function return cpu usage on node.
|
Function return cpu usage on node.
|
||||||
"""
|
"""
|
||||||
|
@ -43,6 +43,8 @@ class wvmHostDetails(wvmConnect):
|
||||||
diff_idle = idle - prev_idle
|
diff_idle = idle - prev_idle
|
||||||
diff_total = total - prev_total
|
diff_total = total - prev_total
|
||||||
diff_usage = (1000 * (diff_total - diff_idle) / diff_total + 5) / 10
|
diff_usage = (1000 * (diff_total - diff_idle) / diff_total + 5) / 10
|
||||||
|
if not diff:
|
||||||
|
return {"usage": diff_usage}
|
||||||
prev_total = total
|
prev_total = total
|
||||||
prev_idle = idle
|
prev_idle = idle
|
||||||
if num == 0:
|
if num == 0:
|
||||||
|
|
Loading…
Reference in a new issue