genvid.toolbox.ConsulTool

class genvid.toolbox.ConsulTool(**kwargs)

Bases: genvid.toolbox.network.NetworkTool

This class allows you to access different Consul services.

CONSUL_KEY_SEP = '/'

Consul KV store folder separator

DESCRIPTION = 'An interface to the consul discovery service.'
NAME = 'consul'
UI_NAMES = ('consul-ui',)

List of UI services name

add_consul_commands()

Add the Consul commands to the parser.

Run from add_commands() to add the events commands to the parser.

connect_consul(ip=None)

Return a connection to a specific Consul node.

consul_agent

The Consul agent API.

consul_catalog

The Consul catalog.

consul_join(ip)

Join a Consul cluster.

consul_kv

The Consul KV store.

consulate

A connected Consul client, from the consulate package.

get_consul_ip()

Return the IP of the Consul service to connect to.

get_service(name, timeout=0.0, tag: str = '')

Return the status of the service name.

You can pass a timeout parameter that will retry for a valid service for at least that many seconds. If a tag is passed as parameter, return only the service with this tag.

Raises a ServiceIsNotRunningError if the service is unavailable.

run_consul_command(command, options)

Detect if the command is a Consul command and execute it.

Call it from run_command() to handle Consul commands. Consul commands are added with the help of add_consul_commands().

Returns:

handled, result: A tuple with a boolean saying if the
command were handled and it’s result if it was.
start_consul_ui()

Start a web browser on the Consul UI.

start_service_ui(ui)

Start a web browser on the service named ui.

start_ui(*uis)

Open a web page on the services specified by uis.

class consul.ConsulTool

Implementation of genvid.toolbox.ConsulTool.