Change in vdsm[ovirt-3.5]: api: introducing onlyUUID parameter for getVMList verb

piotr.kliczewski at gmail.com piotr.kliczewski at gmail.com
Mon Mar 9 12:17:36 UTC 2015


Piotr Kliczewski has uploaded a new change for review.

Change subject: api: introducing onlyUUID parameter for getVMList verb
......................................................................

api: introducing onlyUUID parameter for getVMList verb

Due to vdsm sending only an array of vmids in a response to getVMList
the engine asks separately using VM.getStats which creates unnecessary
load. In order to fix this issue we introduce a new parameter 'onlyUUID'
which is set to True by default. Engine 3.5.0 still wants to get an
array of vmids, but for all other versions we set 'onlyUUID' to False
which returns map of vmids and statuses.

Change-Id: I2d9eb359f6995c09d61a3159e733498fa3b55780
Bug-Url: https://bugzilla.redhat.com/1196735
Related-To: https://gerrit.ovirt.org/#/c/38448
Signed-off-by: pkliczewski <piotr.kliczewski at gmail.com>
---
M vdsm/API.py
M vdsm/rpc/BindingXMLRPC.py
M vdsm/rpc/Bridge.py
M vdsm/rpc/vdsmapi-schema.json
4 files changed, 20 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/76/38476/1

diff --git a/vdsm/API.py b/vdsm/API.py
index 6c28479..4b02327 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1363,7 +1363,7 @@
         return dict(status=doneCode)
 
     # VM-related functions
-    def getVMList(self, fullStatus=False, vmList=()):
+    def getVMList(self, fullStatus=False, vmList=(), onlyUUID=True):
         """ return a list of known VMs with full (or partial) config each """
 
         def reportedStatus(v, full):
@@ -1375,10 +1375,14 @@
 
         # To improve complexity, convert 'vms' to set(vms)
         vmSet = set(vmList)
-        return {'status': doneCode,
-                'vmList': [reportedStatus(v, fullStatus)
-                           for v in self._cif.vmContainer.values()
-                           if not vmSet or v.id in vmSet]}
+        vmlist = [v.status(fullStatus)
+                  for v in self._cif.vmContainer.values()
+                  if not vmSet or v.id in vmSet]
+        if onlyUUID:
+            # BZ 1196735: api backward compatibility issue
+            # REQUIRED_FOR: engine-3.5.0 only
+            vmlist = [v['vmId'] for v in vmlist]
+        return {'status': doneCode, 'vmList': vmlist}
 
     # Networking-related functions
     def setupNetworks(self, networks, bondings, options):
diff --git a/vdsm/rpc/BindingXMLRPC.py b/vdsm/rpc/BindingXMLRPC.py
index 8a8e5b7..2f12eb8 100644
--- a/vdsm/rpc/BindingXMLRPC.py
+++ b/vdsm/rpc/BindingXMLRPC.py
@@ -358,7 +358,7 @@
     def getVMList(self, fullStatus=False, vmList=()):
         API.updateTimestamp()  # required for editNetwork flow
         api = API.Global()
-        return api.getVMList(fullStatus, vmList)
+        return api.getVMList(fullStatus, vmList, False)
 
     def vmPause(self, vmId):
         vm = API.VM(vmId)
diff --git a/vdsm/rpc/Bridge.py b/vdsm/rpc/Bridge.py
index e4b12aa..b07f5fb 100644
--- a/vdsm/rpc/Bridge.py
+++ b/vdsm/rpc/Bridge.py
@@ -322,7 +322,8 @@
     """
     API.updateTimestamp()  # required for editNetwork flow
     vmList = args.get('vmList', [])
-    return API.Global().getVMList(False, vmList)
+    onlyUUID = args.get('onlyUUID', True)
+    return API.Global().getVMList(False, vmList, onlyUUID)
 
 
 def Host_getVMFullList_Call(api, args):
@@ -330,7 +331,7 @@
     This call is interested in returning full status.
     """
     vmList = args.get('vmList', [])
-    return API.Global().getVMList(True, vmList)
+    return API.Global().getVMList(True, vmList, False)
 
 
 def Host_getVMList_Ret(ret):
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index e42e3ac..8491b3b 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -3471,7 +3471,7 @@
 ##
 {'type': 'VmInfo',
  'data': {},
- 'union': ['VmDefinition', 'VmShortStatus']}
+ 'union': ['VmDefinition', 'UUID', 'VmShortStatus']}
 
 ##
 # @Host.getVMList:
@@ -3480,14 +3480,18 @@
 #
 # @vmList:      #optional Filter the results by a list of UUIDs
 #
+# @onlyUUID:    #optional determines whether we need short of full status
+#               This parmeter is provided to keep backward compatibility
+#               with engine-3.5.0
+#
 # Returns:
 # A list of VM UUIDs
 #
 # Since: 4.10.0
 ##
 {'command': {'class': 'Host', 'name': 'getVMList'},
- 'data': {'*vmList': ['UUID']},
- 'returns': ['UUID']}
+ 'data': {'*fullStatus': 'bool','*vmList': ['UUID'], '*onlyUUID': 'bool'},
+ 'returns': ['VmInfo']}
 
 ##
 # @GuestDiskMappingInfo:


-- 
To view, visit https://gerrit.ovirt.org/38476
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2d9eb359f6995c09d61a3159e733498fa3b55780
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Piotr Kliczewski <piotr.kliczewski at gmail.com>


More information about the vdsm-patches mailing list