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

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

Known subclasses: libcloud.compute.drivers.abiquo.AbiquoNodeDriver, libcloud.compute.drivers.bluebox.BlueboxNodeDriver, libcloud.compute.drivers.brightbox.BrightboxNodeDriver, libcloud.compute.drivers.cloudsigma.CloudSigmaBaseNodeDriver, libcloud.compute.drivers.cloudstack.CloudStackNodeDriver, libcloud.compute.drivers.digitalocean.DigitalOceanNodeDriver, libcloud.compute.drivers.dreamhost.DreamhostNodeDriver, libcloud.compute.drivers.dummy.DummyNodeDriver, libcloud.compute.drivers.ec2.BaseEC2NodeDriver, 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.hostvirtual.HostVirtualNodeDriver, 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__ @param key: API key or username to be used (required) @type key: C{str}
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: C{list} of L{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 the given nodes are fully booted and have an IP address assigned.
Method _wait_until_running Undocumented
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 _connect_and_run_deployment_script Undocumented
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)
@param    key:    API key or username to be used (required)
@type     key:    C{str}

@param    secret: Secret password to be used (required)
@type     secret: C{str}

@param    secure: Weither to use HTTPS or HTTP. Note: Some providers
                    only support HTTPS, and it is on by default.
@type     secure: C{bool}

@param    host: Override hostname used for connections.
@type     host: C{str}

@param    port: Override port used for connections.
@type     port: C{int}

@param    api_version: Optional API version. Only used by drivers
                         which support multiple API versions.
@type     api_version: C{str}

@rtype: C{None}
def create_node(self, **kwargs): (source)
overridden in libcloud.compute.drivers.abiquo.AbiquoNodeDriver, libcloud.compute.drivers.bluebox.BlueboxNodeDriver, libcloud.compute.drivers.brightbox.BrightboxNodeDriver, libcloud.compute.drivers.cloudsigma.CloudSigmaBaseNodeDriver, libcloud.compute.drivers.cloudstack.CloudStackNodeDriver, libcloud.compute.drivers.digitalocean.DigitalOceanNodeDriver, libcloud.compute.drivers.dreamhost.DreamhostNodeDriver, libcloud.compute.drivers.dummy.DummyNodeDriver, libcloud.compute.drivers.ec2.BaseEC2NodeDriver, libcloud.compute.drivers.ecp.ECPNodeDriver, libcloud.compute.drivers.elasticstack.ElasticStackBaseNodeDriver, libcloud.compute.drivers.gandi.GandiNodeDriver, libcloud.compute.drivers.gogrid.GoGridNodeDriver, libcloud.compute.drivers.hostvirtual.HostVirtualNodeDriver, libcloud.compute.drivers.ibm_sce.IBMNodeDriver, libcloud.compute.drivers.joyent.JoyentNodeDriver, libcloud.compute.drivers.linode.LinodeNodeDriver, libcloud.compute.drivers.opennebula.OpenNebulaNodeDriver, libcloud.compute.drivers.openstack.OpenStack_1_0_NodeDriver, libcloud.compute.drivers.openstack.OpenStack_1_1_NodeDriver, 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
Create a new node instance.

@keyword    name:   String with a name for this new node (required)
@type       name:   C{str}

@keyword    size:   The size of resources allocated to this node.
                    (required)
@type       size:   L{NodeSize}

@keyword    image:  OS Image to boot on node. (required)
@type       image:  L{NodeImage}

@keyword    location: Which data center to create a node in. If empty,
                      undefined behavoir will be selected. (optional)
@type       location: L{NodeLocation}

@keyword    auth:   Initial authentication information for the node
                    (optional)
@type       auth:   L{NodeAuthSSHKey} or L{NodeAuthPassword}

@return: The newly created node.
@rtype: L{Node}
def destroy_node(self, node): (source)
overridden in libcloud.compute.drivers.abiquo.AbiquoNodeDriver, libcloud.compute.drivers.bluebox.BlueboxNodeDriver, libcloud.compute.drivers.brightbox.BrightboxNodeDriver, libcloud.compute.drivers.cloudsigma.CloudSigmaBaseNodeDriver, libcloud.compute.drivers.cloudstack.CloudStackNodeDriver, libcloud.compute.drivers.digitalocean.DigitalOceanNodeDriver, libcloud.compute.drivers.dreamhost.DreamhostNodeDriver, libcloud.compute.drivers.dummy.DummyNodeDriver, libcloud.compute.drivers.ec2.BaseEC2NodeDriver, 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.hostvirtual.HostVirtualNodeDriver, 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
Destroy a node.

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

@param node: The node to be destroyed
@type node: L{Node}

@return: True if the destroy was successful, otherwise False
@rtype: C{bool}
def reboot_node(self, node): (source)
Reboot a node.

@param node: The node to be rebooted
@type node: L{Node}

@return: True if the reboot was successful, otherwise False
@rtype: C{bool}
def list_nodes(self): (source)
overridden in libcloud.compute.drivers.abiquo.AbiquoNodeDriver, libcloud.compute.drivers.bluebox.BlueboxNodeDriver, libcloud.compute.drivers.brightbox.BrightboxNodeDriver, libcloud.compute.drivers.cloudsigma.CloudSigmaBaseNodeDriver, libcloud.compute.drivers.cloudstack.CloudStackNodeDriver, libcloud.compute.drivers.digitalocean.DigitalOceanNodeDriver, libcloud.compute.drivers.dreamhost.DreamhostNodeDriver, libcloud.compute.drivers.dummy.DummyNodeDriver, libcloud.compute.drivers.ec2.BaseEC2NodeDriver, 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.hostvirtual.HostVirtualNodeDriver, 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
List all nodes
@return:  list of node objects
@rtype: C{list} of L{Node}
def list_images(self, location=None): (source)
List images on a provider

