]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: rbd-mirroring: Added mirroing info to image info command in RBD CLI
authorRicardo Dias <rdias@suse.com>
Thu, 10 Mar 2016 13:43:18 +0000 (13:43 +0000)
committerRicardo Dias <rdias@suse.com>
Mon, 14 Mar 2016 17:56:38 +0000 (17:56 +0000)
Signed-off-by: Ricardo Dias <rdias@suse.com>
Fixes: #13296
src/tools/rbd/Utils.cc
src/tools/rbd/Utils.h
src/tools/rbd/action/Info.cc

index 49571f446e805d5681192996be36cf7b39e0da2f..1b6df94315c964e6c50e670ae9e815194570f7c3 100644 (file)
@@ -619,5 +619,18 @@ std::string image_id(librbd::Image& image) {
   return string(prefix + strlen(RBD_DATA_PREFIX));
 }
 
+std::string mirror_image_state(rbd_mirror_image_state_t mirror_image_state) {
+  switch (mirror_image_state) {
+    case RBD_MIRROR_IMAGE_DISABLING:
+      return "disabling";
+    case RBD_MIRROR_IMAGE_ENABLED:
+      return "enabled";
+    case RBD_MIRROR_IMAGE_DISABLED:
+      return "disabled";
+    default:
+      return "unknown";
+  }
+}
+
 } // namespace utils
 } // namespace rbd
index 7caf43d7f16fab67784aa21d567bb2e370fe8dd5..0cd8a410b171ffe52dc093afe514c21ae48fed3e 100644 (file)
@@ -100,6 +100,8 @@ int snap_set(librbd::Image &image, const std::string &snap_name);
 
 std::string image_id(librbd::Image& image);
 
+std::string mirror_image_state(rbd_mirror_image_state_t mirror_image_state);
+
 } // namespace utils
 } // namespace rbd
 
index f3d81ac0ad3e300b33072e98d57db0d1ba935bff..3cb60604a911da8804ec38a523f1b2e43e4ae10f 100644 (file)
@@ -71,6 +71,7 @@ static int do_show_info(const char *imgname, librbd::Image& image,
   uint8_t old_format;
   uint64_t overlap, features, flags;
   bool snap_protected = false;
+  librbd::mirror_image_t mirror_image;
   int r;
 
   r = image.stat(info, sizeof(info));
@@ -100,6 +101,13 @@ static int do_show_info(const char *imgname, librbd::Image& image,
       return r;
   }
 
+  if (features & RBD_FEATURE_JOURNALING) {
+    r = image.mirror_image_get(&mirror_image);
+    if (r < 0) {
+      return r;
+    }
+  }
+
   char prefix[RBD_MAX_BLOCK_NAME_SIZE + 1];
   strncpy(prefix, info.block_name_prefix, RBD_MAX_BLOCK_NAME_SIZE);
   prefix[RBD_MAX_BLOCK_NAME_SIZE] = '\0';
@@ -179,6 +187,23 @@ static int do_show_info(const char *imgname, librbd::Image& image,
     }
   }
 
+  if (features & RBD_FEATURE_JOURNALING) {
+    if (f) {
+      f->dump_string("mirroring_state",
+          utils::mirror_image_state(mirror_image.state));
+      if (mirror_image.state != RBD_MIRROR_IMAGE_DISABLED) {
+        f->dump_string("mirroring_global_id", mirror_image.global_id);
+      }
+    } else {
+      std::cout << "\tmirroring state: "
+        << utils::mirror_image_state(mirror_image.state) << std::endl;
+      if (mirror_image.state != RBD_MIRROR_IMAGE_DISABLED) {
+        std::cout << "\tmirroring global id: " << mirror_image.global_id
+          << std::endl;
+      }
+    }
+  }
+
   if (f) {
     f->close_section();
     f->flush(std::cout);