Cloudwatt Compute Driver Documentation

Cloudwatt is a public cloud provider based in Boulogne-Billancourt, France with one datacenter at Val-de-Reuil

../../_images/cloudwatt.png

Cloudwatt driver is based on the OpenStack driver so for more information about that and OpenStack specific documentation, please refer to OpenStack Compute Driver Documentation page.

Instantiating a driver

When you instantiate a driver you need to pass the following arguments to the driver constructor:

  • username - your Cloudwatt registered email
  • password - your Cloudwatt password
  • tenant_id - your Cloudwatt tenant ID
  • tenant_name - your Cloudwatt tenant name

Tenant ID and name are foundable in the RC script available with web interface at https://console.cloudwatt.com/overrides/access_and_security_overrides/view_credentials/

Examples

Create instance

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

Cloudwatt = get_driver(Provider.CLOUDWATT)
driver = Cloudwatt('your_email', 'your_password', 'your_tenant_id',
                   tenant_name='your_tenant_name')
image = [i for i in driver.list_images() if i.name == 'Debian Wheezy'][0]
size = [s for s in driver.list_sizes() if s.name == 'n1.cw.standard-1'][0]
node = driver.create_node(name='yournode', size=size, image=image)

Create volume and attach

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

Cloudwatt = get_driver(Provider.CLOUDWATT)
driver = Cloudwatt('your_email', 'your_password', 'your_tenant_id',
                   tenant_name='your_tenant_name')
node = driver.list_nodes()[0]
volume = driver.create_volume(10, 'your_volume')
driver.attach_volume(node, volume)

API Docs

class libcloud.compute.drivers.cloudwatt.CloudwattNodeDriver(key, secret, tenant_id, secure=True, tenant_name=None, host=None, port=None, **kwargs)[source]

Implements the NodeDriver’s for Cloudwatt.

@inherits: NodeDriver.__init__

Parameters:tenant_id (str) – ID of tenant required for Cloudwatt auth
attach_volume(node, volume, device=None)[source]

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 CloudwattConnection

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, metadata=None)

Creates a new image.

Parameters:
  • node (Node) – Node
  • name (str) – The name for the new image.
  • metadata (dict) – Key and value pairs for metadata.
Return type:

NodeImage

create_key_pair(name)

Create a new key pair object.

Parameters:name (str) – Key pair name.
Return type:KeyPair object
create_node(name, size, image=None, ex_keyname=None, ex_userdata=None, ex_config_drive=None, ex_security_groups=None, ex_metadata=None, ex_files=None, networks=None, ex_disk_config=None, ex_admin_pass=None, ex_availability_zone=None, ex_blockdevicemappings=None)

Create a new node

@inherits: NodeDriver.create_node

Parameters:
  • ex_keyname (str) – The name of the key pair
  • ex_userdata (str) – String containing user data see https://help.ubuntu.com/community/CloudInit
  • ex_config_drive (bool) – Enable config drive see http://docs.openstack.org/grizzly/openstack-compute/admin/content/config-drive.html
  • ex_security_groups (list of OpenStackSecurityGroup) – List of security groups to assign to the node
  • ex_metadata (dict) – Key/Value metadata to associate with a node
  • ex_files (dict) – File Path => File contents to create on the node
  • networks (list of OpenStackNetwork) – The server is launched into a set of Networks.
  • ex_disk_config (str) – Name of the disk configuration. Can be either AUTO or MANUAL.
  • ex_config_drive – If True enables metadata injection in a server through a configuration drive.
  • ex_admin_pass (str) – The root password for the node
  • ex_availability_zone (str) – Nova availability zone for the node
create_volume(size, name, location=None, snapshot=None, ex_volume_type=None)

Create a new volume.

Parameters:
  • size (int) – Size of volume in gigabytes (required)
  • name (str) – Name of the volume to be created
  • location (NodeLocation) – Which data center to create a volume in. If empty, undefined behavior will be selected. (optional)
  • snapshot (VolumeSnapshot) – Snapshot from which to create the new volume. (optional)
  • ex_volume_type (str) – What kind of volume to create. (optional)
Returns:

The newly created volume.

Return type:

StorageVolume

create_volume_snapshot(volume, name=None, ex_description=None, ex_force=True)

Create snapshot from volume

Parameters:
  • volume (StorageVolume) – Instance of StorageVolume
  • name (str | NoneType) – Name of snapshot (optional)
  • ex_description (str | NoneType) – Description of the snapshot (optional)
  • ex_force (bool) – Specifies if we create a snapshot that is not in state available. For example in-use. Defaults to True. (optional)
Return type:

VolumeSnapshot

delete_image(image)

Delete a NodeImage

@inherits: NodeDriver.delete_image

Parameters:image (NodeImage) – image witch should be used
Return type:bool
delete_key_pair(key_pair)

Delete a KeyPair.

Parameters:keypair (OpenStackKeyPair) – KeyPair to delete
Return type:bool
deploy_node(deploy, ssh_username='root', ssh_alternate_usernames=None, ssh_port=22, ssh_timeout=10, ssh_key=None, auth=None, timeout=300, max_tries=3, ssh_interface='public_ips', **create_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)

