Options for the display/test stage
+ -f --format the format of --dump, defaults to json-pretty
+ can be one of json, json-pretty, xml, xml-pretty,
+ table, table-kv, html, html-pretty
+ --dump dump the crush map
--tree print map summary as a tree
--check [max_id] check if any item is referencing an unknown name/type
-i mapfn --show-location id
#include "common/debug.h"
#include "common/errno.h"
#include "common/config.h"
+#include "common/Formatter.h"
#include "common/ceph_argparse.h"
#include "include/stringify.h"
cout << "\n";
cout << "Options for the display/test stage\n";
cout << "\n";
+ cout << " -f --format the format of --dump, defaults to json-pretty\n";
+ cout << " can be one of json, json-pretty, xml, xml-pretty,\n";
+ cout << " table, table-kv, html, html-pretty\n";
+ cout << " --dump dump the crush map\n";
cout << " --tree print map summary as a tree\n";
cout << " --check [max_id] check if any item is referencing an unknown name/type\n";
cout << " -i mapfn --show-location id\n";
bool test = false;
bool display = false;
bool tree = false;
+ string dump_format = "json-pretty";
+ bool dump = false;
int full_location = -1;
bool write_to_file = false;
int verbose = 0;
verbose += 1;
} else if (ceph_argparse_flag(args, i, "--tree", (char*)NULL)) {
tree = true;
+ } else if (ceph_argparse_witharg(args, i, &val, "-f", "--format", (char*)NULL)) {
+ dump_format = val;
+ } else if (ceph_argparse_flag(args, i, "--dump", (char*)NULL)) {
+ dump = true;
} else if (ceph_argparse_flag(args, i, "--show_utilization", (char*)NULL)) {
display = true;
tester.set_output_utilization(true);
cerr << "cannot specify more than one of compile, decompile, and build" << std::endl;
return EXIT_FAILURE;
}
- if (!check && !compile && !decompile && !build && !test && !reweight && !adjust && !tree &&
+ if (!check && !compile && !decompile && !build && !test && !reweight && !adjust && !tree && !dump &&
add_item < 0 && full_location < 0 &&
remove_name.empty() && reweight_name.empty()) {
cerr << "no action specified; -h for help" << std::endl;
crush.dump_tree(&cout, NULL);
}
+ if (dump) {
+ boost::scoped_ptr<Formatter> f(Formatter::create(dump_format, "json-pretty", "json-pretty"));
+ f->open_object_section("crush_map");
+ crush.dump(f.get());
+ f->close_section();
+ f->flush(cout);
+ cout << "\n";
+ }
+
if (decompile) {
CrushCompiler cc(crush, cerr, verbose);
if (!outfn.empty()) {