mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Remove double-stating file while generating grains
This commit is contained in:
parent
8aa0e83be6
commit
bba2b93e79
@ -2489,15 +2489,15 @@ def _linux_iqn():
|
||||
|
||||
initiator = '/etc/iscsi/initiatorname.iscsi'
|
||||
|
||||
if os.path.isfile(initiator):
|
||||
if os.access(initiator, os.R_OK):
|
||||
with salt.utils.files.fopen(initiator, 'r') as _iscsi:
|
||||
for line in _iscsi:
|
||||
line = line.strip()
|
||||
if line.startswith('InitiatorName='):
|
||||
ret.append(line.split('=', 1)[1])
|
||||
else:
|
||||
log.debug('Access denied to %s', initiator)
|
||||
try:
|
||||
with salt.utils.files.fopen(initiator, 'r') as _iscsi:
|
||||
for line in _iscsi:
|
||||
line = line.strip()
|
||||
if line.startswith('InitiatorName='):
|
||||
ret.append(line.split('=', 1)[1])
|
||||
except OSError as ex:
|
||||
if ex.errno != ex.errno.ENOENT:
|
||||
log.debug("Error while accessing '%s': %s", initiator, ex)
|
||||
|
||||
return ret
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user