#include "include/stringify.h"
#include "mon/MonitorDBStore.h"
#include "mon/Paxos.h"
+#include "mon/MonMap.h"
+#include "mds/MDSMap.h"
+#include "osd/OSDMap.h"
namespace po = boost::program_options;
using namespace std;
} else if (cmd == "get") {
unsigned v = 0;
string outpath;
+ bool readable = false;
string map_type;
// visible options for this command
po::options_description op_desc("Allowed 'get' options");
"output file (default: stdout)")
("version,v", po::value<unsigned>(&v),
"map version to obtain")
+ ("readable,r", po::value<bool>(&readable)->default_value(false),
+ "print the map infomation in human readable format")
;
// this is going to be a positional argument; we don't want to show
// it as an option during --help, but we do want to have it captured
::close(fd);
goto done;
}
- bl.write_fd(fd);
+
+ if (readable) {
+ stringstream ss;
+ bufferlist out;
+ if (map_type == "monmap") {
+ MonMap monmap;
+ monmap.decode(bl);
+ monmap.print(ss);
+ } else if (map_type == "osdmap") {
+ OSDMap osdmap;
+ osdmap.decode(bl);
+ osdmap.print(ss);
+ } else if (map_type == "mdsmap") {
+ MDSMap mdsmap;
+ mdsmap.decode(bl);
+ mdsmap.print(ss);
+ } else {
+ std::cerr << "This type of readable map does not exist: " << map_type << std::endl
+ << "You can only specify[osdmap|monmap|mdsmap]" << std::endl;
+ }
+ out.append(ss);
+ out.write_fd(fd);
+ } else {
+ bl.write_fd(fd);
+ }
if (!outpath.empty()) {
std::cout << "wrote " << map_type