OVH Compute Driver Documentation

OVH is an Internet Service Provider providing dedicated servers, shared and cloud hosting, domain registration, and VOIP telephony services.


OVH driver uses a REST API, for more information about that, please refer to API console.

Instantiating a driver

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

  • key - Application key
  • secret - Application secret
  • ex_project_id - Project ID
  • ex_consumer_key - Consumer key

For get application key and secret, you must register an application at Next step, create a consumer key with following command:

curl -X POST \
    -H 'X-Ovh-Application: youApplicationKey' \
    -H 'Content-Type: application/json' \
    -d '{
        }' \

This will answer a JSON like below with inside your Consumer Key and validationUrl. Follow this link for valid your key.


Secondly, you must create a cloud project and retrieve its ID, from URL for example.

Now you have and can use you credentials with Libcloud.


Create node

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

Ovh = get_driver(Provider.OVH)
driver = Ovh('yourAppKey', 'yourAppSecret', 'yourProjectId', 'yourConsumerKey')

location = [l for l in driver.list_locations() if == 'SBG1'][0]
image = [i for i in driver.list_images() if 'Debian 8' ==][0]
size = [s for s in driver.list_sizes() if == 'vps-ssd-1'][0]

node = driver.create_node(name='yournode', size=size, image=image,

Create and attach a volume to a node

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

Ovh = get_driver(Provider.OVH)
driver = Ovh('yourAppKey', 'yourAppSecret', 'youProjectId', 'yourConsumerKey')

location = [l for l in driver.list_locations() if == 'SBG1'][0]
node = driver.list_nodes()[0]

volume = driver.create_volume(size=10, location=location)
driver.attach_volume(node=node, volume=volume)

API Docs

class, secret, ex_project_id, ex_consumer_key=None)[source]

Libcloud driver for the Ovh API

For more information on the Ovh API, read the official reference:

Instantiate the driver with the given API credentials.

  • key (str) – Your application key (required)
  • secret (str) – Your application secret (required)
  • ex_project_id (str) – Your project ID
  • ex_consumer_key (str) – Your consumer key (required)
Return type:


attach_volume(node, volume, device=None)[source]

Attach a volume to a node.

  • node (Node) – Node where to attach volume
  • volume (StorageVolume) – The ID of the volume
  • device – Unsed parameter

True or False representing operation successful

Return type:



alias of

copy_image(source_region, node_image, name, description=None)

Copies an image from a source region to the current region.

  • 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 instance on success.

create_image(node, name, description=None)

Creates an image from a node object.

  • node (Node) – Node to run the task on.
  • name (description) – name for new image.
  • description – description for new image.
Return type:



NodeImage instance on success.


Create a new key pair object.

Parameters:name (str) – Key pair name.
Return type:KeyPair object
create_node(name, image, size, location, ex_keyname=None)[source]

Create a new node

  • name (str) – Name of created node
  • image (NodeImage) – Image used for node
  • size (NodeSize) – Size (flavor) used for node
  • location (NodeLocation) – Location (region) where to create node
  • ex_keyname (str) – Name of SSH key used

Created node

:rtype : Node

create_volume(size, name, location, snapshot=None, ex_volume_type='classic', ex_description=None)[source]

Create a volume.

  • size (int) – Size of volume to create (in GB).
  • name (str) – Name of volume to create
  • location (NodeLocation or None) – Location to create the volume in
  • snapshot (VolumeSnapshot) – Snapshot from which to create the new volume. (optional)
  • ex_volume_type (str) – 'classic' or 'high-speed'
  • ex_description (str) – Optionnal description of volume

Storage Volume object

Return type:


create_volume_snapshot(volume, name=None, ex_description=None)[source]

Create snapshot from volume

  • volume (StorageVolume) – Instance of StorageVolume
  • name (str | NoneType) – Name of snapshot (optional)
  • ex_description (str | NoneType) – Description of the snapshot (optional)
Return type:



Deletes a node image from a provider.

Parameters:node_image (NodeImage) – Node image object.
Returns:True if delete_image was successful, False otherwise.
Return type:bool

Delete an existing key pair.

Parameters:key_pair (KeyPair) – Key pair object.
Return type:bool
deploy_node(deploy, ssh_username='root', ssh_alternate_usernames=None, ssh_port=22, ssh_timeout=10, ssh_key=None, ssh_key_password=None, auth=None, timeout=300, max_tries=3, ssh_interface='public_ips', at_exit_func=None, **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.

  • 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)
  • ssh_key_password (str) – Optional password used for encrypted keys.
  • 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’.
  • at_exit_func (func) –

    Optional atexit handler function which will be registered and called with created node if user cancels the deploy process (e.g. CTRL+C), after the node has been created, but before the deploy process has finished.

    This method gets passed in two keyword arguments:

    • driver -> node driver in question
    • node -> created Node object

    Keep in mind that this function will only be called in such scenario. In case the method finishes (this includes throwing an exception), at exit handler function won’t be called.


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

Destroys a storage volume.

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

Destroys a snapshot.

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

Detach a volume to a node.

  • volume (StorageVolume) – The ID of the volume
  • ex_node (Node) – Node to detach from (optionnal if volume is attached to only one node)

True or False representing operation successful

Return type:



Exception: If ex_node is not provided and more than one node is attached to the volume


Get a individual node.

Parameters:node_id (str) – Node’s ID
Returns:Created node

:rtype : Node


Get an individual size (flavor).

Parameters:size_id (str) – Size’s ID
Return type:NodeSize

Return a Volume object based on a volume ID.

Parameters:volume_id (int) – The ID of the volume
Returns:A StorageVolume object for the volume
Return type:StorageVolume

Returns a single volume snapshot.

Parameters:snapshot_id (str) – Node to run the task on.

:rtype VolumeSnapshot: :return: Volume snapshot.


List all snapshots.

Parameters:location (NodeLocation or None) – Location used to filter
Return type:list of VolumeSnapshot

Returns a single node image from a provider.

Parameters:image_id (str) – Node to run the task on.

:rtype NodeImage: :return: NodeImage instance on success.

get_key_pair(name, ex_location=None)[source]

Get an individual SSH public key by its name and location.

  • name (str) – Name of the key pair to retrieve.
  • ex_location (NodeLocation) – Key’s region

Public key

Return type:


import_key_pair_from_file(name, key_file_path)

Import a new public key from string.

  • 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, ex_location)[source]

Import a new public key from string.

  • name (str) – Key pair name.
  • key_material (str) – Public key material.
  • ex_location (NodeLocation) – Location where to store the key

Imported key pair object.

Return type:


list_images(location=None, ex_size=None)[source]

List available images

  • location (NodeLocation) – Location (region) used as filter
  • ex_size (NodeImage) – Exclude images which are uncompatible with given size

List of images

:rtype : list of NodeImage


List available SSH public keys.

Parameters:ex_location (NodeLocation) – Location (region) used as filter
Returns:Public keys
Return type:``list``of KeyPair

List data centers for a provider

Returns:list of node location objects
Return type:list of NodeLocation

List all nodes.

Parameters:location (NodeLocation) – Location (region) used as filter
Returns:List of node objects
Return type:list of Node

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 snapshots for a storage volume.

Return type:list of VolumeSnapshot

Return a list of volumes.

Parameters:ex_location (NodeLocation or None) – Location used to filter
Returns:A list of volume objects.
Return type:list of StorageVolume

Reboot a node.

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

Start a node.

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

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.

  • 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.

[(Node, ip_addresses)] list of tuple of Node instance and list of ip_address on success.

Return type:

list of tuple