Gandi Computer Driver Documentation¶
Gandi SAS is a registrar, web hosting and private and public cloud provider based in France with data centers in France, Luxembourg and USA.
Instantiating a driver¶
When you instantiate a driver you need to pass the API key and activate the API platforms. See this Gandi’s documentation for how to do it.
Examples¶
Create instance¶
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
Gandi = get_driver(Provider.GANDI)
driver = Gandi("api_key")
image = [i for i in driver.list_images() if "Debian 8 64" in i.name][0]
size = [s for s in driver.list_sizes() if s.name == "Medium instance"][0]
location = [loc for loc in driver.list_locations() if loc.name == "FR-SD2"][0]
node = driver.create_node(
name="yournode",
size=size,
image=image,
location=location,
login="youruser",
password="pass",
)
API Docs¶
- class libcloud.compute.drivers.gandi.GandiNodeDriver(*args, **kwargs)[source]¶
Gandi node driver
@inherits:
NodeDriver.__init__
- attach_volume(node, volume, device=None)[source]¶
Attach a volume to a node.
- Parameters
node (
Node
) – The node to attach the volume tovolume (
StorageVolume
) – The volume to attach.device (
None
) – Not used in this cloud.
- Returns
True if successful
- Return type
bool
- connectionCls¶
- copy_image(source_region, node_image, name, description=None)¶
Copies an image from a source region to the current region.
- create_image(node, name, description=None)¶
Creates an image from a node object.
- create_key_pair(name)¶
Create a new key pair object.
- Parameters
name (
str
) – Key pair name.- Return type
KeyPair
object
- create_node(name, size, image, location=None, login=None, password=None, inet_family=4, keypairs=None)[source]¶
Create a new Gandi node
- Parameters
name (
str
) – String with a name for this new node (required)image (
NodeImage
) – OS Image to boot on node. (required)location (
NodeLocation
) – Which data center to create a node in. If empty, undefined behavior will be selected. (optional)size (
NodeSize
) – The size of resources allocated to this node. (required)login (
str
) – user name to create for login on machine (required)password (
str
) – password for user that’ll be created (required)inet_family (
int
) – version of ip to use, default 4 (optional)keypairs (list of
int
orKeyPair
) – IDs of keypairs or Keypairs object
- Return type
Node
- create_volume(size, name, location=None, snapshot=None)[source]¶
Create a volume (disk).
- Parameters
size (
int
) – Size of volume to create (in GB).name (
str
) – Name of volume to createlocation (
NodeLocation
orNone
) – Location (zone) to create the volume insnapshot (
Snapshot
) – Snapshot to create image from
- Returns
Storage Volume object
- Return type
StorageVolume
- create_volume_snapshot(volume, name=None)¶
Creates a snapshot of the storage volume.
- Parameters
volume (
StorageVolume
) – The StorageVolume to create a VolumeSnapshot fromname (str) – Name of created snapshot (optional)
- Return type
VolumeSnapshot
- delete_image(node_image)¶
Deletes a node image from a provider.
- Parameters
node_image (
NodeImage
) – Node image object.- Returns
True
if delete_image was successful,False
otherwise.- Return type
bool
- delete_key_pair(key_pair)[source]¶
Delete an existing key pair.
- Parameters
key_pair (:class.KeyPair` or
int
) – Key pair object or ID.- Returns
True of False based on success of Keypair deletion
- Return type
bool
- destroy_node(node)[source]¶
Destroy a node.
- Parameters
node (
Node
) – Node object to destroy- Returns
True if successful
- Return type
bool
- destroy_volume(volume)[source]¶
Destroy a volume.
- Parameters
volume (
StorageVolume
) – Volume object to destroy- Returns
True if successful
- Return type
bool
- destroy_volume_snapshot(snapshot)¶
Destroys a snapshot.
- Parameters
snapshot (
VolumeSnapshot
) – The snapshot to delete- Return type
- detach_volume(node, volume)[source]¶
Detaches a volume from a node.
- Parameters
node (
Node
) – Node which should be usedvolume (
StorageVolume
) – Volume to be detached
- Return type
bool
- ex_get_node(node_id)[source]¶
Return a Node object based on a node id.
- Parameters
name (
int
) – The ID of the node- Returns
A Node object for the node
- Return type
Node
- ex_get_volume(volume_id)[source]¶
Return a Volume object based on a volume ID.
- Parameters
volume_id (
int
) – The ID of the volume- Returns
A StorageVolume object for the volume
- Return type
StorageVolume
- ex_list_interfaces()[source]¶
Specific method to list network interfaces
- Return type
list
ofGandiNetworkInterface
- ex_node_attach_disk(node, disk)[source]¶
Specific method to attach a disk to a node
- Parameters
node (
Node
) – Node which should be useddisk (
GandiDisk
) – Disk which should be used
- Return type
bool
- ex_node_attach_interface(node, iface)[source]¶
Specific method to attach an interface to a node
- Parameters
node (
Node
) – Node which should be usediface (
GandiNetworkInterface
) – Network interface which should be used
- Return type
bool
- ex_node_detach_disk(node, disk)[source]¶
Specific method to detach a disk from a node
- Parameters
node (
Node
) – Node which should be useddisk (
GandiDisk
) – Disk which should be used
- Return type
bool
- ex_node_detach_interface(node, iface)[source]¶
Specific method to detach an interface from a node
- Parameters
node (
Node
) – Node which should be usediface (
GandiNetworkInterface
) – Network interface which should be used
- Return type
bool
- ex_snapshot_disk(disk, name=None)[source]¶
Specific method to make a snapshot of a disk
- Parameters
disk (
GandiDisk
) – Disk which should be usedname (
str
) – Name which should be used
- Return type
bool
- ex_update_disk(disk, new_size=None, new_name=None)[source]¶
Specific method to update size or name of a disk WARNING: if a server is attached it’ll be rebooted
- Parameters
disk (
GandiDisk
) – Disk which should be usednew_size (
int
) – New sizenew_name (
str
) – New name
- Return type
bool
- get_image(image_id)¶
Returns a single node image from a provider.
- Parameters
image_id (
str
) – Node to run the task on.
:rtype
NodeImage
: :return: NodeImage instance on success.
- get_key_pair(name)[source]¶
Retrieve a single key pair.
- Parameters
name (
str
) – Name of the key pair to retrieve.- Return type
- import_key_pair_from_file(name, key_file_path)¶
Import a new public key from string.
- Parameters
name (
str
) – Key pair name.key_file_path (
str
) – Path to the public key file.
- Return type
KeyPair
object
- import_key_pair_from_string(name, key_material)[source]¶
Create a new key pair object.
- Parameters
name (
str
) – Key pair name.key_material (
str
) – Public key material.
- Returns
Imported key pair object.
- Return type
- list_images(location=None)[source]¶
Return a list of image objects.
- Parameters
location (
NodeLocation
) – Which data center to filter a images in.- Returns
List of GCENodeImage objects
- Return type
list
ofGCENodeImage
- list_key_pairs()[source]¶
List registered key pairs.
- Returns
A list of key par objects.
- Return type
list
oflibcloud.compute.base.KeyPair
- list_locations()[source]¶
Return a list of locations (datacenters).
- Returns
List of NodeLocation objects
- Return type
list
ofNodeLocation
- list_nodes()[source]¶
Return a list of nodes in the current zone or all zones.
- Returns
List of Node objects
- Return type
list
ofNode
- list_sizes(location=None)[source]¶
Return a list of sizes (machineTypes) in a zone.
- Parameters
location (
NodeLocation
orNone
) – Which data center to filter a sizes in.- Returns
List of NodeSize objects
- Return type
list
ofNodeSize
- list_volume_snapshots(volume)¶
List snapshots for a storage volume.
- Return type
list
ofVolumeSnapshot
- list_volumes()[source]¶
Return a list of volumes.
- Returns
A list of volume objects.
- Return type
list
ofStorageVolume
- reboot_node(node)[source]¶
Reboot a node.
- Parameters
node (
Node
) – Node to be rebooted- Returns
True if successful, False if not
- Return type
bool
- start_node(node)¶
Start a node.
- Parameters
node (
Node
) – The node to be started- Returns
True if the start was successful, otherwise False
- Return type
bool
- stop_node(node)¶
Stop a node
- Parameters
node (
Node
) – The node to be stopped.- Returns
True if the stop was successful, otherwise False
- Return type
bool
- wait_until_running(nodes, wait_period=5, timeout=600, ssh_interface='public_ips', force_ipv4=True, ex_list_nodes_kwargs=None)¶
Block until the provided nodes are considered running.
Node is considered running when it’s state is “running” and when it has at least one IP address assigned.
- Parameters
nodes (
list
ofNode
) – List of nodes to wait for.wait_period (
int
) – How many seconds to wait between each loop iteration. (default is 3)timeout (
int
) – How many seconds to wait before giving up. (default is 600)ssh_interface (
str
) – Which attribute on the node to use to obtain an IP address. Valid options: public_ips, private_ips. Default is public_ips.force_ipv4 (
bool
) – Ignore IPv6 addresses (default is True).ex_list_nodes_kwargs (
dict
) – Optional driver-specific keyword arguments which are passed to thelist_nodes
method.
- Returns
[(Node, ip_addresses)]
list of tuple of Node instance and list of ip_address on success.- Return type
list
oftuple