I just pulled a new copy of libcloud from the Apache.org git repo.
The example code does this:
nodes = [ driver.list_nodes() for driver in drivers ]
i.e. makes a list of nodes per driver.
Then tries to access the names with:
node = filter(lambda x: x.name == 'test', nodes)[0]
"x" is a list, not a node, so it throws an Exception.
Here's a more readable approach that reboots any node named "test", and that
shows that the provider has to be accessed by Node.driver.name, not
Node.provider as is implied by the string printed out by Node.__repr__:
# List out the nodes, grouped by provider and reboot any node named "test"
for provider in nodes:
if provider:
print "Provider: %s" % provider[0].driver.name
for node in provider:
print "Node : %s" % node.name
if node.name == "test":
node.reboot()
I haven't cloned the repo yet...which of the git mirrors is the best for
submitting pull requests?
Thanks,
S