Destroy a node.

Depending upon the provider, this may destroy all data associated with the node, including backups.

Parameters:node (Node) – The node to be destroyed
Returns:True if the destroy was successful, False otherwise.
Return type:bool
destroy_volume(volume)

Destroys a storage volume.

Parameters:volume (StorageVolume) – Volume to be destroyed
Return type:bool
destroy_volume_snapshot(snapshot)

Destroys a snapshot.

Parameters:snapshot (VolumeSnapshot) – The snapshot to delete
Return type:bool
detach_volume(volume, ex_node=None)

Detaches a volume from a node.

Parameters:volume (StorageVolume) – Volume to be detached
Return type:bool
ex_attach_floating_ip_to_node(node, ip)

Attach the floating IP to the node

Parameters:
  • node (Node) – node
  • ip (str or OpenStack_1_1_FloatingIpAddress) – floating IP to attach
Return type:

bool

ex_confirm_resize(node)

Confirms a pending resize action.

Parameters:node (Node) – Node to resize.
Return type:bool
ex_create_floating_ip(ip_pool=None)

Create new floating IP. The ip_pool attribute is optional only if your infrastructure has only one IP pool available.

Parameters:ip_pool (str) – name of the floating IP pool
Return type:OpenStack_1_1_FloatingIpAddress
ex_create_keypair(name)

Create a new KeyPair

Parameters:name (str) – Name of the new KeyPair
Return type:OpenStackKeyPair
ex_create_network(name, cidr)

Create a new Network

Parameters:
  • name (str) – Name of network which should be used
  • cidr (str) – cidr of network which should be used
Return type:

OpenStackNetwork

ex_create_security_group(name, description)

Create a new Security Group

Parameters:
  • name (str) – Name of the new Security Group
  • description (str) – Description of the new Security Group
Return type:

OpenStackSecurityGroup

ex_create_security_group_rule(security_group, ip_protocol, from_port, to_port, cidr=None, source_security_group=None)

Create a new Rule in a Security Group

