Reputation: 87
I'm trying to find a way to stop or start a node (device, instance) via libcloud and I cannot find a method for this. Could this basic functionality be missing? I'm now looking for working against EC2, but may need to work against other providers as well. Thanks in advance!
Upvotes: 0
Views: 298
Reputation: 376
To stop a running node given that instance ID is known for a given region.
cls = get_driver(Provider.EC2_AP_NORTHEAST)
driver = cls(access_key, secret_key)
nodes = driver.list_nodes()
node_id = "i-xyz"
inst = [i for i in nodes if i.id == node_id][0]
driver.ex_stop_node(inst)
To start a stopped node.
cls = get_driver(Provider.EC2_AP_NORTHEAST)
driver = cls(access_key, secret_key)
nodes = driver.list_nodes()
node_id = "i-xyz"
inst = [i for i in nodes if i.id == node_id][0]
driver.ex_start_node(inst)
Upvotes: 4