Cloudstack CLI
Cloudstack CLI is a CloudStack API client written in Ruby.
Installation
Install the cloudstack-cli gem:
$ gem install cloudstack-cli
Setup
Create the initial configuration:
$ cs setup
cloudstack-cli expects to find a configuartion file with the API URL and your CloudStack credentials in your home directory named .cloudstack-cli.yml. If the file is located elsewhere you can specify the loaction using the --config option.
Example content of the configuration file:
:url: "https://my-cloudstack-server/client/api/"
:api_key: "cloudstack-api-key"
:secret_key: "cloudstack-api-secret"
Usage
Please see http://rubydoc.info/gems/cloudstack-cli/0.0.3/frames
See the help screen:
$ cs
Example 1
Bootsrap a server:
$ cs server create server01 --zone ZUERICH_IX --port-forwarding 193.218.104.10:22 193.218.104.10:80 --template CentOS-6.4-x64-v1.4 --offering 1cpu_1gb --networks M_Demo
Example 2
Run a custom API command:
$ cs command listAlerts type=8
Example 3
Sort all computing offerings by CPU and Memory grouped my Domain:
$ cs offering sort
Example 4
Stop all virtual routers of project Demo (you could filter by Zone too): (This command is helpful if you have to deploy new versions of Cloudstack when using redumdant routers)
$ cs router list --project Demo --status running --redundant-state BACKUP --command stop
Hint: You can watch the status of the command with watch.
$ watch -n cs router list --project Demo
References
- Cloudstack API documentation
- This tool was inspired by the Knife extension for Cloudstack: knife-cloudstack
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
License
Released under the MIT License. See the LICENSE file for further details.