l.c.d.d.DummyNodeDriver(NodeDriver) : class documentation

Part of libcloud.compute.drivers.dummy View Source View In Hierarchy

Dummy node driver

This is a fake driver which appears to always create or destroy
nodes successfully.

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

If the credentials you give convert to an integer then the next
node to be created will be one higher.

Each time you create a node you will get a different IP address.

>>> driver = DummyNodeDriver(22)
>>> node=driver.create_node()
>>> node.name
'dummy-23'
Method __init__ @param creds: Credentials @type creds: C{str}
Method get_uuid @param unique_field: Unique field @type unique_field: C{bool} @rtype: L{UUID}
Method list_nodes List the nodes known to a particular driver; There are two default nodes created at the beginning
Method reboot_node Sets the node state to rebooting; in this dummy driver always returns True as if the reboot had been successful.
Method destroy_node Sets the node state to terminated and removes it from the node list
Method list_images Returns a list of images as a cloud provider might have
Method list_sizes Returns a list of node sizes as a cloud provider might have
Method list_locations Returns a list of locations of nodes
Method create_node Creates a dummy node; the node id is equal to the number of nodes in the node list

Inherited from NodeDriver:

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 (via NodeDriver):

Method _ex_connection_class_kwargs Return extra connection keyword arguments which are passed to the Connection class constructor.
def __init__(self, creds): (source)
@param  creds: Credentials
@type   creds: C{str}

@rtype: C{None}
def get_uuid(self, unique_field=None): (source)
@param  unique_field: Unique field
@type   unique_field: C{bool}
@rtype: L{UUID}
def list_nodes(self): (source)
List the nodes known to a particular driver;
There are two default nodes created at the beginning

>>> from libcloud.compute.drivers.dummy import DummyNodeDriver
>>> driver = DummyNodeDriver(0)
>>> node_list=driver.list_nodes()
>>> sorted([node.name for node in node_list ])
['dummy-1', 'dummy-2']

each item in the list returned is a node object from which you
can carry out any node actions you wish

>>> node_list[0].reboot()
True

As more nodes are added, list_nodes will return them

>>> node=driver.create_node()
>>> node.size.id
's1'
>>> node.image.id
'i2'
>>> sorted([node.name for node in driver.list_nodes()])
['dummy-1', 'dummy-2', 'dummy-3']

@inherits: L{NodeDriver.list_nodes}
def reboot_node(self, node): (source)
Sets the node state to rebooting; in this dummy driver always
returns True as if the reboot had been successful.

>>> from libcloud.compute.drivers.dummy import DummyNodeDriver
>>> driver = DummyNodeDriver(0)
>>> node=driver.create_node()
>>> from libcloud.compute.types import NodeState
>>> node.state == NodeState.RUNNING
True
>>> node.state == NodeState.REBOOTING
False
>>> driver.reboot_node(node)
True
>>> node.state == NodeState.REBOOTING
True

Please note, dummy nodes never recover from the reboot.

@inherits: L{NodeDriver.reboot_node}
def destroy_node(self, node): (source)
Sets the node state to terminated and removes it from the node list

>>> from libcloud.compute.drivers.dummy import DummyNodeDriver
>>> driver = DummyNodeDriver(0)
>>> from libcloud.compute.types import NodeState
>>> node = [node for node in driver.list_nodes() if node.name == 'dummy-1'][0]
>>> node.state == NodeState.RUNNING
True
>>> driver.destroy_node(node)
True
>>> node.state == NodeState.RUNNING
False
>>> [node for node in driver.list_nodes() if node.name == 'dummy-1']
[]

@inherits: L{NodeDriver.destroy_node}
def list_images(self, location=None): (source)
Returns a list of images as a cloud provider might have

>>> from libcloud.compute.drivers.dummy import DummyNodeDriver
>>> driver = DummyNodeDriver(0)
>>> sorted([image.name for image in driver.list_images()])
['Slackware 4', 'Ubuntu 9.04', 'Ubuntu 9.10']

@inherits: L{NodeDriver.list_images}
def list_sizes(self, location=None): (source)
Returns a list of node sizes as a cloud provider might have

>>> from libcloud.compute.drivers.dummy import DummyNodeDriver
>>> driver = DummyNodeDriver(0)
>>> sorted([size.ram for size in driver.list_sizes()])
[128, 512, 4096, 8192]

@inherits: L{NodeDriver.list_images}
def list_locations(self): (source)
Returns a list of locations of nodes

>>> from libcloud.compute.drivers.dummy import DummyNodeDriver
>>> driver = DummyNodeDriver(0)
>>> sorted([loc.name + " in " + loc.country for loc in driver.list_locations()])
['Island Datacenter in FJ', 'London Loft in GB', "Paul's Room in US"]

@inherits: L{NodeDriver.list_locations}
def create_node(self, **kwargs): (source)
Creates a dummy node; the node id is equal to the number of
nodes in the node list

>>> from libcloud.compute.drivers.dummy import DummyNodeDriver
>>> driver = DummyNodeDriver(0)
>>> sorted([node.name for node in driver.list_nodes()])
['dummy-1', 'dummy-2']
>>> nodeA = driver.create_node()
>>> sorted([node.name for node in driver.list_nodes()])
['dummy-1', 'dummy-2', 'dummy-3']
>>> driver.create_node().name
'dummy-4'
>>> driver.destroy_node(nodeA)
True
>>> sorted([node.name for node in driver.list_nodes()])
['dummy-1', 'dummy-2', 'dummy-4']

@inherits: L{NodeDriver.create_node}
API Documentation for libcloud, generated by pydoctor at 2013-07-01 17:02:02.