Part of libcloud.compute.base View Source View In Hierarchy
Known subclasses: libcloud.compute.drivers.cloudstack.CloudStackNode, libcloud.compute.drivers.gogrid.GoGridNode
Provide a common interface for handling nodes of all types.
The Node object provides the interface in libcloud through which we can manipulate nodes in different cloud providers in the same way. Node objects don't actually do much directly themselves, instead the node driver handles the connection to the node.
You don't normally create a node object yourself; instead you use a driver and then have that create the node for you.
>>> 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'
You can also get nodes from the driver's list_node function.
>>> node = driver.list_nodes()[0] >>> node.name 'dummy-1'
the node keeps a reference to its own driver which means that we can work on nodes from different providers without having to know which is which.
>>> driver = DummyNodeDriver(72) >>> node2 = driver.create_node() >>> node.driver.creds 0 >>> node2.driver.creds 72
Althrough Node objects can be subclassed, this isn't normally done. Instead, any driver specific information is stored in the "extra" proproperty of the node.
>>> node.extra {'foo': 'bar'}
Method | __init__ | Undocumented |
Method | get_uuid | Unique hash for this node |
Method | reboot | Reboot this node |
Method | destroy | Destroy this node |
Method | __repr__ | Undocumented |
Returns | string
The hash is a function of an SHA1 hash of the node's ID and its driver which means that it should be unique between all nodes. In some subclasses (e.g. GoGrid) there is no ID available so the public IP address is used. This means that, unlike a properly done system UUID, the same UUID may mean a different system install at a different time >>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> node = driver.create_node() >>> node.get_uuid() 'd3748461511d8b9b0e0bfa0d4d3383a619a2bb9f' Note, for example, that this example will always produce the same UUID! |
Returns | bool
This calls the node's driver and reboots the node >>> 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 >>> node.reboot() True >>> node.state == NodeState.REBOOTING True |
Returns | bool
This calls the node's driver and destroys the node >>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> from libcloud.compute.types import NodeState >>> node = driver.create_node() >>> node.state == NodeState.RUNNING True >>> node.destroy() True >>> node.state == NodeState.RUNNING False |