mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Merge pull request #45113 from twangboy/win_fix_fcgrain
Fix a stack trace in grains.core
This commit is contained in:
commit
66e090e75d
2 changed files with 8 additions and 1 deletions
|
@ -2552,7 +2552,7 @@ def _windows_wwns():
|
||||||
'''
|
'''
|
||||||
Return Fibre Channel port WWNs from a Windows host.
|
Return Fibre Channel port WWNs from a Windows host.
|
||||||
'''
|
'''
|
||||||
ps_cmd = r'Get-WmiObject -class MSFC_FibrePortHBAAttributes -namespace "root\WMI" | Select -Expandproperty Attributes | %{($_.PortWWN | % {"{0:x2}" -f $_}) -join ""}'
|
ps_cmd = r'Get-WmiObject -ErrorAction Stop -class MSFC_FibrePortHBAAttributes -namespace "root\WMI" | Select -Expandproperty Attributes | %{($_.PortWWN | % {"{0:x2}" -f $_}) -join ""}'
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
|
|
|
@ -3241,6 +3241,13 @@ def powershell(cmd,
|
||||||
else:
|
else:
|
||||||
encoded_cmd = False
|
encoded_cmd = False
|
||||||
|
|
||||||
|
# Put the whole command inside a try / catch block
|
||||||
|
# Some errors in PowerShell are not "Terminating Errors" and will not be
|
||||||
|
# caught in a try/catch block. For example, the `Get-WmiObject` command will
|
||||||
|
# often return a "Non Terminating Error". To fix this, make sure
|
||||||
|
# `-ErrorAction Stop` is set in the powershell command
|
||||||
|
cmd = 'try {' + cmd + '} catch { "{}" | ConvertTo-JSON}'
|
||||||
|
|
||||||
# Retrieve the response, while overriding shell with 'powershell'
|
# Retrieve the response, while overriding shell with 'powershell'
|
||||||
response = run(cmd,
|
response = run(cmd,
|
||||||
cwd=cwd,
|
cwd=cwd,
|
||||||
|
|
Loading…
Add table
Reference in a new issue