Reset, Stop, Start a Server Using Libcloud

I’m trying to use the ProfitBricks’ Libcloud library to issue various commands to my server. Namely, I want to reboot it automatically via script, but would also like to know how to stop and start it, too.

  • **bold**
  • _italics_
  • `code`
  • ```code block```
  • # Heading 1
  • ## Heading 2
  • > Quote

You can do this with a few lines of code. You’ll want to first follow our tutorial on getting started with Libcloud. Setup your code so it can authenticate without an issue. This is covered in the link I provided. I usually test authentication by calling list_sizes.

Now that you have your code ready, you can easily do:

This will retrieve a list of nodes currently deployed.

nodes = driver.list_nodes()

Get your node. You will pass this to the reboot_node function. node = [n for n in nodes if 'servername' in][0]

Reboot the node. driver.reboot_node(node=node)

The reboot_node function is the same as resetting a server.

In the context of Libcloud a node is the same as a virtual machine.

You can stop a server by doing:


Or start it back up by doing: