]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/controllers/_rest_controller.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / controllers / _rest_controller.py
index 03e124f9e4fb1dbec6f596bf41a5222bb126bb9d..0224c366f3bcae58fa133dc6899e0a5541f84a67 100644 (file)
@@ -70,6 +70,7 @@ class RESTController(BaseController, skip_registry=True):
         for k, v in cls._method_mapping.items():
             func = getattr(cls, k, None)
             while hasattr(func, "__wrapped__"):
+                assert func
                 func = func.__wrapped__
             if v['resource'] and func:
                 path_params = cls.get_path_param_names()
@@ -83,7 +84,7 @@ class RESTController(BaseController, skip_registry=True):
         result = super().endpoints()
         res_id_params = cls.infer_resource_id()
 
-        for _, func in inspect.getmembers(cls, predicate=callable):
+        for name, func in inspect.getmembers(cls, predicate=callable):
             endpoint_params = {
                 'no_resource_id_params': False,
                 'status': 200,
@@ -94,10 +95,9 @@ class RESTController(BaseController, skip_registry=True):
                 'sec_permissions': hasattr(func, '_security_permissions'),
                 'permission': None,
             }
-
-            if func.__name__ in cls._method_mapping:
+            if name in cls._method_mapping:
                 cls._update_endpoint_params_method_map(
-                    func, res_id_params, endpoint_params)
+                    func, res_id_params, endpoint_params, name=name)
 
             elif hasattr(func, "__collection_method__"):
                 cls._update_endpoint_params_collection_map(func, endpoint_params)
@@ -166,8 +166,8 @@ class RESTController(BaseController, skip_registry=True):
             endpoint_params['permission'] = cls._permission_map[endpoint_params['method']]
 
     @classmethod
-    def _update_endpoint_params_method_map(cls, func, res_id_params, endpoint_params):
-        meth = cls._method_mapping[func.__name__]  # type: dict
+    def _update_endpoint_params_method_map(cls, func, res_id_params, endpoint_params, name=None):
+        meth = cls._method_mapping[func.__name__ if not name else name]  # type: dict
 
         if meth['resource']:
             if not res_id_params: