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.

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

The list of all services.

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

The base class associated with each service.

SUPERVISOR_BASE

The mixin base class for service.

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 = None

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) → 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.

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) → 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.

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

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

Install the services.

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

Uninstall the servicess.

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

Uninstall and reinstall the services.

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

Start the services.

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

Stop the services.

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

Stop than restart the services.

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

Return the status of all services.

add_commands()

Add service installer and Consul commands.

run_command(command: str, options) → typing.Tuple[bool, typing.Any]
class service.ServiceInstaller

Implementation of genvid.toolbox.ServiceInstaller