Created
May 11, 2018 15:45
-
-
Save travispaul/cf2f163b3889b3ff63f548ef3bf7c315 to your computer and use it in GitHub Desktop.
sysutils/salt/patches/patch-salt_grains_core.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$NetBSD$ | |
Prevent crash on NetBSD and OpenBSD when no swap is configured. | |
https://github.com/saltstack/salt/pull/47600 | |
--- salt/grains/core.py.orig 2018-05-11 13:12:38.000000000 +0000 | |
+++ salt/grains/core.py | |
@@ -450,11 +450,13 @@ def _bsd_memdata(osdata): | |
mem = __salt__['cmd.run']('{0} -n hw.physmem64'.format(sysctl)) | |
grains['mem_total'] = int(mem) // 1024 // 1024 | |
- if osdata['kernel'] == 'OpenBSD': | |
+ if osdata['kernel'] in ['OpenBSD', 'NetBSD']: | |
swapctl = salt.utils.path.which('swapctl') | |
- swap_total = __salt__['cmd.run']('{0} -sk'.format(swapctl)).split(' ')[1] | |
- else: | |
- swap_total = __salt__['cmd.run']('{0} -n vm.swap_total'.format(sysctl)) | |
+ 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] | |
grains['swap_total'] = int(swap_total) // 1024 // 1024 | |
return grains |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment