Package starcluster :: Module config :: Class StarClusterConfig
[hide private]
[frames] | no frames]

Class StarClusterConfig

source code


Loads StarCluster configuration settings defined in config_file which defaults to ~/.starclustercfg

Settings are available as follows:

cfg = StarClusterConfig() or cfg = StarClusterConfig('/path/to/my/config.cfg') cfg.load() aws_info = cfg.aws cluster_cfg = cfg.clusters['mycluster'] key_cfg = cfg.keys['gsg-keypair'] print cluster_cfg

Instance Methods [hide private]
 
__init__(self, config_file=None, cache=False)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__repr__(self)
repr(x)
source code
 
_get_urlfp(self, url) source code
 
_get_fp(self, cfg_file) source code
 
_get_cfg_fp(self, cfg_file=None) source code
 
_get_bool(self, config, section, option) source code
 
_get_int(self, config, section, option) source code
 
_get_float(self, config, section, option) source code
 
_get_string(self, config, section, option) source code
 
_get_list(self, config, section, option) source code
 
__load_config(self)
Populates self._config with a new ConfigParser instance
source code
 
reload(self)
Reloads the configuration file
source code
 
_load_settings(self, section_name, settings, store, filter_settings=True)
Load section settings into a dictionary
source code
 
_check_required(self, section_name, settings, store)
Check that all required settings were specified in the config.
source code
 
_load_defaults(self, settings, store)
Sets the default for each setting in settings regardless of whether the setting was specified in the config or not.
source code
 
_load_extends_settings(self, section_name, store)
Loads all settings from other template(s) specified by a section's 'extends' setting.
source code
 
_load_keypairs(self, store) source code
 
_load_volumes(self, store) source code
 
_load_plugins(self, store) source code
 
_load_permissions(self, store) source code
 
_load_instance_types(self, store) source code
 
_load_section(self, section_name, section_settings, filter_settings=True)
Returns a dictionary containing all section_settings for a given section_name by first loading the settings in the config, loading the defaults for all settings not specified, and then checking that all required options have been specified
source code
 
_get_section_name(self, section)
Returns section name minus prefix e.g.
source code
 
_get_sections(self, section_prefix)
Returns all sections starting with section_prefix e.g.
source code
 
_load_sections(self, section_prefix, section_settings, filter_settings=True)
Loads all sections starting with section_prefix and returns a dictionary containing the name and dictionary of settings for each section.
source code
 
_load_cluster_sections(self, cluster_sections)
Loads all cluster sections.
source code
 
load(self)
Populate this config object from the StarCluster config
source code
 
get_aws_from_environ(self)
Returns AWS credentials defined in the user's shell environment.
source code
 
get_aws_credentials(self)
Returns AWS credentials defined in the configuration file.
source code
 
get_cluster_names(self) source code
 
get_cluster_template(self, template_name, tag_name=None, ec2_conn=None)
Returns Cluster instance configured with the settings in the config file.
source code
 
get_default_cluster_template(self)
Returns the default_template specified in the [global] section of the config.
source code
 
get_clusters(self) source code
 
get_plugin(self, plugin) source code
 
get_key(self, keyname) source code
 
get_easy_s3(self)
Factory for EasyEC2 class that attempts to load AWS credentials from the StarCluster config file.
source code
 
get_easy_ec2(self)
Factory for EasyEC2 class that attempts to load AWS credentials from the StarCluster config file.
source code
 
