Rackspace Compute Driver Documentation

Rackspace is a public and private cloud provider based in San Antonio, Texas with datacenters in United States, United Kingdom, China and Australia.

Rackspace driver supports working with legacy, first-gen cloud servers and next-gen OpenStack based cloud servers. Driver is based on the OpenStack so for more informsa

Rackspace 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

Examples

1. Working with ‘performance’ cloud server flavors

Rackspace recently annouced new ‘perfomance’ flavors of their cloud servers. The example bellow shows how to use this new flavors.

Keep in mind that this new flavors are currently only supported in the following regions: iad, ord, lon.

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

cls = get_driver(Provider.RACKSPACE)
driver = cls('username', 'api key', region='iad')

sizes = driver.list_sizes()

performance_sizes = [size for size in sizes if 'performance' in size.id]

for size in performance_sizes:
    print(size)

API Docs

class libcloud.compute.drivers.rackspace.RackspaceNodeDriver(key, secret=None, secure=True, host=None, port=None, region='dfw', **kwargs)[source]

@inherits: NodeDriver.__init__

Parameters:region (str) – ID of the region which should be used.
connectionCls

alias of RackspaceConnection

create_node(**kwargs)

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_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 no de
  • networks (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.
create_volume_snapshot(volume, name)

Creates a snapshot of the storage volume.

Return type:VolumeSnapshot
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 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 availble 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_volume_snapshot(snapshot)

Destroys a snapshot.

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_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_delete_image(image)

Delete a NodeImage

Parameters:image (NodeImage) – image witch should be used
Return type:bool
ex_delete_keypair(keypair)

Delete a KeyPair.

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

Get a list of NodeNetorks that are available.

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_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_image(image_id)

Get a NodeImage

Parameters:image_id (str) – ID of the image which should be used
Return type:NodeImage
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_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 no de
  • 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.
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_save_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

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

list_images(location=None, ex_only_active=True)

@inherits: NodeDriver.list_images

Parameters:ex_only_active (bool) – True if list only active
list_volume_snapshots(volume)

List snapshots for a storage volume.

Return type:list of VolumeSnapshot
openstack_connection_kwargs()
Return type:dict
wait_until_running(nodes, wait_period=3, timeout=600, ssh_interface='public_ips', force_ipv4=True)

Block until the given nodes are fully booted and have an IP address assigned.

Parameters:
  • nodes (List of Node) – list of node instances.
  • wait_period (int) – How many seconds to between each loop iteration (default is 3)
  • timeout (int) – How many seconds to wait before timing out (default is 600)
  • ssh_interface (str) – The interface to wait for. Default is ‘public_ips’, other option is ‘private_ips’.
  • force_ipv4 (bool) – Ignore ipv6 IP addresses (default is True).
Returns:

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

Return type:

list of tuple

class libcloud.compute.drivers.rackspace.RackspaceFirstGenNodeDriver(key, secret=None, secure=True, host=None, port=None, region='us', **kwargs)[source]

@inherits: NodeDriver.__init__

Parameters:region (str) – Region ID which should be used
connectionCls

alias of RackspaceFirstGenConnection

create_node(**kwargs)

Create a new node

@inherits: NodeDriver.create_node

Parameters:
  • ex_metadata (dict) – Key/Value metadata to associate with a node
  • ex_files (dict) – File Path => File contents to create on the node
  • ex_shared_ip_group_id (str) – The server is launched into that shared IP group
create_volume_snapshot(volume, name)

Creates a snapshot of the storage volume.

Return type:VolumeSnapshot
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 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 availble 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_volume_snapshot(snapshot)

Destroys a snapshot.

Return type:bool
ex_confirm_resize(node)

Confirm a resize request which is currently in progress. If a resize request is not explicitly confirmed or reverted it’s automatically confirmed after 24 hours.

For more info refer to the API documentation: http://goo.gl/zjFI1

Parameters:node (Node) – node for which the resize request will be confirmed.
Return type:bool
ex_create_ip_group(group_name, node_id=None)

Creates a shared IP group.

Parameters:
  • group_name (str) – group name which should be used
  • node_id (str) – ID of the node which should be used
Return type:

bool

ex_delete_image(image)

Delete an image for node.

Parameters:image (NodeImage) – the image to be deleted
Return type:bool
ex_delete_ip_group(group_id)

Deletes the specified shared IP group.

Parameters:group_id (str) – group id which should be used
Return type:bool
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_hard_reboot_node(node)

Hard reboots the specified server

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

Extra call to get account’s limits, such as rates (for example amount of POST requests per day) and absolute limits like total amount of available RAM to be used by servers.

Returns:dict with keys ‘rate’ and ‘absolute’
Return type:dict
ex_list_ip_addresses(node_id)

List all server addresses.

Parameters:node_id (str) – ID of the node which should be used
Return type:OpenStack_1_0_NodeIpAddresses
ex_list_ip_groups(details=False)

Lists IDs and names for shared IP groups. If details lists all details for shared IP groups.

Parameters:details (bool) – True if details is required
Return type:list of OpenStack_1_0_SharedIpGroup
ex_rebuild(node_id, image_id)

Rebuilds the specified server.

Parameters:
  • node_id (str) – ID of the node which should be used
  • image_id (str) – ID of the image which should be used
Return type:

bool

ex_resize(node, size)

Change an existing server flavor / scale the server up or down.

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

bool

ex_revert_resize(node)

Revert a resize request which is currently in progress. All resizes are automatically confirmed after 24 hours if they have not already been confirmed explicitly or reverted.

For more info refer to the API documentation: http://goo.gl/AizBu

Parameters:node (Node) – node for which the resize request will be reverted.
Return type:bool
ex_save_image(node, name)

Create an image for node.

Parameters:
  • node (Node) – node to use as a base for image
  • name (str) – name for new image
Return type:

NodeImage

ex_set_password(node, password)

Sets the Node’s root password.

This will reboot the instance to complete the operation.

Node.extra['password'] will be set to the new value if the operation was successful.

Parameters:
  • node (Node) – node to set password
  • password (str) – new password.
Return type:

bool

ex_set_server_name(node, name)

Sets the Node’s name.

This will reboot the instance to complete the operation.

Parameters:
  • node (Node) – node to set name
  • name (str) – new name
Return type:

bool

ex_share_ip(group_id, node_id, ip, configure_node=True)

Shares an IP address to the specified server.

Parameters:
  • group_id (str) – group id which should be used
  • node_id (str) – ID of the node which should be used
  • ip (str) – ip which should be used
  • configure_node (bool) – configure node
Return type:

bool

ex_soft_reboot_node(node)

Soft reboots the specified server

Parameters:node (Node) – node
Return type:bool
ex_unshare_ip(node_id, ip)

Removes a shared IP address from the specified server.

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

bool

list_images(location=None, ex_only_active=True)

@inherits: NodeDriver.list_images

Parameters:ex_only_active (bool) – True if list only active
list_locations()[source]

Lists available locations

Locations cannot be set or retrieved via the API, but currently there are two locations, DFW and ORD.

@inherits: OpenStack_1_0_NodeDriver.list_locations

list_volume_snapshots(volume)

List snapshots for a storage volume.

Return type:list of VolumeSnapshot
openstack_connection_kwargs()
Return type:dict
wait_until_running(nodes, wait_period=3, timeout=600, ssh_interface='public_ips', force_ipv4=True)

Block until the given nodes are fully booted and have an IP address assigned.

Parameters:
  • nodes (List of Node) – list of node instances.
  • wait_period (int) – How many seconds to between each loop iteration (default is 3)
  • timeout (int) – How many seconds to wait before timing out (default is 600)
  • ssh_interface (str) – The interface to wait for. Default is ‘public_ips’, other option is ‘private_ips’.
  • force_ipv4 (bool) – Ignore ipv6 IP addresses (default is True).
Returns:

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

Return type:

list of tuple