Package: python-etcd-azion
python-etcd documentation=========================A python client for Etcd https://github.com/coreos/etcdOfficial documentation: http://python-etcd.readthedocs.org/.. image:: https://travis-ci.org/jplana/python-etcd.png?branch=master:target: https://travis-ci.org/jplana/python-etcdInstallation------------Pre-requirements~~~~~~~~~~~~~~~~Install etcd (0.2.rc1 or later). This version of python-etcd will only work correctly with the etcd API version 2.This client is known to work with python 2.7 and with python 3.3 or above. It is not tested or expected to work in more outddated versions of python.From source~~~~~~~~~~~.. code:: bash$ python setup.py installUsage-----The basic methods of the client have changed compared to previous versions, to reflect the new API structure; however a compatibility layer has been maintained so that you don't necessarily need to rewrite all your existing code.Create a client object~~~~~~~~~~~~~~~~~~~~~~.. code:: pythonimport etcdclient = etcd.Client() # this will create a client against etcd server running on localhost on port 4001client = etcd.Client(port=4002)client = etcd.Client(host='127.0.0.1', port=4003)client = etcd.Client(host='127.0.0.1', port=4003, allow_redirect=False) # wont let you run sensitive commands on non-leader machines, default is true# create a client against https://api.example.com:443/etcdclient = etcd.Client(host='api.example.com', protocol='https', port=443, version_prefix='/etcd')Write a key~~~~~~~~~.. code:: pythonclient.write('/nodes/n1', 1)# with ttlclient.write('/nodes/n2', 2, ttl=4)  # sets the ttl to 4 secondsclient.set('/nodes/n2', 1) # Equivalent, for compatibility reasons.Read a key~~~~~~~~~.. code:: pythonclient.read('/nodes/n2').valueclient.read('/nodes', recursive = True) #get all the values of a directory, recursively.client.get('/nodes/n2').valueDelete a key~~~~~~~~~~~~.. code:: pythonclient.delete('/nodes/n1')Atomic Compare and Swap~~~~~~~~~~~~.. code:: pythonclient.write('/nodes/n2', 2, prevValue = 4) # will set /nodes/n2 's value to 2 only if its previous value was 4 andclient.write('/nodes/n2', 2, prevExist = False) # will set /nodes/n2 's value to 2 only if the key did not exist beforeclient.write('/nodes/n2', 2, prevIndex = 30) # will set /nodes/n2 's value to 2 only if the key was last modified at index 30client.test_and_set('/nodes/n2', 2, 4) #equivalent to client.write('/nodes/n2', 2, prevValue = 4)You can also atomically update a result:.. code:: pythonresult = client.read('/foo')print(result.value) # barresult.value += u'bar'updated = client.update(result) # if any other client wrote '/foo' in the meantime this will failprint(updated.value) # barbarWatch a key~~~~~~~~~~~.. code:: pythonclient.read('/nodes/n1', wait = True) # will wait till the key is changed, and return once its changedclient.read('/nodes/n1', wait = True, timeout=30) # will wait till the key is changed, and return once its changed, or exit with an exception after 30 seconds.client.read('/nodes/n1', wait = True, waitIndex = 10) # get all changes on this key starting from index 10client.watch('/nodes/n1') #equivalent to client.read('/nodes/n1', wait = True)client.watch('/nodes/n1', index = 10)Locking module~~~~~~~~~~~~~~.. code:: python# Initialize the lock object:# NOTE: this does not acquire a lock yetclient = etcd.Client()lock = client.get_lock('/customer1', ttl=60)# Use the lock object:lock.acquire(timeout=30) #returns if lock could not be acquired within 30 secondslock.is_locked()  # Truelock.renew(60)lock.release()lock.is_locked()  # False# The lock object may also be used as a context manager:client = etcd.Client()lock = client.get_lock('/customer1', ttl=60)with lock as my_lock:do_stuff()lock.is_locked()  # Truelock.renew(60)lock.is_locked()  # FalseLeader Election module~~~~~~~~~~~~~~~~~~~~~~.. code:: python# Set a leader object with a name; if no name is given, the local hostname# is used.# Zero or no ttl means the leader object is persistent.client = etcd.Client()client.election.set('/mysql', name='foo.example.com', ttl=120, timeout=30) # returns the etcd index# Get the nameprint(client.election.get('/mysql')) # 'foo.example.com'# Delete it!print(client.election.delete('/mysql', name='foo.example.com'))Get machines in the cluster~~~~~~~~~~~~~~~~~~~~~~~~~~~.. code:: pythonclient.machinesGet leader of the cluster~~~~~~~~~~~~~~~~~~~~~~~~~.. code:: pythonclient.leaderDevelopment setup-----------------To create a buildout,.. code:: bash$ python bootstrap.py$ bin/buildoutto test you should have etcd available in your system path:.. code:: bash$ bin/testto generate documentation,.. code:: bash$ cd docs$ makeRelease HOWTO-------------To make a release1) Update release date/version in NEWS.txt and setup.py2) Run 'python setup.py sdist'3) Test the generated source distribution in dist/4) Upload to PyPI: 'python setup.py sdist register upload'News====0.3.4-----* Retry in a bigger number of exceptions0.3.3-----*Release date: 12-Apr-2015** Forward leaves_only value in get_subtree() recursive calls* Fix README prevExists->prevExist* Added configurable version_prefix* Added support for recursive watch* Better error handling support (more detailed exceptions)* Fixed some unreliable tests* Fix bad .format usage for Python 2.6* Change package name to python-etcd-azion0.3.2-----*Release date: 4-Aug-2014** Fixed generated documentation version.0.3.1-----*Release date: 4-Aug-2014** Added consisten read option* Fixed timeout parameter in read()* Added atomic delete parameter support* Fixed delete behaviour* Added update method that allows atomic updated on results* Fixed checks on write()* Added leaves generator to EtcdResult and get_subtree for recursive fetch* Added etcd_index to EtcdResult* Changed ethernal -> eternal* Updated urllib3 & pyOpenSSL libraries* Several performance fixes* Better parsing of etcd_index and raft_index* Removed duplicated tests* Added several integration and unit tests* Use etcd v0.3.0 in travis* Execute test using `python setup.py test` and nose0.3.0-----*Release date: 18-Jan-2014** API v2 support* Python 3.3 compatibility0.2.1-----*Release data: 30-Nov-2013** SSL support* Added support for subdirectories in results.* Improve test* Added support for reconnections, allowing death node tolerance.0.2.0-----*Release date: 30-Sep-2013** Allow fetching of multiple keys (sub-nodes)0.1---*Release date: 18-Sep-2013** Initial release