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

Inherited from NodeDriver:

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 (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)
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 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()
>>> node.size.id
's1'
>>> node.image.id
'i2'
>>> 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 2012-07-15 18:48:28.