genvid.toolbox.Clusters¶
-
class
genvid.toolbox.
Clusters
(use_wan=False, **kwargs)¶ Bases:
genvid.toolbox.bastion_api.BastionAPI
This class is used as a base class to manage clusters.
-
CLUSTER_MAPPED_ARGS
= {'plans': 'plan_file'}¶
-
global_show
()¶ Show the global configuration.
-
global_update
(bastion_id)¶ Update the global configuration.
Parameters: bastion_id – The Bastion ID.
-
global_tfvars_show
()¶ Show the global tfvars.
-
global_tfvars_update
(tffile: str)¶ Update the global tfvars.
-
cluster_list
()¶ Print the list of clusters.
-
cluster_create
(cluster_id: str, backend: str = 'default', variable: typing.List[str] = None, category: str = 'cluster')¶ Create a cluster.
Parameters:
-
cluster_delete
(cluster_id: str, force: bool = False)¶ Delete a cluster.
Parameters: - cluster_id –
- force – Force the cluster to be deleted
-
cluster_show
(cluster_id: str)¶ Show information about the specified cluster.
Parameters: cluster_id –
-
get_instances
(clusters: typing.List[str] = None) → typing.List[dict]¶ Get the cluster instances :param clusters: The list of clusters
-
get_instance_id
(clusters: typing.List[str] = None, globalcontext: bool = False)¶ Get a single instance ID.
Parameters: - clusters – A list of clusters (must be a single list).
- globalcontext – The global context.
Returns: A single instance or raised exception.
Raises: ValueError if the number of instances isn’t 1.
-
execute_global_action
(action: str, globalcontext: bool = False, silent: bool = False, **kwargs)¶ Execute a global action.
Parameters: - action – init, plan, apply, destroy, or refresh.
- globalcontext – If the action is for global context.
- silent – Do not print the command logs.
- kwargs –
-
execute_clusters_action
(action: str, clusters: typing.List[str] = None, silent: bool = False, **kwargs)¶ Execute an action for multiple clusters in parallel.
Parameters: - action – init, plan, apply, destroy, or refresh.
- clusters – The list of clusters.
- silent – Do not print the command logs.
- kwargs –
Returns: A dictionary
-
execute_action
(action: str = None, cluster_id: str = None, instance_id: str = None, silent: bool = False, **kwargs)¶ Execute an action.
Parameters: - action – init, plan, apply, destroy, or refresh.
- cluster_id – The cluster ID. May be empty for the global context.
- instance_id – The instance ID.
- silent – Do not print the command logs.
- kwargs –
Returns:
-
terraform_get
(clusters: typing.List[str] = None, globalcontext: bool = False)¶ Execute a Terraform get.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
-
terraform_plan
(clusters: typing.List[str] = None, globalcontext=False, destroy=False, silent=False, **kwargs)¶ Execute a Terraform plan.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- destroy – If true, print a destroy plan.
- silent – Don’t print.
- kwargs –
-
terraform_plan_destroy
(clusters: typing.List[str] = None, globalcontext=False, silent=False, **kwargs)¶ Execute a Terraform plan for destroying clusters.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- silent – Don’t print.
- kwargs –
-
terraform_plan_apply
(clusters: typing.List[str] = None, globalcontext=False, silent=False, **kwargs)¶ Execute a Terraform plan for apply.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- silent – Don’t print.
- kwargs –
-
terraform_import_module
(clusters: typing.List[str] = None, module_path: str = 'cluster/default', globalcontext=False, silent=False, force=False, **kwargs)¶ Execute a Terraform init.
Parameters: - clusters – The list of clusters.
- module_path – The module path to import.
- globalcontext – The global context.
- silent – Don’t print.
- force – Force the import even if the cluster is in an invalid state.
- kwargs –
-
terraform_init
(clusters: typing.List[str] = None, globalcontext=False, silent=False, force=False, doall=False, **kwargs)¶ Execute a Terraform init.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- silent – Don’t print.
- force – Force initialization even if the cluster is in an invalid state.
- doall – Do it on all clusters.
- kwargs –
Changed in version 1.14.0: Add the doall parameter.
-
terraform_apply
(clusters: typing.List[str] = None, globalcontext=False, silent=False, **kwargs)¶ Execute a Terraform apply.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- silent – Don’t print.
- kwargs –
-
terraform_apply_plan
(clusters: typing.List[str] = None, globalcontext=False, silent=False, **kwargs)¶ Execute a Terraform apply on a specified plan file.
Parameters: - globalcontext – The global context.
- silent – Don’t print.
- kwargs –
-
terraform_destroy
(clusters: typing.List[str] = None, globalcontext=False, silent=False, **kwargs)¶ Execute a Terraform destroy.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- silent – Don’t print.
- kwargs –
-
terraform_refresh
(clusters: typing.List[str] = None, globalcontext=False, silent=False, **kwargs)¶ Execute a Terraform refresh.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- silent – Don’t print.
- kwargs –
-
terraform_output
(clusters: typing.List[str] = None, globalcontext=False, **kwargs)¶ Execute a Terraform output.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- kwargs –
-
terraform_status
(clusters: typing.List[str] = None, globalcontext=False, **kwargs)¶ Print the status of the clusters on the command line.
The result can be:
VOID
: The instance doesn’t exist.EMPTY
: The instance exists but isn’t initialized.DOWN
: The instance is initialized but doesn’t contain any- resources.
UP
: The instance is managing some resources.BUSY
: The instance is currently running a command.ERROR
: An error has occured during status retrieval.INVALID
: The current status of the instance is unknown.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- kwargs –
-
terraform_tfvars_show
(clusters: typing.List[str] = None, globalcontext=False, **kwargs)¶ Show the terraform.tfvars.json file.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- kwargs –
-
terraform_tfvars_default
(clusters: typing.List[str] = None, globalcontext=False, **kwargs)¶ Show the default terraform.tfvars.json file.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- kwargs –
-
terraform_schema
(clusters: typing.List[str] = None, globalcontext=False, **kwargs)¶ Show the default terraform.tfvars.json file.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- kwargs –
-
terraform_tfvars_update
(clusters: typing.List[str] = None, globalcontext=False, tffile: str = '', **kwargs)¶ Update the terraform.tfvars.json file.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- file – The source file to update from.
- kwargs –
-
commands_list
(clusters: typing.List[str] = None, globalcontext=False, **kwargs)¶ Show the list of available commands.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- kwargs –
-
commands_log
(clusters: typing.List[str] = None, globalcontext=False, command_id: str = '', **kwargs)¶ Print a command log.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- command_id – The command ID.
- kwargs –
-
commands_latest
(clusters: typing.List[str] = None, globalcontext=False, **kwargs)¶ Print the latest command logs.
Parameters: - clusters – The list of clusters.
- globalcontext – The global context.
- kwargs –
-
repository_list
()¶ List of all terraform repositories configuration.
-
path_to_uri
(url)¶ Ensure a path is actually a uri and not a file.
The file pointing by the url must actually exist.
-
repository_add
(repository: str, url: str)¶ Add a repository.
Parameters: - repository – The unique name of the repository.
- url – The url of the repository (must be accessible from the bastion).
Returns: The repository configuration.
-
repository_update
(repository: str, url: str = '')¶ Update an existing repository.
Parameters: - repository – The name of the repository.
- url – The url of the repository(optional).
Returns: The repository configuration.
-
repository_remove
(repository: str)¶ Remove a repository.
Parameters: name – The name of the repository Returns: The repository configuration.
-
repository_update_all
()¶ Update all registered repositories.
-
repository_clean
()¶ Remove all registered repositories.
-
backend_list
()¶ Get the list of all backend templates.
-
backend_add
(backend_id: str, backend_type: str, variables: dict = {})¶ Add a new backend template.
Parameters: - backend_id – The backend ID.
- backend_type – The type of backend.
- variables – A list of default variables for the backend.
-
backend_update
(backend_id: str, backend_type: str, variables: dict = {})¶ Update an existing backend template.
Parameters: - backend_id – The backend ID.
- backend_type – The type of backend.
- variables – A list of default variables for the backend.
-
backend_remove
(backend_id: str)¶ Remove a backend template.
Parameters: backend_id – The backend ID.
-