Francesco Romani has uploaded a new change for review.
Change subject: virt: faster getVMList
......................................................................
virt: faster getVMList
avoid (apparently?) wasteful work and make
the verb implementation faster with no
changes in behaviour.
Change-Id: I82c602301bc133d6a4971c8a4d15f823929f7c43
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/API.py
M vdsm/virt/vm.py
2 files changed, 5 insertions(+), 10 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/02/36902/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 6c28479..91632f9 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1365,18 +1365,10 @@
# VM-related functions
def getVMList(self, fullStatus=False, vmList=()):
""" return a list of known VMs with full (or partial) config each
"""
-
- def reportedStatus(v, full):
- d = v.status()
- if full:
- return d
- else:
- return {'vmId': d['vmId'], 'status':
d['status']}
-
# To improve complexity, convert 'vms' to set(vms)
vmSet = set(vmList)
return {'status': doneCode,
- 'vmList': [reportedStatus(v, fullStatus)
+ 'vmList': [v.status(fullStatus)
for v in self._cif.vmContainer.values()
if not vmSet or v.id in vmSet]}
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 22bb957..2d69923 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -2796,8 +2796,11 @@
pass
self.saveState()
- def status(self):
+ def status(self, fullStatus=True):
# used by API.Global.getVMList
+ if not fullStatus:
+ return {'vmId': self.id, 'status': self.lastStatus}
+
self.conf['status'] = self.lastStatus
with self._confLock:
# Filter out any internal keys
--
To view, visit
http://gerrit.ovirt.org/36902
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I82c602301bc133d6a4971c8a4d15f823929f7c43
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>