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_health

The Consul Health API.

New in version 1.15.0.

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: typing.Union[str, NoneType] = None, passing: bool = True)

Return the status of the service name.

Parameters:
  • timeout – The service will retry for at least that many seconds or that a good service is found.
  • tag – If not empty, return only the service with this tag.
  • passing – If true (the default), returns only passing services.

Raises a ServiceIsNotRunningError if the service is unavailable.

Changed in version 1.15.0: Used /v1/health/service instead of catalog to only returns healty services. Set the new passing parameter to False to get the old behaviour.

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.