rbd tool changed format? (breaks compatibility)
Hello ceph team,
As you may already know, our team in GRNET is building a complete open source cloud platform called Synnefo [1], which already powers our production public cloud service ~okeanos [2].
Synnefo is using Google Ganeti for the low level VM management part [3]. As of Jan 2012, we have merged to upstream Ganeti support for VM disks on RADOS [4].
Today we received some feedback, that other people trying to run Ganeti with RADOS get an error because probably the output of the 'rbd showmapped' command has changed.
I'd like to ask if indeed the output format of the rbd tool has changed. More specifically:
1. Does the 'rbd showmapped' command still returns just the headers if no device is mapped?
2. Has the separator between the 'rbd showmapped' columns changed from \t to ""?
I don't have the latest rbd tool setup (but rather ceph-common=0.48.1argonaut-1~bpo60+1), so I can't test it right now, but I see this commit:
https://github.com/ceph/ceph/commit/bed55369a96c2651f513b8c9b1a7bb92fb87550a
How stable can we consider rbd tool's output format?
This is something we want to run in production environment. Using the tool rather than the library makes things much simpler.
Kind Regards,
Constantinos Venetsanopoulos
[1] http://synnefo.org
[2] http://okeanos.io
[3] http://code.google.com/p/ganeti/
[4] http://git.ganeti.org/?p=ganeti.git;a=commit;h=7181fba0662246b5f02764a5b3b0d500f6934dd0
Quoted 14 lines · Constantinos Venetsanopoulos
Hello ceph team,
As you may already know, our team in GRNET is building a complete open source cloud platform called Synnefo [1], which already powers our production public cloud service ~okeanos [2].
Synnefo is using Google Ganeti for the low level VM management part [3]. As of Jan 2012, we have merged to upstream Ganeti support for VM disks on RADOS [4].
Today we received some feedback, that other people trying to run Ganeti with RADOS get an error because probably the output of the 'rbd showmapped' command has changed.
Quoted 5 lines
I'd like to ask if indeed the output format of the rbd tool has changed. More specifically:
1. Does the 'rbd showmapped' command still returns just the headers if no device is mapped?
No
Quoted 2 lines
2. Has the separator between the 'rbd showmapped' columns changed from \t to ""?
Yes, this is in the release notes for 0.54 (http://ceph.com/docs/master/release-notes/#v0-54).
Quoted 5 lines
I don't have the latest rbd tool setup (but rather ceph-common=0.48.1argonaut-1~bpo60+1), so I can't test it right now, but I see this commit:
https://github.com/ceph/ceph/commit/bed55369a96c2651f513b8c9b1a7bb92fb87550a
Yeah, that's the commit that changed it.
Quoted 3 lines
How stable can we consider rbd tool's output format?
This is something we want to run in production environment. Using the tool rather than the library makes things much simpler.
Generally it won't change much, but I don't think it should be considered entirely unchanging. We'll add it to the release notes when the output does change. We'll probably switch other commands to use TextTable too, with the same results as with showmapped and lock list. We could send a message to the mailing list when the output changes as well, so you can prepare for a future release.
Perhaps we should add a --format json|plain option so you don't have to rely on particular formatting, you just parse the json. This would match existing usage by many 'ceph ...' commands, and be easier for scripts to use in general.
Josh
Quoted 15 lines · Josh Durgin
Quoted 14 lines · Constantinos Venetsanopoulos
Hello ceph team,
As you may already know, our team in GRNET is building a complete open source cloud platform called Synnefo [1], which already powers our production public cloud service ~okeanos [2].
Synnefo is using Google Ganeti for the low level VM management part [3]. As of Jan 2012, we have merged to upstream Ganeti support for VM disks on RADOS [4].
Today we received some feedback, that other people trying to run Ganeti with RADOS get an error because probably the output of the 'rbd showmapped' command has changed.
Quoted 7 lines
Quoted 5 lines
I'd like to ask if indeed the output format of the rbd tool has changed. More specifically:
1. Does the 'rbd showmapped' command still returns just the headers if no device is mapped?
No
Ack.
Quoted 7 lines
Quoted 4 lines
2. Has the separator between the 'rbd showmapped' columns changed from \t to ""?
Yes, this is in the release notes for 0.54 (http://ceph.com/docs/master/release-notes/#v0-54).
Ack.
Quoted 13 lines
Quoted 6 lines
I don't have the latest rbd tool setup (but rather ceph-common=0.48.1argonaut-1~bpo60+1), so I can't test it right now, but I see this commit:
https://github.com/ceph/ceph/commit/bed55369a96c2651f513b8c9b1a7bb92fb87550a
Yeah, that's the commit that changed it.
Quoted 3 lines
How stable can we consider rbd tool's output format?
This is something we want to run in production environment. Using the tool rather than the library makes things much simpler.
Quoted 6 lines
Generally it won't change much, but I don't think it should be considered entirely unchanging. We'll add it to the release notes when the output does change. We'll probably switch other commands to use TextTable too, with the same results as with showmapped and lock list. We could send a message to the mailing list when the output changes as well, so you can prepare for a future release.
That would be great, and highly appreciated. Please drop us an email at the following mailing lists, when the rbd tool's format changes:
[email protected]
[email protected]
Quoted 5 lines
Perhaps we should add a --format json|plain option so you don't have to rely on particular formatting, you just parse the json. This would match existing usage by many 'ceph ...' commands, and be easier for scripts to use in general.
That would be even better! That would be the best approach for us, since we use it inside python code. Parsing a json is very simple and we will be able to maintain compatibility even when the format changes.
Thanks,
Consantinos
PATCH 1/1 rbd: Add --json flag for the showmapped command
In reply to Josh Durgin---
Hi Josh,
This patch adds the '--json' flag to enable dumping the showmapped output in json format (as you suggested). I'm not sure if any other rbd subcommands could make use of this flag (so the patch is showmapped-specific atm).
Comments?
Thanks,
Stratos
man/rbd.8 | 5 +++++ src/rbd.cc | 54 +++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 46 insertions(+), 13 deletions(-)
man/rbd.8 +5 -0
@@ -132,6 +132,11 @@ be open from more than one client at once, like during live migration of a virtual machine, or for use underneath a clustered filesystem. .UNINDENT +.INDENT 0.0 +.TP +.B \-\-json +Dump output in json format (currently used only by showmapped). +.UNINDENT .SH COMMANDS .INDENT 0.0 .TP
src/rbd.cc +41 -13
106 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH] rbd: Add --json flag for the showmapped command
Quoted 5 lines · Stratos Psomadakis
Signed-off-by Stratos Psomadakis <[email protected]>---
Hi Josh,This patch adds the '--json' flag to enable dumping the showmapped output in
I think that it should be "--format=json" rather than --json. This will make it more in line with other tools. Also, then you could have the unpopular --format=xml.
Quoted 153 lines
json format (as you suggested). I'm not sure if any other rbd subcommands could make use of this flag (so the patch is showmapped-specific atm).
Comments?
Thanks,
Stratosman/rbd.8 | 5 +++++ src/rbd.cc | 54 +++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 46 insertions(+), 13 deletions(-)man/rbd.8 +5
-0@@ -132,6 +132,11 @@ be open from more than one client at once, like during live migration of a virtual machine, or for use underneath a clustered filesystem. .UNINDENT +.INDENT 0.0 +.TP +.B \-\-json +Dump output in json format (currently used only by showmapped). +.UNINDENT .SH COMMANDS .INDENT 0.0 .TPsrc/rbd.cc +41
-14@@ -47,6 +47,8 @@ #include "include/rbd_types.h" #include "common/TextTable.h" +#include "common/Formatter.h" + #if defined(__linux__) #include <linux/fs.h> #endif@@ -126,7 +128,8 @@ void usage() " format 2 supports cloning\n" " --id <username> rados user (without 'client.' prefix) to authenticate as\n" " --keyfile <path> file containing secret key for use with cephx\n" -" --shared <tag> take a shared (rather than exclusive) lock\n"; +" --shared <tag> take a shared (rather than exclusive) lock\n" +" --json dump output in json format (currently used only by showmapped)\n"; } static string feature_str(uint64_t features)@@ -1198,7 +1201,7 @@ void do_closedir(DIR *dp) closedir(dp); } -static int do_kernel_showmapped() +static int do_kernel_showmapped(bool dump_json) { int r; bool have_output = false;@@ -1220,12 +1223,18 @@ static int do_kernel_showmapped() return r; } + JSONFormatter jsf(false); TextTable tbl; - tbl.define_column("id", TextTable::LEFT, TextTable::LEFT); - tbl.define_column("pool", TextTable::LEFT, TextTable::LEFT); - tbl.define_column("image", TextTable::LEFT, TextTable::LEFT); - tbl.define_column("snap", TextTable::LEFT, TextTable::LEFT); - tbl.define_column("device", TextTable::LEFT, TextTable::LEFT); + if(dump_json == false) { + tbl.define_column("id", TextTable::LEFT, TextTable::LEFT); + tbl.define_column("pool", TextTable::LEFT, TextTable::LEFT); + tbl.define_column("image", TextTable::LEFT, TextTable::LEFT); + tbl.define_column("snap", TextTable::LEFT, TextTable::LEFT); + tbl.define_column("device", TextTable::LEFT, TextTable::LEFT); + } + else { + jsf.open_object_section("devices"); + } do { if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0)@@ -1262,13 +1271,30 @@ static int do_kernel_showmapped() << cpp_strerror(-r) << std::endl; continue; } - - tbl << dent->d_name << pool << name << snap << dev << TextTable::endrow; + + if (dump_json == false) { + tbl << dent->d_name << pool << name << snap << dev << TextTable::endrow; + } + else { + jsf.open_object_section(dent->d_name); + jsf.dump_string("pool", pool); + jsf.dump_string("name", name); + jsf.dump_string("snap", snap); + jsf.dump_string("device", dev); + jsf.close_section(); + } have_output = true; } while ((dent = readdir(device_dir.get()))); - if (have_output) - cout << tbl; + + if (dump_json == false) { + if (have_output) + cout << tbl; + } + else { + jsf.close_section(); + jsf.flush(cout); + } return 0; }@@ -1505,7 +1531,7 @@ int main(int argc, const char **argv) const char *poolname = NULL; uint64_t size = 0; // in bytes int order = 0; - bool format_specified = false; + bool format_specified = false, dump_json = false; int format = 1; uint64_t features = RBD_FEATURE_LAYERING; const char *imgname = NULL, *snapname = NULL, *destname = NULL,@@ -1579,6 +1605,8 @@ int main(int argc, const char **argv) imgname = strdup(val.c_str()); } else if (ceph_argparse_witharg(args, i, &val, "--shared", (char *)NULL)) { lock_tag = strdup(val.c_str()); + } else if (ceph_argparse_flag(args, i, "--json", (char *) NULL)) { + dump_json = true; } else { ++i; }@@ -2130,7 +2158,7 @@ if (!set_conf_param(v, p1, p2, p3)) { \ break; case OPT_SHOWMAPPED: - r = do_kernel_showmapped(); + r = do_kernel_showmapped(dump_json); if (r < 0) { cerr << "rbd: showmapped failed: " << cpp_strerror(-r) << std::endl; return EXIT_FAILURE; --1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] rbd: Add --json flag for the showmapped command
Quoted 9 lines · Yehuda Sadeh
Quoted 5 lines · Stratos Psomadakis
Signed-off-by Stratos Psomadakis <[email protected]>---
Hi Josh,This patch adds the '--json' flag to enable dumping the showmapped output in
I think that it should be "--format=json" rather than --json. This will make it more in line with other tools. Also, then you could have the unpopular --format=xml.
Hi,
the problem is that --format is arleady used in rbd (to select the rbd image format). So, you could either use --output-format= for plain/json/xml output (but then you would be inconsistent wrt the other tools), or change --format to --image-format (or something like that), and use --format to select the output formatting.
Quoted 154 lines
Quoted 154 lines
json format (as you suggested). I'm not sure if any other rbd subcommands could make use of this flag (so the patch is showmapped-specific atm).
Comments?
Thanks,
Stratosman/rbd.8 | 5 +++++ src/rbd.cc | 54 +++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 46 insertions(+), 13 deletions(-)man/rbd.8 +5
-0@@ -132,6 +132,11 @@ be open from more than one client at once, like during live migration of a virtual machine, or for use underneath a clustered filesystem. .UNINDENT +.INDENT 0.0 +.TP +.B \-\-json +Dump output in json format (currently used only by showmapped). +.UNINDENT .SH COMMANDS .INDENT 0.0 .TPsrc/rbd.cc +41
-14@@ -47,6 +47,8 @@ #include "include/rbd_types.h" #include "common/TextTable.h" +#include "common/Formatter.h" + #if defined(__linux__) #include <linux/fs.h> #endif@@ -126,7 +128,8 @@ void usage() " format 2 supports cloning\n" " --id <username> rados user (without 'client.' prefix) to authenticate as\n" " --keyfile <path> file containing secret key for use with cephx\n" -" --shared <tag> take a shared (rather than exclusive) lock\n"; +" --shared <tag> take a shared (rather than exclusive) lock\n" +" --json dump output in json format (currently used only by showmapped)\n"; } static string feature_str(uint64_t features)@@ -1198,7 +1201,7 @@ void do_closedir(DIR *dp) closedir(dp); } -static int do_kernel_showmapped() +static int do_kernel_showmapped(bool dump_json) { int r; bool have_output = false;@@ -1220,12 +1223,18 @@ static int do_kernel_showmapped() return r; } + JSONFormatter jsf(false); TextTable tbl; - tbl.define_column("id", TextTable::LEFT, TextTable::LEFT); - tbl.define_column("pool", TextTable::LEFT, TextTable::LEFT); - tbl.define_column("image", TextTable::LEFT, TextTable::LEFT); - tbl.define_column("snap", TextTable::LEFT, TextTable::LEFT); - tbl.define_column("device", TextTable::LEFT, TextTable::LEFT); + if(dump_json == false) { + tbl.define_column("id", TextTable::LEFT, TextTable::LEFT); + tbl.define_column("pool", TextTable::LEFT, TextTable::LEFT); + tbl.define_column("image", TextTable::LEFT, TextTable::LEFT); + tbl.define_column("snap", TextTable::LEFT, TextTable::LEFT); + tbl.define_column("device", TextTable::LEFT, TextTable::LEFT); + } + else { + jsf.open_object_section("devices"); + } do { if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0)@@ -1262,13 +1271,30 @@ static int do_kernel_showmapped() << cpp_strerror(-r) << std::endl; continue; } - - tbl << dent->d_name << pool << name << snap << dev << TextTable::endrow; + + if (dump_json == false) { + tbl << dent->d_name << pool << name << snap << dev << TextTable::endrow; + } + else { + jsf.open_object_section(dent->d_name); + jsf.dump_string("pool", pool); + jsf.dump_string("name", name); + jsf.dump_string("snap", snap); + jsf.dump_string("device", dev); + jsf.close_section(); + } have_output = true; } while ((dent = readdir(device_dir.get()))); - if (have_output) - cout << tbl; + + if (dump_json == false) { + if (have_output) + cout << tbl; + } + else { + jsf.close_section(); + jsf.flush(cout); + } return 0; }@@ -1505,7 +1531,7 @@ int main(int argc, const char **argv) const char *poolname = NULL; uint64_t size = 0; // in bytes int order = 0; - bool format_specified = false; + bool format_specified = false, dump_json = false; int format = 1; uint64_t features = RBD_FEATURE_LAYERING; const char *imgname = NULL, *snapname = NULL, *destname = NULL,@@ -1579,6 +1605,8 @@ int main(int argc, const char **argv) imgname = strdup(val.c_str()); } else if (ceph_argparse_witharg(args, i, &val, "--shared", (char *)NULL)) { lock_tag = strdup(val.c_str()); + } else if (ceph_argparse_flag(args, i, "--json", (char *) NULL)) { + dump_json = true; } else { ++i; }@@ -2130,7 +2158,7 @@ if (!set_conf_param(v, p1, p2, p3)) { \ break; case OPT_SHOWMAPPED: - r = do_kernel_showmapped(); + r = do_kernel_showmapped(dump_json); if (r < 0) { cerr << "rbd: showmapped failed: " << cpp_strerror(-r) << std::endl; return EXIT_FAILURE; --1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Stratos Psomadakis <[email protected]>
Re: [PATCH] rbd: Add --json flag for the showmapped command
Quoted 11 lines · Stratos Psomadakis
Quoted 9 lines · Yehuda Sadeh
Quoted 5 lines · Stratos Psomadakis
Signed-off-by Stratos Psomadakis <[email protected]>---
Hi Josh,This patch adds the '--json' flag to enable dumping the showmapped output in
I think that it should be "--format=json" rather than --json. This will make it more in line with other tools. Also, then you could have the unpopular --format=xml.
Quoted 7 lines
Hi,
the problem is that --format is arleady used in rbd (to select the rbd image format). So, you could either use --output-format= for plain/json/xml output (but then you would be inconsistent wrt the other tools), or change --format to --image-format (or something like that), and use --format to select the output formatting.
We could deprecate --format in favor of --image-format, but maintain
backwards compatibility by accepting the string 1 or 2 for --format
still. Maybe not pretty, but it lets us be consistent without changing existing usage.
Josh
Re: [PATCH] rbd: Add --json flag for the showmapped command
Quoted 28 lines · Josh Durgin
Quoted 18 lines · Stratos Psomadakis
Quoted 8 lines · Yehuda Sadeh
Quoted 5 lines · Stratos Psomadakis
Signed-off-by Stratos Psomadakis <[email protected]>---
Hi Josh,Quoted 6 lines
Quoted 2 lines
This patch adds the '--json' flag to enable dumping the showmapped output in
I think that it should be "--format=json" rather than --json. This will make it more in line with other tools. Also, then you could have the unpopular --format=xml.
Quoted 7 lines
Hi,
the problem is that --format is arleady used in rbd (to select the rbd image format). So, you could either use --output-format= for plain/json/xml output (but then you would be inconsistent wrt the other tools), or change --format to --image-format (or something like that), and use --format to select the output formatting.
Quoted 5 lines
We could deprecate --format in favor of --image-format, but maintain backwards compatibility by accepting the string 1 or 2 for --format still. Maybe not pretty, but it lets us be consistent without changing existing usage.
That would work, but we should dump a noticeable warning whenever it's being used.
Re: [PATCH] rbd: Add --json flag for the showmapped command
Quoted 29 lines · Yehuda Sadeh
Quoted 28 lines · Josh Durgin
Quoted 25 lines · Stratos Psomadakis
Quoted 8 lines · Yehuda Sadeh
Quoted 5 lines · Stratos Psomadakis
Signed-off-by Stratos Psomadakis <[email protected]>---
Hi Josh,Quoted 6 lines
Quoted 2 lines
This patch adds the '--json' flag to enable dumping the showmapped output in
I think that it should be "--format=json" rather than --json. This will make it more in line with other tools. Also, then you could have the unpopular --format=xml.
Hi,
the problem is that --format is arleady used in rbd (to select the rbd image format). So, you could either use --output-format= for plain/json/xml output (but then you would be inconsistent wrt the other tools), or change --format to --image-format (or something like that), and use --format to select the output formatting.
Quoted 7 lines
Quoted 5 lines
We could deprecate --format in favor of --image-format, but maintain backwards compatibility by accepting the string 1 or 2 for --format still. Maybe not pretty, but it lets us be consistent without changing existing usage.
That would work, but we should dump a noticeable warning whenever it's being used.
Sounds good to me.
Re: [PATCH] rbd: Add --json flag for the showmapped command
In reply to Stratos PsomadakisQuoted 7 lines · Stratos Psomadakis
Signed-off-by Stratos Psomadakis <[email protected]>---
Hi Josh,This patch adds the '--json' flag to enable dumping the showmapped output in json format (as you suggested). I'm not sure if any other rbd subcommands could make use of this flag (so the patch is showmapped-specific atm).
Thanks, this looks good overall. Mainly some style nits below.
Other subcommands that could use json output would be:
info
ls [-l]
snap ls
lock list
children
Quoted 15 lines
Comments?
Thanks,
Stratosman/rbd.8 | 5 +++++ src/rbd.cc | 54 +++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 46 insertions(+), 13 deletions(-)man/rbd.8 +0
-0@@ -132,6 +132,11 @@ be open from more than one client at once, like during live migration of a virtual machine, or for use underneath
man/rbd.8 be open from more than one client at once, like during · line 142
Quoted 10 lines
man/rbd.8 +5
-0a clustered filesystem. .UNINDENT +.INDENT 0.0 +.TP +.B \-\-json +Dump output in json format (currently used only by showmapped). +.UNINDENT .SH COMMANDS .INDENT 0.0 .TP
These man pages are actually generated from rst in ceph.git. In this case the source file is docs/man/8/rbd.rst. Building the documentation rebuilds the man pages as well [1], although this could be more explicit in the docs.
If you send the rst change, I can rebuild the man pages.
Quoted 34 lines
src/rbd.cc +5
-2@@ -47,6 +47,8 @@ #include "include/rbd_types.h" #include "common/TextTable.h" +#include "common/Formatter.h" + #if defined(__linux__) #include <linux/fs.h> #endif@@ -126,7 +128,8 @@ void usage() " format 2 supports cloning\n" " --id <username> rados user (without 'client.' prefix) to authenticate as\n" " --keyfile <path> file containing secret key for use with cephx\n" -" --shared <tag> take a shared (rather than exclusive) lock\n"; +" --shared <tag> take a shared (rather than exclusive) lock\n" +" --json dump output in json format (currently used only by showmapped)\n"; } static string feature_str(uint64_t features)@@ -1198,7 +1201,7 @@ void do_closedir(DIR *dp) closedir(dp); } -static int do_kernel_showmapped() +static int do_kernel_showmapped(bool dump_json) { int r; bool have_output = false;@@ -1220,12 +1223,18 @@ static int do_kernel_showmapped() return r;
src/rbd.cc static int do_kernel_showmapped() · line 1228
Quoted 10 lines
src/rbd.cc +2
-5} + JSONFormatter jsf(false); TextTable tbl; - tbl.define_column("id", TextTable::LEFT, TextTable::LEFT); - tbl.define_column("pool", TextTable::LEFT, TextTable::LEFT); - tbl.define_column("image", TextTable::LEFT, TextTable::LEFT); - tbl.define_column("snap", TextTable::LEFT, TextTable::LEFT); - tbl.define_column("device", TextTable::LEFT, TextTable::LEFT); + if(dump_json == false) {
Missing space between if and (. Swapping the cases so if (dump_json) came first would be a little nicer to read.
src/rbd.cc static int do_kernel_showmapped() · line 1235
Quoted 7 lines
src/rbd.cc +7
-0+ tbl.define_column("id", TextTable::LEFT, TextTable::LEFT); + tbl.define_column("pool", TextTable::LEFT, TextTable::LEFT); + tbl.define_column("image", TextTable::LEFT, TextTable::LEFT); + tbl.define_column("snap", TextTable::LEFT, TextTable::LEFT); + tbl.define_column("device", TextTable::LEFT, TextTable::LEFT); + } + else {
} else {
src/rbd.cc static int do_kernel_showmapped() · line 1275
Quoted 13 lines
src/rbd.cc +4
-2+ jsf.open_object_section("devices"); + } do { if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0)@@ -1262,13 +1271,30 @@ static int do_kernel_showmapped() << cpp_strerror(-r) << std::endl; continue; } - - tbl << dent->d_name << pool << name << snap << dev << TextTable::endrow; + + if (dump_json == false) {
same comment about swapping the cases
src/rbd.cc static int do_kernel_showmapped() · line 1278
Quoted 3 lines
src/rbd.cc +3
-0+ tbl << dent->d_name << pool << name << snap << dev << TextTable::endrow; + } + else {
} else {
Quoted 4 lines
src/rbd.cc +4
-0+ jsf.open_object_section(dent->d_name); + jsf.dump_string("pool", pool); + jsf.dump_string("name", name); + jsf.dump_string("snap", snap);
src/rbd.cc static int do_kernel_showmapped() · line 1290
Quoted 10 lines
src/rbd.cc +5
-2+ jsf.dump_string("device", dev); + jsf.close_section(); + } have_output = true; } while ((dent = readdir(device_dir.get()))); - if (have_output) - cout << tbl; + + if (dump_json == false) {
same comment about swapping the cases
src/rbd.cc static int do_kernel_showmapped() · line 1294
Quoted 4 lines
src/rbd.cc +4
-0+ if (have_output) + cout << tbl; + } + else {
} else {
Quoted 26 lines
src/rbd.cc +6
-1+ jsf.close_section(); + jsf.flush(cout); + } return 0; }@@ -1505,7 +1531,7 @@ int main(int argc, const char **argv) const char *poolname = NULL; uint64_t size = 0; // in bytes int order = 0; - bool format_specified = false; + bool format_specified = false, dump_json = false; int format = 1; uint64_t features = RBD_FEATURE_LAYERING; const char *imgname = NULL, *snapname = NULL, *destname = NULL,@@ -1579,6 +1605,8 @@ int main(int argc, const char **argv) imgname = strdup(val.c_str()); } else if (ceph_argparse_witharg(args, i, &val, "--shared", (char *)NULL)) { lock_tag = strdup(val.c_str()); + } else if (ceph_argparse_flag(args, i, "--json", (char *) NULL)) { + dump_json = true; } else { ++i; }
src/rbd.cc if (!set_conf_param(v, p1, p2, p3)) { \ · line 2164
Quoted 8 lines
src/rbd.cc +1
-1@@ -2130,7 +2158,7 @@ if (!set_conf_param(v, p1, p2, p3)) { \ break; case OPT_SHOWMAPPED: - r = do_kernel_showmapped(); + r = do_kernel_showmapped(dump_json); if (r < 0) { cerr << "rbd: showmapped failed: " << cpp_strerror(-r) << std::endl; return EXIT_FAILURE;
It'd be nice to report an error and fail if the --json option (or whatever it ends up being) is provided for a command that doesn't use it.
Josh
PATCH v2 1/1 rbd: Support plain/json/xml output formatting
This patch renames the --format option to --image-format, for specyfing the RBD image format, and uses --format to specify the output formating (to be consistent with the other ceph tools). To avoid breaking backwards compatibility with existing scripts, rbd will still accept --format [1|2] for the image format, but will print a warning message, noting its use is deprecated.
The rbd subcommands that support the new --format option are : ls, info, snap list, children, showmapped, lock list.
---
Hi,
this is the updated version of the patch. I renamed --format option to
--image-format, and used --format to specify the output formatting, as you
suggested.
I also implemented some basic error checking on the --format input, and modified the rbd subcommands you mentioned, to support plain/json/xml output formatting. Although, I'm not sure if the json and xml output of those commands is what you'd want.
The style issues should also be resolved now.
Let me know what you think.
Thanks,
Stratos
doc/man/8/rbd.rst | 6 +- src/rbd.cc | 424 ++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 325 insertions(+), 105 deletions(-)
doc/man/8/rbd.rst +5 -1
@@ -41,7 +41,7 @@ Options Parameters ========== -.. option:: --format format +.. option:: --image-format format Specifies which object layout to use. The default is 1.
@@ -100,6 +100,10 @@ Parameters live migration of a virtual machine, or for use underneath a clustered filesystem. +.. option:: --format format + + Specifies output formatting (default: plain, json, xml) + Commands ========
src/rbd.cc +320 -104
651 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH v2] rbd: Support plain/json/xml output formatting
Quoted 17 lines · Stratos Psomadakis
This patch renames the --format option to --image-format, for specyfing the RBD image format, and uses --format to specify the output formating (to be consistent with the other ceph tools). To avoid breaking backwards compatibility with existing scripts, rbd will still accept --format [1|2] for the image format, but will print a warning message, noting its use is deprecated.
The rbd subcommands that support the new --format option are : ls, info, snap list, children, showmapped, lock list.
Signed-off-by Stratos Psomadakis <[email protected]>---
Hi,this is the updated version of the patch. I renamed --format option to
--image-format, and used --format to specify the output formatting, as you
suggested.
Quoted 8 lines
I also implemented some basic error checking on the --format input, and modified the rbd subcommands you mentioned, to support plain/json/xml output formatting. Although, I'm not sure if the json and xml output of those commands is what you'd want.
The style issues should also be resolved now.
Let me know what you think.
There were still some style issues (missing braces, long lines, and spaces instead of tabs), but I squashed fixes to those into the wip-rbd-formatted-output branch.
I changed the output a bit to uses ints, arrays, etc. where it seemed appropriate. The tests aren't quite done yet, but does this new json output look good to you?
Josh
Re: [PATCH v2] rbd: Support plain/json/xml output formatting
Quoted 39 lines · Josh Durgin
Quoted 30 lines · Stratos Psomadakis
This patch renames the --format option to --image-format, for specyfing the RBD
image format, and uses --format to specify the output formating (to be consistent with the other ceph tools). To avoid breaking backwards compatibility
with existing scripts, rbd will still accept --format [1|2] for the image
format, but will print a warning message, noting its use is deprecated.The rbd subcommands that support the new --format option are : ls, info, snap
list, children, showmapped, lock list.Signed-off-by Stratos Psomadakis <[email protected]>---
Hi,this is the updated version of the patch. I renamed --format option to
--image-format, and used --format to specify the output formatting,
as you
suggested.I also implemented some basic error checking on the --format input, and modified
the rbd subcommands you mentioned, to support plain/json/xml output formatting.
Although, I'm not sure if the json and xml output of those commands is what
you'd want.Quoted 3 lines
The style issues should also be resolved now.
Let me know what you think.
There were still some style issues (missing braces, long lines, and spaces instead of tabs), but I squashed fixes to those into the wip-rbd-formatted-output branch.
Quoted 5 lines
I changed the output a bit to uses ints, arrays, etc. where it seemed appropriate. The tests aren't quite done yet, but does this new json output look good to you?
Josh
Hi,
Sorry for the delay. Thanks for resolving the style issues and cleaning this up.
Wrt the json output, I think it's fine as it is now.
Just a minor comment. The --pretty-format option doesn't seem to be documented (in either rbd --help or rbd man page). Other than that, I don't see any other issues.
Thanks,
Stratos
Signature · 2 lines
Stratos Psomadakis <[email protected]>
Re: [PATCH v2] rbd: Support plain/json/xml output formatting
Quoted 44 lines · Stratos Psomadakis
Quoted 43 lines · Josh Durgin
Quoted 30 lines · Stratos Psomadakis
This patch renames the --format option to --image-format, for specyfing the RBD
image format, and uses --format to specify the output formating (to be consistent with the other ceph tools). To avoid breaking backwards compatibility
with existing scripts, rbd will still accept --format [1|2] for the image
format, but will print a warning message, noting its use is deprecated.The rbd subcommands that support the new --format option are : ls, info, snap
list, children, showmapped, lock list.Signed-off-by Stratos Psomadakis <[email protected]>---
Hi,this is the updated version of the patch. I renamed --format option to
--image-format, and used --format to specify the output formatting,
as you
suggested.I also implemented some basic error checking on the --format input, and modified
the rbd subcommands you mentioned, to support plain/json/xml output formatting.
Although, I'm not sure if the json and xml output of those commands is what
you'd want.Quoted 3 lines
The style issues should also be resolved now.
Let me know what you think.
There were still some style issues (missing braces, long lines, and spaces instead of tabs), but I squashed fixes to those into the wip-rbd-formatted-output branch.
I changed the output a bit to uses ints, arrays, etc. where it seemed appropriate. The tests aren't quite done yet, but does this new json output look good to you?
Quoted 8 lines
Quoted 1 line
Josh
Hi,
Sorry for the delay. Thanks for resolving the style issues and cleaning this up.
Wrt the json output, I think it's fine as it is now.
Great!
Quoted 3 lines
Just a minor comment. The --pretty-format option doesn't seem to be documented (in either rbd --help or rbd man page). Other than that, I don't see any other issues.
Thanks for pointing that out. I'll fix that, the tests, and then merge it into master.
Josh