Parameters:
  • security_group (OpenStackSecurityGroup) – Security Group in which to add the rule
  • ip_protocol (str) – Protocol to which this rule applies Examples: tcp, udp, …
  • from_port (int) – First port of the port range
  • to_port (int) – Last port of the port range
  • cidr (str) – CIDR notation of the source IP range for this rule
  • source_security_group (L{OpenStackSecurityGroup) – Existing Security Group to use as the source (instead of CIDR)
Return type:

OpenStackSecurityGroupRule

ex_create_snapshot(volume, name, description=None, force=False)

Create a snapshot based off of a volume.

Parameters:
  • volume (StorageVolume) – volume
  • name (str) – New name for the volume snapshot
  • description (str) – Description of the snapshot (optional)
  • force (bool) – Whether to force creation (optional)
Return type:

VolumeSnapshot

ex_delete_floating_ip(ip)

Delete specified floating IP

Parameters:ip (OpenStack_1_1_FloatingIpAddress) – floating IP to remove
Return type:bool
ex_delete_keypair(keypair)

Delete a KeyPair.

Parameters:keypair (OpenStackKeyPair) – KeyPair to delete
Return type:bool
ex_delete_network(network)

Delete a Network

Parameters:network (OpenStackNetwork) – Network which should be used
Return type:bool
ex_delete_security_group(security_group)

Delete a Security Group.

Parameters:security_group (OpenStackSecurityGroup) – Security Group should be deleted
Return type:bool
ex_delete_security_group_rule(rule)

Delete a Rule from a Security Group.

Parameters:rule (OpenStackSecurityGroupRule) – Rule should be deleted
Return type:bool
ex_delete_snapshot(snapshot)

Delete a VolumeSnapshot

Parameters:snapshot (VolumeSnapshot) – snapshot
Return type:bool
ex_detach_floating_ip_from_node(node, ip)

Detach the floating IP from the node

Parameters:
  • node (Node) – node
  • ip (str or OpenStack_1_1_FloatingIpAddress) – floating IP to remove
Return type:

bool

ex_get_console_output(node, length=None)

Get console output

Parameters:
  • node (Node) – node
  • length (int) – Optional number of lines to fetch from the console log
Returns:

Dictionary with the output

Return type:

dict

ex_get_floating_ip(ip)

Get specified floating IP

Parameters:ip (str) – floating IP to get
Return type:OpenStack_1_1_FloatingIpAddress
ex_get_metadata(node)

Get a Node’s metadata.

Parameters:node (Node) – Node
Returns:Key/Value metadata associated with node.
Return type:dict
ex_get_metadata_for_node(node)

Return the metadata associated with the node.

Parameters:node (Node) – Node instance
Returns:A dictionary or other mapping of strings to strings, associating tag names with tag values.
ex_get_node_details(node_id)

Lists details of the specified server.

Parameters:node_id (str) – ID of the node which should be used
Return type:Node
ex_get_node_security_groups(node)

Get Security Groups of the specified server.

Return type:list of OpenStackSecurityGroup
ex_get_size(size_id)

Get a NodeSize

Parameters:size_id (str) – ID of the size which should be used
Return type:NodeSize
ex_hard_reboot_node(node)

Hard reboots the specified server

Parameters:node (Node) – node
Return type:bool
ex_import_keypair(name, keyfile)

Import a KeyPair from a file

Parameters:
  • name (str) – Name of the new KeyPair
  • keyfile (str) – Path to the public key file (in OpenSSH format)
Return type:

OpenStackKeyPair

ex_import_keypair_from_string(name, key_material)

Import a KeyPair from a string

Parameters:
  • name (str) – Name of the new KeyPair
  • key_material (str) – Public key (in OpenSSH format)
Return type:

OpenStackKeyPair

ex_list_floating_ip_pools()

List available floating IP pools

Return type:list of OpenStack_1_1_FloatingIpPool
ex_list_floating_ips()

List floating IPs

Return type:list of OpenStack_1_1_FloatingIpAddress
ex_list_keypairs()

Get a list of KeyPairs that are available.

Return type:list of OpenStackKeyPair
ex_list_networks()

Get a list of Networks that are available.

Return type:list of OpenStackNetwork
ex_list_security_groups()

Get a list of Security Groups that are available.

Return type:list of OpenStackSecurityGroup
ex_rebuild(node, image, **kwargs)

Rebuild a Node.

Parameters:
  • node (Node) – Node to rebuild.
  • image (NodeImage) – New image to use.
  • ex_metadata (dict) – Key/Value metadata to associate with a node
  • ex_files (dict) – File Path => File contents to create on the node
  • ex_keyname (str) – Name of existing public key to inject into instance
  • ex_userdata (str) – String containing user data see https://help.ubuntu.com/community/CloudInit
  • ex_security_groups (list of OpenStackSecurityGroup) – List of security groups to assign to the node
  • ex_disk_config (str) – Name of the disk configuration. Can be either AUTO or MANUAL.
  • ex_config_drive (bool) – If True enables metadata injection in a server through a configuration drive.
Return type:

bool

ex_rescue(node, password=None)

Rescue a node

Parameters:
  • node (Node) – node
  • password (str) – password
Return type:

Node

ex_resize(node, size)

Change a node size.

Parameters:
  • node (Node) – Node to resize.
  • size (NodeSize) – New size to use.
Return type:

bool

ex_revert_resize(node)

Cancels and reverts a pending resize action.

Parameters:node (Node) – Node to resize.
Return type:bool
ex_set_metadata(node, metadata)

Sets the Node’s metadata.

Parameters:
  • node (Node) – Node
  • metadata (dict) – Key/Value metadata to associate with a node
Return type:

dict

ex_set_password(node, password)

Changes the administrator password for a specified server.

Parameters:
  • node (Node) – Node to rebuild.
  • password (str) – The administrator password.
Return type:

bool

ex_set_server_name(node, name)

Sets the Node’s name.

Parameters:
  • node (Node) – Node
  • name (str) – The name of the server.
Return type:

Node

ex_soft_reboot_node(node)

Soft reboots the specified server

Parameters:node (Node) – node
Return type:bool
ex_unrescue(node)

Unrescue a node

Parameters:node (Node) – node
Return type:bool
ex_update_node(node, **node_updates)

Update the Node’s editable attributes. The OpenStack API currently supports editing name and IPv4/IPv6 access addresses.

The driver currently only supports updating the node name.

Parameters:
  • node (Node) – Node
  • name (str) – New name for the server
Return type:

Node

get_image(image_id)

Get a NodeImage

@inherits: NodeDriver.get_image

Parameters:image_id (str) – ID of the image which should be used
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)

Import a new public key from string.

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

KeyPair object

list_images(location=None, ex_only_active=True)

Lists all active images

@inherits: NodeDriver.list_images

Parameters:ex_only_active (bool) – True if list only active (optional)
list_key_pairs()

List all the available key pair objects.

Return type:list of KeyPair objects
list_locations()

List data centers for a provider

Returns:list of node location objects
Return type:list of NodeLocation
list_nodes(ex_all_tenants=False)

List the nodes in a tenant

Parameters:ex_all_tenants (bool) – List nodes for all the tenants. Note: Your user must have admin privileges for this functionality to work.
list_sizes(location=None)

List sizes on a provider

Parameters:location (NodeLocation) – The location at which to list sizes
Returns:list of node size objects
Return type:list of NodeSize
list_volume_snapshots(volume)

List snapshots for a storage volume.

Return type:list of VolumeSnapshot
list_volumes()

List storage volumes.

Return type:list of StorageVolume
openstack_connection_kwargs()

Returns certain ex_* parameters for this connection.

Return type:dict
reboot_node(node)

Reboot a node.

Parameters:node (Node) – The node to be rebooted
Returns:True if the reboot was successful, otherwise False
Return type:bool
start_node(node)

Start a node.

Parameters:node (Node) – The node to be started
Returns:True if the start was successful, otherwise False
Return type:bool
stop_node(node)

Stop a node

Parameters:node (Node) – The node to be stopped.
Returns:True if the stop 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