adding versionadded and fixing minor lint errors

This commit is contained in:
David 425 2015-11-24 18:29:49 -08:00
parent a870523a6c
commit 01b4e47356
2 changed files with 14 additions and 3 deletions

View File

@ -192,6 +192,7 @@ def list_sebool():
'Description': ' '.join(comps[4:])}
return ret
def getsemod(module):
'''
Return the information on a specific selinux module
@ -201,6 +202,8 @@ def getsemod(module):
.. code-block:: bash
salt '*' selinux.getsemod mysql
.. versionadded:: Boron
'''
return list_semod().get(module, {})
@ -214,6 +217,8 @@ def setsemod(module, state):
.. code-block:: bash
salt '*' selinux.setsemod nagios Enabled
.. versionadded:: Boron
'''
if state.lower() == 'enabled':
cmd = 'semodule -e {0}'.format(module)
@ -232,6 +237,8 @@ def list_semod():
.. code-block:: bash
salt '*' selinux.list_semod
.. versionadded:: Boron
'''
mdata = __salt__['cmd.run']('semodule -l').splitlines()
ret = {}

View File

@ -60,9 +60,11 @@ def _refine_value(value):
return 'off'
return None
def _refine_module_state(module_state):
'''
Return a predictable value, or allow us to error out
.. versionadded:: Boron
'''
module_state = str(module_state).lower()
if module_state in ('1', 'on', 'yes', 'true', 'enabled'):
@ -174,6 +176,8 @@ def module(name, module_state='Enabled', version='any'):
version
Defaults to no preference, set to a specified value if required.
Currently can only alert if the version is incorrect.
.. versionadded:: Boron
'''
ret = {'name': name,
'result': True,
@ -199,12 +203,12 @@ def module(name, module_state='Enabled', version='any'):
return ret
current_module_state = _refine_module_state(modules[name]['Enabled'])
if rmodule_state == current_module_state:
ret['comment'] = 'Module {0} is in the desired state'.format(name)
return ret
ret['comment'] = 'Module {0} is in the desired state'.format(name)
return ret
if __opts__['test']:
ret['result'] = None
ret['comment'] = 'Module {0} is set to be togggled to {1}'.format(
name, module_state)
name, module_state)
return ret
if __salt__['selinux.setsemod'](name, rmodule_state):