Scaleway Compute Driver Documentation

Scaleway is a dedicated bare metal cloud hosting provider based in Paris

../../_images/scaleway.png

Instantiating a driver and listing nodes

from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver

cls = get_driver(Provider.SCALEWAY)
driver = cls('SCALEWAY_ACCESS_KEY', 'SCALEWAY_SECRET_TOKEN')

nodes = driver.list_nodes()
for node in nodes:
    print(node)

Instantiating a driver and listing volumes

from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver

cls = get_driver(Provider.SCALEWAY)
driver = cls('SCALEWAY_ACCESS_KEY', 'SCALEWAY_SECRET_TOKEN')

volumes = driver.list_volumes()
for volume in volumes:
    print(volume)
    snapshots = driver.list_volume_snapshots(volume)
    for snapshot in snapshots:
        print("  snapshot-%s" % snapshot)

API Docs

class libcloud.compute.drivers.scaleway.ScalewayNodeDriver(key, secret=None, secure=True, host=None, port=None, api_version=None, region=None, **kwargs)[source]

Scaleway Node Driver Class

This is the primary driver for interacting with Scaleway. It contains all of the standard libcloud methods that Scaleway’s API supports.

Parameters:
  • key (str) – API key or username to be used (required)
  • secret (str) – Secret password to be used (required)
  • secure (bool) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.
  • host (str) – Override hostname used for connections.
  • port (int) – Override port used for connections.
  • api_version (str) – Optional API version. Only used by drivers which support multiple API versions.
  • region (str) – Optional driver region. Only used by drivers which support multiple regions.
Return type:

None

attach_volume(node, volume, device=None)

Attaches volume to node.

Parameters:
  • node (Node) – Node to attach volume to.
  • volume (StorageVolume) – Volume to attach.
  • device (str) – Where the device is exposed, e.g. ‘/dev/sdb’
Rytpe:

bool

connectionCls

alias of ScalewayConnection

copy_image(source_region, node_image, name, description=None)

Copies an image from a source region to the current region.

Parameters:
  • source_region (str) – Region to copy the node from.
  • node_image (NodeImage:) – NodeImage to copy.
  • name (str) – name for new image.
  • description – description for new image.
Return type:

NodeImage:

Returns:

NodeImage instance on success.

create_image(node, name, region=None)[source]

Create a VM image from an existing node’s root volume.

Parameters:
  • node (Node) – The node from which to create the image
  • name (str) – The name to give the image
  • region – The region in which to create the image

(if None, use default region specified in __init__) :type region: NodeLocation

Returns:the newly created image object
Return type:NodeImage
create_key_pair(name)

Create a new key pair object.

Parameters:name (str) – Key pair name.
create_node(name, size, image, ex_volumes=None, ex_tags=None, region=None)[source]

Create a new node.

Parameters:
  • name (str) – The name to give the node
  • size (NodeSize) – The size of node to create
  • image (NodeImage) – The image to create the node with
  • ex_volumes (dict of :class:`.StorageVolume`s) – Additional volumes to create the node with
  • ex_tags (list of str) – Tags to assign to the node
  • region – The region in which to create the node

(if None, use default region specified in __init__) :type region: NodeLocation

Returns:the newly created node object
Return type:Node
create_volume(size, name, region=None)[source]

Create a new volume.

Parameters:
  • size (int) – Size of volume in gigabytes.
  • name (str) – Name of the volume to be created.
  • region – The region in which to create the volume

(if None, use default region specified in __init__) :type region: NodeLocation

Returns:The newly created volume.
Return type:StorageVolume
create_volume_snapshot(volume, name, region=None)[source]

Create snapshot from volume.

Parameters:
  • volume (:class`StorageVolume`) – The volume to create a snapshot from
  • name (str) – The name to give the snapshot
  • region – The region in which to create the snapshot

(if None, use default region specified in __init__) :type region: NodeLocation

Returns:The newly created snapshot.
Return type:VolumeSnapshot
delete_image(node_image, region=None)[source]

Delete a VM image.

Parameters:
  • node_image (NodeImage) – The image to delete
  • region – The region in which to find/delete the image

(if None, use default region specified in __init__) :type region: NodeLocation

Returns:True if the image was deleted, otherwise False
Return type:bool
delete_key_pair(key_pair)[source]

Delete an existing key pair.

Parameters:key_pair (KeyPair) – Key pair object.
Returns:True of False based on success of Keypair deletion
Return type:bool
deploy_node(**kwargs)

Create a new node, and start deployment.

In order to be able to SSH into a created node access credentials are required.

A user can pass either a NodeAuthPassword or NodeAuthSSHKey to the auth argument. If the create_node implementation supports that kind if credential (as declared in self.features['create_node']) then it is passed on to create_node. Otherwise it is not passed on to create_node and it is only used for authentication.

If the auth parameter is not supplied but the driver declares it supports generates_password then the password returned by create_node will be used to SSH into the server.

Finally, if the ssh_key_file is supplied that key will be used to SSH into the server.

This function may raise a DeploymentException, if a create_node call was successful, but there is a later error (like SSH failing or timing out). This exception includes a Node object which you may want to destroy if incomplete deployments are not desirable.

