Skip to content

doc: Add a generated reference of all mon commands.#33886

Merged
sebastian-philipp merged 4 commits intoceph:masterfrom
sebastian-philipp:doc-mon-command-api
May 13, 2020
Merged

doc: Add a generated reference of all mon commands.#33886
sebastian-philipp merged 4 commits intoceph:masterfrom
sebastian-philipp:doc-mon-command-api

Conversation

@sebastian-philipp
Copy link
Contributor

@sebastian-philipp sebastian-philipp commented Mar 11, 2020

We gather the MGR commands by importing all modules and then concat all Module.COMMAND lists.

Then we use the C preprocessor to parse the MonCommands.h and then pretend the output to be Python. Which actually works.

Then we generate a ReST document which contains all mon commands.

Fixes: sebastian-philipp/ceph-command-api#2

Signed-off-by: Sebastian Wagner sebastian.wagner@suse.com

Depends on

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

Show available Jenkins commands
  • jenkins retest this please
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard backend
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

@sebastian-philipp sebastian-philipp requested a review from a team as a code owner March 11, 2020 13:59
@sebastian-philipp sebastian-philipp force-pushed the doc-mon-command-api branch 2 times, most recently from 5d2f005 to 981616b Compare March 11, 2020 14:04
@sebastian-philipp
Copy link
Contributor Author

jenkins render docs

@ceph-jenkins
Copy link
Collaborator

Doc render available at http://docs.ceph.com/ceph-prs/33886/

@sebastian-philipp
Copy link
Contributor Author

@sebastian-philipp
Copy link
Contributor Author

jenkins retest this please

@sebastian-philipp
Copy link
Contributor Author

ImportError while loading conftest '/home/jenkins-build/build/workspace/ceph-pull-requests/src/pybind/mgr/dashboard/conftest.py'.
__init__.py:39: in <module>
    from .module import Module, StandbyModule  # noqa: F401
module.py:55: in <module>
    from .plugins import feature_toggles, debug  # noqa # pylint: disable=unused-import
plugins/feature_toggles.py:16: in <module>
    from ..controllers.cephfs import CephFS
controllers/cephfs.py:9: in <module>
    import cephfs
E   ModuleNotFoundError: No module named 'cephfs'

@liewegas
Copy link
Member

This is great!

  • can we show args positionally instead of with --foo=bar syntax? i'm not even sure if the latte rworks for the n=N args
  • hide the ones with HIDDEN flag?

@sebastian-philipp
Copy link
Contributor Author

This is great!

  • can we show args positionally instead of with --foo=bar syntax? i'm not even sure if the latte rworks for the n=N args

osd pool create doesn't work with positional arguments:

ceph osd pool create --pool=poolname --pg_num=1 --pgp_num=1 --pool_type=choice --erasure_code_profile=string --rule=string --expected_num_objects=1 --size=1 --pg_num_min=1 --autoscale_mode=choice --target_size_bytes=1 --target_size_ratio=0.0

because of:

ceph osd pool create poolname 1 1 choice string string 11 1 choice 1 0.0
  • hide the ones with HIDDEN flag?

@sebastian-philipp
Copy link
Contributor Author

I'd like to depend on #32319 here, as I need @jan--f 's tox.ini enhancements.

@sebastian-philipp
Copy link
Contributor Author

This is great!

  • can we show args positionally instead of with --foo=bar syntax? i'm not even sure if the latte rworks for the n=N args

Fixed for the simple commands

  • hide the ones with HIDDEN flag?

Fixed

@sebastian-philipp
Copy link
Contributor Author

jenkins render docs

@sebastian-philipp
Copy link
Contributor Author

jenkins test make check

@ceph-jenkins
Copy link
Collaborator

Doc render available at http://docs.ceph.com/ceph-prs/33886/

@sebastian-philipp
Copy link
Contributor Author

jenkins test make check

@sebastian-philipp
Copy link
Contributor Author

anyone wants to review this?

@tchaikov
Copy link
Contributor

tchaikov commented Apr 8, 2020

@sebastian-philipp i hate to say "sorry". but sorry for the latency. it's on my list.

@sebastian-philipp
Copy link
Contributor Author

ImportError while loading conftest '/home/jenkins-build/build/workspace/ceph-pull-requests/src/pybind/mgr/dashboard/conftest.py'.
__init__.py:39: in <module>
    from .module import Module, StandbyModule  # noqa: F401
module.py:15: in <module>
    from mgr_module import MgrModule, MgrStandbyModule, Option, CLIWriteCommand
../mgr_module.py:14: in <module>
    import rados
E   ModuleNotFoundError: No module named 'rados'

