l.c.b.NodeDriver(BaseDriver) : class documentation

Part of libcloud.compute.base View Source View In Hierarchy

Known subclasses: libcloud.compute.drivers.bluebox.BlueboxNodeDriver, libcloud.compute.drivers.brightbox.BrightboxNodeDriver, libcloud.compute.drivers.cloudsigma.CloudSigmaBaseNodeDriver, libcloud.compute.drivers.cloudstack.CloudStackNodeDriver, libcloud.compute.drivers.dreamhost.DreamhostNodeDriver, libcloud.compute.drivers.dummy.DummyNodeDriver, libcloud.compute.drivers.ec2.EC2NodeDriver, libcloud.compute.drivers.ecp.ECPNodeDriver, libcloud.compute.drivers.elasticstack.ElasticStackBaseNodeDriver, libcloud.compute.drivers.gandi.GandiNodeDriver, libcloud.compute.drivers.gogrid.GoGridNodeDriver, libcloud.compute.drivers.gridspot.GridspotNodeDriver, libcloud.compute.drivers.ibm_sce.IBMNodeDriver, libcloud.compute.drivers.joyent.JoyentNodeDriver, libcloud.compute.drivers.libvirt_driver.LibvirtNodeDriver, libcloud.compute.drivers.linode.LinodeNodeDriver, libcloud.compute.drivers.opennebula.OpenNebulaNodeDriver, libcloud.compute.drivers.openstack.OpenStackNodeDriver, libcloud.compute.drivers.opsource.OpsourceNodeDriver, libcloud.compute.drivers.rimuhosting.RimuHostingNodeDriver, libcloud.compute.drivers.slicehost.SlicehostNodeDriver, libcloud.compute.drivers.softlayer.SoftLayerNodeDriver, libcloud.compute.drivers.vcl.VCLNodeDriver, libcloud.compute.drivers.vcloud.VCloudNodeDriver, libcloud.compute.drivers.voxel.VoxelNodeDriver, libcloud.compute.drivers.vpsnet.VPSNetNodeDriver

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.

Method __init__
Method create_node Create a new node instance.
Method destroy_node Destroy a node.
Method reboot_node Reboot a node.
Method list_nodes List all nodes @return: list of node objects @rtype: list of Node
Method list_images List images on a provider
Method list_sizes List sizes on a provider
Method list_locations List data centers for a provider
Method deploy_node Create a new node, and start deployment.
Method create_volume Create a new volume.
Method destroy_volume Destroys a storage volume.
Method attach_volume Attaches volume to node.
Method detach_volume Detaches a volume from a node.
Method _wait_until_running Block until node is fully booted and has an IP address assigned.
Method _ssh_client_connect Try to connect to the remote SSH server. If a connection times out or is refused it is retried up to timeout number of seconds.
Method _run_deployment_script Run the deployment script on the provided node. At this point it is assumed that SSH connection has already been established.
Method _get_size_price Undocumented

Inherited from BaseDriver:

Method _ex_connection_class_kwargs Return extra connection keyword arguments which are passed to the Connection class constructor.
def __init__(self, key, secret=None, secure=True, host=None, port=None, api_version=None, **kwargs): (source)
Unknown Field: requireskey, secret
def create_node(self, **kwargs): (source)
Create a new node instance.
ParametersnameString with a name for this new node (required) (type: str)
sizeThe size of resources allocated to this node. (required) (type: NodeSize)
imageOS Image to boot on node. (required) (type: NodeImage)
locationWhich data center to create a node in. If empty, undefined behavoir will be selected. (optional) (type: NodeLocation)
authInitial authentication information for the node (optional) (type: NodeAuthSSHKey or NodeAuthPassword)
ReturnsThe newly created node. (type: Node)
def destroy_node(self, node): (source)
Destroy a node.

Depending upon the provider, this may destroy all data associated with the node, including backups.

