mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Prevent crash on NetBSD and OpenBSD when no swap is configured.
This commit is contained in:
parent
c4d828c986
commit
f9f464fa51
1 changed files with 5 additions and 1 deletions
|
@ -451,7 +451,11 @@ def _bsd_memdata(osdata):
|
|||
|
||||
if osdata['kernel'] in ['OpenBSD', 'NetBSD']:
|
||||
swapctl = salt.utils.path.which('swapctl')
|
||||
swap_total = __salt__['cmd.run']('{0} -sk'.format(swapctl)).split(' ')[1]
|
||||
swap_data = __salt__['cmd.run']('{0} -sk'.format(swapctl))
|
||||
if swap_data == 'no swap devices configured':
|
||||
swap_total = 0
|
||||
else:
|
||||
swap_total = swap_data.split(' ')[1]
|
||||
else:
|
||||
swap_total = __salt__['cmd.run']('{0} -n vm.swap_total'.format(sysctl))
|
||||
grains['swap_total'] = int(swap_total) // 1024 // 1024
|
||||
|
|
Loading…
Add table
Reference in a new issue