laniakea.core.providers.gce package¶
Submodules¶
Google Compute Engine API
-
class
laniakea.core.providers.gce.manager.ComputeEngineManager(user_id, key, project)¶ Bases:
objectGoogle 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.
- image (
-
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.
- container (
-
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 (
strorGCENodeSize) – The machine type to use. - number (
int) – Amount of nodes to be spawned. - meta (
dictorNone) – Metadata dictionary for the nodes. - name (
str) – The name of the node to create. - image (
strorGCENodeImageorNone) – 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: listofNode- size (
-
filter(zone='all')¶ Filter nodes by their attributes.
Parameters: zone ( str) – A zone containing nodes.Returns: A chainable filter object. Return type: objectofFilter
-
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.
- nodes (
-
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:
ExceptionException class for Google Compute Engine Manager.
-
class
laniakea.core.providers.gce.manager.Filter(nodes=None)¶ Bases:
objectChainable 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: listofNode
-
has_labels(labels=None)¶ Filter by presence of labels.
Parameters: labels ( list) – Labels to filter.Returns: A list of Node objects. Return type: listofNode
-
is_preemptible()¶ Filter by preemptible scheduling.
Returns: A list of Node objects. Return type: listofNode
-
labels(labels=None)¶ Filter by value of labels.
Parameters: labels ( dict) – Labels to filter.Returns: A list of Node objects. Return type: listofNode
-
name(names=None)¶ Filter by node name.
Parameters: names ( list) – Node names to filter.Returns: A list of Node objects. Return type: listofNode
-
state(states=None)¶ Filter by state.
Parameters: tags ( list) – States to filter.Returns: A list of Node objects. Return type: listofNode
Filter by tags.
Parameters: tags ( list) – Tags to filter.Returns: A list of Node objects. Return type: listofNode
-
Module contents¶
Google Compute Engine CLI
-
class
laniakea.core.providers.gce.GceCommandLine¶ Bases:
objectSub 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.
-