]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd/action/Config.cc
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / tools / rbd / action / Config.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #include "common/Formatter.h"
5 #include "common/TextTable.h"
6 #include "common/ceph_context.h"
7 #include "common/ceph_json.h"
8 #include "common/escape.h"
9 #include "common/errno.h"
10 #include "common/options.h"
11 #include "global/global_context.h"
12 #include "include/stringify.h"
13
14 #include "tools/rbd/ArgumentTypes.h"
15 #include "tools/rbd/Shell.h"
16 #include "tools/rbd/Utils.h"
17
18 #include <iostream>
19
20 #include <boost/algorithm/string/predicate.hpp>
21 #include <boost/program_options.hpp>
22
23 namespace rbd {
24 namespace action {
25 namespace config {
26
27 namespace at = argument_types;
28 namespace po = boost::program_options;
29
30 namespace {
31
32 const std::string METADATA_CONF_PREFIX = "conf_";
33 const uint32_t MAX_KEYS = 64;
34
35 void add_config_entity_option(
36 boost::program_options::options_description *positional) {
37 positional->add_options()
38 ("config-entity", "config entity (global, client, client.<id>)");
39 }
40
41 void add_pool_option(boost::program_options::options_description *positional) {
42 positional->add_options()
43 ("pool-name", "pool name");
44 }
45
46 void add_key_option(po::options_description *positional) {
47 positional->add_options()
48 ("key", "config key");
49 }
50
51 int get_config_entity(const po::variables_map &vm, std::string *config_entity) {
52 *config_entity = utils::get_positional_argument(vm, 0);
53
54 if (*config_entity != "global" && *config_entity != "client" &&
55 !boost::starts_with(*config_entity, ("client."))) {
56 std::cerr << "rbd: invalid config entity: " << *config_entity
57 << " (must be global, client or client.<id>)" << std::endl;
58 return -EINVAL;
59 }
60
61 return 0;
62 }
63
64 int get_pool(const po::variables_map &vm, std::string *pool_name) {
65 *pool_name = utils::get_positional_argument(vm, 0);
66 if (pool_name->empty()) {
67 std::cerr << "rbd: pool name was not specified" << std::endl;
68 return -EINVAL;
69 }
70
71 return 0;
72 }
73
74 int get_key(const po::variables_map &vm, size_t *arg_index,
75 std::string *key) {
76 *key = utils::get_positional_argument(vm, *arg_index);
77 if (key->empty()) {
78 std::cerr << "rbd: config key was not specified" << std::endl;
79 return -EINVAL;
80 } else {
81 ++(*arg_index);
82 }
83
84 if (!boost::starts_with(*key, "rbd_")) {
85 std::cerr << "rbd: not rbd option: " << *key << std::endl;
86 return -EINVAL;
87 }
88
89 std::string value;
90 int r = g_ceph_context->_conf.get_val(key->c_str(), &value);
91 if (r < 0) {
92 std::cerr << "rbd: invalid config key: " << *key << std::endl;
93 return -EINVAL;
94 }
95
96 return 0;
97 }
98
99 std::ostream& operator<<(std::ostream& os,
100 const librbd::config_source_t& source) {
101 switch (source) {
102 case RBD_CONFIG_SOURCE_CONFIG:
103 os << "config";
104 break;
105 case RBD_CONFIG_SOURCE_POOL:
106 os << "pool";
107 break;
108 case RBD_CONFIG_SOURCE_IMAGE:
109 os << "image";
110 break;
111 default:
112 os << "unknown (" << static_cast<uint32_t>(source) << ")";
113 break;
114 }
115 return os;
116 }
117
118 int config_global_list(
119 librados::Rados &rados, const std::string &config_entity,
120 std::map<std::string, std::pair<std::string, std::string>> *options) {
121 bool client_id_config_entity =
122 boost::starts_with(config_entity, ("client."));
123 std::string cmd =
124 "{"
125 "\"prefix\": \"config dump\", "
126 "\"format\": \"json\" "
127 "}";
128 bufferlist in_bl;
129 bufferlist out_bl;
130 std::string ss;
131 int r = rados.mon_command(cmd, in_bl, &out_bl, &ss);
132 if (r < 0) {
133 std::cerr << "rbd: error reading config: " << ss << std::endl;
134 return r;
135 }
136
137 json_spirit::mValue json_root;
138 if (!json_spirit::read(out_bl.to_str(), json_root)) {
139 std::cerr << "rbd: error parsing config dump" << std::endl;
140 return -EINVAL;
141 }
142
143 try {
144 auto &json_array = json_root.get_array();
145 for (auto& e : json_array) {
146 auto &json_obj = e.get_obj();
147 std::string section;
148 std::string name;
149 std::string value;
150
151 for (auto &pairs : json_obj) {
152 if (pairs.first == "section") {
153 section = pairs.second.get_str();
154 } else if (pairs.first == "name") {
155 name = pairs.second.get_str();
156 } else if (pairs.first == "value") {
157 value = pairs.second.get_str();
158 }
159 }
160
161 if (!boost::starts_with(name, "rbd_")) {
162 continue;
163 }
164 if (section != "global" && section != "client" &&
165 (!client_id_config_entity || section != config_entity)) {
166 continue;
167 }
168 if (config_entity == "global" && section != "global") {
169 continue;
170 }
171 auto it = options->find(name);
172 if (it == options->end()) {
173 (*options)[name] = {value, section};
174 continue;
175 }
176 if (section == "client") {
177 if (it->second.second == "global") {
178 it->second = {value, section};
179 }
180 } else if (client_id_config_entity) {
181 it->second = {value, section};
182 }
183 }
184 } catch (std::runtime_error &e) {
185 std::cerr << "rbd: error parsing config dump: " << e.what() << std::endl;
186 return -EINVAL;
187 }
188
189 return 0;
190 }
191
192 } // anonymous namespace
193
194 void get_global_get_arguments(po::options_description *positional,
195 po::options_description *options) {
196 add_config_entity_option(positional);
197 add_key_option(positional);
198 }
199
200 int execute_global_get(const po::variables_map &vm,
201 const std::vector<std::string> &ceph_global_init_args) {
202 std::string config_entity;
203 int r = get_config_entity(vm, &config_entity);
204 if (r < 0) {
205 return r;
206 }
207
208 std::string key;
209 size_t arg_index = 1;
210 r = get_key(vm, &arg_index, &key);
211 if (r < 0) {
212 return r;
213 }
214
215 librados::Rados rados;
216 r = utils::init_rados(&rados);
217 if (r < 0) {
218 return r;
219 }
220
221 std::map<std::string, std::pair<std::string, std::string>> options;
222 r = config_global_list(rados, config_entity, &options);
223 if (r < 0) {
224 return r;
225 }
226
227 auto it = options.find(key);
228
229 if (it == options.end() || it->second.second != config_entity) {
230 std::cerr << "rbd: " << key << " is not set" << std::endl;
231 return -ENOENT;
232 }
233
234 std::cout << it->second.first << std::endl;
235 return 0;
236 }
237
238 void get_global_set_arguments(po::options_description *positional,
239 po::options_description *options) {
240 add_config_entity_option(positional);
241 add_key_option(positional);
242 positional->add_options()
243 ("value", "config value");
244 }
245
246 int execute_global_set(const po::variables_map &vm,
247 const std::vector<std::string> &ceph_global_init_args) {
248 std::string config_entity;
249 int r = get_config_entity(vm, &config_entity);
250 if (r < 0) {
251 return r;
252 }
253
254 std::string key;
255 size_t arg_index = 1;
256 r = get_key(vm, &arg_index, &key);
257 if (r < 0) {
258 return r;
259 }
260
261 librados::Rados rados;
262 r = utils::init_rados(&rados);
263 if (r < 0) {
264 return r;
265 }
266
267 std::string value = utils::get_positional_argument(vm, 2);
268 std::string cmd =
269 "{"
270 "\"prefix\": \"config set\", "
271 "\"who\": \"" + stringify(json_stream_escaper(config_entity)) + "\", "
272 "\"name\": \"" + key + "\", "
273 "\"value\": \"" + stringify(json_stream_escaper(value)) + "\""
274 "}";
275 bufferlist in_bl;
276 std::string ss;
277 r = rados.mon_command(cmd, in_bl, nullptr, &ss);
278 if (r < 0) {
279 std::cerr << "rbd: error setting " << key << ": " << ss << std::endl;
280 return r;
281 }
282
283 return 0;
284 }
285
286 void get_global_remove_arguments(po::options_description *positional,
287 po::options_description *options) {
288 add_config_entity_option(positional);
289 add_key_option(positional);
290 }
291
292 int execute_global_remove(
293 const po::variables_map &vm,
294 const std::vector<std::string> &ceph_global_init_args) {
295 std::string config_entity;
296 int r = get_config_entity(vm, &config_entity);
297 if (r < 0) {
298 return r;
299 }
300
301 std::string key;
302 size_t arg_index = 1;
303 r = get_key(vm, &arg_index, &key);
304 if (r < 0) {
305 return r;
306 }
307
308 librados::Rados rados;
309 r = utils::init_rados(&rados);
310 if (r < 0) {
311 return r;
312 }
313
314 std::string cmd =
315 "{"
316 "\"prefix\": \"config rm\", "
317 "\"who\": \"" + stringify(json_stream_escaper(config_entity)) + "\", "
318 "\"name\": \"" + key + "\""
319 "}";
320 bufferlist in_bl;
321 std::string ss;
322 r = rados.mon_command(cmd, in_bl, nullptr, &ss);
323 if (r < 0) {
324 std::cerr << "rbd: error removing " << key << ": " << ss << std::endl;
325 return r;
326 }
327
328 return 0;
329 }
330
331 void get_global_list_arguments(po::options_description *positional,
332 po::options_description *options) {
333 add_config_entity_option(positional);
334 at::add_format_options(options);
335 }
336
337 int execute_global_list(const po::variables_map &vm,
338 const std::vector<std::string> &ceph_global_init_args) {
339 std::string config_entity;
340 int r = get_config_entity(vm, &config_entity);
341 if (r < 0) {
342 return r;
343 }
344
345 at::Format::Formatter f;
346 r = utils::get_formatter(vm, &f);
347 if (r < 0) {
348 return r;
349 }
350
351 librados::Rados rados;
352 r = utils::init_rados(&rados);
353 if (r < 0) {
354 return r;
355 }
356
357 std::map<std::string, std::pair<std::string, std::string>> options;
358 r = config_global_list(rados, config_entity, &options);
359 if (r < 0) {
360 return r;
361 }
362
363 if (options.empty() && !f) {
364 return 0;
365 }
366
367 TextTable tbl;
368
369 if (f) {
370 f->open_array_section("config");
371 } else {
372 tbl.define_column("Name", TextTable::LEFT, TextTable::LEFT);
373 tbl.define_column("Value", TextTable::LEFT, TextTable::LEFT);
374 tbl.define_column("Section", TextTable::LEFT, TextTable::LEFT);
375 }
376
377 for (const auto &it : options) {
378 if (f) {
379 f->open_object_section("option");
380 f->dump_string("name", it.first);
381 f->dump_string("value", it.second.first);
382 f->dump_string("section", it.second.second);
383 f->close_section();
384 } else {
385 tbl << it.first << it.second.first << it.second.second
386 << TextTable::endrow;
387 }
388 }
389
390 if (f) {
391 f->close_section();
392 f->flush(std::cout);
393 } else {
394 std::cout << tbl;
395 }
396
397 return 0;
398 }
399
400 void get_pool_get_arguments(po::options_description *positional,
401 po::options_description *options) {
402 add_pool_option(positional);
403 add_key_option(positional);
404 }
405
406 int execute_pool_get(const po::variables_map &vm,
407 const std::vector<std::string> &ceph_global_init_args) {
408 std::string pool_name;
409 int r = get_pool(vm, &pool_name);
410 if (r < 0) {
411 return r;
412 }
413
414 std::string key;
415 size_t arg_index = 1;
416 r = get_key(vm, &arg_index, &key);
417 if (r < 0) {
418 return r;
419 }
420
421 librados::Rados rados;
422 librados::IoCtx io_ctx;
423 r = utils::init(pool_name, "", &rados, &io_ctx);
424 if (r < 0) {
425 return r;
426 }
427
428 librbd::RBD rbd;
429 std::string value;
430
431 r = rbd.pool_metadata_get(io_ctx, METADATA_CONF_PREFIX + key, &value);
432 if (r < 0) {
433 if (r == -ENOENT) {
434 std::cerr << "rbd: " << key << " is not set" << std::endl;
435 } else {
436 std::cerr << "rbd: failed to get " << key << ": " << cpp_strerror(r)
437 << std::endl;
438 }
439 return r;
440 }
441
442 std::cout << value << std::endl;
443 return 0;
444 }
445
446 void get_pool_set_arguments(po::options_description *positional,
447 po::options_description *options) {
448 add_pool_option(positional);
449 add_key_option(positional);
450 positional->add_options()
451 ("value", "config value");
452 }
453
454 int execute_pool_set(const po::variables_map &vm,
455 const std::vector<std::string> &ceph_global_init_args) {
456 std::string pool_name;
457 int r = get_pool(vm, &pool_name);
458 if (r < 0) {
459 return r;
460 }
461
462 std::string key;
463 size_t arg_index = 1;
464 r = get_key(vm, &arg_index, &key);
465 if (r < 0) {
466 return r;
467 }
468
469 std::string value = utils::get_positional_argument(vm, 2);
470
471 librados::Rados rados;
472 librados::IoCtx io_ctx;
473 r = utils::init(pool_name, "", &rados, &io_ctx);
474 if (r < 0) {
475 return r;
476 }
477
478 librbd::RBD rbd;
479 r = rbd.pool_metadata_set(io_ctx, METADATA_CONF_PREFIX + key, value);
480 if (r < 0) {
481 std::cerr << "rbd: failed to set " << key << ": " << cpp_strerror(r)
482 << std::endl;
483 return r;
484 }
485
486 return 0;
487 }
488
489 void get_pool_remove_arguments(po::options_description *positional,
490 po::options_description *options) {
491 add_pool_option(positional);
492 add_key_option(positional);
493 }
494
495 int execute_pool_remove(const po::variables_map &vm,
496 const std::vector<std::string> &ceph_global_init_args) {
497 std::string pool_name;
498 int r = get_pool(vm, &pool_name);
499 if (r < 0) {
500 return r;
501 }
502
503 std::string key;
504 size_t arg_index = 1;
505 r = get_key(vm, &arg_index, &key);
506 if (r < 0) {
507 return r;
508 }
509
510 librados::Rados rados;
511 librados::IoCtx io_ctx;
512 r = utils::init(pool_name, "", &rados, &io_ctx);
513 if (r < 0) {
514 return r;
515 }
516
517 librbd::RBD rbd;
518 r = rbd.pool_metadata_remove(io_ctx, METADATA_CONF_PREFIX + key);
519 if (r < 0) {
520 std::cerr << "rbd: failed to remove " << key << ": " << cpp_strerror(r)
521 << std::endl;
522 return r;
523 }
524
525 return 0;
526 }
527
528 void get_pool_list_arguments(po::options_description *positional,
529 po::options_description *options) {
530 add_pool_option(positional);
531 at::add_format_options(options);
532 }
533
534 int execute_pool_list(const po::variables_map &vm,
535 const std::vector<std::string> &ceph_global_init_args) {
536 std::string pool_name;
537 int r = get_pool(vm, &pool_name);
538 if (r < 0) {
539 return r;
540 }
541
542 at::Format::Formatter f;
543 r = utils::get_formatter(vm, &f);
544 if (r < 0) {
545 return r;
546 }
547
548 librados::Rados rados;
549 librados::IoCtx io_ctx;
550 r = utils::init(pool_name, "", &rados, &io_ctx);
551 if (r < 0) {
552 return r;
553 }
554
555 TextTable tbl;
556 librbd::RBD rbd;
557 std::vector<librbd::config_option_t> options;
558
559 r = rbd.config_list(io_ctx, &options);
560 if (r < 0) {
561 std::cerr << "rbd: failed to list config: " << cpp_strerror(r) << std::endl;
562 return r;
563 }
564
565 if (f) {
566 f->open_array_section("config");
567 } else {
568 tbl.define_column("Name", TextTable::LEFT, TextTable::LEFT);
569 tbl.define_column("Value", TextTable::LEFT, TextTable::LEFT);
570 tbl.define_column("Source", TextTable::LEFT, TextTable::LEFT);
571 }
572
573 for (auto &option : options) {
574 if (f) {
575 f->open_object_section("option");
576 f->dump_string("name", option.name);
577 f->dump_string("value", option.value);
578 f->dump_stream("source") << option.source;
579 f->close_section();
580 } else {
581 std::ostringstream source;
582 source << option.source;
583 tbl << option.name << option.value << source.str() << TextTable::endrow;
584 }
585 }
586
587 if (f) {
588 f->close_section();
589 f->flush(std::cout);
590 } else {
591 std::cout << tbl;
592 }
593
594 return 0;
595 }
596
597 void get_image_get_arguments(po::options_description *positional,
598 po::options_description *options) {
599 at::add_image_spec_options(positional, options, at::ARGUMENT_MODIFIER_NONE);
600 add_key_option(positional);
601 }
602
603 int execute_image_get(const po::variables_map &vm,
604 const std::vector<std::string> &ceph_global_init_args) {
605 size_t arg_index = 0;
606 std::string pool_name;
607 std::string namespace_name;
608 std::string image_name;
609 std::string snap_name;
610 int r = utils::get_pool_image_snapshot_names(
611 vm, at::ARGUMENT_MODIFIER_NONE, &arg_index, &pool_name, &namespace_name,
612 &image_name, &snap_name, true, utils::SNAPSHOT_PRESENCE_NONE,
613 utils::SPEC_VALIDATION_NONE);
614 if (r < 0) {
615 return r;
616 }
617
618 std::string key;
619 r = get_key(vm, &arg_index, &key);
620 if (r < 0) {
621 return r;
622 }
623
624 librados::Rados rados;
625 librados::IoCtx io_ctx;
626 librbd::Image image;
627 r = utils::init_and_open_image(pool_name, namespace_name, image_name, "", "",
628 false, &rados, &io_ctx, &image);
629 if (r < 0) {
630 return r;
631 }
632
633 std::string value;
634
635 r = image.metadata_get(METADATA_CONF_PREFIX + key, &value);
636 if (r < 0) {
637 if (r == -ENOENT) {
638 std::cerr << "rbd: " << key << " is not set" << std::endl;
639 } else {
640 std::cerr << "rbd: failed to get " << key << ": " << cpp_strerror(r)
641 << std::endl;
642 }
643 return r;
644 }
645
646 std::cout << value << std::endl;
647 return 0;
648 }
649
650 void get_image_set_arguments(po::options_description *positional,
651 po::options_description *options) {
652 at::add_image_spec_options(positional, options, at::ARGUMENT_MODIFIER_NONE);
653 add_key_option(positional);
654 positional->add_options()
655 ("value", "config value");
656 }
657
658 int execute_image_set(const po::variables_map &vm,
659 const std::vector<std::string> &ceph_global_init_args) {
660 size_t arg_index = 0;
661 std::string pool_name;
662 std::string namespace_name;
663 std::string image_name;
664 std::string snap_name;
665 int r = utils::get_pool_image_snapshot_names(
666 vm, at::ARGUMENT_MODIFIER_NONE, &arg_index, &pool_name, &namespace_name,
667 &image_name, &snap_name, true, utils::SNAPSHOT_PRESENCE_NONE,
668 utils::SPEC_VALIDATION_NONE);
669 if (r < 0) {
670 return r;
671 }
672
673 std::string key;
674 r = get_key(vm, &arg_index, &key);
675 if (r < 0) {
676 return r;
677 }
678
679 std::string value = utils::get_positional_argument(vm, arg_index);
680 if (value.empty()) {
681 std::cerr << "rbd: image config value was not specified" << std::endl;
682 return -EINVAL;
683 }
684
685 librados::Rados rados;
686 librados::IoCtx io_ctx;
687 librbd::Image image;
688 r = utils::init_and_open_image(pool_name, namespace_name, image_name, "", "",
689 false, &rados, &io_ctx, &image);
690 if (r < 0) {
691 return r;
692 }
693
694 r = image.metadata_set(METADATA_CONF_PREFIX + key, value);
695 if (r < 0) {
696 std::cerr << "rbd: failed to set " << key << ": " << cpp_strerror(r)
697 << std::endl;
698 return r;
699 }
700
701 return 0;
702 }
703
704 void get_image_remove_arguments(po::options_description *positional,
705 po::options_description *options) {
706 at::add_image_spec_options(positional, options, at::ARGUMENT_MODIFIER_NONE);
707 add_key_option(positional);
708 }
709
710 int execute_image_remove(
711 const po::variables_map &vm,
712 const std::vector<std::string> &ceph_global_init_args) {
713 size_t arg_index = 0;
714 std::string pool_name;
715 std::string namespace_name;
716 std::string image_name;
717 std::string snap_name;
718 int r = utils::get_pool_image_snapshot_names(
719 vm, at::ARGUMENT_MODIFIER_NONE, &arg_index, &pool_name, &namespace_name,
720 &image_name, &snap_name, true, utils::SNAPSHOT_PRESENCE_NONE,
721 utils::SPEC_VALIDATION_NONE);
722 if (r < 0) {
723 return r;
724 }
725
726 std::string key;
727 r = get_key(vm, &arg_index, &key);
728 if (r < 0) {
729 return r;
730 }
731
732 librados::Rados rados;
733 librados::IoCtx io_ctx;
734 librbd::Image image;
735 r = utils::init_and_open_image(pool_name, namespace_name, image_name, "", "",
736 false, &rados, &io_ctx, &image);
737 if (r < 0) {
738 return r;
739 }
740
741 r = image.metadata_remove(METADATA_CONF_PREFIX + key);
742 if (r < 0) {
743 std::cerr << "rbd: failed to remove " << key << ": " << cpp_strerror(r)
744 << std::endl;
745 return r;
746 }
747
748 return 0;
749 }
750
751 void get_image_list_arguments(po::options_description *positional,
752 po::options_description *options) {
753 at::add_image_spec_options(positional, options, at::ARGUMENT_MODIFIER_NONE);
754 at::add_format_options(options);
755 }
756
757 int execute_image_list(const po::variables_map &vm,
758 const std::vector<std::string> &ceph_global_init_args) {
759 size_t arg_index = 0;
760 std::string pool_name;
761 std::string namespace_name;
762 std::string image_name;
763 std::string snap_name;
764 int r = utils::get_pool_image_snapshot_names(
765 vm, at::ARGUMENT_MODIFIER_NONE, &arg_index, &pool_name, &namespace_name,
766 &image_name, &snap_name, true, utils::SNAPSHOT_PRESENCE_NONE,
767 utils::SPEC_VALIDATION_NONE);
768 if (r < 0) {
769 return r;
770 }
771
772 at::Format::Formatter f;
773 r = utils::get_formatter(vm, &f);
774 if (r < 0) {
775 return r;
776 }
777
778 librados::Rados rados;
779 librados::IoCtx io_ctx;
780 librbd::Image image;
781 r = utils::init_and_open_image(pool_name, namespace_name, image_name, "", "",
782 false, &rados, &io_ctx, &image);
783 if (r < 0) {
784 return r;
785 }
786
787 TextTable tbl;
788 std::vector<librbd::config_option_t> options;
789
790 r = image.config_list(&options);
791 if (r < 0) {
792 std::cerr << "rbd: failed to list config: " << cpp_strerror(r) << std::endl;
793 return r;
794 }
795
796 if (options.empty()) {
797 if (f == nullptr) {
798 std::cout << "There are no values" << std::endl;
799 }
800 return 0;
801 }
802
803 if (f) {
804 f->open_array_section("config");
805 } else {
806 tbl.define_column("Name", TextTable::LEFT, TextTable::LEFT);
807 tbl.define_column("Value", TextTable::LEFT, TextTable::LEFT);
808 tbl.define_column("Source", TextTable::LEFT, TextTable::LEFT);
809 }
810
811 for (auto &option : options) {
812 if (f) {
813 f->open_object_section("option");
814 f->dump_string("name", option.name);
815 f->dump_string("value", option.value);
816 f->dump_stream("source") << option.source;
817 f->close_section();
818 } else {
819 std::ostringstream source;
820 source << option.source;
821 tbl << option.name << option.value << source.str() << TextTable::endrow;
822 }
823 }
824
825 if (f == nullptr) {
826 bool single = (options.size() == 1);
827 std::cout << "There " << (single ? "is" : "are") << " " << options.size()
828 << " " << (single ? "value" : "values") << ":" << std::endl;
829 }
830
831 if (f) {
832 f->close_section();
833 f->flush(std::cout);
834 } else {
835 std::cout << tbl;
836 }
837
838 return 0;
839 }
840
841 Shell::Action action_global_get(
842 {"config", "global", "get"}, {},
843 "Get a global-level configuration override.", "",
844 &get_global_get_arguments, &execute_global_get);
845 Shell::Action action_global_set(
846 {"config", "global", "set"}, {},
847 "Set a global-level configuration override.", "",
848 &get_global_set_arguments, &execute_global_set);
849 Shell::Action action_global_remove(
850 {"config", "global", "remove"}, {"config", "global", "rm"},
851 "Remove a global-level configuration override.", "",
852 &get_global_remove_arguments, &execute_global_remove);
853 Shell::Action action_global_list(
854 {"config", "global", "list"}, {"config", "global", "ls"},
855 "List global-level configuration overrides.", "",
856 &get_global_list_arguments, &execute_global_list);
857
858 Shell::Action action_pool_get(
859 {"config", "pool", "get"}, {}, "Get a pool-level configuration override.", "",
860 &get_pool_get_arguments, &execute_pool_get);
861 Shell::Action action_pool_set(
862 {"config", "pool", "set"}, {}, "Set a pool-level configuration override.", "",
863 &get_pool_set_arguments, &execute_pool_set);
864 Shell::Action action_pool_remove(
865 {"config", "pool", "remove"}, {"config", "pool", "rm"},
866 "Remove a pool-level configuration override.", "",
867 &get_pool_remove_arguments, &execute_pool_remove);
868 Shell::Action action_pool_list(
869 {"config", "pool", "list"}, {"config", "pool", "ls"},
870 "List pool-level configuration overrides.", "",
871 &get_pool_list_arguments, &execute_pool_list);
872
873 Shell::Action action_image_get(
874 {"config", "image", "get"}, {}, "Get an image-level configuration override.",
875 "", &get_image_get_arguments, &execute_image_get);
876 Shell::Action action_image_set(
877 {"config", "image", "set"}, {}, "Set an image-level configuration override.",
878 "", &get_image_set_arguments, &execute_image_set);
879 Shell::Action action_image_remove(
880 {"config", "image", "remove"}, {"config", "image", "rm"},
881 "Remove an image-level configuration override.", "",
882 &get_image_remove_arguments, &execute_image_remove);
883 Shell::Action action_image_list(
884 {"config", "image", "list"}, {"config", "image", "ls"},
885 "List image-level configuration overrides.", "",
886 &get_image_list_arguments, &execute_image_list);
887
888 } // namespace config
889 } // namespace action
890 } // namespace rbd