libcloud.compute package¶
Subpackages¶
- libcloud.compute.drivers package
- Submodules
- libcloud.compute.drivers.abiquo module
- libcloud.compute.drivers.auroracompute module
- libcloud.compute.drivers.azure module
- libcloud.compute.drivers.bluebox module
- libcloud.compute.drivers.brightbox module
- libcloud.compute.drivers.cloudframes module
- libcloud.compute.drivers.cloudsigma module
- libcloud.compute.drivers.cloudstack module
- libcloud.compute.drivers.cloudwatt module
- libcloud.compute.drivers.digitalocean module
- libcloud.compute.drivers.dimensiondata module
- libcloud.compute.drivers.dreamhost module
- libcloud.compute.drivers.dummy module
- libcloud.compute.drivers.ec2 module
- libcloud.compute.drivers.ecp module
- libcloud.compute.drivers.elastichosts module
- libcloud.compute.drivers.elasticstack module
- libcloud.compute.drivers.exoscale module
- libcloud.compute.drivers.gandi module
- libcloud.compute.drivers.gce module
- libcloud.compute.drivers.gogrid module
- libcloud.compute.drivers.gridspot module
- libcloud.compute.drivers.hostvirtual module
- libcloud.compute.drivers.hpcloud module
- libcloud.compute.drivers.ibm_sce module
- libcloud.compute.drivers.ikoula module
- libcloud.compute.drivers.joyent module
- libcloud.compute.drivers.kili module
- libcloud.compute.drivers.ktucloud module
- libcloud.compute.drivers.libvirt_driver module
- libcloud.compute.drivers.linode module
- libcloud.compute.drivers.nephoscale module
- libcloud.compute.drivers.ninefold module
- libcloud.compute.drivers.onapp module
- libcloud.compute.drivers.opennebula module
- libcloud.compute.drivers.openstack module
- libcloud.compute.drivers.opsource module
- libcloud.compute.drivers.packet module
- libcloud.compute.drivers.profitbricks module
- libcloud.compute.drivers.rackspace module
- libcloud.compute.drivers.rimuhosting module
- libcloud.compute.drivers.runabove module
- libcloud.compute.drivers.serverlove module
- libcloud.compute.drivers.skalicloud module
- libcloud.compute.drivers.softlayer module
- libcloud.compute.drivers.vcl module
- libcloud.compute.drivers.vcloud module
- libcloud.compute.drivers.voxel module
- libcloud.compute.drivers.vpsnet module
- libcloud.compute.drivers.vsphere module
- libcloud.compute.drivers.vultr module
- Module contents
Submodules¶
libcloud.compute.base module¶
Provides base classes for working with drivers
-
class
libcloud.compute.base.
Node
(id, name, state, public_ips, private_ips, driver, size=None, image=None, extra=None)[source]¶ Bases:
libcloud.compute.base.UuidMixin
Provide a common interface for handling nodes of all types.
The Node object provides the interface in libcloud through which we can manipulate nodes in different cloud providers in the same way. Node objects don’t actually do much directly themselves, instead the node driver handles the connection to the node.
You don’t normally create a node object yourself; instead you use a driver and then have that create the node for you.
>>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> node = driver.create_node() >>> node.public_ips[0] '127.0.0.3' >>> node.name 'dummy-3'
You can also get nodes from the driver’s list_node function.
>>> node = driver.list_nodes()[0] >>> node.name 'dummy-1'
The node keeps a reference to its own driver which means that we can work on nodes from different providers without having to know which is which.
>>> driver = DummyNodeDriver(72) >>> node2 = driver.create_node() >>> node.driver.creds 0 >>> node2.driver.creds 72
Although Node objects can be subclassed, this isn’t normally done. Instead, any driver specific information is stored in the “extra” attribute of the node.
>>> node.extra {'foo': 'bar'}
Parameters: - id (
str
) – Node ID. - name (
str
) – Node name. - state (
libcloud.compute.types.NodeState
) – Node state. - public_ips (
list
) – Public IP addresses associated with this node. - private_ips (
list
) – Private IP addresses associated with this node. - driver (
NodeDriver
) – Driver this node belongs to. - size (
NodeImage
) – Size of this node. (optional) - image – Image of this node. (optional)
- extra (
dict
) – Optional provider specific attributes associated with this node.
-
destroy
()[source]¶ Destroy this node
Returns: bool
This calls the node’s driver and destroys the node
>>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> from libcloud.compute.types import NodeState >>> node = driver.create_node() >>> node.state == NodeState.RUNNING True >>> node.destroy() True >>> node.state == NodeState.RUNNING False
-
reboot
()[source]¶ Reboot this node
Returns: bool
This calls the node’s driver and reboots the node
>>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> node = driver.create_node() >>> node.state == NodeState.RUNNING True >>> node.state == NodeState.REBOOTING False >>> node.reboot() True >>> node.state == NodeState.REBOOTING True
- id (
-
class
libcloud.compute.base.
NodeState
[source]¶ Bases:
object
Standard states for a node
Variables: - RUNNING – Node is running.
- REBOOTING – Node is rebooting.
- TERMINATED – Node is terminated. This node can’t be started later on.
- STOPPED – Node is stopped. This node can be started later on.
- PENDING – Node is pending.
- STOPPED – Node is stopped.
- SUSPENDED – Node is suspended.
- ERROR – Node is an error state. Usually no operations can be performed on the node once it ends up in the error state.
- PAUSED – Node is paused.
- UNKNOWN – Node state is unknown.
-
ERROR
= 7¶
-
PAUSED
= 8¶
-
PENDING
= 3¶
-
REBOOTING
= 1¶
-
RUNNING
= 0¶
-
STOPPED
= 5¶
-
SUSPENDED
= 6¶
-
TERMINATED
= 2¶
-
UNKNOWN
= 4¶
-
class
libcloud.compute.base.
NodeSize
(id, name, ram, disk, bandwidth, price, driver, extra=None)[source]¶ Bases:
libcloud.compute.base.UuidMixin
A Base NodeSize class to derive from.
NodeSizes are objects which are typically returned a driver’s list_sizes function. They contain a number of different parameters which define how big an image is.
The exact parameters available depends on the provider.
N.B. Where a parameter is “unlimited” (for example bandwidth in Amazon) this will be given as 0.
>>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> size = driver.list_sizes()[0] >>> size.ram 128 >>> size.bandwidth 500 >>> size.price 4
Parameters: - id (
str
) – Size ID. - name (
str
) – Size name. - ram (
int
) – Amount of memory (in MB) provided by this size. - disk (
int
) – Amount of disk storage (in GB) provided by this image. - bandwidth (
int
) – Amount of bandiwdth included with this size. - price (
float
) – Price (in US dollars) of running this node for an hour. - driver (
NodeDriver
) – Driver this size belongs to. - extra (
dict
) – Optional provider specific attributes associated with this size.
- id (
-
class
libcloud.compute.base.
NodeImage
(id, name, driver, extra=None)[source]¶ Bases:
libcloud.compute.base.UuidMixin
An operating system image.
NodeImage objects are typically returned by the driver for the cloud provider in response to the list_images function
>>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> image = driver.list_images()[0] >>> image.name 'Ubuntu 9.10'
Apart from name and id, there is no further standard information; other parameters are stored in a driver specific “extra” variable
When creating a node, a node image should be given as an argument to the create_node function to decide which OS image to use.
>>> node = driver.create_node(image=image)
Parameters: - id (
str
) – Image ID. - name (
str
) – Image name. - driver (
NodeDriver
) – Driver this image belongs to. - extra (
dict
) – Optional provided specific attributes associated with this image.
- id (
-
class
libcloud.compute.base.
NodeLocation
(id, name, country, driver)[source]¶ Bases:
object
A physical location where nodes can be.
>>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> location = driver.list_locations()[0] >>> location.country 'US'
Parameters: - id (
str
) – Location ID. - name (
str
) – Location name. - country (
str
) – Location country. - driver (
NodeDriver
) – Driver this location belongs to.
- id (
-
class
libcloud.compute.base.
NodeAuthSSHKey
(pubkey)[source]¶ Bases:
object
An SSH key to be installed for authentication to a node.
This is the actual contents of the users ssh public key which will normally be installed as root’s public key on the node.
>>> pubkey = '...' # read from file >>> from libcloud.compute.base import NodeAuthSSHKey >>> k = NodeAuthSSHKey(pubkey) >>> k <NodeAuthSSHKey>
Parameters: pubkey ( str
) – Public key matetiral.
-
class
libcloud.compute.base.
NodeAuthPassword
(password, generated=False)[source]¶ Bases:
object
A password to be used for authentication to a node.
Parameters: password ( str
) – Password.
-
class
libcloud.compute.base.
NodeDriver
(key, secret=None, secure=True, host=None, port=None, api_version=None, **kwargs)[source]¶ Bases:
libcloud.common.base.BaseDriver
A base NodeDriver class to derive from
This class is always subclassed by a specific driver. For examples of base behavior of most functions (except deploy node) see the dummy driver.
-
NODE_STATE_MAP
= {}¶
-
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
- node (
-
connectionCls
¶ alias of
ConnectionKey
-
copy_image
(source_region, node_image, name, description=None)[source]¶ 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)[source]¶ 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_node
(**kwargs)[source]¶ Create a new node instance. This instance will be started automatically.
Not all hosting API’s are created equal and to allow libcloud to support as many as possible there are some standard supported variations of
create_node
. These are declared using afeatures
API. You can inspectdriver.features['create_node']
to see what variation of the API you are dealing with:ssh_key
- You can inject a public key into a new node allows key based SSH authentication.
password
- You can inject a password into a new node for SSH authentication.
If no password is provided libcloud will generated a password.
The password will be available as
return_value.extra['password']
. generates_password
- The hosting provider will generate a password. It will be returned
to you via
return_value.extra['password']
.
Some drivers allow you to set how you will authenticate with the instance that is created. You can inject this initial authentication information via the
auth
parameter.If a driver supports the
ssh_key
feature flag forcreated_node
you can upload a public key into the new instance:>>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> auth = NodeAuthSSHKey('pubkey data here') >>> node = driver.create_node("test_node", auth=auth)
If a driver supports the
password
feature flag forcreate_node
you can set a password:>>> driver = DummyNodeDriver(0) >>> auth = NodeAuthPassword('mysecretpassword') >>> node = driver.create_node("test_node", auth=auth)
If a driver supports the
password
feature and you don’t provide theauth
argument libcloud will assign a password:>>> driver = DummyNodeDriver(0) >>> node = driver.create_node("test_node") >>> password = node.extra['password']
A password will also be returned in this way for drivers that declare the
generates_password
feature, though in that case the password is actually provided to the driver API by the hosting provider rather than generated by libcloud.You can only pass a
NodeAuthPassword
orNodeAuthSSHKey
tocreate_node
via the auth parameter if has the corresponding feature flag.Parameters: - name (
str
) – String with a name for this new node (required) - size (
NodeSize
) – The size of resources allocated to this node. (required) - image (
NodeImage
) – OS Image to boot on node. (required) - location (
NodeLocation
) – Which data center to create a node in. If empty, undefined behavior will be selected. (optional) - auth (
NodeAuthSSHKey
orNodeAuthPassword
) – Initial authentication information for the node (optional)
Returns: The newly created node.
Return type:
-
create_volume
(size, name, location=None, snapshot=None)[source]¶ 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)
Returns: The newly created volume.
Return type: - size (
-
create_volume_snapshot
(volume, name=None)[source]¶ 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: - volume (
-
delete_image
(node_image)[source]¶ 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_key_pair
(key_pair)[source]¶ Delete an existing key pair.
Parameters: key_pair ( KeyPair
) – Key pair object.
-
deploy_node
(**kwargs)[source]¶ 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
orNodeAuthSSHKey
to theauth
argument. If thecreate_node
implementation 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_node
and it is only used for authentication.If the
auth
parameter is not supplied but the driver declares it supportsgenerates_password
then the password returned bycreate_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
orNodeAuthPassword
) – Initial authentication information for the node (optional) - ssh_key (
str
orlist
ofstr
) – 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_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 destroyedReturns: 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 destroyedReturn type: bool
-
destroy_volume_snapshot
(snapshot)[source]¶ Destroys a snapshot.
Parameters: snapshot ( VolumeSnapshot
) – The snapshot to deleteReturn type: bool
-
detach_volume
(volume)[source]¶ Detaches a volume from a node.
Parameters: volume ( StorageVolume
) – Volume to be detachedReturn type: bool
-
features
= {'create_node': []}¶ - 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.
- ssh_key: Supports
-
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)[source]¶ 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)[source]¶ 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- name (
-
import_key_pair_from_string
(name, key_material)[source]¶ Import a new public key from string.
Parameters: - name (
str
) – Key pair name. - key_material (
str
) – Public key material.
Return type: KeyPair
object- name (
-
list_images
(location=None)[source]¶ List images on a provider.
Parameters: location ( NodeLocation
) – The location at which to list images.Returns: list of node image objects. Return type: list
ofNodeImage
-
list_key_pairs
()[source]¶ List all the available key pair objects.
Return type: list
ofKeyPair
objects
-
list_locations
()[source]¶ List data centers for a provider
Returns: list of node location objects Return type: list
ofNodeLocation
-
list_sizes
(location=None)[source]¶ List sizes on a provider
Parameters: location ( NodeLocation
) – The location at which to list sizesReturns: list of node size objects Return type: list
ofNodeSize
-
list_volume_snapshots
(volume)[source]¶ List snapshots for a storage volume.
Return type: list
ofVolumeSnapshot
-
list_volumes
()[source]¶ List storage volumes.
Return type: list
ofStorageVolume
-
name
= None¶
-
port
= None¶
-
reboot_node
(node)[source]¶ Reboot a node.
Parameters: node ( Node
) – The node to be rebootedReturns: True if the reboot was successful, otherwise False Return type: bool
-
type
= None¶
-
wait_until_running
(nodes, wait_period=3, timeout=600, ssh_interface='public_ips', force_ipv4=True, ex_list_nodes_kwargs=None)[source]¶ 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
ofNode
) – 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_nodes
method.
Returns: [(Node, ip_addresses)]
list of tuple of Node instance and list of ip_address on success.Return type: list
oftuple
- nodes (
-
-
class
libcloud.compute.base.
StorageVolume
(id, name, size, driver, state=None, extra=None)[source]¶ Bases:
libcloud.compute.base.UuidMixin
A base StorageVolume class to derive from.
Parameters: - id (
str
) – Storage volume ID. - name (
str
) – Storage volume name. - size (
int
) – Size of this volume (in GB). - driver (
NodeDriver
) – Driver this image belongs to. - state (
StorageVolumeState
) – Optional state of the StorageVolume. If not provided, will default to UNKNOWN. - extra (
dict
) – Optional provider specific attributes.
-
attach
(node, device=None)[source]¶ Attach this volume to a node.
Parameters: - node (
Node
) – Node to attach volume to - device (
str
) – Where the device is exposed, e.g. ‘/dev/sdb (optional)
Returns: True
if attach was successful,False
otherwise.Return type: bool
- node (
-
destroy
()[source]¶ Destroy this storage volume.
Returns: True
if destroy was successful,False
otherwise.Return type: bool
- id (
-
class
libcloud.compute.base.
StorageVolumeState
[source]¶ Bases:
object
Standard states of a StorageVolume
-
ATTACHING
= 7¶
-
AVAILABLE
= 0¶
-
BACKUP
= 6¶
-
CREATING
= 3¶
-
DELETED
= 5¶
-
DELETING
= 4¶
-
ERROR
= 1¶
-
INUSE
= 2¶
-
UNKNOWN
= 8¶
-
-
class
libcloud.compute.base.
VolumeSnapshot
(id, driver, size=None, extra=None, created=None)[source]¶ Bases:
object
A base VolumeSnapshot class to derive from.
VolumeSnapshot constructor.
Parameters: - id (
str
) – Snapshot ID. - driver (NodeDriver) – The driver that represents a connection to the provider
- size (
int
) – A snapshot size in GB. - extra (
dict
) – Provider depends parameters for snapshot. - created (
datetime.datetime
) – A datetime object that represents when the snapshot was created
- id (
-
libcloud.compute.base.
is_private_subnet
(ip)[source]¶ Utility function to check if an IP address is inside a private subnet.
Parameters: ip ( str
) – IP address to checkReturns: bool
if the specified IP address is private.
-
libcloud.compute.base.
is_valid_ip_address
(address, family=2)[source]¶ Check if the provided address is valid IPv4 or IPv6 address.
Parameters: - address (
str
) – IPv4 or IPv6 ddress to check. - family (
int
) – Address family (socket.AF_INTET / socket.AF_INET6).
Returns: bool
True if the provided address is valid.- address (
libcloud.compute.deployment module¶
Provides generic deployment steps for machines post boot.
-
class
libcloud.compute.deployment.
Deployment
[source]¶ Bases:
object
Base class for deployment tasks.
-
class
libcloud.compute.deployment.
FileDeployment
(source, target)[source]¶ Bases:
libcloud.compute.deployment.Deployment
Installs a file on the server.
Parameters: - source (
str
) – Local path of file to be installed - target (
str
) – Path to install file on node
-
run
(node, client)[source]¶ Upload the file, retaining permissions.
See also
Deployment.run
- source (
-
class
libcloud.compute.deployment.
MultiStepDeployment
(add=None)[source]¶ Bases:
libcloud.compute.deployment.Deployment
Runs a chain of Deployment steps.
Parameters: add ( list
) – Deployment steps to add.-
add
(add)[source]¶ Add a deployment to this chain.
Parameters: add (Single Deployment
or alist
ofDeployment
) – Adds this deployment to the others already in thisobject.
-
run
(node, client)[source]¶ Run each deployment that has been added.
See also
Deployment.run
-
-
class
libcloud.compute.deployment.
SSHKeyDeployment
(key)[source]¶ Bases:
libcloud.compute.deployment.Deployment
Installs a public SSH Key onto a server.
Parameters: key ( str
orFile
object) – Contents of the public key write or a file object which can be read.-
run
(node, client)[source]¶ Installs SSH key into
.ssh/authorized_keys
See also
Deployment.run
-
-
class
libcloud.compute.deployment.
ScriptDeployment
(script, args=None, name=None, delete=False)[source]¶ Bases:
libcloud.compute.deployment.Deployment
Runs an arbitrary shell script on the server.
This step works by first writing the content of the shell script (script argument) in a *.sh file on a remote server and then running that file.
If you are running a non-shell script, make sure to put the appropriate shebang to the top of the script. You are also advised to do that even if you are running a plan shell script.
Parameters: - script (
str
) – Contents of the script to run. - args (
list
) – Optional command line arguments which get passed to the deployment script file. - name (
str
) – Name of the script to upload it as, if not specified, a random name will be chosen. - delete (
bool
) – Whether to delete the script on completion.
-
run
(node, client)[source]¶ Uploads the shell script and then executes it.
See also
Deployment.run
- script (
-
class
libcloud.compute.deployment.
ScriptFileDeployment
(script_file, args=None, name=None, delete=False)[source]¶ Bases:
libcloud.compute.deployment.ScriptDeployment
Runs an arbitrary shell script from a local file on the server. Same as ScriptDeployment, except that you can pass in a path to the file instead of the script content.
Parameters: - script_file (
str
) – Path to a file containing the script to run. - args (
list
) – Optional command line arguments which get passed to the deployment script file. - name (
str
) – Name of the script to upload it as, if not specified, a random name will be chosen. - delete (
bool
) – Whether to delete the script on completion.
- script_file (
libcloud.compute.providers module¶
Provider related utilities
-
class
libcloud.compute.providers.
Provider
[source]¶ Bases:
object
Defines for each of the supported providers
Variables: - DUMMY – Example provider
- EC2_US_EAST – Amazon AWS US N. Virgina
- EC2_US_WEST – Amazon AWS US N. California
- EC2_EU_WEST – Amazon AWS EU Ireland
- RACKSPACE – Rackspace next-gen OpenStack based Cloud Servers
- RACKSPACE_FIRST_GEN – Rackspace First Gen Cloud Servers
- GCE – Google Compute Engine
- GOGRID – GoGrid
- VPSNET – VPS.net
- LINODE – Linode.com
- VCLOUD – vmware vCloud
- RIMUHOSTING – RimuHosting.com
- ECP – Enomaly
- IBM – IBM Developer Cloud
- OPENNEBULA – OpenNebula.org
- DREAMHOST – DreamHost Private Server
- ELASTICHOSTS – ElasticHosts.com
- CLOUDSIGMA – CloudSigma
- NIMBUS – Nimbus
- BLUEBOX – Bluebox
- OPSOURCE – Opsource Cloud
- DIMENSIONDATA – Dimension Data Cloud
- NINEFOLD – Ninefold
- TERREMARK – Terremark
- EC2_US_WEST_OREGON – Amazon AWS US West 2 (Oregon)
- CLOUDSTACK – CloudStack
- CLOUDSIGMA_US – CloudSigma US Las Vegas
- LIBVIRT – Libvirt driver
- JOYENT – Joyent driver
- VCL – VCL driver
- KTUCLOUD – kt ucloud driver
- GRIDSPOT – Gridspot driver
- ABIQUO – Abiquo driver
- NEPHOSCALE – NephoScale driver
- EXOSCALE – Exoscale driver.
- IKOULA – Ikoula driver.
- OUTSCALE_SAS – Outscale SAS driver.
- OUTSCALE_INC – Outscale INC driver.
- PROFIT_BRICKS – ProfitBricks driver.
- VULTR – vultr driver.
- AZURE – Azure driver.
- AURORACOMPUTE – Aurora Compute driver.
-
ABIQUO
= 'abiquo'¶
-
AURORACOMPUTE
= 'aurora_compute'¶
-
AZURE
= 'azure'¶
-
BLUEBOX
= 'bluebox'¶
-
BRIGHTBOX
= 'brightbox'¶
-
CLOUDFRAMES
= 'cloudframes'¶
-
CLOUDSIGMA
= 'cloudsigma'¶
-
CLOUDSIGMA_US
= 'cloudsigma_us'¶
-
CLOUDSTACK
= 'cloudstack'¶
-
CLOUDWATT
= 'cloudwatt'¶
-
DIGITAL_OCEAN
= 'digitalocean'¶
-
DIMENSIONDATA
= 'dimensiondata'¶
-
DREAMHOST
= 'dreamhost'¶
-
DUMMY
= 'dummy'¶
-
EC2
= 'ec2_us_east'¶
-
EC2_AP_NORTHEAST
= 'ec2_ap_northeast'¶
-
EC2_AP_SOUTHEAST
= 'ec2_ap_southeast'¶
-
EC2_AP_SOUTHEAST2
= 'ec2_ap_southeast_2'¶
-
EC2_EU
= 'ec2_eu_west'¶
-
EC2_EU_WEST
= 'ec2_eu_west'¶
-
EC2_SA_EAST
= 'ec2_sa_east'¶
-
EC2_US_EAST
= 'ec2_us_east'¶
-
EC2_US_WEST
= 'ec2_us_west'¶
-
EC2_US_WEST_OREGON
= 'ec2_us_west_oregon'¶
-
ECP
= 'ecp'¶
-
ELASTICHOSTS
= 'elastichosts'¶
-
ELASTICHOSTS_AU1
= 'elastichosts_au1'¶
-
ELASTICHOSTS_CA1
= 'elastichosts_ca1'¶
-
ELASTICHOSTS_CN1
= 'elastichosts_cn1'¶
-
ELASTICHOSTS_UK1
= 'elastichosts_uk1'¶
-
ELASTICHOSTS_UK2
= 'elastichosts_uk2'¶
-
ELASTICHOSTS_US1
= 'elastichosts_us1'¶
-
ELASTICHOSTS_US2
= 'elastichosts_us2'¶
-
ELASTICHOSTS_US3
= 'elastichosts_us3'¶
-
EUCALYPTUS
= 'eucalyptus'¶
-
EXOSCALE
= 'exoscale'¶
-
GANDI
= 'gandi'¶
-
GCE
= 'gce'¶
-
GOGRID
= 'gogrid'¶
-
GRIDSPOT
= 'gridspot'¶
-
HOSTVIRTUAL
= 'hostvirtual'¶
-
HPCLOUD
= 'hpcloud'¶
-
IBM
= 'ibm'¶
-
IKOULA
= 'ikoula'¶
-
JOYENT
= 'joyent'¶
-
KILI
= 'kili'¶
-
KTUCLOUD
= 'ktucloud'¶
-
LIBVIRT
= 'libvirt'¶
-
LINODE
= 'linode'¶
-
NEPHOSCALE
= 'nephoscale'¶
-
NIMBUS
= 'nimbus'¶
-
NINEFOLD
= 'ninefold'¶
-
ONAPP
= 'onapp'¶
-
OPENNEBULA
= 'opennebula'¶
-
OPENSTACK
= 'openstack'¶
-
OPSOURCE
= 'opsource'¶
-
OUTSCALE_INC
= 'outscale_inc'¶
-
OUTSCALE_SAS
= 'outscale_sas'¶
-
PACKET
= 'packet'¶
-
PROFIT_BRICKS
= 'profitbricks'¶
-
RACKSPACE
= 'rackspace'¶
-
RACKSPACE_FIRST_GEN
= 'rackspace_first_gen'¶
-
RACKSPACE_NOVA_BETA
= 'rackspace_nova_beta'¶
-
RACKSPACE_NOVA_DFW
= 'rackspace_nova_dfw'¶
-
RACKSPACE_NOVA_LON
= 'rackspace_nova_lon'¶
-
RACKSPACE_NOVA_ORD
= 'rackspace_nova_ord'¶
-
RACKSPACE_UK
= 'rackspace_uk'¶
-
RIMUHOSTING
= 'rimuhosting'¶
-
RUNABOVE
= 'runabove'¶
-
SERVERLOVE
= 'serverlove'¶
-
SKALICLOUD
= 'skalicloud'¶
-
SOFTLAYER
= 'softlayer'¶
-
TERREMARK
= 'terremark'¶
-
VCL
= 'vcl'¶
-
VCLOUD
= 'vcloud'¶
-
VOXEL
= 'voxel'¶
-
VPSNET
= 'vpsnet'¶
-
VSPHERE
= 'vsphere'¶
-
VULTR
= 'vultr'¶
libcloud.compute.ssh module¶
Wraps multiple ways to communicate over SSH.
-
class
libcloud.compute.ssh.
BaseSSHClient
(hostname, port=22, username='root', password=None, key=None, key_files=None, timeout=None)[source]¶ Bases:
object
Base class representing a connection over SSH/SCP to a remote node.
Parameters: - hostname (
str
) – Hostname or IP address to connect to. - port (
int
) – TCP port to communicate on, defaults to 22. - username (
str
) – Username to use, defaults to root. - password (
str
) – Password to authenticate with or a password used to unlock a private key if a password protected key is used. - key – Deprecated in favor of
key_files
argument. - key_files (
str
orlist
) – A list of paths to the private key files to use.
-
close
()[source]¶ Shutdown connection to the remote node.
Returns: True if the connection has been successfully closed, False otherwise. Return type: bool
-
connect
()[source]¶ Connect to the remote node over SSH.
Returns: True if the connection has been successfully established, False otherwise. Return type: bool
-
delete
(path)[source]¶ Delete/Unlink a file on the remote node.
Parameters: path ( str
) – File path on the remote node.Returns: True if the file has been successfully deleted, False otherwise. Return type: bool
-
put
(path, contents=None, chmod=None, mode='w')[source]¶ Upload a file to the remote node.
Parameters: - path (
str
) – File path on the remote node. - contents (
str
) – File Contents. - chmod (
int
) – chmod file to this after creation. - mode (
str
) – Mode in which the file is opened.
Returns: Full path to the location where a file has been saved.
Return type: str
- path (
- hostname (
-
class
libcloud.compute.ssh.
ParamikoSSHClient
(hostname, port=22, username='root', password=None, key=None, key_files=None, key_material=None, timeout=None)[source]¶ Bases:
libcloud.compute.ssh.BaseSSHClient
A SSH Client powered by Paramiko.
Authentication is always attempted in the following order:
- The key passed in (if key is provided)
- Any key we can find through an SSH agent (only if no password and key is provided)
- Any “id_rsa” or “id_dsa” key discoverable in ~/.ssh/ (only if no password and key is provided)
- Plain username/password auth, if a password was given (if password is provided)
-
CHUNK_SIZE
= 1024¶
-
SLEEP_DELAY
= 1.5¶
-
class
libcloud.compute.ssh.
ShellOutSSHClient
(hostname, port=22, username='root', password=None, key=None, key_files=None, timeout=None)[source]¶ Bases:
libcloud.compute.ssh.BaseSSHClient
This client shells out to “ssh” binary to run commands on the remote server.
Note: This client should not be used in production.
-
exception
libcloud.compute.ssh.
SSHCommandTimeoutError
(cmd, timeout)[source]¶ Bases:
exceptions.Exception
Exception which is raised when an SSH command times out.
libcloud.compute.types module¶
Base types used by other parts of libcloud
-
class
libcloud.compute.types.
Provider
[source]¶ Bases:
object
Defines for each of the supported providers
Variables: - DUMMY – Example provider
- EC2_US_EAST – Amazon AWS US N. Virgina
- EC2_US_WEST – Amazon AWS US N. California
- EC2_EU_WEST – Amazon AWS EU Ireland
- RACKSPACE – Rackspace next-gen OpenStack based Cloud Servers
- RACKSPACE_FIRST_GEN – Rackspace First Gen Cloud Servers
- GCE – Google Compute Engine
- GOGRID – GoGrid
- VPSNET – VPS.net
- LINODE – Linode.com
- VCLOUD – vmware vCloud
- RIMUHOSTING – RimuHosting.com
- ECP – Enomaly
- IBM – IBM Developer Cloud
- OPENNEBULA – OpenNebula.org
- DREAMHOST – DreamHost Private Server
- ELASTICHOSTS – ElasticHosts.com
- CLOUDSIGMA – CloudSigma
- NIMBUS – Nimbus
- BLUEBOX – Bluebox
- OPSOURCE – Opsource Cloud
- DIMENSIONDATA – Dimension Data Cloud
- NINEFOLD – Ninefold
- TERREMARK – Terremark
- EC2_US_WEST_OREGON – Amazon AWS US West 2 (Oregon)
- CLOUDSTACK – CloudStack
- CLOUDSIGMA_US – CloudSigma US Las Vegas
- LIBVIRT – Libvirt driver
- JOYENT – Joyent driver
- VCL – VCL driver
- KTUCLOUD – kt ucloud driver
- GRIDSPOT – Gridspot driver
- ABIQUO – Abiquo driver
- NEPHOSCALE – NephoScale driver
- EXOSCALE – Exoscale driver.
- IKOULA – Ikoula driver.
- OUTSCALE_SAS – Outscale SAS driver.
- OUTSCALE_INC – Outscale INC driver.
- PROFIT_BRICKS – ProfitBricks driver.
- VULTR – vultr driver.
- AZURE – Azure driver.
- AURORACOMPUTE – Aurora Compute driver.
-
ABIQUO
= 'abiquo'¶
-
AURORACOMPUTE
= 'aurora_compute'¶
-
AZURE
= 'azure'¶
-
BLUEBOX
= 'bluebox'¶
-
BRIGHTBOX
= 'brightbox'¶
-
CLOUDFRAMES
= 'cloudframes'¶
-
CLOUDSIGMA
= 'cloudsigma'¶
-
CLOUDSIGMA_US
= 'cloudsigma_us'¶
-
CLOUDSTACK
= 'cloudstack'¶
-
CLOUDWATT
= 'cloudwatt'¶
-
DIGITAL_OCEAN
= 'digitalocean'¶
-
DIMENSIONDATA
= 'dimensiondata'¶
-
DREAMHOST
= 'dreamhost'¶
-
DUMMY
= 'dummy'¶
-
EC2
= 'ec2_us_east'¶
-
EC2_AP_NORTHEAST
= 'ec2_ap_northeast'¶
-
EC2_AP_SOUTHEAST
= 'ec2_ap_southeast'¶
-
EC2_AP_SOUTHEAST2
= 'ec2_ap_southeast_2'¶
-
EC2_EU
= 'ec2_eu_west'¶
-
EC2_EU_WEST
= 'ec2_eu_west'¶
-
EC2_SA_EAST
= 'ec2_sa_east'¶
-
EC2_US_EAST
= 'ec2_us_east'¶
-
EC2_US_WEST
= 'ec2_us_west'¶
-
EC2_US_WEST_OREGON
= 'ec2_us_west_oregon'¶
-
ECP
= 'ecp'¶
-
ELASTICHOSTS
= 'elastichosts'¶
-
ELASTICHOSTS_AU1
= 'elastichosts_au1'¶
-
ELASTICHOSTS_CA1
= 'elastichosts_ca1'¶
-
ELASTICHOSTS_CN1
= 'elastichosts_cn1'¶
-
ELASTICHOSTS_UK1
= 'elastichosts_uk1'¶
-
ELASTICHOSTS_UK2
= 'elastichosts_uk2'¶
-
ELASTICHOSTS_US1
= 'elastichosts_us1'¶
-
ELASTICHOSTS_US2
= 'elastichosts_us2'¶
-
ELASTICHOSTS_US3
= 'elastichosts_us3'¶
-
EUCALYPTUS
= 'eucalyptus'¶
-
EXOSCALE
= 'exoscale'¶
-
GANDI
= 'gandi'¶
-
GCE
= 'gce'¶
-
GOGRID
= 'gogrid'¶
-
GRIDSPOT
= 'gridspot'¶
-
HOSTVIRTUAL
= 'hostvirtual'¶
-
HPCLOUD
= 'hpcloud'¶
-
IBM
= 'ibm'¶
-
IKOULA
= 'ikoula'¶
-
JOYENT
= 'joyent'¶
-
KILI
= 'kili'¶
-
KTUCLOUD
= 'ktucloud'¶
-
LIBVIRT
= 'libvirt'¶
-
LINODE
= 'linode'¶
-
NEPHOSCALE
= 'nephoscale'¶
-
NIMBUS
= 'nimbus'¶
-
NINEFOLD
= 'ninefold'¶
-
ONAPP
= 'onapp'¶
-
OPENNEBULA
= 'opennebula'¶
-
OPENSTACK
= 'openstack'¶
-
OPSOURCE
= 'opsource'¶
-
OUTSCALE_INC
= 'outscale_inc'¶
-
OUTSCALE_SAS
= 'outscale_sas'¶
-
PACKET
= 'packet'¶
-
PROFIT_BRICKS
= 'profitbricks'¶
-
RACKSPACE
= 'rackspace'¶
-
RACKSPACE_FIRST_GEN
= 'rackspace_first_gen'¶
-
RACKSPACE_NOVA_BETA
= 'rackspace_nova_beta'¶
-
RACKSPACE_NOVA_DFW
= 'rackspace_nova_dfw'¶
-
RACKSPACE_NOVA_LON
= 'rackspace_nova_lon'¶
-
RACKSPACE_NOVA_ORD
= 'rackspace_nova_ord'¶
-
RACKSPACE_UK
= 'rackspace_uk'¶
-
RIMUHOSTING
= 'rimuhosting'¶
-
RUNABOVE
= 'runabove'¶
-
SERVERLOVE
= 'serverlove'¶
-
SKALICLOUD
= 'skalicloud'¶
-
SOFTLAYER
= 'softlayer'¶
-
TERREMARK
= 'terremark'¶
-
VCL
= 'vcl'¶
-
VCLOUD
= 'vcloud'¶
-
VOXEL
= 'voxel'¶
-
VPSNET
= 'vpsnet'¶
-
VSPHERE
= 'vsphere'¶
-
VULTR
= 'vultr'¶
-
class
libcloud.compute.types.
NodeState
[source]¶ Bases:
object
Standard states for a node
Variables: - RUNNING – Node is running.
- REBOOTING – Node is rebooting.
- TERMINATED – Node is terminated. This node can’t be started later on.
- STOPPED – Node is stopped. This node can be started later on.
- PENDING – Node is pending.
- STOPPED – Node is stopped.
- SUSPENDED – Node is suspended.
- ERROR – Node is an error state. Usually no operations can be performed on the node once it ends up in the error state.
- PAUSED – Node is paused.
- UNKNOWN – Node state is unknown.
-
ERROR
= 7¶
-
PAUSED
= 8¶
-
PENDING
= 3¶
-
REBOOTING
= 1¶
-
RUNNING
= 0¶
-
STOPPED
= 5¶
-
SUSPENDED
= 6¶
-
TERMINATED
= 2¶
-
UNKNOWN
= 4¶
-
exception
libcloud.compute.types.
DeploymentError
(node, original_exception=None, driver=None)[source]¶ Bases:
libcloud.common.types.LibcloudError
Exception used when a Deployment Task failed.
Variables: node – Node
on which this exception happened, you might want to callNode.destroy()
-
libcloud.compute.types.
DeploymentException
¶ alias of
DeploymentError
-
exception
libcloud.compute.types.
LibcloudError
(value, driver=None)[source]¶ Bases:
exceptions.Exception
The base class for other libcloud exceptions
-
exception
libcloud.compute.types.
MalformedResponseError
(value, body=None, driver=None)[source]¶ Bases:
libcloud.common.types.LibcloudError
Exception for the cases when a provider returns a malformed response, e.g. you request JSON and provider returns ‘<h3>something</h3>’ due to some error on their side.
-
exception
libcloud.compute.types.
InvalidCredsError
(value='Invalid credentials with the provider', driver=None)[source]¶ Bases:
libcloud.common.types.ProviderError
Exception used when invalid credentials are used on a provider.
-
libcloud.compute.types.
InvalidCredsException
¶ alias of
InvalidCredsError
Module contents¶
Module for working with Cloud Servers