Merge pull request #5787 from jirutka/fix-sysctl-bool

sysctl: parse bool value as 0/1 and refactor a little bit
pull/5754/merge
jctanner 11 years ago
commit ff6b44e3e4

@ -120,10 +120,7 @@ class SysctlModule(object):
# Whitespace is bad # Whitespace is bad
self.args['name'] = self.args['name'].strip() self.args['name'] = self.args['name'].strip()
if self.args['value'] is not None: self.args['value'] = self._parse_value(self.args['value'])
self.args['value'] = self.args['value'].strip()
else:
self.args['value'] = ""
thisname = self.args['name'] 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) 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 # SYSCTL COMMAND MANAGEMENT
# ============================================================== # ==============================================================

Loading…
Cancel
Save