genvid.toolbox.ServiceInstaller

class genvid.toolbox.ServiceInstaller(**kwargs)

Bases: genvid.toolbox.service.ServiceTool

Base class for installing all services.

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

DESCRIPTION = 'Installation of services.'
NAME = 'service-installer'
SERVICES = ('consul', 'vault', 'nomad')

The list of all services.

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

The base class associated with each service.

SUPERVISOR_BASE

The mixin base class for service.

alias of ServiceTool

add_commands()

Add service installer and Consul commands.

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.

do_command(command: str, *services: str, **options: str) → typing.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.

get_service_class(name)

Returns the class of the named service.

get_services(*services)

Returns the services associated with name.

The default returns all services.

get_tool_class(basekls)

Create and return the mixin class of the service.

install(*services: str, **options: str) → typing.Any

Install the services.

reinstall(*services: str, **options: str) → typing.Any

Uninstall and reinstall the services.

restart(*services: str, **options: str) → typing.Any

Stop than restart the services.

run_command(command: str, options) → typing.Tuple[bool, typing.Any]
run_service_installer_command(command: str, options) → typing.Tuple[bool, typing.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.
services = None

The instances of all services.

start(*services: str, **options: str) → typing.Any

Start the services.

status(*services: str, **options: str) → typing.Any

Return the status of all services.

stop(*services: str, **options: str) → typing.Any

Stop the services.

uninstall(*services: str, **options: str) → typing.Any

Uninstall the servicess.

class service.ServiceInstaller

Implementation of genvid.toolbox.ServiceInstaller