genvid.toolbox.TerraformTool

Warning

This module has been deprecated. Although the code is still working for our oldest model, it is not expected to work with the new Bastion API. Please use the new genvid-bastion tool.

class genvid.toolbox.TerraformTool(**kwargs)

Bases: genvid.toolbox.runtime.RuntimeTool, genvid.toolbox.docker.DockerTool

Main tool for managing the cloud environment using Terraform.

Deprecated since version 1.33.0: Deprecated class.

NAME = 'terraform'
DESCRIPTION = 'Genvidtech Terraform Utility'
ARTIFACTS_URL_TEMPLATE = '{images_domain_name}/'

The template for the base URL for loading the Docker images. It is formatted with the information inside the terraform_config property.

SERVER_CLASSES = ('server', 'public_worker', 'internal_worker')

The list of server node classes.

TF

The location of the Terraform executable.

TFS3DIR

The location of the terraform-s3-dir executable.

terraform_config

A dictionary of some of the Terraform output and variables.

Call refresh() to refresh them.

status(*jobs)
refresh()

Refresh the terraform_config values.

get_ip()
get_consul_ip()
ssh_shell(ip=None)
ssh_config()

Returns the SSH command line parameters to connect to the main server.

Uses the first server IP if None is passed.

ssh(*cmd, ip=None)

Run cmd on the server designated by IP using SSH.

Uses the first server IP if None is passed.

run_nomad_fs(*args, ip=None, **kwargs)

Run nomad fs on the server using SSH.

This allows nomad fs to run on nodes which are only available through a reverse proxy.

get_cluster_ips(public=False)

Return the list of the private IPs of all nodes on the cluster.

If public is True it returns the public IPs instead.

setup_jobs(**kwargs)
update_images()

Update all Docker images in the Terraform configuration.

run_tf(*args, cwd=None, **kwargs)

Run Terraform with the passed arguments.

Note that the cwd is set to self.ROOTDIR when not specified.

plan_cluster(*args, **kwargs)

Run Terraform plan.

apply_cluster(*args, **kwargs)

Run Terraform apply.

destroy_cluster(*args, **kwargs)

Run Terraform destroy.

output_cluster(*args, check=False, **kwargs)

Run Terraform output.

show_cluster(*args, **kwargs)

Run Terraform show.

add_terraform_commands()

Add all the commands available from TerraformTool.

Run from add_commands() to add all the commands available from Terraform to the parser. See RuntimeTool.add_runtime_commands() for other commands available from TerraformTool.

run_terraform_command(command, options)

Detect if the command is a Terraform command and execute it.

Call from run_command() to handle Terraform commands. Terraform commands are added with the help of add_terraform_commands().

Returns:

handled, result: A tuple with a boolean saying if the
command was handled and its result if it was.
add_commands()
run_command(command, options)