Skip to content

Getting Started

Rohit Yadav edited this page Mar 14, 2019 · 8 revisions

Installation

To install the modern Apache CloudStack cloudmonkey or cmk, please download the binary from the latest release: https://github.com/apache/cloudstack-cloudmonkey/releases

Install on Linux and Mac OSX

Download the binary for Linux or Mac based on your platform and move it to a directory that is on $PATH such as /usr/local/bin. For example:

sudo wget <file link> -O /usr/local/bin/cmk
sudo chmod +x /usr/local/bin/cmk

Install on Windows

Download the Windows specific .exe executable file and copy it to a directory which on the cmd's PATH such as C:\Windows\System32\. Launch cmd.exe or powershell and see if you can run/access cmk.exe.

First steps

The default server profile has the name localcloud with defaults (such as url and credentials) set to a locally running CloudStack server. Start cmk, create a new server profile, configure your CloudStack server's API endpoint and run sync, for example:

$ cmk
Apache CloudStack 🐵 CloudMonkey 6.0.0
Report issues: https://github.com/apache/cloudstack-cloudmonkey/issues

(localcloud) 🐱 > set profile mycloud
Loaded server profile: mycloud
Url:         http://localhost:8080/client/api
Username:    admin
Domain:      /
API Key:     
Total APIs:  595    

(mycloud) 🐱 > set url http://myprovider.cloud/client/api
(mycloud) 🐱 > set username myusername
(mycloud) 🐱 > set password mypassword
(mycloud) 🐱 > sync
Discovered 610 APIs

You can also use the set command to set the various server profile specific options. The cloudmonkey configuration is stored at ~/.cmk/config file. The ~/.cmk directory also contains the API cache at ~/.cmk/profiles.

Getting help

Help for any API command can be obtained using <cmd> -h, for example:

> help
usage: cmk [flags] [commands|apis] [-h]

CloudMonkey (cmk) 🐵 is a command line interface for Apache CloudStack.

Allowed flags:
  -h        Show this help message or API doc when specified after an API
  -v        Print version
  -o        API response output format: json, text, table, column, csv
  -p        Server profile
  -d        Enable debug mode

Default commands:
  exit      Exits
  help      Help
  set       Configures options for cmk
  sync      Discovers and updates APIs
  version   Version info

> list users -h
> help listUsers

A typical help doc for an api will list all available acceptable arguments and required arguments.

Example help for listUsers API:

> list users  -h
listUsers: Lists user accounts
API Params               Type     Description
==========               ====     ===========
account                  string   list resources by account. Must be used w
                                  ith the domainId parameter.
accounttype              long     List users by account type. Valid types i
                                  nclude admin, domain-admin, read-only-ad
                                  min, or user.
domainid                 uuid     list only resources belonging to the doma
                                  in specified
id                       uuid     List user by ID.
isrecursive              boolean  defaults to false, but if true, lists all
                                   resources from the parent specified by 
                                  the domainId till leaves.
keyword                  string   List by keyword
listall                  boolean  If set to false, list only resources belo
                                  nging to the command's caller; if set to
                                   true - list resources that the caller i
                                  s authorized to see. Default value is fa
                                  lse
page                     integer  
pagesize                 integer  
state                    string   List users by state of the user account.
username                 string   List user by the username

Making API requests

Try autocompletion using tabbing:

> <tab><tab>
> list <tab><tab>
> list users <tab><tab> # for options
> list users <press enter>
> list users
{
  "count": 1,
  "user": [
    {
      "account": "admin",
      "accountid": "79665239-3cd4-11e9-bf33-f4d1082409e6",
      "accounttype": 1,
      "apikey": "...redacted...",
      "created": "2019-03-02T15:48:07+0000",
      "domain": "ROOT",
      "domainid": "7965d079-3cd4-11e9-bf33-f4d1082409e6",
      "email": "admin@mailprovider.com",
      "firstname": "Admin",
      "id": "7966afa9-3cd4-11e9-bf33-f4d1082409e6",
      "iscallerchilddomain": false,
      "isdefault": true,
      "lastname": "User",
      "roleid": "852a28b1-3cd4-11e9-bf33-f4d1082409e6",
      "rolename": "Root Admin",
      "roletype": "Admin",
      "state": "enabled",
      "username": "admin",
      "usersource": "native"
    }
  ]
}

Consult the API docs at http://cloudstack.apache.org/api.html

Clone this wiki locally
You can’t perform that action at this time.