Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solving bug : sysctl check_after failing on multi-value sysctl parameters #2091

Merged
merged 1 commit into from
Feb 16, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion library/sysctl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ author: David "DaviXX" CHANIAL <david.chanial@gmail.com>

import os
import tempfile
import re

# ==============================================================

Expand Down Expand Up @@ -185,13 +186,22 @@ def sysctl_check(current_step, **sysctl_args):
if current_step == 'after' and sysctl_args['checks'] in ['after', 'both']:

if sysctl_args['value'] is not None:

# reading the virtual file
f = open(sysctl_args['key_path'],'r')
output = f.read()
f.close()
output = output.strip(' \t\n\r')

# multi positive integer values separated by spaces as described in issue #2004 :
if re.search('^([\d\s]+)$', sysctl_args['value']):
# replace all groups of spaces by one space
output = re.sub('(\s+)', ' ', output)

# normal case, finded value must be equal to the submitted 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, ''

# weird end
Expand Down