rados.py: allow long-form names of 'warn' and 'err' as watch levels

Signed-off-by: Dan Mick <dan.mick@inktank.com>
common: Formatter: add flush to bufferlist

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
MonCommands: add new fields: modulename, perms, availability

To help optimize the REST API, we need to know whether the commands
are read (GET) or write (PUT/POST).  However, we also could use that
same info for permission/caps checking.  Add modulename/perms as
the required caps for each command to drive both needs.

The availability field is to control whether a command is displayed/
advertised through the CLI or REST interfaces; some commands aren't
really useful for REST, and we may want to invent REST-only commands;
also, this gives us a way to deprecate commands quickly and leave the
code, should that be desirable.  Make the CLI display only commands
marked with the 'CLI' marker.

Also stop renaming 'help' to 'helptext' in the client.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
ceph.in, ceph_argparse.py: move descsort() to ceph_argparse

Signed-off-by: Dan Mick <dan.mick@inktank.com>
ceph CLI: valid() no longer returns bool, but just exception

The type validation's valid() method was using a combination of
return code and exception to really indicate the same thing;
simplify by only raising on validation error, and change callers
to cope.  validate_one() follows suit.

Also, allow validate() to be called with args that are dicts
(for REST support) rather than bare words.  Rules: 'name':'value'
must both match descriptor's name and validate (through valid() for
the value.  If value is '', it's assumed to be the same as name,
(one can pass, for example, "detail" as one parameter to
REST, but it will still show up as {'detail':''} here).

Tweak validate()'s algorithm a bit in the process, and make
validate_command() exit the bestcmds loop immediately on first
full validation.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
ceph_argparse.py cleanup: simplify some code, error on unused args

Signed-off-by: Dan Mick <dan.mick@inktank.com>
auth: Crypto: add encode_formatted/plaintext() functions

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon,auth: AuthMonitor, KeyRing: add Formatter-dumps of auth info

Signed-off-by: Dan Mick <dan.mick@inktank.com>

auth: KeyRing: encode_formatted() receives a label as first argument

Also, this allows us to standardize formatted output on the AuthMonitor,
so that all output starts with a section 'auth'.  Other subsystems using
the KeyRing class, can specify whatever section they prefer.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: AuthMonitor: early out on bad entity name

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
mon: AuthMonitor: dump formatted and plaintext key on 'get-key'

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: AuthMonitor: formatted output to 'auth get-or-create[-key]'

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: AuthMonitor: improve error reporting for import

Signed-off-by: Dan Mick <dan.mick@inktank.com>
auth: cephx: KeyServer: list secrets to formatter or plaintext

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: add formatted output for several commands:

    pg stat
    pg map
    osd stat
    osd lspools
    osd blacklist ls
    osd create
    osd getmaxosd
    mds compat show

Signed-off-by: Dan Mick <dan.mick@inktank.com>
mon: Monitor: support multiple formatters on some status functions

Commands such as 'mon_status', 'quorum_status', 'sync_status' and
'sync_force' didn't support other formatter besides json.  Regardless of
'--format=foo' being specified, they would always output in json.

This commit changes that behavior, allowing a format to be passed.  These
functions do not output in plain-text however.  Plain-text will default
to 'json' -- the reason: the information they provide are better outputted
in a structured fashion, and I was too lazy to come up with a plain-text
version that could be at least as good.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
mon: Monitor: 'health detail --format=json' should only output JSON

Fixes: #5526

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: formatted output for 'fsid'

Signed-off-by: Dan Mick <dan.mick@inktank.com>
mon: OSDMonitor: osd pool get: move to preproc, add formatted output

Move 'osd pool get' handling to preprocess_command()
It's a read operation; there's no need for it to be in prepare_command().
Also, add formatted output.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: OSDMonitor: formatter output on 'osd map'

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
CompatSet, MDSMap: formatted dumps must avoid numeric tags

Tags made of numbers only confuse XML parsers.  Avoid them.

Signed-off-by: Dan Mick <dan.mick@inktank.com>