def cloud_config(path, env_var='SALT_CLOUD_CONFIG', defaults=None, master_config_path=None, master_config=None, providers_config_path=None, providers_config=None, profiles_config_path=None, profiles_config=None):
 if path:
  config_dir = os.path.dirname(path)
 else:
  config_dir = salt.syspaths.CONFIG_DIR
 overrides = load_config(path, env_var, os.path.join(config_dir, 'cloud'))
 if (defaults is None):
  defaults = DEFAULT_CLOUD_OPTS.copy()
 defaults.update(overrides)
 overrides = defaults
 overrides.update(salt.config.include_config(overrides['default_include'], path, verbose=False))
 include = overrides.get('include', [])
 overrides.update(salt.config.include_config(include, path, verbose=True))
 if (('master_config' in overrides) and (master_config_path is None)):
  master_config_path = overrides['master_config']
 elif (('master_config' not in overrides) and (not master_config) and (not master_config_path)):
  master_config_path = os.path.join(config_dir, 'master')
 master_config_path = _absolute_path(master_config_path, config_dir)
 if (('providers_config' in overrides) and (providers_config_path is None)):
  providers_config_path = overrides['providers_config']
 elif (('providers_config' not in overrides) and (not providers_config) and (not providers_config_path)):
  providers_config_path = os.path.join(config_dir, 'cloud.providers')
 providers_config_path = _absolute_path(providers_config_path, config_dir)
 if (('profiles_config' in overrides) and (profiles_config_path is None)):
  profiles_config_path = overrides['profiles_config']
 elif (('profiles_config' not in overrides) and (not profiles_config) and (not profiles_config_path)):
  profiles_config_path = os.path.join(config_dir, 'cloud.profiles')
 profiles_config_path = _absolute_path(profiles_config_path, config_dir)
 deploy_scripts_search_path = overrides.get('deploy_scripts_search_path', defaults.get('deploy_scripts_search_path', 'cloud.deploy.d'))
 if isinstance(deploy_scripts_search_path, string_types):
  deploy_scripts_search_path = [deploy_scripts_search_path]
 for (idx, entry) in enumerate(deploy_scripts_search_path[:]):
  if (not os.path.isabs(entry)):
   entry = os.path.join(os.path.dirname(path), entry)
  if os.path.isdir(entry):
   deploy_scripts_search_path[idx] = entry
   continue
  deploy_scripts_search_path.pop(idx)
 deploy_scripts_search_path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'cloud', 'deploy')))
 overrides.update(deploy_scripts_search_path=tuple(deploy_scripts_search_path))
 if ((master_config_path is not None) and (master_config is not None)):
  raise salt.exceptions.SaltCloudConfigError('Only pass `master_config` or `master_config_path`, not both.')
 elif ((master_config_path is None) and (master_config is None)):
  master_config = salt.config.master_config(overrides.get('master_config', os.path.join(salt.syspaths.CONFIG_DIR, 'master')))
 elif ((master_config_path is not None) and (master_config is None)):
  master_config = salt.config.master_config(master_config_path)
 del master_config['cachedir']
 master_config.update(overrides)
 overrides = master_config
 if ((providers_config_path is not None) and (providers_config is not None)):
  raise salt.exceptions.SaltCloudConfigError('Only pass `providers_config` or `providers_config_path`, not both.')
 elif ((providers_config_path is None) and (providers_config is None)):
  providers_config_path = overrides.get('providers_config', os.path.join(salt.syspaths.CONFIG_DIR, 'cloud.providers'))
 if ((profiles_config_path is not None) and (profiles_config is not None)):
  raise salt.exceptions.SaltCloudConfigError('Only pass `profiles_config` or `profiles_config_path`, not both.')
 elif ((profiles_config_path is None) and (profiles_config is None)):
  profiles_config_path = overrides.get('profiles_config', os.path.join(salt.syspaths.CONFIG_DIR, 'cloud.profiles'))
 opts = apply_cloud_config(overrides, defaults)
 if ('providers' in opts):
  if (providers_config is not None):
   raise salt.exceptions.SaltCloudConfigError('Do not mix the old cloud providers configuration with the passing a pre-configured providers configuration dictionary.')
  if (providers_config_path is not None):
   providers_confd = os.path.join(os.path.dirname(providers_config_path), 'cloud.providers.d', '*')
   if (os.path.isfile(providers_config_path) or glob.glob(providers_confd)):
    raise salt.exceptions.SaltCloudConfigError('Do not mix the old cloud providers configuration with the new one. The providers configuration should now go in the file `{0}` or a separate `*.conf` file within `cloud.providers.d/` which is relative to `{0}`.'.format(os.path.join(salt.syspaths.CONFIG_DIR, 'cloud.providers')))
  providers_config = opts['providers']
 elif (providers_config_path is not None):
  providers_config = cloud_providers_config(providers_config_path)
 opts['providers'] = providers_config
 if (profiles_config is None):
  profiles_config = vm_profiles_config(profiles_config_path, providers_config)
 opts['profiles'] = profiles_config
 apply_sdb(opts)
 prepend_root_dirs = ['cachedir']
 prepend_root_dir(opts, prepend_root_dirs)
 return opts

