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.- allow_insecure = False
- 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 emptydict
.data (
unicode
) – A body of data to send with the request.headers (
dict
) – Extra headers to add to the request None, leave as an emptydict
.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 imagename (
str
) – The name to give the imageregion – 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:
- 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 nodesize (
NodeSize
) – The size of node to createimage (
NodeImage
) – The image to create the node withex_volumes (
dict
of :class:`.StorageVolume`s) – Additional volumes to create the node withex_tags (
list
ofstr
) – Tags to assign to the noderegion – 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:
- 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 snapshotregion – 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 deleteregion – 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 destroyedregion – 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 retrieveregion – 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:
- 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
ofNodeImage
- list_key_pairs()[source]
List all the available SSH keys.
- Returns:
Available SSH keys.
- Return type:
list
ofKeyPair
- list_locations()[source]
List data centers available.
- Returns:
list of node location objects
- Return type:
list
ofNodeLocation
- 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
ofNode
- 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
ofNodeSize
- 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
ofStorageVolume
- 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
orFalse
- valid_response_codes = [<HTTPStatus.OK: 200>, <HTTPStatus.ACCEPTED: 202>, <HTTPStatus.CREATED: 201>, <HTTPStatus.NO_CONTENT: 204>]