Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions drivers/ISCSISR.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,16 @@ def _initPaths(self):
util.SMlog("PATHDICT: key %s: %s" % (key,rec))
addrlist.append(key)

# Try to detect an active path in order of priority
for key in self.pathdict:
if self.adapter.has_key(key):
self.tgtidx = key
self.path = self.pathdict[self.tgtidx]['path']
if os.path.exists(self.path):
util.SMlog("Path found: %s" % self.path)
break
self.address = self.tgtidx
if not os.path.exists(self.path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move this functionality to a separate method, so that we could cover it with unit tests? What I am thinking about:

  • commit 1 to apply a refactor - a simple extract method
  • commit 2 to add Unit Tests for the existing functionality
  • commit 3 to cover the new functionality.

What do you think?

# Try to detect an active path in order of priority
for key in self.pathdict:
if self.adapter.has_key(key):
self.tgtidx = key
self.path = self.pathdict[self.tgtidx]['path']
if os.path.exists(self.path):
util.SMlog("Path found: %s" % self.path)
break
self.address = self.tgtidx
self._synchroniseAddrList(addrlist)

def _init_adapters(self):
Expand Down