]> 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)
committerNathan Cutler <ncutler@suse.com>
Wed, 29 Apr 2020 12:06:58 +0000 (14:06 +0200)
This allows the user to enable mirroring while creating, cloning,
copying, importing, or migrating an image.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 6da56d798248369f15191d8d5ec3b093f8dca831)

src/test/cli/rbd/help.t
src/tools/rbd/ArgumentTypes.cc
src/tools/rbd/ArgumentTypes.h
src/tools/rbd/Utils.cc

index fe3d4dc3efb1b9554cbc03a5f576b0f1b0402d1e..e6f1ee869d1528d3f963f0fa5619f3423dfa5f99 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 74115d8a30aa930b8f799a1be5510fc59aba6f57..cf64f9abe018299da200aece445836b27fa95c47 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);
 }
@@ -463,6 +465,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 520b654714b8cea012194b33cc4f6d1cae7f31b9..903e35ca755f9718914013fabe265cd69257270b 100644 (file)
@@ -557,6 +557,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;
 }