]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
mgr: api_docs.py: Update for use outside Calamari
authorTim Serong <tserong@suse.com>
Thu, 30 Jun 2016 06:38:11 +0000 (16:38 +1000)
committerJohn Spray <john.spray@redhat.com>
Thu, 29 Sep 2016 16:26:56 +0000 (17:26 +0100)
commiteafe2e94463987caf8cdb2d5315598551916e940
treeda6110a88baf9057fb6d748541a27e1f90552ffc
parentb82533fcb73149886461d35598799572ffc1d771
mgr: api_docs.py: Update for use outside Calamari

The ceph_state module is implemented in C++, and isn't available at
build time, which causes import failures when api_docs.py tries to
import calamari_rest in order to introspect it (MgrModule is eventually
imported, which in turn tries to import ceph_state, which fails unless
we stub it out).

Additional changes:

* Search calamari_rest.urls (not calamari_web)

calamari_web isn't available - it largely held static content in
Calamari, and in turn included calamari_rest.urls.  Here in ceph-mgr we
only have calamari_rest.

* note that --list-urls does nothing, apparently

* Pass actions to old as_view method

django-rest-framework 3.x raises TypeError if the actions argument isn't
passed to as_view().

* Use view().get_view_name() instead of metadata

Attempting to access view().metadata(None)['name'] results in
"AttributeError: 'super' object has no attribute 'metadata'".

* Use somewhat unfriendly field class names

django-rest-framework 3.x seems to have done away with type_label for
fields, so instead use the field's class name, which is somewhat
unfriendly, but arguably better than nothing.

* import global_instance to fix ImportError

This is necessary to avoid what seems to be weird import loops (if this
isn't present, we later get "ImportError: cannot import name
UserRequest" or similar).

* Make api_examples.json optional

This way we at least get bare docs with no examples, rather than no docs
at all.

* Explain how to generate API docs

Signed-off-by: Tim Serong <tserong@suse.com>
src/pybind/mgr/calamari_rest/management/commands/api_docs.py