summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorMykola Golub <mykola.golub@clyso.com>2024-01-27 10:14:09 +0100
committerMykola Golub <mgolub@suse.com>2024-03-29 13:41:11 +0100
commit8e61af9614ebf2a5666e9ff6100502961b381235 (patch)
treed23c01dbe61001375add97a92df8607a6aba21c1 /src/tools
parentMerge pull request #56190 from rhcs-dashboard/disable-multi-cluster-non-hub (diff)
downloadceph-8e61af9614ebf2a5666e9ff6100502961b381235.tar.xz
ceph-8e61af9614ebf2a5666e9ff6100502961b381235.zip
tools/rados: allow to read setomapheader value from file
(similarly to setomapval) Signed-off-by: Mykola Golub <mykola.golub@clyso.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/rados/rados.cc31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc
index e6c5819666a..3d24a1b4835 100644
--- a/src/tools/rados/rados.cc
+++ b/src/tools/rados/rados.cc
@@ -133,10 +133,11 @@ void usage(ostream& out)
" getomapval <obj-name> <key> [file] show the value for the specified key\n"
" in the object's object map\n"
" setomapval <obj-name> <key> <val | --input-file file>\n"
-" rmomapkey <obj-name> <key> Remove key from the object map of <obj-name>\n"
+" rmomapkey <obj-name> <key> remove key from the object map of <obj-name>\n"
" clearomap <obj-name> [obj-name2 obj-name3...] clear all the omap keys for the specified objects\n"
-" getomapheader <obj-name> [file] Dump the hexadecimal value of the object map header of <obj-name>\n"
-" setomapheader <obj-name> <val> Set the value of the object map header of <obj-name>\n"
+" getomapheader <obj-name> [file] dump the hexadecimal value of the object map header of <obj-name>\n"
+" setomapheader <obj-name> <val | --input-file file>\n"
+" set the value of the object map header of <obj-name>\n"
" watch <obj-name> add watcher on this object\n"
" notify <obj-name> <message> notify watcher of this object with message\n"
" listwatchers <obj-name> list the watchers of this object\n"
@@ -2820,17 +2821,33 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
ret = 0;
}
} else if (strcmp(nargs[0], "setomapheader") == 0) {
- if (!pool_name || nargs.size() < (obj_name ? 2 : 3)) {
+ uint32_t min_args = 3;
+ if (obj_name) {
+ min_args--;
+ }
+ if (!input_file.empty()) {
+ min_args--;
+ }
+
+ if (!pool_name || nargs.size() < min_args) {
usage(cerr);
return 1;
}
- bufferlist bl;
if (!obj_name) {
obj_name = nargs[1];
- bl.append(nargs[2]); // val
+ }
+
+ bufferlist bl;
+ if (!input_file.empty()) {
+ string err;
+ ret = bl.read_file(input_file.c_str(), &err);
+ if (ret < 0) {
+ cerr << "error reading file " << input_file.c_str() << ": " << err << std::endl;
+ return 1;
+ }
} else {
- bl.append(nargs[1]); // val
+ bl.append(nargs[min_args - 1]); // val
}
ret = io_ctx.omap_set_header(*obj_name, bl);
if (ret < 0) {