Fix Python 2.6-isms in sysctl module

parent 81d426de
...@@ -161,8 +161,9 @@ def sysctl_check(current_step, **sysctl_args): ...@@ -161,8 +161,9 @@ def sysctl_check(current_step, **sysctl_args):
# TODO choose if prefered to use os.access() instead try/catch on open # TODO choose if prefered to use os.access() instead try/catch on open
if current_step == 'before': if current_step == 'before':
try: try:
with open(sysctl_args['sysctl_file']) as f: pass f = open(sysctl_args['sysctl_file'])
except IOError as e: f.close()
except IOError, e:
return 1, 'unable to open supplied sysctl.conf' return 1, 'unable to open supplied sysctl.conf'
# no smart checks at this step ? # no smart checks at this step ?
...@@ -184,11 +185,12 @@ def sysctl_check(current_step, **sysctl_args): ...@@ -184,11 +185,12 @@ def sysctl_check(current_step, **sysctl_args):
if current_step == 'after' and sysctl_args['checks'] in ['after', 'both']: if current_step == 'after' and sysctl_args['checks'] in ['after', 'both']:
if sysctl_args['value'] is not None: if sysctl_args['value'] is not None:
with open(sysctl_args['key_path'],'r') as f: f = open(sysctl_args['key_path'],'r')
output = f.read() output = f.read()
output = output.strip(' \t\n\r') f.close()
if output != sysctl_args['value']: output = output.strip(' \t\n\r')
return 1, 'key seems not set to value even after update/sysctl, founded : <%s>, wanted : <%s>' % (output, sysctl_args['value']) if output != sysctl_args['value']:
return 1, 'key seems not set to value even after update/sysctl, founded : <%s>, wanted : <%s>' % (output, sysctl_args['value'])
return 0, '' return 0, ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment