]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Change pool info API endpoint
authorStephan Müller <smueller@suse.com>
Mon, 2 Mar 2020 10:08:23 +0000 (11:08 +0100)
committerStephan Müller <smueller@suse.com>
Mon, 9 Mar 2020 11:35:58 +0000 (12:35 +0100)
Moves the "_info" endpoint of pool into an equivalent
UI-API call with the name "info".

Added three more attributes to the info dict which enables the dashboard
to only call info to get all the needed data, currently three calls will
be used to do that.

Removed pool_name parameter as the outcome was not used.

Updated the tests and related angular files accordingly.

Fixes: https://tracker.ceph.com/issues/44371
Signed-off-by: Stephan Müller <smueller@suse.com>
qa/tasks/mgr/dashboard/test_pool.py
src/pybind/mgr/dashboard/controllers/pool.py
src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/models/pool-form-info.ts

index 8d403d89a1d51405a3959465f5f9397e9c611b3d..969318d2a94b3b79496cf1396cf7e992ecd05093 100644 (file)
@@ -400,7 +400,7 @@ class PoolTest(DashboardTestCase):
         })
 
     def test_pool_info(self):
-        self._get("/api/pool/_info")
+        self._get("/ui-api/pool/info")
         self.assertSchemaBody(JObj({
             'pool_names': JList(six.string_types),
             'compression_algorithms': JList(six.string_types),
@@ -412,4 +412,6 @@ class PoolTest(DashboardTestCase):
             'crush_rules_erasure': JList(JObj({}, allow_unknown=True)),
             'pg_autoscale_default_mode': six.string_types,
             'pg_autoscale_modes': JList(six.string_types),
+            'erasure_code_profiles': JList(JObj({}, allow_unknown=True)),
+            'used_rules': JObj({}, allow_unknown=True),
         }))
index ac3ab1189b7f9d17be670c444814b437e2574b1d..275c59c44a9207e263b483181226472ee5278c88 100644 (file)
@@ -4,7 +4,7 @@ from __future__ import absolute_import
 import time
 import cherrypy
 
-from . import ApiController, RESTController, Endpoint, ReadPermission, Task
+from . import ApiController, RESTController, Endpoint, ReadPermission, Task, UiApiController
 from .. import mgr
 from ..security import Scope
 from ..services.ceph_service import CephService
@@ -205,15 +205,19 @@ class Pool(RESTController):
     def configuration(self, pool_name):
         return RbdConfiguration(pool_name).list()
 
+
+@UiApiController('/pool', Scope.POOL)
+class PoolUi(Pool):
     @Endpoint()
     @ReadPermission
-    def _info(self, pool_name=''):
-        # type: (str) -> dict
+    def info(self):
         """Used by the create-pool dialog"""
+        osd_map_crush = mgr.get('osd_map_crush')
+        options = mgr.get('config_options')['options']
 
         def rules(pool_type):
             return [r
-                    for r in mgr.get('osd_map_crush')['rules']
+                    for r in osd_map_crush['rules']
                     if r['type'] == pool_type]
 
         def all_bluestore():
@@ -222,12 +226,23 @@ class Pool(RESTController):
 
         def get_config_option_enum(conf_name):
             return [[v for v in o['enum_values'] if len(v) > 0]
-                    for o in mgr.get('config_options')['options']
+                    for o in options
                     if o['name'] == conf_name][0]
 
+        used_rules = {}
+        pool_names = []
+        for p in self._pool_list():
+            name = p['pool_name']
+            rule = p['crush_rule']
+            pool_names.append(name)
+            if rule in used_rules:
+                used_rules[rule].append(name)
+            else:
+                used_rules[rule] = [name]
+
         mgr_config = mgr.get('config')
-        result = {
-            "pool_names": [p['pool_name'] for p in self._pool_list()],
+        return {
+            "pool_names": pool_names,
             "crush_rules_replicated": rules(1),
             "crush_rules_erasure": rules(3),
             "is_all_bluestore": all_bluestore(),
@@ -237,9 +252,6 @@ class Pool(RESTController):
             "compression_modes": get_config_option_enum('bluestore_compression_mode'),
             "pg_autoscale_default_mode": mgr_config['osd_pool_default_pg_autoscale_mode'],
             "pg_autoscale_modes": get_config_option_enum('osd_pool_default_pg_autoscale_mode'),
+            "erasure_code_profiles": CephService.get_erasure_code_profiles(),
+            "used_rules": used_rules
         }
-
-        if pool_name:
-            result['pool_options'] = RbdConfiguration(pool_name).list()
-
-        return result
index 20ff612d65d39826c6498dd8df8d3a0778f8b0e0..6450bc6ade29c6ba38ed65f514f2389cd9407ba5 100644 (file)
@@ -37,7 +37,7 @@ describe('PoolService', () => {
 
   it('should call getInfo', () => {
     service.getInfo().subscribe();
-    const req = httpTesting.expectOne(`${apiPath}/_info`);
+    const req = httpTesting.expectOne(`ui-${apiPath}/info`);
     expect(req.request.method).toBe('GET');
   });
 
index 4d85ec483374fd63b00a09388708f4805e9ff43b..d4382a631e5d220d7124fe1523c0078c93621d0b 100644 (file)
@@ -59,8 +59,8 @@ export class PoolService {
     );
   }
 
-  getInfo(pool_name?: string) {
-    return this.http.get(`${this.apiPath}/_info` + (pool_name ? `?pool_name=${pool_name}` : ''));
+  getInfo() {
+    return this.http.get(`ui-${this.apiPath}/info`);
   }
 
   list(attrs: string[] = []) {
index 4f5b653df38d27b5b63580786da56debd3f47fee..16fa24ca9c7d2dba440f51c04576ee13468c8feb 100644 (file)
@@ -1,4 +1,5 @@
 import { CrushRule } from './crush-rule';
+import { ErasureCodeProfile } from './erasure-code-profile';
 
 export class PoolFormInfo {
   pool_names: string[];
@@ -11,4 +12,6 @@ export class PoolFormInfo {
   crush_rules_erasure: CrushRule[];
   pg_autoscale_default_mode: string;
   pg_autoscale_modes: string[];
+  erasure_code_profiles: ErasureCodeProfile[];
+  used_rules: { [rule_name: string]: string[] };
 }