]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: add new 'pool init' action for initializing a RBD pool
authorJason Dillaman <dillaman@redhat.com>
Mon, 26 Jun 2017 13:48:00 +0000 (09:48 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 19 Jul 2017 17:13:01 +0000 (13:13 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
doc/rbd/libvirt.rst
doc/rbd/rados-rbd-cmds.rst
doc/rbd/rbd-cloudstack.rst
doc/rbd/rbd-openstack.rst
doc/start/quick-rbd.rst
src/test/cli/rbd/help.t
src/tools/rbd/CMakeLists.txt
src/tools/rbd/action/Pool.cc [new file with mode: 0644]

index b0a3dbda3c7ba5ac5b296a9a4edf8411840baf78..a79eaa888d1917a9e3b606a898ae22f16ac8ed15 100644 (file)
@@ -58,7 +58,7 @@ Configuring Ceph
 
 To configure Ceph for use with ``libvirt``, perform the following steps:
 
-#. `Create a pool`_ (or use the default). The following example uses the 
+#. `Create a pool`_. The following example uses the 
    pool name ``libvirt-pool`` with 128 placement groups. ::
 
        ceph osd pool create libvirt-pool 128 128
@@ -67,6 +67,10 @@ To configure Ceph for use with ``libvirt``, perform the following steps:
 
        ceph osd lspools
 
+#. Use the ``rbd`` tool to initialize the pool for use by RBD::
+
+        rbd pool init <pool-name>
+
 #. `Create a Ceph User`_ (or use ``client.admin`` for version 0.9.7 and 
    earlier). The following example uses the Ceph user name ``client.libvirt`` 
    and references ``libvirt-pool``. ::
index a8e2302d23e82380dedc9e83dfd1c61b3d90bdf1..cc113c1d069df27e56fec6dfca33075aed4d4d10 100644 (file)
@@ -13,6 +13,17 @@ details.
 .. important:: To use Ceph Block Device commands, you must have access to 
    a running Ceph cluster.
 
+Create a Block Device Pool
+==========================
+
+#. On the admin node, use the ``ceph`` tool to `create a pool`_.
+
+#. On the admin node, use the ``rbd`` tool to initialize the pool for use by RBD::
+
+        rbd pool init <pool-name>
+
+.. note:: The ``rbd`` tool assumes a default pool name of 'rbd' when not
+   provided.
 
 Creating a Block Device Image
 =============================
@@ -112,6 +123,6 @@ For example::
        rbd rm swimmingpool/bar
 
 
-
+.. _create a pool: ../../rados/operations/pools/#create-a-pool
 .. _Storage Pools: ../../rados/operations/pools
 .. _RBD – Manage RADOS Block Device (RBD) Images: ../../man/8/rbd/
index c50f6f0f0428b467dd4ea94cc7df3804d9842797..e888f787a3f96cb27412ecf0371c0c1f31157d25 100644 (file)
@@ -68,6 +68,11 @@ See `Create a Pool`_ for details on specifying the number of placement groups
 for your pools, and `Placement Groups`_ for details on the number of placement
 groups you should set for your pools.
 
+A newly created pool must initialized prior to use. Use the ``rbd`` tool
+to initialize the pool::
+
+        rbd pool init cloudstack
+
 Create a Ceph User
 ==================
 
index 8df63cb449a3f133f818ab4dda17e181af4091ae..907276fe15befb47747ab033c8a7e32ff3c5716f 100644 (file)
@@ -90,6 +90,14 @@ See `Create a Pool`_ for detail on specifying the number of placement groups for
 your pools, and `Placement Groups`_ for details on the number of placement
 groups you should set for your pools.
 
+Newly created pools must initialized prior to use. Use the ``rbd`` tool
+to initialize the pools::
+
+        rbd pool init volumes
+        rbd pool init images
+        rbd pool init backups
+        rbd pool init vms
+
 .. _Create a Pool: ../../rados/operations/pools#createpool
 .. _Placement Groups: ../../rados/operations/placement-groups
 
index 11d85262f4d640ea44a52927ee797b6f29fbfaf3..787807c36fc4303ec9fca9ffe5054a883a0fed00 100644 (file)
@@ -47,11 +47,16 @@ Install Ceph
    directory. Ensure that the keyring file has appropriate read permissions 
    (e.g., ``sudo chmod +r /etc/ceph/ceph.client.admin.keyring``).
 
-Create an rbd pool
-==================
-#. On the admin node, use the ``ceph`` tool to `Create a Pool`_
+Create a Block Device Pool
+==========================
+
+#. On the admin node, use the ``ceph`` tool to `create a pool`_
    (we recommend the name 'rbd').
 
+#. On the admin node, use the ``rbd`` tool to initialize the pool for use by RBD::
+
+        rbd pool init <pool-name>
+
 Configure a Block Device
 ========================
 
@@ -84,6 +89,7 @@ See `block devices`_ for additional details.
 
 .. _Create a Pool: ../../rados/operations/pools#createpool
 .. _Storage Cluster Quick Start: ../quick-ceph-deploy
+.. _create a pool: ../../rados/operations/pools/#create-a-pool
 .. _block devices: ../../rbd/rbd
 .. _FAQ: http://wiki.ceph.com/How_Can_I_Give_Ceph_a_Try
 .. _OS Recommendations: ../os-recommendations
index 104dfc4f1aed6d60f60720a64d8aa033ab19af3a..e1d99d82695ec8e929846d4c1e274d390c6b91de 100644 (file)
@@ -71,6 +71,7 @@
       nbd unmap                   Unmap a nbd device.
       object-map check            Verify the object map is correct.
       object-map rebuild          Rebuild an invalid object map.
+      pool init                   Initialize pool for use by RBD.
       remove (rm)                 Delete an image.
       rename (mv)                 Rename image within pool.
       resize                      Resize (expand or shrink) image.
     --snap arg            snapshot name
     --no-progress         disable progress output
   
+  rbd help pool init
+  usage: rbd pool init [--pool <pool>] [--force] 
+                       <pool-name> 
+  
+  Initialize pool for use by RBD.
+  
+  Positional arguments
+    <pool-name>          pool name
+  
+  Optional arguments
+    -p [ --pool ] arg    pool name
+    --force              force initialize pool for RBD use if registered by
+                         another application
+  
   rbd help remove
   usage: rbd remove [--pool <pool>] [--image <image>] [--no-progress] 
                     <image-spec> 
index 8774b4902813b3f1b679e50a6c756d84ad765fd1..ad4005ebf0aec88c07037d5cbf422f7d5f09ac02 100644 (file)
@@ -28,6 +28,7 @@ set(rbd_srcs
   action/MirrorImage.cc
   action/Nbd.cc
   action/ObjectMap.cc
+  action/Pool.cc
   action/Remove.cc
   action/Rename.cc
   action/Resize.cc
diff --git a/src/tools/rbd/action/Pool.cc b/src/tools/rbd/action/Pool.cc
new file mode 100644 (file)
index 0000000..7583930
--- /dev/null
@@ -0,0 +1,60 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "tools/rbd/ArgumentTypes.h"
+#include "tools/rbd/Shell.h"
+#include "tools/rbd/Utils.h"
+#include "include/stringify.h"
+#include "common/errno.h"
+#include "osd/osd_types.h"
+#include <iostream>
+#include <boost/program_options.hpp>
+
+namespace rbd {
+namespace action {
+namespace pool {
+
+namespace at = argument_types;
+namespace po = boost::program_options;
+
+void get_arguments_init(po::options_description *positional,
+                        po::options_description *options) {
+  at::add_pool_options(positional, options);
+  options->add_options()
+      ("force", po::bool_switch(),
+       "force initialize pool for RBD use if registered by another application");
+}
+
+int execute_init(const po::variables_map &vm) {
+  size_t arg_index = 0;
+  std::string pool_name = utils::get_pool_name(vm, &arg_index);
+
+  librados::Rados rados;
+  librados::IoCtx io_ctx;
+  int r = utils::init(pool_name, &rados, &io_ctx);
+  if (r < 0) {
+    return r;
+  }
+
+  r = io_ctx.application_enable(pg_pool_t::APPLICATION_NAME_RBD,
+                                vm["force"].as<bool>());
+  if (r == -EOPNOTSUPP) {
+    std::cerr << "rbd: luminous or later release required." << std::endl;
+  } else if (r == -EPERM) {
+    std::cerr << "rbd: pool already registered to a different application."
+              << std::endl;
+  } else if (r < 0) {
+    std::cerr << "rbd: error registered application: " << cpp_strerror(r)
+              << std::endl;
+  }
+
+  return 0;
+}
+
+Shell::Action action(
+  {"pool", "init"}, {}, "Initialize pool for use by RBD.", "",
+    &get_arguments_init, &execute_init);
+
+} // namespace pool
+} // namespace action
+} // namespace rbd