libcloud.compute.drivers.scaleway module

Scaleway Driver

class libcloud.compute.drivers.scaleway.ScalewayConnection(user_id, key, secure=True, host=None, port=None, url=None, timeout=None, proxy_url=None, backoff=None, retry_delay=None)[source]

Bases: ConnectionUserAndKey

Connection class for the Scaleway driver.

Initialize user_id and key; set secure to an int based on passed value.

add_default_headers(headers)[source]

Add headers that are necessary for every request

allow_insecure = False
host: str = 'cp-par1.scaleway.com'
request(action, params=None, data=None, headers=None, method='GET', raw=False, stream=False, region=None)[source]

Request a given action.

Basically a wrapper around the connection object’s request that does some helpful pre-processing.

Parameters:
  • action (str) – A path. This can include arguments. If included, any extra parameters are appended to the existing ones.

  • params (dict) – Optional mapping of additional parameters to send. If None, leave as an empty dict.

  • data (unicode) – A body of data to send with the request.

  • headers (dict) – Extra headers to add to the request None, leave as an empty dict.

  • method (str) – An HTTP method such as “GET” or “POST”.

  • raw (bool) – True to perform a “raw” request aka only send the headers and use the rawResponseCls class. This is used with storage API when uploading a file.

  • stream (bool) – True to return an iterator in Response.iter_content and allow streaming of the response data (for downloading large files)

  • retry_failed – True if failed requests should be retried. This argument can override module level constant and environment variable value on per-request basis.

Returns:

An Response instance.

Return type:

Response instance

responseCls

alias of ScalewayResponse

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

Bases: NodeDriver

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

SNAPSHOT_STATE_MAP = {'available': VolumeSnapshotState.AVAILABLE, 'error': VolumeSnapshotState.ERROR, 'snapshotting': VolumeSnapshotState.CREATING}
connectionCls

alias of ScalewayConnection

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_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

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

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

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

name: str = 'Scaleway'
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

type: Provider | str = 'scaleway'
website: str = 'https://www.scaleway.com/'
class libcloud.compute.drivers.scaleway.ScalewayResponse(response, connection)[source]

Bases: JsonResponse

Parameters:
  • response (httplib.HTTPResponse) – HTTP response object. (optional)

  • connection (Connection) – Parent connection object.

parse_error()[source]

Parse the error messages.

Override in a provider’s subclass.

Returns:

Parsed error.

Return type:

str

success()[source]

Determine if our request was successful.

The meaning of this can be arbitrary; did we receive OK status? Did the node get created? Were we authenticated?

Return type:

bool

Returns:

True or False

valid_response_codes = [<HTTPStatus.OK: 200>, <HTTPStatus.ACCEPTED: 202>, <HTTPStatus.CREATED: 201>, <HTTPStatus.NO_CONTENT: 204>]