mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Merge pull request #3348 from techhat/nfs
Adding initial nfs execution module
This commit is contained in:
commit
8551e410c8
50
salt/modules/nfs.py
Normal file
50
salt/modules/nfs.py
Normal file
@ -0,0 +1,50 @@
|
||||
'''
|
||||
Module for managing NFS.
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
|
||||
import salt.utils
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Only work on posix-like systems
|
||||
'''
|
||||
# Disable on these platorms, specific service modules exist:
|
||||
disable = [
|
||||
'Windows',
|
||||
]
|
||||
if not salt.utils.which('showmount'):
|
||||
return False
|
||||
return 'nfs'
|
||||
|
||||
|
||||
def list_exports(exports='/etc/exports'):
|
||||
'''
|
||||
List configured exports
|
||||
|
||||
CLI Example::
|
||||
|
||||
salt '*' nfs.list_exports
|
||||
'''
|
||||
ret = {}
|
||||
f = open(exports, 'r')
|
||||
for line in f.read().splitlines():
|
||||
if not line:
|
||||
continue
|
||||
if line.startswith('#'):
|
||||
continue
|
||||
comps = line.split()
|
||||
ret[comps[0]] = {'hosts': [], 'options': []}
|
||||
for perm in comps[1:]:
|
||||
permcomps = perm.split('(')
|
||||
permcomps[1] = permcomps[1].replace(')', '')
|
||||
ret[comps[0]]['hosts'] = permcomps[0].split(',')
|
||||
ret[comps[0]]['options'] = permcomps[1].split(',')
|
||||
f.close()
|
||||
return ret
|
||||
|
Loading…
Reference in New Issue
Block a user