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"
9 #include "rgw_acl_s3.h"
10 #include "rgw_cache.h"
11 #include "rgw_bucket.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 f
->dump_object("begin_iter", begin_iter
);
147 f
->dump_object("end_iter", end_iter
);
150 void rgw_log_entry::dump(Formatter
*f
) const
152 f
->dump_string("object_owner", object_owner
.to_str());
153 f
->dump_string("bucket_owner", bucket_owner
.to_str());
154 f
->dump_string("bucket", bucket
);
155 f
->dump_stream("time") << time
;
156 f
->dump_string("remote_addr", remote_addr
);
157 f
->dump_string("user", user
);
160 f
->dump_string("obj", s
.str());
161 f
->dump_string("op", op
);
162 f
->dump_string("uri", uri
);
163 f
->dump_string("http_status", http_status
);
164 f
->dump_string("error_code", error_code
);
165 f
->dump_unsigned("bytes_sent", bytes_sent
);
166 f
->dump_unsigned("bytes_received", bytes_received
);
167 f
->dump_unsigned("obj_size", obj_size
);
168 f
->dump_stream("total_time") << total_time
;
169 f
->dump_string("user_agent", user_agent
);
170 f
->dump_string("referrer", referrer
);
171 f
->dump_string("bucket_id", bucket_id
);
172 f
->dump_string("trans_id", trans_id
);
175 void ACLPermission::dump(Formatter
*f
) const
177 f
->dump_int("flags", flags
);
180 void ACLGranteeType::dump(Formatter
*f
) const
182 f
->dump_unsigned("type", type
);
185 void ACLGrant::dump(Formatter
*f
) const
187 f
->open_object_section("type");
191 f
->dump_string("id", id
.to_str());
192 f
->dump_string("email", email
);
194 f
->open_object_section("permission");
198 f
->dump_string("name", name
);
199 f
->dump_int("group", (int)group
);
200 f
->dump_string("url_spec", url_spec
);
203 void RGWAccessControlList::dump(Formatter
*f
) const
205 map
<string
, int>::const_iterator acl_user_iter
= acl_user_map
.begin();
206 f
->open_array_section("acl_user_map");
207 for (; acl_user_iter
!= acl_user_map
.end(); ++acl_user_iter
) {
208 f
->open_object_section("entry");
209 f
->dump_string("user", acl_user_iter
->first
);
210 f
->dump_int("acl", acl_user_iter
->second
);
215 map
<uint32_t, int>::const_iterator acl_group_iter
= acl_group_map
.begin();
216 f
->open_array_section("acl_group_map");
217 for (; acl_group_iter
!= acl_group_map
.end(); ++acl_group_iter
) {
218 f
->open_object_section("entry");
219 f
->dump_unsigned("group", acl_group_iter
->first
);
220 f
->dump_int("acl", acl_group_iter
->second
);
225 multimap
<string
, ACLGrant
>::const_iterator giter
= grant_map
.begin();
226 f
->open_array_section("grant_map");
227 for (; giter
!= grant_map
.end(); ++giter
) {
228 f
->open_object_section("entry");
229 f
->dump_string("id", giter
->first
);
230 f
->open_object_section("grant");
231 giter
->second
.dump(f
);
238 void ACLOwner::dump(Formatter
*f
) const
240 encode_json("id", id
.to_str(), f
);
241 encode_json("display_name", display_name
, f
);
244 void ACLOwner::decode_json(JSONObj
*obj
) {
246 JSONDecoder::decode_json("id", id_str
, obj
);
248 JSONDecoder::decode_json("display_name", display_name
, obj
);
251 void RGWAccessControlPolicy::dump(Formatter
*f
) const
253 encode_json("acl", acl
, f
);
254 encode_json("owner", owner
, f
);
257 void ObjectMetaInfo::dump(Formatter
*f
) const
259 encode_json("size", size
, f
);
260 encode_json("mtime", utime_t(mtime
), f
);
263 void ObjectCacheInfo::dump(Formatter
*f
) const
265 encode_json("status", status
, f
);
266 encode_json("flags", flags
, f
);
267 encode_json("data", data
, f
);
268 encode_json_map("xattrs", "name", "value", "length", xattrs
, f
);
269 encode_json_map("rm_xattrs", "name", "value", "length", rm_xattrs
, f
);
270 encode_json("meta", meta
, f
);
274 void RGWCacheNotifyInfo::dump(Formatter
*f
) const
276 encode_json("op", op
, f
);
277 encode_json("obj", obj
, f
);
278 encode_json("obj_info", obj_info
, f
);
279 encode_json("ofs", ofs
, f
);
280 encode_json("ns", ns
, f
);
283 void RGWAccessKey::dump(Formatter
*f
) const
285 encode_json("access_key", id
, f
);
286 encode_json("secret_key", key
, f
);
287 encode_json("subuser", subuser
, f
);
290 void RGWAccessKey::dump_plain(Formatter
*f
) const
292 encode_json("access_key", id
, f
);
293 encode_json("secret_key", key
, f
);
296 void encode_json_plain(const char *name
, const RGWAccessKey
& val
, Formatter
*f
)
298 f
->open_object_section(name
);
303 void RGWAccessKey::dump(Formatter
*f
, const string
& user
, bool swift
) const
306 if (!subuser
.empty()) {
310 encode_json("user", u
, f
);
312 encode_json("access_key", id
, f
);
314 encode_json("secret_key", key
, f
);
317 void RGWAccessKey::decode_json(JSONObj
*obj
) {
318 JSONDecoder::decode_json("access_key", id
, obj
, true);
319 JSONDecoder::decode_json("secret_key", key
, obj
, true);
320 if (!JSONDecoder::decode_json("subuser", subuser
, obj
)) {
322 JSONDecoder::decode_json("user", user
, obj
);
323 int pos
= user
.find(':');
325 subuser
= user
.substr(pos
+ 1);
330 void RGWAccessKey::decode_json(JSONObj
*obj
, bool swift
) {
336 if (!JSONDecoder::decode_json("subuser", subuser
, obj
)) {
337 JSONDecoder::decode_json("user", id
, obj
, true);
338 int pos
= id
.find(':');
340 subuser
= id
.substr(pos
+ 1);
343 JSONDecoder::decode_json("secret_key", key
, obj
, true);
346 struct rgw_flags_desc
{
351 static struct rgw_flags_desc rgw_perms
[] = {
352 { RGW_PERM_FULL_CONTROL
, "full-control" },
353 { RGW_PERM_READ
| RGW_PERM_WRITE
, "read-write" },
354 { RGW_PERM_READ
, "read" },
355 { RGW_PERM_WRITE
, "write" },
356 { RGW_PERM_READ_ACP
, "read-acp" },
357 { RGW_PERM_WRITE_ACP
, "write-acp" },
362 static void mask_to_str(T
*mask_list
, uint32_t mask
, char *buf
, int len
)
364 const char *sep
= "";
367 snprintf(buf
, len
, "<none>");
371 uint32_t orig_mask
= mask
;
372 for (int i
= 0; mask_list
[i
].mask
; i
++) {
373 T
*desc
= &mask_list
[i
];
374 if ((mask
& desc
->mask
) == desc
->mask
) {
375 pos
+= snprintf(buf
+ pos
, len
- pos
, "%s%s", sep
, desc
->str
);
384 if (mask
== orig_mask
) // no change
389 static void perm_to_str(uint32_t mask
, char *buf
, int len
)
391 return mask_to_str(rgw_perms
, mask
, buf
, len
);
394 static struct rgw_flags_desc op_type_flags
[] = {
395 { RGW_OP_TYPE_READ
, "read" },
396 { RGW_OP_TYPE_WRITE
, "write" },
397 { RGW_OP_TYPE_DELETE
, "delete" },
401 extern void op_type_to_str(uint32_t mask
, char *buf
, int len
)
403 return mask_to_str(op_type_flags
, mask
, buf
, len
);
406 void RGWSubUser::dump(Formatter
*f
) const
408 encode_json("id", name
, f
);
410 perm_to_str(perm_mask
, buf
, sizeof(buf
));
411 encode_json("permissions", (const char *)buf
, f
);
414 void RGWSubUser::dump(Formatter
*f
, const string
& user
) const
419 encode_json("id", s
, f
);
421 perm_to_str(perm_mask
, buf
, sizeof(buf
));
422 encode_json("permissions", (const char *)buf
, f
);
425 static uint32_t str_to_perm(const string
& s
)
427 if (s
.compare("read") == 0)
428 return RGW_PERM_READ
;
429 else if (s
.compare("write") == 0)
430 return RGW_PERM_WRITE
;
431 else if (s
.compare("read-write") == 0)
432 return RGW_PERM_READ
| RGW_PERM_WRITE
;
433 else if (s
.compare("full-control") == 0)
434 return RGW_PERM_FULL_CONTROL
;
438 void RGWSubUser::decode_json(JSONObj
*obj
)
441 JSONDecoder::decode_json("id", uid
, obj
);
442 int pos
= uid
.find(':');
444 name
= uid
.substr(pos
+ 1);
446 JSONDecoder::decode_json("permissions", perm_str
, obj
);
447 perm_mask
= str_to_perm(perm_str
);
450 static void user_info_dump_subuser(const char *name
, const RGWSubUser
& subuser
, Formatter
*f
, void *parent
)
452 RGWUserInfo
*info
= static_cast<RGWUserInfo
*>(parent
);
453 subuser
.dump(f
, info
->user_id
.to_str());
456 static void user_info_dump_key(const char *name
, const RGWAccessKey
& key
, Formatter
*f
, void *parent
)
458 RGWUserInfo
*info
= static_cast<RGWUserInfo
*>(parent
);
459 key
.dump(f
, info
->user_id
.to_str(), false);
462 static void user_info_dump_swift_key(const char *name
, const RGWAccessKey
& key
, Formatter
*f
, void *parent
)
464 RGWUserInfo
*info
= static_cast<RGWUserInfo
*>(parent
);
465 key
.dump(f
, info
->user_id
.to_str(), true);
468 void RGWUserInfo::dump(Formatter
*f
) const
471 encode_json("user_id", user_id
.to_str(), f
);
472 encode_json("display_name", display_name
, f
);
473 encode_json("email", user_email
, f
);
474 encode_json("suspended", (int)suspended
, f
);
475 encode_json("max_buckets", (int)max_buckets
, f
);
477 encode_json_map("subusers", NULL
, "subuser", NULL
, user_info_dump_subuser
,(void *)this, subusers
, f
);
478 encode_json_map("keys", NULL
, "key", NULL
, user_info_dump_key
,(void *)this, access_keys
, f
);
479 encode_json_map("swift_keys", NULL
, "key", NULL
, user_info_dump_swift_key
,(void *)this, swift_keys
, f
);
481 encode_json("caps", caps
, f
);
484 op_type_to_str(op_mask
, buf
, sizeof(buf
));
485 encode_json("op_mask", (const char *)buf
, f
);
487 if (system
) { /* no need to show it for every user */
488 encode_json("system", (bool)system
, f
);
491 encode_json("admin", (bool)admin
, f
);
493 encode_json("default_placement", default_placement
.name
, f
);
494 encode_json("default_storage_class", default_placement
.storage_class
, f
);
495 encode_json("placement_tags", placement_tags
, f
);
496 encode_json("bucket_quota", bucket_quota
, f
);
497 encode_json("user_quota", user_quota
, f
);
498 encode_json("temp_url_keys", temp_url_keys
, f
);
500 string user_source_type
;
501 switch ((RGWIdentityType
)type
) {
503 user_source_type
= "rgw";
506 user_source_type
= "keystone";
509 user_source_type
= "ldap";
512 user_source_type
= "none";
515 user_source_type
= "none";
518 encode_json("type", user_source_type
, f
);
519 encode_json("mfa_ids", mfa_ids
, f
);
523 static void decode_access_keys(map
<string
, RGWAccessKey
>& m
, JSONObj
*o
)
530 static void decode_swift_keys(map
<string
, RGWAccessKey
>& m
, JSONObj
*o
)
533 k
.decode_json(o
, true);
537 static void decode_subusers(map
<string
, RGWSubUser
>& m
, JSONObj
*o
)
544 void RGWUserInfo::decode_json(JSONObj
*obj
)
548 JSONDecoder::decode_json("user_id", uid
, obj
, true);
549 user_id
.from_str(uid
);
551 JSONDecoder::decode_json("display_name", display_name
, obj
);
552 JSONDecoder::decode_json("email", user_email
, obj
);
554 JSONDecoder::decode_json("suspended", susp
, obj
);
555 suspended
= (__u8
)susp
;
556 JSONDecoder::decode_json("max_buckets", max_buckets
, obj
);
558 JSONDecoder::decode_json("keys", access_keys
, decode_access_keys
, obj
);
559 JSONDecoder::decode_json("swift_keys", swift_keys
, decode_swift_keys
, obj
);
560 JSONDecoder::decode_json("subusers", subusers
, decode_subusers
, obj
);
562 JSONDecoder::decode_json("caps", caps
, obj
);
565 JSONDecoder::decode_json("op_mask", mask_str
, obj
);
566 rgw_parse_op_type_list(mask_str
, &op_mask
);
569 JSONDecoder::decode_json("system", sys
, obj
);
572 JSONDecoder::decode_json("admin", ad
, obj
);
574 JSONDecoder::decode_json("default_placement", default_placement
.name
, obj
);
575 JSONDecoder::decode_json("default_storage_class", default_placement
.storage_class
, obj
);
576 JSONDecoder::decode_json("placement_tags", placement_tags
, obj
);
577 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
578 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
579 JSONDecoder::decode_json("temp_url_keys", temp_url_keys
, obj
);
581 string user_source_type
;
582 JSONDecoder::decode_json("type", user_source_type
, obj
);
583 if (user_source_type
== "rgw") {
585 } else if (user_source_type
== "keystone") {
586 type
= TYPE_KEYSTONE
;
587 } else if (user_source_type
== "ldap") {
589 } else if (user_source_type
== "none") {
592 JSONDecoder::decode_json("mfa_ids", mfa_ids
, obj
);
595 void RGWQuotaInfo::dump(Formatter
*f
) const
597 f
->dump_bool("enabled", enabled
);
598 f
->dump_bool("check_on_raw", check_on_raw
);
600 f
->dump_int("max_size", max_size
);
601 f
->dump_int("max_size_kb", rgw_rounded_kb(max_size
));
602 f
->dump_int("max_objects", max_objects
);
605 void RGWQuotaInfo::decode_json(JSONObj
*obj
)
607 if (false == JSONDecoder::decode_json("max_size", max_size
, obj
)) {
608 /* We're parsing an older version of the struct. */
609 int64_t max_size_kb
= 0;
611 JSONDecoder::decode_json("max_size_kb", max_size_kb
, obj
);
612 max_size
= max_size_kb
* 1024;
614 JSONDecoder::decode_json("max_objects", max_objects
, obj
);
616 JSONDecoder::decode_json("check_on_raw", check_on_raw
, obj
);
617 JSONDecoder::decode_json("enabled", enabled
, obj
);
620 void rgw_data_placement_target::dump(Formatter
*f
) const
622 encode_json("data_pool", data_pool
, f
);
623 encode_json("data_extra_pool", data_extra_pool
, f
);
624 encode_json("index_pool", index_pool
, f
);
627 void rgw_data_placement_target::decode_json(JSONObj
*obj
) {
628 JSONDecoder::decode_json("data_pool", data_pool
, obj
);
629 JSONDecoder::decode_json("data_extra_pool", data_extra_pool
, obj
);
630 JSONDecoder::decode_json("index_pool", index_pool
, obj
);
633 void rgw_bucket::dump(Formatter
*f
) const
635 encode_json("name", name
, f
);
636 encode_json("marker", marker
, f
);
637 encode_json("bucket_id", bucket_id
, f
);
638 encode_json("tenant", tenant
, f
);
639 encode_json("explicit_placement", explicit_placement
, f
);
642 void rgw_bucket::decode_json(JSONObj
*obj
) {
643 JSONDecoder::decode_json("name", name
, obj
);
644 JSONDecoder::decode_json("marker", marker
, obj
);
645 JSONDecoder::decode_json("bucket_id", bucket_id
, obj
);
646 JSONDecoder::decode_json("tenant", tenant
, obj
);
647 JSONDecoder::decode_json("explicit_placement", explicit_placement
, obj
);
648 if (explicit_placement
.data_pool
.empty()) {
649 /* decoding old format */
650 JSONDecoder::decode_json("pool", explicit_placement
.data_pool
, obj
);
651 JSONDecoder::decode_json("data_extra_pool", explicit_placement
.data_extra_pool
, obj
);
652 JSONDecoder::decode_json("index_pool", explicit_placement
.index_pool
, obj
);
656 void RGWBucketEntryPoint::dump(Formatter
*f
) const
658 encode_json("bucket", bucket
, f
);
659 encode_json("owner", owner
, f
);
660 utime_t
ut(creation_time
);
661 encode_json("creation_time", ut
, f
);
662 encode_json("linked", linked
, f
);
663 encode_json("has_bucket_info", has_bucket_info
, f
);
664 if (has_bucket_info
) {
665 encode_json("old_bucket_info", old_bucket_info
, f
);
669 void RGWBucketEntryPoint::decode_json(JSONObj
*obj
) {
670 JSONDecoder::decode_json("bucket", bucket
, obj
);
671 JSONDecoder::decode_json("owner", owner
, obj
);
673 JSONDecoder::decode_json("creation_time", ut
, obj
);
674 creation_time
= ut
.to_real_time();
675 JSONDecoder::decode_json("linked", linked
, obj
);
676 JSONDecoder::decode_json("has_bucket_info", has_bucket_info
, obj
);
677 if (has_bucket_info
) {
678 JSONDecoder::decode_json("old_bucket_info", old_bucket_info
, obj
);
682 void RGWStorageStats::dump(Formatter
*f
) const
684 encode_json("size", size
, f
);
685 encode_json("size_actual", size_rounded
, f
);
686 encode_json("size_utilized", size_utilized
, f
);
687 encode_json("size_kb", rgw_rounded_kb(size
), f
);
688 encode_json("size_kb_actual", rgw_rounded_kb(size_rounded
), f
);
689 encode_json("size_kb_utilized", rgw_rounded_kb(size_utilized
), f
);
690 encode_json("num_objects", num_objects
, f
);
693 void RGWRedirectInfo::dump(Formatter
*f
) const
695 encode_json("protocol", protocol
, f
);
696 encode_json("hostname", hostname
, f
);
697 encode_json("http_redirect_code", (int)http_redirect_code
, f
);
700 void RGWRedirectInfo::decode_json(JSONObj
*obj
) {
701 JSONDecoder::decode_json("protocol", protocol
, obj
);
702 JSONDecoder::decode_json("hostname", hostname
, obj
);
704 JSONDecoder::decode_json("http_redirect_code", code
, obj
);
705 http_redirect_code
= code
;
708 void RGWBWRedirectInfo::dump(Formatter
*f
) const
710 encode_json("redirect", redirect
, f
);
711 encode_json("replace_key_prefix_with", replace_key_prefix_with
, f
);
712 encode_json("replace_key_with", replace_key_with
, f
);
715 void RGWBWRedirectInfo::decode_json(JSONObj
*obj
) {
716 JSONDecoder::decode_json("redirect", redirect
, obj
);
717 JSONDecoder::decode_json("replace_key_prefix_with", replace_key_prefix_with
, obj
);
718 JSONDecoder::decode_json("replace_key_with", replace_key_with
, obj
);
721 void RGWBWRoutingRuleCondition::dump(Formatter
*f
) const
723 encode_json("key_prefix_equals", key_prefix_equals
, f
);
724 encode_json("http_error_code_returned_equals", (int)http_error_code_returned_equals
, f
);
727 void RGWBWRoutingRuleCondition::decode_json(JSONObj
*obj
) {
728 JSONDecoder::decode_json("key_prefix_equals", key_prefix_equals
, obj
);
730 JSONDecoder::decode_json("http_error_code_returned_equals", code
, obj
);
731 http_error_code_returned_equals
= code
;
734 void RGWBWRoutingRule::dump(Formatter
*f
) const
736 encode_json("condition", condition
, f
);
737 encode_json("redirect_info", redirect_info
, f
);
740 void RGWBWRoutingRule::decode_json(JSONObj
*obj
) {
741 JSONDecoder::decode_json("condition", condition
, obj
);
742 JSONDecoder::decode_json("redirect_info", redirect_info
, obj
);
745 void RGWBWRoutingRules::dump(Formatter
*f
) const
747 encode_json("rules", rules
, f
);
750 void RGWBWRoutingRules::decode_json(JSONObj
*obj
) {
751 JSONDecoder::decode_json("rules", rules
, obj
);
754 void RGWBucketWebsiteConf::dump(Formatter
*f
) const
756 if (!redirect_all
.hostname
.empty()) {
757 encode_json("redirect_all", redirect_all
, f
);
759 encode_json("index_doc_suffix", index_doc_suffix
, f
);
760 encode_json("error_doc", error_doc
, f
);
761 encode_json("routing_rules", routing_rules
, f
);
765 void RGWBucketWebsiteConf::decode_json(JSONObj
*obj
) {
766 JSONDecoder::decode_json("redirect_all", redirect_all
, obj
);
767 JSONDecoder::decode_json("index_doc_suffix", index_doc_suffix
, obj
);
768 JSONDecoder::decode_json("error_doc", error_doc
, obj
);
769 JSONDecoder::decode_json("routing_rules", routing_rules
, obj
);
772 void RGWBucketInfo::dump(Formatter
*f
) const
774 encode_json("bucket", bucket
, f
);
775 utime_t
ut(creation_time
);
776 encode_json("creation_time", ut
, f
);
777 encode_json("owner", owner
.to_str(), f
);
778 encode_json("flags", flags
, f
);
779 encode_json("zonegroup", zonegroup
, f
);
780 encode_json("placement_rule", placement_rule
, f
);
781 encode_json("has_instance_obj", has_instance_obj
, f
);
782 encode_json("quota", quota
, f
);
783 encode_json("num_shards", num_shards
, f
);
784 encode_json("bi_shard_hash_type", (uint32_t)bucket_index_shard_hash_type
, f
);
785 encode_json("requester_pays", requester_pays
, f
);
786 encode_json("has_website", has_website
, f
);
788 encode_json("website_conf", website_conf
, f
);
790 encode_json("swift_versioning", swift_versioning
, f
);
791 encode_json("swift_ver_location", swift_ver_location
, f
);
792 encode_json("index_type", (uint32_t)index_type
, f
);
793 encode_json("mdsearch_config", mdsearch_config
, f
);
794 encode_json("reshard_status", (int)reshard_status
, f
);
795 encode_json("new_bucket_instance_id", new_bucket_instance_id
, f
);
796 if (!empty_sync_policy()) {
797 encode_json("sync_policy", *sync_policy
, f
);
801 void RGWBucketInfo::decode_json(JSONObj
*obj
) {
802 JSONDecoder::decode_json("bucket", bucket
, obj
);
804 JSONDecoder::decode_json("creation_time", ut
, obj
);
805 creation_time
= ut
.to_real_time();
806 JSONDecoder::decode_json("owner", owner
, obj
);
807 JSONDecoder::decode_json("flags", flags
, obj
);
808 JSONDecoder::decode_json("zonegroup", zonegroup
, obj
);
809 /* backward compatability with region */
810 if (zonegroup
.empty()) {
811 JSONDecoder::decode_json("region", zonegroup
, obj
);
814 JSONDecoder::decode_json("placement_rule", pr
, obj
);
815 placement_rule
.from_str(pr
);
816 JSONDecoder::decode_json("has_instance_obj", has_instance_obj
, obj
);
817 JSONDecoder::decode_json("quota", quota
, obj
);
818 JSONDecoder::decode_json("num_shards", num_shards
, obj
);
820 JSONDecoder::decode_json("bi_shard_hash_type", hash_type
, obj
);
821 bucket_index_shard_hash_type
= (uint8_t)hash_type
;
822 JSONDecoder::decode_json("requester_pays", requester_pays
, obj
);
823 JSONDecoder::decode_json("has_website", has_website
, obj
);
825 JSONDecoder::decode_json("website_conf", website_conf
, obj
);
827 JSONDecoder::decode_json("swift_versioning", swift_versioning
, obj
);
828 JSONDecoder::decode_json("swift_ver_location", swift_ver_location
, obj
);
830 JSONDecoder::decode_json("index_type", it
, obj
);
831 index_type
= (RGWBucketIndexType
)it
;
832 JSONDecoder::decode_json("mdsearch_config", mdsearch_config
, obj
);
834 JSONDecoder::decode_json("reshard_status", rs
, obj
);
835 reshard_status
= (cls_rgw_reshard_status
)rs
;
837 rgw_sync_policy_info sp
;
838 JSONDecoder::decode_json("sync_policy", sp
, obj
);
840 set_sync_policy(std::move(sp
));
844 void rgw_sync_directional_rule::dump(Formatter
*f
) const
846 encode_json("source_zone", source_zone
, f
);
847 encode_json("dest_zone", dest_zone
, f
);
850 void rgw_sync_directional_rule::decode_json(JSONObj
*obj
)
852 JSONDecoder::decode_json("source_zone", source_zone
, obj
);
853 JSONDecoder::decode_json("dest_zone", dest_zone
, obj
);
856 void rgw_sync_symmetric_group::dump(Formatter
*f
) const
858 encode_json("id", id
, f
);
859 encode_json("zones", zones
, f
);
862 void rgw_sync_symmetric_group::decode_json(JSONObj
*obj
)
864 JSONDecoder::decode_json("id", id
, obj
);
865 JSONDecoder::decode_json("zones", zones
, obj
);
868 void rgw_sync_bucket_entity::dump(Formatter
*f
) const
870 encode_json("zone", zone
, f
);
871 encode_json("bucket", bucket_key(), f
);
874 void rgw_sync_bucket_entity::decode_json(JSONObj
*obj
)
876 JSONDecoder::decode_json("zone", zone
, obj
);
878 if (JSONDecoder::decode_json("bucket", s
, obj
)) {
880 int ret
= rgw_bucket_parse_bucket_key(nullptr, s
, &b
, nullptr);
889 void rgw_sync_pipe_filter_tag::dump(Formatter
*f
) const
891 encode_json("key", key
, f
);
892 encode_json("value", value
, f
);
895 void rgw_sync_pipe_filter_tag::decode_json(JSONObj
*obj
)
897 JSONDecoder::decode_json("key", key
, obj
);
898 JSONDecoder::decode_json("value", value
, obj
);
901 void rgw_sync_pipe_filter::dump(Formatter
*f
) const
903 encode_json("prefix", prefix
, f
);
904 encode_json("tags", tags
, f
);
907 void rgw_sync_pipe_filter::decode_json(JSONObj
*obj
)
909 JSONDecoder::decode_json("prefix", prefix
, obj
);
910 JSONDecoder::decode_json("tags", tags
, obj
);
913 void rgw_sync_pipe_acl_translation::dump(Formatter
*f
) const
915 encode_json("owner", owner
, f
);
918 void rgw_sync_pipe_acl_translation::decode_json(JSONObj
*obj
)
920 JSONDecoder::decode_json("owner", owner
, obj
);
923 void rgw_sync_pipe_source_params::dump(Formatter
*f
) const
925 encode_json("filter", filter
, f
);
928 void rgw_sync_pipe_source_params::decode_json(JSONObj
*obj
)
930 JSONDecoder::decode_json("filter", filter
, obj
);
933 void rgw_sync_pipe_dest_params::dump(Formatter
*f
) const
935 encode_json("acl_translation", acl_translation
, f
);
936 encode_json("storage_class", storage_class
, f
);
939 void rgw_sync_pipe_dest_params::decode_json(JSONObj
*obj
)
941 JSONDecoder::decode_json("acl_translation", acl_translation
, obj
);
942 JSONDecoder::decode_json("storage_class", storage_class
, obj
);
945 void rgw_sync_pipe_params::dump(Formatter
*f
) const
947 encode_json("source", source
, f
);
948 encode_json("dest", dest
, f
);
949 encode_json("priority", priority
, f
);
958 encode_json("mode", s
, f
);
959 encode_json("user", user
, f
);
962 void rgw_sync_pipe_params::decode_json(JSONObj
*obj
)
964 JSONDecoder::decode_json("source", source
, obj
);
965 JSONDecoder::decode_json("dest", dest
, obj
);
966 JSONDecoder::decode_json("priority", priority
, obj
);
968 JSONDecoder::decode_json("mode", s
, obj
);
974 JSONDecoder::decode_json("user", user
, obj
);
978 void rgw_sync_bucket_entities::dump(Formatter
*f
) const
980 encode_json("bucket", rgw_sync_bucket_entities::bucket_key(bucket
), f
);
982 encode_json("zones", zones
, f
);
983 } else if (all_zones
) {
984 set
<string
> z
= { "*" };
985 encode_json("zones", z
, f
);
989 void rgw_sync_bucket_entities::decode_json(JSONObj
*obj
)
992 JSONDecoder::decode_json("bucket", s
, obj
);
997 int ret
= rgw_bucket_parse_bucket_key(nullptr, s
, &b
, nullptr);
1001 if (b
.tenant
== "*") {
1004 if (b
.name
== "*") {
1007 if (b
.bucket_id
== "*") {
1008 b
.bucket_id
.clear();
1013 JSONDecoder::decode_json("zones", zones
, obj
);
1014 if (zones
&& zones
->size() == 1) {
1015 auto iter
= zones
->begin();
1023 void rgw_sync_bucket_pipe::dump(Formatter
*f
) const
1025 encode_json("id", id
, f
);
1026 encode_json("source", source
, f
);
1027 encode_json("dest", dest
, f
);
1028 encode_json("params", params
, f
);
1031 void rgw_sync_bucket_pipe::decode_json(JSONObj
*obj
)
1033 JSONDecoder::decode_json("id", id
, obj
);
1034 JSONDecoder::decode_json("source", source
, obj
);
1035 JSONDecoder::decode_json("dest", dest
, obj
);
1036 JSONDecoder::decode_json("params", params
, obj
);
1039 void rgw_sync_bucket_pipes::dump(Formatter
*f
) const
1041 encode_json("id", id
, f
);
1042 encode_json("source", source
, f
);
1043 encode_json("dest", dest
, f
);
1044 encode_json("params", params
, f
);
1047 void rgw_sync_bucket_pipes::decode_json(JSONObj
*obj
)
1049 JSONDecoder::decode_json("id", id
, obj
);
1050 JSONDecoder::decode_json("source", source
, obj
);
1051 JSONDecoder::decode_json("dest", dest
, obj
);
1052 JSONDecoder::decode_json("params", params
, obj
);
1055 void rgw_sync_data_flow_group::dump(Formatter
*f
) const
1057 if (!symmetrical
.empty()) {
1058 encode_json("symmetrical", symmetrical
, f
);
1061 if (!directional
.empty()) {
1062 encode_json("directional", directional
, f
);
1066 void rgw_sync_data_flow_group::decode_json(JSONObj
*obj
)
1068 JSONDecoder::decode_json("symmetrical", symmetrical
, obj
);
1069 JSONDecoder::decode_json("directional", directional
, obj
);
1072 void rgw_sync_policy_group::dump(Formatter
*f
) const
1074 encode_json("id", id
, f
);
1075 encode_json("data_flow", data_flow
, f
);
1076 encode_json("pipes", pipes
, f
);
1079 case rgw_sync_policy_group::Status::FORBIDDEN
:
1082 case rgw_sync_policy_group::Status::ALLOWED
:
1085 case rgw_sync_policy_group::Status::ENABLED
:
1091 encode_json("status", s
, f
);
1094 void rgw_sync_policy_group::decode_json(JSONObj
*obj
)
1096 JSONDecoder::decode_json("id", id
, obj
);
1097 JSONDecoder::decode_json("data_flow", data_flow
, obj
);
1098 JSONDecoder::decode_json("pipes", pipes
, obj
);
1100 JSONDecoder::decode_json("status", s
, obj
);
1104 void rgw_sync_policy_info::dump(Formatter
*f
) const
1106 Formatter::ArraySection
section(*f
, "groups");
1107 for (auto& group
: groups
) {
1108 encode_json("group", group
.second
, f
);
1112 void rgw_sync_policy_info::decode_json(JSONObj
*obj
)
1114 vector
<rgw_sync_policy_group
> groups_vec
;
1116 JSONDecoder::decode_json("groups", groups_vec
, obj
);
1118 for (auto& group
: groups_vec
) {
1119 groups
.emplace(std::make_pair(group
.id
, std::move(group
)));
1123 void rgw_obj_key::dump(Formatter
*f
) const
1125 encode_json("name", name
, f
);
1126 encode_json("instance", instance
, f
);
1127 encode_json("ns", ns
, f
);
1130 void rgw_obj_key::decode_json(JSONObj
*obj
)
1132 JSONDecoder::decode_json("name", name
, obj
);
1133 JSONDecoder::decode_json("instance", instance
, obj
);
1134 JSONDecoder::decode_json("ns", ns
, obj
);
1137 void RGWBucketEnt::dump(Formatter
*f
) const
1139 encode_json("bucket", bucket
, f
);
1140 encode_json("size", size
, f
);
1141 encode_json("size_rounded", size_rounded
, f
);
1142 utime_t
ut(creation_time
);
1143 encode_json("mtime", ut
, f
); /* mtime / creation time discrepency needed for backward compatibility */
1144 encode_json("count", count
, f
);
1145 encode_json("placement_rule", placement_rule
.to_str(), f
);
1148 void RGWUploadPartInfo::dump(Formatter
*f
) const
1150 encode_json("num", num
, f
);
1151 encode_json("size", size
, f
);
1152 encode_json("etag", etag
, f
);
1153 utime_t
ut(modified
);
1154 encode_json("modified", ut
, f
);
1157 void rgw_raw_obj::dump(Formatter
*f
) const
1159 encode_json("pool", pool
, f
);
1160 encode_json("oid", oid
, f
);
1161 encode_json("loc", loc
, f
);
1164 void rgw_raw_obj::decode_json(JSONObj
*obj
) {
1165 JSONDecoder::decode_json("pool", pool
, obj
);
1166 JSONDecoder::decode_json("oid", oid
, obj
);
1167 JSONDecoder::decode_json("loc", loc
, obj
);
1170 void rgw_obj::dump(Formatter
*f
) const
1172 encode_json("bucket", bucket
, f
);
1173 encode_json("key", key
, f
);
1176 void RGWDefaultSystemMetaObjInfo::dump(Formatter
*f
) const {
1177 encode_json("default_id", default_id
, f
);
1180 void RGWDefaultSystemMetaObjInfo::decode_json(JSONObj
*obj
) {
1181 JSONDecoder::decode_json("default_id", default_id
, obj
);
1184 void RGWNameToId::dump(Formatter
*f
) const {
1185 encode_json("obj_id", obj_id
, f
);
1188 void RGWNameToId::decode_json(JSONObj
*obj
) {
1189 JSONDecoder::decode_json("obj_id", obj_id
, obj
);
1192 void RGWSystemMetaObj::dump(Formatter
*f
) const
1194 encode_json("id", id
, f
);
1195 encode_json("name", name
, f
);
1198 void RGWSystemMetaObj::decode_json(JSONObj
*obj
)
1200 JSONDecoder::decode_json("id", id
, obj
);
1201 JSONDecoder::decode_json("name", name
, obj
);
1204 void RGWPeriodLatestEpochInfo::dump(Formatter
*f
) const {
1205 encode_json("latest_epoch", epoch
, f
);
1208 void RGWPeriodLatestEpochInfo::decode_json(JSONObj
*obj
) {
1209 JSONDecoder::decode_json("latest_epoch", epoch
, obj
);
1212 void RGWPeriod::dump(Formatter
*f
) const
1214 encode_json("id", id
, f
);
1215 encode_json("epoch", epoch
, f
);
1216 encode_json("predecessor_uuid", predecessor_uuid
, f
);
1217 encode_json("sync_status", sync_status
, f
);
1218 encode_json("period_map", period_map
, f
);
1219 encode_json("master_zonegroup", master_zonegroup
, f
);
1220 encode_json("master_zone", master_zone
, f
);
1221 encode_json("period_config", period_config
, f
);
1222 encode_json("realm_id", realm_id
, f
);
1223 encode_json("realm_name", realm_name
, f
);
1224 encode_json("realm_epoch", realm_epoch
, f
);
1227 void RGWPeriod::decode_json(JSONObj
*obj
)
1229 JSONDecoder::decode_json("id", id
, obj
);
1230 JSONDecoder::decode_json("epoch", epoch
, obj
);
1231 JSONDecoder::decode_json("predecessor_uuid", predecessor_uuid
, obj
);
1232 JSONDecoder::decode_json("sync_status", sync_status
, obj
);
1233 JSONDecoder::decode_json("period_map", period_map
, obj
);
1234 JSONDecoder::decode_json("master_zonegroup", master_zonegroup
, obj
);
1235 JSONDecoder::decode_json("master_zone", master_zone
, obj
);
1236 JSONDecoder::decode_json("period_config", period_config
, obj
);
1237 JSONDecoder::decode_json("realm_id", realm_id
, obj
);
1238 JSONDecoder::decode_json("realm_name", realm_name
, obj
);
1239 JSONDecoder::decode_json("realm_epoch", realm_epoch
, obj
);
1242 void RGWZoneParams::dump(Formatter
*f
) const
1244 RGWSystemMetaObj::dump(f
);
1245 encode_json("domain_root", domain_root
, f
);
1246 encode_json("control_pool", control_pool
, f
);
1247 encode_json("gc_pool", gc_pool
, f
);
1248 encode_json("lc_pool", lc_pool
, f
);
1249 encode_json("log_pool", log_pool
, f
);
1250 encode_json("intent_log_pool", intent_log_pool
, f
);
1251 encode_json("usage_log_pool", usage_log_pool
, f
);
1252 encode_json("roles_pool", roles_pool
, f
);
1253 encode_json("reshard_pool", reshard_pool
, f
);
1254 encode_json("user_keys_pool", user_keys_pool
, f
);
1255 encode_json("user_email_pool", user_email_pool
, f
);
1256 encode_json("user_swift_pool", user_swift_pool
, f
);
1257 encode_json("user_uid_pool", user_uid_pool
, f
);
1258 encode_json("otp_pool", otp_pool
, f
);
1259 encode_json_plain("system_key", system_key
, f
);
1260 encode_json("placement_pools", placement_pools
, f
);
1261 encode_json("tier_config", tier_config
, f
);
1262 encode_json("realm_id", realm_id
, f
);
1265 void RGWZoneStorageClass::dump(Formatter
*f
) const
1268 encode_json("data_pool", data_pool
.get(), f
);
1270 if (compression_type
) {
1271 encode_json("compression_type", compression_type
.get(), f
);
1275 void RGWZoneStorageClass::decode_json(JSONObj
*obj
)
1277 JSONDecoder::decode_json("data_pool", data_pool
, obj
);
1278 JSONDecoder::decode_json("compression_type", compression_type
, obj
);
1281 void RGWZoneStorageClasses::dump(Formatter
*f
) const
1284 encode_json(i
.first
.c_str(), i
.second
, f
);
1288 void RGWZoneStorageClasses::decode_json(JSONObj
*obj
)
1291 decode_json_obj(f
, obj
);
1293 for (auto& field
: f
.object()) {
1294 JSONObj
*field_obj
= obj
->find_obj(field
.first
);
1297 decode_json_obj(m
[field
.first
], field_obj
);
1299 standard_class
= &m
[RGW_STORAGE_CLASS_STANDARD
];
1302 void RGWZonePlacementInfo::dump(Formatter
*f
) const
1304 encode_json("index_pool", index_pool
, f
);
1305 encode_json("storage_classes", storage_classes
, f
);
1306 encode_json("data_extra_pool", data_extra_pool
, f
);
1307 encode_json("index_type", (uint32_t)index_type
, f
);
1309 /* no real need for backward compatibility of compression_type and data_pool in here,
1310 * rather not clutter the output */
1313 void RGWZonePlacementInfo::decode_json(JSONObj
*obj
)
1315 JSONDecoder::decode_json("index_pool", index_pool
, obj
);
1316 JSONDecoder::decode_json("storage_classes", storage_classes
, obj
);
1317 JSONDecoder::decode_json("data_extra_pool", data_extra_pool
, obj
);
1319 JSONDecoder::decode_json("index_type", it
, obj
);
1320 index_type
= (RGWBucketIndexType
)it
;
1322 /* backward compatibility, these are now defined in storage_classes */
1323 string standard_compression_type
;
1324 string
*pcompression
= nullptr;
1325 if (JSONDecoder::decode_json("compression", standard_compression_type
, obj
)) {
1326 pcompression
= &standard_compression_type
;
1328 rgw_pool standard_data_pool
;
1329 rgw_pool
*ppool
= nullptr;
1330 if (JSONDecoder::decode_json("data_pool", standard_data_pool
, obj
)) {
1331 ppool
= &standard_data_pool
;
1333 if (ppool
|| pcompression
) {
1334 storage_classes
.set_storage_class(RGW_STORAGE_CLASS_STANDARD
, ppool
, pcompression
);
1338 void RGWZoneParams::decode_json(JSONObj
*obj
)
1340 RGWSystemMetaObj::decode_json(obj
);
1341 JSONDecoder::decode_json("domain_root", domain_root
, obj
);
1342 JSONDecoder::decode_json("control_pool", control_pool
, obj
);
1343 JSONDecoder::decode_json("gc_pool", gc_pool
, obj
);
1344 JSONDecoder::decode_json("lc_pool", lc_pool
, obj
);
1345 JSONDecoder::decode_json("log_pool", log_pool
, obj
);
1346 JSONDecoder::decode_json("intent_log_pool", intent_log_pool
, obj
);
1347 JSONDecoder::decode_json("roles_pool", roles_pool
, obj
);
1348 JSONDecoder::decode_json("reshard_pool", reshard_pool
, obj
);
1349 JSONDecoder::decode_json("usage_log_pool", usage_log_pool
, obj
);
1350 JSONDecoder::decode_json("user_keys_pool", user_keys_pool
, obj
);
1351 JSONDecoder::decode_json("user_email_pool", user_email_pool
, obj
);
1352 JSONDecoder::decode_json("user_swift_pool", user_swift_pool
, obj
);
1353 JSONDecoder::decode_json("user_uid_pool", user_uid_pool
, obj
);
1354 JSONDecoder::decode_json("otp_pool", otp_pool
, obj
);
1355 JSONDecoder::decode_json("system_key", system_key
, obj
);
1356 JSONDecoder::decode_json("placement_pools", placement_pools
, obj
);
1357 JSONDecoder::decode_json("tier_config", tier_config
, obj
);
1358 JSONDecoder::decode_json("realm_id", realm_id
, obj
);
1362 void RGWZone::dump(Formatter
*f
) const
1364 encode_json("id", id
, f
);
1365 encode_json("name", name
, f
);
1366 encode_json("endpoints", endpoints
, f
);
1367 encode_json("log_meta", log_meta
, f
);
1368 encode_json("log_data", log_data
, f
);
1369 encode_json("bucket_index_max_shards", bucket_index_max_shards
, f
);
1370 encode_json("read_only", read_only
, f
);
1371 encode_json("tier_type", tier_type
, f
);
1372 encode_json("sync_from_all", sync_from_all
, f
);
1373 encode_json("sync_from", sync_from
, f
);
1374 encode_json("redirect_zone", redirect_zone
, f
);
1377 void RGWZone::decode_json(JSONObj
*obj
)
1379 JSONDecoder::decode_json("id", id
, obj
);
1380 JSONDecoder::decode_json("name", name
, obj
);
1384 JSONDecoder::decode_json("endpoints", endpoints
, obj
);
1385 JSONDecoder::decode_json("log_meta", log_meta
, obj
);
1386 JSONDecoder::decode_json("log_data", log_data
, obj
);
1387 JSONDecoder::decode_json("bucket_index_max_shards", bucket_index_max_shards
, obj
);
1388 JSONDecoder::decode_json("read_only", read_only
, obj
);
1389 JSONDecoder::decode_json("tier_type", tier_type
, obj
);
1390 JSONDecoder::decode_json("sync_from_all", sync_from_all
, true, obj
);
1391 JSONDecoder::decode_json("sync_from", sync_from
, obj
);
1392 JSONDecoder::decode_json("redirect_zone", redirect_zone
, obj
);
1395 void RGWZoneGroupPlacementTarget::dump(Formatter
*f
) const
1397 encode_json("name", name
, f
);
1398 encode_json("tags", tags
, f
);
1399 encode_json("storage_classes", storage_classes
, f
);
1402 void RGWZoneGroupPlacementTarget::decode_json(JSONObj
*obj
)
1404 JSONDecoder::decode_json("name", name
, obj
);
1405 JSONDecoder::decode_json("tags", tags
, obj
);
1406 JSONDecoder::decode_json("storage_classes", storage_classes
, obj
);
1407 if (storage_classes
.empty()) {
1408 storage_classes
.insert(RGW_STORAGE_CLASS_STANDARD
);
1412 void RGWZoneGroup::dump(Formatter
*f
) const
1414 RGWSystemMetaObj::dump(f
);
1415 encode_json("api_name", api_name
, f
);
1416 encode_json("is_master", is_master
, f
);
1417 encode_json("endpoints", endpoints
, f
);
1418 encode_json("hostnames", hostnames
, f
);
1419 encode_json("hostnames_s3website", hostnames_s3website
, f
);
1420 encode_json("master_zone", master_zone
, f
);
1421 encode_json_map("zones", zones
, f
); /* more friendly representation */
1422 encode_json_map("placement_targets", placement_targets
, f
); /* more friendly representation */
1423 encode_json("default_placement", default_placement
, f
);
1424 encode_json("realm_id", realm_id
, f
);
1425 encode_json("sync_policy", sync_policy
, f
);
1428 static void decode_zones(map
<rgw_zone_id
, RGWZone
>& zones
, JSONObj
*o
)
1435 static void decode_placement_targets(map
<string
, RGWZoneGroupPlacementTarget
>& targets
, JSONObj
*o
)
1437 RGWZoneGroupPlacementTarget t
;
1439 targets
[t
.name
] = t
;
1443 void RGWZoneGroup::decode_json(JSONObj
*obj
)
1445 RGWSystemMetaObj::decode_json(obj
);
1447 derr
<< "old format " << dendl
;
1448 JSONDecoder::decode_json("name", name
, obj
);
1451 JSONDecoder::decode_json("api_name", api_name
, obj
);
1452 JSONDecoder::decode_json("is_master", is_master
, obj
);
1453 JSONDecoder::decode_json("endpoints", endpoints
, obj
);
1454 JSONDecoder::decode_json("hostnames", hostnames
, obj
);
1455 JSONDecoder::decode_json("hostnames_s3website", hostnames_s3website
, obj
);
1456 JSONDecoder::decode_json("master_zone", master_zone
, obj
);
1457 JSONDecoder::decode_json("zones", zones
, decode_zones
, obj
);
1458 JSONDecoder::decode_json("placement_targets", placement_targets
, decode_placement_targets
, obj
);
1459 JSONDecoder::decode_json("default_placement", default_placement
.name
, obj
);
1460 JSONDecoder::decode_json("default_storage_class", default_placement
.storage_class
, obj
);
1461 JSONDecoder::decode_json("realm_id", realm_id
, obj
);
1462 JSONDecoder::decode_json("sync_policy", sync_policy
, obj
);
1466 void RGWPeriodMap::dump(Formatter
*f
) const
1468 encode_json("id", id
, f
);
1469 encode_json_map("zonegroups", zonegroups
, f
);
1470 encode_json("short_zone_ids", short_zone_ids
, f
);
1473 static void decode_zonegroups(map
<string
, RGWZoneGroup
>& zonegroups
, JSONObj
*o
)
1477 zonegroups
[zg
.get_id()] = zg
;
1480 void RGWPeriodMap::decode_json(JSONObj
*obj
)
1482 JSONDecoder::decode_json("id", id
, obj
);
1483 JSONDecoder::decode_json("zonegroups", zonegroups
, decode_zonegroups
, obj
);
1484 /* backward compatability with region */
1485 if (zonegroups
.empty()) {
1486 JSONDecoder::decode_json("regions", zonegroups
, obj
);
1488 /* backward compatability with region */
1489 if (master_zonegroup
.empty()) {
1490 JSONDecoder::decode_json("master_region", master_zonegroup
, obj
);
1492 JSONDecoder::decode_json("short_zone_ids", short_zone_ids
, obj
);
1496 void RGWPeriodConfig::dump(Formatter
*f
) const
1498 encode_json("bucket_quota", bucket_quota
, f
);
1499 encode_json("user_quota", user_quota
, f
);
1502 void RGWPeriodConfig::decode_json(JSONObj
*obj
)
1504 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
1505 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
1508 void RGWRegionMap::dump(Formatter
*f
) const
1510 encode_json("regions", regions
, f
);
1511 encode_json("master_region", master_region
, f
);
1512 encode_json("bucket_quota", bucket_quota
, f
);
1513 encode_json("user_quota", user_quota
, f
);
1516 void RGWRegionMap::decode_json(JSONObj
*obj
)
1518 JSONDecoder::decode_json("regions", regions
, obj
);
1519 JSONDecoder::decode_json("master_region", master_region
, obj
);
1520 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
1521 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
1524 void RGWZoneGroupMap::dump(Formatter
*f
) const
1526 encode_json("zonegroups", zonegroups
, f
);
1527 encode_json("master_zonegroup", master_zonegroup
, f
);
1528 encode_json("bucket_quota", bucket_quota
, f
);
1529 encode_json("user_quota", user_quota
, f
);
1532 void RGWZoneGroupMap::decode_json(JSONObj
*obj
)
1534 JSONDecoder::decode_json("zonegroups", zonegroups
, obj
);
1535 /* backward compatability with region */
1536 if (zonegroups
.empty()) {
1537 JSONDecoder::decode_json("regions", zonegroups
, obj
);
1539 JSONDecoder::decode_json("master_zonegroup", master_zonegroup
, obj
);
1540 /* backward compatability with region */
1541 if (master_zonegroup
.empty()) {
1542 JSONDecoder::decode_json("master_region", master_zonegroup
, obj
);
1545 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
1546 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
1549 void RGWMetadataLogInfo::dump(Formatter
*f
) const
1551 encode_json("marker", marker
, f
);
1552 utime_t
ut(last_update
);
1553 encode_json("last_update", ut
, f
);
1556 void RGWMetadataLogInfo::decode_json(JSONObj
*obj
)
1558 JSONDecoder::decode_json("marker", marker
, obj
);
1560 JSONDecoder::decode_json("last_update", ut
, obj
);
1561 last_update
= ut
.to_real_time();
1564 void RGWDataChangesLogInfo::dump(Formatter
*f
) const
1566 encode_json("marker", marker
, f
);
1567 utime_t
ut(last_update
);
1568 encode_json("last_update", ut
, f
);
1571 void RGWDataChangesLogInfo::decode_json(JSONObj
*obj
)
1573 JSONDecoder::decode_json("marker", marker
, obj
);
1575 JSONDecoder::decode_json("last_update", ut
, obj
);
1576 last_update
= ut
.to_real_time();
1580 void RGWRealm::dump(Formatter
*f
) const
1582 RGWSystemMetaObj::dump(f
);
1583 encode_json("current_period", current_period
, f
);
1584 encode_json("epoch", epoch
, f
);
1588 void RGWRealm::decode_json(JSONObj
*obj
)
1590 RGWSystemMetaObj::decode_json(obj
);
1591 JSONDecoder::decode_json("current_period", current_period
, obj
);
1592 JSONDecoder::decode_json("epoch", epoch
, obj
);
1595 void rgw::keystone::TokenEnvelope::Token::decode_json(JSONObj
*obj
)
1597 string expires_iso8601
;
1600 JSONDecoder::decode_json("id", id
, obj
, true);
1601 JSONDecoder::decode_json("tenant", tenant_v2
, obj
, true);
1602 JSONDecoder::decode_json("expires", expires_iso8601
, obj
, true);
1604 if (parse_iso8601(expires_iso8601
.c_str(), &t
)) {
1605 expires
= internal_timegm(&t
);
1608 throw JSONDecoder::err("Failed to parse ISO8601 expiration date from Keystone response.");
1612 void rgw::keystone::TokenEnvelope::Role::decode_json(JSONObj
*obj
)
1614 JSONDecoder::decode_json("id", id
, obj
);
1615 JSONDecoder::decode_json("name", name
, obj
, true);
1618 void rgw::keystone::TokenEnvelope::Domain::decode_json(JSONObj
*obj
)
1620 JSONDecoder::decode_json("id", id
, obj
, true);
1621 JSONDecoder::decode_json("name", name
, obj
, true);
1624 void rgw::keystone::TokenEnvelope::Project::decode_json(JSONObj
*obj
)
1626 JSONDecoder::decode_json("id", id
, obj
, true);
1627 JSONDecoder::decode_json("name", name
, obj
, true);
1628 JSONDecoder::decode_json("domain", domain
, obj
);
1631 void rgw::keystone::TokenEnvelope::User::decode_json(JSONObj
*obj
)
1633 JSONDecoder::decode_json("id", id
, obj
, true);
1634 JSONDecoder::decode_json("name", name
, obj
, true);
1635 JSONDecoder::decode_json("domain", domain
, obj
);
1636 JSONDecoder::decode_json("roles", roles_v2
, obj
);
1639 void rgw::keystone::TokenEnvelope::decode_v3(JSONObj
* const root_obj
)
1641 std::string expires_iso8601
;
1643 JSONDecoder::decode_json("user", user
, root_obj
, true);
1644 JSONDecoder::decode_json("expires_at", expires_iso8601
, root_obj
, true);
1645 JSONDecoder::decode_json("roles", roles
, root_obj
, true);
1646 JSONDecoder::decode_json("project", project
, root_obj
, true);
1649 if (parse_iso8601(expires_iso8601
.c_str(), &t
)) {
1650 token
.expires
= internal_timegm(&t
);
1653 throw JSONDecoder::err("Failed to parse ISO8601 expiration date"
1654 "from Keystone response.");
1658 void rgw::keystone::TokenEnvelope::decode_v2(JSONObj
* const root_obj
)
1660 JSONDecoder::decode_json("user", user
, root_obj
, true);
1661 JSONDecoder::decode_json("token", token
, root_obj
, true);
1663 roles
= user
.roles_v2
;
1664 project
= token
.tenant_v2
;
1667 void rgw_slo_entry::decode_json(JSONObj
*obj
)
1669 JSONDecoder::decode_json("path", path
, obj
);
1670 JSONDecoder::decode_json("etag", etag
, obj
);
1671 JSONDecoder::decode_json("size_bytes", size_bytes
, obj
);
1674 void rgw_meta_sync_info::decode_json(JSONObj
*obj
)
1677 JSONDecoder::decode_json("status", s
, obj
);
1680 } else if (s
== "building-full-sync-maps") {
1681 state
= StateBuildingFullSyncMaps
;
1682 } else if (s
== "sync") {
1685 JSONDecoder::decode_json("num_shards", num_shards
, obj
);
1686 JSONDecoder::decode_json("period", period
, obj
);
1687 JSONDecoder::decode_json("realm_epoch", realm_epoch
, obj
);
1690 void rgw_meta_sync_info::dump(Formatter
*f
) const
1693 switch ((SyncState
)state
) {
1697 case StateBuildingFullSyncMaps
:
1698 s
= "building-full-sync-maps";
1707 encode_json("status", s
, f
);
1708 encode_json("num_shards", num_shards
, f
);
1709 encode_json("period", period
, f
);
1710 encode_json("realm_epoch", realm_epoch
, f
);
1713 void rgw_meta_sync_marker::decode_json(JSONObj
*obj
)
1716 JSONDecoder::decode_json("state", s
, obj
);
1718 JSONDecoder::decode_json("marker", marker
, obj
);
1719 JSONDecoder::decode_json("next_step_marker", next_step_marker
, obj
);
1720 JSONDecoder::decode_json("total_entries", total_entries
, obj
);
1721 JSONDecoder::decode_json("pos", pos
, obj
);
1723 JSONDecoder::decode_json("timestamp", ut
, obj
);
1724 timestamp
= ut
.to_real_time();
1725 JSONDecoder::decode_json("realm_epoch", realm_epoch
, obj
);
1728 void rgw_meta_sync_marker::dump(Formatter
*f
) const
1730 encode_json("state", (int)state
, f
);
1731 encode_json("marker", marker
, f
);
1732 encode_json("next_step_marker", next_step_marker
, f
);
1733 encode_json("total_entries", total_entries
, f
);
1734 encode_json("pos", pos
, f
);
1735 encode_json("timestamp", utime_t(timestamp
), f
);
1736 encode_json("realm_epoch", realm_epoch
, f
);
1739 void rgw_meta_sync_status::decode_json(JSONObj
*obj
)
1741 JSONDecoder::decode_json("info", sync_info
, obj
);
1742 JSONDecoder::decode_json("markers", sync_markers
, obj
);
1745 void rgw_meta_sync_status::dump(Formatter
*f
) const {
1746 encode_json("info", sync_info
, f
);
1747 encode_json("markers", sync_markers
, f
);
1750 void rgw_sync_error_info::dump(Formatter
*f
) const {
1751 encode_json("source_zone", source_zone
, f
);
1752 encode_json("error_code", error_code
, f
);
1753 encode_json("message", message
, f
);
1756 void rgw_bucket_shard_full_sync_marker::decode_json(JSONObj
*obj
)
1758 JSONDecoder::decode_json("position", position
, obj
);
1759 JSONDecoder::decode_json("count", count
, obj
);
1762 void rgw_bucket_shard_full_sync_marker::dump(Formatter
*f
) const
1764 encode_json("position", position
, f
);
1765 encode_json("count", count
, f
);
1768 void rgw_bucket_shard_inc_sync_marker::decode_json(JSONObj
*obj
)
1770 JSONDecoder::decode_json("position", position
, obj
);
1773 void rgw_bucket_shard_inc_sync_marker::dump(Formatter
*f
) const
1775 encode_json("position", position
, f
);
1778 void rgw_bucket_shard_sync_info::decode_json(JSONObj
*obj
)
1781 JSONDecoder::decode_json("status", s
, obj
);
1782 if (s
== "full-sync") {
1783 state
= StateFullSync
;
1784 } else if (s
== "incremental-sync") {
1785 state
= StateIncrementalSync
;
1786 } else if (s
== "stopped") {
1787 state
= StateStopped
;
1791 JSONDecoder::decode_json("full_marker", full_marker
, obj
);
1792 JSONDecoder::decode_json("inc_marker", inc_marker
, obj
);
1795 void rgw_bucket_shard_sync_info::dump(Formatter
*f
) const
1797 const char *s
{nullptr};
1798 switch ((SyncState
)state
) {
1805 case StateIncrementalSync
:
1806 s
= "incremental-sync";
1815 encode_json("status", s
, f
);
1816 encode_json("full_marker", full_marker
, f
);
1817 encode_json("inc_marker", inc_marker
, f
);
1820 /* This utility function shouldn't conflict with the overload of std::to_string
1821 * provided by string_ref since Boost 1.54 as it's defined outside of the std
1822 * namespace. I hope we'll remove it soon - just after merging the Matt's PR
1823 * for bundled Boost. It would allow us to forget that CentOS 7 has Boost 1.53. */
1824 static inline std::string
to_string(const boost::string_ref
& s
)
1826 return std::string(s
.data(), s
.length());
1829 void rgw::keystone::AdminTokenRequestVer2::dump(Formatter
* const f
) const
1831 f
->open_object_section("token_request");
1832 f
->open_object_section("auth");
1833 f
->open_object_section("passwordCredentials");
1834 encode_json("username", ::to_string(conf
.get_admin_user()), f
);
1835 encode_json("password", ::to_string(conf
.get_admin_password()), f
);
1837 encode_json("tenantName", ::to_string(conf
.get_admin_tenant()), f
);
1842 void rgw::keystone::AdminTokenRequestVer3::dump(Formatter
* const f
) const
1844 f
->open_object_section("token_request");
1845 f
->open_object_section("auth");
1846 f
->open_object_section("identity");
1847 f
->open_array_section("methods");
1848 f
->dump_string("", "password");
1850 f
->open_object_section("password");
1851 f
->open_object_section("user");
1852 f
->open_object_section("domain");
1853 encode_json("name", ::to_string(conf
.get_admin_domain()), f
);
1855 encode_json("name", ::to_string(conf
.get_admin_user()), f
);
1856 encode_json("password", ::to_string(conf
.get_admin_password()), f
);
1860 f
->open_object_section("scope");
1861 f
->open_object_section("project");
1862 if (! conf
.get_admin_project().empty()) {
1863 encode_json("name", ::to_string(conf
.get_admin_project()), f
);
1865 encode_json("name", ::to_string(conf
.get_admin_tenant()), f
);
1867 f
->open_object_section("domain");
1868 encode_json("name", ::to_string(conf
.get_admin_domain()), f
);
1877 void rgw::keystone::BarbicanTokenRequestVer2::dump(Formatter
* const f
) const
1879 f
->open_object_section("token_request");
1880 f
->open_object_section("auth");
1881 f
->open_object_section("passwordCredentials");
1882 encode_json("username", cct
->_conf
->rgw_keystone_barbican_user
, f
);
1883 encode_json("password", cct
->_conf
->rgw_keystone_barbican_password
, f
);
1885 encode_json("tenantName", cct
->_conf
->rgw_keystone_barbican_tenant
, f
);
1890 void rgw::keystone::BarbicanTokenRequestVer3::dump(Formatter
* const f
) const
1892 f
->open_object_section("token_request");
1893 f
->open_object_section("auth");
1894 f
->open_object_section("identity");
1895 f
->open_array_section("methods");
1896 f
->dump_string("", "password");
1898 f
->open_object_section("password");
1899 f
->open_object_section("user");
1900 f
->open_object_section("domain");
1901 encode_json("name", cct
->_conf
->rgw_keystone_barbican_domain
, f
);
1903 encode_json("name", cct
->_conf
->rgw_keystone_barbican_user
, f
);
1904 encode_json("password", cct
->_conf
->rgw_keystone_barbican_password
, f
);
1908 f
->open_object_section("scope");
1909 f
->open_object_section("project");
1910 if (!cct
->_conf
->rgw_keystone_barbican_project
.empty()) {
1911 encode_json("name", cct
->_conf
->rgw_keystone_barbican_project
, f
);
1913 encode_json("name", cct
->_conf
->rgw_keystone_barbican_tenant
, f
);
1915 f
->open_object_section("domain");
1916 encode_json("name", cct
->_conf
->rgw_keystone_barbican_domain
, f
);
1924 void RGWOrphanSearchStage::dump(Formatter
*f
) const
1926 f
->open_object_section("orphan_search_stage");
1929 case ORPHAN_SEARCH_STAGE_INIT
:
1932 case ORPHAN_SEARCH_STAGE_LSPOOL
:
1935 case ORPHAN_SEARCH_STAGE_LSBUCKETS
:
1938 case ORPHAN_SEARCH_STAGE_ITERATE_BI
:
1939 s
= "iterate_bucket_index";
1941 case ORPHAN_SEARCH_STAGE_COMPARE
:
1947 f
->dump_string("search_stage", s
);
1948 f
->dump_int("shard",shard
);
1949 f
->dump_string("marker",marker
);
1953 void RGWOrphanSearchInfo::dump(Formatter
*f
) const
1955 f
->open_object_section("orphan_search_info");
1956 f
->dump_string("job_name", job_name
);
1957 encode_json("pool", pool
, f
);
1958 f
->dump_int("num_shards", num_shards
);
1959 encode_json("start_time", start_time
, f
);
1963 void RGWOrphanSearchState::dump(Formatter
*f
) const
1965 f
->open_object_section("orphan_search_state");
1966 encode_json("info", info
, f
);
1967 encode_json("stage", stage
, f
);
1971 void RGWObjTags::dump(Formatter
*f
) const
1973 f
->open_object_section("tagset");
1974 for (auto& tag
: tag_map
){
1975 f
->dump_string(tag
.first
.c_str(), tag
.second
);
1980 void lc_op::dump(Formatter
*f
) const
1982 f
->dump_bool("status", status
);
1983 f
->dump_bool("dm_expiration", dm_expiration
);
1985 f
->dump_int("expiration", expiration
);
1986 f
->dump_int("noncur_expiration", noncur_expiration
);
1987 f
->dump_int("mp_expiration", mp_expiration
);
1988 if (expiration_date
) {
1989 utime_t
ut(*expiration_date
);
1990 f
->dump_stream("expiration_date") << ut
;
1993 f
->dump_object("obj_tags", *obj_tags
);
1997 void LCFilter::dump(Formatter
*f
) const
1999 f
->dump_string("prefix", prefix
);
2000 f
->dump_object("obj_tags", obj_tags
);
2003 void LCExpiration::dump(Formatter
*f
) const
2005 f
->dump_string("days", days
);
2006 f
->dump_string("date", date
);
2009 void LCRule::dump(Formatter
*f
) const
2011 f
->dump_string("id", id
);
2012 f
->dump_string("prefix", prefix
);
2013 f
->dump_string("status", status
);
2014 f
->dump_object("expiration", expiration
);
2015 f
->dump_object("noncur_expiration", noncur_expiration
);
2016 f
->dump_object("mp_expiration", mp_expiration
);
2017 f
->dump_object("filter", filter
);
2018 f
->dump_bool("dm_expiration", dm_expiration
);
2021 void RGWLifecycleConfiguration::dump(Formatter
*f
) const
2023 f
->open_object_section("prefix_map");
2024 for (auto& prefix
: prefix_map
) {
2025 f
->dump_object(prefix
.first
.c_str(), prefix
.second
);
2029 f
->open_array_section("rule_map");
2030 for (auto& rule
: rule_map
) {
2031 f
->open_object_section("entry");
2032 f
->dump_string("id", rule
.first
);
2033 f
->open_object_section("rule");
2034 rule
.second
.dump(f
);
2041 void compression_block::dump(Formatter
*f
) const
2043 f
->dump_unsigned("old_ofs", old_ofs
);
2044 f
->dump_unsigned("new_ofs", new_ofs
);
2045 f
->dump_unsigned("len", len
);
2048 void RGWCompressionInfo::dump(Formatter
*f
) const
2050 f
->dump_string("compression_type", compression_type
);
2051 f
->dump_unsigned("orig_size", orig_size
);
2052 ::encode_json("blocks", blocks
, f
);
2055 void objexp_hint_entry::dump(Formatter
*f
) const
2057 f
->open_object_section("objexp_hint_entry");
2058 encode_json("tenant", tenant
, f
);
2059 encode_json("bucket_name", bucket_name
, f
);
2060 encode_json("bucket_id", bucket_id
, f
);
2061 encode_json("rgw_obj_key", obj_key
, f
);
2062 utime_t
ut(exp_time
);
2063 encode_json("exp_time", ut
, f
);
2067 void rgw_user::dump(Formatter
*f
) const
2069 ::encode_json("user", *this, f
);