Skip to content
This repository was archived by the owner on May 11, 2021. It is now read-only.
This repository was archived by the owner on May 11, 2021. It is now read-only.

staticly generate the api #2

@sebastian-philipp

Description

@sebastian-philipp

See ceph/ceph#28837 (comment) for the background of this issue

This issue itself consists of two parts that need to be handled independently:

.h definitions

See ceph/ceph#28837 (comment)

MGR modules

mgr modules need to be executed and the commands need to be gathered at runtime

(venv) ➜  mgr git:(orchestrator-c-v-inventory) ✗ cat api.py 
import sys
import json

from unittest import mock
class M(object):
    def __init__(self, *args):
        self._ceph_get_version = mock.Mock()

class B(object):
    def __init__(self, *args):
        self._ceph_get_version = mock.Mock()

#@patch('mgr_module.ceph_module')
def foo():
    cm = mock.Mock()
    cm.BaseMgrModule = M
    cm.BaseMgrStandbyModule = B
    sys.modules['ceph_module'] = cm
    sys.modules['OpenSSL'] = mock.Mock()
    
    #import orchestrator_cli
    import dashboard
    import mgr_module
    def subclass(x):
        try:
            return issubclass(x, M)
        except TypeError:
            return False
    mgr_mod = dashboard
    ms = [c for c in mgr_mod.__dict__.values()  if subclass(c)]
    [m] = ms
    print(json.dumps(m.COMMANDS, indent=2))
    print(json.dumps(mgr_module.CLICommand.dump_cmd_list(), indent=2))
    


if __name__ == '__main__':
  foo()

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions