Return devicenodes as empty list if no LUN's
got connected. It is possible for an intiator to successfully connect to a target, whilst getting no LUN's back. If no devicenodes get detected, it makes more sense to return an empty list than plainly None. This potentially avoids further tasks to have to check if devicenodes is iterable.
This commit is contained in:
parent
8a4f07eecd
commit
b2f8e5dc59
1 changed files with 9 additions and 12 deletions
|
@ -206,18 +206,15 @@ def target_device_node(module, target):
|
||||||
# a given target...
|
# a given target...
|
||||||
|
|
||||||
devices = glob.glob('/dev/disk/by-path/*%s*' % target)
|
devices = glob.glob('/dev/disk/by-path/*%s*' % target)
|
||||||
if len(devices) == 0:
|
devdisks = []
|
||||||
return None
|
for dev in devices:
|
||||||
else:
|
# exclude partitions
|
||||||
devdisks = []
|
if "-part" not in dev:
|
||||||
for dev in devices:
|
devdisk = os.path.realpath(dev)
|
||||||
# exclude partitions
|
# only add once (multi-path?)
|
||||||
if "-part" not in dev:
|
if devdisk not in devdisks:
|
||||||
devdisk = os.path.realpath(dev)
|
devdisks.append(devdisk)
|
||||||
# only add once (multi-path?)
|
return devdisks
|
||||||
if devdisk not in devdisks:
|
|
||||||
devdisks.append(devdisk)
|
|
||||||
return devdisks
|
|
||||||
|
|
||||||
|
|
||||||
def target_isauto(module, target):
|
def target_isauto(module, target):
|
||||||
|
|
Loading…
Reference in a new issue