]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix rbd remote calls 46531/head
authorPere Diaz Bou <pdiazbou@redhat.com>
Thu, 30 Jun 2022 11:44:49 +0000 (13:44 +0200)
committerPere Diaz Bou <pdiazbou@redhat.com>
Fri, 1 Jul 2022 08:26:09 +0000 (10:26 +0200)
Signed-off-by: Pere Diaz Bou <pdiazbou@redhat.com>
src/pybind/mgr/dashboard/services/rbd.py

index d47c8a2e9fd7de529a693e20298bad3387c74854..cb83370096a9ad112d72abd9278e5d8a147e3ff0 100644 (file)
@@ -38,13 +38,32 @@ class MIRROR_IMAGE_MODE(IntEnum):
     snapshot = rbd.RBD_MIRROR_IMAGE_MODE_SNAPSHOT
 
 
-def _rbd_support_remote(method_name: str, *args, **kwargs):
+def _rbd_support_remote(method_name: str, *args, level_spec: str = '',
+                        interval: str = '', start_time: str = '', **kwargs):
+    # pacific specific implementation of rbd mirror schedule snapshot remote methods
+    prefixes = {
+        'mirror_snapshot_schedule_status': 'rbd mirror snapshot schedule status',
+        'mirror_snapshot_schedule_add': 'rbd mirror snapshot schedule add',
+        'mirror_snapshot_schedule_remove': 'rbd mirror snapshot schedule remove',
+    }
+    cmd = {
+        'level_spec': level_spec,
+        'prefix': prefixes[method_name]
+    }
+    if interval:
+        cmd['interval'] = interval
+    if start_time:
+        cmd['start_time'] = start_time
+
     try:
-        return mgr.remote('rbd_support', method_name, *args, **kwargs)
+        res = mgr.remote('rbd_support', 'handle_command', None, cmd, *args, **kwargs)
+        return res
     except ImportError as ie:
         raise DashboardException(f'rbd_support module not found {ie}')
     except RuntimeError as ie:
         raise DashboardException(f'rbd_support.{method_name} error: {ie}')
+    except ValueError as ie:
+        raise DashboardException(f'rbd_support handle_command {prefixes[method_name]} error: {ie}')
 
 
 def format_bitmask(features):
@@ -493,9 +512,9 @@ class RbdMirroringService:
 
     @classmethod
     def snapshot_schedule_add(cls, image_spec: str, interval: str):
-        _rbd_support_remote('mirror_snapshot_schedule_add', image_spec,
-                            str(RBDSchedulerInterval(interval)))
+        _rbd_support_remote('mirror_snapshot_schedule_add', level_spec=image_spec,
+                            interval=str(RBDSchedulerInterval(interval)))
 
     @classmethod
     def snapshot_schedule_remove(cls, image_spec: str):
-        _rbd_support_remote('mirror_snapshot_schedule_remove', image_spec)
+        _rbd_support_remote('mirror_snapshot_schedule_remove', level_spec=image_spec)