libcloud.compute.drivers.ovh module¶
Ovh driver
- class libcloud.compute.drivers.ovh.OvhNodeDriver(key, secret, ex_project_id, ex_consumer_key=None, region=None)[source]¶
Bases:
NodeDriver
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.
- Parameters:
key (
str
) – Your application key (required)secret (
str
) – Your application secret (required)ex_project_id (
str
) – Your project IDex_consumer_key (
str
) – Your consumer key (required)region (
str
) – The datacenter to connect to (optional)
- Return type:
None
- NODE_STATE_MAP: Dict[str, NodeState] = {'ACTIVE': NodeState.RUNNING, 'BUILD': NodeState.PENDING, 'DELETED': NodeState.TERMINATED, 'DELETE_IP': NodeState.PENDING, 'ERROR': NodeState.ERROR, 'HARD_REBOOT': NodeState.REBOOTING, 'PASSWORD': NodeState.PENDING, 'PREP_RESIZE': NodeState.PENDING, 'QUEUE_RESIZE': NodeState.PENDING, 'REBOOT': NodeState.REBOOTING, 'REBUILD': NodeState.PENDING, 'RESCUE': NodeState.PENDING, 'RESIZE': NodeState.RECONFIGURING, 'SHARE_IP': NodeState.PENDING, 'SHARE_IP_NO_CONFIG': NodeState.PENDING, 'SHUTOFF': NodeState.STOPPED, 'SUSPENDED': NodeState.SUSPENDED, 'UNKNOWN': NodeState.UNKNOWN, 'VERIFY_RESIZE': NodeState.RUNNING}¶
- SNAPSHOT_STATE_MAP = {'available': VolumeSnapshotState.AVAILABLE, 'creating': VolumeSnapshotState.CREATING, 'deleting': VolumeSnapshotState.DELETING, 'error': VolumeSnapshotState.ERROR, 'error_restoring': VolumeSnapshotState.ERROR, 'restoring': VolumeSnapshotState.RESTORING}¶
- VOLUME_STATE_MAP = {'attaching': StorageVolumeState.ATTACHING, 'available': StorageVolumeState.AVAILABLE, 'backing-up': StorageVolumeState.BACKUP, 'creating': StorageVolumeState.CREATING, 'deleting': StorageVolumeState.DELETING, 'error': StorageVolumeState.ERROR, 'error_deleting': StorageVolumeState.ERROR, 'error_extending': StorageVolumeState.ERROR, 'error_restoring': StorageVolumeState.ERROR, 'in-use': StorageVolumeState.INUSE, 'restoring-backup': StorageVolumeState.BACKUP}¶
- attach_volume(node, volume, device=None)[source]¶
Attach a volume to a node.
- Parameters:
node (
Node
) – Node where to attach volumevolume (
StorageVolume
) – The ID of the volumedevice – Unused parameter
- Returns:
True or False representing operation successful
- Return type:
bool
- connectionCls¶
alias of
OvhConnection
- create_node(name, image, size, location, ex_keyname=None)[source]¶
Create a new node
- Parameters:
name (
str
) – Name of created nodeimage (
NodeImage
) – Image used for nodesize (
NodeSize
) – Size (flavor) used for nodelocation (
NodeLocation
) – Location (region) where to create nodeex_keyname (
str
) – Name of SSH key used
- Returns:
Created node
:rtype :
Node
- create_volume(size, name, location, snapshot=None, ex_volume_type='classic', ex_description=None)[source]¶
Create a volume.
- Parameters:
size (
int
) – Size of volume to create (in GB).name (
str
) – Name of volume to createlocation (
NodeLocation
orNone
) – Location to create the volume insnapshot (
VolumeSnapshot
) – Snapshot from which to create the new volume. (optional)ex_volume_type (
str
) –'classic'
or'high-speed'
ex_description (str) – Optional description of volume
- Returns:
Storage Volume object
- Return type:
StorageVolume
- create_volume_snapshot(volume, name=None, ex_description=None)[source]¶
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)
- Return type:
VolumeSnapshot
- delete_key_pair(key_pair)[source]¶
Delete an existing key pair.
- Parameters:
key_pair (
KeyPair
) – Key pair object.- Return type:
bool
- destroy_node(node)[source]¶
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)[source]¶
Destroys a storage volume.
- Parameters:
volume (
StorageVolume
) – Volume to be destroyed- Return type:
bool
- destroy_volume_snapshot(snapshot)[source]¶
Destroys a snapshot.
- Parameters:
snapshot (
VolumeSnapshot
) – The snapshot to delete- Return type:
- detach_volume(volume, ex_node=None)[source]¶
Detach a volume to a node.
- Parameters:
volume (
StorageVolume
) – The ID of the volumeex_node (
Node
) – Node to detach from (optional if volume is attached to only one node)
- Returns:
True or False representing operation successful
- Return type:
bool
- Raises:
Exception: If
ex_node
is not provided and more than one node is attached to the volume
- ex_get_node(node_id)[source]¶
Get a individual node.
- Parameters:
node_id (
str
) – Node’s ID- Returns:
Created node
:rtype :
Node
- ex_get_size(size_id)[source]¶
Get an individual size (flavor).
- Parameters:
size_id (
str
) – Size’s ID- Returns:
Size
- Return type:
NodeSize
- ex_get_volume(volume_id)[source]¶
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
- ex_get_volume_snapshot(snapshot_id)[source]¶
Returns a single volume snapshot.
- Parameters:
snapshot_id (
str
) – Node to run the task on.
:rtype
VolumeSnapshot
: :return: Volume snapshot.
- ex_list_snapshots(location=None)[source]¶
List all snapshots.
- Parameters:
location (
NodeLocation
orNone
) – Location used to filter- Return type:
list
ofVolumeSnapshot
- features: Dict[str, List[str]] = {'create_node': ['ssh_key']}¶
- List of available features for a driver.
libcloud.compute.base.NodeDriver.create_node()
ssh_key: Supports
NodeAuthSSHKey
as an authentication method for nodes.password: Supports
NodeAuthPassword
as an authentication method for nodes.generates_password: Returns a password attribute on the Node object returned from creation.
- get_image(image_id)[source]¶
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.
- Parameters:
name (
str
) – Name of the key pair to retrieve.ex_location (
NodeLocation
) – Key’s region
- Returns:
Public key
- Return type:
KeyPair
- import_key_pair_from_string(name, key_material, ex_location)[source]¶
Import a new public key from string.
- Parameters:
name (
str
) – Key pair name.key_material (
str
) – Public key material.ex_location (
NodeLocation
) – Location where to store the key
- Returns:
Imported key pair object.
- Return type:
KeyPair
- list_images(location=None, ex_size=None)[source]¶
List available images
- Parameters:
location (
NodeLocation
) – Location (region) used as filterex_size (
NodeImage
) – Exclude images which are incompatible with given size
- Returns:
List of images
:rtype :
list
ofNodeImage
- list_key_pairs(ex_location=None)[source]¶
List available SSH public keys.
- Parameters:
ex_location (
NodeLocation
) – Location (region) used as filter- Returns:
Public keys
- Return type:
``list``of
KeyPair
- list_locations()[source]¶
List data centers for a provider
- Returns:
list of node location objects
- Return type:
list
ofNodeLocation
- list_nodes(location=None)[source]¶
List all nodes.
- Parameters:
location (
NodeLocation
) – Location (region) used as filter- Returns:
List of node objects
- Return type:
list
ofNode
- list_sizes(location=None)[source]¶
List sizes on a provider
- Parameters:
location (
NodeLocation
) – The location at which to list sizes- Returns:
list of node size objects
- Return type:
list
ofNodeSize
- list_volume_snapshots(volume)[source]¶
List snapshots for a storage volume.
- Return type:
list
ofVolumeSnapshot