]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw:cleanup/refactor json and xml encoders and decoders 44299/head
authorKaleb S. KEITHLEY <kkeithle@redhat.com>
Mon, 13 Dec 2021 19:33:52 +0000 (14:33 -0500)
committerKaleb S. KEITHLEY <kkeithle@redhat.com>
Mon, 13 Dec 2021 19:33:52 +0000 (14:33 -0500)
move the encoder and decoder methods into their associated class
files to eliminate undefined references to the class vtable

https://tracker.ceph.com/issues/53596

Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
31 files changed:
src/rgw/CMakeLists.txt
src/rgw/rgw_acl.cc
src/rgw/rgw_acl_s3.cc
src/rgw/rgw_basic_types.cc
src/rgw/rgw_basic_types.h
src/rgw/rgw_bucket.cc
src/rgw/rgw_bucket.h
src/rgw/rgw_cache.cc
src/rgw/rgw_common.cc
src/rgw/rgw_compression.cc
src/rgw/rgw_data_sync.cc
src/rgw/rgw_datalog.cc
src/rgw/rgw_dencoder.cc
src/rgw/rgw_json_enc.cc
src/rgw/rgw_keystone.cc
src/rgw/rgw_lc.cc
src/rgw/rgw_log.cc
src/rgw/rgw_metadata.cc
src/rgw/rgw_multi.cc
src/rgw/rgw_obj_manifest.cc
src/rgw/rgw_op.cc
src/rgw/rgw_orphan.cc
src/rgw/rgw_quota.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_sync.cc
src/rgw/rgw_sync_policy.cc
src/rgw/rgw_tag.cc
src/rgw/rgw_user.cc
src/rgw/rgw_website.cc
src/rgw/rgw_xml_enc.cc
src/rgw/rgw_zone.cc

index f0889d7cdb6e917eff4913278ddfe9889a1f764a..fa7e37615bd138902d04eec3c339ecbfd2e4bed7 100644 (file)
@@ -60,14 +60,12 @@ set(librgw_common_srcs
   rgw_etag_verifier.cc
   rgw_cors.cc
   rgw_cors_s3.cc
-  rgw_dencoder.cc
   rgw_env.cc
   rgw_es_query.cc
   rgw_formats.cc
   rgw_gc.cc
   rgw_gc_log.cc
   rgw_http_client.cc
-  rgw_json_enc.cc
   rgw_keystone.cc
   rgw_ldap.cc
   rgw_lc.cc
@@ -135,7 +133,6 @@ set(librgw_common_srcs
   rgw_user.cc
   rgw_website.cc
   rgw_xml.cc
-  rgw_xml_enc.cc
   rgw_torrent.cc
   rgw_crypt.cc
   rgw_crypt_sanitize.cc
index 413b88a9b76d9cb927f97b7f89c240bb4d4fbc97..f32a73f26529c6f09e6ab4aeb3acf0ca2c8fb52b 100644 (file)
@@ -11,6 +11,7 @@
 #include "common/Formatter.h"
 
 #include "rgw_acl.h"
+#include "rgw_acl_s3.h"
 #include "rgw_user.h"
 
 #define dout_subsys ceph_subsys_rgw
@@ -263,3 +264,179 @@ bool RGWAccessControlPolicy::is_public(const DoutPrefixProvider *dpp) const
                          );
 
 }
+
+void ACLPermission::generate_test_instances(list<ACLPermission*>& o)
+{
+  ACLPermission *p = new ACLPermission;
+  p->set_permissions(RGW_PERM_WRITE_ACP);
+  o.push_back(p);
+  o.push_back(new ACLPermission);
+}
+
+void ACLPermission::dump(Formatter *f) const
+{
+  f->dump_int("flags", flags);
+}
+
+void ACLGranteeType::dump(Formatter *f) const
+{
+  f->dump_unsigned("type", type);
+}
+
+void ACLGrant::dump(Formatter *f) const
+{
+  f->open_object_section("type");
+  type.dump(f);
+  f->close_section();
+
+  f->dump_string("id", id.to_str());
+  f->dump_string("email", email);
+
+  f->open_object_section("permission");
+  permission.dump(f);
+  f->close_section();
+
+  f->dump_string("name", name);
+  f->dump_int("group", (int)group);
+  f->dump_string("url_spec", url_spec);
+}
+
+void ACLGrant::generate_test_instances(list<ACLGrant*>& o)
+{
+  rgw_user id("rgw");
+  string name, email;
+  name = "Mr. RGW";
+  email = "r@gw";
+
+  ACLGrant *g1 = new ACLGrant;
+  g1->set_canon(id, name, RGW_PERM_READ);
+  g1->email = email;
+  o.push_back(g1);
+
+  ACLGrant *g2 = new ACLGrant;
+  g1->set_group(ACL_GROUP_AUTHENTICATED_USERS, RGW_PERM_WRITE);
+  o.push_back(g2);
+
+  o.push_back(new ACLGrant);
+}
+
+void ACLGranteeType::generate_test_instances(list<ACLGranteeType*>& o)
+{
+  ACLGranteeType *t = new ACLGranteeType;
+  t->set(ACL_TYPE_CANON_USER);
+  o.push_back(t);
+  o.push_back(new ACLGranteeType);
+}
+
+void RGWAccessControlList::generate_test_instances(list<RGWAccessControlList*>& o)
+{
+  RGWAccessControlList *acl = new RGWAccessControlList(NULL);
+
+  list<ACLGrant *> glist;
+  list<ACLGrant *>::iterator iter;
+
+  ACLGrant::generate_test_instances(glist);
+  for (iter = glist.begin(); iter != glist.end(); ++iter) {
+    ACLGrant *grant = *iter;
+    acl->add_grant(grant);
+
+    delete grant;
+  }
+  o.push_back(acl);
+  o.push_back(new RGWAccessControlList(NULL));
+}
+
+void ACLOwner::generate_test_instances(list<ACLOwner*>& o)
+{
+  ACLOwner *owner = new ACLOwner;
+  owner->id = "rgw";
+  owner->display_name = "Mr. RGW";
+  o.push_back(owner);
+  o.push_back(new ACLOwner);
+}
+
+void RGWAccessControlPolicy::generate_test_instances(list<RGWAccessControlPolicy*>& o)
+{
+  list<RGWAccessControlList *> acl_list;
+  list<RGWAccessControlList *>::iterator iter;
+  for (iter = acl_list.begin(); iter != acl_list.end(); ++iter) {
+    RGWAccessControlList::generate_test_instances(acl_list);
+    iter = acl_list.begin();
+
+    RGWAccessControlPolicy *p = new RGWAccessControlPolicy(NULL);
+    RGWAccessControlList *l = *iter;
+    p->acl = *l;
+
+    string name = "radosgw";
+    rgw_user id("rgw");
+    p->owner.set_name(name);
+    p->owner.set_id(id);
+
+    o.push_back(p);
+
+    delete l;
+  }
+
+  o.push_back(new RGWAccessControlPolicy(NULL));
+}
+
+void RGWAccessControlList::dump(Formatter *f) const
+{
+  map<string, int>::const_iterator acl_user_iter = acl_user_map.begin();
+  f->open_array_section("acl_user_map");
+  for (; acl_user_iter != acl_user_map.end(); ++acl_user_iter) {
+    f->open_object_section("entry");
+    f->dump_string("user", acl_user_iter->first);
+    f->dump_int("acl", acl_user_iter->second);
+    f->close_section();
+  }
+  f->close_section();
+
+  map<uint32_t, int>::const_iterator acl_group_iter = acl_group_map.begin();
+  f->open_array_section("acl_group_map");
+  for (; acl_group_iter != acl_group_map.end(); ++acl_group_iter) {
+    f->open_object_section("entry");
+    f->dump_unsigned("group", acl_group_iter->first);
+    f->dump_int("acl", acl_group_iter->second);
+    f->close_section();
+  }
+  f->close_section();
+
+  multimap<string, ACLGrant>::const_iterator giter = grant_map.begin();
+  f->open_array_section("grant_map");
+  for (; giter != grant_map.end(); ++giter) {
+    f->open_object_section("entry");
+    f->dump_string("id", giter->first);
+    f->open_object_section("grant");
+    giter->second.dump(f);
+    f->close_section();
+    f->close_section();
+  }
+  f->close_section();
+}
+
+void ACLOwner::dump(Formatter *f) const
+{
+  encode_json("id", id.to_str(), f);
+  encode_json("display_name", display_name, f);
+}
+
+void ACLOwner::decode_json(JSONObj *obj) {
+  string id_str;
+  JSONDecoder::decode_json("id", id_str, obj);
+  id.from_str(id_str);
+  JSONDecoder::decode_json("display_name", display_name, obj);
+}
+
+void RGWAccessControlPolicy::dump(Formatter *f) const
+{
+  encode_json("acl", acl, f);
+  encode_json("owner", owner, f);
+}
+
+ACLGroupTypeEnum ACLGrant::uri_to_group(string& uri)
+{
+  // this is required for backward compatibility
+  return ACLGrant_S3::uri_to_group(uri);
+}
+
index 82496e753433bcf45d869bc87330fc3f1c0c63b8..0d83ff13c2f74076cdd346508318f4f30f321901 100644 (file)
@@ -631,3 +631,13 @@ XMLObj *RGWACLXMLParser_S3::alloc_obj(const char *el)
   return obj;
 }
 
+ACLGroupTypeEnum ACLGrant_S3::uri_to_group(string& uri)
+{
+  if (uri.compare(rgw_uri_all_users) == 0)
+    return ACL_GROUP_ALL_USERS;
+  else if (uri.compare(rgw_uri_auth_users) == 0)
+    return ACL_GROUP_AUTHENTICATED_USERS;
+
+  return ACL_GROUP_NONE;
+}
+
index ed7806e6a5772abf5076070a092b83b51c4a14a3..f306fa10ac9ea1e5e4afbec472fda45749d9f3df 100644 (file)
@@ -8,13 +8,18 @@
 #include "cls/user/cls_user_types.h"
 
 #include "rgw_basic_types.h"
+#include "rgw_bucket.h"
 #include "rgw_xml.h"
+
 #include "common/ceph_json.h"
+#include "common/Formatter.h"
 
 using std::ostream;
 using std::string;
 using std::stringstream;
 
+using namespace std;
+
 void decode_json_obj(rgw_user& val, JSONObj *obj)
 {
   val.from_str(obj->get_data());
@@ -70,6 +75,14 @@ std::string rgw_bucket::get_key(char tenant_delim, char id_delim, size_t reserve
   return key;
 }
 
+void rgw_bucket::generate_test_instances(list<rgw_bucket*>& o)
+{
+  rgw_bucket *b = new rgw_bucket;
+  init_bucket(b, "tenant", "name", "pool", ".index_pool", "marker", "123");
+  o.push_back(b);
+  o.push_back(new rgw_bucket);
+}
+
 std::string rgw_bucket_shard::get_key(char tenant_delim, char id_delim,
                                       char shard_delim) const
 {
@@ -92,6 +105,50 @@ void decode_json_obj(rgw_zone_id& zid, JSONObj *obj)
   decode_json_obj(zid.id, obj);
 }
 
+void rgw_user::generate_test_instances(list<rgw_user*>& o)
+{
+  rgw_user *u = new rgw_user("tenant", "user");
+
+  o.push_back(u);
+  o.push_back(new rgw_user);
+}
+
+void rgw_data_placement_target::dump(Formatter *f) const
+{
+  encode_json("data_pool", data_pool, f);
+  encode_json("data_extra_pool", data_extra_pool, f);
+  encode_json("index_pool", index_pool, f);
+}
+
+void rgw_data_placement_target::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("data_pool", data_pool, obj);
+  JSONDecoder::decode_json("data_extra_pool", data_extra_pool, obj);
+  JSONDecoder::decode_json("index_pool", index_pool, obj);
+}
+
+void rgw_bucket::dump(Formatter *f) const
+{
+  encode_json("name", name, f);
+  encode_json("marker", marker, f);
+  encode_json("bucket_id", bucket_id, f);
+  encode_json("tenant", tenant, f);
+  encode_json("explicit_placement", explicit_placement, f);
+}
+
+void rgw_bucket::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("name", name, obj);
+  JSONDecoder::decode_json("marker", marker, obj);
+  JSONDecoder::decode_json("bucket_id", bucket_id, obj);
+  JSONDecoder::decode_json("tenant", tenant, obj);
+  JSONDecoder::decode_json("explicit_placement", explicit_placement, obj);
+  if (explicit_placement.data_pool.empty()) {
+    /* decoding old format */
+    JSONDecoder::decode_json("pool", explicit_placement.data_pool, obj);
+    JSONDecoder::decode_json("data_extra_pool", explicit_placement.data_extra_pool, obj);
+    JSONDecoder::decode_json("index_pool", explicit_placement.index_pool, obj);
+  }
+}
+
 namespace rgw {
 namespace auth {
 ostream& operator <<(ostream& m, const Principal& p) {
index fc155fb1c13ef48fbb2ace114b90a65c9f1939c3..ab128686940ec6c80ac0222b7fc1170a2062f278 100644 (file)
@@ -510,9 +510,22 @@ inline std::ostream& operator<<(std::ostream& os, const rgw_zone_id& zid) {
   return os;
 }
 
-void encode_json_impl(const char *name, const rgw_zone_id& zid, ceph::Formatter *f);
-void decode_json_obj(rgw_zone_id& zid, JSONObj *obj);
-
+struct obj_version;
+struct rgw_placement_rule;
+struct RGWAccessKey;
+class RGWUserCaps;
+
+extern void encode_json(const char *name, const obj_version& v, Formatter *f);
+extern void encode_json(const char *name, const RGWUserCaps& val, Formatter *f);
+extern void encode_json(const char *name, const rgw_pool& pool, Formatter *f);
+extern void encode_json(const char *name, const rgw_placement_rule& r, Formatter *f);
+extern void encode_json_impl(const char *name, const rgw_zone_id& zid, ceph::Formatter *f);
+extern void encode_json_plain(const char *name, const RGWAccessKey& val, Formatter *f);
+
+extern void decode_json_obj(obj_version& v, JSONObj *obj);
+extern void decode_json_obj(rgw_zone_id& zid, JSONObj *obj);
+extern void decode_json_obj(rgw_pool& pool, JSONObj *obj);
+extern void decode_json_obj(rgw_placement_rule& v, JSONObj *obj);
 
 // Represents an identity. This is more wide-ranging than a
 // 'User'. Its purposes is to be matched against by an
index f3bb7f55d5c780d02f2ae2d45a30182c1df81396..d13c856ab31b5b7c0a61a5bb765b316abe784138 100644 (file)
@@ -63,6 +63,15 @@ using namespace std;
 // (use marker to bridge between calls)
 static constexpr size_t listing_max_entries = 1000;
 
+void init_bucket(rgw_bucket *b, const char *t, const char *n, const char *dp, const char *ip, const char *m, const char *id)
+{
+  b->tenant = t;
+  b->name = n;
+  b->marker = m;
+  b->bucket_id = id;
+  b->explicit_placement.data_pool = rgw_pool(dp);
+  b->explicit_placement.index_pool = rgw_pool(ip);
+}
 
 /*
  * The tenant_name is always returned on purpose. May be empty, of course.
@@ -3072,3 +3081,41 @@ RGWBucketInstanceMetadataHandlerBase *RGWArchiveBucketInstanceMetaHandlerAllocat
   return new RGWArchiveBucketInstanceMetadataHandler();
 }
 
+
+void RGWBucketEntryPoint::generate_test_instances(list<RGWBucketEntryPoint*>& o)
+{
+  RGWBucketEntryPoint *bp = new RGWBucketEntryPoint();
+  init_bucket(&bp->bucket, "tenant", "bucket", "pool", ".index.pool", "marker", "10");
+  bp->owner = "owner";
+  bp->creation_time = ceph::real_clock::from_ceph_timespec({ceph_le32(2), ceph_le32(3)});
+
+  o.push_back(bp);
+  o.push_back(new RGWBucketEntryPoint);
+}
+
+void RGWBucketEntryPoint::dump(Formatter *f) const
+{
+  encode_json("bucket", bucket, f);
+  encode_json("owner", owner, f);
+  utime_t ut(creation_time);
+  encode_json("creation_time", ut, f);
+  encode_json("linked", linked, f);
+  encode_json("has_bucket_info", has_bucket_info, f);
+  if (has_bucket_info) {
+    encode_json("old_bucket_info", old_bucket_info, f);
+  }
+}
+
+void RGWBucketEntryPoint::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("bucket", bucket, obj);
+  JSONDecoder::decode_json("owner", owner, obj);
+  utime_t ut;
+  JSONDecoder::decode_json("creation_time", ut, obj);
+  creation_time = ut.to_real_time();
+  JSONDecoder::decode_json("linked", linked, obj);
+  JSONDecoder::decode_json("has_bucket_info", has_bucket_info, obj);
+  if (has_bucket_info) {
+    JSONDecoder::decode_json("old_bucket_info", old_bucket_info, obj);
+  }
+}
+
index 0dbc4904f2acd55c2f12e29166ab6b25227fcf54..1f0c1ef94f853507332a9b97495963fef0c00f1e 100644 (file)
@@ -38,6 +38,8 @@ class RGWBucketCtl;
 class RGWZone;
 struct RGWZoneParams;
 
+extern void init_bucket(rgw_bucket *b, const char *t, const char *n, const char *dp, const char *ip, const char *m, const char *id);
+
 extern int rgw_bucket_parse_bucket_instance(const std::string& bucket_instance, std::string *bucket_name, std::string *bucket_id, int *shard_id);
 extern int rgw_bucket_parse_bucket_key(CephContext *cct, const std::string& key,
                                        rgw_bucket* bucket, int *shard_id);
index c38f19df020db2fb6b58cd6da9879a93f43cf55a..dd7a826cdd87f1f173125378070703b928090e3a 100644 (file)
@@ -357,3 +357,63 @@ ObjectCache::~ObjectCache()
   }
 }
 
+void ObjectMetaInfo::generate_test_instances(list<ObjectMetaInfo*>& o)
+{
+  ObjectMetaInfo *m = new ObjectMetaInfo;
+  m->size = 1024 * 1024;
+  o.push_back(m);
+  o.push_back(new ObjectMetaInfo);
+}
+
+void ObjectMetaInfo::dump(Formatter *f) const
+{
+  encode_json("size", size, f);
+  encode_json("mtime", utime_t(mtime), f);
+}
+
+void ObjectCacheInfo::generate_test_instances(list<ObjectCacheInfo*>& o)
+{
+  using ceph::encode;
+  ObjectCacheInfo *i = new ObjectCacheInfo;
+  i->status = 0;
+  i->flags = CACHE_FLAG_MODIFY_XATTRS;
+  string s = "this is a string";
+  string s2 = "this is a another string";
+  bufferlist data, data2;
+  encode(s, data);
+  encode(s2, data2);
+  i->data = data;
+  i->xattrs["x1"] = data;
+  i->xattrs["x2"] = data2;
+  i->rm_xattrs["r2"] = data2;
+  i->rm_xattrs["r3"] = data;
+  i->meta.size = 512 * 1024;
+  o.push_back(i);
+  o.push_back(new ObjectCacheInfo);
+}
+
+void ObjectCacheInfo::dump(Formatter *f) const
+{
+  encode_json("status", status, f);
+  encode_json("flags", flags, f);
+  encode_json("data", data, f);
+  encode_json_map("xattrs", "name", "value", "length", xattrs, f);
+  encode_json_map("rm_xattrs", "name", "value", "length", rm_xattrs, f);
+  encode_json("meta", meta, f);
+
+}
+
+void RGWCacheNotifyInfo::generate_test_instances(list<RGWCacheNotifyInfo*>& o)
+{
+  o.push_back(new RGWCacheNotifyInfo);
+}
+
+void RGWCacheNotifyInfo::dump(Formatter *f) const
+{
+  encode_json("op", op, f);
+  encode_json("obj", obj, f);
+  encode_json("obj_info", obj_info, f);
+  encode_json("ofs", ofs, f);
+  encode_json("ns", ns, f);
+}
+
index ab8481a77dfe85f0f1247d1dc6faf5a088745ae3..590705605c00a03dd7e88398f0dff6eee6390cff 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "json_spirit/json_spirit.h"
 #include "common/ceph_json.h"
+#include "common/Formatter.h"
 
 #include "rgw_op.h"
 #include "rgw_common.h"
@@ -22,7 +23,6 @@
 #include "common/armor.h"
 #include "common/errno.h"
 #include "common/Clock.h"
-#include "common/Formatter.h"
 #include "common/convenience.h"
 #include "common/strtol.h"
 #include "include/str_list.h"
@@ -2302,3 +2302,604 @@ bool RGWBucketInfo::empty_sync_policy() const
   return sync_policy->empty();
 }
 
+struct rgw_pool;
+struct rgw_placement_rule;
+class RGWUserCaps;
+
+void decode_json_obj(rgw_pool& pool, JSONObj *obj)
+{
+  string s;
+  decode_json_obj(s, obj);
+  pool = rgw_pool(s);
+}
+
+void encode_json(const char *name, const rgw_placement_rule& r, Formatter *f)
+{
+  encode_json(name, r.to_str(), f);
+}
+
+void encode_json(const char *name, const rgw_pool& pool, Formatter *f)
+{
+  f->dump_string(name, pool.to_str());
+}
+
+void encode_json(const char *name, const RGWUserCaps& val, Formatter *f)
+{
+  val.dump(f, name);
+}
+
+void RGWBucketEnt::generate_test_instances(list<RGWBucketEnt*>& o)
+{
+  RGWBucketEnt *e = new RGWBucketEnt;
+  init_bucket(&e->bucket, "tenant", "bucket", "pool", ".index_pool", "marker", "10");
+  e->size = 1024;
+  e->size_rounded = 4096;
+  e->count = 1;
+  o.push_back(e);
+  o.push_back(new RGWBucketEnt);
+}
+
+void RGWBucketEnt::dump(Formatter *f) const
+{
+  encode_json("bucket", bucket, f);
+  encode_json("size", size, f);
+  encode_json("size_rounded", size_rounded, f);
+  utime_t ut(creation_time);
+  encode_json("mtime", ut, f); /* mtime / creation time discrepency needed for backward compatibility */
+  encode_json("count", count, f);
+  encode_json("placement_rule", placement_rule.to_str(), f);
+}
+
+void rgw_obj::generate_test_instances(list<rgw_obj*>& o)
+{
+  rgw_bucket b;
+  init_bucket(&b, "tenant", "bucket", "pool", ".index_pool", "marker", "10");
+  rgw_obj *obj = new rgw_obj(b, "object");
+  o.push_back(obj);
+  o.push_back(new rgw_obj);
+}
+
+void rgw_bucket_placement::dump(Formatter *f) const
+{
+  encode_json("bucket", bucket, f);
+  encode_json("placement_rule", placement_rule, f);
+}
+
+void RGWBucketInfo::generate_test_instances(list<RGWBucketInfo*>& o)
+{
+  // Since things without a log will have one synthesized on decode,
+  // ensure the things we attempt to encode will have one added so we
+  // round-trip properly.
+  auto gen_layout = [](rgw::BucketLayout& l) {
+    l.current_index.gen = 0;
+    l.current_index.layout.normal.hash_type = rgw::BucketHashType::Mod;
+    l.current_index.layout.type = rgw::BucketIndexType::Normal;
+    l.current_index.layout.normal.num_shards = 11;
+    l.logs.push_back(log_layout_from_index(
+                       l.current_index.gen,
+                       l.current_index.layout.normal));
+  };
+
+
+  RGWBucketInfo *i = new RGWBucketInfo;
+  init_bucket(&i->bucket, "tenant", "bucket", "pool", ".index_pool", "marker", "10");
+  i->owner = "owner";
+  i->flags = BUCKET_SUSPENDED;
+  gen_layout(i->layout);
+  o.push_back(i);
+  i = new RGWBucketInfo;
+  gen_layout(i->layout);
+  o.push_back(i);
+}
+
+void RGWBucketInfo::dump(Formatter *f) const
+{
+  encode_json("bucket", bucket, f);
+  utime_t ut(creation_time);
+  encode_json("creation_time", ut, f);
+  encode_json("owner", owner.to_str(), f);
+  encode_json("flags", flags, f);
+  encode_json("zonegroup", zonegroup, f);
+  encode_json("placement_rule", placement_rule, f);
+  encode_json("has_instance_obj", has_instance_obj, f);
+  encode_json("quota", quota, f);
+  encode_json("num_shards", layout.current_index.layout.normal.num_shards, f);
+  encode_json("bi_shard_hash_type", (uint32_t)layout.current_index.layout.normal.hash_type, f);
+  encode_json("requester_pays", requester_pays, f);
+  encode_json("has_website", has_website, f);
+  if (has_website) {
+    encode_json("website_conf", website_conf, f);
+  }
+  encode_json("swift_versioning", swift_versioning, f);
+  encode_json("swift_ver_location", swift_ver_location, f);
+  encode_json("index_type", (uint32_t)layout.current_index.layout.type, f);
+  encode_json("mdsearch_config", mdsearch_config, f);
+  encode_json("reshard_status", (int)reshard_status, f);
+  encode_json("new_bucket_instance_id", new_bucket_instance_id, f);
+  if (!empty_sync_policy()) {
+    encode_json("sync_policy", *sync_policy, f);
+  }
+}
+
+void RGWBucketInfo::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("bucket", bucket, obj);
+  utime_t ut;
+  JSONDecoder::decode_json("creation_time", ut, obj);
+  creation_time = ut.to_real_time();
+  JSONDecoder::decode_json("owner", owner, obj);
+  JSONDecoder::decode_json("flags", flags, obj);
+  JSONDecoder::decode_json("zonegroup", zonegroup, obj);
+  /* backward compatability with region */
+  if (zonegroup.empty()) {
+    JSONDecoder::decode_json("region", zonegroup, obj);
+  }
+  string pr;
+  JSONDecoder::decode_json("placement_rule", pr, obj);
+  placement_rule.from_str(pr);
+  JSONDecoder::decode_json("has_instance_obj", has_instance_obj, obj);
+  JSONDecoder::decode_json("quota", quota, obj);
+  JSONDecoder::decode_json("num_shards", layout.current_index.layout.normal.num_shards, obj);
+  uint32_t hash_type;
+  JSONDecoder::decode_json("bi_shard_hash_type", hash_type, obj);
+  layout.current_index.layout.normal.hash_type = static_cast<rgw::BucketHashType>(hash_type);
+  JSONDecoder::decode_json("requester_pays", requester_pays, obj);
+  JSONDecoder::decode_json("has_website", has_website, obj);
+  if (has_website) {
+    JSONDecoder::decode_json("website_conf", website_conf, obj);
+  }
+  JSONDecoder::decode_json("swift_versioning", swift_versioning, obj);
+  JSONDecoder::decode_json("swift_ver_location", swift_ver_location, obj);
+  uint32_t it;
+  JSONDecoder::decode_json("index_type", it, obj);
+  layout.current_index.layout.type = (rgw::BucketIndexType)it;
+  JSONDecoder::decode_json("mdsearch_config", mdsearch_config, obj);
+  int rs;
+  JSONDecoder::decode_json("reshard_status", rs, obj);
+  reshard_status = (cls_rgw_reshard_status)rs;
+
+  rgw_sync_policy_info sp;
+  JSONDecoder::decode_json("sync_policy", sp, obj);
+  if (!sp.empty()) {
+    set_sync_policy(std::move(sp));
+  }
+}
+
+void RGWUserInfo::generate_test_instances(list<RGWUserInfo*>& o)
+{
+  RGWUserInfo *i = new RGWUserInfo;
+  i->user_id = "user_id";
+  i->display_name =  "display_name";
+  i->user_email = "user@email";
+  RGWAccessKey k1, k2;
+  k1.id = "id1";
+  k1.key = "key1";
+  k2.id = "id2";
+  k2.subuser = "subuser";
+  RGWSubUser u;
+  u.name = "id2";
+  u.perm_mask = 0x1;
+  i->access_keys[k1.id] = k1;
+  i->swift_keys[k2.id] = k2;
+  i->subusers[u.name] = u;
+  o.push_back(i);
+
+  o.push_back(new RGWUserInfo);
+}
+
+static void user_info_dump_subuser(const char *name, const RGWSubUser& subuser, Formatter *f, void *parent)
+{
+  RGWUserInfo *info = static_cast<RGWUserInfo *>(parent);
+  subuser.dump(f, info->user_id.to_str());
+}
+
+static void user_info_dump_key(const char *name, const RGWAccessKey& key, Formatter *f, void *parent)
+{
+  RGWUserInfo *info = static_cast<RGWUserInfo *>(parent);
+  key.dump(f, info->user_id.to_str(), false);
+}
+
+static void user_info_dump_swift_key(const char *name, const RGWAccessKey& key, Formatter *f, void *parent)
+{
+  RGWUserInfo *info = static_cast<RGWUserInfo *>(parent);
+  key.dump(f, info->user_id.to_str(), true);
+}
+
+static void decode_access_keys(map<string, RGWAccessKey>& m, JSONObj *o)
+{
+  RGWAccessKey k;
+  k.decode_json(o);
+  m[k.id] = k;
+}
+
+static void decode_swift_keys(map<string, RGWAccessKey>& m, JSONObj *o)
+{
+  RGWAccessKey k;
+  k.decode_json(o, true);
+  m[k.id] = k;
+}
+
+static void decode_subusers(map<string, RGWSubUser>& m, JSONObj *o)
+{
+  RGWSubUser u;
+  u.decode_json(o);
+  m[u.name] = u;
+}
+
+
+struct rgw_flags_desc {
+  uint32_t mask;
+  const char *str;
+};
+
+static struct rgw_flags_desc rgw_perms[] = {
+ { RGW_PERM_FULL_CONTROL, "full-control" },
+ { RGW_PERM_READ | RGW_PERM_WRITE, "read-write" },
+ { RGW_PERM_READ, "read" },
+ { RGW_PERM_WRITE, "write" },
+ { RGW_PERM_READ_ACP, "read-acp" },
+ { RGW_PERM_WRITE_ACP, "write-acp" },
+ { 0, NULL }
+};
+
+void rgw_perm_to_str(uint32_t mask, char *buf, int len)
+{
+  const char *sep = "";
+  int pos = 0;
+  if (!mask) {
+    snprintf(buf, len, "<none>");
+    return;
+  }
+  while (mask) {
+    uint32_t orig_mask = mask;
+    for (int i = 0; rgw_perms[i].mask; i++) {
+      struct rgw_flags_desc *desc = &rgw_perms[i];
+      if ((mask & desc->mask) == desc->mask) {
+        pos += snprintf(buf + pos, len - pos, "%s%s", sep, desc->str);
+        if (pos == len)
+          return;
+        sep = ", ";
+        mask &= ~desc->mask;
+        if (!mask)
+          return;
+      }
+    }
+    if (mask == orig_mask) // no change
+      break;
+  }
+}
+
+uint32_t rgw_str_to_perm(const char *str)
+{
+  if (strcasecmp(str, "") == 0)
+    return RGW_PERM_NONE;
+  else if (strcasecmp(str, "read") == 0)
+    return RGW_PERM_READ;
+  else if (strcasecmp(str, "write") == 0)
+    return RGW_PERM_WRITE;
+  else if (strcasecmp(str, "readwrite") == 0)
+    return RGW_PERM_READ | RGW_PERM_WRITE;
+  else if (strcasecmp(str, "full") == 0)
+    return RGW_PERM_FULL_CONTROL;
+
+  return RGW_PERM_INVALID;
+}
+
+template <class T>
+static void mask_to_str(T *mask_list, uint32_t mask, char *buf, int len)
+{
+  const char *sep = "";
+  int pos = 0;
+  if (!mask) {
+    snprintf(buf, len, "<none>");
+    return;
+  }
+  while (mask) {
+    uint32_t orig_mask = mask;
+    for (int i = 0; mask_list[i].mask; i++) {
+      T *desc = &mask_list[i];
+      if ((mask & desc->mask) == desc->mask) {
+        pos += snprintf(buf + pos, len - pos, "%s%s", sep, desc->str);
+        if (pos == len)
+          return;
+        sep = ", ";
+        mask &= ~desc->mask;
+        if (!mask)
+          return;
+      }
+    }
+    if (mask == orig_mask) // no change
+      break;
+  }
+}
+
+static void perm_to_str(uint32_t mask, char *buf, int len)
+{
+  return mask_to_str(rgw_perms, mask, buf, len);
+}
+
+static struct rgw_flags_desc op_type_flags[] = {
+ { RGW_OP_TYPE_READ, "read" },
+ { RGW_OP_TYPE_WRITE, "write" },
+ { RGW_OP_TYPE_DELETE, "delete" },
+ { 0, NULL }
+};
+
+void op_type_to_str(uint32_t mask, char *buf, int len)
+{
+  return mask_to_str(op_type_flags, mask, buf, len);
+}
+
+void RGWUserInfo::dump(Formatter *f) const
+{
+
+  encode_json("user_id", user_id.to_str(), f);
+  encode_json("display_name", display_name, f);
+  encode_json("email", user_email, f);
+  encode_json("suspended", (int)suspended, f);
+  encode_json("max_buckets", (int)max_buckets, f);
+
+  encode_json_map("subusers", NULL, "subuser", NULL, user_info_dump_subuser,(void *)this, subusers, f);
+  encode_json_map("keys", NULL, "key", NULL, user_info_dump_key,(void *)this, access_keys, f);
+  encode_json_map("swift_keys", NULL, "key", NULL, user_info_dump_swift_key,(void *)this, swift_keys, f);
+
+  encode_json("caps", caps, f);
+
+  char buf[256];
+  op_type_to_str(op_mask, buf, sizeof(buf));
+  encode_json("op_mask", (const char *)buf, f);
+
+  if (system) { /* no need to show it for every user */
+    encode_json("system", (bool)system, f);
+  }
+  if (admin) {
+    encode_json("admin", (bool)admin, f);
+  }
+  encode_json("default_placement", default_placement.name, f);
+  encode_json("default_storage_class", default_placement.storage_class, f);
+  encode_json("placement_tags", placement_tags, f);
+  encode_json("bucket_quota", bucket_quota, f);
+  encode_json("user_quota", user_quota, f);
+  encode_json("temp_url_keys", temp_url_keys, f);
+
+  string user_source_type;
+  switch ((RGWIdentityType)type) {
+  case TYPE_RGW:
+    user_source_type = "rgw";
+    break;
+  case TYPE_KEYSTONE:
+    user_source_type = "keystone";
+    break;
+  case TYPE_LDAP:
+    user_source_type = "ldap";
+    break;
+  case TYPE_NONE:
+    user_source_type = "none";
+    break;
+  default:
+    user_source_type = "none";
+    break;
+  }
+  encode_json("type", user_source_type, f);
+  encode_json("mfa_ids", mfa_ids, f);
+}
+
+void RGWUserInfo::decode_json(JSONObj *obj)
+{
+  string uid;
+
+  JSONDecoder::decode_json("user_id", uid, obj, true);
+  user_id.from_str(uid);
+
+  JSONDecoder::decode_json("display_name", display_name, obj);
+  JSONDecoder::decode_json("email", user_email, obj);
+  bool susp = false;
+  JSONDecoder::decode_json("suspended", susp, obj);
+  suspended = (__u8)susp;
+  JSONDecoder::decode_json("max_buckets", max_buckets, obj);
+
+  JSONDecoder::decode_json("keys", access_keys, decode_access_keys, obj);
+  JSONDecoder::decode_json("swift_keys", swift_keys, decode_swift_keys, obj);
+  JSONDecoder::decode_json("subusers", subusers, decode_subusers, obj);
+
+  JSONDecoder::decode_json("caps", caps, obj);
+
+  string mask_str;
+  JSONDecoder::decode_json("op_mask", mask_str, obj);
+  rgw_parse_op_type_list(mask_str, &op_mask);
+
+  bool sys = false;
+  JSONDecoder::decode_json("system", sys, obj);
+  system = (__u8)sys;
+  bool ad = false;
+  JSONDecoder::decode_json("admin", ad, obj);
+  admin = (__u8)ad;
+  JSONDecoder::decode_json("default_placement", default_placement.name, obj);
+  JSONDecoder::decode_json("default_storage_class", default_placement.storage_class, obj);
+  JSONDecoder::decode_json("placement_tags", placement_tags, obj);
+  JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
+  JSONDecoder::decode_json("user_quota", user_quota, obj);
+  JSONDecoder::decode_json("temp_url_keys", temp_url_keys, obj);
+
+  string user_source_type;
+  JSONDecoder::decode_json("type", user_source_type, obj);
+  if (user_source_type == "rgw") {
+    type = TYPE_RGW;
+  } else if (user_source_type == "keystone") {
+    type = TYPE_KEYSTONE;
+  } else if (user_source_type == "ldap") {
+    type = TYPE_LDAP;
+  } else if (user_source_type == "none") {
+    type = TYPE_NONE;
+  }
+  JSONDecoder::decode_json("mfa_ids", mfa_ids, obj);
+}
+
+
+void RGWSubUser::generate_test_instances(list<RGWSubUser*>& o)
+{
+  RGWSubUser *u = new RGWSubUser;
+  u->name = "name";
+  u->perm_mask = 0xf;
+  o.push_back(u);
+  o.push_back(new RGWSubUser);
+}
+
+void RGWSubUser::dump(Formatter *f) const
+{
+  encode_json("id", name, f);
+  char buf[256];
+  perm_to_str(perm_mask, buf, sizeof(buf));
+  encode_json("permissions", (const char *)buf, f);
+}
+
+void RGWSubUser::dump(Formatter *f, const string& user) const
+{
+  string s = user;
+  s.append(":");
+  s.append(name);
+  encode_json("id", s, f);
+  char buf[256];
+  perm_to_str(perm_mask, buf, sizeof(buf));
+  encode_json("permissions", (const char *)buf, f);
+}
+
+uint32_t str_to_perm(const string& s)
+{
+  if (s.compare("read") == 0)
+    return RGW_PERM_READ;
+  else if (s.compare("write") == 0)
+    return RGW_PERM_WRITE;
+  else if (s.compare("read-write") == 0)
+    return RGW_PERM_READ | RGW_PERM_WRITE;
+  else if (s.compare("full-control") == 0)
+    return RGW_PERM_FULL_CONTROL;
+  return 0;
+}
+
+void RGWSubUser::decode_json(JSONObj *obj)
+{
+  string uid;
+  JSONDecoder::decode_json("id", uid, obj);
+  int pos = uid.find(':');
+  if (pos >= 0)
+    name = uid.substr(pos + 1);
+  string perm_str;
+  JSONDecoder::decode_json("permissions", perm_str, obj);
+  perm_mask = str_to_perm(perm_str);
+}
+
+void RGWAccessKey::generate_test_instances(list<RGWAccessKey*>& o)
+{
+  RGWAccessKey *k = new RGWAccessKey;
+  k->id = "id";
+  k->key = "key";
+  k->subuser = "subuser";
+  o.push_back(k);
+  o.push_back(new RGWAccessKey);
+}
+
+void RGWAccessKey::dump(Formatter *f) const
+{
+  encode_json("access_key", id, f);
+  encode_json("secret_key", key, f);
+  encode_json("subuser", subuser, f);
+}
+
+void RGWAccessKey::dump_plain(Formatter *f) const
+{
+  encode_json("access_key", id, f);
+  encode_json("secret_key", key, f);
+}
+
+void RGWAccessKey::dump(Formatter *f, const string& user, bool swift) const
+{
+  string u = user;
+  if (!subuser.empty()) {
+    u.append(":");
+    u.append(subuser);
+  }
+  encode_json("user", u, f);
+  if (!swift) {
+    encode_json("access_key", id, f);
+  }
+  encode_json("secret_key", key, f);
+}
+
+void RGWAccessKey::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("access_key", id, obj, true);
+  JSONDecoder::decode_json("secret_key", key, obj, true);
+  if (!JSONDecoder::decode_json("subuser", subuser, obj)) {
+    string user;
+    JSONDecoder::decode_json("user", user, obj);
+    int pos = user.find(':');
+    if (pos >= 0) {
+      subuser = user.substr(pos + 1);
+    }
+  }
+}
+
+void RGWAccessKey::decode_json(JSONObj *obj, bool swift) {
+  if (!swift) {
+    decode_json(obj);
+    return;
+  }
+
+  if (!JSONDecoder::decode_json("subuser", subuser, obj)) {
+    JSONDecoder::decode_json("user", id, obj, true);
+    int pos = id.find(':');
+    if (pos >= 0) {
+      subuser = id.substr(pos + 1);
+    }
+  }
+  JSONDecoder::decode_json("secret_key", key, obj, true);
+}
+
+void RGWStorageStats::dump(Formatter *f) const
+{
+  encode_json("size", size, f);
+  encode_json("size_actual", size_rounded, f);
+  if (dump_utilized) {
+    encode_json("size_utilized", size_utilized, f);
+  }
+  encode_json("size_kb", rgw_rounded_kb(size), f);
+  encode_json("size_kb_actual", rgw_rounded_kb(size_rounded), f);
+  if (dump_utilized) {
+    encode_json("size_kb_utilized", rgw_rounded_kb(size_utilized), f);
+  }
+  encode_json("num_objects", num_objects, f);
+}
+
+void rgw_obj_key::dump(Formatter *f) const
+{
+  encode_json("name", name, f);
+  encode_json("instance", instance, f);
+  encode_json("ns", ns, f);
+}
+
+void rgw_obj_key::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("name", name, obj);
+  JSONDecoder::decode_json("instance", instance, obj);
+  JSONDecoder::decode_json("ns", ns, obj);
+}
+
+void rgw_raw_obj::dump(Formatter *f) const
+{
+  encode_json("pool", pool, f);
+  encode_json("oid", oid, f);
+  encode_json("loc", loc, f);
+}
+
+void rgw_raw_obj::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("pool", pool, obj);
+  JSONDecoder::decode_json("oid", oid, obj);
+  JSONDecoder::decode_json("loc", loc, obj);
+}
+
+void rgw_obj::dump(Formatter *f) const
+{
+  encode_json("bucket", bucket, f);
+  encode_json("key", key, f);
+}
+
+
index e49502711714ce3173027c16bf383783b30e1fc9..8835a8fc55411e5a4749ee548d730619e8e704fa 100644 (file)
@@ -208,3 +208,21 @@ int RGWGetObj_Decompress::fixup_range(off_t& ofs, off_t& end)
 
   return next->fixup_range(ofs, end);
 }
