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

View File

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