Yaniv Bronhaim has uploaded a new change for review. Change subject: Adding isSPM parameter to getAllTasksList\Status ......................................................................
Adding isSPM parameter to getAllTasksList\Status When requesting for tasks status or list the user will add isSpm variable (default is false), if the request is for SPM tasks VDSM will verifies SPM state for connected storagePool, If host is not SPM, not SPM exception will return to user. Bug-Id: https://bugzilla.redhat.com/show_bug.cgi?id=880547 Signed-off-by: Yaniv Bronhaim <[email protected]> Change-Id: I4cbc11c924f0bd078749fea26d79b39c0dd48094 --- M vdsm/API.py M vdsm/BindingXMLRPC.py M vdsm/storage/hsm.py M vdsm_cli/vdsClient.py 4 files changed, 43 insertions(+), 20 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/17/12517/1 diff --git a/vdsm/API.py b/vdsm/API.py index 0046b57..ff4e0d5 100644 --- a/vdsm/API.py +++ b/vdsm/API.py @@ -1363,11 +1363,11 @@ def getDevicesVisibility(self, guidList): return self._irs.getDevicesVisibility(guidList) - def getAllTasksInfo(self): - return self._irs.getAllTasksInfo() + def getAllTasksInfo(self, isSpm): + return self._irs.getAllTasksInfo(isSpm) - def getAllTasksStatuses(self): - return self._irs.getAllTasksStatuses() + def getAllTasksStatuses(self, isSpm): + return self._irs.getAllTasksStatuses(isSpm) def getAllTasks(self): return self._irs.getAllTasks() diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py index 9a4db12..c85a6d3 100644 --- a/vdsm/BindingXMLRPC.py +++ b/vdsm/BindingXMLRPC.py @@ -697,13 +697,13 @@ return task.stop() # Global storage methods - def tasksGetAllInfo(self): + def tasksGetAllInfo(self, isSpm): api = API.Global() - return api.getAllTasksInfo() + return api.getAllTasksInfo(isSpm) - def tasksGetAllStatuses(self): + def tasksGetAllStatuses(self, isSpm): api = API.Global() - return api.getAllTasksStatuses() + return api.getAllTasksStatuses(isSpm) def tasksGetAll(self, options=None): api = API.Global() diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py index d409fd0..cfcde89 100644 --- a/vdsm/storage/hsm.py +++ b/vdsm/storage/hsm.py @@ -304,6 +304,15 @@ if pool.spmRole != sp.SPM_ACQUIRED: raise se.SpmStatusError(spUUID) + def validateSPMOnConnectedPool(self): + # Currently only one storage pool can be connected + pools = self.getConnectedStoragePoolsList() + # If no pool exists, means not SPM + if len(pools['poollist']) == 0: + raise Exception('Not SPM') + for pool in pools['poollist']: + self.validateSPM(pool) + def validateNotSPM(self, spUUID): pool = self.getPool(spUUID) if pool.spmRole != sp.SPM_FREE: @@ -2036,16 +2045,17 @@ return dict(taskStatus=taskStatus) @public - def getAllTasksStatuses(self, spUUID=None, options=None): + def getAllTasksStatuses(self, isSpm): """ Gets the status of all public tasks. - :param spUUID: The UUID of the storage pool that you - want to check it's tasks. - :type spUUID: UUID (deprecated) - :options: ? + :param isSpm: True if only SPM tasks are requested + + :returns: a dict of all the tasks information. """ # getSharedLock(tasksResource...) + if isSpm: + self.validateSPMOnConnectedPool() allTasksStatus = self.taskMng.getAllTasksStatuses("spm") return dict(allTasksStatus=allTasksStatus) @@ -2071,20 +2081,19 @@ return dict(TaskInfo=inf) @public - def getAllTasksInfo(self, spUUID=None, options=None): + def getAllTasksInfo(self, isSpm): """ Get the information of all the tasks in a storage pool. - :param spUUID: The UUID of the storage pool you that want to check - it's tasks info. - :type spUUID: UUID (deprecated) - :param options: ? + :param isSpm: True if only SPM tasks are requested :returns: a dict of all the tasks information. :rtype: dict """ # getSharedLock(tasksResource...) # TODO: if spUUID passed, make sure tasks are relevant only to pool + if isSpm: + self.validateSPMOnConnectedPool() allTasksInfo = self.taskMng.getAllTasksInfo("spm") return dict(allTasksInfo=allTasksInfo) diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py index 1da7d5f..84e1173 100644 --- a/vdsm_cli/vdsClient.py +++ b/vdsm_cli/vdsClient.py @@ -1159,7 +1159,14 @@ return 0, '' def getAllTasksInfo(self, args): - status = self.s.getAllTasksInfo() + if len(args) == 0: + isSPM = False + else: + key, value = args[0].split('=') + if key.upper() == 'SPM' and value.upper() == 'TRUE': + isSPM = True + + status = self.s.getAllTasksInfo(isSPM) if status['status']['code']: return status['status']['code'], status['status']['message'] for t, inf in status['allTasksInfo'].iteritems(): @@ -1183,7 +1190,14 @@ return 0, '' def getAllTasksStatuses(self, args): - status = self.s.getAllTasksStatuses() + if len(args) == 0: + isSPM = False + else: + key, value = args[0].split('=') + if key.upper() == 'SPM' and value.upper() == 'TRUE': + isSPM = True + + status = self.s.getAllTasksStatuses(isSPM) if status['status']['code']: return status['status']['code'], status['status']['message'] print status # TODO -- To view, visit http://gerrit.ovirt.org/12517 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4cbc11c924f0bd078749fea26d79b39c0dd48094 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