+
+void compression_block::dump(Formatter *f) const
+{
+  f->dump_unsigned("old_ofs", old_ofs);
+  f->dump_unsigned("new_ofs", new_ofs);
+  f->dump_unsigned("len", len);
+}
+
+void RGWCompressionInfo::dump(Formatter *f) const
+{
+  f->dump_string("compression_type", compression_type);
+  f->dump_unsigned("orig_size", orig_size);
+  if (compressor_message) {
+    f->dump_int("compressor_message", *compressor_message);
+  }
+  ::encode_json("blocks", blocks, f);
+}
+
index cb7564f0019f2e34fcdc1be06144be48701c11cb..19f8c2568b0ba4f3669d7d8a9195ced01b283328 100644 (file)
@@ -5061,3 +5061,94 @@ int rgw_bucket_sync_status(const DoutPrefixProvider *dpp,
                                                   dest_bucket_info,
                                                   status));
 }
+
+void rgw_data_sync_info::generate_test_instances(list<rgw_data_sync_info*>& o)
+{
+  auto info = new rgw_data_sync_info;
+  info->state = rgw_data_sync_info::StateBuildingFullSyncMaps;
+  info->num_shards = 8;
+  o.push_back(info);
+  o.push_back(new rgw_data_sync_info);
+}
+
+void rgw_data_sync_marker::generate_test_instances(list<rgw_data_sync_marker*>& o)
+{
+  auto marker = new rgw_data_sync_marker;
+  marker->state = rgw_data_sync_marker::IncrementalSync;
+  marker->marker = "01234";
+  marker->pos = 5;
+  o.push_back(marker);
+  o.push_back(new rgw_data_sync_marker);
+}
+
+void rgw_data_sync_status::generate_test_instances(list<rgw_data_sync_status*>& o)
+{
+  o.push_back(new rgw_data_sync_status);
+}
+
+void rgw_bucket_shard_full_sync_marker::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("position", position, obj);
+  JSONDecoder::decode_json("count", count, obj);
+}
+
+void rgw_bucket_shard_full_sync_marker::dump(Formatter *f) const
+{
+  encode_json("position", position, f);
+  encode_json("count", count, f);
+}
+
+void rgw_bucket_shard_inc_sync_marker::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("position", position, obj);
+  JSONDecoder::decode_json("timestamp", timestamp, obj);
+}
+
+void rgw_bucket_shard_inc_sync_marker::dump(Formatter *f) const
+{
+  encode_json("position", position, f);
+  encode_json("timestamp", timestamp, f);
+}
+
+void rgw_bucket_shard_sync_info::decode_json(JSONObj *obj)
+{
+  std::string s;
+  JSONDecoder::decode_json("status", s, obj);
+  if (s == "full-sync") {
+    state = StateFullSync;
+  } else if (s == "incremental-sync") {
+    state = StateIncrementalSync;
+  } else if (s == "stopped") {
+    state = StateStopped;
+  } else {
+    state = StateInit;
+  }
+  JSONDecoder::decode_json("full_marker", full_marker, obj);
+  JSONDecoder::decode_json("inc_marker", inc_marker, obj);
+}
+
+void rgw_bucket_shard_sync_info::dump(Formatter *f) const
+{
+  const char *s{nullptr};
+  switch ((SyncState)state) {
+    case StateInit:
+    s = "init";
+    break;
+  case StateFullSync:
+    s = "full-sync";
+    break;
+  case StateIncrementalSync:
+    s = "incremental-sync";
+    break;
+  case StateStopped:
+    s = "stopped";
+    break;
+  default:
+    s = "unknown";
+    break;
+  }
+  encode_json("status", s, f);
+  encode_json("full_marker", full_marker, f);
+  encode_json("inc_marker", inc_marker, f);
+}
+
index 670dcacf76f65e819ad74ec53835d2e11784cf3a..24acd3624edab4ee67db31b3c08974e23840684c 100644 (file)
@@ -1015,3 +1015,20 @@ int RGWDataChangesLog::change_format(const DoutPrefixProvider *dpp, log_type typ
 int RGWDataChangesLog::trim_generations(const DoutPrefixProvider *dpp, std::optional<uint64_t>& through) {
   return bes->trim_generations(dpp, through);
 }
+
+void RGWDataChangesLogInfo::dump(Formatter *f) const
+{
+  encode_json("marker", marker, f);
+  utime_t ut(last_update);
+  encode_json("last_update", ut, f);
+}
+
+void RGWDataChangesLogInfo::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("marker", marker, obj);
+  utime_t ut;
+  JSONDecoder::decode_json("last_update", ut, obj);
+  last_update = ut.to_real_time();
+}
+
+
index d0dc8a02df37812181f4ae4e65df0b8e916df0dd..1d1be51c45b4c6d021daf273efd715ed62372d33 100644 (file)
@@ -18,456 +18,6 @@ using namespace std;
 
 static string shadow_ns = RGW_OBJ_NS_SHADOW;
 
