mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
commit
04dce488fb
@ -48,3 +48,32 @@ def list_exports(exports='/etc/exports'):
|
||||
ret[comps[0]].append({'hosts': hosts, 'options': options})
|
||||
f.close()
|
||||
return ret
|
||||
|
||||
|
||||
def del_export(exports='/etc/exports', path=None):
|
||||
'''
|
||||
Remove an export
|
||||
|
||||
CLI Example::
|
||||
|
||||
salt '*' nfs.del_export /media/storage
|
||||
'''
|
||||
edict = list_exports(exports)
|
||||
del edict[path]
|
||||
_write_exports(exports, edict)
|
||||
return edict
|
||||
|
||||
|
||||
def _write_exports(exports, edict):
|
||||
'''
|
||||
Write an exports file to disk
|
||||
'''
|
||||
f = open(exports, 'w')
|
||||
for export in edict:
|
||||
line = export
|
||||
for perms in edict[export]:
|
||||
hosts = ','.join(perms['hosts'])
|
||||
options = ','.join(perms['options'])
|
||||
line += ' {0}({1})'.format(hosts, options)
|
||||
f.write('{0}\n'.format(line))
|
||||
f.close()
|
||||
|
Loading…
Reference in New Issue
Block a user