Skip to content

Commit

Permalink
LVHDoISCSISR: simplify attach logic
Browse files Browse the repository at this point in the history
pylint 2.13.9 seems to notice that `stored_exception` does not get set
if `self.iscsiSRs` is empty:

 drivers/LVHDoISCSISR.py:514:22: E0601: Using variable 'stored_exception' before assignment (used-before-assignment)

The code can indeed be simplified, as `connected` and
`stored_exception` were indeed tighly related, and only one is needed
in the end.

Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
  • Loading branch information
ydirson committed Mar 23, 2023
1 parent 40a8340 commit d260406
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/LVHDoISCSISR.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def delete(self, sr_uuid):

def attach(self, sr_uuid):
try:
connected = False
stored_exception = None
for i in self.iscsiSRs:
try:
i.attach(sr_uuid)
Expand All @@ -503,14 +503,12 @@ def attach(self, sr_uuid):
continue
else:
raise
else:
connected = True

if not i._attach_LUN_bySCSIid(self.SCSIid):
raise xs_errors.XenError('InvalidDev')

# Check if at least one iscsi succeeded
if not connected:
if stored_exception:
raise stored_exception

if 'multiSession' in self.dconf:
Expand Down

0 comments on commit d260406

Please sign in to comment.