-static void init_bucket(rgw_bucket *b, const char *t, const char *n, const char *dp, const char *ip, const char *m, const char *id)
-{
-  b->tenant = t;
-  b->name = n;
-  b->marker = m;
-  b->bucket_id = id;
-  b->explicit_placement.data_pool = rgw_pool(dp);
-  b->explicit_placement.index_pool = rgw_pool(ip);
-}
-
-void RGWObjManifestPart::generate_test_instances(std::list<RGWObjManifestPart*>& o)
-{
-  o.push_back(new RGWObjManifestPart);
-
-  RGWObjManifestPart *p = new RGWObjManifestPart;
-  rgw_bucket b;
-  init_bucket(&b, "tenant", "bucket", ".pool", ".index_pool", "marker_", "12");
-
-  p->loc = rgw_obj(b, "object");
-  p->loc_ofs = 512 * 1024;
-  p->size = 128 * 1024;
-  o.push_back(p);
-}
-
-void RGWObjManifest::generate_test_instances(std::list<RGWObjManifest*>& o)
-{
-  RGWObjManifest *m = new RGWObjManifest;
-  map<uint64_t, RGWObjManifestPart> objs;
-  uint64_t total_size = 0;
-  for (int i = 0; i<10; i++) {
-    RGWObjManifestPart p;
-    rgw_bucket b;
-    init_bucket(&b, "tenant", "bucket", ".pool", ".index_pool", "marker_", "12");
-    p.loc = rgw_obj(b, "object");
-    p.loc_ofs = 0;
-    p.size = 512 * 1024;
-    total_size += p.size;
-    objs[total_size] = p;
-  }
-  m->set_explicit(total_size, objs);
-  o.push_back(m);
-  o.push_back(new RGWObjManifest);
-}
-
-
-void rgw_log_entry::generate_test_instances(list<rgw_log_entry*>& o)
-{
-  rgw_log_entry *e = new rgw_log_entry;
-  e->object_owner = "object_owner";
-  e->bucket_owner = "bucket_owner";
-  e->bucket = "bucket";
-  e->remote_addr = "1.2.3.4";
-  e->user = "user";
-  e->obj = rgw_obj_key("obj");
-  e->uri = "http://uri/bucket/obj";
-  e->http_status = "200";
-  e->error_code = "error_code";
-  e->bytes_sent = 1024;
-  e->bytes_received = 512;
-  e->obj_size = 2048;
-  e->user_agent = "user_agent";
-  e->referrer = "referrer";
-  e->bucket_id = "10";
-  e->trans_id = "trans_id";
-  e->identity_type = TYPE_RGW;
-  o.push_back(e);
-  o.push_back(new rgw_log_entry);
-}
-
-void ACLPermission::generate_test_instances(list<ACLPermission*>& o)
-{
-  ACLPermission *p = new ACLPermission;
-  p->set_permissions(RGW_PERM_WRITE_ACP);
-  o.push_back(p);
-  o.push_back(new ACLPermission);
-}
-
-void ACLGranteeType::generate_test_instances(list<ACLGranteeType*>& o)
-{
-  ACLGranteeType *t = new ACLGranteeType;
-  t->set(ACL_TYPE_CANON_USER);
-  o.push_back(t);
-  o.push_back(new ACLGranteeType);
-}
-
-/* the following is copied here from rgw_acl_s3.cc, to avoid having to have excessive linking
-   with everything it needs */
-
-#define RGW_URI_ALL_USERS      "http://acs.amazonaws.com/groups/global/AllUsers"
-#define RGW_URI_AUTH_USERS     "http://acs.amazonaws.com/groups/global/AuthenticatedUsers"
-
-static string rgw_uri_all_users = RGW_URI_ALL_USERS;
-static string rgw_uri_auth_users = RGW_URI_AUTH_USERS;
-
-ACLGroupTypeEnum ACLGrant::uri_to_group(string& uri)
-{
-  // this is required for backward compatibility
-  return ACLGrant_S3::uri_to_group(uri);
-}
-
-ACLGroupTypeEnum ACLGrant_S3::uri_to_group(string& uri)
-{
-  if (uri.compare(rgw_uri_all_users) == 0)
-    return ACL_GROUP_ALL_USERS;
-  else if (uri.compare(rgw_uri_auth_users) == 0)
-    return ACL_GROUP_AUTHENTICATED_USERS;
-
-  return ACL_GROUP_NONE;
-}
-
-void ACLGrant::generate_test_instances(list<ACLGrant*>& o)
-{
-  rgw_user id("rgw");
-  string name, email;
-  name = "Mr. RGW";
-  email = "r@gw";
-
-  ACLGrant *g1 = new ACLGrant;
-  g1->set_canon(id, name, RGW_PERM_READ);
-  g1->email = email;
-  o.push_back(g1);
-
-  ACLGrant *g2 = new ACLGrant;
-  g1->set_group(ACL_GROUP_AUTHENTICATED_USERS, RGW_PERM_WRITE);
-  o.push_back(g2);
-
-  o.push_back(new ACLGrant);
-}
-
-void RGWAccessControlList::generate_test_instances(list<RGWAccessControlList*>& o)
-{
-  RGWAccessControlList *acl = new RGWAccessControlList(NULL);
-
-  list<ACLGrant *> glist;
-  list<ACLGrant *>::iterator iter;
-
-  ACLGrant::generate_test_instances(glist);
-  for (iter = glist.begin(); iter != glist.end(); ++iter) {
-    ACLGrant *grant = *iter;
-    acl->add_grant(grant);
-
-    delete grant;
-  }
-  o.push_back(acl);
-  o.push_back(new RGWAccessControlList(NULL));
-}
-
-void ACLOwner::generate_test_instances(list<ACLOwner*>& o)
-{
-  ACLOwner *owner = new ACLOwner;
-  owner->id = "rgw";
-  owner->display_name = "Mr. RGW";
-  o.push_back(owner);
-  o.push_back(new ACLOwner);
-}
-
-void RGWAccessControlPolicy::generate_test_instances(list<RGWAccessControlPolicy*>& o)
-{
-  list<RGWAccessControlList *> acl_list;
-  list<RGWAccessControlList *>::iterator iter;
-  for (iter = acl_list.begin(); iter != acl_list.end(); ++iter) {
-    RGWAccessControlList::generate_test_instances(acl_list);
-    iter = acl_list.begin();
-
-    RGWAccessControlPolicy *p = new RGWAccessControlPolicy(NULL);
-    RGWAccessControlList *l = *iter;
-    p->acl = *l;
-
-    string name = "radosgw";
-    rgw_user id("rgw");
-    p->owner.set_name(name);
-    p->owner.set_id(id);
-
-    o.push_back(p);
-
-    delete l;
-  }
-
-  o.push_back(new RGWAccessControlPolicy(NULL));
-}
-
-
-void ObjectMetaInfo::generate_test_instances(list<ObjectMetaInfo*>& o)
-{
-  ObjectMetaInfo *m = new ObjectMetaInfo;
-  m->size = 1024 * 1024;
-  o.push_back(m);
-  o.push_back(new ObjectMetaInfo);
-}
-
-void ObjectCacheInfo::generate_test_instances(list<ObjectCacheInfo*>& o)
-{
-  using ceph::encode;
-  ObjectCacheInfo *i = new ObjectCacheInfo;
-  i->status = 0;
-  i->flags = CACHE_FLAG_MODIFY_XATTRS;
-  string s = "this is a string";
-  string s2 = "this is a another string";
-  bufferlist data, data2;
-  encode(s, data);
-  encode(s2, data2);
-  i->data = data;
-  i->xattrs["x1"] = data;
-  i->xattrs["x2"] = data2;
-  i->rm_xattrs["r2"] = data2;
-  i->rm_xattrs["r3"] = data;
-  i->meta.size = 512 * 1024;
-  o.push_back(i);
-  o.push_back(new ObjectCacheInfo);
-}
-
-void RGWCacheNotifyInfo::generate_test_instances(list<RGWCacheNotifyInfo*>& o)
-{
-  o.push_back(new RGWCacheNotifyInfo);
-}
-
-void RGWAccessKey::generate_test_instances(list<RGWAccessKey*>& o)
-{
-  RGWAccessKey *k = new RGWAccessKey;
-  k->id = "id";
-  k->key = "key";
-  k->subuser = "subuser";
-  o.push_back(k);
-  o.push_back(new RGWAccessKey);
-}
-
-void RGWSubUser::generate_test_instances(list<RGWSubUser*>& o)
-{
-  RGWSubUser *u = new RGWSubUser;
-  u->name = "name";
-  u->perm_mask = 0xf;
-  o.push_back(u);
-  o.push_back(new RGWSubUser);
-}
-
-void RGWUserInfo::generate_test_instances(list<RGWUserInfo*>& o)
-{
-  RGWUserInfo *i = new RGWUserInfo;
-  i->user_id = "user_id";
-  i->display_name =  "display_name";
-  i->user_email = "user@email";
-  RGWAccessKey k1, k2;
-  k1.id = "id1";
-  k1.key = "key1";
-  k2.id = "id2";
-  k2.subuser = "subuser";
-  RGWSubUser u;
-  u.name = "id2";
-  u.perm_mask = 0x1;
-  i->access_keys[k1.id] = k1;
-  i->swift_keys[k2.id] = k2;
-  i->subusers[u.name] = u;
-  o.push_back(i);
-
-  o.push_back(new RGWUserInfo);
-}
-
-void rgw_bucket::generate_test_instances(list<rgw_bucket*>& o)
-{
-  rgw_bucket *b = new rgw_bucket;
-  init_bucket(b, "tenant", "name", "pool", ".index_pool", "marker", "123");
-  o.push_back(b);
-  o.push_back(new rgw_bucket);
-}
-
-void RGWBucketInfo::generate_test_instances(list<RGWBucketInfo*>& o)
-{
-  // Since things without a log will have one synthesized on decode,
-  // ensure the things we attempt to encode will have one added so we
-  // round-trip properly.
-  auto gen_layout = [](rgw::BucketLayout& l) {
-    l.current_index.gen = 0;
-    l.current_index.layout.normal.hash_type = rgw::BucketHashType::Mod;
-    l.current_index.layout.type = rgw::BucketIndexType::Normal;
-    l.current_index.layout.normal.num_shards = 11;
-    l.logs.push_back(log_layout_from_index(
-                      l.current_index.gen,
-                      l.current_index.layout.normal));
-  };
-
-
-  RGWBucketInfo *i = new RGWBucketInfo;
-  init_bucket(&i->bucket, "tenant", "bucket", "pool", ".index_pool", "marker", "10");
-  i->owner = "owner";
-  i->flags = BUCKET_SUSPENDED;
-  gen_layout(i->layout);
-  o.push_back(i);
-  i = new RGWBucketInfo;
-  gen_layout(i->layout);
-  o.push_back(i);
-}
-
-void RGWZoneGroup::generate_test_instances(list<RGWZoneGroup*>& o)
-{
-  RGWZoneGroup *r = new RGWZoneGroup;
-  o.push_back(r);
-  o.push_back(new RGWZoneGroup);
-}
-
-void RGWZone::generate_test_instances(list<RGWZone*> &o)
-{
-  RGWZone *z = new RGWZone;
-  o.push_back(z);
-  o.push_back(new RGWZone);
-}
-
-void RGWRealm::generate_test_instances(list<RGWRealm*> &o)
-{
-  RGWRealm *z = new RGWRealm;
-  o.push_back(z);
-  o.push_back(new RGWRealm);
-}
-
-void RGWPeriod::generate_test_instances(list<RGWPeriod*> &o)
-{
-  RGWPeriod *z = new RGWPeriod;
-  o.push_back(z);
-  o.push_back(new RGWPeriod);
-}
-
-void RGWPeriodLatestEpochInfo::generate_test_instances(list<RGWPeriodLatestEpochInfo*> &o)
-{
-  RGWPeriodLatestEpochInfo *z = new RGWPeriodLatestEpochInfo;
-  o.push_back(z);
-  o.push_back(new RGWPeriodLatestEpochInfo);
-}
-
-void RGWZoneParams::generate_test_instances(list<RGWZoneParams*> &o)
-{
-  o.push_back(new RGWZoneParams);
-  o.push_back(new RGWZoneParams); 
-}
-
-void RGWOLHInfo::generate_test_instances(list<RGWOLHInfo*> &o)
-{
-  RGWOLHInfo *olh = new RGWOLHInfo;
-  olh->removed = false;
-  o.push_back(olh);
-  o.push_back(new RGWOLHInfo);
-}
-
-void RGWBucketEnt::generate_test_instances(list<RGWBucketEnt*>& o)
-{
-  RGWBucketEnt *e = new RGWBucketEnt;
-  init_bucket(&e->bucket, "tenant", "bucket", "pool", ".index_pool", "marker", "10");
-  e->size = 1024;
-  e->size_rounded = 4096;
-  e->count = 1;
-  o.push_back(e);
-  o.push_back(new RGWBucketEnt);
-}
-
-void RGWUploadPartInfo::generate_test_instances(list<RGWUploadPartInfo*>& o)
-{
-  RGWUploadPartInfo *i = new RGWUploadPartInfo;
-  i->num = 1;
-  i->size = 10 * 1024 * 1024;
-  i->etag = "etag";
-  o.push_back(i);
-  o.push_back(new RGWUploadPartInfo);
-}
-
-void rgw_obj::generate_test_instances(list<rgw_obj*>& o)
-{
-  rgw_bucket b;
-  init_bucket(&b, "tenant", "bucket", "pool", ".index_pool", "marker", "10");
-  rgw_obj *obj = new rgw_obj(b, "object");
-  o.push_back(obj);
-  o.push_back(new rgw_obj);
-}
-
-void rgw_meta_sync_info::generate_test_instances(list<rgw_meta_sync_info*>& o)
-{
-  auto info = new rgw_meta_sync_info;
-  info->state = rgw_meta_sync_info::StateBuildingFullSyncMaps;
-  info->period = "periodid";
-  info->realm_epoch = 5;
-  o.push_back(info);
-  o.push_back(new rgw_meta_sync_info);
-}
-
-void rgw_meta_sync_marker::generate_test_instances(list<rgw_meta_sync_marker*>& o)
-{
-  auto marker = new rgw_meta_sync_marker;
-  marker->state = rgw_meta_sync_marker::IncrementalSync;
-  marker->marker = "01234";
-  marker->realm_epoch = 5;
-  o.push_back(marker);
-  o.push_back(new rgw_meta_sync_marker);
-}
-
-void rgw_meta_sync_status::generate_test_instances(list<rgw_meta_sync_status*>& o)
-{
-  o.push_back(new rgw_meta_sync_status);
-}
-
-void rgw_data_sync_info::generate_test_instances(list<rgw_data_sync_info*>& o)
-{
-  auto info = new rgw_data_sync_info;
-  info->state = rgw_data_sync_info::StateBuildingFullSyncMaps;
-  info->num_shards = 8;
-  o.push_back(info);
-  o.push_back(new rgw_data_sync_info);
-}
-
-void rgw_data_sync_marker::generate_test_instances(list<rgw_data_sync_marker*>& o)
-{
-  auto marker = new rgw_data_sync_marker;
-  marker->state = rgw_data_sync_marker::IncrementalSync;
-  marker->marker = "01234";
-  marker->pos = 5;
-  o.push_back(marker);
-  o.push_back(new rgw_data_sync_marker);
-}
-
-void rgw_data_sync_status::generate_test_instances(list<rgw_data_sync_status*>& o)
-{
-  o.push_back(new rgw_data_sync_status);
-}
-
-void objexp_hint_entry::generate_test_instances(list<objexp_hint_entry*>& o)
-{
-  auto it = new objexp_hint_entry;
-  it->tenant = "tenant1";
-  it->bucket_name = "bucket1";
-  it->bucket_id = "1234";
-  it->obj_key = rgw_obj_key("obj");
-  o.push_back(it);
-  o.push_back(new objexp_hint_entry);
-}
-
-void RGWBucketEntryPoint::generate_test_instances(list<RGWBucketEntryPoint*>& o)
-{
-  RGWBucketEntryPoint *bp = new RGWBucketEntryPoint();
-  init_bucket(&bp->bucket, "tenant", "bucket", "pool", ".index.pool", "marker", "10");
-  bp->owner = "owner";
-  bp->creation_time = ceph::real_clock::from_ceph_timespec({ceph_le32(2), ceph_le32(3)});
-
-  o.push_back(bp);
-  o.push_back(new RGWBucketEntryPoint);
-}
-
-void rgw_user::generate_test_instances(list<rgw_user*>& o)
-{
-  rgw_user *u = new rgw_user("tenant", "user");
-
-  o.push_back(u);
-  o.push_back(new rgw_user);
-}
-
 void obj_version::generate_test_instances(list<obj_version*>& o)
 {
   obj_version *v = new obj_version;
index 5c3ae67350cf306f31fc0f25d60c931e97bc9273..bac6e84ef39309b970a3b5d9551296c9455e36ab 100644 (file)
 
 using namespace std;
 
-void encode_json(const char *name, const obj_version& v, Formatter *f)
-{
-  f->open_object_section(name);
-  f->dump_string("tag", v.tag);
-  f->dump_unsigned("ver", v.ver);
-  f->close_section();
-}
-
-void decode_json_obj(obj_version& v, JSONObj *obj)
-{
-  JSONDecoder::decode_json("tag", v.tag, obj);
-  JSONDecoder::decode_json("ver", v.ver, obj);
-}
-
-void encode_json(const char *name, const RGWUserCaps& val, Formatter *f)
-{
-  val.dump(f, name);
-}
-
-
-void encode_json(const char *name, const rgw_pool& pool, Formatter *f)
-{
-  f->dump_string(name, pool.to_str());
-}
-
-void decode_json_obj(rgw_pool& pool, JSONObj *obj)
-{
-  string s;
-  decode_json_obj(s, obj);
-  pool = rgw_pool(s);
-}
-
-void encode_json(const char *name, const rgw_placement_rule& r, Formatter *f)
-{
-  encode_json(name, r.to_str(), f);
-}
-
 void decode_json_obj(rgw_placement_rule& v, JSONObj *obj)
 {
   string s;
@@ -70,2148 +33,3 @@ void decode_json_obj(rgw_placement_rule& v, JSONObj *obj)
   v.from_str(s);
 }
 
-void RGWOLHInfo::dump(Formatter *f) const
-{
-  encode_json("target", target, f);
-}
-
-void RGWOLHPendingInfo::dump(Formatter *f) const
-{
-  utime_t ut(time);
-  encode_json("time", ut, f);
-}
-
-void RGWObjManifestPart::dump(Formatter *f) const
-{
-  f->open_object_section("loc");
-  loc.dump(f);
-  f->close_section();
-  f->dump_unsigned("loc_ofs", loc_ofs);
-  f->dump_unsigned("size", size);
-}
-
-void RGWObjManifestRule::dump(Formatter *f) const
-{
-  encode_json("start_part_num", start_part_num, f);
-  encode_json("start_ofs", start_ofs, f);
-  encode_json("part_size", part_size, f);
-  encode_json("stripe_max_size", stripe_max_size, f);
-  encode_json("override_prefix", override_prefix, f);
-}
-
-void RGWObjTier::dump(Formatter *f) const
-{
-  encode_json("name", name, f);
-  encode_json("tier_placement", tier_placement, f);
-  encode_json("is_multipart_upload", is_multipart_upload, f);
-}
-
-void rgw_bucket_placement::dump(Formatter *f) const
-{
-  encode_json("bucket", bucket, f);
-  encode_json("placement_rule", placement_rule, f);
-}
-
-void rgw_obj_select::dump(Formatter *f) const
-{
-  f->dump_string("placement_rule", placement_rule.to_str());
-  f->dump_object("obj", obj);
-  f->dump_object("raw_obj", raw_obj);
-  f->dump_bool("is_raw", is_raw);
-}
-
-void RGWObjManifest::obj_iterator::dump(Formatter *f) const
-{
-  f->dump_unsigned("part_ofs", part_ofs);
-  f->dump_unsigned("stripe_ofs", stripe_ofs);
-  f->dump_unsigned("ofs", ofs);
-  f->dump_unsigned("stripe_size", stripe_size);
-  f->dump_int("cur_part_id", cur_part_id);
-  f->dump_int("cur_stripe", cur_stripe);
-  f->dump_string("cur_override_prefix", cur_override_prefix);
-  f->dump_object("location", location);
-}
-
-void RGWObjManifest::dump(Formatter *f) const
-{
-  map<uint64_t, RGWObjManifestPart>::const_iterator iter = objs.begin();
-  f->open_array_section("objs");
-  for (; iter != objs.end(); ++iter) {
-    f->dump_unsigned("ofs", iter->first);
-    f->open_object_section("part");
-    iter->second.dump(f);
-    f->close_section();
-  }
-  f->close_section();
-  f->dump_unsigned("obj_size", obj_size);
-  ::encode_json("explicit_objs", explicit_objs, f);
-  ::encode_json("head_size", head_size, f);
-  ::encode_json("max_head_size", max_head_size, f);
-  ::encode_json("prefix", prefix, f);
-  ::encode_json("rules", rules, f);
-  ::encode_json("tail_instance", tail_instance, f);
-  ::encode_json("tail_placement", tail_placement, f);
-  ::encode_json("tier_type", tier_type, f);
-  
-  if (tier_type == "cloud-s3") {
-    ::encode_json("tier_config", tier_config, f);
-  }
-
-  // nullptr being passed into iterators since there
-  // is no cct and we aren't doing anything with these
-  // iterators that would write do the log
-  f->dump_object("begin_iter", obj_begin(nullptr));
-  f->dump_object("end_iter", obj_end(nullptr));
-}
-
-void rgw_log_entry::dump(Formatter *f) const
-{
-  f->dump_string("object_owner", object_owner.to_str());
-  f->dump_string("bucket_owner", bucket_owner.to_str());
-  f->dump_string("bucket", bucket);
-  f->dump_stream("time") << time;
-  f->dump_string("remote_addr", remote_addr);
-  f->dump_string("user", user);
-  f->dump_stream("obj") << obj;
-  f->dump_string("op", op);
-  f->dump_string("uri", uri);
-  f->dump_string("http_status", http_status);
-  f->dump_string("error_code", error_code);
-  f->dump_unsigned("bytes_sent", bytes_sent);
-  f->dump_unsigned("bytes_received", bytes_received);
-  f->dump_unsigned("obj_size", obj_size);
-  f->dump_stream("total_time") << total_time;
-  f->dump_string("user_agent", user_agent);
-  f->dump_string("referrer", referrer);
-  f->dump_string("bucket_id", bucket_id);
-  f->dump_string("trans_id", trans_id);
-  f->dump_unsigned("identity_type", identity_type);
-}
-
-void ACLPermission::dump(Formatter *f) const
-{
-  f->dump_int("flags", flags);
-}
-
-void ACLGranteeType::dump(Formatter *f) const
-{
-  f->dump_unsigned("type", type);
-}
-
-void ACLGrant::dump(Formatter *f) const
-{
-  f->open_object_section("type");
-  type.dump(f);
-  f->close_section();
-
-  f->dump_string("id", id.to_str());
-  f->dump_string("email", email);
-
-  f->open_object_section("permission");
-  permission.dump(f);
-  f->close_section();
-
-  f->dump_string("name", name);
-  f->dump_int("group", (int)group);
-  f->dump_string("url_spec", url_spec);
-}
-
-void RGWAccessControlList::dump(Formatter *f) const
-{
-  map<string, int>::const_iterator acl_user_iter = acl_user_map.begin();
-  f->open_array_section("acl_user_map");
-  for (; acl_user_iter != acl_user_map.end(); ++acl_user_iter) {
-    f->open_object_section("entry");
-    f->dump_string("user", acl_user_iter->first);
-    f->dump_int("acl", acl_user_iter->second);
-    f->close_section();
-  }
-  f->close_section();
-
-  map<uint32_t, int>::const_iterator acl_group_iter = acl_group_map.begin();
-  f->open_array_section("acl_group_map");
-  for (; acl_group_iter != acl_group_map.end(); ++acl_group_iter) {
-    f->open_object_section("entry");
-    f->dump_unsigned("group", acl_group_iter->first);
-    f->dump_int("acl", acl_group_iter->second);
-    f->close_section();
-  }
-  f->close_section();
-
-  multimap<string, ACLGrant>::const_iterator giter = grant_map.begin();
-  f->open_array_section("grant_map");
-  for (; giter != grant_map.end(); ++giter) {
-    f->open_object_section("entry");
-    f->dump_string("id", giter->first);
-    f->open_object_section("grant");
-    giter->second.dump(f);
-    f->close_section();
-    f->close_section();
-  }
-  f->close_section();
-}
-
-void ACLOwner::dump(Formatter *f) const
-{
-  encode_json("id", id.to_str(), f);
-  encode_json("display_name", display_name, f);
-}
-
-void ACLOwner::decode_json(JSONObj *obj) {
-  string id_str;
-  JSONDecoder::decode_json("id", id_str, obj);
-  id.from_str(id_str);
-  JSONDecoder::decode_json("display_name", display_name, obj);
-}
-
-void RGWAccessControlPolicy::dump(Formatter *f) const
-{
-  encode_json("acl", acl, f);
-  encode_json("owner", owner, f);
-}
-
-void ObjectMetaInfo::dump(Formatter *f) const
-{
-  encode_json("size", size, f);
-  encode_json("mtime", utime_t(mtime), f);
-}
-
-void ObjectCacheInfo::dump(Formatter *f) const
-{
-  encode_json("status", status, f);
-  encode_json("flags", flags, f);
-  encode_json("data", data, f);
-  encode_json_map("xattrs", "name", "value", "length", xattrs, f);
-  encode_json_map("rm_xattrs", "name", "value", "length", rm_xattrs, f);
-  encode_json("meta", meta, f);
-
-}
-
-void RGWCacheNotifyInfo::dump(Formatter *f) const
-{
-  encode_json("op", op, f);
-  encode_json("obj", obj, f);
-  encode_json("obj_info", obj_info, f);
-  encode_json("ofs", ofs, f);
-  encode_json("ns", ns, f);
-}
-
-void RGWAccessKey::dump(Formatter *f) const
-{
-  encode_json("access_key", id, f);
-  encode_json("secret_key", key, f);
-  encode_json("subuser", subuser, f);
-}
-
-void RGWAccessKey::dump_plain(Formatter *f) const
-{
-  encode_json("access_key", id, f);
-  encode_json("secret_key", key, f);
-}
-
-void encode_json_plain(const char *name, const RGWAccessKey& val, Formatter *f)
-{
-  f->open_object_section(name);
-  val.dump_plain(f);
-  f->close_section();
-}
-
-void RGWAccessKey::dump(Formatter *f, const string& user, bool swift) const
-{
-  string u = user;
-  if (!subuser.empty()) {
-    u.append(":");
-    u.append(subuser);
-  }
-  encode_json("user", u, f);
-  if (!swift) {
-    encode_json("access_key", id, f);
-  }
-  encode_json("secret_key", key, f);
-}
-
-void RGWAccessKey::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("access_key", id, obj, true);
-  JSONDecoder::decode_json("secret_key", key, obj, true);
-  if (!JSONDecoder::decode_json("subuser", subuser, obj)) {
-    string user;
-    JSONDecoder::decode_json("user", user, obj);
-    int pos = user.find(':');
-    if (pos >= 0) {
-      subuser = user.substr(pos + 1);
-    }
-  }
-}
-
-void RGWAccessKey::decode_json(JSONObj *obj, bool swift) {
-  if (!swift) {
-    decode_json(obj);
-    return;
-  }
-
-  if (!JSONDecoder::decode_json("subuser", subuser, obj)) {
-    JSONDecoder::decode_json("user", id, obj, true);
-    int pos = id.find(':');
-    if (pos >= 0) {
-      subuser = id.substr(pos + 1);
-    }
-  }
-  JSONDecoder::decode_json("secret_key", key, obj, true);
-}
-
-struct rgw_flags_desc {
-  uint32_t mask;
-  const char *str;
-};
-
-static struct rgw_flags_desc rgw_perms[] = {
- { RGW_PERM_FULL_CONTROL, "full-control" },
- { RGW_PERM_READ | RGW_PERM_WRITE, "read-write" },
- { RGW_PERM_READ, "read" },
- { RGW_PERM_WRITE, "write" },
- { RGW_PERM_READ_ACP, "read-acp" },
- { RGW_PERM_WRITE_ACP, "write-acp" },
- { 0, NULL }
-};
-
-template <class T>
-static void mask_to_str(T *mask_list, uint32_t mask, char *buf, int len)
-{
-  const char *sep = "";
-  int pos = 0;
-  if (!mask) {
-    snprintf(buf, len, "<none>");
-    return;
-  }
-  while (mask) {
-    uint32_t orig_mask = mask;
-    for (int i = 0; mask_list[i].mask; i++) {
-      T *desc = &mask_list[i];
-      if ((mask & desc->mask) == desc->mask) {
-        pos += snprintf(buf + pos, len - pos, "%s%s", sep, desc->str);
-        if (pos == len)
-          return;
-        sep = ", ";
-        mask &= ~desc->mask;
-        if (!mask)
-          return;
-      }
-    }
-    if (mask == orig_mask) // no change
-      break;
-  }
-}
-
-static void perm_to_str(uint32_t mask, char *buf, int len)
-{
-  return mask_to_str(rgw_perms, mask, buf, len);
-}
-
-static struct rgw_flags_desc op_type_flags[] = {
- { RGW_OP_TYPE_READ, "read" },
- { RGW_OP_TYPE_WRITE, "write" },
- { RGW_OP_TYPE_DELETE, "delete" },
- { 0, NULL }
-};
-
-extern void op_type_to_str(uint32_t mask, char *buf, int len)
-{
-  return mask_to_str(op_type_flags, mask, buf, len);
-}
-
-void RGWSubUser::dump(Formatter *f) const
-{
-  encode_json("id", name, f);
-  char buf[256];
-  perm_to_str(perm_mask, buf, sizeof(buf));
-  encode_json("permissions", (const char *)buf, f);
-}
-
-void RGWSubUser::dump(Formatter *f, const string& user) const
-{
-  string s = user;
-  s.append(":");
-  s.append(name);
-  encode_json("id", s, f);
-  char buf[256];
-  perm_to_str(perm_mask, buf, sizeof(buf));
-  encode_json("permissions", (const char *)buf, f);
-}
-
-static uint32_t str_to_perm(const string& s)
-{
-  if (s.compare("read") == 0)
-    return RGW_PERM_READ;
-  else if (s.compare("write") == 0)
-    return RGW_PERM_WRITE;
-  else if (s.compare("read-write") == 0)
-    return RGW_PERM_READ | RGW_PERM_WRITE;
-  else if (s.compare("full-control") == 0)
-    return RGW_PERM_FULL_CONTROL;
-  return 0;
-}
-
-void RGWSubUser::decode_json(JSONObj *obj)
-{
-  string uid;
-  JSONDecoder::decode_json("id", uid, obj);
-  int pos = uid.find(':');
-  if (pos >= 0)
-    name = uid.substr(pos + 1);
-  string perm_str;
-  JSONDecoder::decode_json("permissions", perm_str, obj);
-  perm_mask = str_to_perm(perm_str);
-}
-
-static void user_info_dump_subuser(const char *name, const RGWSubUser& subuser, Formatter *f, void *parent)
-{
-  RGWUserInfo *info = static_cast<RGWUserInfo *>(parent);
-  subuser.dump(f, info->user_id.to_str());
-}
-
-static void user_info_dump_key(const char *name, const RGWAccessKey& key, Formatter *f, void *parent)
-{
-  RGWUserInfo *info = static_cast<RGWUserInfo *>(parent);
-  key.dump(f, info->user_id.to_str(), false);
-}
-
-static void user_info_dump_swift_key(const char *name, const RGWAccessKey& key, Formatter *f, void *parent)
-{
-  RGWUserInfo *info = static_cast<RGWUserInfo *>(parent);
-  key.dump(f, info->user_id.to_str(), true);
-}
-
-void RGWUserInfo::dump(Formatter *f) const
-{
-
-  encode_json("user_id", user_id.to_str(), f);
-  encode_json("display_name", display_name, f);
-  encode_json("email", user_email, f);
-  encode_json("suspended", (int)suspended, f);
-  encode_json("max_buckets", (int)max_buckets, f);
-
-  encode_json_map("subusers", NULL, "subuser", NULL, user_info_dump_subuser,(void *)this, subusers, f);
-  encode_json_map("keys", NULL, "key", NULL, user_info_dump_key,(void *)this, access_keys, f);
-  encode_json_map("swift_keys", NULL, "key", NULL, user_info_dump_swift_key,(void *)this, swift_keys, f);
-
-  encode_json("caps", caps, f);
-
-  char buf[256];
-  op_type_to_str(op_mask, buf, sizeof(buf));
-  encode_json("op_mask", (const char *)buf, f);
-
-  if (system) { /* no need to show it for every user */
-    encode_json("system", (bool)system, f);
-  }
-  if (admin) {
-    encode_json("admin", (bool)admin, f);
-  }
-  encode_json("default_placement", default_placement.name, f);
-  encode_json("default_storage_class", default_placement.storage_class, f);
-  encode_json("placement_tags", placement_tags, f);
-  encode_json("bucket_quota", bucket_quota, f);
-  encode_json("user_quota", user_quota, f);
-  encode_json("temp_url_keys", temp_url_keys, f);
-
-  string user_source_type;
-  switch ((RGWIdentityType)type) {
-  case TYPE_RGW:
-    user_source_type = "rgw";
-    break;
-  case TYPE_KEYSTONE:
-    user_source_type = "keystone";
-    break;
-  case TYPE_LDAP:
-    user_source_type = "ldap";
-    break;
-  case TYPE_NONE:
-    user_source_type = "none";
-    break;
-  default:
-    user_source_type = "none";
-    break;
-  }
-  encode_json("type", user_source_type, f);
-  encode_json("mfa_ids", mfa_ids, f);
-}
-
-
-static void decode_access_keys(map<string, RGWAccessKey>& m, JSONObj *o)
-{
-  RGWAccessKey k;
-  k.decode_json(o);
-  m[k.id] = k;
-}
-
-static void decode_swift_keys(map<string, RGWAccessKey>& m, JSONObj *o)
-{
-  RGWAccessKey k;
-  k.decode_json(o, true);
-  m[k.id] = k;
-}
-
-static void decode_subusers(map<string, RGWSubUser>& m, JSONObj *o)
-{
-  RGWSubUser u;
-  u.decode_json(o);
-  m[u.name] = u;
-}
-
-void RGWUserInfo::decode_json(JSONObj *obj)
-{
-  string uid;
-
-  JSONDecoder::decode_json("user_id", uid, obj, true);
-  user_id.from_str(uid);
-
-  JSONDecoder::decode_json("display_name", display_name, obj);
-  JSONDecoder::decode_json("email", user_email, obj);
-  bool susp = false;
-  JSONDecoder::decode_json("suspended", susp, obj);
-  suspended = (__u8)susp;
-  JSONDecoder::decode_json("max_buckets", max_buckets, obj);
-
-  JSONDecoder::decode_json("keys", access_keys, decode_access_keys, obj);
-  JSONDecoder::decode_json("swift_keys", swift_keys, decode_swift_keys, obj);
-  JSONDecoder::decode_json("subusers", subusers, decode_subusers, obj);
-
-  JSONDecoder::decode_json("caps", caps, obj);
-
-  string mask_str;
-  JSONDecoder::decode_json("op_mask", mask_str, obj);
-  rgw_parse_op_type_list(mask_str, &op_mask);
-
-  bool sys = false;
-  JSONDecoder::decode_json("system", sys, obj);
-  system = (__u8)sys;
-  bool ad = false;
-  JSONDecoder::decode_json("admin", ad, obj);
-  admin = (__u8)ad;
-  JSONDecoder::decode_json("default_placement", default_placement.name, obj);
-  JSONDecoder::decode_json("default_storage_class", default_placement.storage_class, obj);
-  JSONDecoder::decode_json("placement_tags", placement_tags, obj);
-  JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
-  JSONDecoder::decode_json("user_quota", user_quota, obj);
-  JSONDecoder::decode_json("temp_url_keys", temp_url_keys, obj);
-
-  string user_source_type;
-  JSONDecoder::decode_json("type", user_source_type, obj);
-  if (user_source_type == "rgw") {
-    type = TYPE_RGW;
-  } else if (user_source_type == "keystone") {
-    type = TYPE_KEYSTONE;
-  } else if (user_source_type == "ldap") {
-    type = TYPE_LDAP;
-  } else if (user_source_type == "none") {
-    type = TYPE_NONE;
-  }
-  JSONDecoder::decode_json("mfa_ids", mfa_ids, obj);
-}
-
-void RGWQuotaInfo::dump(Formatter *f) const
-{
-  f->dump_bool("enabled", enabled);
-  f->dump_bool("check_on_raw", check_on_raw);
-
-  f->dump_int("max_size", max_size);
-  f->dump_int("max_size_kb", rgw_rounded_kb(max_size));
-  f->dump_int("max_objects", max_objects);
-}
-
-void RGWQuotaInfo::decode_json(JSONObj *obj)
-{
-  if (false == JSONDecoder::decode_json("max_size", max_size, obj)) {
-    /* We're parsing an older version of the struct. */
-    int64_t max_size_kb = 0;
-
-    JSONDecoder::decode_json("max_size_kb", max_size_kb, obj);
-    max_size = max_size_kb * 1024;
-  }
-  JSONDecoder::decode_json("max_objects", max_objects, obj);
-
-  JSONDecoder::decode_json("check_on_raw", check_on_raw, obj);
-  JSONDecoder::decode_json("enabled", enabled, obj);
-}
-
-void rgw_data_placement_target::dump(Formatter *f) const
-{
-  encode_json("data_pool", data_pool, f);
-  encode_json("data_extra_pool", data_extra_pool, f);
-  encode_json("index_pool", index_pool, f);
-}
-  
-void rgw_data_placement_target::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("data_pool", data_pool, obj);
-  JSONDecoder::decode_json("data_extra_pool", data_extra_pool, obj);
-  JSONDecoder::decode_json("index_pool", index_pool, obj);
-}
-
-void rgw_bucket::dump(Formatter *f) const
-{
-  encode_json("name", name, f);
-  encode_json("marker", marker, f);
-  encode_json("bucket_id", bucket_id, f);
-  encode_json("tenant", tenant, f);
-  encode_json("explicit_placement", explicit_placement, f);
-}
-
-void rgw_bucket::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("name", name, obj);
-  JSONDecoder::decode_json("marker", marker, obj);
-  JSONDecoder::decode_json("bucket_id", bucket_id, obj);
-  JSONDecoder::decode_json("tenant", tenant, obj);
-  JSONDecoder::decode_json("explicit_placement", explicit_placement, obj);
-  if (explicit_placement.data_pool.empty()) {
-    /* decoding old format */
-    JSONDecoder::decode_json("pool", explicit_placement.data_pool, obj);
-    JSONDecoder::decode_json("data_extra_pool", explicit_placement.data_extra_pool, obj);
-    JSONDecoder::decode_json("index_pool", explicit_placement.index_pool, obj);
-  }
-}
-
-void RGWBucketEntryPoint::dump(Formatter *f) const
-{
-  encode_json("bucket", bucket, f);
-  encode_json("owner", owner, f);
-  utime_t ut(creation_time);
-  encode_json("creation_time", ut, f);
-  encode_json("linked", linked, f);
-  encode_json("has_bucket_info", has_bucket_info, f);
-  if (has_bucket_info) {
-    encode_json("old_bucket_info", old_bucket_info, f);
-  }
-}
-
-void RGWBucketEntryPoint::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("bucket", bucket, obj);
-  JSONDecoder::decode_json("owner", owner, obj);
-  utime_t ut;
-  JSONDecoder::decode_json("creation_time", ut, obj);
-  creation_time = ut.to_real_time();
-  JSONDecoder::decode_json("linked", linked, obj);
-  JSONDecoder::decode_json("has_bucket_info", has_bucket_info, obj);
-  if (has_bucket_info) {
-    JSONDecoder::decode_json("old_bucket_info", old_bucket_info, obj);
-  }
-}
-
-void RGWStorageStats::dump(Formatter *f) const
-{
-  encode_json("size", size, f);
-  encode_json("size_actual", size_rounded, f);
-  if (dump_utilized) {
-    encode_json("size_utilized", size_utilized, f);
-  }
-  encode_json("size_kb", rgw_rounded_kb(size), f);
-  encode_json("size_kb_actual", rgw_rounded_kb(size_rounded), f);
-  if (dump_utilized) {
-    encode_json("size_kb_utilized", rgw_rounded_kb(size_utilized), f);
-  }
-  encode_json("num_objects", num_objects, f);
-}
-
-void RGWRedirectInfo::dump(Formatter *f) const
-{
-  encode_json("protocol", protocol, f);
-  encode_json("hostname", hostname, f);
-  encode_json("http_redirect_code", (int)http_redirect_code, f);
-}
-
-void RGWRedirectInfo::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("protocol", protocol, obj);
-  JSONDecoder::decode_json("hostname", hostname, obj);
-  int code;
-  JSONDecoder::decode_json("http_redirect_code", code, obj);
-  http_redirect_code = code;
-}
-
-void RGWBWRedirectInfo::dump(Formatter *f) const
-{
-  encode_json("redirect", redirect, f);
-  encode_json("replace_key_prefix_with", replace_key_prefix_with, f);
-  encode_json("replace_key_with", replace_key_with, f);
-}
-
-void RGWBWRedirectInfo::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("redirect", redirect, obj);
-  JSONDecoder::decode_json("replace_key_prefix_with", replace_key_prefix_with, obj);
-  JSONDecoder::decode_json("replace_key_with", replace_key_with, obj);
-}
-
-void RGWBWRoutingRuleCondition::dump(Formatter *f) const
-{
-  encode_json("key_prefix_equals", key_prefix_equals, f);
-  encode_json("http_error_code_returned_equals", (int)http_error_code_returned_equals, f);
-}
-
-void RGWBWRoutingRuleCondition::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("key_prefix_equals", key_prefix_equals, obj);
-  int code;
-  JSONDecoder::decode_json("http_error_code_returned_equals", code, obj);
-  http_error_code_returned_equals = code;
-}
-
-void RGWBWRoutingRule::dump(Formatter *f) const
-{
-  encode_json("condition", condition, f);
-  encode_json("redirect_info", redirect_info, f);
-}
-
-void RGWBWRoutingRule::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("condition", condition, obj);
-  JSONDecoder::decode_json("redirect_info", redirect_info, obj);
-}
-
-void RGWBWRoutingRules::dump(Formatter *f) const
-{
-  encode_json("rules", rules, f);
-}
-
-void RGWBWRoutingRules::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("rules", rules, obj);
-}
-
-void RGWBucketWebsiteConf::dump(Formatter *f) const
-{
-  if (!redirect_all.hostname.empty()) {
-    encode_json("redirect_all", redirect_all, f);
-  } else {
-    encode_json("index_doc_suffix", index_doc_suffix, f);
-    encode_json("error_doc", error_doc, f);
-    encode_json("routing_rules", routing_rules, f);
-  }
-}
-
-void RGWBucketWebsiteConf::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("redirect_all", redirect_all, obj);
-  JSONDecoder::decode_json("index_doc_suffix", index_doc_suffix, obj);
-  JSONDecoder::decode_json("error_doc", error_doc, obj);
-  JSONDecoder::decode_json("routing_rules", routing_rules, obj);
-}
-
-void RGWBucketInfo::dump(Formatter *f) const
-{
-  encode_json("bucket", bucket, f);
-  utime_t ut(creation_time);
-  encode_json("creation_time", ut, f);
-  encode_json("owner", owner.to_str(), f);
-  encode_json("flags", flags, f);
-  encode_json("zonegroup", zonegroup, f);
-  encode_json("placement_rule", placement_rule, f);
-  encode_json("has_instance_obj", has_instance_obj, f);
-  encode_json("quota", quota, f);
-  encode_json("num_shards", layout.current_index.layout.normal.num_shards, f);
-  encode_json("bi_shard_hash_type", (uint32_t)layout.current_index.layout.normal.hash_type, f);
-  encode_json("requester_pays", requester_pays, f);
-  encode_json("has_website", has_website, f);
-  if (has_website) {
-    encode_json("website_conf", website_conf, f);
-  }
-  encode_json("swift_versioning", swift_versioning, f);
-  encode_json("swift_ver_location", swift_ver_location, f);
-  encode_json("index_type", (uint32_t)layout.current_index.layout.type, f);
-  encode_json("mdsearch_config", mdsearch_config, f);
-  encode_json("reshard_status", (int)reshard_status, f);
-  encode_json("new_bucket_instance_id", new_bucket_instance_id, f);
-  if (!empty_sync_policy()) {
-    encode_json("sync_policy", *sync_policy, f);
-  }
-}
-
-void RGWBucketInfo::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("bucket", bucket, obj);
-  utime_t ut;
-  JSONDecoder::decode_json("creation_time", ut, obj);
-  creation_time = ut.to_real_time();
-  JSONDecoder::decode_json("owner", owner, obj);
-  JSONDecoder::decode_json("flags", flags, obj);
-  JSONDecoder::decode_json("zonegroup", zonegroup, obj);
-  /* backward compatability with region */
-  if (zonegroup.empty()) {
-    JSONDecoder::decode_json("region", zonegroup, obj);
-  }
-  string pr;
-  JSONDecoder::decode_json("placement_rule", pr, obj);
-  placement_rule.from_str(pr);
-  JSONDecoder::decode_json("has_instance_obj", has_instance_obj, obj);
-  JSONDecoder::decode_json("quota", quota, obj);
-  JSONDecoder::decode_json("num_shards", layout.current_index.layout.normal.num_shards, obj);
-  uint32_t hash_type;
-  JSONDecoder::decode_json("bi_shard_hash_type", hash_type, obj);
-  layout.current_index.layout.normal.hash_type = static_cast<rgw::BucketHashType>(hash_type);
-  JSONDecoder::decode_json("requester_pays", requester_pays, obj);
-  JSONDecoder::decode_json("has_website", has_website, obj);
-  if (has_website) {
-    JSONDecoder::decode_json("website_conf", website_conf, obj);
-  }
-  JSONDecoder::decode_json("swift_versioning", swift_versioning, obj);
-  JSONDecoder::decode_json("swift_ver_location", swift_ver_location, obj);
-  uint32_t it;
-  JSONDecoder::decode_json("index_type", it, obj);
-  layout.current_index.layout.type = (rgw::BucketIndexType)it;
-  JSONDecoder::decode_json("mdsearch_config", mdsearch_config, obj);
-  int rs;
-  JSONDecoder::decode_json("reshard_status", rs, obj);
-  reshard_status = (cls_rgw_reshard_status)rs;
-
-  rgw_sync_policy_info sp;
-  JSONDecoder::decode_json("sync_policy", sp, obj);
-  if (!sp.empty()) {
-    set_sync_policy(std::move(sp));
-  }
-}
-
-void rgw_sync_directional_rule::dump(Formatter *f) const
-{
-  encode_json("source_zone", source_zone, f);
-  encode_json("dest_zone", dest_zone, f);
-}
-
-void rgw_sync_directional_rule::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("source_zone", source_zone, obj);
-  JSONDecoder::decode_json("dest_zone", dest_zone, obj);
-}
-
-void rgw_sync_symmetric_group::dump(Formatter *f) const
-{
-  encode_json("id", id, f);
-  encode_json("zones", zones, f);
-}
-
-void rgw_sync_symmetric_group::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("id", id, obj);
-  JSONDecoder::decode_json("zones", zones, obj);
-}
-
-void rgw_sync_bucket_entity::dump(Formatter *f) const
-{
-  encode_json("zone", zone, f);
-  encode_json("bucket", bucket_key(), f);
-}
-
-void rgw_sync_bucket_entity::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("zone", zone, obj);
-  string s;
-  if (JSONDecoder::decode_json("bucket", s, obj)) {
-    rgw_bucket b;
-    int ret = rgw_bucket_parse_bucket_key(nullptr, s, &b, nullptr);
-    if (ret >= 0) {
-      bucket = b;
-    } else {
-      bucket.reset();
-    }
-  }
-}
-
-void rgw_sync_pipe_filter_tag::dump(Formatter *f) const
-{
-  encode_json("key", key, f);
-  encode_json("value", value, f);
-}
-
-void rgw_sync_pipe_filter_tag::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("key", key, obj);
-  JSONDecoder::decode_json("value", value, obj);
-}
-
-void rgw_sync_pipe_filter::dump(Formatter *f) const
-{
-  encode_json("prefix", prefix, f);
-  encode_json("tags", tags, f);
-}
-
-void rgw_sync_pipe_filter::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("prefix", prefix, obj);
-  JSONDecoder::decode_json("tags", tags, obj);
-}
-
-void rgw_sync_pipe_acl_translation::dump(Formatter *f) const
-{
-  encode_json("owner", owner, f);
-}
-
-void rgw_sync_pipe_acl_translation::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("owner", owner, obj);
-}
-
-void rgw_sync_pipe_source_params::dump(Formatter *f) const
-{
-  encode_json("filter", filter, f);
-}
-
-void rgw_sync_pipe_source_params::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("filter", filter, obj);
-}
-
-void rgw_sync_pipe_dest_params::dump(Formatter *f) const
-{
-  encode_json("acl_translation", acl_translation, f);
-  encode_json("storage_class", storage_class, f);
-}
-
-void rgw_sync_pipe_dest_params::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("acl_translation", acl_translation, obj);
-  JSONDecoder::decode_json("storage_class", storage_class, obj);
-}
-
-void rgw_sync_pipe_params::dump(Formatter *f) const
-{
-  encode_json("source", source, f);
-  encode_json("dest", dest, f);
-  encode_json("priority", priority, f);
-  string s;
-  switch (mode) {
-    case MODE_SYSTEM:
-      s = "system";
-      break;
-    default:
-      s = "user";
-  }
-  encode_json("mode", s, f);
-  encode_json("user", user, f);
-}
-
-void rgw_sync_pipe_params::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("source", source, obj);
-  JSONDecoder::decode_json("dest", dest, obj);
-  JSONDecoder::decode_json("priority", priority, obj);
-  string s;
-  JSONDecoder::decode_json("mode", s, obj);
-  if (s == "system") {
-    mode = MODE_SYSTEM;
-  } else {
-    mode = MODE_USER;
-  }
-  JSONDecoder::decode_json("user", user, obj);
-}
-
-
-void rgw_sync_bucket_entities::dump(Formatter *f) const
-{
-  encode_json("bucket", rgw_sync_bucket_entities::bucket_key(bucket), f);
-  if (zones) {
-    encode_json("zones", zones, f);
-  } else if (all_zones) {
-    set<string> z = { "*" };
-    encode_json("zones", z, f);
-  }
-}
-
-void rgw_sync_bucket_entities::decode_json(JSONObj *obj)
-{
-  string s;
-  JSONDecoder::decode_json("bucket", s, obj);
-  if (s == "*") {
-    bucket.reset();
-  } else {
-    rgw_bucket b;
-    int ret = rgw_bucket_parse_bucket_key(nullptr, s, &b, nullptr);
-    if (ret < 0) {
-      bucket.reset();
-    } else {
-      if (b.tenant == "*") {
-        b.tenant.clear();
-      }
-      if (b.name == "*") {
-        b.name.clear();
-      }
-      if (b.bucket_id == "*") {
-        b.bucket_id.clear();
-      }
-      bucket = b;
-    }
-  }
-  JSONDecoder::decode_json("zones", zones, obj);
-  if (zones && zones->size() == 1) {
-    auto iter = zones->begin();
-    if (*iter == "*") {
-      zones.reset();
-      all_zones = true;
-    }
-  }
-}
-
-void rgw_sync_bucket_pipe::dump(Formatter *f) const
-{
-  encode_json("id", id, f);
-  encode_json("source", source, f);
-  encode_json("dest", dest, f);
-  encode_json("params", params, f);
-}
-
-void rgw_sync_bucket_pipe::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("id", id, obj);
-  JSONDecoder::decode_json("source", source, obj);
-  JSONDecoder::decode_json("dest", dest, obj);
-  JSONDecoder::decode_json("params", params, obj);
-}
-
-void rgw_sync_bucket_pipes::dump(Formatter *f) const
-{
-  encode_json("id", id, f);
-  encode_json("source", source, f);
-  encode_json("dest", dest, f);
-  encode_json("params", params, f);
-}
-
-void rgw_sync_bucket_pipes::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("id", id, obj);
-  JSONDecoder::decode_json("source", source, obj);
-  JSONDecoder::decode_json("dest", dest, obj);
-  JSONDecoder::decode_json("params", params, obj);
-}
-
-void rgw_sync_data_flow_group::dump(Formatter *f) const
-{
-  if (!symmetrical.empty()) {
-    encode_json("symmetrical", symmetrical, f);
-  }
-
-  if (!directional.empty()) {
-    encode_json("directional", directional, f);
-  }
-}
-
-void rgw_sync_data_flow_group::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("symmetrical", symmetrical, obj);
-  JSONDecoder::decode_json("directional", directional, obj);
-}
-
-void rgw_sync_policy_group::dump(Formatter *f) const
-{
-  encode_json("id", id, f);
-  encode_json("data_flow", data_flow, f);
-  encode_json("pipes", pipes, f);
-  string s;
-  switch (status) {
-    case  rgw_sync_policy_group::Status::FORBIDDEN:
-      s = "forbidden";
-      break;
-    case  rgw_sync_policy_group::Status::ALLOWED:
-      s = "allowed";
-      break;
-    case  rgw_sync_policy_group::Status::ENABLED:
-      s = "enabled";
-      break;
-    default:
-      s = "unknown";
-  }
-  encode_json("status", s, f);
-}
-
-void rgw_sync_policy_group::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("id", id, obj);
-  JSONDecoder::decode_json("data_flow", data_flow, obj);
-  JSONDecoder::decode_json("pipes", pipes, obj);
-  string s;
-  JSONDecoder::decode_json("status", s, obj);
-  set_status(s);
-}
-
-void rgw_sync_policy_info::dump(Formatter *f) const
-{
-  Formatter::ArraySection section(*f, "groups");
-  for (auto& group : groups ) {
-    encode_json("group", group.second, f);
-  }
-}
-
-void rgw_sync_policy_info::decode_json(JSONObj *obj)
-{
-  vector<rgw_sync_policy_group> groups_vec;
-
-  JSONDecoder::decode_json("groups", groups_vec, obj);
-
-  for (auto& group : groups_vec) {
-    groups.emplace(std::make_pair(group.id, std::move(group)));
-  }
-}
-
-void rgw_obj_key::dump(Formatter *f) const
-{
-  encode_json("name", name, f);
-  encode_json("instance", instance, f);
-  encode_json("ns", ns, f);
-}
-
-void rgw_obj_key::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("name", name, obj);
-  JSONDecoder::decode_json("instance", instance, obj);
-  JSONDecoder::decode_json("ns", ns, obj);
-}
-
-void RGWBucketEnt::dump(Formatter *f) const
-{
-  encode_json("bucket", bucket, f);
-  encode_json("size", size, f);
-  encode_json("size_rounded", size_rounded, f);
-  utime_t ut(creation_time);
-  encode_json("mtime", ut, f); /* mtime / creation time discrepency needed for backward compatibility */
-  encode_json("count", count, f);
-  encode_json("placement_rule", placement_rule.to_str(), f);
-}
-
-void RGWUploadPartInfo::dump(Formatter *f) const
-{
-  encode_json("num", num, f);
-  encode_json("size", size, f);
-  encode_json("etag", etag, f);
-  utime_t ut(modified);
-  encode_json("modified", ut, f);
-}
-
-void rgw_raw_obj::dump(Formatter *f) const
-{
-  encode_json("pool", pool, f);
-  encode_json("oid", oid, f);
-  encode_json("loc", loc, f);
-}
-
-void rgw_raw_obj::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("pool", pool, obj);
-  JSONDecoder::decode_json("oid", oid, obj);
-  JSONDecoder::decode_json("loc", loc, obj);
-}
-
-void rgw_obj::dump(Formatter *f) const
-{
-  encode_json("bucket", bucket, f);
-  encode_json("key", key, f);
-}
-
-void RGWDefaultSystemMetaObjInfo::dump(Formatter *f) const {
-  encode_json("default_id", default_id, f);
-}
-
-void RGWDefaultSystemMetaObjInfo::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("default_id", default_id, obj);
-}
-
-void RGWNameToId::dump(Formatter *f) const {
-  encode_json("obj_id", obj_id, f);
-}
-
-void RGWNameToId::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("obj_id", obj_id, obj);
-}
-
-void RGWSystemMetaObj::dump(Formatter *f) const
-{
-  encode_json("id", id , f);
-  encode_json("name", name , f);
-}
-
-void RGWSystemMetaObj::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("id", id, obj);
-  JSONDecoder::decode_json("name", name, obj);
-}
-
-void RGWPeriodLatestEpochInfo::dump(Formatter *f) const {
-  encode_json("latest_epoch", epoch, f);
-}
-
-void RGWPeriodLatestEpochInfo::decode_json(JSONObj *obj) {
-  JSONDecoder::decode_json("latest_epoch", epoch, obj);
-}
-
-void RGWPeriod::dump(Formatter *f) const
-{
-  encode_json("id", id, f);
-  encode_json("epoch", epoch , f);
-  encode_json("predecessor_uuid", predecessor_uuid, f);
-  encode_json("sync_status", sync_status, f);
-  encode_json("period_map", period_map, f);
-  encode_json("master_zonegroup", master_zonegroup, f);
-  encode_json("master_zone", master_zone, f);
-  encode_json("period_config", period_config, f);
-  encode_json("realm_id", realm_id, f);
-  encode_json("realm_name", realm_name, f);
-  encode_json("realm_epoch", realm_epoch, f);
-}
-
-void RGWPeriod::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("id", id, obj);
-  JSONDecoder::decode_json("epoch", epoch, obj);
-  JSONDecoder::decode_json("predecessor_uuid", predecessor_uuid, obj);
-  JSONDecoder::decode_json("sync_status", sync_status, obj);
-  JSONDecoder::decode_json("period_map", period_map, obj);
-  JSONDecoder::decode_json("master_zonegroup", master_zonegroup, obj);
-  JSONDecoder::decode_json("master_zone", master_zone, obj);
-  JSONDecoder::decode_json("period_config", period_config, obj);
-  JSONDecoder::decode_json("realm_id", realm_id, obj);
-  JSONDecoder::decode_json("realm_name", realm_name, obj);
-  JSONDecoder::decode_json("realm_epoch", realm_epoch, obj);
-}
-
-void RGWZoneParams::dump(Formatter *f) const
-{
-  RGWSystemMetaObj::dump(f);
-  encode_json("domain_root", domain_root, f);
-  encode_json("control_pool", control_pool, f);
-  encode_json("gc_pool", gc_pool, f);
-  encode_json("lc_pool", lc_pool, f);
-  encode_json("log_pool", log_pool, f);
-  encode_json("intent_log_pool", intent_log_pool, f);
-  encode_json("usage_log_pool", usage_log_pool, f);
-  encode_json("roles_pool", roles_pool, f);
-  encode_json("reshard_pool", reshard_pool, f);
-  encode_json("user_keys_pool", user_keys_pool, f);
-  encode_json("user_email_pool", user_email_pool, f);
-  encode_json("user_swift_pool", user_swift_pool, f);
-  encode_json("user_uid_pool", user_uid_pool, f);
-  encode_json("otp_pool", otp_pool, f);
-  encode_json_plain("system_key", system_key, f);
-  encode_json("placement_pools", placement_pools, f);
-  encode_json("tier_config", tier_config, f);
-  encode_json("realm_id", realm_id, f);
-  encode_json("notif_pool", notif_pool, f);
-}
-
-void RGWZoneStorageClass::dump(Formatter *f) const
-{
-  if (data_pool) {
-    encode_json("data_pool", data_pool.get(), f);
-  }
-  if (compression_type) {
-    encode_json("compression_type", compression_type.get(), f);
-  }
-}
-
-void RGWZoneStorageClass::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("data_pool", data_pool, obj);
-  JSONDecoder::decode_json("compression_type", compression_type, obj);
-}
-
-void RGWZoneStorageClasses::dump(Formatter *f) const
-{
-  for (auto& i : m) {
-    encode_json(i.first.c_str(), i.second, f);
-  }
-}
-
-void RGWZoneStorageClasses::decode_json(JSONObj *obj)
-{
-  JSONFormattable f;
-  decode_json_obj(f, obj);
-
-  for (auto& field : f.object()) {
-    JSONObj *field_obj = obj->find_obj(field.first);
-    assert(field_obj);
-
-    decode_json_obj(m[field.first], field_obj);
-  }
-  standard_class = &m[RGW_STORAGE_CLASS_STANDARD];
-}
-
-void RGWZonePlacementInfo::dump(Formatter *f) const
-{
-  encode_json("index_pool", index_pool, f);
-  encode_json("storage_classes", storage_classes, f);
-  encode_json("data_extra_pool", data_extra_pool, f);
-  encode_json("index_type", (uint32_t)index_type, f);
-
-  /* no real need for backward compatibility of compression_type and data_pool in here,
-   * rather not clutter the output */
-}
-
-void RGWZonePlacementInfo::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("index_pool", index_pool, obj);
-  JSONDecoder::decode_json("storage_classes", storage_classes, obj);
-  JSONDecoder::decode_json("data_extra_pool", data_extra_pool, obj);
-  uint32_t it;
-  JSONDecoder::decode_json("index_type", it, obj);
-  index_type = (rgw::BucketIndexType)it;
-
-  /* backward compatibility, these are now defined in storage_classes */
-  string standard_compression_type;
-  string *pcompression = nullptr;
-  if (JSONDecoder::decode_json("compression", standard_compression_type, obj)) {
-    pcompression = &standard_compression_type;
-  }
-  rgw_pool standard_data_pool;
-  rgw_pool *ppool = nullptr;
-  if (JSONDecoder::decode_json("data_pool", standard_data_pool, obj)) {
-    ppool = &standard_data_pool;
-  }
-  if (ppool || pcompression) {
-    storage_classes.set_storage_class(RGW_STORAGE_CLASS_STANDARD, ppool, pcompression);
-  }
-}
-
-void RGWZoneParams::decode_json(JSONObj *obj)
-{
-  RGWSystemMetaObj::decode_json(obj);
-  JSONDecoder::decode_json("domain_root", domain_root, obj);
-  JSONDecoder::decode_json("control_pool", control_pool, obj);
-  JSONDecoder::decode_json("gc_pool", gc_pool, obj);
-  JSONDecoder::decode_json("lc_pool", lc_pool, obj);
-  JSONDecoder::decode_json("log_pool", log_pool, obj);
-  JSONDecoder::decode_json("intent_log_pool", intent_log_pool, obj);
-  JSONDecoder::decode_json("roles_pool", roles_pool, obj);
-  JSONDecoder::decode_json("reshard_pool", reshard_pool, obj);
-  JSONDecoder::decode_json("usage_log_pool", usage_log_pool, obj);
-  JSONDecoder::decode_json("user_keys_pool", user_keys_pool, obj);
-  JSONDecoder::decode_json("user_email_pool", user_email_pool, obj);
-  JSONDecoder::decode_json("user_swift_pool", user_swift_pool, obj);
-  JSONDecoder::decode_json("user_uid_pool", user_uid_pool, obj);
-  JSONDecoder::decode_json("otp_pool", otp_pool, obj);
-  JSONDecoder::decode_json("system_key", system_key, obj);
-  JSONDecoder::decode_json("placement_pools", placement_pools, obj);
-  JSONDecoder::decode_json("tier_config", tier_config, obj);
-  JSONDecoder::decode_json("realm_id", realm_id, obj);
-  JSONDecoder::decode_json("notif_pool", notif_pool, obj);
-
-}
-
-void RGWZone::dump(Formatter *f) const
-{
-  encode_json("id", id, f);
-  encode_json("name", name, f);
-  encode_json("endpoints", endpoints, f);
-  encode_json("log_meta", log_meta, f);
-  encode_json("log_data", log_data, f);
-  encode_json("bucket_index_max_shards", bucket_index_max_shards, f);
-  encode_json("read_only", read_only, f);
-  encode_json("tier_type", tier_type, f);
-  encode_json("sync_from_all", sync_from_all, f);
-  encode_json("sync_from", sync_from, f);
-  encode_json("redirect_zone", redirect_zone, f);
-}
-
-void RGWZone::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("id", id, obj);
-  JSONDecoder::decode_json("name", name, obj);
-  if (id.empty()) {
-    id = name;
-  }
-  JSONDecoder::decode_json("endpoints", endpoints, obj);
-  JSONDecoder::decode_json("log_meta", log_meta, obj);
-  JSONDecoder::decode_json("log_data", log_data, obj);
-  JSONDecoder::decode_json("bucket_index_max_shards", bucket_index_max_shards, obj);
-  JSONDecoder::decode_json("read_only", read_only, obj);
-  JSONDecoder::decode_json("tier_type", tier_type, obj);
-  JSONDecoder::decode_json("sync_from_all", sync_from_all, true, obj);
-  JSONDecoder::decode_json("sync_from", sync_from, obj);
-  JSONDecoder::decode_json("redirect_zone", redirect_zone, obj);
-}
-
-void RGWTierACLMapping::dump(Formatter *f) const
-{
-  string s;
-  switch (type) {
-    case ACL_TYPE_EMAIL_USER:
-      s = "email";
-      break;
-    case ACL_TYPE_GROUP:
-      s = "uri";
-      break;
-    default:
-      s = "id";
-      break;
-  }
-  encode_json("type", s, f);
-  encode_json("source_id", source_id, f);
-  encode_json("dest_id", dest_id, f);
-}
-
-void RGWTierACLMapping::decode_json(JSONObj *obj)
-{
-  string s;
-  JSONDecoder::decode_json("type", s, obj);
-  if (s == "email") {
-    type = ACL_TYPE_EMAIL_USER;
-  } else if (s == "uri") {
-    type = ACL_TYPE_GROUP;
-  } else {
-    type = ACL_TYPE_CANON_USER;
-  }
-
-  JSONDecoder::decode_json("source_id", source_id, obj);
-  JSONDecoder::decode_json("dest_id", dest_id, obj);
-}
-
-void RGWZoneGroupPlacementTier::dump(Formatter *f) const
-{
-  encode_json("tier_type", tier_type, f);
-  encode_json("storage_class", storage_class, f);
-  encode_json("retain_head_object", retain_head_object, f);
-
-  if (tier_type == "cloud-s3") {
-    encode_json("s3", t.s3, f);
-  }
-}
-
-void RGWZoneGroupPlacementTierS3::dump(Formatter *f) const
-{
-  encode_json("endpoint", endpoint, f);
-  encode_json("access_key", key.id, f);
-  encode_json("secret", key.key, f);
-  encode_json("region", region, f);
-  string s = (host_style == PathStyle ? "path" : "virtual");
-  encode_json("host_style", s, f);
-  encode_json("target_storage_class", target_storage_class, f);
-  encode_json("target_path", target_path, f);
-  encode_json("acl_mappings", acl_mappings, f);
-  encode_json("multipart_sync_threshold", multipart_sync_threshold, f);
-  encode_json("multipart_min_part_size", multipart_min_part_size, f);
-}
-
-void RGWZoneGroupPlacementTier::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("tier_type", tier_type, obj);
-  JSONDecoder::decode_json("storage_class", storage_class, obj);
-  JSONDecoder::decode_json("retain_head_object", retain_head_object, obj);
-
-  if (tier_type == "cloud-s3") {
-    JSONDecoder::decode_json("s3", t.s3, obj);
-  }
-}
-
-void RGWZoneGroupPlacementTierS3::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("endpoint", endpoint, obj);
-  JSONDecoder::decode_json("access_key", key.id, obj);
-  JSONDecoder::decode_json("secret", key.key, obj);
-  JSONDecoder::decode_json("region", region, obj);
-  string s;
-  JSONDecoder::decode_json("host_style", s, obj);
-  if (s != "virtual") {
-    host_style = PathStyle;
-  } else {
-    host_style = VirtualStyle;
-  }
-  JSONDecoder::decode_json("target_storage_class", target_storage_class, obj);
-  JSONDecoder::decode_json("target_path", target_path, obj);
-  JSONDecoder::decode_json("acl_mappings", acl_mappings, obj);
-  JSONDecoder::decode_json("multipart_sync_threshold", multipart_sync_threshold, obj);
-  JSONDecoder::decode_json("multipart_min_part_size", multipart_min_part_size, obj);
-}
-
-void RGWZoneGroupPlacementTarget::dump(Formatter *f) const
-{
-  encode_json("name", name, f);
-  encode_json("tags", tags, f);
-  encode_json("storage_classes", storage_classes, f);
-  if (!tier_targets.empty()) {
-    encode_json("tier_targets", tier_targets, f);
-  }
-}
-
-void RGWZoneGroupPlacementTarget::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("name", name, obj);
-  JSONDecoder::decode_json("tags", tags, obj);
-  JSONDecoder::decode_json("storage_classes", storage_classes, obj);
-  if (storage_classes.empty()) {
-    storage_classes.insert(RGW_STORAGE_CLASS_STANDARD);
-  }
-  if (!tier_targets.empty()) {
-    JSONDecoder::decode_json("tier_targets", tier_targets, obj);
-  }
-}
-
-void RGWZoneGroup::dump(Formatter *f) const
-{
-  RGWSystemMetaObj::dump(f);
-  encode_json("api_name", api_name, f);
-  encode_json("is_master", is_master, f);
-  encode_json("endpoints", endpoints, f);
-  encode_json("hostnames", hostnames, f);
-  encode_json("hostnames_s3website", hostnames_s3website, f);
-  encode_json("master_zone", master_zone, f);
-  encode_json_map("zones", zones, f); /* more friendly representation */
-  encode_json_map("placement_targets", placement_targets, f); /* more friendly representation */
-  encode_json("default_placement", default_placement, f);
-  encode_json("realm_id", realm_id, f);
-  encode_json("sync_policy", sync_policy, f);
-}
-
-static void decode_zones(map<rgw_zone_id, RGWZone>& zones, JSONObj *o)
-{
-  RGWZone z;
-  z.decode_json(o);
-  zones[z.id] = z;
-}
-
-static void decode_placement_targets(map<string, RGWZoneGroupPlacementTarget>& targets, JSONObj *o)
-{
-  RGWZoneGroupPlacementTarget t;
-  t.decode_json(o);
-  targets[t.name] = t;
-}
-
-
-void RGWZoneGroup::decode_json(JSONObj *obj)
-{
-  RGWSystemMetaObj::decode_json(obj);
-  if (id.empty()) {
-    derr << "old format " << dendl;
-    JSONDecoder::decode_json("name", name, obj);
-    id = name;
-  }
-  JSONDecoder::decode_json("api_name", api_name, obj);
-  JSONDecoder::decode_json("is_master", is_master, obj);
-  JSONDecoder::decode_json("endpoints", endpoints, obj);
-  JSONDecoder::decode_json("hostnames", hostnames, obj);
-  JSONDecoder::decode_json("hostnames_s3website", hostnames_s3website, obj);
-  JSONDecoder::decode_json("master_zone", master_zone, obj);
-  JSONDecoder::decode_json("zones", zones, decode_zones, obj);
-  JSONDecoder::decode_json("placement_targets", placement_targets, decode_placement_targets, obj);
-  JSONDecoder::decode_json("default_placement", default_placement.name, obj);
-  JSONDecoder::decode_json("default_storage_class", default_placement.storage_class, obj);
-  JSONDecoder::decode_json("realm_id", realm_id, obj);
-  JSONDecoder::decode_json("sync_policy", sync_policy, obj);
-}
-
-
-void RGWPeriodMap::dump(Formatter *f) const
-{
-  encode_json("id", id, f);
-  encode_json_map("zonegroups", zonegroups, f);
-  encode_json("short_zone_ids", short_zone_ids, f);
-}
-
-static void decode_zonegroups(map<string, RGWZoneGroup>& zonegroups, JSONObj *o)
-{
-  RGWZoneGroup zg;
-  zg.decode_json(o);
-  zonegroups[zg.get_id()] = zg;
-}
-
-void RGWPeriodMap::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("id", id, obj);
-  JSONDecoder::decode_json("zonegroups", zonegroups, decode_zonegroups, obj);
-  /* backward compatability with region */
-  if (zonegroups.empty()) {
-    JSONDecoder::decode_json("regions", zonegroups, obj);
-  }
-  /* backward compatability with region */
-  if (master_zonegroup.empty()) {
-    JSONDecoder::decode_json("master_region", master_zonegroup, obj);
-  }
-  JSONDecoder::decode_json("short_zone_ids", short_zone_ids, obj);
-}
-
-
-void RGWPeriodConfig::dump(Formatter *f) const
-{
-  encode_json("bucket_quota", bucket_quota, f);
-  encode_json("user_quota", user_quota, f);
-}
-
-void RGWPeriodConfig::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
-  JSONDecoder::decode_json("user_quota", user_quota, obj);
-}
-
-void RGWRegionMap::dump(Formatter *f) const
-{
-  encode_json("regions", regions, f);
-  encode_json("master_region", master_region, f);
-  encode_json("bucket_quota", bucket_quota, f);
-  encode_json("user_quota", user_quota, f);
-}
-
-void RGWRegionMap::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("regions", regions, obj);
-  JSONDecoder::decode_json("master_region", master_region, obj);
-  JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
-  JSONDecoder::decode_json("user_quota", user_quota, obj);
-}
-
-void RGWZoneGroupMap::dump(Formatter *f) const
-{
-  encode_json("zonegroups", zonegroups, f);
-  encode_json("master_zonegroup", master_zonegroup, f);
-  encode_json("bucket_quota", bucket_quota, f);
-  encode_json("user_quota", user_quota, f);
-}
-
-void RGWZoneGroupMap::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("zonegroups", zonegroups, obj);
-  /* backward compatability with region */
-  if (zonegroups.empty()) {
-    JSONDecoder::decode_json("regions", zonegroups, obj);
-  }
-  JSONDecoder::decode_json("master_zonegroup", master_zonegroup, obj);
-  /* backward compatability with region */
-  if (master_zonegroup.empty()) {
-    JSONDecoder::decode_json("master_region", master_zonegroup, obj);
-  }
-
-  JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
-  JSONDecoder::decode_json("user_quota", user_quota, obj);
-}
-
-void RGWMetadataLogInfo::dump(Formatter *f) const
-{
-  encode_json("marker", marker, f);
-  utime_t ut(last_update);
-  encode_json("last_update", ut, f);
-}
-
-void RGWMetadataLogInfo::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("marker", marker, obj);
-  utime_t ut;
-  JSONDecoder::decode_json("last_update", ut, obj);
-  last_update = ut.to_real_time();
-}
-
-void RGWDataChangesLogInfo::dump(Formatter *f) const
-{
-  encode_json("marker", marker, f);
-  utime_t ut(last_update);
-  encode_json("last_update", ut, f);
-}
-
-void RGWDataChangesLogInfo::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("marker", marker, obj);
-  utime_t ut;
-  JSONDecoder::decode_json("last_update", ut, obj);
-  last_update = ut.to_real_time();
-}
-
-
-void RGWRealm::dump(Formatter *f) const
-{
-  RGWSystemMetaObj::dump(f);
-  encode_json("current_period", current_period, f);
-  encode_json("epoch", epoch, f);
-}
-
-
-void RGWRealm::decode_json(JSONObj *obj)
-{
-  RGWSystemMetaObj::decode_json(obj);
-  JSONDecoder::decode_json("current_period", current_period, obj);
-  JSONDecoder::decode_json("epoch", epoch, obj);
-}
-
-void rgw::keystone::TokenEnvelope::Token::decode_json(JSONObj *obj)
-{
-  string expires_iso8601;
-  struct tm t;
-
-  JSONDecoder::decode_json("id", id, obj, true);
-  JSONDecoder::decode_json("tenant", tenant_v2, obj, true);
-  JSONDecoder::decode_json("expires", expires_iso8601, obj, true);
-
-  if (parse_iso8601(expires_iso8601.c_str(), &t)) {
-    expires = internal_timegm(&t);
-  } else {
-    expires = 0;
-    throw JSONDecoder::err("Failed to parse ISO8601 expiration date from Keystone response.");
-  }
-}
-
-void rgw::keystone::TokenEnvelope::Role::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("id", id, obj);
-  JSONDecoder::decode_json("name", name, obj, true);
-}
-
-void rgw::keystone::TokenEnvelope::Domain::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("id", id, obj, true);
-  JSONDecoder::decode_json("name", name, obj, true);
-}
-
-void rgw::keystone::TokenEnvelope::Project::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("id", id, obj, true);
-  JSONDecoder::decode_json("name", name, obj, true);
-  JSONDecoder::decode_json("domain", domain, obj);
-}
-
-void rgw::keystone::TokenEnvelope::User::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("id", id, obj, true);
-  JSONDecoder::decode_json("name", name, obj, true);
-  JSONDecoder::decode_json("domain", domain, obj);
-  JSONDecoder::decode_json("roles", roles_v2, obj);
-}
-
-void rgw::keystone::TokenEnvelope::decode_v3(JSONObj* const root_obj)
-{
-  std::string expires_iso8601;
-
-  JSONDecoder::decode_json("user", user, root_obj, true);
-  JSONDecoder::decode_json("expires_at", expires_iso8601, root_obj, true);
-  JSONDecoder::decode_json("roles", roles, root_obj, true);
-  JSONDecoder::decode_json("project", project, root_obj, true);
-
-  struct tm t;
-  if (parse_iso8601(expires_iso8601.c_str(), &t)) {
-    token.expires = internal_timegm(&t);
-  } else {
-    token.expires = 0;
-    throw JSONDecoder::err("Failed to parse ISO8601 expiration date"
-                           "from Keystone response.");
-  }
-}
-
-void rgw::keystone::TokenEnvelope::decode_v2(JSONObj* const root_obj)
-{
-  JSONDecoder::decode_json("user", user, root_obj, true);
-  JSONDecoder::decode_json("token", token, root_obj, true);
-
-  roles = user.roles_v2;
-  project = token.tenant_v2;
-}
-
-void rgw_slo_entry::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("path", path, obj);
-  JSONDecoder::decode_json("etag", etag, obj);
-  JSONDecoder::decode_json("size_bytes", size_bytes, obj);
-};
-
-void rgw_meta_sync_info::decode_json(JSONObj *obj)
-{
-  string s;
-  JSONDecoder::decode_json("status", s, obj);
-  if (s == "init") {
-    state = StateInit;
-  } else if (s == "building-full-sync-maps") {
-    state = StateBuildingFullSyncMaps;
-  } else if (s == "sync") {
-    state = StateSync;
-  }    
-  JSONDecoder::decode_json("num_shards", num_shards, obj);
-  JSONDecoder::decode_json("period", period, obj);
-  JSONDecoder::decode_json("realm_epoch", realm_epoch, obj);
-}
-
-void rgw_meta_sync_info::dump(Formatter *f) const
-{
-  string s;
-  switch ((SyncState)state) {
-  case StateInit:
-    s = "init";
-    break;
-  case StateBuildingFullSyncMaps:
-    s = "building-full-sync-maps";
-    break;
-  case StateSync:
-    s = "sync";
-    break;
-  default:
-    s = "unknown";
-    break;
-  }
-  encode_json("status", s, f);
-  encode_json("num_shards", num_shards, f);
-  encode_json("period", period, f);
-  encode_json("realm_epoch", realm_epoch, f);
-}
-
-void rgw_meta_sync_marker::decode_json(JSONObj *obj)
-{
-  int s;
-  JSONDecoder::decode_json("state", s, obj);
-  state = s;
-  JSONDecoder::decode_json("marker", marker, obj);
-  JSONDecoder::decode_json("next_step_marker", next_step_marker, obj);
-  JSONDecoder::decode_json("total_entries", total_entries, obj);
-  JSONDecoder::decode_json("pos", pos, obj);
-  utime_t ut;
-  JSONDecoder::decode_json("timestamp", ut, obj);
-  timestamp = ut.to_real_time();
-  JSONDecoder::decode_json("realm_epoch", realm_epoch, obj);
-}
-
-void rgw_meta_sync_marker::dump(Formatter *f) const
-{
-  encode_json("state", (int)state, f);
-  encode_json("marker", marker, f);
-  encode_json("next_step_marker", next_step_marker, f);
-  encode_json("total_entries", total_entries, f);
-  encode_json("pos", pos, f);
-  encode_json("timestamp", utime_t(timestamp), f);
-  encode_json("realm_epoch", realm_epoch, f);
-}
-
-void rgw_meta_sync_status::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("info", sync_info, obj);
-  JSONDecoder::decode_json("markers", sync_markers, obj);
-}
-
-void rgw_meta_sync_status::dump(Formatter *f) const {
-  encode_json("info", sync_info, f);
-  encode_json("markers", sync_markers, f);
-}
-
-void rgw_sync_error_info::dump(Formatter *f) const {
-  encode_json("source_zone", source_zone, f);
-  encode_json("error_code", error_code, f);
-  encode_json("message", message, f);
-}
-
-void rgw_bucket_shard_full_sync_marker::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("position", position, obj);
-  JSONDecoder::decode_json("count", count, obj);
-}
-
-void rgw_bucket_shard_full_sync_marker::dump(Formatter *f) const
-{
-  encode_json("position", position, f);
-  encode_json("count", count, f);
-}
-
-void rgw_bucket_shard_inc_sync_marker::decode_json(JSONObj *obj)
-{
-  JSONDecoder::decode_json("position", position, obj);
-  JSONDecoder::decode_json("timestamp", timestamp, obj);
-}
-
-void rgw_bucket_shard_inc_sync_marker::dump(Formatter *f) const
-{
-  encode_json("position", position, f);
-  encode_json("timestamp", timestamp, f);
-}
-
-void rgw_bucket_shard_sync_info::decode_json(JSONObj *obj)
-{
-  std::string s;
-  JSONDecoder::decode_json("status", s, obj);
-  if (s == "full-sync") {
-    state = StateFullSync;
-  } else if (s == "incremental-sync") {
-    state = StateIncrementalSync;
-  } else if (s == "stopped") {
-    state = StateStopped;
-  } else {
-    state = StateInit;
-  }
-  JSONDecoder::decode_json("full_marker", full_marker, obj);
-  JSONDecoder::decode_json("inc_marker", inc_marker, obj);
-}
-
-void rgw_bucket_shard_sync_info::dump(Formatter *f) const
-{
-  const char *s{nullptr};
-  switch ((SyncState)state) {
-    case StateInit:
-    s = "init";
-    break;
-  case StateFullSync:
-    s = "full-sync";
-    break;
-  case StateIncrementalSync:
-    s = "incremental-sync";
-    break;
-  case StateStopped:
-    s = "stopped";
-    break;
-  default:
-    s = "unknown";
-    break;
-  }
-  encode_json("status", s, f);
-  encode_json("full_marker", full_marker, f);
-  encode_json("inc_marker", inc_marker, f);
-}
-
-/* This utility function shouldn't conflict with the overload of std::to_string
- * provided by string_ref since Boost 1.54 as it's defined outside of the std
- * namespace. I hope we'll remove it soon - just after merging the Matt's PR
- * for bundled Boost. It would allow us to forget that CentOS 7 has Boost 1.53. */
-static inline std::string to_string(const std::string_view& s)
-{
-  return std::string(s.data(), s.length());
-}
-
-void rgw::keystone::AdminTokenRequestVer2::dump(Formatter* const f) const
-{
-  f->open_object_section("token_request");
-    f->open_object_section("auth");
-      f->open_object_section("passwordCredentials");
-        encode_json("username", ::to_string(conf.get_admin_user()), f);
-        encode_json("password", ::to_string(conf.get_admin_password()), f);
-      f->close_section();
-      encode_json("tenantName", ::to_string(conf.get_admin_tenant()), f);
-    f->close_section();
-  f->close_section();
-}
-
-void rgw::keystone::AdminTokenRequestVer3::dump(Formatter* const f) const
-{
-  f->open_object_section("token_request");
-    f->open_object_section("auth");
-      f->open_object_section("identity");
-        f->open_array_section("methods");
-          f->dump_string("", "password");
-        f->close_section();
-        f->open_object_section("password");
-          f->open_object_section("user");
-            f->open_object_section("domain");
-              encode_json("name", ::to_string(conf.get_admin_domain()), f);
-            f->close_section();
-            encode_json("name", ::to_string(conf.get_admin_user()), f);
-            encode_json("password", ::to_string(conf.get_admin_password()), f);
-          f->close_section();
-        f->close_section();
-      f->close_section();
-      f->open_object_section("scope");
-        f->open_object_section("project");
-          if (! conf.get_admin_project().empty()) {
-            encode_json("name", ::to_string(conf.get_admin_project()), f);
-          } else {
-            encode_json("name", ::to_string(conf.get_admin_tenant()), f);
-          }
-          f->open_object_section("domain");
-            encode_json("name", ::to_string(conf.get_admin_domain()), f);
-          f->close_section();
-        f->close_section();
-      f->close_section();
-    f->close_section();
-  f->close_section();
-}
-
-
-void rgw::keystone::BarbicanTokenRequestVer2::dump(Formatter* const f) const
-{
-  f->open_object_section("token_request");
-    f->open_object_section("auth");
-      f->open_object_section("passwordCredentials");
-        encode_json("username", cct->_conf->rgw_keystone_barbican_user, f);
-        encode_json("password", cct->_conf->rgw_keystone_barbican_password, f);
-      f->close_section();
-      encode_json("tenantName", cct->_conf->rgw_keystone_barbican_tenant, f);
-    f->close_section();
-  f->close_section();
-}
-
-void rgw::keystone::BarbicanTokenRequestVer3::dump(Formatter* const f) const
-{
-  f->open_object_section("token_request");
-    f->open_object_section("auth");
-      f->open_object_section("identity");
-        f->open_array_section("methods");
-          f->dump_string("", "password");
-        f->close_section();
-        f->open_object_section("password");
-          f->open_object_section("user");
-            f->open_object_section("domain");
-              encode_json("name", cct->_conf->rgw_keystone_barbican_domain, f);
-            f->close_section();
-            encode_json("name", cct->_conf->rgw_keystone_barbican_user, f);
-            encode_json("password", cct->_conf->rgw_keystone_barbican_password, f);
-          f->close_section();
-        f->close_section();
-      f->close_section();
-      f->open_object_section("scope");
-        f->open_object_section("project");
-          if (!cct->_conf->rgw_keystone_barbican_project.empty()) {
-            encode_json("name", cct->_conf->rgw_keystone_barbican_project, f);
-          } else {
-            encode_json("name", cct->_conf->rgw_keystone_barbican_tenant, f);
-          }
-          f->open_object_section("domain");
-            encode_json("name", cct->_conf->rgw_keystone_barbican_domain, f);
-          f->close_section();
-        f->close_section();
-      f->close_section();
-    f->close_section();
-  f->close_section();
-}
-
-void RGWOrphanSearchStage::dump(Formatter *f) const
-{
-  f->open_object_section("orphan_search_stage");
-  string s;
-  switch(stage){
-  case ORPHAN_SEARCH_STAGE_INIT:
-    s = "init";
-    break;
-  case ORPHAN_SEARCH_STAGE_LSPOOL:
-    s = "lspool";
-    break;
-  case ORPHAN_SEARCH_STAGE_LSBUCKETS:
-    s =  "lsbuckets";
-    break;
-  case ORPHAN_SEARCH_STAGE_ITERATE_BI:
-    s = "iterate_bucket_index";
-    break;
-  case ORPHAN_SEARCH_STAGE_COMPARE:
-    s = "comparing";
-    break;
-  default:
-    s = "unknown";
-  }
-  f->dump_string("search_stage", s);
-  f->dump_int("shard",shard);
-  f->dump_string("marker",marker);
-  f->close_section();
-}
-
-void RGWOrphanSearchInfo::dump(Formatter *f) const
-{
-  f->open_object_section("orphan_search_info");
-  f->dump_string("job_name", job_name);
-  encode_json("pool", pool, f);
-  f->dump_int("num_shards", num_shards);
-  encode_json("start_time", start_time, f);
-  f->close_section();
-}
-
-void RGWOrphanSearchState::dump(Formatter *f) const
-{
-  f->open_object_section("orphan_search_state");
-  encode_json("info", info, f);
-  encode_json("stage", stage, f);
-  f->close_section();
-}
-
-void RGWObjTags::dump(Formatter *f) const
-{
-  f->open_object_section("tagset");
-  for (auto& tag: tag_map){
-    f->dump_string(tag.first.c_str(), tag.second);
-  }
-  f->close_section();
-}
-
-void lc_op::dump(Formatter *f) const
-{
-  f->dump_bool("status", status);
-  f->dump_bool("dm_expiration", dm_expiration);
-
-  f->dump_int("expiration", expiration);
-  f->dump_int("noncur_expiration", noncur_expiration);
-  f->dump_int("mp_expiration", mp_expiration);
-  if (expiration_date) {
-    utime_t ut(*expiration_date);
-    f->dump_stream("expiration_date") << ut;
-  }
-  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, transition);
-  }
-  f->close_section();
-
-  f->open_object_section("noncur_transitions");  
-  for (auto& [storage_class, transition] : noncur_transitions) {
-    f->dump_object(storage_class, transition);
-  }
-  f->close_section();
-}
-
-void LCFilter::dump(Formatter *f) const
-{
-  f->dump_string("prefix", prefix);
-  f->dump_object("obj_tags", obj_tags);
-}
-
-void LCExpiration::dump(Formatter *f) const
-{
-  f->dump_string("days", days);
-  f->dump_string("date", date);
-}
-
-void LCRule::dump(Formatter *f) const
-{
-  f->dump_string("id", id);
-  f->dump_string("prefix", prefix);
-  f->dump_string("status", status);
-  f->dump_object("expiration", expiration);
-  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, transition);
-  }
-  f->close_section();
-
-  f->open_object_section("noncur_transitions");  
-  for (auto& [storage_class, transition] : noncur_transitions) {
-    f->dump_object(storage_class, transition);
-  }
-  f->close_section();
-  f->dump_bool("dm_expiration", dm_expiration);
-}
-
-void RGWLifecycleConfiguration::dump(Formatter *f) const
-{
-  f->open_object_section("prefix_map");
-  for (auto& prefix : prefix_map) {
-    f->dump_object(prefix.first.c_str(), prefix.second);
-  }
-  f->close_section();
-
-  f->open_array_section("rule_map");
-  for (auto& rule : rule_map) {
-    f->open_object_section("entry");
-    f->dump_string("id", rule.first);
-    f->open_object_section("rule");
-    rule.second.dump(f);
-    f->close_section();
-    f->close_section();
-  }
-  f->close_section();
-}
-
-void compression_block::dump(Formatter *f) const
-{
-  f->dump_unsigned("old_ofs", old_ofs);
-  f->dump_unsigned("new_ofs", new_ofs);
-  f->dump_unsigned("len", len);
-}
-
-void RGWCompressionInfo::dump(Formatter *f) const
-{
-  f->dump_string("compression_type", compression_type);
-  f->dump_unsigned("orig_size", orig_size);
-  if (compressor_message) {
-    f->dump_int("compressor_message", *compressor_message);
-  }
-  ::encode_json("blocks", blocks, f);
-}
-
-void objexp_hint_entry::dump(Formatter *f) const
-{
-  f->open_object_section("objexp_hint_entry");
-  encode_json("tenant", tenant, f);
-  encode_json("bucket_name", bucket_name, f);
-  encode_json("bucket_id", bucket_id, f);
-  encode_json("rgw_obj_key", obj_key, f);
-  utime_t ut(exp_time);
-  encode_json("exp_time", ut, f);
-  f->close_section();
-}
-
-void rgw_user::dump(Formatter *f) const
-{
-  ::encode_json("user", *this, f);
-}
index fb8a00a6d33bc3389b6127711e489f78d4073609..15033aee261b2e14d808a2937f2f826cdb0cee33 100644 (file)
@@ -491,3 +491,180 @@ bool TokenCache::going_down() const
 
 }; /* namespace keystone */
 }; /* namespace rgw */
