Fix trailing newline on grains

The grains iscsi_iqn and fc_wwn have training newlines which cause
show when calling the grain from a state file and trying to pass
this to an execution module.

Remove the training newline with rstrip()
This commit is contained in:
Simon Dodsley 2017-09-26 13:05:02 -07:00
parent 63821381a0
commit 676c18481f
No known key found for this signature in database
GPG key ID: 91F33CCDBF171E25

View file

@ -2517,7 +2517,8 @@ def _linux_iqn():
for line in _iscsi:
if line.find('InitiatorName') != -1:
iqn = line.split('=')
ret.extend([iqn[1]])
final_iqn = iqn[1].rstrip()
ret.extend([final_iqn])
return ret
@ -2532,7 +2533,8 @@ def _aix_iqn():
aixret = __salt__['cmd.run'](aixcmd)
if aixret[0].isalpha():
iqn = aixret.split()
ret.extend([iqn[1]])
final_iqn = iqn[1].rstrip()
ret.extend([final_iqn])
return ret
@ -2545,6 +2547,7 @@ def _linux_wwns():
for fcfile in glob.glob('/sys/class/fc_host/*/port_name'):
with salt.utils.files.fopen(fcfile, 'r') as _wwn:
for line in _wwn:
line = line.rstrip()
ret.extend([line[2:]])
return ret
@ -2571,6 +2574,7 @@ def _windows_iqn():
for line in cmdret['stdout'].splitlines():
if line[0].isalpha():
continue
line = line.rstrip()
ret.extend([line])
return ret
@ -2587,6 +2591,7 @@ def _windows_wwns():
cmdret = __salt__['cmd.run_ps'](ps_cmd)
for line in cmdret:
line = line.rstrip()
ret.append(line)
return ret