cthulhu: Refactor RequestCollection to be global

This is instead of having one per ClusterMonitor.  The
idea here is two accomplish two things:
* Expose RequestCollection to ServerMonitor
* Enable REST API to easily list all the requests

The alternative was to instantiate an additional RequestCollection
for servers.  This would have been awkward, because requests on
servers are also "in" zero or more clusters, so the API querying
for requests would have become complicated, touching multiple
RequestCollections.

A separate RequestCollection encapsulated in ServerMonitor would
also have lacked calls to its on_map method for notifications.  This
way, the global RequestCollection gets all notifications, so any
request (whether a cluster one or a server one) can subscribe to anything
its interested in.

Signed-off-by: John Spray <john.spray@inktank.com>
cthulhu: Nicer OsdRequestFactory messages

Special cases for in/out/down/reweight.

Signed-off-by: John Spray <john.spray@inktank.com>
cthulhu: remove workaround for saltstack #11928

The upstream release version now includes the fix,
since 2013.1.2.

Fixes: #8075

Signed-off-by: John Spray <john.spray@inktank.com>
rest_api: add 'CLI' resource

This is to enable REST API consumers to do anything
with the Ceph CLI that we don't currently expose
fully in our API.

It uses the same mechanism as the log tailer: calling
directly out to the cluster from the REST API layer.  That
mechanism is generalised into RemoteViewSet.

Signed-off-by: John Spray <john.spray@inktank.com>
rest_api: refactor salt grain code

Concentrate the access to salt in one place.

Signed-off-by: John Spray <john.spray@inktank.com>
calamari_rest: validate 'status' properly on key

Previously attempts to reject an accepted key would
be accepted but would have no effect: now validate
that the only allowed transitions are pre->[accepted|rejected].

Also remove some comments about handling 404s, as that
has been covered by NotFound exceptions for a while.

Signed-off-by: John Spray <john.spray@inktank.com>
calamari_rest: fix API help_text on event severity

(work around rest_framework limitation and note
 the upstream PR so we can remove workaround when
 that's released)

Signed-off-by: John Spray <john.spray@inktank.com>
Makefile: only run the needed test for api docs

(was running redundant test_touch_urls_in_a_404_way)

Signed-off-by: John Spray <john.spray@inktank.com>
calamari_rest: suppress DeprecationWarnings in 3rd party code

These were annoying spam when running unit tests.

Signed-off-by: John Spray <john.spray@inktank.com>
rest_api: update requests/ and add cancellation

Add a global /request/ URL in addition to the one
which is specific to a cluster (/cluster/<fsid>/request).

Hook up the cancel() method of RequestCollection to a new
/request/<request id>/cancel URL.

Signed-off-by: John Spray <john.spray@inktank.com>
cthulhu: test/debug hooks for jobs

Enabling automated testing of cancellation.

Signed-off-by: John Spray <john.spray@inktank.com>
cthulhu: retired DerivedObjects code

This was the stuff for building structures the v1 API wanted
in response to cluster map changes, and caching them so
that fetching them from the API was quick.

Reasons for this to go away:
 * Moving as much processing as possible outside the cthulhu
   thread: don't mind recalculating in API because API request
   handlers execute in parallel.
 * It was getting out of date wrt ServerMonitor, and hooking
   up all the ServerMonitor code to also trigger DerivedObjects
   was too much footprint for a convenience class (#8503)
 * Originally there was an O(pg_num) scan to generate these
   structures, but now we have pg_summary recalculating them
   on demand is much more reasonable.

Signed-off-by: John Spray <john.spray@redhat.com>
cthulhu: make 'manhole' module optional

One less mandatory dependency.

Signed-off-by: John Spray <john.spray@inktank.com>
calamari_rest: Make graphite module optional

One less mandatory dependency.

Signed-off-by: John Spray <john.spray@inktank.com>
calamari_rest: gracefully degrade without sqlalchemy

Makes sqlalchemy optional: even history will always appear
empty if it is absent.

One less mandatory dependency.

Signed-off-by: John Spray <john.spray@inktank.com>
cthulhu: null persistence with no sqlalchemy

One less mandatory dependency.

Signed-off-by: John Spray <john.spray@inktank.com>
doc: clean up development/

Enables build in a much more lightweight
environment (such as readthedocs.org)

Signed-off-by: John Spray <john.spray@inktank.com>
cthulhu: concentrate salt code in one place

Makes clear our interface with salt, makes our
modules importable without salt (useful for
e.g. building docs with sphinx autodoc)

Signed-off-by: John Spray <john.spray@inktank.com>
cthulhu: handle missing zerorpc

So that we can import but not run the code
if zerorpc is not installed.  This is useful
because zerorpc depends on zeromq, which is
a binary dependency.

Signed-off-by: John Spray <jspray@redhat.com>
cthulhu: cope with missing msgpack

Signed-off-by: John Spray <jspray@redhat.com>