libcloud.compute.drivers.cloudscale module

A driver for cloudscale.ch.

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

Bases: ConnectionKey

Connection class for the cloudscale.ch 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

This method adds token to the request.

host: str = 'api.cloudscale.ch'
responseCls

alias of CloudscaleResponse

class libcloud.compute.drivers.cloudscale.CloudscaleNodeDriver(key, **kwargs)[source]

Bases: NodeDriver

Cloudscale’s node driver.

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

NODE_STATE_MAP: Dict[str, NodeState] = {'changing': NodeState.PENDING, 'paused': NodeState.PAUSED, 'running': NodeState.RUNNING, 'stopped': NodeState.STOPPED}
connectionCls

alias of CloudscaleConnection

create_node(name, size, image, location=None, ex_create_attr=None)[source]

Create a node.

The ex_create_attr parameter can include the following dictionary key and value pairs:

  • ssh_keys: list of str ssh public keys

  • volume_size_gb: int defaults to 10.

  • bulk_volume_size_gb: defaults to None.

  • use_public_network: bool defaults to True

  • use_private_network: bool defaults to False

  • use_ipv6: bool defaults to True

  • anti_affinity_with: uuid of a server to create an anti-affinity group with that server or add it to the same group as that server.

  • user_data: str for optional cloud-config data

Parameters:

ex_create_attr (dict) – A dictionary of optional attributes for droplet creation

Returns:

The newly created node.

Return type:

Node

destroy_node(node)[source]

Delete a node. It’s also possible to use node.destroy(). This will irreversibly delete the cloudscale.ch server and all its volumes. So please be cautious.

ex_node_by_uuid(uuid)[source]
Parameters:

ex_user_data (str) – A valid uuid that references your existing cloudscale.ch server.

Returns:

The server node you asked for.

Return type:

Node

ex_start_node(node)[source]
ex_stop_node(node)[source]
list_images()[source]

List all images.

Images are identified by slugs on cloudscale.ch. This means that minor version upgrades (e.g. Ubuntu 16.04.1 to Ubuntu 16.04.2) will be possible within the same id ubuntu-16.04.

list_nodes()[source]

List all your existing compute nodes.

list_sizes()[source]

Lists all available sizes. On cloudscale these are known as flavors.

name: str = 'Cloudscale'
reboot_node(node)[source]

Reboot a node. It’s also possible to use node.reboot().

start_node(node)[source]

Start a node. This is only possible if the node is stopped.

stop_node(node)[source]

Stop a specific node. Similar to shutdown -h now. This is only possible if the node is running.

type: Provider | str = 'cloudscale'
website: str = 'https://www.cloudscale.ch'
class libcloud.compute.drivers.cloudscale.CloudscaleResponse(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>]