pycloudlib.gce.instance module

GCE instance.

class pycloudlib.gce.instance.GceInstance(key_pair, instance_id, project, zone, credentials_path, *, name=None, username: str | None = None)[source]

Bases: BaseInstance

GCE backed instance.

__init__(key_pair, instance_id, project, zone, credentials_path, *, name=None, username: str | None = None)[source]

Set up the instance.

Parameters:
  • key_pair – A KeyPair for SSH interactions

  • instance_id – Id returned when creating the instance

  • project – Project instance was created in

  • zone – Zone instance was created in

  • name – Name of the instance

  • username – username to use when connecting via SSH

delete(wait=True) List[Exception][source]

Delete the instance.

Parameters:

wait – wait for instance to be deleted

property id

Return the instance id.

property ip

Return IP address of instance.

property name

Return the instance name.

shutdown(wait=True, **kwargs)[source]

Shutdown the instance.

Parameters:

wait – wait for the instance to shutdown

start(wait=True)[source]

Start the instance.

Parameters:

wait – wait for the instance to start.

wait_for_delete(sleep_seconds=30, raise_on_fail=False)[source]

Wait for instance to be deleted.

wait_for_stop(**kwargs)[source]

Wait for instance stop.