%PDF- %PDF-
| Direktori : /proc/self/root/proc/3522530/root/lib/python2.7/site-packages/salt/tops/ |
| Current File : //proc/self/root/proc/3522530/root/lib/python2.7/site-packages/salt/tops/mongo.pyo |
�
���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l Z y d d l Z e Z Wn e
k
ri e Z n Xi d d 6d d 6d d 6d d
6d d 6Z d � Z
e j e � Z d
� Z d S( u
Read tops data from a mongodb collection
This module will load tops data from a mongo collection. It uses the node's id
for lookups.
Salt Master Mongo Configuration
===============================
The module shares the same base mongo connection variables as
:py:mod:`salt.returners.mongo_return`. These variables go in your master
config file.
* ``mongo.db`` - The mongo database to connect to. Defaults to ``'salt'``.
* ``mongo.host`` - The mongo host to connect to. Supports replica sets by
specifying all hosts in the set, comma-delimited. Defaults to ``'salt'``.
* ``mongo.port`` - The port that the mongo database is running on. Defaults
to ``27017``.
* ``mongo.user`` - The username for connecting to mongo. Only required if
you are using mongo authentication. Defaults to ``''``.
* ``mongo.password`` - The password for connecting to mongo. Only required
if you are using mongo authentication. Defaults to ``''``.
Configuring the Mongo Tops Subsystem
====================================
.. code-block:: yaml
master_tops:
mongo:
collection: tops
id_field: _id
re_replace: ""
re_pattern: \.example\.com
states_field: states
environment_field: environment
Module Documentation
====================
i ( t absolute_importt print_functiont unicode_literalsNu saltu mongo.dbu
mongo.hostu u mongo.passwordi�i u
mongo.portu
mongo.userc C@ s t s
t Sd S( Nu mongo( t HAS_PYMONGOt False( ( ( s3 /usr/lib/python2.7/site-packages/salt/tops/mongo.pyt __virtual__A s c K@ s t d } t d } t d d j d d � } t d d j d d � } t d d j d d
� } t d d j d d
� } t d d j d d
� } t d d j d d � } t j d | | � t j | | � } t j d t d � | t d }
t j d � } t j d � } | rD| rDt j d | � |
j | | � n | d d }
| rpt j | | |
� }
n t j d | |
� |
| j
i |
| 6d | | g �} | r�| | k r�| | k r�| | } n d } t j d � i | | | 6St j d | � i Sd S( u{
Connect to a mongo database and read per-node tops data.
Parameters:
* `collection`: The mongodb collection to read data from. Defaults to
``'tops'``.
* `id_field`: The field in the collection that represents an individual
minion id. Defaults to ``'_id'``.
* `re_pattern`: If your naming convention in the collection is shorter
than the minion id, you can use this to trim the name.
`re_pattern` will be used to match the name, and `re_replace` will
be used to replace it. Backrefs are supported as they are in the
Python standard library. If ``None``, no mangling of the name will
be performed - the collection will be searched with the entire
minion id. Defaults to ``None``.
* `re_replace`: Use as the replacement value in node ids matched with
`re_pattern`. Defaults to ''. Feel free to use backreferences here.
* `states_field`: The name of the field providing a list of states.
* `environment_field`: The name of the field providing the environment.
Defaults to ``environment``.
u
mongo.hostu
mongo.portu master_topsu mongou
collectionu topsu id_fieldu _idu
re_patternu u
re_replaceu states_fieldu statesu environment_fieldu environmentu&