def cloud_config ( path , env_var = 'SALT_CLOUD_CONFIG' , defaults = None , master_config_path = None , master_config = None , providers_config_path = None , providers_config = None , profiles_config_path = None , profiles_config = None ) : if path : config_dir = os . path . dirname ( path ) else : config_dir = salt . syspaths . CONFIG_DIR overrides = load_config ( path , env_var , os . path . join ( config_dir , 'cloud' ) ) if ( defaults is None ) : defaults = DEFAULT_CLOUD_OPTS . copy ( ) defaults . update ( overrides ) overrides = defaults overrides . update ( salt . config . include_config ( overrides [ 'default_include' ] , path , verbose = False ) ) include = overrides . get ( 'include' , [ ] ) overrides . update ( salt . config . include_config ( include , path , verbose = True ) ) if ( ( 'master_config' in overrides ) and ( master_config_path is None ) ) : master_config_path = overrides [ 'master_config' ] elif ( ( 'master_config' not in overrides ) and ( not master_config ) and ( not master_config_path ) ) : master_config_path = os . path . join ( config_dir , 'master' ) master_config_path = _absolute_path ( master_config_path , config_dir ) if ( ( 'providers_config' in overrides ) and ( providers_config_path is None ) ) : providers_config_path = overrides [ 'providers_config' ] elif ( ( 'providers_config' not in overrides ) and ( not providers_config ) and ( not providers_config_path ) ) : providers_config_path = os . path . join ( config_dir , 'cloud.providers' ) providers_config_path = _absolute_path ( providers_config_path , config_dir ) if ( ( 'profiles_config' in overrides ) and ( profiles_config_path is None ) ) : profiles_config_path = overrides [ 'profiles_config' ] elif ( ( 'profiles_config' not in overrides ) and ( not profiles_config ) and ( not profiles_config_path ) ) : profiles_config_path = os . path . join ( config_dir , 'cloud.profiles' ) profiles_config_path = _absolute_path ( profiles_config_path , config_dir ) deploy_scripts_search_path = overrides . get ( 'deploy_scripts_search_path' , defaults . get ( 'deploy_scripts_search_path' , 'cloud.deploy.d' ) ) if isinstance ( deploy_scripts_search_path , string_types ) : deploy_scripts_search_path = [ deploy_scripts_search_path ] for ( idx , entry ) in enumerate ( deploy_scripts_search_path [ : ] ) : if ( not os . path . isabs ( entry ) ) : entry = os . path . join ( os . path . dirname ( path ) , entry ) if os . path . isdir ( entry ) : deploy_scripts_search_path [ idx ] = entry continue deploy_scripts_search_path . pop ( idx ) deploy_scripts_search_path . append ( os . path . abspath ( os . path . join ( os . path . dirname ( __file__ ) , '..' , 'cloud' , 'deploy' ) ) ) overrides . update ( deploy_scripts_search_path = tuple ( deploy_scripts_search_path ) ) if ( ( master_config_path is not None ) and ( master_config is not None ) ) : raise salt . exceptions . SaltCloudConfigError ( 'Only pass `master_config` or `master_config_path`, not both.' ) elif ( ( master_config_path is None ) and ( master_config is None ) ) : master_config = salt . config . master_config ( overrides . get ( 'master_config' , os . path . join ( salt . syspaths . CONFIG_DIR , 'master' ) ) ) elif ( ( master_config_path is not None ) and ( master_config is None ) ) : master_config = salt . config . master_config ( master_config_path ) del master_config [ 'cachedir' ] master_config . update ( overrides ) overrides = master_config if ( ( providers_config_path is not None ) and ( providers_config is not None ) ) : raise salt . exceptions . SaltCloudConfigError ( 'Only pass `providers_config` or `providers_config_path`, not both.' ) elif ( ( providers_config_path is None ) and ( providers_config is None ) ) : providers_config_path = overrides . get ( 'providers_config' , os . path . join ( salt . syspaths . CONFIG_DIR , 'cloud.providers' ) ) if ( ( profiles_config_path is not None ) and ( profiles_config is not None ) ) : raise salt . exceptions . SaltCloudConfigError ( 'Only pass `profiles_config` or `profiles_config_path`, not both.' ) elif ( ( profiles_config_path is None ) and ( profiles_config is None ) ) : profiles_config_path = overrides . get ( 'profiles_config' , os . path . join ( salt . syspaths . CONFIG_DIR , 'cloud.profiles' ) ) opts = apply_cloud_config ( overrides , defaults ) if ( 'providers' in opts ) : if ( providers_config is not None ) : raise salt . exceptions . SaltCloudConfigError ( 'Do not mix the old cloud providers configuration with the passing a pre-configured providers configuration dictionary.' ) if ( providers_config_path is not None ) : providers_confd = os . path . join ( os . path . dirname ( providers_config_path ) , 'cloud.providers.d' , '*' ) if ( os . path . isfile ( providers_config_path ) or glob . glob ( providers_confd ) ) : raise salt . exceptions . SaltCloudConfigError ( 'Do not mix the old cloud providers configuration with the new one. The providers configuration should now go in the file `{0}` or a separate `*.conf` file within `cloud.providers.d/` which is relative to `{0}`.' . format ( os . path . join ( salt . syspaths . CONFIG_DIR , 'cloud.providers' ) ) ) providers_config = opts [ 'providers' ] elif ( providers_config_path is not None ) : providers_config = cloud_providers_config ( providers_config_path ) opts [ 'providers' ] = providers_config if ( profiles_config is None ) : profiles_config = vm_profiles_config ( profiles_config_path , providers_config ) opts [ 'profiles' ] = profiles_config apply_sdb ( opts ) prepend_root_dirs = [ 'cachedir' ] prepend_root_dir ( opts , prepend_root_dirs ) return opts
provides a configuration object as a proxy to environment variables .