%PDF- %PDF-
| Direktori : /proc/self/root/proc/thread-self/root/usr/lib/python2.7/site-packages/salt/utils/ |
| Current File : //proc/self/root/proc/thread-self/root/usr/lib/python2.7/site-packages/salt/utils/memcached.pyo |
�
���^c @@ s d Z d d l m Z m Z d d l Z d d l m Z m Z d d l m Z d d l
m Z y d d l Z e
Z Wn e k
r� e Z n Xd Z d Z d Z d Z e j e � Z i d d
6Z d � Z d d d d � Z d
� Z e e d � Z d � Z d S( u�
Utilities for working with memcache
:depends: - python-memcached
This library sets up a connection object for memcache, using the configuration
passed into the get_conn() function. Normally, this is __opts__. Optionally,
a profile or specific host and port may be passed in. If neither profile nor
host and port are provided, the defaults of '`127.0.0.`` and ``11211`` are
used. The following configurations are both valid:
.. code-block:: yaml
# No profile name
memcached.host: 127.0.0.1
memcached.port: 11211
# One or more profiles defined
my_memcached_config:
memcached.host: 127.0.0.1
memcached.port: 11211
Once configured, the get_conn() function is passed a set of opts, and,
optionally, the name of a profile to be used.
.. code-block:: python
import salt.utils.memcached_utils.py
conn = salt.utils.memcached_utils.get_conn(__opts__,
profile='my_memcached_config')
It should be noted that some usages of memcached may require a profile to be
specified, rather than top-level configurations. This being the case, it is
better to always use a named configuration profile, as shown above.
i ( t absolute_importt unicode_literalsN( t CommandExecutionErrort SaltInvocationError( t
integer_types( t sixu 127.0.0.1i�+ u setu set_c C@ s t r
t St S( u4
Only load if python-memcached is installed
( t HAS_LIBSt Truet False( ( ( s8 /usr/lib/python2.7/site-packages/salt/utils/memcached.pyt __virtual__F s c C@ s� | o | s� | j d i � } | j d i � } i } | j | � | j | � | j | � | rx | j | i � } n | } | j d t � } | j d t � } n t j | � j � s� t d � � n t r� t j
d j | | � g � St d � � d S( u6
Return a conn object for accessing memcached
u pillaru masteru memcached.hostu memcached.portu port must be an integeru {0}:{1}u= (unable to import memcache, module most likely not installed)N(
t gett updatet DEFAULT_HOSTt DEFAULT_PORTR t text_typet isdigitR R t memcachet Clientt formatR ( t optst profilet hostt portt opts_pillart opts_mastert opts_mergedt conf( ( s8 /usr/lib/python2.7/site-packages/salt/utils/memcached.pyt get_connM s$
c C@ s% | j � } | s! t d � � n | S( u�
Helper function to check the stats data passed into it, and raise an
exception if none are returned. Otherwise, the stats are returned.
u* memcached server is down or does not exist( t get_statsR ( t connt stats( ( s8 /usr/lib/python2.7/site-packages/salt/utils/memcached.pyt _check_statsn s
c C@ s\ t | t � s t d � � n t | t � s<