laniakea.core.providers.gce package

Submodules

Google Compute Engine API

class laniakea.core.providers.gce.manager.ComputeEngineManager(user_id, key, project)

Bases: object

Google Compute Engine Manager base class.

build_bootdisk(image, size=10, auto_delete=True)

Buid a disk struct.

Parameters:
  • image (str) – Base image name.
  • size (int) – Persistent disk size.
  • auto_delete (bool) – Wether to auto delete disk on instance termination.
build_container_vm(container, disk, zone='us-east1-b', tags=None, preemptible=True)

Build kwargs for a container VM.

Parameters:
  • container (dict) – Container declaration.
  • disk (dict) – Disk definition structure.
  • zone (str) – The zone in which the instance should run.
  • tags (dict) – Tags associated with the instance.
  • preemptible (bool) – Wether the instance is a preemtible or not.
connect(**kwargs)

Connect to Google Compute Engine.

create(size, number, meta, name=None, image=None, attempts=3)

Create container VM nodes. Uses a container declaration which is undocumented.

Parameters:
  • size (str or GCENodeSize) – The machine type to use.
  • number (int) – Amount of nodes to be spawned.
  • meta (dict or None) – Metadata dictionary for the nodes.
  • name (str) – The name of the node to create.
  • image (str or GCENodeImage or None) – The image used to create the disk - optional for multiple nodes.
  • attempts (int) – The amount of tries to perform in case nodes fail to create.
Returns:

A list of newly created Node objects for the new nodes.

Return type:

list of Node

filter(zone='all')

Filter nodes by their attributes.

Parameters:zone (str) – A zone containing nodes.
Returns:A chainable filter object.
Return type:object of Filter
is_connected(attempts=3)

Try to reconnect if neccessary.

Parameters:attempts (int) – The amount of tries to reconnect if neccessary.
reboot(nodes=None)

Reboot one or many nodes.

Parameters:nodes (list) – Nodes to be rebooted.
start(nodes=None)

Start one or many nodes.

Parameters:nodes (list) – Nodes to be started.
stop(nodes=None)

Stop one or many nodes.

Parameters:nodes (list) – Nodes to be stopped.
terminate(nodes=None)

Destroy one or many nodes.

Parameters:nodes (list) – Nodes to be destroyed.
Returns:List of nodes which failed to terminate.
Return type:list
terminate_ex(nodes, threads=False, attempts=3)

Wrapper method for terminate.

Parameters:
  • nodes (list) – Nodes to be destroyed.
  • attempts (int) – The amount of attempts for retrying to terminate failed instances.
  • threads (bool) – Whether to use the threaded approach or not.
terminate_nowait(nodes=None)

Destroy one or many nodes, without waiting to see that the node is destroyed.

Parameters:nodes (list) – Nodes to be destroyed.
terminate_with_threads(nodes=None)

Destroy one or many nodes threaded.

Parameters:nodes (list) – Nodes to be destroyed.
Returns:List of nodes which failed to terminate.
Return type:list
exception laniakea.core.providers.gce.manager.ComputeEngineManagerException

Bases: Exception

Exception class for Google Compute Engine Manager.

class laniakea.core.providers.gce.manager.Filter(nodes=None)

Bases: object

Chainable filter class for Node objects.

expr(callback)

Filter by custom expression.

Parameters:callback – Callback for custom expression.
Returns:A list of Node objects.
Return type:list of Node
has_labels(labels=None)

Filter by presence of labels.

Parameters:labels (list) – Labels to filter.
Returns:A list of Node objects.
Return type:list of Node
is_preemptible()

Filter by preemptible scheduling.

Returns:A list of Node objects.
Return type:list of Node
labels(labels=None)

Filter by value of labels.

Parameters:labels (dict) – Labels to filter.
Returns:A list of Node objects.
Return type:list of Node
name(names=None)

Filter by node name.

Parameters:names (list) – Node names to filter.
Returns:A list of Node objects.
Return type:list of Node
state(states=None)

Filter by state.

Parameters:tags (list) – States to filter.
Returns:A list of Node objects.
Return type:list of Node
tags(tags=None)

Filter by tags.

Parameters:tags (list) – Tags to filter.
Returns:A list of Node objects.
Return type:list of Node
class laniakea.core.providers.gce.manager.Kurz

Bases: object

static ips(node)
static is_preemtible(node)
static zone(node)

Module contents

Google Compute Engine CLI

class laniakea.core.providers.gce.GceCommandLine

Bases: object

Sub command-line interface for the Google Compute Engine provider.

HOME = '/home/travis/build/MozillaSecurity/laniakea/laniakea/core/providers/gce'
VERSION = 0.1
classmethod add_arguments(subparsers, dirs)

Argument parser of this module.

list(cluster, zone, states, names, tags)
classmethod main(args, settings=None, userdata=None)

Main entry point of this module.