]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: add '--mirror-image-mode' optional to image creation actions
authorJason Dillaman <dillaman@redhat.com>
Tue, 21 Apr 2020 00:37:56 +0000 (20:37 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 23 Apr 2020 17:19:49 +0000 (13:19 -0400)
This allows the user to enable mirroring while creating, cloning,
copying, importing, or migrating an image.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/cli/rbd/help.t
src/tools/rbd/ArgumentTypes.cc
src/tools/rbd/ArgumentTypes.h
src/tools/rbd/Utils.cc

index 1f9aff38fb957d4d54074e13ac6b8f20b2c9a20a..fc2bc57749cfd7415d049473b755c688a8d5d927 100644 (file)
                    [--image-feature <image-feature>] [--image-shared] 
                    [--stripe-unit <stripe-unit>] [--stripe-count <stripe-count>] 
                    [--data-pool <data-pool>] 
+                   [--mirror-image-mode <mirror-image-mode>] 
                    [--journal-splay-width <journal-splay-width>] 
                    [--journal-object-size <journal-object-size>] 
                    [--journal-pool <journal-pool>] 
     --stripe-unit arg         stripe unit in B/K/M
     --stripe-count arg        stripe count
     --data-pool arg           data pool
+    --mirror-image-mode arg   mirror image mode [journal or snapshot]
     --journal-splay-width arg number of active journal objects
     --journal-object-size arg size of journal objects [4K <= size <= 64M]
     --journal-pool arg        pool for journal objects
                   [--image-feature <image-feature>] [--image-shared] 
                   [--stripe-unit <stripe-unit>] [--stripe-count <stripe-count>] 
                   [--data-pool <data-pool>] 
+                  [--mirror-image-mode <mirror-image-mode>] 
                   [--journal-splay-width <journal-splay-width>] 
                   [--journal-object-size <journal-object-size>] 
                   [--journal-pool <journal-pool>] [--sparse-size <sparse-size>] 
     --stripe-unit arg            stripe unit in B/K/M
     --stripe-count arg           stripe count
     --data-pool arg              data pool
+    --mirror-image-mode arg      mirror image mode [journal or snapshot]
     --journal-splay-width arg    number of active journal objects
     --journal-object-size arg    size of journal objects [4K <= size <= 64M]
     --journal-pool arg           pool for journal objects
                     [--image-feature <image-feature>] [--image-shared] 
                     [--stripe-unit <stripe-unit>] 
                     [--stripe-count <stripe-count>] [--data-pool <data-pool>] 
+                    [--mirror-image-mode <mirror-image-mode>] 
                     [--journal-splay-width <journal-splay-width>] 
                     [--journal-object-size <journal-object-size>] 
                     [--journal-pool <journal-pool>] 
     --stripe-unit arg         stripe unit in B/K/M
     --stripe-count arg        stripe count
     --data-pool arg           data pool
+    --mirror-image-mode arg   mirror image mode [journal or snapshot]
     --journal-splay-width arg number of active journal objects
     --journal-object-size arg size of journal objects [4K <= size <= 64M]
     --journal-pool arg        pool for journal objects
                        [--image-feature <image-feature>] [--image-shared] 
                        [--stripe-unit <stripe-unit>] 
                        [--stripe-count <stripe-count>] [--data-pool <data-pool>] 
+                       [--mirror-image-mode <mirror-image-mode>] 
                        [--journal-splay-width <journal-splay-width>] 
                        [--journal-object-size <journal-object-size>] 
                        [--journal-pool <journal-pool>] [--flatten] 
     --stripe-unit arg            stripe unit in B/K/M
     --stripe-count arg           stripe count
     --data-pool arg              data pool
+    --mirror-image-mode arg      mirror image mode [journal or snapshot]
     --journal-splay-width arg    number of active journal objects
     --journal-object-size arg    size of journal objects [4K <= size <= 64M]
     --journal-pool arg           pool for journal objects
                     [--image-feature <image-feature>] [--image-shared] 
                     [--stripe-unit <stripe-unit>] 
                     [--stripe-count <stripe-count>] [--data-pool <data-pool>] 
+                    [--mirror-image-mode <mirror-image-mode>] 
                     [--journal-splay-width <journal-splay-width>] 
                     [--journal-object-size <journal-object-size>] 
                     [--journal-pool <journal-pool>] 
     --stripe-unit arg         stripe unit in B/K/M
     --stripe-count arg        stripe count
     --data-pool arg           data pool
+    --mirror-image-mode arg   mirror image mode [journal or snapshot]
     --journal-splay-width arg number of active journal objects
     --journal-object-size arg size of journal objects [4K <= size <= 64M]
     --journal-pool arg        pool for journal objects
                                [--image-shared] [--stripe-unit <stripe-unit>] 
                                [--stripe-count <stripe-count>] 
                                [--data-pool <data-pool>] 
+                               [--mirror-image-mode <mirror-image-mode>] 
                                [--journal-splay-width <journal-splay-width>] 
                                [--journal-object-size <journal-object-size>] 
                                [--journal-pool <journal-pool>] [--flatten] 
     --stripe-unit arg         stripe unit in B/K/M
     --stripe-count arg        stripe count
     --data-pool arg           data pool
+    --mirror-image-mode arg   mirror image mode [journal or snapshot]
     --journal-splay-width arg number of active journal objects
     --journal-object-size arg size of journal objects [4K <= size <= 64M]
     --journal-pool arg        pool for journal objects
index e21c60aa3f7d15d72987a7ed6d01918d2b0734e6..74a460fcf1e81c08bf750e42199c2d558104e7d2 100644 (file)
@@ -243,7 +243,9 @@ void add_create_image_options(po::options_description *opt,
     (IMAGE_SHARED.c_str(), po::bool_switch(), "shared image")
     (IMAGE_STRIPE_UNIT.c_str(), po::value<ImageObjectSize>(), "stripe unit in B/K/M")
     (IMAGE_STRIPE_COUNT.c_str(), po::value<uint64_t>(), "stripe count")
-    (IMAGE_DATA_POOL.c_str(), po::value<std::string>(), "data pool");
+    (IMAGE_DATA_POOL.c_str(), po::value<std::string>(), "data pool")
+    (IMAGE_MIRROR_IMAGE_MODE.c_str(), po::value<MirrorImageMode>(),
+     "mirror image mode [journal or snapshot]");
 
   add_create_journal_options(opt);
 }
@@ -461,6 +463,19 @@ void validate(boost::any& v, const std::vector<std::string>& values,
   }
 }
 
