For those who need to deal with Marathon and prefer command line rather than graphical administration I've written a CLI in python. It's based on the marathon REST API and can be used for scripting by checking the exit status: 0 ok, 2 failed.
Despite the 'Marathonctl' CLI distributed by mesosphere team is good enough, this one doesn't need to be compiled and works in any architecture with python installed. Also I've been without using python for a long time and this has been a good opportunity to get in touch again.
You can download freely from mi github account and follow the instructions to install it.
Installation
Needs a python interpreter (tested in 2.x) and this modules- ConfigParser
- requests
- json
Configuration
You can supply a configuration file from the CLI or use the default one under ~./.pmcli.cfg. The format is:
[default]
host = <marathonhost>
user = <username>
password = <password>
format = <output format>
port = <marathon port>
format can be:
human: simplified columnsjson: json on one linejsonpp: json pretty printed, defaultraw: the same response from Marathon, without post-parsing
You can have different marathon hosts (profiles) in the file and specify the one to use from the CLI with the '-p' switch
[default]
host = <marathonhost1>
user = <username1>
password = <password1>
format = <output format1>
port = <marathon port1>
[profile2]
host = <marathonhost2>
user = <username2>
password = <password2>
format = <output format2>
port = <marathon port2>
Usage
pmcli <flags...> [section] [action]
├─ app
│ └─┬─ list - list all apps
│ ├─ versions [appid] - list all versions of 'appid'
│ ├─ show [appid] - show config and status of 'appid' (latest version)
│ ├─ showversion [appid] [versionid] - show config and status of 'appid' and 'versionid'
│ ├─ create [jsonfile] - deploy application defined in jsonfile
│ ├─ update [appid] [jsonfile] - update application 'appid' as defined in jsonfile
│ ├─ change [opt] [appid] [value] - change appid option 'opt' to 'value'
│ ├─ scale [appid] [N] - Scale application 'appid' to have N instances
│ ├─ restart [appid] - restart app of 'appid'
│ └─ destroy [appid] - destroy and remove all instances of 'appid'
│
├─ task
│ └─┬─ list - list all tasks
│ ├─ show [appid] - list tasks of app of 'appid'
│ ├─ kill [appid] - kill all tasks of 'appid'
│ ├─ killtask [appid] [taskid] - kill task 'taskid' of app 'appid'
│ └─ queue - list all queued tasks
│
├─ group
│ └─┬─ list - list all groups
│ ├─ show [groupid] - list groups in 'groupid'
│ ├─ create [jsonfile] - create a group defined in jsonfile
│ ├─ update [groupid] [jsonfile] - update 'groupid' as defined in jsonfile
│ └─ destroy [groupid] - destroy group of 'groupid'
│
├─ deploy
│ └─┬─ list - list all active deploys
│ └─ destroy [deployid] - cancel deployment of 'deployid'
│
└─ marathon
└─┬─ leader - get the current Marathon leader
├─ abdicate - force the current leader to relinquish control
├─ ping - ping Marathon master host[s]
├─ info - get info about marathon instance
└─ metrics - get marathon metrics
Flags
-c [config file]
-h [host]
-P [port] Marathon port
-u [user:password] (separated by colon)
-p [profile] (profile used in the config file)
-o [output file] (json format. Overrides -f flag)
-f [format]
human (simplified columns)
json (json on one line)
jsonpp (json pretty printed, default)
raw (unprocessed reply from Marathon)
-F Force operation
Any feedback will be appreciated. I'm not developer, so any idea or suggestion with the code will be also welcomed.
No comments:
Post a Comment