Saggi Mizrahi has posted comments on this change.
Change subject: gluster: add task support
......................................................................
Patch Set 13: Code-Review-1
(9 comments)
....................................................
Commit Message
Line 16: {TASKID: {
Line 17: "volume": VOLUMENAME,
Line 18: "status": TaskStatus,
Line 19: "type": TaskType,
Line 20: "data": SUMMARY
rouge tab
Line 21: }, ...}
Line 22:
Line 23: Change-Id: I154df353bc6f23001d7bf61b8f5345abd2019cb6
Line 24: Signed-off-by: Bala.FA <barumuga(a)redhat.com>
....................................................
File vdsm/gluster/tasks.py
Line 24: from cli import TaskType
Line 25:
Line 26:
Line 27: @makePublic
Line 28: def tasksList(taskId=None):
* A functions' name needs to convey an action for instance GetTasksInfo()
* taskId shouldn't be a string. Making it a set or equivalent it goes better with the
premise of the method.
Line 29: subRes = {}
Line 30: tasks = cli.volumeStatusAll()
Line 31: for tid in tasks:
Line 32: if taskId:
Line 25:
Line 26:
Line 27: @makePublic
Line 28: def tasksList(taskId=None):
Line 29: subRes = {}
did you mean "result" or "tasksInfo"
Line 30: tasks = cli.volumeStatusAll()
Line 31: for tid in tasks:
Line 32: if taskId:
Line 33: if tid != taskId:
Line 26:
Line 27: @makePublic
Line 28: def tasksList(taskId=None):
Line 29: subRes = {}
Line 30: tasks = cli.volumeStatusAll()
Can't this throw an error?
Line 31: for tid in tasks:
Line 32: if taskId:
Line 33: if tid != taskId:
Line 34: continue
Line 32: if taskId:
Line 33: if tid != taskId:
Line 34: continue
Line 35:
Line 36: try:
Only wrap valid methods and not the entire thing
Line 37: value = tasks[tid]
Line 38: data = {}
Line 39: state = value['status']
Line 40: if value['taskType'] == TaskType.REBALANCE:
Line 37: value = tasks[tid]
Line 38: data = {}
Line 39: state = value['status']
Line 40: if value['taskType'] == TaskType.REBALANCE:
Line 41: data = cli.volumeRebalanceStatus(value['volumeName'])
if you are reusing value['taskType'] and value['volumeName'] and other
multiple times it's better to move them to local variables. It's faster and there
is less chance that you misspell the key name. pyflakes does a better job detecting
misspelled local variables than keys.
Line 42: elif value['taskType'] == TaskType.REMOVE_BRICK:
Line 43: data = cli.volumeRemoveBrickStatus(value['volumeName'],
Line 44: value['bricks'])
Line 45: elif value['taskType'] == TaskType.REPLACE_BRICK:
Line 42: elif value['taskType'] == TaskType.REMOVE_BRICK:
Line 43: data = cli.volumeRemoveBrickStatus(value['volumeName'],
Line 44: value['bricks'])
Line 45: elif value['taskType'] == TaskType.REPLACE_BRICK:
Line 46: data = cli.volumeReplaceBrickStatus(value['volumeName'],
If you call the same method twice you should compose the arguments and call the method
only once so your try\catch clause would be smaller.
Line 47: value['bricks'][0],
Line 48: value['bricks'][1])
Line 49:
Line 50: summary = data['summary'] if 'summary' in data else
{}
Line 46: data = cli.volumeReplaceBrickStatus(value['volumeName'],
Line 47: value['bricks'][0],
Line 48: value['bricks'][1])
Line 49:
Line 50: summary = data['summary'] if 'summary' in data else
{}
From this point one I don't see how a GlusterException can be
thrown. Please put outside the the clause.
Line 51: subRes[tid] =
{"volume": value['volumeName'],
Line 52: "status": state,
Line 53: "type": value['taskType'],
Line 54: "data": summary}
Line 52: "status": state,
Line 53: "type": value['taskType'],
Line 54: "data": summary}
Line 55: except ge.GlusterException:
Line 56: logging.error("gluster exception occured", exc_info=True)
Try and not use the root logger
--
To view, visit
http://gerrit.ovirt.org/10200
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I154df353bc6f23001d7bf61b8f5345abd2019cb6
Gerrit-PatchSet: 13
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Bala.FA <barumuga(a)redhat.com>
Gerrit-Reviewer: Adam Litke <agl(a)us.ibm.com>
Gerrit-Reviewer: Aravinda VK <avishwan(a)redhat.com>
Gerrit-Reviewer: Ayal Baron <abaron(a)redhat.com>
Gerrit-Reviewer: Bala.FA <barumuga(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce(a)redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi(a)redhat.com>
Gerrit-Reviewer: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
Gerrit-Reviewer: Timothy Asir <tjeyasin(a)redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei(a)redhat.com>
Gerrit-Reviewer: ndarshan <dnarayan(a)redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes