elasticluster.conf

Turn ElastiCluster configuration into internal data structures.

Digesting configuration files into data structures ready to be processed by the rest of ElastiCluster happens in three stages:

  1. Read configuration files and create a (nested) key/value store of all the configuration items.
  2. Arrange the configuration items into sets of properties that are needed to create ElastiCluster objects (clusters, cloud providers, etc.) – the outcome of this phase would be a set of dictionaries that can be fed as **kwargs to class constructors.
  3. Instanciate the actual working objects.
class elasticluster.conf.Creator(conf, storage_path=None, storage_type=None)[source]

The Creator class is responsible for:

  1. keeping track of the configuration, and
  2. offering factory methods to create all kind of objects that need information from the configuration, and
  3. loading a cluster from a valid repository.AbstractClusterRepository.

First argument cluster configuration is a nested Python mapping structured in the following way:

'cluster': {  ## this must be literally `cluster`
   { "<cluster_template>" : {
       "setup" : { properties of the setup section },
       "cloud" : { properties of the cloud section },
       "login" : { properties of the login section },
       "cluster" : { properties of the cluster section },
       "nodes": {  "<node_kind>" : { properties of the node},
                   "<node_kind>" : { properties of the node},
               },
       },
    "<cluster_template>" : {
       (see above)
       }
    }
}

The actual “property” parameters follow the names and types described in the Configuration section of the manual. This is indeed nothing more than a dereferenced un-dump of the configuration file; use load_config_files() to load a set of configuration files into a data structure like the above.

Parameters:
  • cluster_conf (dict) – see description above
  • storage_path (str) – path to store data
Raises:

MultipleInvalid – configuration validation

create_cloud_provider(cluster_template)[source]

Return cloud provider instance for the given cluster template.

Parameters:cluster_template (str) – name of cluster template to use
Returns:cloud provider instance that fulfills the contract of elasticluster.providers.AbstractCloudProvider
create_cluster(template, name=None, cloud=None, setup=None)[source]

Creates a Cluster:class: instance by inspecting the configuration properties of the given cluster template.

Parameters:
  • template (str) – name of the cluster template
  • name (str) – name of the cluster. If not defined, the cluster will be named after the template.
  • cloud – A CloudProvider instance to use instead of the configured one. If None (default) then the configured cloud provider will be used.
  • setup – A SetupProvider instance to use instead of the configured one. If None (default) then the configured setup provider will be used.
Returns:

elasticluster.cluster.Cluster instance:

Raises:

ConfigurationError – cluster template not found in config

create_setup_provider(cluster_template, name=None)[source]

Creates the setup provider for the given cluster template.

Parameters:
  • cluster_template (str) – template of the cluster
  • name (str) – name of the cluster to read configuration properties
load_cluster(cluster_name)[source]

Load a cluster from the configured repository.

Parameters:cluster_name (str) – name of the cluster
Returns:elasticluster.cluster.cluster instance
elasticluster.conf.load_config_files(paths)[source]

Read configuration file(s) and return corresponding data structure.

Parameters:paths – list of file names to load.
elasticluster.conf.make_creator(configfiles, storage_path=None)[source]

Return a Creator instance initialized from given configuration files.

Parameters:
  • configfiles (list) – list of paths to the INI-style file(s). For each path P in configfiles, if a directory named P.d exists, also reads all the *.conf files in that directory.
  • storage_path (str) – path to the storage directory. If defined, a repository.DiskRepository class will be instantiated.
Returns:

Creator