def include_config(include, orig_path, verbose, exit_on_config_errors=False):
    '''
    Parses extra configuration file(s) specified in an include list in the
    main config file.
    '''
    # Protect against empty option
    if not include:
        return {}

    if orig_path is None:
        # When the passed path is None, we just want the configuration
        # defaults, not actually loading the whole configuration.
        return {}

    if isinstance(include, six.string_types):
        include = [include]

    configuration = {}
    for path in include:
        # Allow for includes like ~/foo
        path = os.path.expanduser(path)
        if not os.path.isabs(path):
            path = os.path.join(os.path.dirname(orig_path), path)

        # Catch situation where user typos path in configuration; also warns
        # for empty include directory (which might be by design)
        glob_matches = glob.glob(path)
        if not glob_matches:
            if verbose:
                log.warning(
                    'Warning parsing configuration file: "include" path/glob '
                    "'%s' matches no files", path
                )

        for fn_ in sorted(glob_matches):
            log.debug('Including configuration from \'%s\'', fn_)
            try:
                opts = _read_conf_file(fn_)
            except salt.exceptions.SaltConfigurationError as error:
                log.error(error)
                if exit_on_config_errors:
                    sys.exit(salt.defaults.exitcodes.EX_GENERIC)
                else:
                    # Initialize default config if we wish to skip config errors
                    opts = {}
            schedule = opts.get('schedule', {})
            if schedule and 'schedule' in configuration:
                configuration['schedule'].update(schedule)
            include = opts.get('include', [])
            if include:
                opts.update(include_config(include, fn_, verbose))

            salt.utils.dictupdate.update(configuration, opts, True, True)

    return configuration
def include_config ( include , orig_path , verbose , exit_on_config_errors = False ) : if not include : return { } if orig_path is None : return { } if isinstance ( include , six . string_types ) : include = [ include ] configuration = { } for path in include : path = os . path . expanduser ( path ) if not os . path . isabs ( path ) : path = os . path . join ( os . path . dirname ( orig_path ) , path ) glob_matches = glob . glob ( path ) if not glob_matches : if verbose : log . warning ( 'Warning parsing configuration file: "include" path/glob ' "'%s' matches no files" , path ) for fn_ in sorted ( glob_matches ) : log . debug ( 'Including configuration from \'%s\'' , fn_ ) try : opts = _read_conf_file ( fn_ ) except salt . exceptions . SaltConfigurationError as error : log . error ( error ) if exit_on_config_errors : sys . exit ( salt . defaults . exitcodes . EX_GENERIC ) else : opts = { } schedule = opts . get ( 'schedule' , { } ) if schedule and 'schedule' in configuration : configuration [ 'schedule' ] . update ( schedule ) include = opts . get ( 'include' , [ ] ) if include : opts . update ( include_config ( include , fn_ , verbose ) ) salt . utils . dictupdate . update ( configuration , opts , True , True ) return configuration
Parses extra configuration file(s) specified in an include list in the
    main config file.