]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: export ImageOptions print operator
authorMykola Golub <to.my.trociny@gmail.com>
Sat, 14 Oct 2017 15:54:28 +0000 (18:54 +0300)
committerMykola Golub <to.my.trociny@gmail.com>
Mon, 6 Nov 2017 08:26:37 +0000 (10:26 +0200)
(so it could be used for logging image options)

Signed-off-by: Mykola Golub <to.my.trociny@gmail.com>
src/librbd/internal.cc
src/librbd/internal.h

index cb01b57fac7a8c2c15625b9e23f1adffb826277a..9c24bb7f818462ef1af3df09e1a8196740200265 100644 (file)
@@ -327,31 +327,6 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     }
   }
 
-  std::ostream &operator<<(std::ostream &os, const ImageOptions &opts) {
-    os << "[";
-
-    const char *delimiter = "";
-    for (auto &i : IMAGE_OPTIONS_TYPE_MAPPING) {
-      if (i.second == STR) {
-       std::string val;
-       if (opts.get(i.first, &val) == 0) {
-         os << delimiter << image_option_name(i.first) << "=" << val;
-         delimiter = ", ";
-       }
-      } else if (i.second == UINT64) {
-       uint64_t val;
-       if (opts.get(i.first, &val) == 0) {
-         os << delimiter << image_option_name(i.first) << "=" << val;
-         delimiter = ", ";
-       }
-      }
-    }
-
-    os << "]";
-
-    return os;
-  }
-
   void image_options_create(rbd_image_options_t* opts)
   {
     image_options_ref* opts_ = new image_options_ref(new image_options_t());
@@ -2355,3 +2330,29 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
 
 
 }
+
+std::ostream &operator<<(std::ostream &os, const librbd::ImageOptions &opts) {
+  os << "[";
+
+  const char *delimiter = "";
+  for (auto &i : librbd::IMAGE_OPTIONS_TYPE_MAPPING) {
+    if (i.second == librbd::STR) {
+      std::string val;
+      if (opts.get(i.first, &val) == 0) {
+        os << delimiter << librbd::image_option_name(i.first) << "=" << val;
+        delimiter = ", ";
+      }
+    } else if (i.second == librbd::UINT64) {
+      uint64_t val;
+      if (opts.get(i.first, &val) == 0) {
+        os << delimiter << librbd::image_option_name(i.first) << "=" << val;
+        delimiter = ", ";
+      }
+    }
+  }
+
+  os << "]";
+
+  return os;
+}
+
index d6401380557be25ed800f81e8eebb2640b9acddc..b08fab3be0dedebdcc58d3f56d3a93bd0ec8532f 100644 (file)
@@ -172,4 +172,6 @@ namespace librbd {
 
 }
 
+std::ostream &operator<<(std::ostream &os, const librbd::ImageOptions &opts);
+
 #endif