genvid.toolbox.ClusterAPI

class genvid.toolbox.ClusterAPI(cluster_id='local', **kwargs)

Bases: genvid.toolbox.httpapi.BaseHttpApiTool, genvid.toolbox.consul.ConsulTool

Handles the communication with a cluster.

GENVID_CLUSTER_API_BASEURL = None

Base URL for Genvid Cluster Service API.

NAME = 'cluster-api'
as_bitrate(bitrate: str) → int

This method converts a string representing a bitrate into a number.

It follows the FFmpeg convention and accepts a string representing a number as input. It may be followed by one of the SI unit prefixes, such as ’K’, ’M’, or ’G’.

If ’i’ is appended to the SI unit prefix the complete prefix is interpreted as a unit prefix for binary multiples, which are based on powers of 1024 instead of powers of 1000.

Appending ’B’ to the SI unit prefix multiplies the value by 8. This allows using suffixes like ’KB’, ’MiB’, ’G’ and ’B’.

clear_secrets(timeout=0.0)

Delete a secret.

Parameters:timeout – The timeout in seconds.
delete_events_def(event_id: str, timeout=0.0)

Delete an events definition.

Parameters:
  • event_id – The events definition to delete.
  • timeout – The timeout in seconds.
delete_events_defs(timeout=0.0)

Delete the multiple event definitions.

Parameters:timeout – The timeout in seconds.
delete_jobsdef(job_id: str, timeout=0.0)

Delete a job definition.

Parameters:timeout – The timeout in seconds.
delete_jobsdefs(timeout=0.0)

Delete multiple job definitions.

Parameters:timeout – The timeout in seconds.
delete_linksdef(link_id: str, timeout=0.0)

Delete a link definition.

Parameters:timeout – The timeout in seconds.
delete_linksdefs(timeout=0.0)

Delete multiple link definitions.

Parameters:timeout – The timeout in seconds.
delete_project_config(timeout=0.0)

Delete the configuration. The keys genvid, bastion, and vault are omitted.

Parameters:timeout – The timeout in seconds.
delete_project_log(log_id: str, timeout=0.0)

Delete the specified log.

Parameters:
  • log_id – The log ID.
  • timeout – The timeout in seconds.
delete_project_log_list(timeout=0.0)

Delete the list of logs.

Parameters:timeout – The timeout in seconds.
delete_secret(path: str, timeout=0.0)

Delete a secret.

Parameters:
  • path – The path to the secret.
  • timeout – The timeout in seconds.
do_consul_template(template: str, timeout=0.0) → dict

Execute a consul-template on the server site and return the result.

Parameters:
  • template – The template.
  • timeout – The timeout in seconds.
Returns:

Ex: { “data”: “result”, “stderr”: “message”}

get_base_url(timeout=0.0) → str

Get the base url

get_default_settings() → dict

Get the default settings.

Returns:A dictionary of settings.
get_events_defs(timeout=0.0)

Get the events definitions.

Parameters:timeout – The timeout in seconds.
get_health(service: str, timeout=0.0)
get_jobsdefs(timeout=0.0) → dict

Retrieve multiple job definitions.

Parameters:timeout – The timeout in seconds.
Returns:The data associated with the job definitions.

Get the list of links.

Parameters:
  • category – The link’s category.
  • link_id – The link’s ID.
  • timeout – The timeout in seconds.
Returns:

A list of strings.

get_linksdefs(timeout=0.0) → dict

Retrieve multiple link definitions.

Parameters:timeout – The timeout in seconds.
Returns:The data associated with the link definitions.
get_project_config(timeout=0.0)

Get the project configuration.

Parameters:timeout – The timeout in seconds.
Returns:The project configuration.
get_project_jobs(timeout=0.0)

Return currently running jobs in the process.

get_project_log_list(timeout=0.0) → typing.List[dict]

Get the list of logs.

Returns:The list of logs.
get_project_log_meta(name: str, timeout=0.0) → dict

Return the meta data associated with the project log.

Parameters:
  • name – The log name.
  • timeout – The timeout in seconds.
get_project_log_stream(meta: dict, origin: str, offset: int, timeout=0.0)

Return the log stream for the log specified in the meta.

Parameters:
  • meta – The log meta information.
  • origin – The origin of the log. Either ‘start’ or ‘end’.
  • offset – The offset to the origin.
  • timeout – The timeout in seconds.
get_proxied_url(service: str = 'cluster-api') → str

Get the cluster service proxied url

get_schema(schema: str)

Get the specified schema.

Parameters:schema – The schema file.
Returns:
get_secret(path: str, timeout=0.0) → dict

Retrieve a secret.

Parameters:
  • path – The path to the secret.
  • timeout – The timeout in seconds.
Returns:

The data associated with the secret.

get_secrets(timeout=0.0) → dict

Get the list of secrets in the database.

Parameters:timeout – The timeout in seconds.
Returns:The list of secrets. Ex: { “keys”: [“command”, “disco”]}
get_service_addresses(service: str, timeout=0.0) → typing.List[str]

Get the service addresses

Parameters:
  • service – The service name
  • timeout – The timeout in seconds
Returns:

get_settings() → dict

Get the settings.

Returns:A dictionary of settings.
get_settings_validation() → typing.List[str]

Get the settings validation.

Returns:A list of warning messages.
is_cluster_running(timeout=0.0)

Return if the cluster server is running.

load_project_definition(definition)

Load a project definition into the cluster.

print_project_log(name, output=None, tail=False, follow=False, lines=10, timeout=0.0)

Print project logs on output.

Parameters:
  • name – The name of the log.
  • output – If None, defaults to stdout.
  • tail – If True, prints the end of the log.
  • follow – If True, continues to show the log as it runs.
  • lines – An approximate number of lines to show.
  • timeout – The timeout in seconds.
run_project_job(job: str, timeout=0.0)

Start a project job by calling the cluster service.

Parameters:
  • job – The job name.
  • timeout – The timeout in seconds.
set_events_defs(events_defs: dict, timeout=0.0) → dict

Set the events definition.

Parameters:
  • events_defs – The events.
  • timeout – The timeout in seconds.
set_jobsdefs(data: dict, timeout=0.0)

Set multiple job definitions.

Parameters:
  • data – Data associated with the job definitions.
  • timeout – The timeout in seconds.
set_linksdefs(data: dict, timeout=0.0)

Set multiple link definitions.

Parameters:
  • data – Data associated with the link definitions.
  • timeout – The timeout in seconds.
set_project_config(config: dict, timeout=0.0)

Set the project configuration. The keys genvid, bastion, and vault are omitted.

Parameters:
  • config – The project configuration.
  • timeout – The timeout in seconds.
set_project_log_list(logs: list, timeout=0.0)

Return the list of logs.

Parameters:
  • logs – Configure the list of logs.
  • timeout – The timeout in seconds.
set_secret(path: str, data: dict, timeout=0.0)

Set a secret.

Parameters:
  • path – The path to the secret.
  • data – Data associated with the secret.
  • timeout – The timeout in seconds.
set_settings(settings: dict)

Set multiple configuration settings.

Parameters:settings – The settings used for configuration. Values default to empty.
stop_project_job(job: str, timeout=0.0)

Stop a project job by calling the cluster service.

Parameters:
  • job – The job name.
  • timeout – The timeout in seconds.
class cluster_api.ClusterAPI

Implementation of genvid.toolbox.ClusterAPI