From cb9b1fff1355649defc2e1b8ce971c910c0b7ae9 Mon Sep 17 00:00:00 2001 From: Shengming Zhang Date: Sat, 18 Jul 2020 14:16:34 +0800 Subject: [PATCH] rgw: dump transitions in RGWLifecycleConfiguration::dump() Signed-off-by: Shengming Zhang (cherry picked from commit c843b6f08799c1fef39a4a6fd24c27207d1e951e) Conflicts: src/rgw/rgw_json_enc.cc - trivial whitespace difference - dump_object() accepts string_view in master branch, but accepts char* in nautilus branch --- src/rgw/rgw_json_enc.cc | 22 ++++++++++++++++++++++ src/rgw/rgw_lc.h | 14 +++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index b9a2ed26bfc7..5804d7c72482 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -1694,6 +1694,17 @@ void lc_op::dump(Formatter *f) const if (obj_tags) { f->dump_object("obj_tags", *obj_tags); } + f->open_object_section("transitions"); + for(auto& [storage_class, transition] : transitions) { + f->dump_object(storage_class.c_str(), transition); + } + f->close_section(); + + f->open_object_section("noncur_transitions"); + for (auto& [storage_class, transition] : noncur_transitions) { + f->dump_object(storage_class.c_str(), transition); + } + f->close_section(); } void LCFilter::dump(Formatter *f) const @@ -1717,6 +1728,17 @@ void LCRule::dump(Formatter *f) const f->dump_object("noncur_expiration", noncur_expiration); f->dump_object("mp_expiration", mp_expiration); f->dump_object("filter", filter); + f->open_object_section("transitions"); + for (auto& [storage_class, transition] : transitions) { + f->dump_object(storage_class.c_str(), transition); + } + f->close_section(); + + f->open_object_section("noncur_transitions"); + for (auto& [storage_class, transition] : noncur_transitions) { + f->dump_object(storage_class.c_str(), transition); + } + f->close_section(); f->dump_bool("dm_expiration", dm_expiration); } diff --git a/src/rgw/rgw_lc.h b/src/rgw/rgw_lc.h index e50d9b75ce12..e7daec3f91a1 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -152,7 +152,11 @@ public: decode(storage_class, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; + void dump(Formatter *f) const { + f->dump_string("days", days); + f->dump_string("date", date); + f->dump_string("storage_class", storage_class); + } }; WRITE_CLASS_ENCODER(LCTransition) @@ -369,6 +373,14 @@ struct transition_action boost::optional date; string storage_class; transition_action() : days(0) {} + void dump(Formatter *f) const { + if (!date) { + f->dump_int("days", days); + } else { + utime_t ut(*date); + f->dump_stream("date") << ut; + } + } }; /* XXX why not LCRule? */ -- 2.47.3