Configuration

pymco.config

Provides MCollective configuration parsing and an entry point for getting the right plugin classes.

class pymco.config.Config(configdict, logger=<logging.Logger object>)[source]

python-mcollective confiugration class.

Parameters:configdict (dict) – a dictionary like object containing configuration as key values.
static from_configfile(configfile)[source]

Reads configfile and returns a new Config instance

Parameters:configfile – path to the configuration file to be parsed.
Returns:Config instance.
static from_configstr(configstr, section='default')[source]

Parses given string an returns a new Config instance

Parameters:
  • configstr – configuration file content as string.
  • section – dummy section to be used for parsing configuration as INI file.
Returns:

Config instance.

get(name, *args, **kwargs)[source]

Get option by key.

Parameters:key – key to look for.
get_conn_params()[source]

Get STOMP connection parameters for current configuration.

Returns:Dictionary with stomp.py connection like key/values.
get_connector()[source]

Get connector based on MCollective settings.

get_host_and_ports()[source]

Get all hosts and port pairs for the current configuration.

The result must follow the stomp.Connection host_and_ports parameter.

Returns:Iterable of two-tuple where the first element is the host and the second is the port.
get_security()[source]

Get security plugin based on MCollective settings.

get_serializer(key)[source]

Get serializer based on MCollective settings.

get_ssl_params()[source]

Get SSL configuration for current connector

Returns:An iterable of SSL configuration parameters to be used with stomp.Transport.set_ssl().
get_user_and_password(current_host_and_port=None)[source]

Get the user and password for the current host and port.

Parameters:

current_host_and_port – two-tuple iterable where the first element is the host and second is the port. This parameter is not required for pymco.connector.stomp.StompConnector connector.

Returns:

Two-tuple where the first element is the user and the second is the password for the given host and port.

Raises:
  • ValueError – if connector isn’t stomp and host_and_port is not provided.
  • pymco.exc.ConfigLookupError – if host and port are not found into the connector list of host and ports.
getboolean(name, *args, **kwargs)[source]

Get bool option by key.

Acceptable truly values are: true, y, 1 and yes, thought MCollective only officially supports 1.

Parameters:key – key to look for.
getfloat(name, *args, **kwargs)[source]

Get float option by key.

Parameters:key – key to look for.
getint(name, *args, **kwargs)[source]

Get int option by key.

Parameters:key – key to look for.
pymco.config.lookup_with_default(fnc)[source]

Wraps ConfigParser lookups, catching exceptions and providing defaults.

Parameters:fnc – Function to be decorated.
pymco.config.INFINITE

Constant used for trying middleware connections indefinitely.