pyconsul

Python client for Consul (http://www.consul.io)


License
MIT
Install
pip install pyconsul==0.0.1

Documentation

PyConsul

Latest Version Build Status Coverage Status Code Health Requirements Status License

Python client for Consul

A dummy, one-file implementation on top of the HTTP API of Consul.

This is also a convenient interface for iron-app enabled applications.

Teaser

# Dpending on your setup, sudo might be required
pip install pyconsul
# Assuming you have a running server of consul locally
# Consul cluster visibility
c = http.Consul()
print c.nodes, c.services
Out[20]: 
[{u'Node': u'master', u'Address': u'192.168.0.21'}] {u'consul': []}

print c.health(node='master')
Out[21]: 
[{u'CheckID': u'serfHealth',
  u'Name': u'Serf Health Status',
  u'Node': u'master',
  u'Notes': u'',
  u'Output': u'Agent alive and reachable',
  u'ServiceID': u'',
  u'ServiceName': u'',
  u'Status': u'passing'}]

# Consul kv storage interface
print c.storage.get('my/config', recurse=True)
Out[22]: 
[{u'CreateIndex': 26,
  u'Flags': 0,
  u'Key': u'my/config',
  u'LockIndex': 0,
  u'ModifyIndex': 26,
  u'Value': 'nothing set yet'}]

# App on steroids, powered by iron-app
app = iron.App('my-app')
# Get my-app os, platform, command ...
print app['metadatas']
if app.metrics.available:
  io_data = app.metrics['io.read.count']
  print io_data.head()
Out[28]:
2014-08-10 10:43:01    12590538
2014-08-10 10:42:51    12590538
2014-08-10 10:42:41    12590538
2014-08-10 10:42:31    12590538
2014-08-10 10:42:26    12590538
Name: io.read.count, dtype: int64

Pyconsul is developed as a submodule of the unide project. Check out the documentation to learn more.

License

Copyright 2014 Xavier Bruhiere.

PyConsul is available under the MIT Licence.