RunAbove Compute Driver Documentation¶
RunAbove is a public cloud offer created by OVH Group with datacenters in North America and Europe.
RunAbove driver uses the OVH/RunAbove API so for more information about that, please refer to RunAbove knowledge base page and API console.
Instantiating a driver¶
When you instantiate a driver you need to pass the following arguments to the driver constructor:
key- Application keysecret- Application secretex_consumer_key- Consumer key
For get application key and secret, you must first register an application at https://api.runabove.com/createApp/. Next step, create a consumer key with following command:
curl -X POST \
-H 'X-Ra-Application: youApplicationKey' \
-H 'Content-Type: application/json' \
-d '{
"accessRules":
[
{"method":"GET","path":"/*"},
{"method":"POST","path":"/*"},
{"method":"DELETE","path":"/*"},
{"method":"PUT","path":"/*"},
],
"redirection":"http://runabove.com"
}' \
"https://api.runabove.com/1.0/auth/credential"
This will answer a JSON like below with inside your Consumer Key and
validationUrl. Follow this link for valid your key.
{
"validationUrl":"https://api.runabove.com/login/?credentialToken=fIDK6KCVHfEMuSTP3LV84D3CsHTq4T3BhOrmEEdd2hQ0CNcfVgGVWZRqIlolDJ3W",
"consumerKey":"y7epYeHCIqoO17BzBgxluvB4XLedpba9",
"state":"pendingValidation"
}
Now you have and can use you credentials with Libcloud.
Examples¶
Create node¶
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
RunAbove = get_driver(Provider.RUNABOVE)
driver = RunAbove('yourAppKey', 'yourAppSecret', 'YourConsumerKey')
image = [i for i in driver.list_images() if 'Debian 8' == i.name][0]
size = [s for s in driver.list_sizes() if s.name == 'ra.s'][0]
location = [l for l in driver.list_locations() if l.id == 'SBG-1'][0]
node = driver.create_node(name='yournode', size=size, image=image,
location=location)
Create and attach a volume to a node¶
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
RunAbove = get_driver(Provider.RUNABOVE)
driver = RunAbove('yourAppKey', 'yourAppSecret', 'YourConsumerKey')
location = [l for l in driver.list_locations() if l.id == 'SBG-1'][0]
node = driver.list_nodes()[0]
volume = driver.create_volume(size=10, location=location)
driver.attach_volume(node=node, volume=volume)
API Docs¶
-
class
libcloud.compute.drivers.runabove.RunAboveNodeDriver(key, secret, ex_consumer_key=None)[source]¶ Libcloud driver for the RunAbove API
For more information on the RunAbove 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_consumer_key (
str) – Your consumer key (required)
Return type: None-
attach_volume(node, volume, device=None)[source]¶ Attach a volume to a node.
Parameters: - node (
Node) – Node where to attach volume - volume (
StorageVolume) – The ID of the volume - device – Unsed parameter
Returns: True or False representing operation successful
Return type: bool- node (
-
connectionCls¶ alias of
RunAboveConnection
-
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: Returns: NodeImage instance on success.
- source_region (
-
create_image(node, name, description=None)¶ Creates an image from a node object.
Parameters: - node (
Node) – Node to run the task on. - name (
description) – name for new image. - description – description for new image.
Return type: Returns: NodeImage instance on success.
- node (
-
create_key_pair(name)¶ Create a new key pair object.
Parameters: name ( str) – Key pair name.
-
create_node(name, image, size, location, ex_keyname=None)[source]¶ Create a new node
Parameters: - 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
Retunrs: Created node
:rtype :
Node- name (
-
create_volume(size, location, name=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 create - location (
NodeLocationorNone) – Location to create the volume in - ex_volume_type (
str) –'classic'or'high-speed' - ex_description (str) – Optionnal description of volume
Returns: Storage Volume object
Return type: StorageVolume- size (
-
create_volume_snapshot(volume, name=None)¶ Creates a snapshot of the storage volume.
Parameters: - volume (
VolumeSnapshot) – The StorageVolume to create a VolumeSnapshot from - name (str) – Name of created snapshot (optional)
Return type: VolumeSnapshot- volume (
-
delete_image(node_image)¶ Deletes a node image from a provider.
Parameters: node_image ( NodeImage) – Node image object.Returns: Trueif delete_image was successful,Falseotherwise.Return type: bool
-
delete_key_pair(name, location)[source]¶ Delete an existing key pair.
Parameters: - name (
str) – Key pair name. - location (
NodeLocation) – Key’s region
Returns: True of False based on success of Keypair deletion
Return type: bool- name (
-
deploy_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
NodeAuthPasswordorNodeAuthSSHKeyto theauthargument. If thecreate_nodeimplementation supports that kind if credential (as declared inself.features['create_node']) then it is passed on tocreate_node. Otherwise it is not passed on tocreate_nodeand it is only used for authentication.If the
authparameter is not supplied but the driver declares it supportsgenerates_passwordthen the password returned bycreate_nodewill be used to SSH into the server.Finally, if the
ssh_key_fileis 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 (
NodeAuthSSHKeyorNodeAuthPassword) – Initial authentication information for the node (optional) - ssh_key (
strorlistofstr) – 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’.
- deploy (
-
destroy_volume_snapshot(snapshot)¶ Destroys a snapshot.
Parameters: snapshot ( VolumeSnapshot) – The snapshot to deleteReturn type: bool
-
detach_volume(volume, ex_node=None)[source]¶ Detach a volume to a node.
Parameters: - volume (
StorageVolume) – The ID of the volume - ex_node (
Node) – Node to detach from (optionnal if volume is attached to only one node)
Returns: True or False representing operation successful
Return type: boolRaises: Exception: If
ex_nodeis not provided and more than one node is attached to the volume- volume (
-
ex_get_node(node_id)[source]¶ Get a individual node.
Parameters: node_id ( str) – Node’s IDReturns: Created node :rtype :
Node
-
ex_get_size(size_id)[source]¶ Get an individual size (flavor).
Parameters: size_id ( str) – Size’s IDReturns: 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 volumeReturns: A StorageVolume object for the volume Return type: StorageVolume
-
get_key_pair(name, location)[source]¶ Get an individual SSH public key by its name and location.
Parameters: - name (str) – SSH key name
- location (
NodeLocation) – Key’s region
Returns: Public key
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: KeyPairobject- name (
-
import_key_pair_from_string(name, key_material, location)[source]¶ Import a new public key from string.
Parameters: - name (
str) – Key pair name. - key_material (
str) – Public key material.
Returns: Imported key pair object.
Return type: KeyPair- name (
-
list_images(location=None, ex_size=None)[source]¶ List available images
Parameters: - location (
NodeLocation) – Location (region) used as filter - ex_size (
NodeImage) – Exclude images which are uncompatible with given size
Returns: List of images
:rtype :
listofNodeImage- location (
-
list_key_pairs(location=None)[source]¶ List available SSH public keys.
Parameters: location ( NodeLocation) – Location (region) used as filterReturns: Public keys Return type: ``list``of KeyPair
-
list_nodes(location=None)[source]¶ List all nodes.
Parameters: location ( NodeLocation) – Location (region) used as filterReturns: List of node objects Return type: listofNode
-
list_volume_snapshots(volume)¶ List snapshots for a storage volume.
Return type: listofVolumeSnapshot
-
list_volumes(location=None)[source]¶ Return a list of volumes.
Parameters: location ( NodeLocationorNone) – Location use for filterReturns: A list of volume objects. Return type: listofStorageVolume
-
reboot_node(node)¶ Reboot a node.
Parameters: node ( Node) – The node to be rebootedReturns: True if the reboot 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 (
listofNode) – 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 thelist_nodesmethod.
Returns: [(Node, ip_addresses)]list of tuple of Node instance and list of ip_address on success.Return type: listoftuple- nodes (
- key (