>>> from libcloud.compute.drivers.dummy import DummyNodeDriver
>>> from libcloud.compute.deployment import ScriptDeployment
>>> from libcloud.compute.deployment import MultiStepDeployment
>>> from libcloud.compute.base import NodeAuthSSHKey
>>> driver = DummyNodeDriver(0)
>>> key = NodeAuthSSHKey('...') # read from file
>>> script = ScriptDeployment("yum -y install emacs strace tcpdump")
>>> msd = MultiStepDeployment([key, script])
>>> def d():
...     try:
...         driver.deploy_node(deploy=msd)
...     except NotImplementedError:
...         print ("not implemented for dummy driver")
>>> d()
not implemented for dummy driver

Deploy node is typically not overridden in subclasses. The existing implementation should be able to handle most such.

Parameters:
  • deploy (Deployment) – Deployment to run once machine is online and available to SSH.
  • ssh_username (str) – Optional name of the account which is used when connecting to SSH server (default is root)
  • ssh_alternate_usernames (list) – Optional list of ssh usernames to try to connect with if using the default one fails
  • ssh_port (int) – Optional SSH server port (default is 22)
  • ssh_timeout (float) – Optional SSH connection timeout in seconds (default is 10)
  • auth (NodeAuthSSHKey or NodeAuthPassword) – Initial authentication information for the node (optional)
  • ssh_key (str or list of str) – A path (or paths) to an SSH private key with which to attempt to authenticate. (optional)
  • timeout (int) – How many seconds to wait before timing out. (default is 600)
  • max_tries (int) – How many times to retry if a deployment fails before giving up (default is 3)
  • ssh_interface (str) – The interface to wait for. Default is ‘public_ips’, other option is ‘private_ips’.
destroy_node(node)[source]

Destroy a node.

Parameters:node (Node) – The node to be destroyed
Returns:True if the destroy was successful, otherwise False
Return type:bool
destroy_volume(volume, region=None)[source]

Destroys a storage volume.

Parameters:
  • volume (StorageVolume) – Volume to be destroyed
  • region – The region in which to look for the volume

(if None, use default region specified in __init__) :type region: NodeLocation

Returns:True if the destroy was successful, otherwise False
Return type:bool
destroy_volume_snapshot(snapshot, region=None)[source]

Dostroy a volume snapshot

Parameters:
  • snapshot (class:VolumeSnapshot) – volume snapshot to destroy
  • region – The region in which to look for the snapshot

(if None, use default region specified in __init__) :type region: NodeLocation

Returns:True if the destroy was successful, otherwise False
Return type:bool
detach_volume(volume)

Detaches a volume from a node.

Parameters:volume (StorageVolume) – Volume to be detached
Return type:bool
get_image(image_id, region=None)[source]

Retrieve a specific VM image.

Parameters:
  • image_id (int) – The id of the image to retrieve
  • region – The region in which to create the image

(if None, use default region specified in __init__) :type region: NodeLocation

Returns:the requested image object
Return type:NodeImage
get_key_pair(name)

Retrieve a single key pair.

Parameters:name (str) – Name of the key pair to retrieve.
Return type:KeyPair
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]

Import a new public key from string.

Parameters:
  • name (str) – Key pair name.
  • key_material (str) – Public key material.
Returns:

Imported key pair object.

Return type:

KeyPair

list_images(region=None)[source]

List available VM images.

Parameters:region – The region in which to list images

(if None, use default region specified in __init__) :type region: NodeLocation

Returns:list of image objects
Return type:list of NodeImage
list_key_pairs()[source]

List all the available SSH keys.

Returns:Available SSH keys.
Return type:list of KeyPair
list_locations()[source]

List data centers available.

Returns:list of node location objects
Return type:list of NodeLocation
list_nodes(region=None)[source]

List all nodes.

Parameters:region – The region in which to look for nodes

(if None, use default region specified in __init__) :type region: NodeLocation

Returns:list of node objects
Return type:list of Node
list_sizes(region=None)[source]

List available VM sizes.

Parameters:region – The region in which to list sizes

(if None, use default region specified in __init__) :type region: NodeLocation

Returns:list of node size objects
Return type:list of NodeSize
list_volume_snapshots(volume, region=None)[source]

List snapshots for a storage volume.

@inherits NodeDriver.list_volume_snapshots

Parameters:region – The region in which to look for snapshots

(if None, use default region specified in __init__) :type region: NodeLocation

list_volumes(region=None)[source]

Return a list of volumes.

Parameters:region – The region in which to look for volumes

(if None, use default region specified in __init__) :type region: NodeLocation

Returns:A list of volume objects.
Return type:list of StorageVolume
reboot_node(node)[source]

Reboot a node.

Parameters:node (Node) – The node to be rebooted
Returns:True if the reboot was successful, otherwise False
Return type:bool
wait_until_running(nodes, wait_period=3, 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 of Node) – 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 the list_nodes method.
Returns:

[(Node, ip_addresses)] list of tuple of Node instance and list of ip_address on success.

Return type:

list of tuple