1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-03-22 10:34:49 +00:00

Migrate source code to python 3.7 and refine code style

This commit is contained in:
Gao Jiangmiao 2019-08-16 12:59:37 +08:00
parent 0e231a930d
commit a4d74a09a6
55 changed files with 192 additions and 306 deletions

View file

@ -19,9 +19,7 @@ class wvmHostDetails(wvmConnect):
all_mem = self.wvm.getInfo()[1] * 1048576
freemem = self.wvm.getMemoryStats(-1, 0)
if type(freemem) == dict:
free = (freemem.values()[0] +
freemem.values()[2] +
freemem.values()[3]) * 1024
free = (freemem.values()[0] + freemem.values()[2] + freemem.values()[3]) * 1024
percent = (100 - ((free * 100) / all_mem))
usage = (all_mem - free)
mem_usage = {'total': all_mem, 'usage': usage, 'percent': percent}
@ -59,14 +57,10 @@ class wvmHostDetails(wvmConnect):
Function return host server information: hostname, cpu, memory, ...
"""
info = []
info.append(self.wvm.getHostname()) # hostname
info.append(self.wvm.getInfo()[0]) # architecture
info.append(self.wvm.getInfo()[1] * 1048576) # memory
info.append(self.wvm.getInfo()[2]) # cpu core count
info.append(get_xml_path(self.wvm.getSysinfo(0), func=cpu_version)) # cpu version
info.append(self.wvm.getURI()) #uri
info.append(self.wvm.getHostname()) # hostname
info.append(self.wvm.getInfo()[0]) # architecture
info.append(self.wvm.getInfo()[1] * 1048576) # memory
info.append(self.wvm.getInfo()[2]) # cpu core count
info.append(get_xml_path(self.wvm.getSysinfo(0), func=cpu_version)) # cpu version
info.append(self.wvm.getURI()) # uri
return info