+void validate(boost::any& v, const std::vector<std::string>& values,
+              MirrorImageMode* mirror_image_mode, int) {
+  po::validators::check_first_occurrence(v);
+  const std::string &s = po::validators::get_single_string(values);
+  if (s == "journal") {
+    v = boost::any(RBD_MIRROR_IMAGE_MODE_JOURNAL);
+  } else if (s == "snapshot") {
+    v = boost::any(RBD_MIRROR_IMAGE_MODE_SNAPSHOT);
+  } else {
+    throw po::validation_error(po::validation_error::invalid_option_value);
+  }
+}
+
 void validate(boost::any& v, const std::vector<std::string>& values,
               Format *target_type, int) {
   po::validators::check_first_occurrence(v);
index 23bb02b9cd0ce9c2526c1c14d86f940c4f425c64..0554acceee967a8c3c398787ca5c28a5d998ebde 100644 (file)
@@ -69,6 +69,7 @@ static const std::string IMAGE_DATA_POOL("data-pool");
 static const std::string IMAGE_SPARSE_SIZE("sparse-size");
 static const std::string IMAGE_THICK_PROVISION("thick-provision");
 static const std::string IMAGE_FLATTEN("flatten");
+static const std::string IMAGE_MIRROR_IMAGE_MODE("mirror-image-mode");
 
 static const std::string JOURNAL_OBJECT_SIZE("journal-object-size");
 static const std::string JOURNAL_SPLAY_WIDTH("journal-splay-width");
@@ -97,6 +98,8 @@ struct ImageFeatures {
   uint64_t features;
 };
 
+struct MirrorImageMode {};
+
 template <typename T>
 struct TypedValue {
   T value;
index f02adb8a32ee2853f6cc7fe013332f05047d07af..7698dae9a634cc76d1ceed2a9765013b0e461c72 100644 (file)
@@ -555,6 +555,11 @@ int get_image_options(const boost::program_options::variables_map &vm,
     return r;
   }
 
+  if (vm.count(at::IMAGE_MIRROR_IMAGE_MODE)) {
+    opts->set(RBD_IMAGE_OPTION_MIRROR_IMAGE_MODE,
+              vm[at::IMAGE_MIRROR_IMAGE_MODE].as<librbd::mirror_image_mode_t>());
+  }
+
   return 0;
 }