1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
4 #include "rgw_common.h"
8 #include "rgw_acl_s3.h"
10 #include "rgw_bucket.h"
11 #include "rgw_datalog.h"
12 #include "rgw_keystone.h"
13 #include "rgw_basic_types.h"
15 #include "rgw_data_sync.h"
17 #include "rgw_orphan.h"
18 #include "rgw_bucket_sync.h"
19 #include "rgw_tools.h"
21 #include "common/ceph_json.h"
22 #include "common/Formatter.h"
24 #define dout_context g_ceph_context
25 #define dout_subsys ceph_subsys_rgw
27 void encode_json(const char *name
, const obj_version
& v
, Formatter
*f
)
29 f
->open_object_section(name
);
30 f
->dump_string("tag", v
.tag
);
31 f
->dump_unsigned("ver", v
.ver
);
35 void decode_json_obj(obj_version
& v
, JSONObj
*obj
)
37 JSONDecoder::decode_json("tag", v
.tag
, obj
);
38 JSONDecoder::decode_json("ver", v
.ver
, obj
);
41 void encode_json(const char *name
, const RGWUserCaps
& val
, Formatter
*f
)
47 void encode_json(const char *name
, const rgw_pool
& pool
, Formatter
*f
)
49 f
->dump_string(name
, pool
.to_str());
52 void decode_json_obj(rgw_pool
& pool
, JSONObj
*obj
)
55 decode_json_obj(s
, obj
);
59 void encode_json(const char *name
, const rgw_placement_rule
& r
, Formatter
*f
)
61 encode_json(name
, r
.to_str(), f
);
64 void decode_json_obj(rgw_placement_rule
& v
, JSONObj
*obj
)
67 decode_json_obj(s
, obj
);
71 void RGWOLHInfo::dump(Formatter
*f
) const
73 encode_json("target", target
, f
);
76 void RGWOLHPendingInfo::dump(Formatter
*f
) const
79 encode_json("time", ut
, f
);
82 void RGWObjManifestPart::dump(Formatter
*f
) const
84 f
->open_object_section("loc");
87 f
->dump_unsigned("loc_ofs", loc_ofs
);
88 f
->dump_unsigned("size", size
);
91 void RGWObjManifestRule::dump(Formatter
*f
) const
93 encode_json("start_part_num", start_part_num
, f
);
94 encode_json("start_ofs", start_ofs
, f
);
95 encode_json("part_size", part_size
, f
);
96 encode_json("stripe_max_size", stripe_max_size
, f
);
97 encode_json("override_prefix", override_prefix
, f
);
100 void rgw_bucket_placement::dump(Formatter
*f
) const
102 encode_json("bucket", bucket
, f
);
103 encode_json("placement_rule", placement_rule
, f
);
106 void rgw_obj_select::dump(Formatter
*f
) const
108 f
->dump_string("placement_rule", placement_rule
.to_str());
109 f
->dump_object("obj", obj
);
110 f
->dump_object("raw_obj", raw_obj
);
111 f
->dump_bool("is_raw", is_raw
);
114 void RGWObjManifest::obj_iterator::dump(Formatter
*f
) const
116 f
->dump_unsigned("part_ofs", part_ofs
);
117 f
->dump_unsigned("stripe_ofs", stripe_ofs
);
118 f
->dump_unsigned("ofs", ofs
);
119 f
->dump_unsigned("stripe_size", stripe_size
);
120 f
->dump_int("cur_part_id", cur_part_id
);
121 f
->dump_int("cur_stripe", cur_stripe
);
122 f
->dump_string("cur_override_prefix", cur_override_prefix
);
123 f
->dump_object("location", location
);
126 void RGWObjManifest::dump(Formatter
*f
) const
128 map
<uint64_t, RGWObjManifestPart
>::const_iterator iter
= objs
.begin();
129 f
->open_array_section("objs");
130 for (; iter
!= objs
.end(); ++iter
) {
131 f
->dump_unsigned("ofs", iter
->first
);
132 f
->open_object_section("part");
133 iter
->second
.dump(f
);
137 f
->dump_unsigned("obj_size", obj_size
);
138 ::encode_json("explicit_objs", explicit_objs
, f
);
139 ::encode_json("head_size", head_size
, f
);
140 ::encode_json("max_head_size", max_head_size
, f
);
141 ::encode_json("prefix", prefix
, f
);
142 ::encode_json("rules", rules
, f
);
143 ::encode_json("tail_instance", tail_instance
, f
);
144 ::encode_json("tail_placement", tail_placement
, f
);
146 // nullptr being passed into iterators since there
147 // is no cct and we aren't doing anything with these
148 // iterators that would write do the log
149 f
->dump_object("begin_iter", obj_begin(nullptr));
150 f
->dump_object("end_iter", obj_end(nullptr));
153 void rgw_log_entry::dump(Formatter
*f
) const
155 f
->dump_string("object_owner", object_owner
.to_str());
156 f
->dump_string("bucket_owner", bucket_owner
.to_str());
157 f
->dump_string("bucket", bucket
);
158 f
->dump_stream("time") << time
;
159 f
->dump_string("remote_addr", remote_addr
);
160 f
->dump_string("user", user
);
163 f
->dump_string("obj", s
.str());
164 f
->dump_string("op", op
);
165 f
->dump_string("uri", uri
);
166 f
->dump_string("http_status", http_status
);
167 f
->dump_string("error_code", error_code
);
168 f
->dump_unsigned("bytes_sent", bytes_sent
);
169 f
->dump_unsigned("bytes_received", bytes_received
);
170 f
->dump_unsigned("obj_size", obj_size
);
171 f
->dump_stream("total_time") << total_time
;
172 f
->dump_string("user_agent", user_agent
);
173 f
->dump_string("referrer", referrer
);
174 f
->dump_string("bucket_id", bucket_id
);
175 f
->dump_string("trans_id", trans_id
);
178 void ACLPermission::dump(Formatter
*f
) const
180 f
->dump_int("flags", flags
);
183 void ACLGranteeType::dump(Formatter
*f
) const
185 f
->dump_unsigned("type", type
);
188 void ACLGrant::dump(Formatter
*f
) const
190 f
->open_object_section("type");
194 f
->dump_string("id", id
.to_str());
195 f
->dump_string("email", email
);
197 f
->open_object_section("permission");
201 f
->dump_string("name", name
);
202 f
->dump_int("group", (int)group
);
203 f
->dump_string("url_spec", url_spec
);
206 void RGWAccessControlList::dump(Formatter
*f
) const
208 map
<string
, int>::const_iterator acl_user_iter
= acl_user_map
.begin();
209 f
->open_array_section("acl_user_map");
210 for (; acl_user_iter
!= acl_user_map
.end(); ++acl_user_iter
) {
211 f
->open_object_section("entry");
212 f
->dump_string("user", acl_user_iter
->first
);
213 f
->dump_int("acl", acl_user_iter
->second
);
218 map
<uint32_t, int>::const_iterator acl_group_iter
= acl_group_map
.begin();
219 f
->open_array_section("acl_group_map");
220 for (; acl_group_iter
!= acl_group_map
.end(); ++acl_group_iter
) {
221 f
->open_object_section("entry");
222 f
->dump_unsigned("group", acl_group_iter
->first
);
223 f
->dump_int("acl", acl_group_iter
->second
);
228 multimap
<string
, ACLGrant
>::const_iterator giter
= grant_map
.begin();
229 f
->open_array_section("grant_map");
230 for (; giter
!= grant_map
.end(); ++giter
) {
231 f
->open_object_section("entry");
232 f
->dump_string("id", giter
->first
);
233 f
->open_object_section("grant");
234 giter
->second
.dump(f
);
241 void ACLOwner::dump(Formatter
*f
) const
243 encode_json("id", id
.to_str(), f
);
244 encode_json("display_name", display_name
, f
);
247 void ACLOwner::decode_json(JSONObj
*obj
) {
249 JSONDecoder::decode_json("id", id_str
, obj
);
251 JSONDecoder::decode_json("display_name", display_name
, obj
);
254 void RGWAccessControlPolicy::dump(Formatter
*f
) const
256 encode_json("acl", acl
, f
);
257 encode_json("owner", owner
, f
);
260 void ObjectMetaInfo::dump(Formatter
*f
) const
262 encode_json("size", size
, f
);
263 encode_json("mtime", utime_t(mtime
), f
);
266 void ObjectCacheInfo::dump(Formatter
*f
) const
268 encode_json("status", status
, f
);
269 encode_json("flags", flags
, f
);
270 encode_json("data", data
, f
);
271 encode_json_map("xattrs", "name", "value", "length", xattrs
, f
);
272 encode_json_map("rm_xattrs", "name", "value", "length", rm_xattrs
, f
);
273 encode_json("meta", meta
, f
);
277 void RGWCacheNotifyInfo::dump(Formatter
*f
) const
279 encode_json("op", op
, f
);
280 encode_json("obj", obj
, f
);
281 encode_json("obj_info", obj_info
, f
);
282 encode_json("ofs", ofs
, f
);
283 encode_json("ns", ns
, f
);
286 void RGWAccessKey::dump(Formatter
*f
) const
288 encode_json("access_key", id
, f
);
289 encode_json("secret_key", key
, f
);
290 encode_json("subuser", subuser
, f
);
293 void RGWAccessKey::dump_plain(Formatter
*f
) const
295 encode_json("access_key", id
, f
);
296 encode_json("secret_key", key
, f
);
299 void encode_json_plain(const char *name
, const RGWAccessKey
& val
, Formatter
*f
)
301 f
->open_object_section(name
);
306 void RGWAccessKey::dump(Formatter
*f
, const string
& user
, bool swift
) const
309 if (!subuser
.empty()) {
313 encode_json("user", u
, f
);
315 encode_json("access_key", id
, f
);
317 encode_json("secret_key", key
, f
);
320 void RGWAccessKey::decode_json(JSONObj
*obj
) {
321 JSONDecoder::decode_json("access_key", id
, obj
, true);
322 JSONDecoder::decode_json("secret_key", key
, obj
, true);
323 if (!JSONDecoder::decode_json("subuser", subuser
, obj
)) {
325 JSONDecoder::decode_json("user", user
, obj
);
326 int pos
= user
.find(':');
328 subuser
= user
.substr(pos
+ 1);
333 void RGWAccessKey::decode_json(JSONObj
*obj
, bool swift
) {
339 if (!JSONDecoder::decode_json("subuser", subuser
, obj
)) {
340 JSONDecoder::decode_json("user", id
, obj
, true);
341 int pos
= id
.find(':');
343 subuser
= id
.substr(pos
+ 1);
346 JSONDecoder::decode_json("secret_key", key
, obj
, true);
349 struct rgw_flags_desc
{
354 static struct rgw_flags_desc rgw_perms
[] = {
355 { RGW_PERM_FULL_CONTROL
, "full-control" },
356 { RGW_PERM_READ
| RGW_PERM_WRITE
, "read-write" },
357 { RGW_PERM_READ
, "read" },
358 { RGW_PERM_WRITE
, "write" },
359 { RGW_PERM_READ_ACP
, "read-acp" },
360 { RGW_PERM_WRITE_ACP
, "write-acp" },
365 static void mask_to_str(T
*mask_list
, uint32_t mask
, char *buf
, int len
)
367 const char *sep
= "";
370 snprintf(buf
, len
, "<none>");
374 uint32_t orig_mask
= mask
;
375 for (int i
= 0; mask_list
[i
].mask
; i
++) {
376 T
*desc
= &mask_list
[i
];
377 if ((mask
& desc
->mask
) == desc
->mask
) {
378 pos
+= snprintf(buf
+ pos
, len
- pos
, "%s%s", sep
, desc
->str
);
387 if (mask
== orig_mask
) // no change
392 static void perm_to_str(uint32_t mask
, char *buf
, int len
)
394 return mask_to_str(rgw_perms
, mask
, buf
, len
);
397 static struct rgw_flags_desc op_type_flags
[] = {
398 { RGW_OP_TYPE_READ
, "read" },
399 { RGW_OP_TYPE_WRITE
, "write" },
400 { RGW_OP_TYPE_DELETE
, "delete" },
404 extern void op_type_to_str(uint32_t mask
, char *buf
, int len
)
406 return mask_to_str(op_type_flags
, mask
, buf
, len
);
409 void RGWSubUser::dump(Formatter
*f
) const
411 encode_json("id", name
, f
);
413 perm_to_str(perm_mask
, buf
, sizeof(buf
));
414 encode_json("permissions", (const char *)buf
, f
);
417 void RGWSubUser::dump(Formatter
*f
, const string
& user
) const
422 encode_json("id", s
, f
);
424 perm_to_str(perm_mask
, buf
, sizeof(buf
));
425 encode_json("permissions", (const char *)buf
, f
);
428 static uint32_t str_to_perm(const string
& s
)
430 if (s
.compare("read") == 0)
431 return RGW_PERM_READ
;
432 else if (s
.compare("write") == 0)
433 return RGW_PERM_WRITE
;
434 else if (s
.compare("read-write") == 0)
435 return RGW_PERM_READ
| RGW_PERM_WRITE
;
436 else if (s
.compare("full-control") == 0)
437 return RGW_PERM_FULL_CONTROL
;
441 void RGWSubUser::decode_json(JSONObj
*obj
)
444 JSONDecoder::decode_json("id", uid
, obj
);
445 int pos
= uid
.find(':');
447 name
= uid
.substr(pos
+ 1);
449 JSONDecoder::decode_json("permissions", perm_str
, obj
);
450 perm_mask
= str_to_perm(perm_str
);
453 static void user_info_dump_subuser(const char *name
, const RGWSubUser
& subuser
, Formatter
*f
, void *parent
)
455 RGWUserInfo
*info
= static_cast<RGWUserInfo
*>(parent
);
456 subuser
.dump(f
, info
->user_id
.to_str());
459 static void user_info_dump_key(const char *name
, const RGWAccessKey
& key
, Formatter
*f
, void *parent
)
461 RGWUserInfo
*info
= static_cast<RGWUserInfo
*>(parent
);
462 key
.dump(f
, info
->user_id
.to_str(), false);
465 static void user_info_dump_swift_key(const char *name
, const RGWAccessKey
& key
, Formatter
*f
, void *parent
)
467 RGWUserInfo
*info
= static_cast<RGWUserInfo
*>(parent
);
468 key
.dump(f
, info
->user_id
.to_str(), true);
471 void RGWUserInfo::dump(Formatter
*f
) const
474 encode_json("user_id", user_id
.to_str(), f
);
475 encode_json("display_name", display_name
, f
);
476 encode_json("email", user_email
, f
);
477 encode_json("suspended", (int)suspended
, f
);
478 encode_json("max_buckets", (int)max_buckets
, f
);
480 encode_json_map("subusers", NULL
, "subuser", NULL
, user_info_dump_subuser
,(void *)this, subusers
, f
);
481 encode_json_map("keys", NULL
, "key", NULL
, user_info_dump_key
,(void *)this, access_keys
, f
);
482 encode_json_map("swift_keys", NULL
, "key", NULL
, user_info_dump_swift_key
,(void *)this, swift_keys
, f
);
484 encode_json("caps", caps
, f
);
487 op_type_to_str(op_mask
, buf
, sizeof(buf
));
488 encode_json("op_mask", (const char *)buf
, f
);
490 if (system
) { /* no need to show it for every user */
491 encode_json("system", (bool)system
, f
);
494 encode_json("admin", (bool)admin
, f
);
496 encode_json("default_placement", default_placement
.name
, f
);
497 encode_json("default_storage_class", default_placement
.storage_class
, f
);
498 encode_json("placement_tags", placement_tags
, f
);
499 encode_json("bucket_quota", bucket_quota
, f
);
500 encode_json("user_quota", user_quota
, f
);
501 encode_json("temp_url_keys", temp_url_keys
, f
);
503 string user_source_type
;
504 switch ((RGWIdentityType
)type
) {
506 user_source_type
= "rgw";
509 user_source_type
= "keystone";
512 user_source_type
= "ldap";
515 user_source_type
= "none";
518 user_source_type
= "none";
521 encode_json("type", user_source_type
, f
);
522 encode_json("mfa_ids", mfa_ids
, f
);
526 static void decode_access_keys(map
<string
, RGWAccessKey
>& m
, JSONObj
*o
)
533 static void decode_swift_keys(map
<string
, RGWAccessKey
>& m
, JSONObj
*o
)
536 k
.decode_json(o
, true);
540 static void decode_subusers(map
<string
, RGWSubUser
>& m
, JSONObj
*o
)
547 void RGWUserInfo::decode_json(JSONObj
*obj
)
551 JSONDecoder::decode_json("user_id", uid
, obj
, true);
552 user_id
.from_str(uid
);
554 JSONDecoder::decode_json("display_name", display_name
, obj
);
555 JSONDecoder::decode_json("email", user_email
, obj
);
557 JSONDecoder::decode_json("suspended", susp
, obj
);
558 suspended
= (__u8
)susp
;
559 JSONDecoder::decode_json("max_buckets", max_buckets
, obj
);
561 JSONDecoder::decode_json("keys", access_keys
, decode_access_keys
, obj
);
562 JSONDecoder::decode_json("swift_keys", swift_keys
, decode_swift_keys
, obj
);
563 JSONDecoder::decode_json("subusers", subusers
, decode_subusers
, obj
);
565 JSONDecoder::decode_json("caps", caps
, obj
);
568 JSONDecoder::decode_json("op_mask", mask_str
, obj
);
569 rgw_parse_op_type_list(mask_str
, &op_mask
);
572 JSONDecoder::decode_json("system", sys
, obj
);
575 JSONDecoder::decode_json("admin", ad
, obj
);
577 JSONDecoder::decode_json("default_placement", default_placement
.name
, obj
);
578 JSONDecoder::decode_json("default_storage_class", default_placement
.storage_class
, obj
);
579 JSONDecoder::decode_json("placement_tags", placement_tags
, obj
);
580 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
581 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
582 JSONDecoder::decode_json("temp_url_keys", temp_url_keys
, obj
);
584 string user_source_type
;
585 JSONDecoder::decode_json("type", user_source_type
, obj
);
586 if (user_source_type
== "rgw") {
588 } else if (user_source_type
== "keystone") {
589 type
= TYPE_KEYSTONE
;
590 } else if (user_source_type
== "ldap") {
592 } else if (user_source_type
== "none") {
595 JSONDecoder::decode_json("mfa_ids", mfa_ids
, obj
);
598 void RGWQuotaInfo::dump(Formatter
*f
) const
600 f
->dump_bool("enabled", enabled
);
601 f
->dump_bool("check_on_raw", check_on_raw
);
603 f
->dump_int("max_size", max_size
);
604 f
->dump_int("max_size_kb", rgw_rounded_kb(max_size
));
605 f
->dump_int("max_objects", max_objects
);
608 void RGWQuotaInfo::decode_json(JSONObj
*obj
)
610 if (false == JSONDecoder::decode_json("max_size", max_size
, obj
)) {
611 /* We're parsing an older version of the struct. */
612 int64_t max_size_kb
= 0;
614 JSONDecoder::decode_json("max_size_kb", max_size_kb
, obj
);
615 max_size
= max_size_kb
* 1024;
617 JSONDecoder::decode_json("max_objects", max_objects
, obj
);
619 JSONDecoder::decode_json("check_on_raw", check_on_raw
, obj
);
620 JSONDecoder::decode_json("enabled", enabled
, obj
);
623 void rgw_data_placement_target::dump(Formatter
*f
) const
625 encode_json("data_pool", data_pool
, f
);
626 encode_json("data_extra_pool", data_extra_pool
, f
);
627 encode_json("index_pool", index_pool
, f
);
630 void rgw_data_placement_target::decode_json(JSONObj
*obj
) {
631 JSONDecoder::decode_json("data_pool", data_pool
, obj
);
632 JSONDecoder::decode_json("data_extra_pool", data_extra_pool
, obj
);
633 JSONDecoder::decode_json("index_pool", index_pool
, obj
);
636 void rgw_bucket::dump(Formatter
*f
) const
638 encode_json("name", name
, f
);
639 encode_json("marker", marker
, f
);
640 encode_json("bucket_id", bucket_id
, f
);
641 encode_json("tenant", tenant
, f
);
642 encode_json("explicit_placement", explicit_placement
, f
);
645 void rgw_bucket::decode_json(JSONObj
*obj
) {
646 JSONDecoder::decode_json("name", name
, obj
);
647 JSONDecoder::decode_json("marker", marker
, obj
);
648 JSONDecoder::decode_json("bucket_id", bucket_id
, obj
);
649 JSONDecoder::decode_json("tenant", tenant
, obj
);
650 JSONDecoder::decode_json("explicit_placement", explicit_placement
, obj
);
651 if (explicit_placement
.data_pool
.empty()) {
652 /* decoding old format */
653 JSONDecoder::decode_json("pool", explicit_placement
.data_pool
, obj
);
654 JSONDecoder::decode_json("data_extra_pool", explicit_placement
.data_extra_pool
, obj
);
655 JSONDecoder::decode_json("index_pool", explicit_placement
.index_pool
, obj
);
659 void RGWBucketEntryPoint::dump(Formatter
*f
) const
661 encode_json("bucket", bucket
, f
);
662 encode_json("owner", owner
, f
);
663 utime_t
ut(creation_time
);
664 encode_json("creation_time", ut
, f
);
665 encode_json("linked", linked
, f
);
666 encode_json("has_bucket_info", has_bucket_info
, f
);
667 if (has_bucket_info
) {
668 encode_json("old_bucket_info", old_bucket_info
, f
);
672 void RGWBucketEntryPoint::decode_json(JSONObj
*obj
) {
673 JSONDecoder::decode_json("bucket", bucket
, obj
);
674 JSONDecoder::decode_json("owner", owner
, obj
);
676 JSONDecoder::decode_json("creation_time", ut
, obj
);
677 creation_time
= ut
.to_real_time();
678 JSONDecoder::decode_json("linked", linked
, obj
);
679 JSONDecoder::decode_json("has_bucket_info", has_bucket_info
, obj
);
680 if (has_bucket_info
) {
681 JSONDecoder::decode_json("old_bucket_info", old_bucket_info
, obj
);
685 void RGWStorageStats::dump(Formatter
*f
) const
687 encode_json("size", size
, f
);
688 encode_json("size_actual", size_rounded
, f
);
689 encode_json("size_utilized", size_utilized
, f
);
690 encode_json("size_kb", rgw_rounded_kb(size
), f
);
691 encode_json("size_kb_actual", rgw_rounded_kb(size_rounded
), f
);
692 encode_json("size_kb_utilized", rgw_rounded_kb(size_utilized
), f
);
693 encode_json("num_objects", num_objects
, f
);
696 void RGWRedirectInfo::dump(Formatter
*f
) const
698 encode_json("protocol", protocol
, f
);
699 encode_json("hostname", hostname
, f
);
700 encode_json("http_redirect_code", (int)http_redirect_code
, f
);
703 void RGWRedirectInfo::decode_json(JSONObj
*obj
) {
704 JSONDecoder::decode_json("protocol", protocol
, obj
);
705 JSONDecoder::decode_json("hostname", hostname
, obj
);
707 JSONDecoder::decode_json("http_redirect_code", code
, obj
);
708 http_redirect_code
= code
;
711 void RGWBWRedirectInfo::dump(Formatter
*f
) const
713 encode_json("redirect", redirect
, f
);
714 encode_json("replace_key_prefix_with", replace_key_prefix_with
, f
);
715 encode_json("replace_key_with", replace_key_with
, f
);
718 void RGWBWRedirectInfo::decode_json(JSONObj
*obj
) {
719 JSONDecoder::decode_json("redirect", redirect
, obj
);
720 JSONDecoder::decode_json("replace_key_prefix_with", replace_key_prefix_with
, obj
);
721 JSONDecoder::decode_json("replace_key_with", replace_key_with
, obj
);
724 void RGWBWRoutingRuleCondition::dump(Formatter
*f
) const
726 encode_json("key_prefix_equals", key_prefix_equals
, f
);
727 encode_json("http_error_code_returned_equals", (int)http_error_code_returned_equals
, f
);
730 void RGWBWRoutingRuleCondition::decode_json(JSONObj
*obj
) {
731 JSONDecoder::decode_json("key_prefix_equals", key_prefix_equals
, obj
);
733 JSONDecoder::decode_json("http_error_code_returned_equals", code
, obj
);
734 http_error_code_returned_equals
= code
;
737 void RGWBWRoutingRule::dump(Formatter
*f
) const
739 encode_json("condition", condition
, f
);
740 encode_json("redirect_info", redirect_info
, f
);
743 void RGWBWRoutingRule::decode_json(JSONObj
*obj
) {
744 JSONDecoder::decode_json("condition", condition
, obj
);
745 JSONDecoder::decode_json("redirect_info", redirect_info
, obj
);
748 void RGWBWRoutingRules::dump(Formatter
*f
) const
750 encode_json("rules", rules
, f
);
753 void RGWBWRoutingRules::decode_json(JSONObj
*obj
) {
754 JSONDecoder::decode_json("rules", rules
, obj
);
757 void RGWBucketWebsiteConf::dump(Formatter
*f
) const
759 if (!redirect_all
.hostname
.empty()) {
760 encode_json("redirect_all", redirect_all
, f
);
762 encode_json("index_doc_suffix", index_doc_suffix
, f
);
763 encode_json("error_doc", error_doc
, f
);
764 encode_json("routing_rules", routing_rules
, f
);
768 void RGWBucketWebsiteConf::decode_json(JSONObj
*obj
) {
769 JSONDecoder::decode_json("redirect_all", redirect_all
, obj
);
770 JSONDecoder::decode_json("index_doc_suffix", index_doc_suffix
, obj
);
771 JSONDecoder::decode_json("error_doc", error_doc
, obj
);
772 JSONDecoder::decode_json("routing_rules", routing_rules
, obj
);
775 void RGWBucketInfo::dump(Formatter
*f
) const
777 encode_json("bucket", bucket
, f
);
778 utime_t
ut(creation_time
);
779 encode_json("creation_time", ut
, f
);
780 encode_json("owner", owner
.to_str(), f
);
781 encode_json("flags", flags
, f
);
782 encode_json("zonegroup", zonegroup
, f
);
783 encode_json("placement_rule", placement_rule
, f
);
784 encode_json("has_instance_obj", has_instance_obj
, f
);
785 encode_json("quota", quota
, f
);
786 encode_json("num_shards", layout
.current_index
.layout
.normal
.num_shards
, f
);
787 encode_json("bi_shard_hash_type", (uint32_t)layout
.current_index
.layout
.normal
.hash_type
, f
);
788 encode_json("requester_pays", requester_pays
, f
);
789 encode_json("has_website", has_website
, f
);
791 encode_json("website_conf", website_conf
, f
);
793 encode_json("swift_versioning", swift_versioning
, f
);
794 encode_json("swift_ver_location", swift_ver_location
, f
);
795 encode_json("index_type", (uint32_t)layout
.current_index
.layout
.type
, f
);
796 encode_json("mdsearch_config", mdsearch_config
, f
);
797 encode_json("reshard_status", (int)reshard_status
, f
);
798 encode_json("new_bucket_instance_id", new_bucket_instance_id
, f
);
799 if (!empty_sync_policy()) {
800 encode_json("sync_policy", *sync_policy
, f
);
804 void RGWBucketInfo::decode_json(JSONObj
*obj
) {
805 JSONDecoder::decode_json("bucket", bucket
, obj
);
807 JSONDecoder::decode_json("creation_time", ut
, obj
);
808 creation_time
= ut
.to_real_time();
809 JSONDecoder::decode_json("owner", owner
, obj
);
810 JSONDecoder::decode_json("flags", flags
, obj
);
811 JSONDecoder::decode_json("zonegroup", zonegroup
, obj
);
812 /* backward compatability with region */
813 if (zonegroup
.empty()) {
814 JSONDecoder::decode_json("region", zonegroup
, obj
);
817 JSONDecoder::decode_json("placement_rule", pr
, obj
);
818 placement_rule
.from_str(pr
);
819 JSONDecoder::decode_json("has_instance_obj", has_instance_obj
, obj
);
820 JSONDecoder::decode_json("quota", quota
, obj
);
821 JSONDecoder::decode_json("num_shards", layout
.current_index
.layout
.normal
.num_shards
, obj
);
823 JSONDecoder::decode_json("bi_shard_hash_type", hash_type
, obj
);
824 layout
.current_index
.layout
.normal
.hash_type
= static_cast<rgw::BucketHashType
>(hash_type
);
825 JSONDecoder::decode_json("requester_pays", requester_pays
, obj
);
826 JSONDecoder::decode_json("has_website", has_website
, obj
);
828 JSONDecoder::decode_json("website_conf", website_conf
, obj
);
830 JSONDecoder::decode_json("swift_versioning", swift_versioning
, obj
);
831 JSONDecoder::decode_json("swift_ver_location", swift_ver_location
, obj
);
833 JSONDecoder::decode_json("index_type", it
, obj
);
834 layout
.current_index
.layout
.type
= (rgw::BucketIndexType
)it
;
835 JSONDecoder::decode_json("mdsearch_config", mdsearch_config
, obj
);
837 JSONDecoder::decode_json("reshard_status", rs
, obj
);
838 reshard_status
= (cls_rgw_reshard_status
)rs
;
840 rgw_sync_policy_info sp
;
841 JSONDecoder::decode_json("sync_policy", sp
, obj
);
843 set_sync_policy(std::move(sp
));
847 void rgw_sync_directional_rule::dump(Formatter
*f
) const
849 encode_json("source_zone", source_zone
, f
);
850 encode_json("dest_zone", dest_zone
, f
);
853 void rgw_sync_directional_rule::decode_json(JSONObj
*obj
)
855 JSONDecoder::decode_json("source_zone", source_zone
, obj
);
856 JSONDecoder::decode_json("dest_zone", dest_zone
, obj
);
859 void rgw_sync_symmetric_group::dump(Formatter
*f
) const
861 encode_json("id", id
, f
);
862 encode_json("zones", zones
, f
);
865 void rgw_sync_symmetric_group::decode_json(JSONObj
*obj
)
867 JSONDecoder::decode_json("id", id
, obj
);
868 JSONDecoder::decode_json("zones", zones
, obj
);
871 void rgw_sync_bucket_entity::dump(Formatter
*f
) const
873 encode_json("zone", zone
, f
);
874 encode_json("bucket", bucket_key(), f
);
877 void rgw_sync_bucket_entity::decode_json(JSONObj
*obj
)
879 JSONDecoder::decode_json("zone", zone
, obj
);
881 if (JSONDecoder::decode_json("bucket", s
, obj
)) {
883 int ret
= rgw_bucket_parse_bucket_key(nullptr, s
, &b
, nullptr);
892 void rgw_sync_pipe_filter_tag::dump(Formatter
*f
) const
894 encode_json("key", key
, f
);
895 encode_json("value", value
, f
);
898 void rgw_sync_pipe_filter_tag::decode_json(JSONObj
*obj
)
900 JSONDecoder::decode_json("key", key
, obj
);
901 JSONDecoder::decode_json("value", value
, obj
);
904 void rgw_sync_pipe_filter::dump(Formatter
*f
) const
906 encode_json("prefix", prefix
, f
);
907 encode_json("tags", tags
, f
);
910 void rgw_sync_pipe_filter::decode_json(JSONObj
*obj
)
912 JSONDecoder::decode_json("prefix", prefix
, obj
);
913 JSONDecoder::decode_json("tags", tags
, obj
);
916 void rgw_sync_pipe_acl_translation::dump(Formatter
*f
) const
918 encode_json("owner", owner
, f
);
921 void rgw_sync_pipe_acl_translation::decode_json(JSONObj
*obj
)
923 JSONDecoder::decode_json("owner", owner
, obj
);
926 void rgw_sync_pipe_source_params::dump(Formatter
*f
) const
928 encode_json("filter", filter
, f
);
931 void rgw_sync_pipe_source_params::decode_json(JSONObj
*obj
)
933 JSONDecoder::decode_json("filter", filter
, obj
);
936 void rgw_sync_pipe_dest_params::dump(Formatter
*f
) const
938 encode_json("acl_translation", acl_translation
, f
);
939 encode_json("storage_class", storage_class
, f
);
942 void rgw_sync_pipe_dest_params::decode_json(JSONObj
*obj
)
944 JSONDecoder::decode_json("acl_translation", acl_translation
, obj
);
945 JSONDecoder::decode_json("storage_class", storage_class
, obj
);
948 void rgw_sync_pipe_params::dump(Formatter
*f
) const
950 encode_json("source", source
, f
);
951 encode_json("dest", dest
, f
);
952 encode_json("priority", priority
, f
);
961 encode_json("mode", s
, f
);
962 encode_json("user", user
, f
);
965 void rgw_sync_pipe_params::decode_json(JSONObj
*obj
)
967 JSONDecoder::decode_json("source", source
, obj
);
968 JSONDecoder::decode_json("dest", dest
, obj
);
969 JSONDecoder::decode_json("priority", priority
, obj
);
971 JSONDecoder::decode_json("mode", s
, obj
);
977 JSONDecoder::decode_json("user", user
, obj
);
981 void rgw_sync_bucket_entities::dump(Formatter
*f
) const
983 encode_json("bucket", rgw_sync_bucket_entities::bucket_key(bucket
), f
);
985 encode_json("zones", zones
, f
);
986 } else if (all_zones
) {
987 set
<string
> z
= { "*" };
988 encode_json("zones", z
, f
);
992 void rgw_sync_bucket_entities::decode_json(JSONObj
*obj
)
995 JSONDecoder::decode_json("bucket", s
, obj
);
1000 int ret
= rgw_bucket_parse_bucket_key(nullptr, s
, &b
, nullptr);
1004 if (b
.tenant
== "*") {
1007 if (b
.name
== "*") {
1010 if (b
.bucket_id
== "*") {
1011 b
.bucket_id
.clear();
1016 JSONDecoder::decode_json("zones", zones
, obj
);
1017 if (zones
&& zones
->size() == 1) {
1018 auto iter
= zones
->begin();
1026 void rgw_sync_bucket_pipe::dump(Formatter
*f
) const
1028 encode_json("id", id
, f
);
1029 encode_json("source", source
, f
);
1030 encode_json("dest", dest
, f
);
1031 encode_json("params", params
, f
);
1034 void rgw_sync_bucket_pipe::decode_json(JSONObj
*obj
)
1036 JSONDecoder::decode_json("id", id
, obj
);
1037 JSONDecoder::decode_json("source", source
, obj
);
1038 JSONDecoder::decode_json("dest", dest
, obj
);
1039 JSONDecoder::decode_json("params", params
, obj
);
1042 void rgw_sync_bucket_pipes::dump(Formatter
*f
) const
1044 encode_json("id", id
, f
);
1045 encode_json("source", source
, f
);
1046 encode_json("dest", dest
, f
);
1047 encode_json("params", params
, f
);
1050 void rgw_sync_bucket_pipes::decode_json(JSONObj
*obj
)
1052 JSONDecoder::decode_json("id", id
, obj
);
1053 JSONDecoder::decode_json("source", source
, obj
);
1054 JSONDecoder::decode_json("dest", dest
, obj
);
1055 JSONDecoder::decode_json("params", params
, obj
);
1058 void rgw_sync_data_flow_group::dump(Formatter
*f
) const
1060 if (!symmetrical
.empty()) {
1061 encode_json("symmetrical", symmetrical
, f
);
1064 if (!directional
.empty()) {
1065 encode_json("directional", directional
, f
);
1069 void rgw_sync_data_flow_group::decode_json(JSONObj
*obj
)
1071 JSONDecoder::decode_json("symmetrical", symmetrical
, obj
);
1072 JSONDecoder::decode_json("directional", directional
, obj
);
1075 void rgw_sync_policy_group::dump(Formatter
*f
) const
1077 encode_json("id", id
, f
);
1078 encode_json("data_flow", data_flow
, f
);
1079 encode_json("pipes", pipes
, f
);
1082 case rgw_sync_policy_group::Status::FORBIDDEN
:
1085 case rgw_sync_policy_group::Status::ALLOWED
:
1088 case rgw_sync_policy_group::Status::ENABLED
:
1094 encode_json("status", s
, f
);
1097 void rgw_sync_policy_group::decode_json(JSONObj
*obj
)
1099 JSONDecoder::decode_json("id", id
, obj
);
1100 JSONDecoder::decode_json("data_flow", data_flow
, obj
);
1101 JSONDecoder::decode_json("pipes", pipes
, obj
);
1103 JSONDecoder::decode_json("status", s
, obj
);
1107 void rgw_sync_policy_info::dump(Formatter
*f
) const
1109 Formatter::ArraySection
section(*f
, "groups");
1110 for (auto& group
: groups
) {
1111 encode_json("group", group
.second
, f
);
1115 void rgw_sync_policy_info::decode_json(JSONObj
*obj
)
1117 vector
<rgw_sync_policy_group
> groups_vec
;
1119 JSONDecoder::decode_json("groups", groups_vec
, obj
);
1121 for (auto& group
: groups_vec
) {
1122 groups
.emplace(std::make_pair(group
.id
, std::move(group
)));
1126 void rgw_obj_key::dump(Formatter
*f
) const
1128 encode_json("name", name
, f
);
1129 encode_json("instance", instance
, f
);
1130 encode_json("ns", ns
, f
);
1133 void rgw_obj_key::decode_json(JSONObj
*obj
)
1135 JSONDecoder::decode_json("name", name
, obj
);
1136 JSONDecoder::decode_json("instance", instance
, obj
);
1137 JSONDecoder::decode_json("ns", ns
, obj
);
1140 void RGWBucketEnt::dump(Formatter
*f
) const
1142 encode_json("bucket", bucket
, f
);
1143 encode_json("size", size
, f
);
1144 encode_json("size_rounded", size_rounded
, f
);
1145 utime_t
ut(creation_time
);
1146 encode_json("mtime", ut
, f
); /* mtime / creation time discrepency needed for backward compatibility */
1147 encode_json("count", count
, f
);
1148 encode_json("placement_rule", placement_rule
.to_str(), f
);
1151 void RGWUploadPartInfo::dump(Formatter
*f
) const
1153 encode_json("num", num
, f
);
1154 encode_json("size", size
, f
);
1155 encode_json("etag", etag
, f
);
1156 utime_t
ut(modified
);
1157 encode_json("modified", ut
, f
);
1160 void rgw_raw_obj::dump(Formatter
*f
) const
1162 encode_json("pool", pool
, f
);
1163 encode_json("oid", oid
, f
);
1164 encode_json("loc", loc
, f
);
1167 void rgw_raw_obj::decode_json(JSONObj
*obj
) {
1168 JSONDecoder::decode_json("pool", pool
, obj
);
1169 JSONDecoder::decode_json("oid", oid
, obj
);
1170 JSONDecoder::decode_json("loc", loc
, obj
);
1173 void rgw_obj::dump(Formatter
*f
) const
1175 encode_json("bucket", bucket
, f
);
1176 encode_json("key", key
, f
);
1179 void RGWDefaultSystemMetaObjInfo::dump(Formatter
*f
) const {
1180 encode_json("default_id", default_id
, f
);
1183 void RGWDefaultSystemMetaObjInfo::decode_json(JSONObj
*obj
) {
1184 JSONDecoder::decode_json("default_id", default_id
, obj
);
1187 void RGWNameToId::dump(Formatter
*f
) const {
1188 encode_json("obj_id", obj_id
, f
);
1191 void RGWNameToId::decode_json(JSONObj
*obj
) {
1192 JSONDecoder::decode_json("obj_id", obj_id
, obj
);
1195 void RGWSystemMetaObj::dump(Formatter
*f
) const
1197 encode_json("id", id
, f
);
1198 encode_json("name", name
, f
);
1201 void RGWSystemMetaObj::decode_json(JSONObj
*obj
)
1203 JSONDecoder::decode_json("id", id
, obj
);
1204 JSONDecoder::decode_json("name", name
, obj
);
1207 void RGWPeriodLatestEpochInfo::dump(Formatter
*f
) const {
1208 encode_json("latest_epoch", epoch
, f
);
1211 void RGWPeriodLatestEpochInfo::decode_json(JSONObj
*obj
) {
1212 JSONDecoder::decode_json("latest_epoch", epoch
, obj
);
1215 void RGWPeriod::dump(Formatter
*f
) const
1217 encode_json("id", id
, f
);
1218 encode_json("epoch", epoch
, f
);
1219 encode_json("predecessor_uuid", predecessor_uuid
, f
);
1220 encode_json("sync_status", sync_status
, f
);
1221 encode_json("period_map", period_map
, f
);
1222 encode_json("master_zonegroup", master_zonegroup
, f
);
1223 encode_json("master_zone", master_zone
, f
);
1224 encode_json("period_config", period_config
, f
);
1225 encode_json("realm_id", realm_id
, f
);
1226 encode_json("realm_name", realm_name
, f
);
1227 encode_json("realm_epoch", realm_epoch
, f
);
1230 void RGWPeriod::decode_json(JSONObj
*obj
)
1232 JSONDecoder::decode_json("id", id
, obj
);
1233 JSONDecoder::decode_json("epoch", epoch
, obj
);
1234 JSONDecoder::decode_json("predecessor_uuid", predecessor_uuid
, obj
);
1235 JSONDecoder::decode_json("sync_status", sync_status
, obj
);
1236 JSONDecoder::decode_json("period_map", period_map
, obj
);
1237 JSONDecoder::decode_json("master_zonegroup", master_zonegroup
, obj
);
1238 JSONDecoder::decode_json("master_zone", master_zone
, obj
);
1239 JSONDecoder::decode_json("period_config", period_config
, obj
);
1240 JSONDecoder::decode_json("realm_id", realm_id
, obj
);
1241 JSONDecoder::decode_json("realm_name", realm_name
, obj
);
1242 JSONDecoder::decode_json("realm_epoch", realm_epoch
, obj
);
1245 void RGWZoneParams::dump(Formatter
*f
) const
1247 RGWSystemMetaObj::dump(f
);
1248 encode_json("domain_root", domain_root
, f
);
1249 encode_json("control_pool", control_pool
, f
);
1250 encode_json("gc_pool", gc_pool
, f
);
1251 encode_json("lc_pool", lc_pool
, f
);
1252 encode_json("log_pool", log_pool
, f
);
1253 encode_json("intent_log_pool", intent_log_pool
, f
);
1254 encode_json("usage_log_pool", usage_log_pool
, f
);
1255 encode_json("roles_pool", roles_pool
, f
);
1256 encode_json("reshard_pool", reshard_pool
, f
);
1257 encode_json("user_keys_pool", user_keys_pool
, f
);
1258 encode_json("user_email_pool", user_email_pool
, f
);
1259 encode_json("user_swift_pool", user_swift_pool
, f
);
1260 encode_json("user_uid_pool", user_uid_pool
, f
);
1261 encode_json("otp_pool", otp_pool
, f
);
1262 encode_json_plain("system_key", system_key
, f
);
1263 encode_json("placement_pools", placement_pools
, f
);
1264 encode_json("tier_config", tier_config
, f
);
1265 encode_json("realm_id", realm_id
, f
);
1266 encode_json("notif_pool", notif_pool
, f
);
1269 void RGWZoneStorageClass::dump(Formatter
*f
) const
1272 encode_json("data_pool", data_pool
.get(), f
);
1274 if (compression_type
) {
1275 encode_json("compression_type", compression_type
.get(), f
);
1279 void RGWZoneStorageClass::decode_json(JSONObj
*obj
)
1281 JSONDecoder::decode_json("data_pool", data_pool
, obj
);
1282 JSONDecoder::decode_json("compression_type", compression_type
, obj
);
1285 void RGWZoneStorageClasses::dump(Formatter
*f
) const
1288 encode_json(i
.first
.c_str(), i
.second
, f
);
1292 void RGWZoneStorageClasses::decode_json(JSONObj
*obj
)
1295 decode_json_obj(f
, obj
);
1297 for (auto& field
: f
.object()) {
1298 JSONObj
*field_obj
= obj
->find_obj(field
.first
);
1301 decode_json_obj(m
[field
.first
], field_obj
);
1303 standard_class
= &m
[RGW_STORAGE_CLASS_STANDARD
];
1306 void RGWZonePlacementInfo::dump(Formatter
*f
) const
1308 encode_json("index_pool", index_pool
, f
);
1309 encode_json("storage_classes", storage_classes
, f
);
1310 encode_json("data_extra_pool", data_extra_pool
, f
);
1311 encode_json("index_type", (uint32_t)index_type
, f
);
1313 /* no real need for backward compatibility of compression_type and data_pool in here,
1314 * rather not clutter the output */
1317 void RGWZonePlacementInfo::decode_json(JSONObj
*obj
)
1319 JSONDecoder::decode_json("index_pool", index_pool
, obj
);
1320 JSONDecoder::decode_json("storage_classes", storage_classes
, obj
);
1321 JSONDecoder::decode_json("data_extra_pool", data_extra_pool
, obj
);
1323 JSONDecoder::decode_json("index_type", it
, obj
);
1324 index_type
= (rgw::BucketIndexType
)it
;
1326 /* backward compatibility, these are now defined in storage_classes */
1327 string standard_compression_type
;
1328 string
*pcompression
= nullptr;
1329 if (JSONDecoder::decode_json("compression", standard_compression_type
, obj
)) {
1330 pcompression
= &standard_compression_type
;
1332 rgw_pool standard_data_pool
;
1333 rgw_pool
*ppool
= nullptr;
1334 if (JSONDecoder::decode_json("data_pool", standard_data_pool
, obj
)) {
1335 ppool
= &standard_data_pool
;
1337 if (ppool
|| pcompression
) {
1338 storage_classes
.set_storage_class(RGW_STORAGE_CLASS_STANDARD
, ppool
, pcompression
);
1342 void RGWZoneParams::decode_json(JSONObj
*obj
)
1344 RGWSystemMetaObj::decode_json(obj
);
1345 JSONDecoder::decode_json("domain_root", domain_root
, obj
);
1346 JSONDecoder::decode_json("control_pool", control_pool
, obj
);
1347 JSONDecoder::decode_json("gc_pool", gc_pool
, obj
);
1348 JSONDecoder::decode_json("lc_pool", lc_pool
, obj
);
1349 JSONDecoder::decode_json("log_pool", log_pool
, obj
);
1350 JSONDecoder::decode_json("intent_log_pool", intent_log_pool
, obj
);
1351 JSONDecoder::decode_json("roles_pool", roles_pool
, obj
);
1352 JSONDecoder::decode_json("reshard_pool", reshard_pool
, obj
);
1353 JSONDecoder::decode_json("usage_log_pool", usage_log_pool
, obj
);
1354 JSONDecoder::decode_json("user_keys_pool", user_keys_pool
, obj
);
1355 JSONDecoder::decode_json("user_email_pool", user_email_pool
, obj
);
1356 JSONDecoder::decode_json("user_swift_pool", user_swift_pool
, obj
);
1357 JSONDecoder::decode_json("user_uid_pool", user_uid_pool
, obj
);
1358 JSONDecoder::decode_json("otp_pool", otp_pool
, obj
);
1359 JSONDecoder::decode_json("system_key", system_key
, obj
);
1360 JSONDecoder::decode_json("placement_pools", placement_pools
, obj
);
1361 JSONDecoder::decode_json("tier_config", tier_config
, obj
);
1362 JSONDecoder::decode_json("realm_id", realm_id
, obj
);
1363 JSONDecoder::decode_json("notif_pool", notif_pool
, obj
);
1367 void RGWZone::dump(Formatter
*f
) const
1369 encode_json("id", id
, f
);
1370 encode_json("name", name
, f
);
1371 encode_json("endpoints", endpoints
, f
);
1372 encode_json("log_meta", log_meta
, f
);
1373 encode_json("log_data", log_data
, f
);
1374 encode_json("bucket_index_max_shards", bucket_index_max_shards
, f
);
1375 encode_json("read_only", read_only
, f
);
1376 encode_json("tier_type", tier_type
, f
);
1377 encode_json("sync_from_all", sync_from_all
, f
);
1378 encode_json("sync_from", sync_from
, f
);
1379 encode_json("redirect_zone", redirect_zone
, f
);
1382 void RGWZone::decode_json(JSONObj
*obj
)
1384 JSONDecoder::decode_json("id", id
, obj
);
1385 JSONDecoder::decode_json("name", name
, obj
);
1389 JSONDecoder::decode_json("endpoints", endpoints
, obj
);
1390 JSONDecoder::decode_json("log_meta", log_meta
, obj
);
1391 JSONDecoder::decode_json("log_data", log_data
, obj
);
1392 JSONDecoder::decode_json("bucket_index_max_shards", bucket_index_max_shards
, obj
);
1393 JSONDecoder::decode_json("read_only", read_only
, obj
);
1394 JSONDecoder::decode_json("tier_type", tier_type
, obj
);
1395 JSONDecoder::decode_json("sync_from_all", sync_from_all
, true, obj
);
1396 JSONDecoder::decode_json("sync_from", sync_from
, obj
);
1397 JSONDecoder::decode_json("redirect_zone", redirect_zone
, obj
);
1400 void RGWZoneGroupPlacementTarget::dump(Formatter
*f
) const
1402 encode_json("name", name
, f
);
1403 encode_json("tags", tags
, f
);
1404 encode_json("storage_classes", storage_classes
, f
);
1407 void RGWZoneGroupPlacementTarget::decode_json(JSONObj
*obj
)
1409 JSONDecoder::decode_json("name", name
, obj
);
1410 JSONDecoder::decode_json("tags", tags
, obj
);
1411 JSONDecoder::decode_json("storage_classes", storage_classes
, obj
);
1412 if (storage_classes
.empty()) {
1413 storage_classes
.insert(RGW_STORAGE_CLASS_STANDARD
);
1417 void RGWZoneGroup::dump(Formatter
*f
) const
1419 RGWSystemMetaObj::dump(f
);
1420 encode_json("api_name", api_name
, f
);
1421 encode_json("is_master", is_master
, f
);
1422 encode_json("endpoints", endpoints
, f
);
1423 encode_json("hostnames", hostnames
, f
);
1424 encode_json("hostnames_s3website", hostnames_s3website
, f
);
1425 encode_json("master_zone", master_zone
, f
);
1426 encode_json_map("zones", zones
, f
); /* more friendly representation */
1427 encode_json_map("placement_targets", placement_targets
, f
); /* more friendly representation */
1428 encode_json("default_placement", default_placement
, f
);
1429 encode_json("realm_id", realm_id
, f
);
1430 encode_json("sync_policy", sync_policy
, f
);
1433 static void decode_zones(map
<rgw_zone_id
, RGWZone
>& zones
, JSONObj
*o
)
1440 static void decode_placement_targets(map
<string
, RGWZoneGroupPlacementTarget
>& targets
, JSONObj
*o
)
1442 RGWZoneGroupPlacementTarget t
;
1444 targets
[t
.name
] = t
;
1448 void RGWZoneGroup::decode_json(JSONObj
*obj
)
1450 RGWSystemMetaObj::decode_json(obj
);
1452 derr
<< "old format " << dendl
;
1453 JSONDecoder::decode_json("name", name
, obj
);
1456 JSONDecoder::decode_json("api_name", api_name
, obj
);
1457 JSONDecoder::decode_json("is_master", is_master
, obj
);
1458 JSONDecoder::decode_json("endpoints", endpoints
, obj
);
1459 JSONDecoder::decode_json("hostnames", hostnames
, obj
);
1460 JSONDecoder::decode_json("hostnames_s3website", hostnames_s3website
, obj
);
1461 JSONDecoder::decode_json("master_zone", master_zone
, obj
);
1462 JSONDecoder::decode_json("zones", zones
, decode_zones
, obj
);
1463 JSONDecoder::decode_json("placement_targets", placement_targets
, decode_placement_targets
, obj
);
1464 JSONDecoder::decode_json("default_placement", default_placement
.name
, obj
);
1465 JSONDecoder::decode_json("default_storage_class", default_placement
.storage_class
, obj
);
1466 JSONDecoder::decode_json("realm_id", realm_id
, obj
);
1467 JSONDecoder::decode_json("sync_policy", sync_policy
, obj
);
1471 void RGWPeriodMap::dump(Formatter
*f
) const
1473 encode_json("id", id
, f
);
1474 encode_json_map("zonegroups", zonegroups
, f
);
1475 encode_json("short_zone_ids", short_zone_ids
, f
);
1478 static void decode_zonegroups(map
<string
, RGWZoneGroup
>& zonegroups
, JSONObj
*o
)
1482 zonegroups
[zg
.get_id()] = zg
;
1485 void RGWPeriodMap::decode_json(JSONObj
*obj
)
1487 JSONDecoder::decode_json("id", id
, obj
);
1488 JSONDecoder::decode_json("zonegroups", zonegroups
, decode_zonegroups
, obj
);
1489 /* backward compatability with region */
1490 if (zonegroups
.empty()) {
1491 JSONDecoder::decode_json("regions", zonegroups
, obj
);
1493 /* backward compatability with region */
1494 if (master_zonegroup
.empty()) {
1495 JSONDecoder::decode_json("master_region", master_zonegroup
, obj
);
1497 JSONDecoder::decode_json("short_zone_ids", short_zone_ids
, obj
);
1501 void RGWPeriodConfig::dump(Formatter
*f
) const
1503 encode_json("bucket_quota", bucket_quota
, f
);
1504 encode_json("user_quota", user_quota
, f
);
1507 void RGWPeriodConfig::decode_json(JSONObj
*obj
)
1509 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
1510 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
1513 void RGWRegionMap::dump(Formatter
*f
) const
1515 encode_json("regions", regions
, f
);
1516 encode_json("master_region", master_region
, f
);
1517 encode_json("bucket_quota", bucket_quota
, f
);
1518 encode_json("user_quota", user_quota
, f
);
1521 void RGWRegionMap::decode_json(JSONObj
*obj
)
1523 JSONDecoder::decode_json("regions", regions
, obj
);
1524 JSONDecoder::decode_json("master_region", master_region
, obj
);
1525 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
1526 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
1529 void RGWZoneGroupMap::dump(Formatter
*f
) const
1531 encode_json("zonegroups", zonegroups
, f
);
1532 encode_json("master_zonegroup", master_zonegroup
, f
);
1533 encode_json("bucket_quota", bucket_quota
, f
);
1534 encode_json("user_quota", user_quota
, f
);
1537 void RGWZoneGroupMap::decode_json(JSONObj
*obj
)
1539 JSONDecoder::decode_json("zonegroups", zonegroups
, obj
);
1540 /* backward compatability with region */
1541 if (zonegroups
.empty()) {
1542 JSONDecoder::decode_json("regions", zonegroups
, obj
);
1544 JSONDecoder::decode_json("master_zonegroup", master_zonegroup
, obj
);
1545 /* backward compatability with region */
1546 if (master_zonegroup
.empty()) {
1547 JSONDecoder::decode_json("master_region", master_zonegroup
, obj
);
1550 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
1551 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
1554 void RGWMetadataLogInfo::dump(Formatter
*f
) const
1556 encode_json("marker", marker
, f
);
1557 utime_t
ut(last_update
);
1558 encode_json("last_update", ut
, f
);
1561 void RGWMetadataLogInfo::decode_json(JSONObj
*obj
)
1563 JSONDecoder::decode_json("marker", marker
, obj
);
1565 JSONDecoder::decode_json("last_update", ut
, obj
);
1566 last_update
= ut
.to_real_time();
1569 void RGWDataChangesLogInfo::dump(Formatter
*f
) const
1571 encode_json("marker", marker
, f
);
1572 utime_t
ut(last_update
);
1573 encode_json("last_update", ut
, f
);
1576 void RGWDataChangesLogInfo::decode_json(JSONObj
*obj
)
1578 JSONDecoder::decode_json("marker", marker
, obj
);
1580 JSONDecoder::decode_json("last_update", ut
, obj
);
1581 last_update
= ut
.to_real_time();
1585 void RGWRealm::dump(Formatter
*f
) const
1587 RGWSystemMetaObj::dump(f
);
1588 encode_json("current_period", current_period
, f
);
1589 encode_json("epoch", epoch
, f
);
1593 void RGWRealm::decode_json(JSONObj
*obj
)
1595 RGWSystemMetaObj::decode_json(obj
);
1596 JSONDecoder::decode_json("current_period", current_period
, obj
);
1597 JSONDecoder::decode_json("epoch", epoch
, obj
);
1600 void rgw::keystone::TokenEnvelope::Token::decode_json(JSONObj
*obj
)
1602 string expires_iso8601
;
1605 JSONDecoder::decode_json("id", id
, obj
, true);
1606 JSONDecoder::decode_json("tenant", tenant_v2
, obj
, true);
1607 JSONDecoder::decode_json("expires", expires_iso8601
, obj
, true);
1609 if (parse_iso8601(expires_iso8601
.c_str(), &t
)) {
1610 expires
= internal_timegm(&t
);
1613 throw JSONDecoder::err("Failed to parse ISO8601 expiration date from Keystone response.");
1617 void rgw::keystone::TokenEnvelope::Role::decode_json(JSONObj
*obj
)
1619 JSONDecoder::decode_json("id", id
, obj
);
1620 JSONDecoder::decode_json("name", name
, obj
, true);
1623 void rgw::keystone::TokenEnvelope::Domain::decode_json(JSONObj
*obj
)
1625 JSONDecoder::decode_json("id", id
, obj
, true);
1626 JSONDecoder::decode_json("name", name
, obj
, true);
1629 void rgw::keystone::TokenEnvelope::Project::decode_json(JSONObj
*obj
)
1631 JSONDecoder::decode_json("id", id
, obj
, true);
1632 JSONDecoder::decode_json("name", name
, obj
, true);
1633 JSONDecoder::decode_json("domain", domain
, obj
);
1636 void rgw::keystone::TokenEnvelope::User::decode_json(JSONObj
*obj
)
1638 JSONDecoder::decode_json("id", id
, obj
, true);
1639 JSONDecoder::decode_json("name", name
, obj
, true);
1640 JSONDecoder::decode_json("domain", domain
, obj
);
1641 JSONDecoder::decode_json("roles", roles_v2
, obj
);
1644 void rgw::keystone::TokenEnvelope::decode_v3(JSONObj
* const root_obj
)
1646 std::string expires_iso8601
;
1648 JSONDecoder::decode_json("user", user
, root_obj
, true);
1649 JSONDecoder::decode_json("expires_at", expires_iso8601
, root_obj
, true);
1650 JSONDecoder::decode_json("roles", roles
, root_obj
, true);
1651 JSONDecoder::decode_json("project", project
, root_obj
, true);
1654 if (parse_iso8601(expires_iso8601
.c_str(), &t
)) {
1655 token
.expires
= internal_timegm(&t
);
1658 throw JSONDecoder::err("Failed to parse ISO8601 expiration date"
1659 "from Keystone response.");
1663 void rgw::keystone::TokenEnvelope::decode_v2(JSONObj
* const root_obj
)
1665 JSONDecoder::decode_json("user", user
, root_obj
, true);
1666 JSONDecoder::decode_json("token", token
, root_obj
, true);
1668 roles
= user
.roles_v2
;
1669 project
= token
.tenant_v2
;
1672 void rgw_slo_entry::decode_json(JSONObj
*obj
)
1674 JSONDecoder::decode_json("path", path
, obj
);
1675 JSONDecoder::decode_json("etag", etag
, obj
);
1676 JSONDecoder::decode_json("size_bytes", size_bytes
, obj
);
1679 void rgw_meta_sync_info::decode_json(JSONObj
*obj
)
1682 JSONDecoder::decode_json("status", s
, obj
);
1685 } else if (s
== "building-full-sync-maps") {
1686 state
= StateBuildingFullSyncMaps
;
1687 } else if (s
== "sync") {
1690 JSONDecoder::decode_json("num_shards", num_shards
, obj
);
1691 JSONDecoder::decode_json("period", period
, obj
);
1692 JSONDecoder::decode_json("realm_epoch", realm_epoch
, obj
);
1695 void rgw_meta_sync_info::dump(Formatter
*f
) const
1698 switch ((SyncState
)state
) {
1702 case StateBuildingFullSyncMaps
:
1703 s
= "building-full-sync-maps";
1712 encode_json("status", s
, f
);
1713 encode_json("num_shards", num_shards
, f
);
1714 encode_json("period", period
, f
);
1715 encode_json("realm_epoch", realm_epoch
, f
);
1718 void rgw_meta_sync_marker::decode_json(JSONObj
*obj
)
1721 JSONDecoder::decode_json("state", s
, obj
);
1723 JSONDecoder::decode_json("marker", marker
, obj
);
1724 JSONDecoder::decode_json("next_step_marker", next_step_marker
, obj
);
1725 JSONDecoder::decode_json("total_entries", total_entries
, obj
);
1726 JSONDecoder::decode_json("pos", pos
, obj
);
1728 JSONDecoder::decode_json("timestamp", ut
, obj
);
1729 timestamp
= ut
.to_real_time();
1730 JSONDecoder::decode_json("realm_epoch", realm_epoch
, obj
);
1733 void rgw_meta_sync_marker::dump(Formatter
*f
) const
1735 encode_json("state", (int)state
, f
);
1736 encode_json("marker", marker
, f
);
1737 encode_json("next_step_marker", next_step_marker
, f
);
1738 encode_json("total_entries", total_entries
, f
);
1739 encode_json("pos", pos
, f
);
1740 encode_json("timestamp", utime_t(timestamp
), f
);
1741 encode_json("realm_epoch", realm_epoch
, f
);
1744 void rgw_meta_sync_status::decode_json(JSONObj
*obj
)
1746 JSONDecoder::decode_json("info", sync_info
, obj
);
1747 JSONDecoder::decode_json("markers", sync_markers
, obj
);
1750 void rgw_meta_sync_status::dump(Formatter
*f
) const {
1751 encode_json("info", sync_info
, f
);
1752 encode_json("markers", sync_markers
, f
);
1755 void rgw_sync_error_info::dump(Formatter
*f
) const {
1756 encode_json("source_zone", source_zone
, f
);
1757 encode_json("error_code", error_code
, f
);
1758 encode_json("message", message
, f
);
1761 void rgw_bucket_shard_full_sync_marker::decode_json(JSONObj
*obj
)
1763 JSONDecoder::decode_json("position", position
, obj
);
1764 JSONDecoder::decode_json("count", count
, obj
);
1767 void rgw_bucket_shard_full_sync_marker::dump(Formatter
*f
) const
1769 encode_json("position", position
, f
);
1770 encode_json("count", count
, f
);
1773 void rgw_bucket_shard_inc_sync_marker::decode_json(JSONObj
*obj
)
1775 JSONDecoder::decode_json("position", position
, obj
);
1776 JSONDecoder::decode_json("timestamp", timestamp
, obj
);
1779 void rgw_bucket_shard_inc_sync_marker::dump(Formatter
*f
) const
1781 encode_json("position", position
, f
);
1782 encode_json("timestamp", timestamp
, f
);
1785 void rgw_bucket_shard_sync_info::decode_json(JSONObj
*obj
)
1788 JSONDecoder::decode_json("status", s
, obj
);
1789 if (s
== "full-sync") {
1790 state
= StateFullSync
;
1791 } else if (s
== "incremental-sync") {
1792 state
= StateIncrementalSync
;
1793 } else if (s
== "stopped") {
1794 state
= StateStopped
;
1798 JSONDecoder::decode_json("full_marker", full_marker
, obj
);
1799 JSONDecoder::decode_json("inc_marker", inc_marker
, obj
);
1802 void rgw_bucket_shard_sync_info::dump(Formatter
*f
) const
1804 const char *s
{nullptr};
1805 switch ((SyncState
)state
) {
1812 case StateIncrementalSync
:
1813 s
= "incremental-sync";
1822 encode_json("status", s
, f
);
1823 encode_json("full_marker", full_marker
, f
);
1824 encode_json("inc_marker", inc_marker
, f
);
1827 /* This utility function shouldn't conflict with the overload of std::to_string
1828 * provided by string_ref since Boost 1.54 as it's defined outside of the std
1829 * namespace. I hope we'll remove it soon - just after merging the Matt's PR
1830 * for bundled Boost. It would allow us to forget that CentOS 7 has Boost 1.53. */
1831 static inline std::string
to_string(const std::string_view
& s
)
1833 return std::string(s
.data(), s
.length());
1836 void rgw::keystone::AdminTokenRequestVer2::dump(Formatter
* const f
) const
1838 f
->open_object_section("token_request");
1839 f
->open_object_section("auth");
1840 f
->open_object_section("passwordCredentials");
1841 encode_json("username", ::to_string(conf
.get_admin_user()), f
);
1842 encode_json("password", ::to_string(conf
.get_admin_password()), f
);
1844 encode_json("tenantName", ::to_string(conf
.get_admin_tenant()), f
);
1849 void rgw::keystone::AdminTokenRequestVer3::dump(Formatter
* const f
) const
1851 f
->open_object_section("token_request");
1852 f
->open_object_section("auth");
1853 f
->open_object_section("identity");
1854 f
->open_array_section("methods");
1855 f
->dump_string("", "password");
1857 f
->open_object_section("password");
1858 f
->open_object_section("user");
1859 f
->open_object_section("domain");
1860 encode_json("name", ::to_string(conf
.get_admin_domain()), f
);
1862 encode_json("name", ::to_string(conf
.get_admin_user()), f
);
1863 encode_json("password", ::to_string(conf
.get_admin_password()), f
);
1867 f
->open_object_section("scope");
1868 f
->open_object_section("project");
1869 if (! conf
.get_admin_project().empty()) {
1870 encode_json("name", ::to_string(conf
.get_admin_project()), f
);
1872 encode_json("name", ::to_string(conf
.get_admin_tenant()), f
);
1874 f
->open_object_section("domain");
1875 encode_json("name", ::to_string(conf
.get_admin_domain()), f
);
1884 void rgw::keystone::BarbicanTokenRequestVer2::dump(Formatter
* const f
) const
1886 f
->open_object_section("token_request");
1887 f
->open_object_section("auth");
1888 f
->open_object_section("passwordCredentials");
1889 encode_json("username", cct
->_conf
->rgw_keystone_barbican_user
, f
);
1890 encode_json("password", cct
->_conf
->rgw_keystone_barbican_password
, f
);
1892 encode_json("tenantName", cct
->_conf
->rgw_keystone_barbican_tenant
, f
);
1897 void rgw::keystone::BarbicanTokenRequestVer3::dump(Formatter
* const f
) const
1899 f
->open_object_section("token_request");
1900 f
->open_object_section("auth");
1901 f
->open_object_section("identity");
1902 f
->open_array_section("methods");
1903 f
->dump_string("", "password");
1905 f
->open_object_section("password");
1906 f
->open_object_section("user");
1907 f
->open_object_section("domain");
1908 encode_json("name", cct
->_conf
->rgw_keystone_barbican_domain
, f
);
1910 encode_json("name", cct
->_conf
->rgw_keystone_barbican_user
, f
);
1911 encode_json("password", cct
->_conf
->rgw_keystone_barbican_password
, f
);
1915 f
->open_object_section("scope");
1916 f
->open_object_section("project");
1917 if (!cct
->_conf
->rgw_keystone_barbican_project
.empty()) {
1918 encode_json("name", cct
->_conf
->rgw_keystone_barbican_project
, f
);
1920 encode_json("name", cct
->_conf
->rgw_keystone_barbican_tenant
, f
);
1922 f
->open_object_section("domain");
1923 encode_json("name", cct
->_conf
->rgw_keystone_barbican_domain
, f
);
1931 void RGWOrphanSearchStage::dump(Formatter
*f
) const
1933 f
->open_object_section("orphan_search_stage");
1936 case ORPHAN_SEARCH_STAGE_INIT
:
1939 case ORPHAN_SEARCH_STAGE_LSPOOL
:
1942 case ORPHAN_SEARCH_STAGE_LSBUCKETS
:
1945 case ORPHAN_SEARCH_STAGE_ITERATE_BI
:
1946 s
= "iterate_bucket_index";
1948 case ORPHAN_SEARCH_STAGE_COMPARE
:
1954 f
->dump_string("search_stage", s
);
1955 f
->dump_int("shard",shard
);
1956 f
->dump_string("marker",marker
);
1960 void RGWOrphanSearchInfo::dump(Formatter
*f
) const
1962 f
->open_object_section("orphan_search_info");
1963 f
->dump_string("job_name", job_name
);
1964 encode_json("pool", pool
, f
);
1965 f
->dump_int("num_shards", num_shards
);
1966 encode_json("start_time", start_time
, f
);
1970 void RGWOrphanSearchState::dump(Formatter
*f
) const
1972 f
->open_object_section("orphan_search_state");
1973 encode_json("info", info
, f
);
1974 encode_json("stage", stage
, f
);
1978 void RGWObjTags::dump(Formatter
*f
) const
1980 f
->open_object_section("tagset");
1981 for (auto& tag
: tag_map
){
1982 f
->dump_string(tag
.first
.c_str(), tag
.second
);
1987 void lc_op::dump(Formatter
*f
) const
1989 f
->dump_bool("status", status
);
1990 f
->dump_bool("dm_expiration", dm_expiration
);
1992 f
->dump_int("expiration", expiration
);
1993 f
->dump_int("noncur_expiration", noncur_expiration
);
1994 f
->dump_int("mp_expiration", mp_expiration
);
1995 if (expiration_date
) {
1996 utime_t
ut(*expiration_date
);
1997 f
->dump_stream("expiration_date") << ut
;
2000 f
->dump_object("obj_tags", *obj_tags
);
2002 f
->open_object_section("transitions");
2003 for(auto& [storage_class
, transition
] : transitions
) {
2004 f
->dump_object(storage_class
, transition
);
2008 f
->open_object_section("noncur_transitions");
2009 for (auto& [storage_class
, transition
] : noncur_transitions
) {
2010 f
->dump_object(storage_class
, transition
);
2015 void LCFilter::dump(Formatter
*f
) const
2017 f
->dump_string("prefix", prefix
);
2018 f
->dump_object("obj_tags", obj_tags
);
2021 void LCExpiration::dump(Formatter
*f
) const
2023 f
->dump_string("days", days
);
2024 f
->dump_string("date", date
);
2027 void LCRule::dump(Formatter
*f
) const
2029 f
->dump_string("id", id
);
2030 f
->dump_string("prefix", prefix
);
2031 f
->dump_string("status", status
);
2032 f
->dump_object("expiration", expiration
);
2033 f
->dump_object("noncur_expiration", noncur_expiration
);
2034 f
->dump_object("mp_expiration", mp_expiration
);
2035 f
->dump_object("filter", filter
);
2036 f
->open_object_section("transitions");
2037 for (auto& [storage_class
, transition
] : transitions
) {
2038 f
->dump_object(storage_class
, transition
);
2042 f
->open_object_section("noncur_transitions");
2043 for (auto& [storage_class
, transition
] : noncur_transitions
) {
2044 f
->dump_object(storage_class
, transition
);
2047 f
->dump_bool("dm_expiration", dm_expiration
);
2050 void RGWLifecycleConfiguration::dump(Formatter
*f
) const
2052 f
->open_object_section("prefix_map");
2053 for (auto& prefix
: prefix_map
) {
2054 f
->dump_object(prefix
.first
.c_str(), prefix
.second
);
2058 f
->open_array_section("rule_map");
2059 for (auto& rule
: rule_map
) {
2060 f
->open_object_section("entry");
2061 f
->dump_string("id", rule
.first
);
2062 f
->open_object_section("rule");
2063 rule
.second
.dump(f
);
2070 void compression_block::dump(Formatter
*f
) const
2072 f
->dump_unsigned("old_ofs", old_ofs
);
2073 f
->dump_unsigned("new_ofs", new_ofs
);
2074 f
->dump_unsigned("len", len
);
2077 void RGWCompressionInfo::dump(Formatter
*f
) const
2079 f
->dump_string("compression_type", compression_type
);
2080 f
->dump_unsigned("orig_size", orig_size
);
2081 if (compressor_message
) {
2082 f
->dump_int("compressor_message", *compressor_message
);
2084 ::encode_json("blocks", blocks
, f
);
2087 void objexp_hint_entry::dump(Formatter
*f
) const
2089 f
->open_object_section("objexp_hint_entry");
2090 encode_json("tenant", tenant
, f
);
2091 encode_json("bucket_name", bucket_name
, f
);
2092 encode_json("bucket_id", bucket_id
, f
);
2093 encode_json("rgw_obj_key", obj_key
, f
);
2094 utime_t
ut(exp_time
);
2095 encode_json("exp_time", ut
, f
);
2099 void rgw_user::dump(Formatter
*f
) const
2101 ::encode_json("user", *this, f
);