From f16d3036185eb4c8c9a79c094772216cc58d5c0c Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Wed, 17 Oct 2018 10:43:01 -0400 Subject: [PATCH] radosgw-admin: translate reshard status codes (trivial) Fixes: http://tracker.ceph.com/issues/36486 Signed-off-by: Matt Benjamin (cherry picked from commit 731fca4f921e8227e907b204dec9f1016d66b8c3) --- src/cls/rgw/cls_rgw_types.h | 21 +++++++++++++++++++++ src/rgw/rgw_admin.cc | 19 +++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/cls/rgw/cls_rgw_types.h b/src/cls/rgw/cls_rgw_types.h index 51107c3259521..baa61c9fbd363 100644 --- a/src/cls/rgw/cls_rgw_types.h +++ b/src/cls/rgw/cls_rgw_types.h @@ -1,3 +1,6 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + #ifndef CEPH_CLS_RGW_TYPES_H #define CEPH_CLS_RGW_TYPES_H @@ -609,6 +612,24 @@ enum cls_rgw_reshard_status { CLS_RGW_RESHARD_DONE = 2, }; +static inline std::string to_string(const enum cls_rgw_reshard_status status) +{ + switch (status) { + case CLS_RGW_RESHARD_NONE: + return "CLS_RGW_RESHARD_NONE"; + break; + case CLS_RGW_RESHARD_IN_PROGRESS: + return "CLS_RGW_RESHARD_IN_PROGRESS"; + break; + case CLS_RGW_RESHARD_DONE: + return "CLS_RGW_RESHARD_DONE"; + break; + default: + break; + }; + return "Unknown reshard status"; +} + struct cls_rgw_bucket_instance_entry { cls_rgw_reshard_status reshard_status{CLS_RGW_RESHARD_NONE}; string new_bucket_instance_id; diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 311596b8820ad..c980add710cf2 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1055,6 +1055,22 @@ static void show_roles_info(vector& roles, Formatter* formatter) formatter->flush(cout); } +static void show_reshard_status( + const list& status, Formatter *formatter) +{ + formatter->open_array_section("status"); + for (const auto& entry : status) { + formatter->open_object_section("entry"); + formatter->dump_string("reshard_status", to_string(entry.reshard_status)); + formatter->dump_string("new_bucket_instance_id", + entry.new_bucket_instance_id); + formatter->dump_unsigned("num_shards", entry.num_shards); + formatter->close_section(); + } + formatter->close_section(); + formatter->flush(cout); +} + class StoreDestructor { RGWRados *store; public: @@ -6019,8 +6035,7 @@ next: return -r; } - encode_json("status", status, formatter); - formatter->flush(cout); + show_reshard_status(status, formatter); } if (opt_cmd == OPT_RESHARD_PROCESS) { -- 2.39.5