genvid.toolbox.ServiceInstaller

class genvid.toolbox.ServiceInstaller(**kwargs)

Bases: ServiceTool

Base class for installing all services.

This class uses a SUPERVISOR_BASE to create a mixin (through multi-inheritance) of the actual services.

NAME = 'service-installer'

The name of the logger for this tool. Must be redefined in children.

DESCRIPTION = 'Installation of services.'

A description of the tool, used in the help parser. Must be redefined in children.

SERVICES = ('consul', 'vault', 'nomad')

The list of all services.

SERVICE_CLASSES = {'consul': <class 'genvid.toolbox.service.ConsulService'>, 'nomad': <class 'genvid.toolbox.service.NomadService'>, 'vault': <class 'genvid.toolbox.service.VaultService'>}

The base class associated with each service.

SUPERVISOR_BASE

alias of ServiceTool

get_tool_class(basekls)

Create and return the mixin class of the service.

get_service_class(name)

Returns the class of the named service.

services

The instances of all services.

get_services(*services, rev: bool = False)

Returns the services associated with name.

The default returns all services.

add_service_installer_commands()

Add the service installer commands to the parser.

Run from add_commands() to add the service installer commands to the parser.

run_service_installer_command(command: str, options) Tuple[bool, Any]

Detect if the command is a service installer command and execute it.

Call from run_command() to handle the service installer commands. The service installer commands are added with the help of add_service_commands().

Returns

Whether the command was handled and the result if it was.

Changed in version 1.15.0: Commands ‘stop’ and ‘uninstall’ are now run in reverse order of services.

do_command(command: str, *services: str, **options: str) Any

Execute the named command.

The behavior is similar to running from the command line with options used as keyword arguments.

Parameters
  • command – The name of the command to run.

  • services – A list of possible services to run the command. Runs on all available services if not specified.

Options

Any options to pass to the command.

Changed in version 1.15.0: Commands ‘stop’ and ‘uninstall’ are now run in reverse order of services.

install(*services: str, **options: str) Any

Install the services.

uninstall(*services: str, **options: str) Any

Uninstall the servicess.

reinstall(*services: str, **options: str) Any

Uninstall and reinstall the services.

start(*services: str, **options: str) Any

Start the services.

stop(*services: str, **options: str) Any

Stop the services.

restart(*services: str, **options: str) Any

Stop than restart the services.

status(*services: str, **options: str) Any

Return the status of all services.

add_commands()

Add service installer and Consul commands.

run_command(command: str, options) Tuple[bool, Any]

Run command with those options.

You must override this method.

Parameters
  • command – The name of the command to run.

  • options – A argparse.Namespace object with the options pass in arguments.

class service.ServiceInstaller

Implementation of genvid.toolbox.ServiceInstaller