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.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
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 @return: list of NodeLocation objects
Method deploy_node Create a new node, and start deployment.
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)
ParameterskeyAPI key or username to used (type: str)
secretSecret password to be used (type: str)
secureWeither to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default. (type: bool)
hostOverride hostname used for connections. (type: str)
portOverride port used for connections. (type: int)
api_versionOptional API version. Only used by drivers which support multiple API versions. (type: str)
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.
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)
Returnsbool True if the destroy was successful, otherwise False
def reboot_node(self, node): (source)
Reboot a node.
ParametersnodeThe node to be rebooted (type: Node)
Returnsbool True if the reboot was successful, otherwise False
def list_nodes(self): (source)
List all nodes
Returnslist of Node objects
def list_images(self, location=None): (source)
List images on a provider
ParameterslocationThe location at which to list images (type: NodeLocation)
Returnslist of NodeImage objects
def list_sizes(self, location=None): (source)
List sizes on a provider
ParameterslocationThe location at which to list sizes (type: NodeLocation)
Returnslist of NodeSize objects
def list_locations(self): (source)
List data centers for a provider
Returnslist of NodeLocation objects
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.

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: string or list of strings)
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

See NodeDriver.create_node for more keyword args.

>>> 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.

)
def _wait_until_running(self, node, wait_period=3, timeout=600, ssh_interface='public_ips'): (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)
Returns(Node, ip_addresses) tuple of Node instance and list of ip_address on success.
def _ssh_client_connect(self, ssh_client, 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)
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-15 18:10:03.