Misc s/func/certmaster/ replacements
[certmaster.git] / certmaster / minion / modules / sysctl.py
1 # Copyright 2008, Red Hat, Inc
2 # Luke Macken <lmacken@redhat.com>
3 #
4 # This software may be freely redistributed under the terms of the GNU
5 # general public license.
6 #
7 # You should have received a copy of the GNU General Public License
8 # along with this program; if not, write to the Free Software
9 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
10
11 import func_module
12 import sub_process
13
14 class SysctlModule(func_module.FuncModule):
15
16 version = "0.0.1"
17 description = "Configure kernel parameters at runtime"
18
19 def __run(self, cmd):
20 cmd = sub_process.Popen(cmd.split(), stdout=sub_process.PIPE,
21 stderr=sub_process.PIPE, shell=False)
22 return [line for line in cmd.communicate()[0].strip().split('\n')]
23
24 def list(self):
25 return self.__run("/sbin/sysctl -a")
26
27 def get(self, name):
28 return self.__run("/sbin/sysctl -n %s" % name)
29
30 def set(self, name, value):
31 return self.__run("/sbin/sysctl -w %s=%s" % (name, value))