+
+void rgw::keystone::TokenEnvelope::Token::decode_json(JSONObj *obj)
+{
+  string expires_iso8601;
+  struct tm t;
+
+  JSONDecoder::decode_json("id", id, obj, true);
+  JSONDecoder::decode_json("tenant", tenant_v2, obj, true);
+  JSONDecoder::decode_json("expires", expires_iso8601, obj, true);
+
+  if (parse_iso8601(expires_iso8601.c_str(), &t)) {
+    expires = internal_timegm(&t);
+  } else {
+    expires = 0;
+    throw JSONDecoder::err("Failed to parse ISO8601 expiration date from Keystone response.");
+  }
+}
+
+void rgw::keystone::TokenEnvelope::Role::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("id", id, obj);
+  JSONDecoder::decode_json("name", name, obj, true);
+}
+
+void rgw::keystone::TokenEnvelope::Domain::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("id", id, obj, true);
+  JSONDecoder::decode_json("name", name, obj, true);
+}
+
+void rgw::keystone::TokenEnvelope::Project::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("id", id, obj, true);
+  JSONDecoder::decode_json("name", name, obj, true);
+  JSONDecoder::decode_json("domain", domain, obj);
+}
+
+void rgw::keystone::TokenEnvelope::User::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("id", id, obj, true);
+  JSONDecoder::decode_json("name", name, obj, true);
+  JSONDecoder::decode_json("domain", domain, obj);
+  JSONDecoder::decode_json("roles", roles_v2, obj);
+}
+
+void rgw::keystone::TokenEnvelope::decode_v3(JSONObj* const root_obj)
+{
+  std::string expires_iso8601;
+
+  JSONDecoder::decode_json("user", user, root_obj, true);
+  JSONDecoder::decode_json("expires_at", expires_iso8601, root_obj, true);
+  JSONDecoder::decode_json("roles", roles, root_obj, true);
+  JSONDecoder::decode_json("project", project, root_obj, true);
+
+  struct tm t;
+  if (parse_iso8601(expires_iso8601.c_str(), &t)) {
+    token.expires = internal_timegm(&t);
+  } else {
+    token.expires = 0;
+    throw JSONDecoder::err("Failed to parse ISO8601 expiration date"
+                           "from Keystone response.");
+  }
+}
+
+void rgw::keystone::TokenEnvelope::decode_v2(JSONObj* const root_obj)
+{
+  JSONDecoder::decode_json("user", user, root_obj, true);
+  JSONDecoder::decode_json("token", token, root_obj, true);
+
+  roles = user.roles_v2;
+  project = token.tenant_v2;
+}
+
+/* This utility function shouldn't conflict with the overload of std::to_string
+ * provided by string_ref since Boost 1.54 as it's defined outside of the std
+ * namespace. I hope we'll remove it soon - just after merging the Matt's PR
+ * for bundled Boost. It would allow us to forget that CentOS 7 has Boost 1.53. */
+static inline std::string to_string(const std::string_view& s)
+{
+  return std::string(s.data(), s.length());
+}
+
+void rgw::keystone::AdminTokenRequestVer2::dump(Formatter* const f) const
+{
+  f->open_object_section("token_request");
+    f->open_object_section("auth");
+      f->open_object_section("passwordCredentials");
+        encode_json("username", ::to_string(conf.get_admin_user()), f);
+        encode_json("password", ::to_string(conf.get_admin_password()), f);
+      f->close_section();
+      encode_json("tenantName", ::to_string(conf.get_admin_tenant()), f);
+    f->close_section();
+  f->close_section();
+}
+
+void rgw::keystone::AdminTokenRequestVer3::dump(Formatter* const f) const
+{
+  f->open_object_section("token_request");
+    f->open_object_section("auth");
+      f->open_object_section("identity");
+        f->open_array_section("methods");
+          f->dump_string("", "password");
+        f->close_section();
+        f->open_object_section("password");
+          f->open_object_section("user");
+            f->open_object_section("domain");
+              encode_json("name", ::to_string(conf.get_admin_domain()), f);
+            f->close_section();
+            encode_json("name", ::to_string(conf.get_admin_user()), f);
+            encode_json("password", ::to_string(conf.get_admin_password()), f);
+          f->close_section();
+        f->close_section();
+      f->close_section();
+      f->open_object_section("scope");
+        f->open_object_section("project");
+          if (! conf.get_admin_project().empty()) {
+            encode_json("name", ::to_string(conf.get_admin_project()), f);
+          } else {
+            encode_json("name", ::to_string(conf.get_admin_tenant()), f);
+          }
+          f->open_object_section("domain");
+            encode_json("name", ::to_string(conf.get_admin_domain()), f);
+          f->close_section();
+        f->close_section();
+      f->close_section();
+    f->close_section();
+  f->close_section();
+}
+
+void rgw::keystone::BarbicanTokenRequestVer2::dump(Formatter* const f) const
+{
+  f->open_object_section("token_request");
+    f->open_object_section("auth");
+      f->open_object_section("passwordCredentials");
+        encode_json("username", cct->_conf->rgw_keystone_barbican_user, f);
+        encode_json("password", cct->_conf->rgw_keystone_barbican_password, f);
+      f->close_section();
+      encode_json("tenantName", cct->_conf->rgw_keystone_barbican_tenant, f);
+    f->close_section();
+  f->close_section();
+}
+
+void rgw::keystone::BarbicanTokenRequestVer3::dump(Formatter* const f) const
+{
+  f->open_object_section("token_request");
+    f->open_object_section("auth");
+      f->open_object_section("identity");
+        f->open_array_section("methods");
+          f->dump_string("", "password");
+        f->close_section();
+        f->open_object_section("password");
+          f->open_object_section("user");
+            f->open_object_section("domain");
+              encode_json("name", cct->_conf->rgw_keystone_barbican_domain, f);
+            f->close_section();
+            encode_json("name", cct->_conf->rgw_keystone_barbican_user, f);
+            encode_json("password", cct->_conf->rgw_keystone_barbican_password, f);
+          f->close_section();
+        f->close_section();
+      f->close_section();
+      f->open_object_section("scope");
+        f->open_object_section("project");
+          if (!cct->_conf->rgw_keystone_barbican_project.empty()) {
+            encode_json("name", cct->_conf->rgw_keystone_barbican_project, f);
+          } else {
+            encode_json("name", cct->_conf->rgw_keystone_barbican_tenant, f);
+          }
+          f->open_object_section("domain");
+            encode_json("name", cct->_conf->rgw_keystone_barbican_domain, f);
+          f->close_section();
+        f->close_section();
+      f->close_section();
+    f->close_section();
+  f->close_section();
+}
+
+
index 3ad0f85d6079f09bf2307505c57e507b2232e26b..c930863d6a08ede4e03fee60edc2ba5f5551eeb6 100644 (file)
@@ -2648,3 +2648,88 @@ bool s3_multipart_abort_header(
 }
 
 } /* namespace rgw::lc */
