genvid.toolbox.GenvidClusterTool¶
Warning
This module is in beta. Its interface is likely to change.
-
class
genvid.toolbox.
GenvidClusterTool
(**kwargs)¶ Bases:
genvid.toolbox.config.EventsTool
,genvid.toolbox.project.ProjectTool
This class is the basic class for Genvid Project
-
GENVID_API_BASEURL
= '/v1/cluster/single/v1'¶ Base URL for Genvid Cluster Service API.
-
LINKS
= {}¶ List of links.
-
RE_BITRATE
= re.compile('(?P<number>\\d+)(?P<prefix>[kmg]i?)?(?P<byte>b)?')¶ Regexp matching for bitrate conversion
-
SETUP_JOBS
= ('hashi-ui', 'cluster-api', 'bastion-api', 'genvid-ui')¶ Jobs run on setup.
-
START_JOBS
= ('services',)¶ Jobs run on start.
-
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: - path – The path to the secret.
- timeout – The timeout in seconds
-
delete_jobsdefs
(timeout=0.0)¶ Delete jobs definitions
Parameters: timeout – The timeout in seconds
-
delete_linksdefs
(timeout=0.0)¶ Delete links definitions
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
-
genvid_request_delete
(path: str, timeout=0.0, params: dict = None, data: str = None, json_data=None)¶ Run a request over the genvid cluster service. :param path: The http request path :param timeout: The request timeout :param params: Parameters used for the query string :param json_data: A dictionary that will be transform into json :param data: The text data
-
genvid_request_get
(path: str, timeout=0.0, params: dict = None)¶ Run a request over the genvid cluster service. :param path: The http request path :param timeout: The request timeout :param params: Parameters used for the query string
-
genvid_request_post
(path: str, timeout=0.0, params: dict = None, data: str = None, json_data=None)¶ Run a request over the genvid cluster service. :param path: The http request path :param timeout: The request timeout :param params: Parameters used for the query string :param json_data: A dictionary that will be transform into json :param data: The text data
-
get_genvid_cluster_addr
(timeout=0.0) → str¶ Return the address of the genvid cluster service.
-
get_genvid_cluster_base_url
(timeout=0.0) → str¶ Return the address of the genvid cluster service.
-
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_jobs
(timeout=0.0)¶ Return currently running jobs in the process.
-
get_project_log_list
(timeout=0.0) → list¶ 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_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) → list¶ 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
-
is_genvid_cluster_running
(timeout=0.0)¶ Return if the genvid cluster server is running.
-
is_jobs_running
()¶ Return True if a job is configured to be running
-
load_project_definition
(definition)¶ Load a project definition into consul.
-
load_project_jobs
()¶ Load project jobs into consul.
-
load_project_links
()¶ Load project links into consul.
-
load_project_logs
()¶ Load project logs into consul.
-
load_project_map_reduce
(events)¶ Load the project map/reduce definitions into the configuration.
-
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_genvid
(*args, **kwargs)¶ Run the genvid executable
This set the GENVID_CLUSTER_HTTP_ADDR environment variable to the current registered service.
-
run_project_job
(job: str, timeout=0.0)¶ Start a project job by calling the genvid cluster service.
Parameters: - job – The job name
- 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_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.
-
start_project_jobs
(*jobs)¶ Starts an array of jobs :param jobs: The list of jobs
-
stop_project_job
(job: str, timeout=0.0)¶ Stop a project job by calling the genvid cluster service.
Parameters: - job – The job name
- timeout – The timeout in seconds
-
stop_project_jobs
(*jobs)¶ Stops an array of jobs :param jobs: The list of jobs
-