cloudscale.ch Compute Driver Documentation

cloudscale.ch is a public cloud provider based in Switzerland.

../../_images/cloudscale.png

How to get an API Key

Simply visit https://control.cloudscale.ch/user/api-tokens and generate your key.

You can generate read and read/write API keys. These token types give you more access control. Revoking an API token is also possible.

Using the API to the full extent

Most of the cloudscale.ch API is covered by the simple commands:

  • driver.list_sizes()

  • driver.list_images()

  • driver.list_nodes()

  • driver.reboot_node(node)

  • driver.ex_start_node(node)

  • driver.ex_stop_node(node)

  • driver.ex_node_by_uuid(server_uuid)

  • driver.destroy_node(node)

  • driver.create_node(name, size, image, ex_create_attr={})

In our example below you can see how you use ex_create_attr when creating servers. Possible dictionary entries in ex_create_attr are:

  • ssh_keys (list of str) - A list of SSH public keys.

  • volume_size_gb (int) - The size in GB of the root volume.

  • bulk_volume_size_gb (int) - The size in GB of the bulk storage volume.

  • use_public_network (bool) - Attaching/Detaching the public network interface.

  • use_private_network (bool) - Attaching/Detaching the private network interface.

  • use_ipv6 (bool) - Enabling/Disabling IPv6.

  • anti_affinity_with (str) - Pass the UUID of another server.

  • user_data (str) - Cloud-init configuration (cloud-config). Provide YAML.

There’s more extensive documentation on these parameters in our Server-Create API Documentation.

Examples

Create a cloudscale.ch server

from pprint import pprint

import libcloud

cls = libcloud.get_driver(libcloud.DriverType.COMPUTE, libcloud.DriverType.COMPUTE.CLOUDSCALE)

TOKEN = "3pjzjh3h3rfynqa4iemvtvc33pyfzss2"
driver = cls(TOKEN)

sizes = driver.list_sizes()
images = driver.list_images()
pprint(sizes)
pprint(images)

new_node = driver.create_node(
    name="hello-darkness-my-old-friend",
    size=sizes[0],
    image=images[0],
    ex_create_attr=dict(
        ssh_keys=["ssh-rsa AAAAB3Nza..."],
        use_private_network=True,
    ),
)
pprint(new_node)

API Docs

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

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

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.

reboot_node(node)[source]

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

wait_until_running(nodes: List[Node], wait_period: float = 5, timeout: int = 600, ssh_interface: str = 'public_ips', force_ipv4: bool = True, ex_list_nodes_kwargs: Dict | None = None) List[Tuple[Node, List[str]]]

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