Connectors¶
Connectors base¶
python-mcollective base for MCollective connector plugins.
-
class
pymco.connector.BaseConnector(config, connection=None, logger=<logging.Logger object>)[source]¶ Base abstract class for MCollective connectors.
Parameters: - config (pymco.config.Config) – configuration instance.
- connection (stomp.Connection) – connection object. Optional
parameter, if not given
default_connection()result will be used.
-
connect(wait=None)[source]¶ Connect to MCollective middleware.
Parameters: wait (bool) – wait for connection to be established or not. Returns: self
-
classmethod
default_connection(config)[source]¶ Creates a
stomp.Connectionobject with defaultsReturns: stomp.Connectionobject.
-
get_current_host_and_port()[source]¶ Get the current host and port from the tracker listener.
Returns: A two-tuple, where the first element is the current host and the second the current port.
-
receive(timeout, *args, **kwargs)[source]¶ Subscribe to MCollective topic queue and wait for just one message.
Parameters: - timeout (float) – how long we should wait for the message in seconds.
- *args – extra positional arguments.
- **kwargs – extra keyword arguments.
Returns: received message.
Raise: pymco.exc.TimeoutErrorif expected messages doesn’t come in giventimeoutseconds.
-
security¶ Security provider property.
-
send(msg, destination, *args, **kwargs)[source]¶ Send an MCollective message.
Parameters: - msg (pymco.message.Message) – message to be sent.
- *args – extra positional arguments.
- **kwargs – extra keyword arguments.
Returns: self.
-
subscribe(destination, id=None, *args, **kwargs)[source]¶ Subscribe to MCollective queue.
Parameters: - destination – Target to subscribe.
- *args – extra positional arguments.
- **kwargs – extra keyword arguments.
Returns: self.
-
unsubscribe(destination, *args, **kwargs)[source]¶ Unsubscribe to MCollective queue.
Parameters: - destination – Target to unsubscribe.
- *args – extra positional arguments.
- **kwargs – extra keyword arguments.
Returns: self.
-
use_b64¶ Determines if the message should be base64 encoded.
-
pymco.connector.get_reply_target(self, agent, collective)[source]¶ Get the message target for the given agent and collective.
Parameters: - agent – MCollective target agent name.
- collective – MCollective target collective.
Returns: message reply target string representation for given agent and collective.
-
pymco.connector.get_target(self, agent, collective, topciprefix=None)[source]¶ Get the message target for the given agent and collective.
Parameters: - agent – MCollective target agent name.
- collective – MCollective target collective.
- topicprefix – Required for older versions of MCollective
Returns: Message target string representation for given agent and collective.