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 it 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 agent API of consul.

consul_catalog

The catalog of consul.

consul_join(ip)

Join a consul cluster.

consul_kv

The KV store of consul

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 at least timeout seconds for a valid service. 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 its result in such case.
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.