def enabled( self, paths=None, saltenv=None, files=None, view=None, flat=False ): ''' :param paths: :param saltenv: :param files: :param view: :param flat: ''' # Convert paths to top_paths toppaths = self.prepare_paths(paths)[0] enabled = self.files( saltenv=saltenv, files=files, view='raw', toppath=toppaths, abspath=self.pattern_enable ) view = view or ['saltenv', 'abspath'] return fileinfo.fileinfo_view(enabled, view=view, flat=flat)
def _status(view=None, flat=None, **kwargs): view = view or ['saltenv', 'abspath'] status = {} for key, topinfo in six.iteritems(kwargs): if topinfo: status[key] = fileinfo.fileinfo_view( topinfo, view=view, flat=flat ) return status
def disabled( self, paths=None, saltenv=None, files=None, view=None, flat=False ): ''' :param paths: :param saltenv: :param files: :param view: :param flat: ''' # Convert paths to top_paths toppaths = self.prepare_paths(paths)[0] all_tops = self.files( saltenv=saltenv, files=files, view='raw', toppath=toppaths ) # Don't include enabled tops enabled = set( self.enabled( paths=paths, saltenv=saltenv, files=files, view='raw' ) ) # Don't include tops link target enabled.update(set(self.include_links(enabled))) disabled = set(all_tops).difference(enabled) view = view or ['saltenv', 'abspath'] return fileinfo.fileinfo_view(list(disabled), view=view, flat=flat)
def files(self, saltenv=None, roots=None, view=None, files=None, flat=None, pathinfo=None, **patterns): ''' Return a list of the files in the file server's specified environment or a dictionary of all results if saltenv is None. All files will be filtered if a pattern is supplied. :param saltenv: Can be a single saltenv such as 'base', a list of saltenv's such as ['base', 'all'], or None in which case all saltenv's will be set. :param roots: :param view: :param files: :param patterns: Only return files that match wildcard pattern filter such as '*.tops'. :param flat: If True, a list of all environment values will be returned, otherwise a dictionary with the passed saltenv will be returned. The default for a single salt environment is to flatten. :param pathinfo: FileInfo instance to use to parse filelist. ''' if files: return self.find(files, **patterns) # Convert saltenv to list; include all environments if saltenv is None saltenvs = self.saltenvs(saltenv) # XXX: Test with get_top; maybe don't need cache_roots / file_roots # if pillar is True # # Get default file_roots, pillar_roots and cache_roots if roots is None if not roots: roots = self.pathinfo_roots(saltenvs) # Select patterns to use for filtering file list or default to selected # saltenvs patterns = patterns or dict(saltenv=saltenvs) # XXX: Add a way to determine which object to use? # topinfo may want to have different object; maybe a routine # that calls this one first so as not to overload file signature # # Walk roots to retrieve a listing of all files pathinfo = pathinfo or PathInfo(match_each=True, **patterns) # Extra kwargs for pathinfo extra_kwargs = { 'cachedir': self.opts.get('cachedir', None), 'is_pillar': self.is_pillar() } # Generate filtered pathinfo list files = pathinfo.filelist(roots=roots, **extra_kwargs) # Determine and return pathinfo view which can be one of flattened, # reduceby (dictionary) or all (un-modified). if len(saltenvs) == 1 and flat is None: flat = True view = view or ['saltenv', 'relpath'] return fileinfo.fileinfo_view(files, view=view, flat=flat)
def files( self, saltenv=None, roots=None, view=None, files=None, flat=None, pathinfo=None, **patterns ): ''' Return a list of the files in the file server's specified environment or a dictionary of all results if saltenv is None. All files will be filtered if a pattern is supplied. :param saltenv: Can be a single saltenv such as 'base', a list of saltenv's such as ['base', 'all'], or None in which case all saltenv's will be set. :param roots: :param view: :param files: :param patterns: Only return files that match wildcard pattern filter such as '*.tops'. :param flat: If True, a list of all environment values will be returned, otherwise a dictionary with the passed saltenv will be returned. The default for a single salt environment is to flatten. :param pathinfo: FileInfo instance to use to parse filelist. ''' if files: return self.find(files, **patterns) # Convert saltenv to list; include all environments if saltenv is None saltenvs = self.saltenvs(saltenv) # XXX: Test with get_top; maybe don't need cache_roots / file_roots # if pillar is True # # Get default file_roots, pillar_roots and cache_roots if roots is None if not roots: roots = self.pathinfo_roots(saltenvs) # Select patterns to use for filtering file list or default to selected # saltenvs patterns = patterns or dict(saltenv=saltenvs) # XXX: Add a way to determine which object to use? # topinfo may want to have different object; maybe a routine # that calls this one first so as not to overload file signature # # Walk roots to retrieve a listing of all files pathinfo = pathinfo or PathInfo(match_each=True, **patterns) # Extra kwargs for pathinfo extra_kwargs = { 'cachedir': self.opts.get('cachedir', None), 'is_pillar': self.is_pillar() } # Generate filtered pathinfo list files = pathinfo.filelist(roots=roots, **extra_kwargs) # Determine and return pathinfo view which can be one of flattened, # reduceby (dictionary) or all (un-modified). if len(saltenvs) == 1 and flat is None: flat = True view = view or ['saltenv', 'relpath'] return fileinfo.fileinfo_view(files, view=view, flat=flat)