+
+void lc_op::dump(Formatter *f) const
+{
+  f->dump_bool("status", status);
+  f->dump_bool("dm_expiration", dm_expiration);
+
+  f->dump_int("expiration", expiration);
+  f->dump_int("noncur_expiration", noncur_expiration);
+  f->dump_int("mp_expiration", mp_expiration);
+  if (expiration_date) {
+    utime_t ut(*expiration_date);
+    f->dump_stream("expiration_date") << ut;
+  }
+  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, transition);
+  }
+  f->close_section();
+
+  f->open_object_section("noncur_transitions");
+  for (auto& [storage_class, transition] : noncur_transitions) {
+    f->dump_object(storage_class, transition);
+  }
+  f->close_section();
+}
+
+void LCFilter::dump(Formatter *f) const
+{
+  f->dump_string("prefix", prefix);
+  f->dump_object("obj_tags", obj_tags);
+}
+
+void LCExpiration::dump(Formatter *f) const
+{
+  f->dump_string("days", days);
+  f->dump_string("date", date);
+}
+
+void LCRule::dump(Formatter *f) const
+{
+  f->dump_string("id", id);
+  f->dump_string("prefix", prefix);
+  f->dump_string("status", status);
+  f->dump_object("expiration", expiration);
+  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, transition);
+  }
+  f->close_section();
+
+  f->open_object_section("noncur_transitions");
+  for (auto& [storage_class, transition] : noncur_transitions) {
+    f->dump_object(storage_class, transition);
+  }
+  f->close_section();
+  f->dump_bool("dm_expiration", dm_expiration);
+}
+
+
+void RGWLifecycleConfiguration::dump(Formatter *f) const
+{
+  f->open_object_section("prefix_map");
+  for (auto& prefix : prefix_map) {
+    f->dump_object(prefix.first.c_str(), prefix.second);
+  }
+  f->close_section();
+
+  f->open_array_section("rule_map");
+  for (auto& rule : rule_map) {
+    f->open_object_section("entry");
+    f->dump_string("id", rule.first);
+    f->open_object_section("rule");
+    rule.second.dump(f);
+    f->close_section();
+    f->close_section();
+  }
+  f->close_section();
+}
+
index aee079daf7f0e1e1c01607c2a0c3079136841138..4214708ef1562121a3206d40b1c482abed47e65d 100644 (file)
@@ -628,3 +628,52 @@ int rgw_log_op(RGWREST* const rest, struct req_state *s, const string& op_name,
   }
   return 0;
 }
