A library for implementing Choria External Discovery in Python
Project description
py-choria-discovery
Overview
py-choria-discovery
contains a collection of tools for writing Choria External Discovery plugins in Python.
Installation
pip install py-choria-discovery
This library requires a version of Choria with external discovery support (0.19.1+).
Implementing Discovery plugins
The bare minimum steps to implement a python discovery plugin are:
- Create a python file without a
.py
extension
#!/usr/bin/python3
from choria_external.dispatcher import dispatch
from choria_discovery import Discovery
class MyDiscovery(Discovery):
def discover(self):
filtered_nodes = []
# Retrieve your list of all available nodes
#nodes = get_nodes()
# Apply the filters in self.request.collective and self.request.filter
#filtered_nodes = apply_filters()
# Return the set of node names which match the filters
self.reply.nodes = filtered_nodes
if __name__ == '__main__':
dispatch(MyDiscovery)
Example
See examples/static for a basic implementation of the node filtering and response.
Reference
Discovery
Provides a base class for implementing External Discovery plugins
Public methods:
discover
Returns a boolean value to indicate whether the agent should be activated on this host. By default returns True and the agent is always activated. Subclasses may choose to override this method and deactivate themselves under appropriate conditions such as missing pre-requisites.
Instance variables:
logger
Contains a python logger which can be used to send log information back to choria (debug and info are sent to stdout, which is only displayed in verbose mode; warnings and errors are sent to stderr which are displayed always). The logger is set to use thechoria.plugin_name
hierarchy. By default all other logging is disabled to prevent pollution of the reply. This is done by setting the log level on the root logger to 100. You can re-enable logging by adjusting the log-level on either the root logger or a specific child if required.config
Contains a dict-like object which can be used to read configuration settings from a choria plugin configuration file (/etc/puppetlabs/mcollective/plugin.d/agentname.cfg
by default).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file py-choria-discovery-0.1.1.tar.gz
.
File metadata
- Download URL: py-choria-discovery-0.1.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c80e69edce3aa5bc5815cdae3c7006e72a0d2852e6b6415f3c5d7ebcc63b9e7 |
|
MD5 | abb74a71793877cc960bc9057bebf1c3 |
|
BLAKE2b-256 | 6c13b5ca3738857233a8e24e7d316936711d2f5f6cc5856c2c7c4df34fcbe32f |