From 619b0c02449306f72d0da48e46cc00db1171c452 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 10 Jan 2018 14:46:07 -0500 Subject: [PATCH] rbd: adjusted "lock list" JSON and XML formatted output Signed-off-by: Jason Dillaman --- PendingReleaseNotes | 13 +++--- qa/workunits/rbd/test_lock_fence.sh | 4 +- .../cli-integration/rbd/formatted-output.t | 42 +++++++++++-------- src/tools/rbd/action/Lock.cc | 5 ++- 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/PendingReleaseNotes b/PendingReleaseNotes index 1b30751de3b1e..8922cec2eba94 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -1,10 +1,6 @@ 13.0.1 ------ -* The RBD C API's rbd_discard method now enforces a maximum length of - 2GB to match the C++ API's Image::discard method. This restriction - prevents overflow of the result code. - * *CephFS*: * Several "ceph mds" commands have been obsoleted and replaced @@ -25,12 +21,19 @@ mds_session_timeout, mds_session_autoclose, and mds_max_file_size are now obsolete. +* *RBD* + + * The RBD C API's rbd_discard method now enforces a maximum length of + 2GB to match the C++ API's Image::discard method. This restriction + prevents overflow of the result code. + + * The rbd CLI's "lock list" JSON and XML output has changed. + * The sample ``crush-location-hook`` script has been removed. Its output is equivalent to the built-in default behavior, so it has been replaced with an example in the CRUSH documentation. - >= 12.2.2 --------- diff --git a/qa/workunits/rbd/test_lock_fence.sh b/qa/workunits/rbd/test_lock_fence.sh index 1206da11aaf4f..e425e161d0028 100755 --- a/qa/workunits/rbd/test_lock_fence.sh +++ b/qa/workunits/rbd/test_lock_fence.sh @@ -14,8 +14,8 @@ python $RBDRW $IMAGE $LOCKID & iochild=$! # give client time to lock and start reading/writing -LOCKS='{}' -while [ "$LOCKS" == "{}" ] +LOCKS='[]' +while [ "$LOCKS" == '[]' ] do LOCKS=$(rbd lock list $IMAGE --format json) sleep 1 diff --git a/src/test/cli-integration/rbd/formatted-output.t b/src/test/cli-integration/rbd/formatted-output.t index 2b05d720d6e40..4c2faf934a1ec 100644 --- a/src/test/cli-integration/rbd/formatted-output.t +++ b/src/test/cli-integration/rbd/formatted-output.t @@ -746,7 +746,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. $ rbd lock list foo $ rbd lock list foo --format json | python -mjson.tool | sed 's/,$/, /' - {} + [] $ rbd lock list foo --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' $ rbd lock list quux @@ -754,18 +754,20 @@ whenever it is run. grep -v to ignore it, but still work on other distros. Locker*ID*Address* (glob) client.* id * (glob) $ rbd lock list quux --format json | python -mjson.tool | sed 's/,$/, /' - { - "id": { + [ + { "address": "*", (glob) + "id": "id", "locker": "client.*" (glob) } - } + ] $ rbd lock list quux --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' - + + id client.* (glob)
*
(glob) -
+
$ rbd lock list baz There are 3 shared locks on this image. @@ -775,34 +777,40 @@ whenever it is run. grep -v to ignore it, but still work on other distros. client.*id[123].* (re) client.*id[123].* (re) $ rbd lock list baz --format json | python -mjson.tool | sed 's/,$/, /' - { - "id1": { + [ + { "address": "*", (glob) + "id": "id*", (glob) "locker": "client.*" (glob) }, - "id2": { + { "address": "*", (glob) + "id": "id*", (glob) "locker": "client.*" (glob) }, - "id3": { + { "address": "*", (glob) + "id": "id*", (glob) "locker": "client.*" (glob) } - } + ] $ rbd lock list baz --format xml | xml_pp 2>&1 | grep -v '^new version at /usr/bin/xml_pp' - (glob) + + id* (glob) client.* (glob)
*
(glob) -
(glob) - (glob) + + + id* (glob) client.* (glob)
*
(glob) -
(glob) - (glob) + + + id* (glob) client.* (glob)
*
(glob) -
(glob) +
$ rbd snap list foo SNAPID NAME SIZE TIMESTAMP diff --git a/src/tools/rbd/action/Lock.cc b/src/tools/rbd/action/Lock.cc index 60d63e8efd21c..5b48190f158cd 100644 --- a/src/tools/rbd/action/Lock.cc +++ b/src/tools/rbd/action/Lock.cc @@ -48,7 +48,7 @@ static int do_lock_list(librbd::Image& image, Formatter *f) return r; if (f) { - f->open_object_section("locks"); + f->open_array_section("locks"); } else { tbl.define_column("Locker", TextTable::LEFT, TextTable::LEFT); tbl.define_column("ID", TextTable::LEFT, TextTable::LEFT); @@ -69,7 +69,8 @@ static int do_lock_list(librbd::Image& image, Formatter *f) for (std::list::const_iterator it = lockers.begin(); it != lockers.end(); ++it) { if (f) { - f->open_object_section(it->cookie.c_str()); + f->open_object_section("lock"); + f->dump_string("id", it->cookie); f->dump_string("locker", it->client); f->dump_string("address", it->address); f->close_section(); -- 2.39.5