+
+void rgw_log_entry::generate_test_instances(list<rgw_log_entry*>& o)
+{
+  rgw_log_entry *e = new rgw_log_entry;
+  e->object_owner = "object_owner";
+  e->bucket_owner = "bucket_owner";
+  e->bucket = "bucket";
+  e->remote_addr = "1.2.3.4";
+  e->user = "user";
+  e->obj = rgw_obj_key("obj");
+  e->uri = "http://uri/bucket/obj";
+  e->http_status = "200";
+  e->error_code = "error_code";
+  e->bytes_sent = 1024;
+  e->bytes_received = 512;
+  e->obj_size = 2048;
+  e->user_agent = "user_agent";
+  e->referrer = "referrer";
+  e->bucket_id = "10";
+  e->trans_id = "trans_id";
+  e->identity_type = TYPE_RGW;
+  o.push_back(e);
+  o.push_back(new rgw_log_entry);
+}
+
+void rgw_log_entry::dump(Formatter *f) const
+{
+  f->dump_string("object_owner", object_owner.to_str());
+  f->dump_string("bucket_owner", bucket_owner.to_str());
+  f->dump_string("bucket", bucket);
+  f->dump_stream("time") << time;
+  f->dump_string("remote_addr", remote_addr);
+  f->dump_string("user", user);
+  f->dump_stream("obj") << obj;
+  f->dump_string("op", op);
+  f->dump_string("uri", uri);
+  f->dump_string("http_status", http_status);
+  f->dump_string("error_code", error_code);
+  f->dump_unsigned("bytes_sent", bytes_sent);
+  f->dump_unsigned("bytes_received", bytes_received);
+  f->dump_unsigned("obj_size", obj_size);
+  f->dump_stream("total_time") << total_time;
+  f->dump_string("user_agent", user_agent);
+  f->dump_string("referrer", referrer);
+  f->dump_string("bucket_id", bucket_id);
+  f->dump_string("trans_id", trans_id);
+  f->dump_unsigned("identity_type", identity_type);
+}
+
index f036bf5485d3ea739f566f21c397f36834a39a0b..b3ba33eac80e3f5bb55992208501f6439652b582 100644 (file)
@@ -31,6 +31,22 @@ using namespace std;
 
 const std::string RGWMetadataLogHistory::oid = "meta.history";
 
+struct obj_version;
+
+void encode_json(const char *name, const obj_version& v, Formatter *f)
+{
+  f->open_object_section(name);
+  f->dump_string("tag", v.tag);
+  f->dump_unsigned("ver", v.ver);
+  f->close_section();
+}
+
+void decode_json_obj(obj_version& v, JSONObj *obj)
+{
+  JSONDecoder::decode_json("tag", v.tag, obj);
+  JSONDecoder::decode_json("ver", v.ver, obj);
+}
+
 void LogStatusDump::dump(Formatter *f) const {
   string s;
   switch (status) {
@@ -857,3 +873,18 @@ void RGWMetadataManager::get_sections(list<string>& sections)
   }
 }
 
+void RGWMetadataLogInfo::dump(Formatter *f) const
+{
+  encode_json("marker", marker, f);
+  utime_t ut(last_update);
+  encode_json("last_update", ut, f);
+}
+
+void RGWMetadataLogInfo::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("marker", marker, obj);
+  utime_t ut;
+  JSONDecoder::decode_json("last_update", ut, obj);
+  last_update = ut.to_real_time();
+}
+
index ecb0979e379abfdd435661a1b1d9de20e5f7142d..b7c8a1931d6d8a27594b3a88fdc1daad7f1b13f8 100644 (file)
@@ -79,3 +79,22 @@ bool is_v2_upload_id(const string& upload_id)
          (strncmp(uid, MULTIPART_UPLOAD_ID_PREFIX_LEGACY, sizeof(MULTIPART_UPLOAD_ID_PREFIX_LEGACY) - 1) == 0);
 }
 
+void RGWUploadPartInfo::generate_test_instances(list<RGWUploadPartInfo*>& o)
+{
+  RGWUploadPartInfo *i = new RGWUploadPartInfo;
+  i->num = 1;
+  i->size = 10 * 1024 * 1024;
+  i->etag = "etag";
+  o.push_back(i);
+  o.push_back(new RGWUploadPartInfo);
+}
+
+void RGWUploadPartInfo::dump(Formatter *f) const
+{
+  encode_json("num", num, f);
+  encode_json("size", size, f);
+  encode_json("etag", etag, f);
+  utime_t ut(modified);
+  encode_json("modified", ut, f);
+}
+
index 227e1dda759adc12c4356f11307631a8aba73665..5af0b12a8daf80eae8010fc2e773f35afd960aca 100644 (file)
@@ -6,6 +6,7 @@
 #include "services/svc_zone.h"
 #include "services/svc_tier_rados.h"
 #include "rgw_rados.h" // RGW_OBJ_NS_SHADOW and RGW_OBJ_NS_MULTIPART
+#include "rgw_bucket.h"
 
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_rgw
@@ -505,3 +506,109 @@ void RGWObjManifest::get_implicit_location(uint64_t cur_part_id, uint64_t cur_st
   location->set_placement_rule(tail_placement.placement_rule);
   *location = loc;
 }
+
+void RGWObjManifestPart::generate_test_instances(std::list<RGWObjManifestPart*>& o)
+{
+  o.push_back(new RGWObjManifestPart);
+
+  RGWObjManifestPart *p = new RGWObjManifestPart;
+  rgw_bucket b;
+  init_bucket(&b, "tenant", "bucket", ".pool", ".index_pool", "marker_", "12");
+
+  p->loc = rgw_obj(b, "object");
+  p->loc_ofs = 512 * 1024;
+  p->size = 128 * 1024;
+  o.push_back(p);
+}
+
+void RGWObjManifest::generate_test_instances(std::list<RGWObjManifest*>& o)
+{
+  RGWObjManifest *m = new RGWObjManifest;
+  map<uint64_t, RGWObjManifestPart> objs;
+  uint64_t total_size = 0;
+  for (int i = 0; i<10; i++) {
+    RGWObjManifestPart p;
+    rgw_bucket b;
+    init_bucket(&b, "tenant", "bucket", ".pool", ".index_pool", "marker_", "12");
+    p.loc = rgw_obj(b, "object");
+    p.loc_ofs = 0;
+    p.size = 512 * 1024;
+    total_size += p.size;
+    objs[total_size] = p;
+  }
+  m->set_explicit(total_size, objs);
+  o.push_back(m);
+  o.push_back(new RGWObjManifest);
+}
+
+void RGWObjManifestPart::dump(Formatter *f) const
+{
+  f->open_object_section("loc");
+  loc.dump(f);
+  f->close_section();
+  f->dump_unsigned("loc_ofs", loc_ofs);
+  f->dump_unsigned("size", size);
+}
+
+void RGWObjManifest::obj_iterator::dump(Formatter *f) const
+{
+  f->dump_unsigned("part_ofs", part_ofs);
+  f->dump_unsigned("stripe_ofs", stripe_ofs);
+  f->dump_unsigned("ofs", ofs);
+  f->dump_unsigned("stripe_size", stripe_size);
+  f->dump_int("cur_part_id", cur_part_id);
+  f->dump_int("cur_stripe", cur_stripe);
+  f->dump_string("cur_override_prefix", cur_override_prefix);
+  f->dump_object("location", location);
+}
+
+void RGWObjManifest::dump(Formatter *f) const
+{
+  map<uint64_t, RGWObjManifestPart>::const_iterator iter = objs.begin();
+  f->open_array_section("objs");
+  for (; iter != objs.end(); ++iter) {
+    f->dump_unsigned("ofs", iter->first);
+    f->open_object_section("part");
+    iter->second.dump(f);
+    f->close_section();
+  }
+  f->close_section();
+  f->dump_unsigned("obj_size", obj_size);
+  ::encode_json("explicit_objs", explicit_objs, f);
+  ::encode_json("head_size", head_size, f);
+  ::encode_json("max_head_size", max_head_size, f);
+  ::encode_json("prefix", prefix, f);
+  ::encode_json("rules", rules, f);
+  ::encode_json("tail_instance", tail_instance, f);
+  ::encode_json("tail_placement", tail_placement, f);
+
+  // nullptr being passed into iterators since there
+  // is no cct and we aren't doing anything with these
+  // iterators that would write do the log
+  f->dump_object("begin_iter", obj_begin(nullptr));
+  f->dump_object("end_iter", obj_end(nullptr));
+}
+
+void RGWObjManifestRule::dump(Formatter *f) const
+{
+  encode_json("start_part_num", start_part_num, f);
+  encode_json("start_ofs", start_ofs, f);
+  encode_json("part_size", part_size, f);
+  encode_json("stripe_max_size", stripe_max_size, f);
+  encode_json("override_prefix", override_prefix, f);
+}
+
+void rgw_obj_select::dump(Formatter *f) const
+{
+  f->dump_string("placement_rule", placement_rule.to_str());
+  f->dump_object("obj", obj);
+  f->dump_object("raw_obj", raw_obj);
+  f->dump_bool("is_raw", is_raw);
+}
+
+void RGWObjTier::dump(Formatter *f) const
+{
+  encode_json("name", name, f);
+  encode_json("tier_placement", tier_placement, f);
+  encode_json("is_multipart_upload", is_multipart_upload, f);
+}
index d79a2d8c01bff781bf01a2816123b58ceefbc092..6b761f470e47966a3d3051884919bc757250afbd 100644 (file)
@@ -8734,3 +8734,11 @@ void RGWDeleteBucketEncryption::execute(optional_yield y)
     return op_ret;
   });
 }
+
+void rgw_slo_entry::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("path", path, obj);
+  JSONDecoder::decode_json("etag", etag, obj);
+  JSONDecoder::decode_json("size_bytes", size_bytes, obj);
+};
+
index 3d19f4366fb8310ee49688c55c81521350b944c6..874061306b6580f90a59186c3dcd9a3e2ffd9d0f 100644 (file)
@@ -1523,3 +1523,52 @@ int RGWRadosList::do_incomplete_multipart(const DoutPrefixProvider *dpp,
 
   return 0;
 } // RGWRadosList::do_incomplete_multipart
+
+void RGWOrphanSearchStage::dump(Formatter *f) const
+{
+  f->open_object_section("orphan_search_stage");
+  string s;
+  switch(stage){
+  case ORPHAN_SEARCH_STAGE_INIT:
+    s = "init";
+    break;
+  case ORPHAN_SEARCH_STAGE_LSPOOL:
+    s = "lspool";
+    break;
+  case ORPHAN_SEARCH_STAGE_LSBUCKETS:
+    s =  "lsbuckets";
+    break;
+  case ORPHAN_SEARCH_STAGE_ITERATE_BI:
+    s = "iterate_bucket_index";
+    break;
+  case ORPHAN_SEARCH_STAGE_COMPARE:
+    s = "comparing";
+    break;
+  default:
+    s = "unknown";
+  }
+  f->dump_string("search_stage", s);
+  f->dump_int("shard",shard);
+  f->dump_string("marker",marker);
+  f->close_section();
+}
+
+void RGWOrphanSearchInfo::dump(Formatter *f) const
+{
+  f->open_object_section("orphan_search_info");
+  f->dump_string("job_name", job_name);
+  encode_json("pool", pool, f);
+  f->dump_int("num_shards", num_shards);
+  encode_json("start_time", start_time, f);
+  f->close_section();
+}
+
+void RGWOrphanSearchState::dump(Formatter *f) const
+{
+  f->open_object_section("orphan_search_state");
+  encode_json("info", info, f);
+  encode_json("stage", stage, f);
+  f->close_section();
+}
+
+
index 1cbb06ae3a6c299d5c0650d1f59b3204fd0b9949..f31abae145f1c2d1ce1f9025fb809acfa80ff85b 100644 (file)
@@ -1003,3 +1003,29 @@ void rgw_apply_default_user_quota(RGWQuotaInfo& quota, const ConfigProxy& conf)
     quota.enabled = true;
   }
 }
+
+void RGWQuotaInfo::dump(Formatter *f) const
+{
+  f->dump_bool("enabled", enabled);
+  f->dump_bool("check_on_raw", check_on_raw);
+
+  f->dump_int("max_size", max_size);
+  f->dump_int("max_size_kb", rgw_rounded_kb(max_size));
+  f->dump_int("max_objects", max_objects);
+}
+
+void RGWQuotaInfo::decode_json(JSONObj *obj)
+{
+  if (false == JSONDecoder::decode_json("max_size", max_size, obj)) {
+    /* We're parsing an older version of the struct. */
+    int64_t max_size_kb = 0;
+
+    JSONDecoder::decode_json("max_size_kb", max_size_kb, obj);
+    max_size = max_size_kb * 1024;
+  }
+  JSONDecoder::decode_json("max_objects", max_objects, obj);
+
+  JSONDecoder::decode_json("check_on_raw", check_on_raw, obj);
+  JSONDecoder::decode_json("enabled", enabled, obj);
+}
+
index 9cb1b9981506e88c9426defe9d0ca4d015a48b6d..e4fa7afcb112a0cd6637a297dc3e5c3fed0d33af 100644 (file)
@@ -9457,3 +9457,46 @@ int RGWRados::delete_obj_aio(const DoutPrefixProvider *dpp, const rgw_obj& obj,
   }
   return ret;
 }
+
+void objexp_hint_entry::generate_test_instances(list<objexp_hint_entry*>& o)
+{
+  auto it = new objexp_hint_entry;
+  it->tenant = "tenant1";
+  it->bucket_name = "bucket1";
+  it->bucket_id = "1234";
+  it->obj_key = rgw_obj_key("obj");
+  o.push_back(it);
+  o.push_back(new objexp_hint_entry);
+}
+
+void objexp_hint_entry::dump(Formatter *f) const
+{
+  f->open_object_section("objexp_hint_entry");
+  encode_json("tenant", tenant, f);
+  encode_json("bucket_name", bucket_name, f);
+  encode_json("bucket_id", bucket_id, f);
+  encode_json("rgw_obj_key", obj_key, f);
+  utime_t ut(exp_time);
+  encode_json("exp_time", ut, f);
+  f->close_section();
+}
+
+void RGWOLHInfo::generate_test_instances(list<RGWOLHInfo*> &o)
+{
+  RGWOLHInfo *olh = new RGWOLHInfo;
+  olh->removed = false;
+  o.push_back(olh);
+  o.push_back(new RGWOLHInfo);
+}
+
+void RGWOLHInfo::dump(Formatter *f) const
+{
+  encode_json("target", target, f);
+}
+
+void RGWOLHPendingInfo::dump(Formatter *f) const
+{
+  utime_t ut(time);
+  encode_json("time", ut, f);
+}
+
index e921aeb1adf1e463771670d02f07e4e7b92ad82a..80b710d404a7c2cec86d607956f7320ca4a0edcc 100644 (file)
@@ -3,13 +3,15 @@
 
 #include <boost/optional.hpp>
 
