]>
git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd/action/Pool.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #include "tools/rbd/ArgumentTypes.h"
5 #include "tools/rbd/Shell.h"
6 #include "tools/rbd/Utils.h"
7 #include "include/stringify.h"
8 #include "common/errno.h"
9 #include "osd/osd_types.h"
11 #include <boost/program_options.hpp>
17 namespace at
= argument_types
;
18 namespace po
= boost::program_options
;
20 void get_arguments_init(po::options_description
*positional
,
21 po::options_description
*options
) {
22 at::add_pool_options(positional
, options
);
23 options
->add_options()
24 ("force", po::bool_switch(),
25 "force initialize pool for RBD use if registered by another application");
28 int execute_init(const po::variables_map
&vm
) {
30 std::string pool_name
= utils::get_pool_name(vm
, &arg_index
);
32 librados::Rados rados
;
33 librados::IoCtx io_ctx
;
34 int r
= utils::init(pool_name
, &rados
, &io_ctx
);
39 r
= io_ctx
.application_enable(pg_pool_t::APPLICATION_NAME_RBD
,
40 vm
["force"].as
<bool>());
41 if (r
== -EOPNOTSUPP
) {
42 std::cerr
<< "rbd: luminous or later release required." << std::endl
;
43 } else if (r
== -EPERM
) {
44 std::cerr
<< "rbd: pool already registered to a different application."
47 std::cerr
<< "rbd: error registered application: " << cpp_strerror(r
)
55 {"pool", "init"}, {}, "Initialize pool for use by RBD.", "",
56 &get_arguments_init
, &execute_init
);