• Stars
    star
    342
  • Rank 119,615 (Top 3 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created about 10 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python client for the Consul HTTP API

Consulate: A Consul Client Library

Consulate is a Python client library and set of application for the Consul service discovery and configuration system.

Version Status Coverage

Installation

Consulate is available via via pypi and can be installed with easy_install or pip:

pip install consulate

If you require communicating with Consul via a Unix socket, there is an extra dependency that is installed via:

pip install consulate[unixsocket]

Command Line Utilities

Consulate comes with two command line utilities that make working with Consul easier from a management perspective. The consulate application provides a cli wrapper for common tasks performed.

consulate

The consulate application provides a CLI interface for registering a service, backing up and restoring the contents of the KV database, and actions for getting, setting, and deleting keys from the KV database.

usage: consulate [-h] [--api-scheme API_SCHEME] [--api-host API_HOST]
                 [--api-port API_PORT] [--datacenter DC] [--token TOKEN]
                 {register,deregister,kv,run_once} ...

CLI utilities for Consul

optional arguments:
  -h, --help            show this help message and exit
  --api-scheme API_SCHEME
                        The scheme to use for connecting to Consul with
  --api-host API_HOST   The consul host to connect on
  --api-port API_PORT   The consul API port to connect to
  --datacenter DC       The datacenter to specify for the connection
  --token TOKEN         ACL token

Commands:
  {register,deregister,kv,run_once,services}
    register            Register a service for this node
    deregister          Deregister a service for this node
    kv                  Key/Value Database Utilities
    run_once            Lock command
    services            List services for this node

If the CONSUL_RPC_ADDR environment variable is set, it will be parsed and used
for default values when connecting.

Service Registration Help:

usage: consulate register [-h] [-a ADDRESS] [-p PORT] [-s SERVICE_ID]
                          [-t TAGS]
                          name {check,httpcheck,no-check,ttl} ...

positional arguments:
  name                  The service name

optional arguments:
  -h, --help            show this help message and exit
  -a ADDRESS, --address ADDRESS
                        Specify an address
  -p PORT, --port PORT  Specify a port
  -s SERVICE_ID, --service-id SERVICE_ID
                        Specify a service ID
  -t TAGS, --tags TAGS  Specify a comma delimited list of tags

Service Check Options:
  {check,httpcheck,no-check,ttl}
    check               Define an external script-based check
    httpcheck           Define an HTTP-based check
    no-check            Do not enable service monitoring
    ttl                 Define a duration based TTL check

KV Database Utilities Help:

usage: consulate kv [-h] {backup,restore,ls,mkdir,get,set,rm} ...

optional arguments:
  -h, --help            show this help message and exit

Key/Value Database Utilities:
  {backup,restore,ls,mkdir,get,set,rm}
    backup              Backup to stdout or a JSON file
    restore             Restore from stdin or a JSON file
    ls                  List all of the keys
    mkdir               Create a folder
    get                 Get a key from the database
    set                 Set a key in the database
    rm                  Remove a key from the database

Locking Operations Help:

usage: consulate [-h] run_once [-i INTERVAL] prefix command

positional arguments:
  prefix                the name of the lock which will be held in Consul.
  command               the command to run

optional arguments:
  -h, --help            show this help message and exit
  -i, --interval        hold the lock for INTERVAL seconds

Service listing Help:

usage: consulate services [-h] [-i INDENT]

optional arguments:
  -h, --help            show this help message and exit
  -i INDENT, --indent INDENT
                        The indent level for output

API Usage Examples

The following examples highlight the usage of Consulate and does not document the scope of the full Consulate API.

Using Consulate with the Consul kv database:

consul = consulate.Consul()

# Set the key named release_flag to True
consul.kv['release_flag'] = True

# Get the value for the release_flag, if not set, raises AttributeError
try:
    should_release_feature = consul.kv['release_flag']
except AttributeError:
    should_release_feature = False

# Delete the release_flag key
del consul.kv['release_flag']

# Find all keys that start with "fl"
consul.kv.find('fl')

# Find all keys that start with "feature_flag" terminated by "/" separator
consul.kv.find('feature_flag', separator='/')

# Check to see if a key called "foo" is set
if "foo" in consul.kv:
    print 'Already Set'

# Return all of the items in the key/value store
consul.kv.items()

Working with the Consulate.agent API:

consul = consulate.Consul()

# Get all of the service checks for the local agent
checks = consul.agent.checks()

# Get all of the services registered with the local agent
services = consul.agent.services()

# Add a service to the local agent
consul.agent.service.register('redis',
                               port=6379,
                               tags=['master'],
                               ttl='10s')

Fetching health information from Consul:

consul = consulate.Consul()

# Get the health of a individual node
health = consul.health.node('my-node')

# Get all checks that are critical
checks = consul.health.state('critical')

For more examples, check out the Consulate documentation.

More Repositories

1

pgsql-listen-exchange

RabbitMQ Exchange that publishes messages received from PostgreSQL Notifications.
Erlang
277
star
2

queries

PostgreSQL database access simplified
Python
259
star
3

rabbitpy

A pure python, thread-safe, minimalistic and pythonic RabbitMQ client library
Python
243
star
4

tinman

Tinman is a Tornado support package including an application wrapper/runner and a set of handy decorators.
Python
187
star
5

RabbitMQ-in-Depth

Examples and materials for RabbitMQ in Depth
Python
132
star
6

flatdict

Python module for interacting with nested dicts as a single level dict with delimited keys.
Python
109
star
7

env-aws-params

Inject AWS SSM Parameters as Environment Variables
Go
84
star
8

rejected

rejected is a consumer framework for RabbitMQ
Python
58
star
9

pamqp

Low level AMQP frame encoding and decoding library
Python
52
star
10

rabbitmq-flume-plugin

A Flume plugin that provides a RabbitMQ Source and Sink
Java
48
star
11

pycon2013-logging

Examples from my "Become a Logging Expert in 30 Minutes" talk at PyCon 2013
Python
48
star
12

glyphicons-sprite-generator

The GLYPHICONS Sprite Generator allows you to change the size and colors of the Bootstap icons using the Free or Pro versions of GLYPHICONS.
Python
47
star
13

rabbitmq-pulse

rabbitmq-pulse is a RabbitMQ plugin that publishes node and queue information, pushing stats instead of polling the Management API
Erlang
45
star
14

tornado-elasticsearch

Extends the official Elasticsearch Python API adding Tornado AsyncHTTPClient support
Python
38
star
15

influxdb-storage-exchange

Post JSON structured event messages to InfluxDB
Erlang
33
star
16

alpine-rabbitmq-autocluster

RabbitMQ image with the autocluster plugin
32
star
17

email-normalize

Return a normalized email-address stripping ISP specific behaviors
Python
30
star
18

On-Rabbits-and-Elephants

Code for my lightning talk at pgCon 2011
Python
29
star
19

helper

Development library for quickly writing configurable applications and daemons.
Python
27
star
20

pgdumplib

Python3 library for reading and writing pg_dump files using the custom format
Python
26
star
21

statelessd

statelessd is a stateless HTTP to AMQP publishing gateway prototype in Python
Python
25
star
22

srvlookup

A small wrapper for dnspython to return SRV records for a given host, protocol, and domain name as a list of namedtuples
Python
23
star
23

kvpbench

Key-Value Store Benchmark Application
Python
23
star
24

passport

Passport generates templated configuration files using Consul's Service Discovery and Key/Value database tools
Python
22
star
25

aiorabbit

An AsyncIO RabbitMQ client for Python 3
Python
21
star
26

tredis

An asynchronous Redis client for Tornado
Python
20
star
27

hockeyapp

Python Client for the HockeyApp.net API
Python
19
star
28

mredis

MRedis is a multi-server wrapper for the excellent Python Redis client.
Python
19
star
29

progrock

A multi-progressbar implementation to complement multiprocessing.Process.
Python
18
star
30

pg-statsd

pg_statsd is a set of PostgreSQL user-defined functions that provide and interface to statsd.
C
15
star
31

strftimerl

Erlang implementation of strftime
Erlang
14
star
32

urilib

A RFC-3986 URI Library for parsing and building URIs
Erlang
13
star
33

infoblox

A python library for interfacing with Infoblox NIOS.
Python
12
star
34

huesos-de-vaquero

A skeleton project for web development using Cowboy (Erlang) for back-end development and Google Web-Starter-Kit for front-end development
Erlang
12
star
35

tornado-aws

A low-level Amazon Web Services API client for Tornado
Python
12
star
36

mikkoo

Mikkoo is a PgQ to RabbitMQ Relay
Python
11
star
37

houston

Easy docker stack deployment to CoreOS clusters using Fleet and Consul
Python
11
star
38

framewerk

Framewerk is a PHP5 OO Framework
PHP
10
star
39

alpine-pgbouncer

Minimalistic Alpine Linux pgBouncer container
Shell
8
star
40

httpbl

Python client library for the project-honeypot.org Http:BL API
Python
8
star
41

cardiff

Cardiff is an extendible statsd clone written in Python that supports all statsd metric types and a variety of configurable stats destinations.
Python
8
star
42

fluent-plugin-json-in-json

Fluentd parser plugin that parses JSON attributes with JSON strings in them
Ruby
7
star
43

pgpasslib

Library for getting passwords from a PostgreSQL Password file
Python
7
star
44

erlln

Example Erlang OTP application that listens for PostgreSQL NOTIFY messages
Erlang
7
star
45

conserl

Erlang client for Consul
Erlang
6
star
46

mgmt-stress

A RabbitMQ stress-testing tool
Erlang
6
star
47

ossicons

An icon font for popular Open Source project logos
HTML
5
star
48

privatepaste

v2 of PrivatePaste.com
Erlang
5
star
49

python-tornado.tmbundle

A TextMate 2 Bundle for Tornado
5
star
50

alpine-postgres

gavinmroy/alpine-postgres is a Docker image with a small disk footprint for PostgreSQL
Shell
5
star
51

dynamodb-backup

CLI utility for backing up DynamoDB to Avro containers
Python
4
star
52

pgsql-utilities

A collection of PostgreSQL utilities
PHP
4
star
53

logging-config

A wrapper class for the Python standard logging module
Python
4
star
54

fleetpy

An opinionated fleet API client for Python
Python
4
star
55

rabbitmq-sns-plugin

RabbitMQ plugin for AWS SNS interoperability
Makefile
4
star
56

golconde

Golconde (gลl-kลn'dษ™) is a queue based data-distribution solution for PostgreSQL written in Python 2.6.
Python
4
star
57

rabbitstew

A command-line tool for publishing messages to RabbitMQ
Python
4
star
58

couchclient

A light-weight, read-only CouchDB client
Python
4
star
59

pglifecycle

A PostgreSQL schema management tool
Python
3
star
60

rmq-node-report

A small set of scripts to gather information from a local RabbitMQ node
Erlang
3
star
61

pgparse

Python wrapper for libpg_query
Python
3
star
62

alpine-rabbitmq

RabbitMQ image with a small disk footprint
3
star
63

PyCon-2012-Tornado-IOLoop-Talk-Examples

Examples from my 2012 PyCon talk: "More than just a pretty web framework, the Tornado IOLoop"
Python
3
star
64

elmer

Elmer allows granular monitoring of RabbitMQ queues with Nagios and other monitoring tools using custom queue arguments.
Erlang
3
star
65

menwith

Menwith is a memcache text protocol command utilization analysis tool.
Python
3
star
66

http-exchange

RabbitMQ exchange for stateless publishing over HTTP
Erlang
3
star
67

rmq-cluster-rebalance

CLI application for rebalancing queues in a RabbitMQ cluster
Python
3
star
68

alpine-statsd

A statsd container with a small disk footprint
3
star
69

github-issue-autoresponder

Check GitHub projects periodically for new issues and automatically comment or label them based upon string matching rules
Python
3
star
70

boxcar

An experimental OS/X app for interfacing with Vagrant
Objective-C
3
star
71

rabbitmq-in-depth-cookbook

Cookbook used by Vagrant when setting up the RabbitMQ in Depth VM
Python
2
star
72

pgdumpreport

Create reports from pg_dump archives
JavaScript
2
star
73

cowboy-bones-gutenberg-generator

An #Erlang Cowboy web app Gutenberg generator with i18n, templating, and more
Erlang
2
star
74

httpc-aws

A light-weight, relatively unopinionated AWS API client for Erlang
Erlang
2
star
75

tdns

An asynchronous Tornado pycares DNS client wrapper
Python
2
star
76

rabbitmq-management-ui-prototype

A ReactJS RabbitMQ Management UI Prototype
TypeScript
2
star
77

hashicorp-packaging

Makefile and templates for creating deb packages for HashiCorp (and ecosystem) projects.
Makefile
2
star
78

formulary

Easy management of AWS Cloud Formation stacks
Python
2
star
79

alpine-redis

Redis image with a small disk footprint
Dockerfile
2
star
80

ecs-pipeline-deploy

An opinionated deployment application for ECS services
Python
2
star
81

rabbitmq-pagerduty

A RabbitMQ monitoring plugin for triggering PagerDuty alerts
Erlang
2
star
82

pg-graph-dump

Dependency graph based dump and reload of PostgreSQL DDL
Erlang
2
star
83

ppp-loan-data

PPP FOIA Data
2
star
84

pgpretty

A Postgres SQL Formatter
Python
1
star
85

mdnserl

Erlang library for providing RFC-6762 multicast-DNS announcement and discovery
Erlang
1
star
86

rmq-definitions

Deterministically sort and format RabbitMQ definition backups
Python
1
star
87

ssm-ps-template

Command line application to render templates with data from SSM Parameter Store
Python
1
star
88

telegraf-pgbouncer

pgBouncer Stats Collector for Telegraf
Python
1
star
89

estuary

Accumulates Avro datum received via RabbitMQ messages and stores them in Avro container files
Erlang
1
star
90

s3-config-overlay

Fetch config from amazon S3 for other containers
Shell
1
star
91

remy

Remy is a tool for managing Chef repositories and automating the addition and management of cookbooks with a chef server using Jenkins and GitHub.
Python
1
star
92

topological

Python3 library of topological sorting algorithms
Python
1
star
93

tornado-dynamodb

Deprecated for sprockets.clients.dynamodb
Python
1
star
94

google-apps-for-domains-utilities

Small python utilities for managing Google Apps for Domains accounts
Python
1
star
95

apiary

JavaScript
1
star
96

tornado-template-gen

This application uses the Tornado Template module to generate static HTML files while still making available a subset of the Tornado template methods like static_url.
Python
1
star
97

rabbitmq-aws

A RabbitMQ Plugin fork of httpc-aws - Now @ rabbitmq/rabbitmq-aws
Erlang
1
star