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_ip[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__ Undocumented
Method get_uuid Undocumented
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
def __init__(self, creds): (source)
Undocumented
def get_uuid(self, unique_field=None): (source)
Undocumented
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()
>>> sorted([node.name for node in driver.list_nodes()])
['dummy-1', 'dummy-2', 'dummy-3']
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.
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']
[]
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']
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]
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"]
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']
API Documentation for libcloud, generated by pydoctor at 2011-07-02 22:19:34.