Manage Public Cloud via CLI using CloudMonkey

Do you want to easily manage your Public Cloud environment via the terminal? You can with CloudMonkey, a command-line tool for Apache CloudStack. It allows you to start, stop, create, or delete virtual machines, configure networks, and much more – all from your CLI.

What is CloudMonkey?

CloudMonkey is an official command-line interface for Apache CloudStack. With this tool, you execute CloudStack API commands without having to manually build URLs or generate signatures. It is especially useful for system administrators, developers, or anyone who enjoys working via the terminal.

Installing CloudMonkey

If you are using macOS, you can quickly and easily install CloudMonkey with MacPorts. That way, you don't need to install Python 3 and pip first.

On Linux, Windows, as well as macOS, you can install CloudMonkey using pip. You will need Python 3 for this. Read this article on how to install Python 3 and pip.

pip install cloudmonkey

After installation, the command is available as cmk.

Creating an API key

To use the commands in CloudMonkey, you need an API key and API secret. You can generate these details in CloudStack.

  1. Log in to your CloudStack environment
  2. Go to Accounts, and click on your username
    Click accounts in CloudStack
  3. Then click on View users
    Click on View Users in CloudStack
  4. Then click on the username on the screen
    Click on username in CloudStack
  5. Next, click on Generate New API/Secret Keys
  6. Your API key and secret key will then be displayed. Copy these details and save them.
    API key and API secret in CloudStack

First-time setup

Before you can use CloudMonkey, you need to configure it with your API details from your mijn.host Public Cloud.

cmk set url https://cloud.mijn.host:8443/client/api
cmk set apikey your-api-key
cmk set secretkey your-secret-key
cmk set domain your-domain

You can find your domain in CloudStack by clicking on Domain.

If you are working with a project, you can also set that up:

cmk set project your-project-name

Using CloudMonkey

After configuration, you can get started right away. Here are a few examples:

  • list virtualmachines – shows all your virtual machines
  • start virtualmachine id=UUID – starts a specific VM
  • stop virtualmachine id=UUID – stops a specific VM
  • deploy virtualmachine templateid=XXX serviceofferingid=YYY zoneid=ZZZ – creates a new VM

CloudMonkey also supports interactive mode, autocomplete, and scripting. You can execute multiple commands in sequence or process them in a script for automation.

In addition to virtual machines, you can also set up networks, create and attach storage, and much more.

More information

Check out the official CloudMonkey GitHub page for all options and documentation.


Still have questions? Get in touch.