-#include "common/ceph_json.h"
 #include "common/RefCountedObj.h"
 #include "common/WorkQueue.h"
 #include "common/Throttle.h"
 #include "common/admin_socket.h"
 #include "common/errno.h"
 
+#include "common/ceph_json.h"
+#include "common/Formatter.h"
+
 #include "rgw_common.h"
 #include "rgw_zone.h"
 #include "rgw_sync.h"
@@ -2480,3 +2482,87 @@ int RGWCloneMetaLogCoroutine::state_store_mdlog_entries_complete()
 {
   return set_cr_done();
 }
+
+void rgw_meta_sync_info::decode_json(JSONObj *obj)
+{
+  string s;
+  JSONDecoder::decode_json("status", s, obj);
+  if (s == "init") {
+    state = StateInit;
+  } else if (s == "building-full-sync-maps") {
+    state = StateBuildingFullSyncMaps;
+  } else if (s == "sync") {
+    state = StateSync;
+  }
+  JSONDecoder::decode_json("num_shards", num_shards, obj);
+  JSONDecoder::decode_json("period", period, obj);
+  JSONDecoder::decode_json("realm_epoch", realm_epoch, obj);
+}
+
+void rgw_meta_sync_info::dump(Formatter *f) const
+{
+  string s;
+  switch ((SyncState)state) {
+  case StateInit:
+    s = "init";
+    break;
+  case StateBuildingFullSyncMaps:
+    s = "building-full-sync-maps";
+    break;
+  case StateSync:
+    s = "sync";
+    break;
+  default:
+    s = "unknown";
+    break;
+  }
+  encode_json("status", s, f);
+  encode_json("num_shards", num_shards, f);
+  encode_json("period", period, f);
+  encode_json("realm_epoch", realm_epoch, f);
+}
+
+
+void rgw_meta_sync_marker::decode_json(JSONObj *obj)
+{
+  int s;
+  JSONDecoder::decode_json("state", s, obj);
+  state = s;
+  JSONDecoder::decode_json("marker", marker, obj);
+  JSONDecoder::decode_json("next_step_marker", next_step_marker, obj);
+  JSONDecoder::decode_json("total_entries", total_entries, obj);
+  JSONDecoder::decode_json("pos", pos, obj);
+  utime_t ut;
+  JSONDecoder::decode_json("timestamp", ut, obj);
+  timestamp = ut.to_real_time();
+  JSONDecoder::decode_json("realm_epoch", realm_epoch, obj);
+}
+
+void rgw_meta_sync_marker::dump(Formatter *f) const
+{
+  encode_json("state", (int)state, f);
+  encode_json("marker", marker, f);
+  encode_json("next_step_marker", next_step_marker, f);
+  encode_json("total_entries", total_entries, f);
+  encode_json("pos", pos, f);
+  encode_json("timestamp", utime_t(timestamp), f);
+  encode_json("realm_epoch", realm_epoch, f);
+}
+
+void rgw_meta_sync_status::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("info", sync_info, obj);
+  JSONDecoder::decode_json("markers", sync_markers, obj);
+}
+
+void rgw_meta_sync_status::dump(Formatter *f) const {
+  encode_json("info", sync_info, f);
+  encode_json("markers", sync_markers, f);
+}
+
+void rgw_sync_error_info::dump(Formatter *f) const {
+  encode_json("source_zone", source_zone, f);
+  encode_json("error_code", error_code, f);
+  encode_json("message", message, f);
+}
+
index 90798fffe33252d0c9a8c5972cfa0781d933f507..b7a8adafcee730d554e6c211c6bbd5e9625f9a01 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "rgw_common.h"
 #include "rgw_sync_policy.h"
+#include "rgw_bucket.h"
 
 #define dout_subsys ceph_subsys_rgw
 
@@ -501,3 +502,282 @@ void rgw_sync_policy_info::get_potential_related_buckets(const rgw_bucket& bucke
     group.get_potential_related_buckets(bucket, sources, dests);
   }
 }
+
+void rgw_sync_directional_rule::dump(Formatter *f) const
+{
+  encode_json("source_zone", source_zone, f);
+  encode_json("dest_zone", dest_zone, f);
+}
+
+void rgw_sync_directional_rule::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("source_zone", source_zone, obj);
+  JSONDecoder::decode_json("dest_zone", dest_zone, obj);
+}
+
+void rgw_sync_symmetric_group::dump(Formatter *f) const
+{
+  encode_json("id", id, f);
+  encode_json("zones", zones, f);
+}
+
+void rgw_sync_symmetric_group::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("id", id, obj);
+  JSONDecoder::decode_json("zones", zones, obj);
+}
+
+void rgw_sync_bucket_entity::dump(Formatter *f) const
+{
+  encode_json("zone", zone, f);
+  encode_json("bucket", bucket_key(), f);
+}
+
+void rgw_sync_bucket_entity::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("zone", zone, obj);
+  string s;
+  if (JSONDecoder::decode_json("bucket", s, obj)) {
+    rgw_bucket b;
+    int ret = rgw_bucket_parse_bucket_key(nullptr, s, &b, nullptr);
+    if (ret >= 0) {
+      bucket = b;
+    } else {
+      bucket.reset();
+    }
+  }
+}
+
+void rgw_sync_pipe_filter_tag::dump(Formatter *f) const
+{
+  encode_json("key", key, f);
+  encode_json("value", value, f);
+}
+
+void rgw_sync_pipe_filter_tag::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("key", key, obj);
+  JSONDecoder::decode_json("value", value, obj);
+}
+
+void rgw_sync_pipe_filter::dump(Formatter *f) const
+{
+  encode_json("prefix", prefix, f);
+  encode_json("tags", tags, f);
+}
+
+void rgw_sync_pipe_filter::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("prefix", prefix, obj);
+  JSONDecoder::decode_json("tags", tags, obj);
+}
+
+void rgw_sync_pipe_acl_translation::dump(Formatter *f) const
+{
+  encode_json("owner", owner, f);
+}
+
+void rgw_sync_pipe_acl_translation::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("owner", owner, obj);
+}
+
+void rgw_sync_pipe_source_params::dump(Formatter *f) const
+{
+  encode_json("filter", filter, f);
+}
+
+void rgw_sync_pipe_source_params::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("filter", filter, obj);
+}
+
+void rgw_sync_pipe_dest_params::dump(Formatter *f) const
+{
+  encode_json("acl_translation", acl_translation, f);
+  encode_json("storage_class", storage_class, f);
+}
+
+void rgw_sync_pipe_dest_params::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("acl_translation", acl_translation, obj);
+  JSONDecoder::decode_json("storage_class", storage_class, obj);
+}
+
+void rgw_sync_pipe_params::dump(Formatter *f) const
+{
+  encode_json("source", source, f);
+  encode_json("dest", dest, f);
+  encode_json("priority", priority, f);
+  string s;
+  switch (mode) {
+    case MODE_SYSTEM:
+      s = "system";
+      break;
+    default:
+      s = "user";
+  }
+  encode_json("mode", s, f);
+  encode_json("user", user, f);
+}
+
+void rgw_sync_pipe_params::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("source", source, obj);
+  JSONDecoder::decode_json("dest", dest, obj);
+  JSONDecoder::decode_json("priority", priority, obj);
+  string s;
+  JSONDecoder::decode_json("mode", s, obj);
+  if (s == "system") {
+    mode = MODE_SYSTEM;
+  } else {
+    mode = MODE_USER;
+  }
+  JSONDecoder::decode_json("user", user, obj);
+}
+
+void rgw_sync_bucket_entities::dump(Formatter *f) const
+{
+  encode_json("bucket", rgw_sync_bucket_entities::bucket_key(bucket), f);
+  if (zones) {
+    encode_json("zones", zones, f);
+  } else if (all_zones) {
+    set<string> z = { "*" };
+    encode_json("zones", z, f);
+  }
+}
+
+void rgw_sync_bucket_entities::decode_json(JSONObj *obj)
+{
+  string s;
+  JSONDecoder::decode_json("bucket", s, obj);
+  if (s == "*") {
+    bucket.reset();
+  } else {
+    rgw_bucket b;
+    int ret = rgw_bucket_parse_bucket_key(nullptr, s, &b, nullptr);
+    if (ret < 0) {
+      bucket.reset();
+    } else {
+      if (b.tenant == "*") {
+        b.tenant.clear();
+      }
+      if (b.name == "*") {
+        b.name.clear();
+      }
+      if (b.bucket_id == "*") {
+        b.bucket_id.clear();
+      }
+      bucket = b;
+    }
+  }
+  JSONDecoder::decode_json("zones", zones, obj);
+  if (zones && zones->size() == 1) {
+    auto iter = zones->begin();
+    if (*iter == "*") {
+      zones.reset();
+      all_zones = true;
+    }
+  }
+}
+
+void rgw_sync_bucket_pipe::dump(Formatter *f) const
+{
+  encode_json("id", id, f);
+  encode_json("source", source, f);
+  encode_json("dest", dest, f);
+  encode_json("params", params, f);
+}
+
+void rgw_sync_bucket_pipe::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("id", id, obj);
+  JSONDecoder::decode_json("source", source, obj);
+  JSONDecoder::decode_json("dest", dest, obj);
+  JSONDecoder::decode_json("params", params, obj);
+}
+
+void rgw_sync_bucket_pipes::dump(Formatter *f) const
+{
+  encode_json("id", id, f);
+  encode_json("source", source, f);
+  encode_json("dest", dest, f);
+  encode_json("params", params, f);
+}
+
+void rgw_sync_bucket_pipes::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("id", id, obj);
+  JSONDecoder::decode_json("source", source, obj);
+  JSONDecoder::decode_json("dest", dest, obj);
+  JSONDecoder::decode_json("params", params, obj);
+}
+
+void rgw_sync_data_flow_group::dump(Formatter *f) const
+{
+  if (!symmetrical.empty()) {
+    encode_json("symmetrical", symmetrical, f);
+  }
+
+  if (!directional.empty()) {
+    encode_json("directional", directional, f);
+  }
+}
+
+void rgw_sync_data_flow_group::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("symmetrical", symmetrical, obj);
+  JSONDecoder::decode_json("directional", directional, obj);
+}
+
+void rgw_sync_policy_group::dump(Formatter *f) const
+{
+  encode_json("id", id, f);
+  encode_json("data_flow", data_flow, f);
+  encode_json("pipes", pipes, f);
+  string s;
+  switch (status) {
+    case  rgw_sync_policy_group::Status::FORBIDDEN:
+      s = "forbidden";
+      break;
+    case  rgw_sync_policy_group::Status::ALLOWED:
+      s = "allowed";
+      break;
+    case  rgw_sync_policy_group::Status::ENABLED:
+      s = "enabled";
+      break;
+    default:
+      s = "unknown";
+  }
+  encode_json("status", s, f);
+}
+
+void rgw_sync_policy_group::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("id", id, obj);
+  JSONDecoder::decode_json("data_flow", data_flow, obj);
+  JSONDecoder::decode_json("pipes", pipes, obj);
+  string s;
+  JSONDecoder::decode_json("status", s, obj);
+  set_status(s);
+}
+
+void rgw_sync_policy_info::dump(Formatter *f) const
+{
+  Formatter::ArraySection section(*f, "groups");
+  for (auto& group : groups ) {
+    encode_json("group", group.second, f);
+  }
+}
+
+void rgw_sync_policy_info::decode_json(JSONObj *obj)
+{
+  vector<rgw_sync_policy_group> groups_vec;
+
+  JSONDecoder::decode_json("groups", groups_vec, obj);
+
+  for (auto& group : groups_vec) {
+    groups.emplace(std::make_pair(group.id, std::move(group)));
+  }
+}
+
index 6befd82db371c9bcc1c1f47838a17a4b3d1780fb..2d6b992c34e9423b69278607ab2d1fc16b28307a 100644 (file)
@@ -52,3 +52,13 @@ int RGWObjTags::set_from_string(const string& input){
   }
   return ret;
 }
+
+void RGWObjTags::dump(Formatter *f) const
+{
+  f->open_object_section("tagset");
+  for (auto& tag: tag_map){
+    f->dump_string(tag.first.c_str(), tag.second);
+  }
+  f->close_section();
+}
+
index b53b048e3f8a8aba8e98aadbece1c36af12cb34f..e475a16e50d7dca7569b5c27f950d36f29372200 100644 (file)
@@ -152,64 +152,6 @@ static bool char_is_unreserved_url(char c)
   }
 }
 
-struct rgw_flags_desc {
-  uint32_t mask;
-  const char *str;
-};
-
-static struct rgw_flags_desc rgw_perms[] = {
- { RGW_PERM_FULL_CONTROL, "full-control" },
- { RGW_PERM_READ | RGW_PERM_WRITE, "read-write" },
- { RGW_PERM_READ, "read" },
- { RGW_PERM_WRITE, "write" },
- { RGW_PERM_READ_ACP, "read-acp" },
- { RGW_PERM_WRITE_ACP, "write-acp" },
- { 0, NULL }
-};
-
-void rgw_perm_to_str(uint32_t mask, char *buf, int len)
-{
-  const char *sep = "";
-  int pos = 0;
-  if (!mask) {
-    snprintf(buf, len, "<none>");
-    return;
-  }
-  while (mask) {
-    uint32_t orig_mask = mask;
-    for (int i = 0; rgw_perms[i].mask; i++) {
-      struct rgw_flags_desc *desc = &rgw_perms[i];
-      if ((mask & desc->mask) == desc->mask) {
-        pos += snprintf(buf + pos, len - pos, "%s%s", sep, desc->str);
-        if (pos == len)
-          return;
-        sep = ", ";
-        mask &= ~desc->mask;
-        if (!mask)
-          return;
-      }
-    }
-    if (mask == orig_mask) // no change
-      break;
-  }
-}
-
-uint32_t rgw_str_to_perm(const char *str)
-{
-  if (strcasecmp(str, "") == 0)
-    return RGW_PERM_NONE;
-  else if (strcasecmp(str, "read") == 0)
-    return RGW_PERM_READ;
-  else if (strcasecmp(str, "write") == 0)
-    return RGW_PERM_WRITE;
-  else if (strcasecmp(str, "readwrite") == 0)
-    return RGW_PERM_READ | RGW_PERM_WRITE;
-  else if (strcasecmp(str, "full") == 0)
-    return RGW_PERM_FULL_CONTROL;
-
-  return RGW_PERM_INVALID;
-}
-
 int rgw_validate_tenant_name(const string& t)
 {
   struct tench {
@@ -2983,3 +2925,8 @@ RGWMetadataHandler *RGWUserMetaHandlerAllocator::alloc(RGWSI_User *user_svc) {
   return new RGWUserMetadataHandler(user_svc);
 }
 
+void rgw_user::dump(Formatter *f) const
+{
+  ::encode_json("user", *this, f);
+}
+
index 8710228570645cdf75166808f281a335b13e82bd..0b68fc1709fecb1385ca427280a07015cb441266 100644 (file)
@@ -15,7 +15,9 @@
  */
 
 #include "common/debug.h"
+
 #include "common/ceph_json.h"
+#include "common/Formatter.h"
 
 #include "acconfig.h"
 
@@ -24,6 +26,8 @@
 #include <list>
 #include "include/types.h"
 #include "rgw_website.h"
+#include "rgw_common.h"
+#include "rgw_xml.h"
 
 using namespace std;
 
@@ -127,3 +131,211 @@ bool RGWBucketWebsiteConf::get_effective_key(const string& key, string *effectiv
 
   return true;
 }
+
+void RGWRedirectInfo::dump(Formatter *f) const
+{
+  encode_json("protocol", protocol, f);
+  encode_json("hostname", hostname, f);
+  encode_json("http_redirect_code", (int)http_redirect_code, f);
+}
+
+void RGWRedirectInfo::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("protocol", protocol, obj);
+  JSONDecoder::decode_json("hostname", hostname, obj);
+  int code;
+  JSONDecoder::decode_json("http_redirect_code", code, obj);
+  http_redirect_code = code;
+}
+
+void RGWBWRedirectInfo::dump(Formatter *f) const
+{
+  encode_json("redirect", redirect, f);
+  encode_json("replace_key_prefix_with", replace_key_prefix_with, f);
+  encode_json("replace_key_with", replace_key_with, f);
+}
+
+void RGWBWRedirectInfo::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("redirect", redirect, obj);
+  JSONDecoder::decode_json("replace_key_prefix_with", replace_key_prefix_with, obj);
+  JSONDecoder::decode_json("replace_key_with", replace_key_with, obj);
+}
+
+void RGWBWRoutingRuleCondition::dump(Formatter *f) const
+{
+  encode_json("key_prefix_equals", key_prefix_equals, f);
+  encode_json("http_error_code_returned_equals", (int)http_error_code_returned_equals, f);
+}
+
+void RGWBWRoutingRuleCondition::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("key_prefix_equals", key_prefix_equals, obj);
+  int code;
+  JSONDecoder::decode_json("http_error_code_returned_equals", code, obj);
+  http_error_code_returned_equals = code;
+}
+
+void RGWBWRoutingRule::dump(Formatter *f) const
+{
+  encode_json("condition", condition, f);
+  encode_json("redirect_info", redirect_info, f);
+}
+
+void RGWBWRoutingRule::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("condition", condition, obj);
+  JSONDecoder::decode_json("redirect_info", redirect_info, obj);
+}
+
+void RGWBWRoutingRules::dump(Formatter *f) const
+{
+  encode_json("rules", rules, f);
+}
+
+void RGWBWRoutingRules::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("rules", rules, obj);
+}
+
+void RGWBucketWebsiteConf::dump(Formatter *f) const
+{
+  if (!redirect_all.hostname.empty()) {
+    encode_json("redirect_all", redirect_all, f);
+  } else {
+    encode_json("index_doc_suffix", index_doc_suffix, f);
+    encode_json("error_doc", error_doc, f);
+    encode_json("routing_rules", routing_rules, f);
+  }
+}
+
+void RGWBucketWebsiteConf::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("redirect_all", redirect_all, obj);
+  JSONDecoder::decode_json("index_doc_suffix", index_doc_suffix, obj);
+  JSONDecoder::decode_json("error_doc", error_doc, obj);
+  JSONDecoder::decode_json("routing_rules", routing_rules, obj);
+}
+
+void RGWBWRedirectInfo::dump_xml(Formatter *f) const
+{
+  if (!redirect.protocol.empty()) {
+    encode_xml("Protocol", redirect.protocol, f);
+  }
+  if (!redirect.hostname.empty()) {
+    encode_xml("HostName", redirect.hostname, f);
+  }
+  if (redirect.http_redirect_code > 0) {
+    encode_xml("HttpRedirectCode", (int)redirect.http_redirect_code, f);
+  }
+  if (!replace_key_prefix_with.empty()) {
+    encode_xml("ReplaceKeyPrefixWith", replace_key_prefix_with, f);
+  }
+  if (!replace_key_with.empty()) {
+    encode_xml("ReplaceKeyWith", replace_key_with, f);
+  }
+}
+
+#define WEBSITE_HTTP_REDIRECT_CODE_MIN      300
+#define WEBSITE_HTTP_REDIRECT_CODE_MAX      400
+void RGWBWRedirectInfo::decode_xml(XMLObj *obj) {
+  RGWXMLDecoder::decode_xml("Protocol", redirect.protocol, obj);
+  RGWXMLDecoder::decode_xml("HostName", redirect.hostname, obj);
+  int code = 0;
+  bool has_http_redirect_code = RGWXMLDecoder::decode_xml("HttpRedirectCode", code, obj);
+  if (has_http_redirect_code &&
+      !(code > WEBSITE_HTTP_REDIRECT_CODE_MIN &&
+        code < WEBSITE_HTTP_REDIRECT_CODE_MAX)) {
+    throw RGWXMLDecoder::err("The provided HTTP redirect code is not valid. Valid codes are 3XX except 300.");
+  }
+  redirect.http_redirect_code = code;
+  bool has_replace_key_prefix_with = RGWXMLDecoder::decode_xml("ReplaceKeyPrefixWith", replace_key_prefix_with, obj);
+  bool has_replace_key_with = RGWXMLDecoder::decode_xml("ReplaceKeyWith", replace_key_with, obj);
+  if (has_replace_key_prefix_with && has_replace_key_with) {
+    throw RGWXMLDecoder::err("You can only define ReplaceKeyPrefix or ReplaceKey but not both.");
+  }
+}
+
+void RGWBWRoutingRuleCondition::dump_xml(Formatter *f) const
+{
+  if (!key_prefix_equals.empty()) {
+    encode_xml("KeyPrefixEquals", key_prefix_equals, f);
+  }
+  if (http_error_code_returned_equals > 0) {
+    encode_xml("HttpErrorCodeReturnedEquals", (int)http_error_code_returned_equals, f);
+  }
+}
+
+#define WEBSITE_HTTP_ERROR_CODE_RETURNED_EQUALS_MIN      400
+#define WEBSITE_HTTP_ERROR_CODE_RETURNED_EQUALS_MAX      600
+void RGWBWRoutingRuleCondition::decode_xml(XMLObj *obj) {
+  RGWXMLDecoder::decode_xml("KeyPrefixEquals", key_prefix_equals, obj);
+  int code = 0;
+  bool has_http_error_code_returned_equals = RGWXMLDecoder::decode_xml("HttpErrorCodeReturnedEquals", code, obj);
+  if (has_http_error_code_returned_equals &&
+      !(code >= WEBSITE_HTTP_ERROR_CODE_RETURNED_EQUALS_MIN &&
+        code < WEBSITE_HTTP_ERROR_CODE_RETURNED_EQUALS_MAX)) {
+    throw RGWXMLDecoder::err("The provided HTTP redirect code is not valid. Valid codes are 4XX or 5XX.");
+  }
+  http_error_code_returned_equals = code;
+}
+
+void RGWBWRoutingRule::dump_xml(Formatter *f) const
+{
+  encode_xml("Condition", condition, f);
+  encode_xml("Redirect", redirect_info, f);
+}
+
+void RGWBWRoutingRule::decode_xml(XMLObj *obj) {
+  RGWXMLDecoder::decode_xml("Condition", condition, obj);
+  RGWXMLDecoder::decode_xml("Redirect", redirect_info, obj);
+}
+
+static void encode_xml(const char *name, const std::list<RGWBWRoutingRule>& l, ceph::Formatter *f)
+{
+  do_encode_xml("RoutingRules", l, "RoutingRule", f);
+}
+
+void RGWBucketWebsiteConf::dump_xml(Formatter *f) const
+{
+  if (!redirect_all.hostname.empty()) {
+    f->open_object_section("RedirectAllRequestsTo");
+    encode_xml("HostName", redirect_all.hostname, f);
+    if (!redirect_all.protocol.empty()) {
+      encode_xml("Protocol", redirect_all.protocol, f);
+    }
+    f->close_section();
+  }
+  if (!index_doc_suffix.empty()) {
+    f->open_object_section("IndexDocument");
+    encode_xml("Suffix", index_doc_suffix, f);
+    f->close_section();
+  }
+  if (!error_doc.empty()) {
+    f->open_object_section("ErrorDocument");
+    encode_xml("Key", error_doc, f);
+    f->close_section();
+  }
+  if (!routing_rules.rules.empty()) {
+    encode_xml("RoutingRules", routing_rules.rules, f);
+  }
+}
+
+void decode_xml_obj(list<RGWBWRoutingRule>& l, XMLObj *obj)
+{
+  do_decode_xml_obj(l, "RoutingRule", obj);
+}
+
+void RGWBucketWebsiteConf::decode_xml(XMLObj *obj) {
+  XMLObj *o = obj->find_first("RedirectAllRequestsTo");
+  if (o) {
+    is_redirect_all = true;
+    RGWXMLDecoder::decode_xml("HostName", redirect_all.hostname, o, true);
+    RGWXMLDecoder::decode_xml("Protocol", redirect_all.protocol, o);
+  } else {
+    o = obj->find_first("IndexDocument");
+    if (o) {
+      is_set_index_doc = true;
+      RGWXMLDecoder::decode_xml("Suffix", index_doc_suffix, o);
+    }
+    o = obj->find_first("ErrorDocument");
+    if (o) {
+      RGWXMLDecoder::decode_xml("Key", error_doc, o);
+    }
+    RGWXMLDecoder::decode_xml("RoutingRules", routing_rules.rules, obj);
+  }
+}
index c12d15f4bc5a3cb8e704eab69ccacb49cad03923..554e953d72545fb1e9a2b2d552018ce407268a51 100644 (file)
 
 using namespace std;
 
