Messaging

pymco.message

python-mcollective messaging objects.

class pymco.message.Filter[source]

Provides MCollective filters for python-mcollective.

This class implements collections.Mapping interface, so it can be used as non mutable mapping (read only dict), but mutable using provided add methods. So that, for adding the agent you can just use add_agent():

filter.add_agent('package')
add_agent(agent)[source]

Add new MCollective agent

Parameters:agent – MCollective agent name.
Returns:self so filters can be chained.
add_cfclass(name)[source]

Add new class applied by your configuration management system.

Roles, cookbooks,... names may be used too.

Parameters:name – class, role, cookbook,... name.
Returns:self so filters can be chained.
add_fact(fact, value, operator=None)[source]

Add a new Facter fact based filter.

Parameters:
  • fact – fact name.
  • value – fact value.
  • operator – Operator to be applied when comparing the fact. Valid values are: ==, <=, >=, <, >, !=. Optional parameter.
Returns:

self so filters can be chained.

add_identity(identity)[source]

Adds new identities

Parameters:identity – MCollective identity value.
Returns:self so filters can be chained.
class pymco.message.Message(body, agent, config, filter_=None, **kwargs)[source]

Provides MCollective messages for python-mcollective.

This class implements collections.MutableMapping interface, so it can be used as read/write mapping (dictionary).

Parameters:
  • body – the message body. It must be serializable using current serialization method.
  • agent – message target agent.
  • configpymco.config.Config instance.
  • filterFilter instance. This parameter is optional.
  • kwargs – Extra keyword arguments. You can set the target collective or the message ttl using them.
Raise:

pymco.exc.ImproperlyConfigured if configuration has no identity or collective is not set neither in kwargs nor in configuration.