get_cluster_manager(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  global_settings = {'default_template': (<type 'str'>, False, N...
  aws_settings = {'aws_access_key_id': (<type 'str'>, True, None...
  key_settings = {'key_location': (<type 'str'>, True, None, Non...
  volume_settings = {'device': (<type 'str'>, False, None, None,...
  plugin_settings = {'setup_class': (<type 'str'>, True, None, N...
  cluster_settings = {'availability_zone': (<type 'str'>, False,...
  permission_settings = {'cidr_ip': (<type 'str'>, False, '0.0.0...
  instance_types = {'c1.medium': ['i386'], 'c1.xlarge': ['x86_64...
Properties [hide private]
  config

Inherited from object: __class__

Method Details [hide private]

__init__(self, config_file=None, cache=False)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

_check_required(self, section_name, settings, store)

source code 

Check that all required settings were specified in the config. Raises ConfigError otherwise.

Note that if a setting specified has required=True and default is not None then this method will not raise an error because a default was given. In short, if a setting is required you must provide None as the 'default' value.

_load_extends_settings(self, section_name, store)

source code 

Loads all settings from other template(s) specified by a section's 'extends' setting.

This method walks a dependency tree of sections from bottom up. Each step is a group of settings for a section in the form of a dictionary. A 'master' dictionary is updated with the settings at each step. This causes the next group of settings to override the previous, and so on. The 'section_name' settings are at the top of the dep tree.

_get_section_name(self, section)

source code 

Returns section name minus prefix e.g. $ print self._get_section('cluster smallcluster') $ smallcluster

_get_sections(self, section_prefix)

source code 

Returns all sections starting with section_prefix e.g. $ print self._get_sections('cluster') $ ['cluster smallcluster', 'cluster mediumcluster', ..]

_load_sections(self, section_prefix, section_settings, filter_settings=True)

source code 

Loads all sections starting with section_prefix and returns a
dictionary containing the name and dictionary of settings for each
section.
keys --> section name (as returned by self._get_section_name)
values --> dictionary of settings for a given section

e.g.
$ print self._load_sections('volumes', self.plugin_settings)

{'myvol': {'__name__': 'volume myvol',
            'device': None,
            'mount_path': '/home',
            'partition': 1,
            'volume_id': 'vol-999999'},
 'myvol2': {'__name__': 'volume myvol2',
               'device': None,
               'mount_path': '/myvol2',
               'partition': 1,
               'volume_id': 'vol-999999'},

_load_cluster_sections(self, cluster_sections)

source code 

Loads all cluster sections. Similar to _load_sections but also handles populating specified keypair,volume,plugins,permissions,etc settings

get_aws_credentials(self)

source code 

Returns AWS credentials defined in the configuration file. Defining any of the AWS settings in the environment overrides the configuration file.

get_cluster_template(self, template_name, tag_name=None, ec2_conn=None)

source code 

Returns Cluster instance configured with the settings in the config file.

template_name is the name of a cluster section defined in the config

tag_name, if specified, will be passed to Cluster instance as cluster_tag

get_default_cluster_template(self)

source code 

Returns the default_template specified in the [global] section of the config. Raises NoDefaultTemplateFound if no default cluster template has been specified in the config.

get_easy_s3(self)

source code 

Factory for EasyEC2 class that attempts to load AWS credentials from the StarCluster config file. Returns an EasyS3 object if successful.

get_easy_ec2(self)

source code 

Factory for EasyEC2 class that attempts to load AWS credentials from the StarCluster config file. Returns an EasyEC2 object if successful.


Class Variable Details [hide private]

global_settings

Value:
{'default_template': (<type 'str'>, False, None, None, None),
 'enable_experimental': (<type 'bool'>, False, False, None, None),
 'include': (<type 'list'>, False, [], None, None),
 'refresh_interval': (<type 'int'>, False, 30, None, None),
 'web_browser': (<type 'str'>, False, None, None, None)}

aws_settings

Value:
{'aws_access_key_id': (<type 'str'>, True, None, None, None),
 'aws_ec2_path': (<type 'str'>, False, '/', None, None),
 'aws_is_secure': (<type 'bool'>, False, True, None, None),
 'aws_port': (<type 'int'>, False, None, None, None),
 'aws_region_host': (<type 'str'>, False, None, None, None),
 'aws_region_name': (<type 'str'>, False, None, None, None),
 'aws_s3_host': (<type 'str'>, False, None, None, None),
 'aws_s3_path': (<type 'str'>, False, '/', None, None),
...

key_settings

Value:
{'key_location': (<type 'str'>,
                  True,
                  None,
                  None,
                  <function __expand_all at 0x1512c80>)}

volume_settings

Value:
{'device': (<type 'str'>, False, None, None, None),
 'mount_path': (<type 'str'>, True, None, None, None),
 'partition': (<type 'int'>, False, None, None, None),
 'volume_id': (<type 'str'>, True, None, None, None)}

plugin_settings

Value:
{'setup_class': (<type 'str'>, True, None, None, None)}

cluster_settings

Value:
{'availability_zone': (<type 'str'>, False, None, None, None),
 'cluster_shell': (<type 'str'>,
                   False,
                   'bash',
                   ['tcsh', 'zsh', 'csh', 'bash', 'ksh'],
                   None),
 'cluster_size': (<type 'int'>, True, None, None, None),
 'cluster_user': (<type 'str'>, False, 'sgeadmin', None, None),
...

permission_settings

Value:
{'cidr_ip': (<type 'str'>, False, '0.0.0.0/0', None, None),
 'from_port': (<type 'int'>, True, None, None, None),
 'ip_protocol': (<type 'str'>,
                 False,
                 'tcp',
                 ['tcp', 'udp', 'icmp'],
                 None),
 'to_port': (<type 'int'>, True, None, None, None)}

instance_types

Value:
{'c1.medium': ['i386'],
 'c1.xlarge': ['x86_64'],
 'cc1.4xlarge': ['x86_64'],
 'cg1.4xlarge': ['x86_64'],
 'm1.large': ['x86_64'],
 'm1.small': ['i386'],
 'm1.xlarge': ['x86_64'],
 'm2.2xlarge': ['x86_64'],
...

Property Details [hide private]

config

Get Method:
unreachable.config(self)