diff options
author | Yuri Weinstein <yweinste@redhat.com> | 2024-10-01 17:00:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-01 17:00:33 +0200 |
commit | 228fbaa453d501e880920f8a7448f02ad0907784 (patch) | |
tree | 89b534f18212408b5a155dee1e94380978afd599 /src/tools | |
parent | Merge pull request #59978 from afreen23/nvme-gateway-fix (diff) | |
parent | tools/rados: allow to read setomapheader value from file (diff) | |
download | ceph-228fbaa453d501e880920f8a7448f02ad0907784.tar.xz ceph-228fbaa453d501e880920f8a7448f02ad0907784.zip |
Merge pull request #55334 from trociny/wip-rados-setomapheader
tools/rados: allow to read setomapheader value from file
Reviewed-by: Igor Fedotov <ifedotov@suse.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/rados/rados.cc | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index da54d441e0c..9dfe9d36c0c 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -136,10 +136,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" @@ -2844,17 +2845,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) { |