AdminSocket users: use generic formatting

All call() routines get a format parameter; all places where
JSONFormatter was created get a new_formatter() instead.
'plain' formatting is unsupported, and help is forced to be
'json-pretty' as it was.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Formatter, admin_socket: make default formatter be json-pretty

If not given, default to json-pretty; if given but not equal to one
of the formatter choices, return NULL as before.  Remove defaulting
code in admin_socket.cc in favor of this.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
In general, flush in caller of dump worker rather than worker

This allows easier refactoring of workers (no dual flushes when code
changes).

Signed-off-by: Dan Mick <dan.mick@inktank.com>
ceph_argparse.py, ceph.in: validate_command: stop handling format

We were passing the entire parsed_args Namespace just to look at
and tack on 'format', and that's kinda silly; do it in the callers
instead.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
ceph.in: admin_socket() now validates command and passes format

Signed-off-by: Dan Mick <dan.mick@inktank.com>
ceph.in: clean up help, fix partial matching on all help

Remove --help-all; too much effort for low benefit

Signed-off-by: Dan Mick <dan.mick@inktank.com>
OSD: provide newer command descs with module/perm/avail

Signed-off-by: Dan Mick <dan.mick@inktank.com>
OSD: "tell <osd.n>" version, bench, dump_pg_recovery_stats: formatted

Signed-off-by: Dan Mick <dan.mick@inktank.com>
PG: add formatted output to pg <pgid> query, list_missing

Signed-off-by: Dan Mick <dan.mick@inktank.com>
mon/PGMonitor: reset in-core PGMap if on-disk format changes

We might have a sequence like:

- start mon, load pgmap 100
- sync
 - including a format upgrade at say v 150
- refresh
 - see format_version==1, and try read pgmap:101 as new format

This simply clears our in-memory state if we see that the format has
changed.  That will make update_from_paxos reload the latest and prevent
it from walking through the old and useless inc updates.

Note: this does not affect the auth monitor because we unconditionally
load the latest map in update_from_paxos on upgrade.  Also, the upgrade
there wasn't a format change--just a translation of cap strings from the
old to new style.

Fixes: #5764
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
ceph_rest_api.py: obtain and handle tell <osd-or-pgid> commands

Contact an OSD that's up to get a list of the commands, and use
them to add to the URL map.

Special treatment throughout for these commands:

* hack the help signature dump
* keep a 'flavor' per command to allow special handler() processing
* strip off 'tell/<target>' when constructing command
* allow multiple dicts with the same url
  (the parameters and get/put methods can change)
* because of above, method must be validated in handler()
* validate the given OSD
* calculate target for command (mon, osd, pg)

Unrelated: make method_dict into global METHOD_DICT

Signed-off-by: Dan Mick <dan.mick@inktank.com>
ceph_argparse, mon: make "tell <pgid>" work (duplicating "pg <pgid>")

It's a wad of special cases, but it implements "tell <pgid>" such that
it has the same effect as "pg <pgid>".

Signed-off-by: Dan Mick <dan.mick@inktank.com>
ceph_argparse.py: make find_cmd_target handle tell <pgid>

Signed-off-by: Dan Mick <dan.mick@inktank.com>
ceph_rest_api.py: cleanup, more docstrings, unused vars

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Merge remote-tracking branch 'gh/wip-tell-unified' into next

Reviewed-by: Sage Weil <sage@inktank.com>
PendingReleaseNotes: note on 'ceph tell <pgid> ...'

Signed-off-by: Sage Weil <sage@inktank.com>
remove unused fiemap code

Signed-off-by: Sage Weil <sage@inktank.com>
mon/MonCap: mds needs to subscribe to the osdmap

Usually it can get it from the OSD, but it assumes the mon will also share
and doesn't behave when it does not.

Fixes: #5767
Signed-off-by: Sage Weil <sage@inktank.com>
osd: humor coverity

CID 1058392: Out-of-bounds access (OVERRUN_DYNAMIC) [select issue]

CID 1058391 (#1 of 1): Out-of-bounds access (OVERRUN)
32. alloc_strlen: Allocating insufficient memory for the terminating null of the string.

CID 1058390 (#1 of 1): Unchecked return value from library (CHECKED_RETURN)
13. check_return: Calling function "this->class_handler->open_all_classes()" without checking return value. It wraps a library function that may fail and return an error code. [show details]
    	14. unchecked_value: No check of the return value of "this->class_handler->open_all_classes()".

Signed-off-by: Sage Weil <sage@inktank.com>
ceph.in: make osdids() (and mon, mds) work on old mons

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>