@keyword location: The location at which to list images
@type location: L{NodeLocation}

@return: list of node image objects
@rtype: C{list} of L{NodeImage}
def list_sizes(self, location=None): (source)
List sizes on a provider

@keyword location: The location at which to list sizes
@type location: L{NodeLocation}

@return: list of node size objects
@rtype: C{list} of L{NodeSize}
def list_locations(self): (source)
List data centers for a provider

@return: list of node location objects
@rtype: C{list} of L{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 L{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.

@inherits: L{NodeDriver.create_node}

@keyword    deploy: Deployment to run once machine is online and
                    availble to SSH.
@type       deploy: L{Deployment}

@keyword    ssh_username: Optional name of the account which is used
                          when connecting to
                          SSH server (default is root)
@type       ssh_username: C{str}

@keyword    ssh_alternate_usernames: Optional list of ssh usernames to
                                     try to connect with if using the
                                     default one fails
@type       ssh_alternate_usernames: C{list}

@keyword    ssh_port: Optional SSH server port (default is 22)
@type       ssh_port: C{int}

@keyword    ssh_timeout: Optional SSH connection timeout in seconds
                         (default is None)
@type       ssh_timeout: C{float}

@keyword    auth:   Initial authentication information for the node
                    (optional)
@type       auth:   L{NodeAuthSSHKey} or L{NodeAuthPassword}

@keyword    ssh_key: A path (or paths) to an SSH private key with which
                     to attempt to authenticate. (optional)
@type       ssh_key: C{str} or C{list} of C{str}

@keyword    timeout: How many seconds to wait before timing out.
                     (default is 600)
@type       timeout: C{int}

@keyword    max_tries: How many times to retry if a deployment fails
                       before giving up (default is 3)
@type       max_tries: C{int}

@keyword    ssh_interface: The interface to wait for. Default is
                           'public_ips', other option is 'private_ips'.
@type       ssh_interface: C{str}
def create_volume(self, size, name, location=None, snapshot=None): (source)
Create a new volume.

@param      size: Size of volume in gigabytes (required)
@type       size: C{int}

@keyword    name: Name of the volume to be created
@type       name: C{str}

@keyword    location: Which data center to create a volume in. If
                       empty, undefined behavoir will be selected.
                       (optional)
@type       location: L{NodeLocation}

@keyword    snapshot:  Name of snapshot from which to create the new
                       volume.  (optional)
@type       snapshot:  C{str}

@return: The newly created volume.
@rtype: L{StorageVolume}
def destroy_volume(self, volume): (source)
Destroys a storage volume.

@param      volume: Volume to be destroyed
@type       volume: L{StorageVolume}

@rtype: C{bool}
def attach_volume(self, node, volume, device=None): (source)
Attaches volume to node.

@param      node: Node to attach volume to
@type       node: L{Node}

@param      volume: Volume to attach
@type       volume: L{StorageVolume}

@param      device: Where the device is exposed,
                    e.g. '/dev/sdb (optional)
@type       device: C{str}

@rtype: C{bool}
def detach_volume(self, volume): (source)
Detaches a volume from a node.

@param      volume: Volume to be detached
@type       volume: L{StorageVolume}

@rtype: C{bool}
def _wait_until_running(self, node, wait_period=3, timeout=600, ssh_interface='public_ips', force_ipv4=True): (source)
Undocumented
def wait_until_running(self, nodes, wait_period=3, timeout=600, ssh_interface='public_ips', force_ipv4=True): (source)
Block until the given nodes are fully booted and have an IP address
assigned.

@keyword    nodes: list of node instances.
@type       nodes: C{List} of L{Node}

@keyword    wait_period: How many seconds to between each loop
                         iteration (default is 3)
@type       wait_period: C{int}

@keyword    timeout: How many seconds to wait before timing out
                     (default is 600)
@type       timeout: C{int}

@keyword    ssh_interface: The interface to wait for.
                           Default is 'public_ips', other option is
                           'private_ips'.
@type       ssh_interface: C{str}

@keyword    force_ipv4: Ignore ipv6 IP addresses (default is True).
@type       force_ipv4: C{bool}

@return: C{[(Node, ip_addresses)]} list of tuple of Node instance and
         list of ip_address on success.

@return: List of tuple of Node instance and list of ip_address on
         success (node, ip_addresses).
@rtype: C{list} of C{tuple}
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.

@keyword    ssh_client: A configured SSHClient instance
@type       ssh_client: C{SSHClient}

@keyword    wait_period: How many seconds to wait between each loop
                         iteration (default is 1.5)
@type       wait_period: C{int}

@keyword    timeout: How many seconds to wait before timing out
                     (default is 600)
@type       timeout: C{int}

@return: C{SSHClient} on success
def _connect_and_run_deployment_script(self, task, node, ssh_hostname, ssh_port, ssh_username, ssh_password, ssh_key_file, ssh_timeout, timeout, max_tries): (source)
Undocumented
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.

@keyword    task: Deployment task to run on the node.
@type       task: C{Deployment}

@keyword    node: Node to operate one
@type       node: C{Node}

@keyword    ssh_client: A configured and connected SSHClient instance
@type       ssh_client: C{SSHClient}

@keyword    max_tries: How many times to retry if a deployment fails
                       before giving up (default is 3)
@type       max_tries: C{int}

@return: C{Node} Node instance on success.
def _get_size_price(self, size_id): (source)
Undocumented
API Documentation for libcloud, generated by pydoctor at 2013-04-20 21:40:42.