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.

List of links.

SETUP_JOBS = ('hashi-ui', 'cluster-api', 'bastion-api', 'genvid-ui')

Jobs run on setup.

START_JOBS = ('services',)

Jobs run on start.

clear_secrets(timeout=0.0)

Delete a secret

Parameters:
  • path – The path to the secret.
  • 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 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_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:
  • path – The path to the secret.
  • data – Data associated with the secret.
  • timeout – The timeout in seconds
Returns:

The list of secrets.

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.

load_project_definition(definition)

Load a project definition into consul.

load_project_jobs()

Load project jobs into consul.

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_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 genvid cluster service.

Parameters:
  • job – The job name
  • timeout – The timeout in seconds