@LenzGr
Copy link
Contributor

LenzGr commented Apr 14, 2020

@tchaikov with our move of the documentation to readthedocs.io, is this still feasible? Or would this be part of the locally hosted API documentation then?

@tchaikov
Copy link
Contributor

@LenzGr yeah, probably the latter. as it'd be difficult to sphinxize following command

$vdir/bin/python $TOPDIR/doc/scripts/gen_mon_command_api.py > $TOPDIR/doc/api/mon_command_api.rst

if we cannot think of a way to do so, we will have to keep this part of document in docs.ceph.com. we could link the RTD document to it though.

Copy link
Contributor

@zdover23 zdover23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. proceed.

@sebastian-philipp
Copy link
Contributor Author

make check:

==================================== ERRORS ====================================
____________________ ERROR collecting tests/test_health.py _____________________
ImportError while importing test module '/home/jenkins-build/build/workspace/ceph-pull-requests/src/pybind/mgr/insights/tests/test_health.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
__init__.py:7: in <module>
    from .module import Module
module.py:6: in <module>
    from mgr_module import MgrModule, CommandResult
../mgr_module.py:1: in <module>
    import ceph_module  # noqa
E   ModuleNotFoundError: No module named 'ceph_module'

This is fixed in #34738

@LenzGr
Copy link
Contributor

LenzGr commented Apr 30, 2020

Nice work. I wonder if it would be possible to add at least one hierarchy level here, to improve the document structure by putting e.g. all dashboard commands under a headline?

Copy link
Member

@epuertat epuertat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome! Kudos to you! Left a few suggestions.

Other question I had is about changes to stand-alone dashboard unit tests (don't they require anything else to be built or tested, just tox -e py3, right?).

Comment on lines +58 to +57
t = {
'CephInt': 'int',
'CephString': 'str',
'CephChoices': 'str',
'CephPgid': 'str',
'CephOsdName': 'str',
'CephPoolname': 'str',
'CephObjectname': 'str',
'CephUUID': 'str',
'CephEntityAddr': 'str',
'CephIPAddr': 'str',
'CephName': 'str',
'CephBool': 'bool',
'CephFloat': 'float',
'CephFilepath': 'str',
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For #34840 I've been thinking how to get this. As all Ceph Types are subclasses of CephArgtype we could simply exploit this and add an @abstractproperty type to the CephArgtype:

class CephInt(CephArgtype):
    py_type = int

...
CEPH_TYPE_TO_PY_TYPE = {CephType.__class__ : CephType.py_type for CephType in CephArgType.__subclassess__}

Copy link
Contributor Author

@sebastian-philipp sebastian-philipp May 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, for now, I'd like not to depend on ceph_argparse.py in the docs. the location is a bit awkward and it has no setup.py, which makes it impossible to add ceph_argparse in the requirements.txt.

I really want to move it to python-common first

Comment on lines +75 to +74
bash_example = {
'CephInt': '1',
'CephString': 'string',
'CephChoices': 'choice',
'CephPgid': '0',
'CephOsdName': 'osd.0',
'CephPoolname': 'poolname',
'CephObjectname': 'objectname',
'CephUUID': 'uuid',
'CephEntityAddr': 'entityaddr',
'CephIPAddr': '0.0.0.0',
'CephName': 'name',
'CephBool': 'true',
'CephFloat': '0.0',
'CephFilepath': '/path/to/file',
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we can also add this metadata to there.

@epuertat
Copy link
Member

Nice work. I wonder if it would be possible to add at least one hierarchy level here, to improve the document structure by putting e.g. all dashboard commands under a headline?

Yeah, I thought the same: what about nesting by 1st & 2nd tokens?

@sebastian-philipp
Copy link
Contributor Author

Nice work. I wonder if it would be possible to add at least one hierarchy level here, to improve the document structure by putting e.g. all dashboard commands under a headline?

Yeah, I thought the same: what about nesting by 1st & 2nd tokens?

Not sure about it, This would generate a lot of single-entry pages. Still I can see the point for grouping the dashboard and orchestrator, but for all others as well?

We gather the MGR commands by importing all modules and then
concat all `Module.COMMAND` lists.

Then we use the C preprocessor to parse the MonCommands.h and
then pretent to output to be Python. Which actually works.

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Generate a ReST document which contains all mon commands.

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
@sebastian-philipp
Copy link
Contributor Author

@sebastian-philipp sebastian-philipp merged commit 79d88ad into ceph:master May 13, 2020
@tchaikov tchaikov mentioned this pull request Jan 6, 2021
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

staticly generate the api

7 participants