sysctl: parse bool value as 0/1 and refactor a little bit
This commit is contained in:
parent
8ff1b06879
commit
8c9a63bcd0
1 changed files with 11 additions and 4 deletions
|
@ -120,10 +120,7 @@ class SysctlModule(object):
|
|||
|
||||
# Whitespace is bad
|
||||
self.args['name'] = self.args['name'].strip()
|
||||
if self.args['value'] is not None:
|
||||
self.args['value'] = self.args['value'].strip()
|
||||
else:
|
||||
self.args['value'] = ""
|
||||
self.args['value'] = self._parse_value(self.args['value'])
|
||||
|
||||
thisname = self.args['name']
|
||||
|
||||
|
@ -176,6 +173,16 @@ class SysctlModule(object):
|
|||
|
||||
return len([i for i, j in zip(a, b) if i == j]) == len(a)
|
||||
|
||||
def _parse_value(self, value):
|
||||
if value is None:
|
||||
return ''
|
||||
elif value.lower() in BOOLEANS_TRUE:
|
||||
return '1'
|
||||
elif value.lower() in BOOLEANS_FALSE:
|
||||
return '0'
|
||||
else:
|
||||
return value.strip()
|
||||
|
||||
# ==============================================================
|
||||
# SYSCTL COMMAND MANAGEMENT
|
||||
# ==============================================================
|
||||
|
|
Loading…
Reference in a new issue