don't crash when calling swapctl fails, i.e. when there's no swap configured
spotted by juanfra@
This commit is contained in:
parent
fe370f3df9
commit
ed98ae7fcd
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.127 2018/05/14 19:16:50 jasper Exp $
|
||||
# $OpenBSD: Makefile,v 1.128 2018/05/17 12:51:10 jasper Exp $
|
||||
|
||||
# optional dependencies
|
||||
# https://github.com/saltstack/salt/blob/develop/doc/conf.py#L54
|
||||
@ -20,7 +20,7 @@ COMMENT = remote execution and configuration management system
|
||||
MODPY_EGG_VERSION = 2018.3.0
|
||||
DISTNAME = salt-${MODPY_EGG_VERSION}
|
||||
|
||||
REVISION = 1
|
||||
REVISION = 2
|
||||
|
||||
CATEGORIES = sysutils net devel
|
||||
|
||||
|
20
sysutils/salt/patches/patch-salt_grains_core_py
Normal file
20
sysutils/salt/patches/patch-salt_grains_core_py
Normal file
@ -0,0 +1,20 @@
|
||||
$OpenBSD: patch-salt_grains_core_py,v 1.1 2018/05/17 12:51:10 jasper Exp $
|
||||
|
||||
don't crash when calling swapctl fails, i.e. when there's no swap configured.
|
||||
|
||||
Index: salt/grains/core.py
|
||||
--- salt/grains/core.py.orig
|
||||
+++ salt/grains/core.py
|
||||
@@ -452,7 +452,11 @@ def _bsd_memdata(osdata):
|
||||
|
||||
if osdata['kernel'] == 'OpenBSD':
|
||||
swapctl = salt.utils.path.which('swapctl')
|
||||
- swap_total = __salt__['cmd.run']('{0} -sk'.format(swapctl)).split(' ')[1]
|
||||
+ ret = __salt__['cmd.run_all']('{0} -sk'.format(swapctl))
|
||||
+ if ret['retcode'] != 0:
|
||||
+ swap_total = 0
|
||||
+ else:
|
||||
+ swap_total = ret['stdout'].split(' ')[1]
|
||||
else:
|
||||
swap_total = __salt__['cmd.run']('{0} -n vm.swap_total'.format(sysctl))
|
||||
grains['swap_total'] = int(swap_total) // 1024 // 1024
|
Loading…
Reference in New Issue
Block a user