ParametersnodeThe node to be destroyed (type: Node)
ReturnsTrue if the destroy was successful, otherwise False (type: bool)
def reboot_node(self, node): (source)
Reboot a node.
ParametersnodeThe node to be rebooted (type: Node)
ReturnsTrue if the reboot was successful, otherwise False (type: bool)
def list_nodes(self): (source)
List all nodes
Returnslist of node objects (type: list of Node)
def list_images(self, location=None): (source)
List images on a provider
ParameterslocationThe location at which to list images (type: NodeLocation)
Returnslist of node image objects (type: list of NodeImage)
def list_sizes(self, location=None): (source)
List sizes on a provider
ParameterslocationThe location at which to list sizes (type: NodeLocation)
Returnslist of node size objects (type: list of NodeSize)
def list_locations(self): (source)
List data centers for a provider
Returnslist of node location objects (type: list of NodeLocation)
def deploy_node(self, **kwargs): (source)
Create a new node, and start deployment.

Depends on a Provider Driver supporting either using a specific password or returning a generated password.

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:
...         node = 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.

ParametersdeployDeployment to run once machine is online and availble to SSH. (type: Deployment)
ssh_usernameOptional name of the account which is used when connecting to SSH server (default is root) (type: str)
ssh_portOptional SSH server port (default is 22) (type: int)
ssh_timeoutOptional SSH connection timeout in seconds (default is None) (type: float)
authInitial authentication information for the node (optional) (type: NodeAuthSSHKey or NodeAuthPassword)
ssh_keyA path (or paths) to an SSH private key with which to attempt to authenticate. (optional) (type: str or list of str)
max_triesHow many times to retry if a deployment fails before giving up (default is 3) (type: int)
ssh_interfaceThe interface to wait for. Default is 'public_ips', other option is 'private_ips'. (type: str)
Unknown Field: inheritsNodeDriver.create_node
def create_volume(self, size, name, location=None, snapshot=None): (source)
Create a new volume.
ParameterssizeSize of volume in gigabytes (required) (type: int)
nameName of the volume to be created (type: str)
locationWhich data center to create a volume in. If empty, undefined behavoir will be selected. (optional) (type: NodeLocation)
snapshotName of snapshot from which to create the new volume. (optional) (type: str)
ReturnsThe newly created volume. (type: StorageVolume)
def destroy_volume(self, volume): (source)
Destroys a storage volume.
ParametersvolumeVolume to be destroyed (type: StorageVolume)
Returns (type: bool)
def attach_volume(self, node, volume, device=None): (source)
Attaches volume to node.
ParametersnodeNode to attach volume to (type: Node)
volumeVolume to attach (type: StorageVolume)
deviceWhere the device is exposed, e.g. '/dev/sdb (optional) (type: str)
Returns (type: bool)
def detach_volume(self, volume): (source)
Detaches a volume from a node.
ParametersvolumeVolume to be detached (type: StorageVolume)
Returns (type: bool)
def _wait_until_running(self, node, wait_period=3, timeout=600, ssh_interface='public_ips', force_ipv4=True): (source)
Block until node is fully booted and has an IP address assigned.
ParametersnodeNode instance. (type: Node)
wait_periodHow many seconds to between each loop iteration (default is 3) (type: int)
timeoutHow many seconds to wait before timing out (default is 600) (type: int)
ssh_interfaceThe interface to wait for. Default is 'public_ips', other option is 'private_ips'. (type: str)
force_ipv4Ignore ipv6 IP addresses (default is True). (type: bool)
Returns(Node, ip_addresses) tuple of Node instance and list of ip_address on success.
def _ssh_client_connect(self, ssh_client, wait_period=1.5, timeout=300): (source)
Try to connect to the remote SSH server. If a connection times out or is refused it is retried up to timeout number of seconds.
Parametersssh_clientA configured SSHClient instance (type: SSHClient)
wait_periodHow many seconds to wait between each loop iteration (default is 1.5) (type: int)
timeoutHow many seconds to wait before timing out (default is 600) (type: int)
ReturnsSSHClient on success
def _run_deployment_script(self, task, node, ssh_client, max_tries=3): (source)
Run the deployment script on the provided node. At this point it is assumed that SSH connection has already been established.
ParameterstaskDeployment task to run on the node. (type: Deployment)
nodeNode to operate one (type: Node)
ssh_clientA configured and connected SSHClient instance (type: SSHClient)
max_triesHow many times to retry if a deployment fails before giving up (default is 3) (type: int)
ReturnsNode Node instance on success.
def _get_size_price(self, size_id): (source)
Undocumented
API Documentation for libcloud, generated by pydoctor at 2012-07-28 18:57:18.