#NEWLINE# def mod_list( only_persist = False ) : #NEWLINE# #INDENT# "\n    Return a list of the loaded module names\n\n    only_persist\n        Only return the list of loaded persistent modules\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' kmod.mod_list\n    " #NEWLINE# mods = set ( ) #NEWLINE# if conf : #NEWLINE# #INDENT# conf = _get_modules_conf ( ) #NEWLINE# if os . path . exists ( conf ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# with salt . utils . fopen ( conf , 'r' ) as modules_file : #NEWLINE# #INDENT# for line in modules_file : #NEWLINE# #INDENT# line = line . strip ( ) #NEWLINE# mod_name = _strip_module_name ( line ) #NEWLINE# if ( ( not line . startswith ( '#' ) ) and mod_name ) : #NEWLINE# #INDENT# mods . add ( mod_name ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except IOError : #NEWLINE# #INDENT# log . error ( 'kmod module could not open modules file at {0}' . format ( conf ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for mod in lsmod ( ) : #NEWLINE# #INDENT# mods . add ( mod [ 'module' ] ) #NEWLINE# #UNINDENT# #UNINDENT# return sorted ( list ( mods ) )