#NEWLINE# def rm_automaster( name , device , config = '/etc/auto_salt' ) : #NEWLINE# #INDENT# "\n    Remove the mount point from the auto_master\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' mount.rm_automaster /mnt/foo /dev/sdg\n    " #NEWLINE# contents = automaster ( config ) #NEWLINE# if ( name not in contents ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# lines = [ ] #NEWLINE# try : #NEWLINE# #INDENT# with salt . utils . fopen ( config , 'r' ) as ifile : #NEWLINE# #INDENT# for line in ifile : #NEWLINE# #INDENT# if line . startswith ( '#' ) : #NEWLINE# #INDENT# lines . append ( line ) #NEWLINE# continue #NEWLINE# #UNINDENT# if ( not line . strip ( ) ) : #NEWLINE# #INDENT# lines . append ( line ) #NEWLINE# continue #NEWLINE# #UNINDENT# comps = line . split ( ) #NEWLINE# if ( len ( comps ) != 3 ) : #NEWLINE# #INDENT# lines . append ( line ) #NEWLINE# continue #NEWLINE# #UNINDENT# comps = line . split ( ) #NEWLINE# prefix = '/..' #NEWLINE# name_chk = comps [ 0 ] . replace ( prefix , '' ) #NEWLINE# device_fmt = comps [ 2 ] . split ( ':' ) #NEWLINE# if device : #NEWLINE# #INDENT# if ( ( name_chk == name ) and ( device_fmt [ 1 ] == device ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( name_chk == name ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# lines . append ( line ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except ( IOError , OSError ) as exc : #NEWLINE# #INDENT# msg = "Couldn't read from {0}: {1}" #NEWLINE# raise CommandExecutionError ( msg . format ( config , str ( exc ) ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# with salt . utils . fopen ( config , 'w+' ) as ofile : #NEWLINE# #INDENT# ofile . writelines ( lines ) #NEWLINE# #UNINDENT# #UNINDENT# except ( IOError , OSError ) as exc : #NEWLINE# #INDENT# msg = "Couldn't write to {0}: {1}" #NEWLINE# raise CommandExecutionError ( msg . format ( config , str ( exc ) ) ) #NEWLINE# #UNINDENT# __salt__ [ 'cmd.run' ] ( 'automount -cv' ) #NEWLINE# return True