Piotr Kliczewski has uploaded a new change for review. Change subject: api: introducing short parameter for getVMList verb ......................................................................
api: introducing short 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 unnecessery load. In order to fix this issue we introduce new parameter 'short' which is set to True by default. Older engines still want to get an array of vmids. For xmlrpc and newer engines which provides 'short' set as False map of vmids and statuses is returned. Change-Id: I2d9eb359f6995c09d61a3159e733498fa3b55780 Signed-off-by: pkliczewski <[email protected]> Bug-Url: https://bugzilla.redhat.com/1196735 --- M vdsm/API.py M vdsm/rpc/BindingXMLRPC.py M vdsm/rpc/Bridge.py M vdsm/rpc/vdsmapi-schema.json 4 files changed, 17 insertions(+), 17 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/49/38449/1 diff --git a/vdsm/API.py b/vdsm/API.py index 42c471e..2ac774f 100644 --- a/vdsm/API.py +++ b/vdsm/API.py @@ -1379,14 +1379,18 @@ return dict(status=doneCode) # VM-related functions - def getVMList(self, fullStatus=False, vmList=()): + def getVMList(self, fullStatus=False, vmList=(), short=True): """ return a list of known VMs with full (or partial) config each """ # To improve complexity, convert 'vms' to set(vms) vmSet = set(vmList) - return {'status': doneCode, - 'vmList': [v.status(fullStatus) - for v in self._cif.vmContainer.values() - if not vmSet or v.id in vmSet]} + ret = {'status': doneCode, + 'vmList': [v.status(fullStatus) + for v in self._cif.vmContainer.values() + if not vmSet or v.id in vmSet]} + if short: + return {'status': doneCode, + 'vmList': [v['vmId'] for v in ret['vmList']]} + return ret def getExternalVMs(self, uri, username, password): """ diff --git a/vdsm/rpc/BindingXMLRPC.py b/vdsm/rpc/BindingXMLRPC.py index b01b661..b92fbb0 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 getExternalVMs(self, uri, username, password): api = API.Global() diff --git a/vdsm/rpc/Bridge.py b/vdsm/rpc/Bridge.py index 6ec7326..71a3a5b 100644 --- a/vdsm/rpc/Bridge.py +++ b/vdsm/rpc/Bridge.py @@ -328,7 +328,8 @@ """ API.updateTimestamp() # required for editNetwork flow vmList = args.get('vmList', []) - return API.Global().getVMList(False, vmList) + short = args.get('short', True) + return API.Global().getVMList(False, vmList, short) def Host_getVMFullList_Call(api, args): @@ -336,14 +337,7 @@ This call is interested in returning full status. """ vmList = args.get('vmList', []) - return API.Global().getVMList(True, vmList) - - -def Host_getVMList_Ret(ret): - """ - Just return a list of VM UUIDs - """ - return [v['vmId'] for v in ret['vmList']] + return API.Global().getVMList(True, vmList, False) def StoragePool_getInfo_Ret(ret): @@ -419,7 +413,7 @@ 'Host_hostdevChangeNumvfs': {}, 'Host_startMonitoringDomain': {}, 'Host_stopMonitoringDomain': {}, - 'Host_getVMList': {'call': Host_getVMList_Call, 'ret': Host_getVMList_Ret}, + 'Host_getVMList': {'call': Host_getVMList_Call, 'ret': 'vmList'}, 'Host_getVMFullList': {'call': Host_getVMFullList_Call, 'ret': 'vmList'}, 'Host_getAllVmStats': {'ret': 'statsList'}, 'Host_setupNetworks': {'ret': 'status'}, diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json index 1d919e8..c6d7705 100644 --- a/vdsm/rpc/vdsmapi-schema.json +++ b/vdsm/rpc/vdsmapi-schema.json @@ -3606,13 +3606,15 @@ # # @vmList: #optional Filter the results by a list of UUIDs # +# @short: #optional determines whether we need short of full status +# # Returns: # A list of VmInfos # # Since: 4.10.0 ## {'command': {'class': 'Host', 'name': 'getVMList'}, - 'data': {'*fullStatus': 'bool','*vmList': ['UUID']}, + 'data': {'*fullStatus': 'bool','*vmList': ['UUID'], '*short': 'bool'}, 'returns': ['VmInfo']} ## -- To view, visit https://gerrit.ovirt.org/38449 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2d9eb359f6995c09d61a3159e733498fa3b55780 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Piotr Kliczewski <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
