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 convert a string representing a bitrate to a number.
It follows the FFmpeg convention and accept a string representing a number as input, which may be followed by one of the SI unit prefixes, for example: ’K’, ’M’, or ’G’.
If ’i’ is appended to the SI unit prefix, the complete prefix will be 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, for example: ’KB’, ’MiB’, ’G’ and ’B’ as number suffixes.
-
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 :param event_id: The events definition to delete :param timeout: The timeout in seconds
-
delete_events_defs
(timeout=0.0)¶ delete the events definition :param timeout: The timeout in seconds
-
delete_jobsdef
(job_id: str, timeout=0.0)¶ Delete jobs definitions
Parameters: timeout – The timeout in seconds
-
delete_jobsdefs
(timeout=0.0)¶ Delete jobs definitions
Parameters: timeout – The timeout in seconds
-
delete_linksdef
(link_id: str, timeout=0.0)¶ Delete links definitions
Parameters: timeout – The timeout in seconds
-
delete_linksdefs
(timeout=0.0)¶ Delete links definitions
Parameters: timeout – The timeout in seconds
-
delete_project_config
(timeout=0.0)¶ Delete the configuration. The key genvid, bastion and vault are omitted. :param 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 :param template: The template :param timeout: The timeout in seconds :return: 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 :param timeout: The timeout in seconds
-
get_jobsdefs
(timeout=0.0) → dict¶ Retrieve jobs definitions
Parameters: timeout – The timeout in seconds Returns: The data associated with the jobs definitions.
-
get_links
(category: str = '', link_id: str = '', timeout=0.0)¶ 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 links definitions
Parameters: timeout – The timeout in seconds Returns: The data associated with the links definitions.
-
get_project_config
(timeout=0.0)¶ Get the project configuration :param timeout: The timeout in seconds :return: 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. ‘start’ or ‘end’
- offset – The offset to the origin
- timeout – The timeout in seconds
-
get_schema
(schema: str)¶ 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_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, default to stdout
- tail – If True, print the end of the log
- follow – If true, continue to show the log
- 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 :param events_defs: The events :param timeout: The timeout in seconds
-
set_jobsdefs
(data: dict, timeout=0.0)¶ Set jobs definitions
Parameters: - data – Data associated with the jobs definitions.
- timeout – The timeout in seconds
-
set_linksdefs
(data: dict, timeout=0.0)¶ Set links definitions
Parameters: - data – Data associated with the links definitions.
- timeout – The timeout in seconds
-
set_project_config
(config: dict, timeout=0.0)¶ Set the project configuration. The key genvid, bastion and vault are omitted. :param config: The project configuration :param timeout: The timeout in seconds
-
set_project_log_list
(logs: list, timeout=0.0)¶ Return the list of logs.
Parameters: - logs – The list of logs configuration
- 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 the settings
Parameters: settings – The settings used for configuration. An empty settings will use the default values.
-
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