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
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.
- Log in to your CloudStack environment
- Go to Accounts, and click on your username
- Then click on View users
- Then click on the username on the screen
- Next, click on Generate New API/Secret Keys
- Your API key and secret key will then be displayed. Copy these details and save them.
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 machinesstart virtualmachine id=UUID– starts a specific VMstop virtualmachine id=UUID– stops a specific VMdeploy 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.