-void RGWBWRedirectInfo::dump_xml(Formatter *f) const
-{
-  if (!redirect.protocol.empty()) {
-    encode_xml("Protocol", redirect.protocol, f);
-  }
-  if (!redirect.hostname.empty()) {
-    encode_xml("HostName", redirect.hostname, f);
-  }
-  if (redirect.http_redirect_code > 0) {
-    encode_xml("HttpRedirectCode", (int)redirect.http_redirect_code, f);
-  }
-  if (!replace_key_prefix_with.empty()) {
-    encode_xml("ReplaceKeyPrefixWith", replace_key_prefix_with, f);
-  }
-  if (!replace_key_with.empty()) {
-    encode_xml("ReplaceKeyWith", replace_key_with, f);
-  }
-}
-
-#define WEBSITE_HTTP_REDIRECT_CODE_MIN      300
-#define WEBSITE_HTTP_REDIRECT_CODE_MAX      400
-void RGWBWRedirectInfo::decode_xml(XMLObj *obj) {
-  RGWXMLDecoder::decode_xml("Protocol", redirect.protocol, obj);
-  RGWXMLDecoder::decode_xml("HostName", redirect.hostname, obj);
-  int code = 0;
-  bool has_http_redirect_code = RGWXMLDecoder::decode_xml("HttpRedirectCode", code, obj);
-  if (has_http_redirect_code &&
-      !(code > WEBSITE_HTTP_REDIRECT_CODE_MIN &&
-        code < WEBSITE_HTTP_REDIRECT_CODE_MAX)) {
-    throw RGWXMLDecoder::err("The provided HTTP redirect code is not valid. Valid codes are 3XX except 300.");
-  }
-  redirect.http_redirect_code = code;
-  bool has_replace_key_prefix_with = RGWXMLDecoder::decode_xml("ReplaceKeyPrefixWith", replace_key_prefix_with, obj);
-  bool has_replace_key_with = RGWXMLDecoder::decode_xml("ReplaceKeyWith", replace_key_with, obj);
-  if (has_replace_key_prefix_with && has_replace_key_with) {
-    throw RGWXMLDecoder::err("You can only define ReplaceKeyPrefix or ReplaceKey but not both.");
-  }
-}
-
-void RGWBWRoutingRuleCondition::dump_xml(Formatter *f) const
-{
-  if (!key_prefix_equals.empty()) {
-    encode_xml("KeyPrefixEquals", key_prefix_equals, f);
-  }
-  if (http_error_code_returned_equals > 0) {
-    encode_xml("HttpErrorCodeReturnedEquals", (int)http_error_code_returned_equals, f);
-  }
-}
-
-#define WEBSITE_HTTP_ERROR_CODE_RETURNED_EQUALS_MIN      400
-#define WEBSITE_HTTP_ERROR_CODE_RETURNED_EQUALS_MAX      600
-void RGWBWRoutingRuleCondition::decode_xml(XMLObj *obj) {
-  RGWXMLDecoder::decode_xml("KeyPrefixEquals", key_prefix_equals, obj);
-  int code = 0;
-  bool has_http_error_code_returned_equals = RGWXMLDecoder::decode_xml("HttpErrorCodeReturnedEquals", code, obj);
-  if (has_http_error_code_returned_equals &&
-      !(code >= WEBSITE_HTTP_ERROR_CODE_RETURNED_EQUALS_MIN &&
-        code < WEBSITE_HTTP_ERROR_CODE_RETURNED_EQUALS_MAX)) {
-    throw RGWXMLDecoder::err("The provided HTTP redirect code is not valid. Valid codes are 4XX or 5XX.");
-  }
-  http_error_code_returned_equals = code;
-}
-
-void RGWBWRoutingRule::dump_xml(Formatter *f) const
-{
-  encode_xml("Condition", condition, f);
-  encode_xml("Redirect", redirect_info, f);
-}
-
-void RGWBWRoutingRule::decode_xml(XMLObj *obj) {
-  RGWXMLDecoder::decode_xml("Condition", condition, obj);
-  RGWXMLDecoder::decode_xml("Redirect", redirect_info, obj);
-}
-
-static void encode_xml(const char *name, const std::list<RGWBWRoutingRule>& l, ceph::Formatter *f)
-{
-  do_encode_xml("RoutingRules", l, "RoutingRule", f);
-}
-
-void RGWBucketWebsiteConf::dump_xml(Formatter *f) const
-{
-  if (!redirect_all.hostname.empty()) {
-    f->open_object_section("RedirectAllRequestsTo");
-    encode_xml("HostName", redirect_all.hostname, f);
-    if (!redirect_all.protocol.empty()) {
-      encode_xml("Protocol", redirect_all.protocol, f);
-    }
-    f->close_section();
-  }
-  if (!index_doc_suffix.empty()) {
-    f->open_object_section("IndexDocument");
-    encode_xml("Suffix", index_doc_suffix, f);
-    f->close_section();
-  }
-  if (!error_doc.empty()) {
-    f->open_object_section("ErrorDocument");
-    encode_xml("Key", error_doc, f);
-    f->close_section();
-  }
-  if (!routing_rules.rules.empty()) {
-    encode_xml("RoutingRules", routing_rules.rules, f);
-  }
-}
-
-void decode_xml_obj(list<RGWBWRoutingRule>& l, XMLObj *obj)
-{
-  do_decode_xml_obj(l, "RoutingRule", obj);
-}
-
-void RGWBucketWebsiteConf::decode_xml(XMLObj *obj) {
-  XMLObj *o = obj->find_first("RedirectAllRequestsTo");
-  if (o) {
-    is_redirect_all = true;
-    RGWXMLDecoder::decode_xml("HostName", redirect_all.hostname, o, true);
-    RGWXMLDecoder::decode_xml("Protocol", redirect_all.protocol, o);
-  } else {
-    o = obj->find_first("IndexDocument");
-    if (o) {
-      is_set_index_doc = true;
-      RGWXMLDecoder::decode_xml("Suffix", index_doc_suffix, o);
-    }
-    o = obj->find_first("ErrorDocument");
-    if (o) {
-      RGWXMLDecoder::decode_xml("Key", error_doc, o);
-    }
-    RGWXMLDecoder::decode_xml("RoutingRules", routing_rules.rules, obj);
-  }
-}
-
index a10f2476fadce246f3e5f5a79f990ab9b2e1f62d..e5ea2d625f8e231dd594563c2dbf5d76e30d21a5 100644 (file)
 #include "services/svc_zone.h"
 #include "services/svc_sys_obj.h"
 
+#include "common/ceph_json.h"
+#include "common/Formatter.h"
+
+#define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_rgw
 
 namespace rgw_zone_defaults {
@@ -48,6 +52,15 @@ RGWMetaSyncStatusManager::~RGWMetaSyncStatusManager(){}
 
 #define FIRST_EPOCH 1
 
+struct RGWAccessKey;
+
+void encode_json_plain(const char *name, const RGWAccessKey& val, Formatter *f)
+{
+  f->open_object_section(name);
+  val.dump_plain(f);
+  f->close_section();
+}
+
 void RGWDefaultZoneGroupInfo::dump(Formatter *f) const {
   encode_json("default_zonegroup", default_zonegroup, f);
 }
@@ -406,6 +419,14 @@ int RGWSystemMetaObj::init(const DoutPrefixProvider *dpp, CephContext *_cct, RGW
   return read_info(dpp, id, y, old_format);
 }
 
+void RGWDefaultSystemMetaObjInfo::dump(Formatter *f) const {
+  encode_json("default_id", default_id, f);
+}
+
+void RGWDefaultSystemMetaObjInfo::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("default_id", default_id, obj);
+}
+
 int RGWSystemMetaObj::read_default(const DoutPrefixProvider *dpp, 
                                    RGWDefaultSystemMetaObjInfo& default_info,
                                   const string& oid, optional_yield y)
@@ -1612,6 +1633,29 @@ int RGWZoneParams::create_default(const DoutPrefixProvider *dpp, optional_yield
   return r;
 }
 
+void RGWZoneParams::dump(Formatter *f) const
+{
+  RGWSystemMetaObj::dump(f);
+  encode_json("domain_root", domain_root, f);
+  encode_json("control_pool", control_pool, f);
+  encode_json("gc_pool", gc_pool, f);
+  encode_json("lc_pool", lc_pool, f);
+  encode_json("log_pool", log_pool, f);
+  encode_json("intent_log_pool", intent_log_pool, f);
+  encode_json("usage_log_pool", usage_log_pool, f);
+  encode_json("roles_pool", roles_pool, f);
+  encode_json("reshard_pool", reshard_pool, f);
+  encode_json("user_keys_pool", user_keys_pool, f);
+  encode_json("user_email_pool", user_email_pool, f);
+  encode_json("user_swift_pool", user_swift_pool, f);
+  encode_json("user_uid_pool", user_uid_pool, f);
+  encode_json("otp_pool", otp_pool, f);
+  encode_json_plain("system_key", system_key, f);
+  encode_json("placement_pools", placement_pools, f);
+  encode_json("tier_config", tier_config, f);
+  encode_json("realm_id", realm_id, f);
+  encode_json("notif_pool", notif_pool, f);
+}
 
 namespace {
 int get_zones_pool_set(const DoutPrefixProvider *dpp, 
@@ -2115,6 +2159,41 @@ int RGWZoneGroupPlacementTier::update_params(const JSONFormattable& config)
   return r;
 }
 
+void RGWZoneGroupPlacementTier::dump(Formatter *f) const
+{
+  encode_json("tier_type", tier_type, f);
+  encode_json("storage_class", storage_class, f);
+  encode_json("retain_head_object", retain_head_object, f);
+
+  if (tier_type == "cloud-s3") {
+    encode_json("s3", t.s3, f);
+  }
+}
+
+void RGWZoneGroupPlacementTier::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("tier_type", tier_type, obj);
+  JSONDecoder::decode_json("storage_class", storage_class, obj);
+  JSONDecoder::decode_json("retain_head_object", retain_head_object, obj);
+
+  if (tier_type == "cloud-s3") {
+    JSONDecoder::decode_json("s3", t.s3, obj);
+  }
+}
+
+int RGWZoneGroupPlacementTier::clear_params(const JSONFormattable& config)
+{
+  if (config.exists("retain_head_object")) {
+    retain_head_object = false;
+  }
+
+  if (tier_type == "cloud-s3") {
+    t.s3.clear_params(config);
+  }
+
+  return 0;
+}
+
 int RGWZoneGroupPlacementTierS3::update_params(const JSONFormattable& config)
 {
   int r = -1;
@@ -2180,17 +2259,40 @@ int RGWZoneGroupPlacementTierS3::update_params(const JSONFormattable& config)
   }
   return 0;
 }
-int RGWZoneGroupPlacementTier::clear_params(const JSONFormattable& config)
+
+void RGWZoneGroupPlacementTierS3::dump(Formatter *f) const
 {
-  if (config.exists("retain_head_object")) {
-    retain_head_object = false;
-  }
+  encode_json("endpoint", endpoint, f);
+  encode_json("access_key", key.id, f);
+  encode_json("secret", key.key, f);
+  encode_json("region", region, f);
+  string s = (host_style == PathStyle ? "path" : "virtual");
+  encode_json("host_style", s, f);
+  encode_json("target_storage_class", target_storage_class, f);
+  encode_json("target_path", target_path, f);
+  encode_json("acl_mappings", acl_mappings, f);
+  encode_json("multipart_sync_threshold", multipart_sync_threshold, f);
+  encode_json("multipart_min_part_size", multipart_min_part_size, f);
+}
 
-  if (tier_type == "cloud-s3") {
-    t.s3.clear_params(config);
+void RGWZoneGroupPlacementTierS3::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("endpoint", endpoint, obj);
+  JSONDecoder::decode_json("access_key", key.id, obj);
+  JSONDecoder::decode_json("secret", key.key, obj);
+  JSONDecoder::decode_json("region", region, obj);
+  string s;
+  JSONDecoder::decode_json("host_style", s, obj);
+  if (s != "virtual") {
+    host_style = PathStyle;
+  } else {
+    host_style = VirtualStyle;
   }
-
-  return 0;
+  JSONDecoder::decode_json("target_storage_class", target_storage_class, obj);
+  JSONDecoder::decode_json("target_path", target_path, obj);
+  JSONDecoder::decode_json("acl_mappings", acl_mappings, obj);
+  JSONDecoder::decode_json("multipart_sync_threshold", multipart_sync_threshold, obj);
+  JSONDecoder::decode_json("multipart_min_part_size", multipart_min_part_size, obj);
 }
 
 int RGWZoneGroupPlacementTierS3::clear_params(const JSONFormattable& config)
@@ -2240,3 +2342,465 @@ int RGWZoneGroupPlacementTierS3::clear_params(const JSONFormattable& config)
   return 0;
 }
 
+void RGWZoneGroupPlacementTarget::dump(Formatter *f) const
+{
+  encode_json("name", name, f);
+  encode_json("tags", tags, f);
+  encode_json("storage_classes", storage_classes, f);
+  if (!tier_targets.empty()) {
+    encode_json("tier_targets", tier_targets, f);
+  }
+}
+
+void RGWZoneGroupPlacementTarget::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("name", name, obj);
+  JSONDecoder::decode_json("tags", tags, obj);
+  JSONDecoder::decode_json("storage_classes", storage_classes, obj);
+  if (storage_classes.empty()) {
+    storage_classes.insert(RGW_STORAGE_CLASS_STANDARD);
+  }
+  if (!tier_targets.empty()) {
+    JSONDecoder::decode_json("tier_targets", tier_targets, obj);
+  }
+}
+
+void RGWZoneGroup::dump(Formatter *f) const
+{
+  RGWSystemMetaObj::dump(f);
+  encode_json("api_name", api_name, f);
+  encode_json("is_master", is_master, f);
+  encode_json("endpoints", endpoints, f);
+  encode_json("hostnames", hostnames, f);
+  encode_json("hostnames_s3website", hostnames_s3website, f);
+  encode_json("master_zone", master_zone, f);
+  encode_json_map("zones", zones, f); /* more friendly representation */
+  encode_json_map("placement_targets", placement_targets, f); /* more friendly representation */
+  encode_json("default_placement", default_placement, f);
+  encode_json("realm_id", realm_id, f);
+  encode_json("sync_policy", sync_policy, f);
+}
+
+static void decode_zones(map<rgw_zone_id, RGWZone>& zones, JSONObj *o)
+{
+  RGWZone z;
+  z.decode_json(o);
+  zones[z.id] = z;
+}
+
+static void decode_placement_targets(map<string, RGWZoneGroupPlacementTarget>& targets, JSONObj *o)
+{
+  RGWZoneGroupPlacementTarget t;
+  t.decode_json(o);
+  targets[t.name] = t;
+}
+
+static void decode_zonegroups(map<string, RGWZoneGroup>& zonegroups, JSONObj *o)
+{
+  RGWZoneGroup zg;
+  zg.decode_json(o);
+  zonegroups[zg.get_id()] = zg;
+}
+
+void RGWZoneGroup::decode_json(JSONObj *obj)
+{
+  RGWSystemMetaObj::decode_json(obj);
+  if (id.empty()) {
+    derr << "old format " << dendl;
+    JSONDecoder::decode_json("name", name, obj);
+    id = name;
+  }
+  JSONDecoder::decode_json("api_name", api_name, obj);
+  JSONDecoder::decode_json("is_master", is_master, obj);
+  JSONDecoder::decode_json("endpoints", endpoints, obj);
+  JSONDecoder::decode_json("hostnames", hostnames, obj);
+  JSONDecoder::decode_json("hostnames_s3website", hostnames_s3website, obj);
+  JSONDecoder::decode_json("master_zone", master_zone, obj);
+  JSONDecoder::decode_json("zones", zones, decode_zones, obj);
+  JSONDecoder::decode_json("placement_targets", placement_targets, decode_placement_targets, obj);
+  JSONDecoder::decode_json("default_placement", default_placement.name, obj);
+  JSONDecoder::decode_json("default_storage_class", default_placement.storage_class, obj);
+  JSONDecoder::decode_json("realm_id", realm_id, obj);
+  JSONDecoder::decode_json("sync_policy", sync_policy, obj);
+}
+
+void rgw_meta_sync_info::generate_test_instances(list<rgw_meta_sync_info*>& o)
+{
+  auto info = new rgw_meta_sync_info;
+  info->state = rgw_meta_sync_info::StateBuildingFullSyncMaps;
+  info->period = "periodid";
+  info->realm_epoch = 5;
+  o.push_back(info);
+  o.push_back(new rgw_meta_sync_info);
+}
+
+void rgw_meta_sync_marker::generate_test_instances(list<rgw_meta_sync_marker*>& o)
+{
+  auto marker = new rgw_meta_sync_marker;
+  marker->state = rgw_meta_sync_marker::IncrementalSync;
+  marker->marker = "01234";
+  marker->realm_epoch = 5;
+  o.push_back(marker);
+  o.push_back(new rgw_meta_sync_marker);
+}
+
+void rgw_meta_sync_status::generate_test_instances(list<rgw_meta_sync_status*>& o)
+{
+  o.push_back(new rgw_meta_sync_status);
+}
+
+void RGWZoneParams::generate_test_instances(list<RGWZoneParams*> &o)
+{
+  o.push_back(new RGWZoneParams);
+  o.push_back(new RGWZoneParams);
+}
+
+void RGWPeriodLatestEpochInfo::generate_test_instances(list<RGWPeriodLatestEpochInfo*> &o)
+{
+  RGWPeriodLatestEpochInfo *z = new RGWPeriodLatestEpochInfo;
+  o.push_back(z);
+  o.push_back(new RGWPeriodLatestEpochInfo);
+}
+
+void RGWRealm::generate_test_instances(list<RGWRealm*> &o)
+{
+  RGWRealm *z = new RGWRealm;
+  o.push_back(z);
+  o.push_back(new RGWRealm);
+}
+
+void RGWRealm::dump(Formatter *f) const
+{
+  RGWSystemMetaObj::dump(f);
+  encode_json("current_period", current_period, f);
+  encode_json("epoch", epoch, f);
+}
+
+
+void RGWRealm::decode_json(JSONObj *obj)
+{
+  RGWSystemMetaObj::decode_json(obj);
+  JSONDecoder::decode_json("current_period", current_period, obj);
+  JSONDecoder::decode_json("epoch", epoch, obj);
+}
+
+void RGWZoneGroup::generate_test_instances(list<RGWZoneGroup*>& o)
+{
+  RGWZoneGroup *r = new RGWZoneGroup;
+  o.push_back(r);
+  o.push_back(new RGWZoneGroup);
+}
+
+void RGWZone::generate_test_instances(list<RGWZone*> &o)
+{
+  RGWZone *z = new RGWZone;
+  o.push_back(z);
+  o.push_back(new RGWZone);
+}
+
+void RGWPeriod::generate_test_instances(list<RGWPeriod*> &o)
+{
+  RGWPeriod *z = new RGWPeriod;
+  o.push_back(z);
+  o.push_back(new RGWPeriod);
+}
+
+void RGWPeriodLatestEpochInfo::dump(Formatter *f) const {
+  encode_json("latest_epoch", epoch, f);
+}
+
+void RGWPeriodLatestEpochInfo::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("latest_epoch", epoch, obj);
+}
+
+void RGWPeriod::dump(Formatter *f) const
+{
+  encode_json("id", id, f);
+  encode_json("epoch", epoch , f);
+  encode_json("predecessor_uuid", predecessor_uuid, f);
+  encode_json("sync_status", sync_status, f);
+  encode_json("period_map", period_map, f);
+  encode_json("master_zonegroup", master_zonegroup, f);
+  encode_json("master_zone", master_zone, f);
+  encode_json("period_config", period_config, f);
+  encode_json("realm_id", realm_id, f);
+  encode_json("realm_name", realm_name, f);
+  encode_json("realm_epoch", realm_epoch, f);
+}
+
+void RGWPeriod::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("id", id, obj);
+  JSONDecoder::decode_json("epoch", epoch, obj);
+  JSONDecoder::decode_json("predecessor_uuid", predecessor_uuid, obj);
+  JSONDecoder::decode_json("sync_status", sync_status, obj);
+  JSONDecoder::decode_json("period_map", period_map, obj);
+  JSONDecoder::decode_json("master_zonegroup", master_zonegroup, obj);
+  JSONDecoder::decode_json("master_zone", master_zone, obj);
+  JSONDecoder::decode_json("period_config", period_config, obj);
+  JSONDecoder::decode_json("realm_id", realm_id, obj);
+  JSONDecoder::decode_json("realm_name", realm_name, obj);
+  JSONDecoder::decode_json("realm_epoch", realm_epoch, obj);
+}
+
+void RGWNameToId::dump(Formatter *f) const {
+  encode_json("obj_id", obj_id, f);
+}
+
+void RGWNameToId::decode_json(JSONObj *obj) {
+  JSONDecoder::decode_json("obj_id", obj_id, obj);
+}
+
+void RGWSystemMetaObj::dump(Formatter *f) const
+{
+  encode_json("id", id , f);
+  encode_json("name", name , f);
+}
+
+void RGWSystemMetaObj::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("id", id, obj);
+  JSONDecoder::decode_json("name", name, obj);
+}
+
+void RGWZoneStorageClass::dump(Formatter *f) const
+{
+  if (data_pool) {
+    encode_json("data_pool", data_pool.get(), f);
+  }
+  if (compression_type) {
+    encode_json("compression_type", compression_type.get(), f);
+  }
+}
+
+void RGWZoneStorageClass::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("data_pool", data_pool, obj);
+  JSONDecoder::decode_json("compression_type", compression_type, obj);
+}
+
+void RGWZoneStorageClasses::dump(Formatter *f) const
+{
+  for (auto& i : m) {
+    encode_json(i.first.c_str(), i.second, f);
+  }
+}
+
+void RGWZoneStorageClasses::decode_json(JSONObj *obj)
+{
+  JSONFormattable f;
+  decode_json_obj(f, obj);
+
+  for (auto& field : f.object()) {
+    JSONObj *field_obj = obj->find_obj(field.first);
+    assert(field_obj);
+
+    decode_json_obj(m[field.first], field_obj);
+  }
+  standard_class = &m[RGW_STORAGE_CLASS_STANDARD];
+}
+
+void RGWZonePlacementInfo::dump(Formatter *f) const
+{
+  encode_json("index_pool", index_pool, f);
+  encode_json("storage_classes", storage_classes, f);
+  encode_json("data_extra_pool", data_extra_pool, f);
+  encode_json("index_type", (uint32_t)index_type, f);
+
+  /* no real need for backward compatibility of compression_type and data_pool in here,
+   * rather not clutter the output */
+}
+
+void RGWZonePlacementInfo::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("index_pool", index_pool, obj);
+  JSONDecoder::decode_json("storage_classes", storage_classes, obj);
+  JSONDecoder::decode_json("data_extra_pool", data_extra_pool, obj);
+  uint32_t it;
+  JSONDecoder::decode_json("index_type", it, obj);
+  index_type = (rgw::BucketIndexType)it;
+
+  /* backward compatibility, these are now defined in storage_classes */
+  string standard_compression_type;
+  string *pcompression = nullptr;
+  if (JSONDecoder::decode_json("compression", standard_compression_type, obj)) {
+    pcompression = &standard_compression_type;
+  }
+  rgw_pool standard_data_pool;
+  rgw_pool *ppool = nullptr;
+  if (JSONDecoder::decode_json("data_pool", standard_data_pool, obj)) {
+    ppool = &standard_data_pool;
+  }
+  if (ppool || pcompression) {
+    storage_classes.set_storage_class(RGW_STORAGE_CLASS_STANDARD, ppool, pcompression);
+  }
+}
+
+void RGWZoneParams::decode_json(JSONObj *obj)
+{
+  RGWSystemMetaObj::decode_json(obj);
+  JSONDecoder::decode_json("domain_root", domain_root, obj);
+  JSONDecoder::decode_json("control_pool", control_pool, obj);
+  JSONDecoder::decode_json("gc_pool", gc_pool, obj);
+  JSONDecoder::decode_json("lc_pool", lc_pool, obj);
+  JSONDecoder::decode_json("log_pool", log_pool, obj);
+  JSONDecoder::decode_json("intent_log_pool", intent_log_pool, obj);
+  JSONDecoder::decode_json("roles_pool", roles_pool, obj);
+  JSONDecoder::decode_json("reshard_pool", reshard_pool, obj);
+  JSONDecoder::decode_json("usage_log_pool", usage_log_pool, obj);
+  JSONDecoder::decode_json("user_keys_pool", user_keys_pool, obj);
+  JSONDecoder::decode_json("user_email_pool", user_email_pool, obj);
+  JSONDecoder::decode_json("user_swift_pool", user_swift_pool, obj);
+  JSONDecoder::decode_json("user_uid_pool", user_uid_pool, obj);
+  JSONDecoder::decode_json("otp_pool", otp_pool, obj);
+  JSONDecoder::decode_json("system_key", system_key, obj);
+  JSONDecoder::decode_json("placement_pools", placement_pools, obj);
+  JSONDecoder::decode_json("tier_config", tier_config, obj);
+  JSONDecoder::decode_json("realm_id", realm_id, obj);
+  JSONDecoder::decode_json("notif_pool", notif_pool, obj);
+
+}
+
+void RGWZone::dump(Formatter *f) const
+{
+  encode_json("id", id, f);
+  encode_json("name", name, f);
+  encode_json("endpoints", endpoints, f);
+  encode_json("log_meta", log_meta, f);
+  encode_json("log_data", log_data, f);
+  encode_json("bucket_index_max_shards", bucket_index_max_shards, f);
+  encode_json("read_only", read_only, f);
+  encode_json("tier_type", tier_type, f);
+  encode_json("sync_from_all", sync_from_all, f);
+  encode_json("sync_from", sync_from, f);
+  encode_json("redirect_zone", redirect_zone, f);
+}
+
+void RGWZone::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("id", id, obj);
+  JSONDecoder::decode_json("name", name, obj);
+  if (id.empty()) {
+    id = name;
+  }
+  JSONDecoder::decode_json("endpoints", endpoints, obj);
+  JSONDecoder::decode_json("log_meta", log_meta, obj);
+  JSONDecoder::decode_json("log_data", log_data, obj);
+  JSONDecoder::decode_json("bucket_index_max_shards", bucket_index_max_shards, obj);
+  JSONDecoder::decode_json("read_only", read_only, obj);
+  JSONDecoder::decode_json("tier_type", tier_type, obj);
+  JSONDecoder::decode_json("sync_from_all", sync_from_all, true, obj);
+  JSONDecoder::decode_json("sync_from", sync_from, obj);
+  JSONDecoder::decode_json("redirect_zone", redirect_zone, obj);
+}
+
+void RGWTierACLMapping::dump(Formatter *f) const
+{
+  string s;
+  switch (type) {
+    case ACL_TYPE_EMAIL_USER:
+      s = "email";
+      break;
+    case ACL_TYPE_GROUP:
+      s = "uri";
+      break;
+    default:
+      s = "id";
+      break;
+  }
+  encode_json("type", s, f);
+  encode_json("source_id", source_id, f);
+  encode_json("dest_id", dest_id, f);
+}
+
+void RGWTierACLMapping::decode_json(JSONObj *obj)
+{
+  string s;
+  JSONDecoder::decode_json("type", s, obj);
+  if (s == "email") {
+    type = ACL_TYPE_EMAIL_USER;
+  } else if (s == "uri") {
+    type = ACL_TYPE_GROUP;
+  } else {
+    type = ACL_TYPE_CANON_USER;
+  }
+
+  JSONDecoder::decode_json("source_id", source_id, obj);
+  JSONDecoder::decode_json("dest_id", dest_id, obj);
+}
+
+void RGWPeriodMap::dump(Formatter *f) const
+{
+  encode_json("id", id, f);
+  encode_json_map("zonegroups", zonegroups, f);
+  encode_json("short_zone_ids", short_zone_ids, f);
+}
+
+void RGWPeriodMap::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("id", id, obj);
+  JSONDecoder::decode_json("zonegroups", zonegroups, decode_zonegroups, obj);
+  /* backward compatability with region */
+  if (zonegroups.empty()) {
+    JSONDecoder::decode_json("regions", zonegroups, obj);
+  }
+  /* backward compatability with region */
+  if (master_zonegroup.empty()) {
+    JSONDecoder::decode_json("master_region", master_zonegroup, obj);
+  }
+  JSONDecoder::decode_json("short_zone_ids", short_zone_ids, obj);
+}
+
+void RGWPeriodConfig::dump(Formatter *f) const
+{
+  encode_json("bucket_quota", bucket_quota, f);
+  encode_json("user_quota", user_quota, f);
+}
+
+void RGWPeriodConfig::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
+  JSONDecoder::decode_json("user_quota", user_quota, obj);
+}
+
+void RGWRegionMap::dump(Formatter *f) const
+{
+  encode_json("regions", regions, f);
+  encode_json("master_region", master_region, f);
+  encode_json("bucket_quota", bucket_quota, f);
+  encode_json("user_quota", user_quota, f);
+}
+
+void RGWRegionMap::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("regions", regions, obj);
+  JSONDecoder::decode_json("master_region", master_region, obj);
+  JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
+  JSONDecoder::decode_json("user_quota", user_quota, obj);
+}
+
+void RGWZoneGroupMap::dump(Formatter *f) const
+{
+  encode_json("zonegroups", zonegroups, f);
+  encode_json("master_zonegroup", master_zonegroup, f);
+  encode_json("bucket_quota", bucket_quota, f);
+  encode_json("user_quota", user_quota, f);
+}
+
+void RGWZoneGroupMap::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("zonegroups", zonegroups, obj);
+  /* backward compatability with region */
+  if (zonegroups.empty()) {
+    JSONDecoder::decode_json("regions", zonegroups, obj);
+  }
+  JSONDecoder::decode_json("master_zonegroup", master_zonegroup, obj);
+  /* backward compatability with region */
+  if (master_zonegroup.empty()) {
+    JSONDecoder::decode_json("master_region", master_zonegroup, obj);
+  }
+
+  JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
+  JSONDecoder::decode_json("user_quota", user_quota, obj);
+}
+