1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
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"
19 #include "common/ceph_json.h"
20 #include "common/Formatter.h"
22 #define dout_context g_ceph_context
23 #define dout_subsys ceph_subsys_rgw
25 void encode_json(const char *name
, const obj_version
& v
, Formatter
*f
)
27 f
->open_object_section(name
);
28 f
->dump_string("tag", v
.tag
);
29 f
->dump_unsigned("ver", v
.ver
);
33 void decode_json_obj(obj_version
& v
, JSONObj
*obj
)
35 JSONDecoder::decode_json("tag", v
.tag
, obj
);
36 JSONDecoder::decode_json("ver", v
.ver
, obj
);
39 void encode_json(const char *name
, const RGWUserCaps
& val
, Formatter
*f
)
45 void encode_json(const char *name
, const rgw_pool
& pool
, Formatter
*f
)
47 f
->dump_string(name
, pool
.to_str());
50 void decode_json_obj(rgw_pool
& pool
, JSONObj
*obj
)
53 decode_json_obj(s
, obj
);
57 void encode_json(const char *name
, const rgw_placement_rule
& r
, Formatter
*f
)
59 encode_json(name
, r
.to_str(), f
);
62 void decode_json_obj(rgw_placement_rule
& v
, JSONObj
*obj
)
65 decode_json_obj(s
, obj
);
69 void RGWOLHInfo::dump(Formatter
*f
) const
71 encode_json("target", target
, f
);
74 void RGWOLHPendingInfo::dump(Formatter
*f
) const
77 encode_json("time", ut
, f
);
80 void RGWObjManifestPart::dump(Formatter
*f
) const
82 f
->open_object_section("loc");
85 f
->dump_unsigned("loc_ofs", loc_ofs
);
86 f
->dump_unsigned("size", size
);
89 void RGWObjManifestRule::dump(Formatter
*f
) const
91 encode_json("start_part_num", start_part_num
, f
);
92 encode_json("start_ofs", start_ofs
, f
);
93 encode_json("part_size", part_size
, f
);
94 encode_json("stripe_max_size", stripe_max_size
, f
);
95 encode_json("override_prefix", override_prefix
, f
);
98 void rgw_bucket_placement::dump(Formatter
*f
) const
100 encode_json("bucket", bucket
, f
);
101 encode_json("placement_rule", placement_rule
, f
);
104 void rgw_obj_select::dump(Formatter
*f
) const
106 f
->dump_string("placement_rule", placement_rule
.to_str());
107 f
->dump_object("obj", obj
);
108 f
->dump_object("raw_obj", raw_obj
);
109 f
->dump_bool("is_raw", is_raw
);
112 void RGWObjManifest::obj_iterator::dump(Formatter
*f
) const
114 f
->dump_unsigned("part_ofs", part_ofs
);
115 f
->dump_unsigned("stripe_ofs", stripe_ofs
);
116 f
->dump_unsigned("ofs", ofs
);
117 f
->dump_unsigned("stripe_size", stripe_size
);
118 f
->dump_int("cur_part_id", cur_part_id
);
119 f
->dump_int("cur_stripe", cur_stripe
);
120 f
->dump_string("cur_override_prefix", cur_override_prefix
);
121 f
->dump_object("location", location
);
124 void RGWObjManifest::dump(Formatter
*f
) const
126 map
<uint64_t, RGWObjManifestPart
>::const_iterator iter
= objs
.begin();
127 f
->open_array_section("objs");
128 for (; iter
!= objs
.end(); ++iter
) {
129 f
->dump_unsigned("ofs", iter
->first
);
130 f
->open_object_section("part");
131 iter
->second
.dump(f
);
135 f
->dump_unsigned("obj_size", obj_size
);
136 ::encode_json("explicit_objs", explicit_objs
, f
);
137 ::encode_json("head_size", head_size
, f
);
138 ::encode_json("max_head_size", max_head_size
, f
);
139 ::encode_json("prefix", prefix
, f
);
140 ::encode_json("rules", rules
, f
);
141 ::encode_json("tail_instance", tail_instance
, f
);
142 ::encode_json("tail_placement", tail_placement
, f
);
144 f
->dump_object("begin_iter", begin_iter
);
145 f
->dump_object("end_iter", end_iter
);
148 void rgw_log_entry::dump(Formatter
*f
) const
150 f
->dump_string("object_owner", object_owner
.to_str());
151 f
->dump_string("bucket_owner", bucket_owner
.to_str());
152 f
->dump_string("bucket", bucket
);
153 f
->dump_stream("time") << time
;
154 f
->dump_string("remote_addr", remote_addr
);
155 f
->dump_string("user", user
);
158 f
->dump_string("obj", s
.str());
159 f
->dump_string("op", op
);
160 f
->dump_string("uri", uri
);
161 f
->dump_string("http_status", http_status
);
162 f
->dump_string("error_code", error_code
);
163 f
->dump_unsigned("bytes_sent", bytes_sent
);
164 f
->dump_unsigned("bytes_received", bytes_received
);
165 f
->dump_unsigned("obj_size", obj_size
);
166 f
->dump_stream("total_time") << total_time
;
167 f
->dump_string("user_agent", user_agent
);
168 f
->dump_string("referrer", referrer
);
169 f
->dump_string("bucket_id", bucket_id
);
172 void ACLPermission::dump(Formatter
*f
) const
174 f
->dump_int("flags", flags
);
177 void ACLGranteeType::dump(Formatter
*f
) const
179 f
->dump_unsigned("type", type
);
182 void ACLGrant::dump(Formatter
*f
) const
184 f
->open_object_section("type");
188 f
->dump_string("id", id
.to_str());
189 f
->dump_string("email", email
);
191 f
->open_object_section("permission");
195 f
->dump_string("name", name
);
196 f
->dump_int("group", (int)group
);
197 f
->dump_string("url_spec", url_spec
);
200 void RGWAccessControlList::dump(Formatter
*f
) const
202 map
<string
, int>::const_iterator acl_user_iter
= acl_user_map
.begin();
203 f
->open_array_section("acl_user_map");
204 for (; acl_user_iter
!= acl_user_map
.end(); ++acl_user_iter
) {
205 f
->open_object_section("entry");
206 f
->dump_string("user", acl_user_iter
->first
);
207 f
->dump_int("acl", acl_user_iter
->second
);
212 map
<uint32_t, int>::const_iterator acl_group_iter
= acl_group_map
.begin();
213 f
->open_array_section("acl_group_map");
214 for (; acl_group_iter
!= acl_group_map
.end(); ++acl_group_iter
) {
215 f
->open_object_section("entry");
216 f
->dump_unsigned("group", acl_group_iter
->first
);
217 f
->dump_int("acl", acl_group_iter
->second
);
222 multimap
<string
, ACLGrant
>::const_iterator giter
= grant_map
.begin();
223 f
->open_array_section("grant_map");
224 for (; giter
!= grant_map
.end(); ++giter
) {
225 f
->open_object_section("entry");
226 f
->dump_string("id", giter
->first
);
227 f
->open_object_section("grant");
228 giter
->second
.dump(f
);
235 void ACLOwner::dump(Formatter
*f
) const
237 encode_json("id", id
.to_str(), f
);
238 encode_json("display_name", display_name
, f
);
241 void ACLOwner::decode_json(JSONObj
*obj
) {
243 JSONDecoder::decode_json("id", id_str
, obj
);
245 JSONDecoder::decode_json("display_name", display_name
, obj
);
248 void RGWAccessControlPolicy::dump(Formatter
*f
) const
250 encode_json("acl", acl
, f
);
251 encode_json("owner", owner
, f
);
254 void ObjectMetaInfo::dump(Formatter
*f
) const
256 encode_json("size", size
, f
);
257 encode_json("mtime", utime_t(mtime
), f
);
260 void ObjectCacheInfo::dump(Formatter
*f
) const
262 encode_json("status", status
, f
);
263 encode_json("flags", flags
, f
);
264 encode_json("data", data
, f
);
265 encode_json_map("xattrs", "name", "value", "length", xattrs
, f
);
266 encode_json_map("rm_xattrs", "name", "value", "length", rm_xattrs
, f
);
267 encode_json("meta", meta
, f
);
271 void RGWCacheNotifyInfo::dump(Formatter
*f
) const
273 encode_json("op", op
, f
);
274 encode_json("obj", obj
, f
);
275 encode_json("obj_info", obj_info
, f
);
276 encode_json("ofs", ofs
, f
);
277 encode_json("ns", ns
, f
);
280 void RGWAccessKey::dump(Formatter
*f
) const
282 encode_json("access_key", id
, f
);
283 encode_json("secret_key", key
, f
);
284 encode_json("subuser", subuser
, f
);
287 void RGWAccessKey::dump_plain(Formatter
*f
) const
289 encode_json("access_key", id
, f
);
290 encode_json("secret_key", key
, f
);
293 void encode_json_plain(const char *name
, const RGWAccessKey
& val
, Formatter
*f
)
295 f
->open_object_section(name
);
300 void RGWAccessKey::dump(Formatter
*f
, const string
& user
, bool swift
) const
303 if (!subuser
.empty()) {
307 encode_json("user", u
, f
);
309 encode_json("access_key", id
, f
);
311 encode_json("secret_key", key
, f
);
314 void RGWAccessKey::decode_json(JSONObj
*obj
) {
315 JSONDecoder::decode_json("access_key", id
, obj
, true);
316 JSONDecoder::decode_json("secret_key", key
, obj
, true);
317 if (!JSONDecoder::decode_json("subuser", subuser
, obj
)) {
319 JSONDecoder::decode_json("user", user
, obj
);
320 int pos
= user
.find(':');
322 subuser
= user
.substr(pos
+ 1);
327 void RGWAccessKey::decode_json(JSONObj
*obj
, bool swift
) {
333 if (!JSONDecoder::decode_json("subuser", subuser
, obj
)) {
334 JSONDecoder::decode_json("user", id
, obj
, true);
335 int pos
= id
.find(':');
337 subuser
= id
.substr(pos
+ 1);
340 JSONDecoder::decode_json("secret_key", key
, obj
, true);
343 struct rgw_flags_desc
{
348 static struct rgw_flags_desc rgw_perms
[] = {
349 { RGW_PERM_FULL_CONTROL
, "full-control" },
350 { RGW_PERM_READ
| RGW_PERM_WRITE
, "read-write" },
351 { RGW_PERM_READ
, "read" },
352 { RGW_PERM_WRITE
, "write" },
353 { RGW_PERM_READ_ACP
, "read-acp" },
354 { RGW_PERM_WRITE_ACP
, "write-acp" },
358 static void mask_to_str(rgw_flags_desc
*mask_list
, uint32_t mask
, char *buf
, int len
)
360 const char *sep
= "";
363 snprintf(buf
, len
, "<none>");
367 uint32_t orig_mask
= mask
;
368 for (int i
= 0; mask_list
[i
].mask
; i
++) {
369 struct rgw_flags_desc
*desc
= &mask_list
[i
];
370 if ((mask
& desc
->mask
) == desc
->mask
) {
371 pos
+= snprintf(buf
+ pos
, len
- pos
, "%s%s", sep
, desc
->str
);
380 if (mask
== orig_mask
) // no change
385 static void perm_to_str(uint32_t mask
, char *buf
, int len
)
387 return mask_to_str(rgw_perms
, mask
, buf
, len
);
390 static struct rgw_flags_desc op_type_flags
[] = {
391 { RGW_OP_TYPE_READ
, "read" },
392 { RGW_OP_TYPE_WRITE
, "write" },
393 { RGW_OP_TYPE_DELETE
, "delete" },
397 extern void op_type_to_str(uint32_t mask
, char *buf
, int len
)
399 return mask_to_str(op_type_flags
, mask
, buf
, len
);
402 void RGWSubUser::dump(Formatter
*f
) const
404 encode_json("id", name
, f
);
406 perm_to_str(perm_mask
, buf
, sizeof(buf
));
407 encode_json("permissions", (const char *)buf
, f
);
410 void RGWSubUser::dump(Formatter
*f
, const string
& user
) const
415 encode_json("id", s
, f
);
417 perm_to_str(perm_mask
, buf
, sizeof(buf
));
418 encode_json("permissions", (const char *)buf
, f
);
421 static uint32_t str_to_perm(const string
& s
)
423 if (s
.compare("read") == 0)
424 return RGW_PERM_READ
;
425 else if (s
.compare("write") == 0)
426 return RGW_PERM_WRITE
;
427 else if (s
.compare("read-write") == 0)
428 return RGW_PERM_READ
| RGW_PERM_WRITE
;
429 else if (s
.compare("full-control") == 0)
430 return RGW_PERM_FULL_CONTROL
;
434 void RGWSubUser::decode_json(JSONObj
*obj
)
437 JSONDecoder::decode_json("id", uid
, obj
);
438 int pos
= uid
.find(':');
440 name
= uid
.substr(pos
+ 1);
442 JSONDecoder::decode_json("permissions", perm_str
, obj
);
443 perm_mask
= str_to_perm(perm_str
);
446 static void user_info_dump_subuser(const char *name
, const RGWSubUser
& subuser
, Formatter
*f
, void *parent
)
448 RGWUserInfo
*info
= static_cast<RGWUserInfo
*>(parent
);
449 subuser
.dump(f
, info
->user_id
.to_str());
452 static void user_info_dump_key(const char *name
, const RGWAccessKey
& key
, Formatter
*f
, void *parent
)
454 RGWUserInfo
*info
= static_cast<RGWUserInfo
*>(parent
);
455 key
.dump(f
, info
->user_id
.to_str(), false);
458 static void user_info_dump_swift_key(const char *name
, const RGWAccessKey
& key
, Formatter
*f
, void *parent
)
460 RGWUserInfo
*info
= static_cast<RGWUserInfo
*>(parent
);
461 key
.dump(f
, info
->user_id
.to_str(), true);
464 void RGWUserInfo::dump(Formatter
*f
) const
467 encode_json("user_id", user_id
.to_str(), f
);
468 encode_json("display_name", display_name
, f
);
469 encode_json("email", user_email
, f
);
470 encode_json("suspended", (int)suspended
, f
);
471 encode_json("max_buckets", (int)max_buckets
, f
);
473 encode_json_map("subusers", NULL
, "subuser", NULL
, user_info_dump_subuser
,(void *)this, subusers
, f
);
474 encode_json_map("keys", NULL
, "key", NULL
, user_info_dump_key
,(void *)this, access_keys
, f
);
475 encode_json_map("swift_keys", NULL
, "key", NULL
, user_info_dump_swift_key
,(void *)this, swift_keys
, f
);
477 encode_json("caps", caps
, f
);
480 op_type_to_str(op_mask
, buf
, sizeof(buf
));
481 encode_json("op_mask", (const char *)buf
, f
);
483 if (system
) { /* no need to show it for every user */
484 encode_json("system", (bool)system
, f
);
487 encode_json("admin", (bool)admin
, f
);
489 encode_json("default_placement", default_placement
.name
, f
);
490 encode_json("default_storage_class", default_placement
.storage_class
, f
);
491 encode_json("placement_tags", placement_tags
, f
);
492 encode_json("bucket_quota", bucket_quota
, f
);
493 encode_json("user_quota", user_quota
, f
);
494 encode_json("temp_url_keys", temp_url_keys
, f
);
496 string user_source_type
;
497 switch ((RGWIdentityType
)type
) {
499 user_source_type
= "rgw";
502 user_source_type
= "keystone";
505 user_source_type
= "ldap";
508 user_source_type
= "none";
511 user_source_type
= "none";
514 encode_json("type", user_source_type
, f
);
515 encode_json("mfa_ids", mfa_ids
, f
);
519 static void decode_access_keys(map
<string
, RGWAccessKey
>& m
, JSONObj
*o
)
526 static void decode_swift_keys(map
<string
, RGWAccessKey
>& m
, JSONObj
*o
)
529 k
.decode_json(o
, true);
533 static void decode_subusers(map
<string
, RGWSubUser
>& m
, JSONObj
*o
)
540 void RGWUserInfo::decode_json(JSONObj
*obj
)
544 JSONDecoder::decode_json("user_id", uid
, obj
, true);
545 user_id
.from_str(uid
);
547 JSONDecoder::decode_json("display_name", display_name
, obj
);
548 JSONDecoder::decode_json("email", user_email
, obj
);
550 JSONDecoder::decode_json("suspended", susp
, obj
);
551 suspended
= (__u8
)susp
;
552 JSONDecoder::decode_json("max_buckets", max_buckets
, obj
);
554 JSONDecoder::decode_json("keys", access_keys
, decode_access_keys
, obj
);
555 JSONDecoder::decode_json("swift_keys", swift_keys
, decode_swift_keys
, obj
);
556 JSONDecoder::decode_json("subusers", subusers
, decode_subusers
, obj
);
558 JSONDecoder::decode_json("caps", caps
, obj
);
561 JSONDecoder::decode_json("op_mask", mask_str
, obj
);
562 rgw_parse_op_type_list(mask_str
, &op_mask
);
565 JSONDecoder::decode_json("system", sys
, obj
);
568 JSONDecoder::decode_json("admin", ad
, obj
);
570 JSONDecoder::decode_json("default_placement", default_placement
.name
, obj
);
571 JSONDecoder::decode_json("default_storage_class", default_placement
.storage_class
, obj
);
572 JSONDecoder::decode_json("placement_tags", placement_tags
, obj
);
573 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
574 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
575 JSONDecoder::decode_json("temp_url_keys", temp_url_keys
, obj
);
577 string user_source_type
;
578 JSONDecoder::decode_json("type", user_source_type
, obj
);
579 if (user_source_type
== "rgw") {
581 } else if (user_source_type
== "keystone") {
582 type
= TYPE_KEYSTONE
;
583 } else if (user_source_type
== "ldap") {
585 } else if (user_source_type
== "none") {
588 JSONDecoder::decode_json("mfa_ids", mfa_ids
, obj
);
591 void RGWQuotaInfo::dump(Formatter
*f
) const
593 f
->dump_bool("enabled", enabled
);
594 f
->dump_bool("check_on_raw", check_on_raw
);
596 f
->dump_int("max_size", max_size
);
597 f
->dump_int("max_size_kb", rgw_rounded_kb(max_size
));
598 f
->dump_int("max_objects", max_objects
);
601 void RGWQuotaInfo::decode_json(JSONObj
*obj
)
603 if (false == JSONDecoder::decode_json("max_size", max_size
, obj
)) {
604 /* We're parsing an older version of the struct. */
605 int64_t max_size_kb
= 0;
607 JSONDecoder::decode_json("max_size_kb", max_size_kb
, obj
);
608 max_size
= max_size_kb
* 1024;
610 JSONDecoder::decode_json("max_objects", max_objects
, obj
);
612 JSONDecoder::decode_json("check_on_raw", check_on_raw
, obj
);
613 JSONDecoder::decode_json("enabled", enabled
, obj
);
616 void rgw_data_placement_target::dump(Formatter
*f
) const
618 encode_json("data_pool", data_pool
, f
);
619 encode_json("data_extra_pool", data_extra_pool
, f
);
620 encode_json("index_pool", index_pool
, f
);
623 void rgw_data_placement_target::decode_json(JSONObj
*obj
) {
624 JSONDecoder::decode_json("data_pool", data_pool
, obj
);
625 JSONDecoder::decode_json("data_extra_pool", data_extra_pool
, obj
);
626 JSONDecoder::decode_json("index_pool", index_pool
, obj
);
629 void rgw_bucket::dump(Formatter
*f
) const
631 encode_json("name", name
, f
);
632 encode_json("marker", marker
, f
);
633 encode_json("bucket_id", bucket_id
, f
);
634 encode_json("tenant", tenant
, f
);
635 encode_json("explicit_placement", explicit_placement
, f
);
638 void rgw_bucket::decode_json(JSONObj
*obj
) {
639 JSONDecoder::decode_json("name", name
, obj
);
640 JSONDecoder::decode_json("marker", marker
, obj
);
641 JSONDecoder::decode_json("bucket_id", bucket_id
, obj
);
642 JSONDecoder::decode_json("tenant", tenant
, obj
);
643 JSONDecoder::decode_json("explicit_placement", explicit_placement
, obj
);
644 if (explicit_placement
.data_pool
.empty()) {
645 /* decoding old format */
646 JSONDecoder::decode_json("pool", explicit_placement
.data_pool
, obj
);
647 JSONDecoder::decode_json("data_extra_pool", explicit_placement
.data_extra_pool
, obj
);
648 JSONDecoder::decode_json("index_pool", explicit_placement
.index_pool
, obj
);
652 void RGWBucketEntryPoint::dump(Formatter
*f
) const
654 encode_json("bucket", bucket
, f
);
655 encode_json("owner", owner
, f
);
656 utime_t
ut(creation_time
);
657 encode_json("creation_time", ut
, f
);
658 encode_json("linked", linked
, f
);
659 encode_json("has_bucket_info", has_bucket_info
, f
);
660 if (has_bucket_info
) {
661 encode_json("old_bucket_info", old_bucket_info
, f
);
665 void RGWBucketEntryPoint::decode_json(JSONObj
*obj
) {
666 JSONDecoder::decode_json("bucket", bucket
, obj
);
667 JSONDecoder::decode_json("owner", owner
, obj
);
669 JSONDecoder::decode_json("creation_time", ut
, obj
);
670 creation_time
= ut
.to_real_time();
671 JSONDecoder::decode_json("linked", linked
, obj
);
672 JSONDecoder::decode_json("has_bucket_info", has_bucket_info
, obj
);
673 if (has_bucket_info
) {
674 JSONDecoder::decode_json("old_bucket_info", old_bucket_info
, obj
);
678 void RGWStorageStats::dump(Formatter
*f
) const
680 encode_json("size", size
, f
);
681 encode_json("size_actual", size_rounded
, f
);
682 encode_json("size_utilized", size_utilized
, f
);
683 encode_json("size_kb", rgw_rounded_kb(size
), f
);
684 encode_json("size_kb_actual", rgw_rounded_kb(size_rounded
), f
);
685 encode_json("size_kb_utilized", rgw_rounded_kb(size_utilized
), f
);
686 encode_json("num_objects", num_objects
, f
);
689 void RGWRedirectInfo::dump(Formatter
*f
) const
691 encode_json("protocol", protocol
, f
);
692 encode_json("hostname", hostname
, f
);
693 encode_json("http_redirect_code", (int)http_redirect_code
, f
);
696 void RGWRedirectInfo::decode_json(JSONObj
*obj
) {
697 JSONDecoder::decode_json("protocol", protocol
, obj
);
698 JSONDecoder::decode_json("hostname", hostname
, obj
);
700 JSONDecoder::decode_json("http_redirect_code", code
, obj
);
701 http_redirect_code
= code
;
704 void RGWBWRedirectInfo::dump(Formatter
*f
) const
706 encode_json("redirect", redirect
, f
);
707 encode_json("replace_key_prefix_with", replace_key_prefix_with
, f
);
708 encode_json("replace_key_with", replace_key_with
, f
);
711 void RGWBWRedirectInfo::decode_json(JSONObj
*obj
) {
712 JSONDecoder::decode_json("redirect", redirect
, obj
);
713 JSONDecoder::decode_json("replace_key_prefix_with", replace_key_prefix_with
, obj
);
714 JSONDecoder::decode_json("replace_key_with", replace_key_with
, obj
);
717 void RGWBWRoutingRuleCondition::dump(Formatter
*f
) const
719 encode_json("key_prefix_equals", key_prefix_equals
, f
);
720 encode_json("http_error_code_returned_equals", (int)http_error_code_returned_equals
, f
);
723 void RGWBWRoutingRuleCondition::decode_json(JSONObj
*obj
) {
724 JSONDecoder::decode_json("key_prefix_equals", key_prefix_equals
, obj
);
726 JSONDecoder::decode_json("http_error_code_returned_equals", code
, obj
);
727 http_error_code_returned_equals
= code
;
730 void RGWBWRoutingRule::dump(Formatter
*f
) const
732 encode_json("condition", condition
, f
);
733 encode_json("redirect_info", redirect_info
, f
);
736 void RGWBWRoutingRule::decode_json(JSONObj
*obj
) {
737 JSONDecoder::decode_json("condition", condition
, obj
);
738 JSONDecoder::decode_json("redirect_info", redirect_info
, obj
);
741 void RGWBWRoutingRules::dump(Formatter
*f
) const
743 encode_json("rules", rules
, f
);
746 void RGWBWRoutingRules::decode_json(JSONObj
*obj
) {
747 JSONDecoder::decode_json("rules", rules
, obj
);
750 void RGWBucketWebsiteConf::dump(Formatter
*f
) const
752 if (!redirect_all
.hostname
.empty()) {
753 encode_json("redirect_all", redirect_all
, f
);
755 encode_json("index_doc_suffix", index_doc_suffix
, f
);
756 encode_json("error_doc", error_doc
, f
);
757 encode_json("routing_rules", routing_rules
, f
);
761 void RGWBucketWebsiteConf::decode_json(JSONObj
*obj
) {
762 JSONDecoder::decode_json("redirect_all", redirect_all
, obj
);
763 JSONDecoder::decode_json("index_doc_suffix", index_doc_suffix
, obj
);
764 JSONDecoder::decode_json("error_doc", error_doc
, obj
);
765 JSONDecoder::decode_json("routing_rules", routing_rules
, obj
);
768 void RGWBucketInfo::dump(Formatter
*f
) const
770 encode_json("bucket", bucket
, f
);
771 utime_t
ut(creation_time
);
772 encode_json("creation_time", ut
, f
);
773 encode_json("owner", owner
.to_str(), f
);
774 encode_json("flags", flags
, f
);
775 encode_json("zonegroup", zonegroup
, f
);
776 encode_json("placement_rule", placement_rule
, f
);
777 encode_json("has_instance_obj", has_instance_obj
, f
);
778 encode_json("quota", quota
, f
);
779 encode_json("num_shards", num_shards
, f
);
780 encode_json("bi_shard_hash_type", (uint32_t)bucket_index_shard_hash_type
, f
);
781 encode_json("requester_pays", requester_pays
, f
);
782 encode_json("has_website", has_website
, f
);
784 encode_json("website_conf", website_conf
, f
);
786 encode_json("swift_versioning", swift_versioning
, f
);
787 encode_json("swift_ver_location", swift_ver_location
, f
);
788 encode_json("index_type", (uint32_t)index_type
, f
);
789 encode_json("mdsearch_config", mdsearch_config
, f
);
790 encode_json("reshard_status", (int)reshard_status
, f
);
791 encode_json("new_bucket_instance_id", new_bucket_instance_id
, f
);
794 void RGWBucketInfo::decode_json(JSONObj
*obj
) {
795 JSONDecoder::decode_json("bucket", bucket
, obj
);
797 JSONDecoder::decode_json("creation_time", ut
, obj
);
798 creation_time
= ut
.to_real_time();
799 JSONDecoder::decode_json("owner", owner
, obj
);
800 JSONDecoder::decode_json("flags", flags
, obj
);
801 JSONDecoder::decode_json("zonegroup", zonegroup
, obj
);
802 /* backward compatability with region */
803 if (zonegroup
.empty()) {
804 JSONDecoder::decode_json("region", zonegroup
, obj
);
807 JSONDecoder::decode_json("placement_rule", pr
, obj
);
808 placement_rule
.from_str(pr
);
809 JSONDecoder::decode_json("has_instance_obj", has_instance_obj
, obj
);
810 JSONDecoder::decode_json("quota", quota
, obj
);
811 JSONDecoder::decode_json("num_shards", num_shards
, obj
);
813 JSONDecoder::decode_json("bi_shard_hash_type", hash_type
, obj
);
814 bucket_index_shard_hash_type
= (uint8_t)hash_type
;
815 JSONDecoder::decode_json("requester_pays", requester_pays
, obj
);
816 JSONDecoder::decode_json("has_website", has_website
, obj
);
818 JSONDecoder::decode_json("website_conf", website_conf
, obj
);
820 JSONDecoder::decode_json("swift_versioning", swift_versioning
, obj
);
821 JSONDecoder::decode_json("swift_ver_location", swift_ver_location
, obj
);
823 JSONDecoder::decode_json("index_type", it
, obj
);
824 index_type
= (RGWBucketIndexType
)it
;
825 JSONDecoder::decode_json("mdsearch_config", mdsearch_config
, obj
);
827 JSONDecoder::decode_json("reshard_status", rs
, obj
);
828 reshard_status
= (cls_rgw_reshard_status
)rs
;
831 void rgw_obj_key::dump(Formatter
*f
) const
833 encode_json("name", name
, f
);
834 encode_json("instance", instance
, f
);
835 encode_json("ns", ns
, f
);
838 void rgw_obj_key::decode_json(JSONObj
*obj
)
840 JSONDecoder::decode_json("name", name
, obj
);
841 JSONDecoder::decode_json("instance", instance
, obj
);
842 JSONDecoder::decode_json("ns", ns
, obj
);
845 void RGWBucketEnt::dump(Formatter
*f
) const
847 encode_json("bucket", bucket
, f
);
848 encode_json("size", size
, f
);
849 encode_json("size_rounded", size_rounded
, f
);
850 utime_t
ut(creation_time
);
851 encode_json("mtime", ut
, f
); /* mtime / creation time discrepency needed for backward compatibility */
852 encode_json("count", count
, f
);
853 encode_json("placement_rule", placement_rule
.to_str(), f
);
856 void RGWUploadPartInfo::dump(Formatter
*f
) const
858 encode_json("num", num
, f
);
859 encode_json("size", size
, f
);
860 encode_json("etag", etag
, f
);
861 utime_t
ut(modified
);
862 encode_json("modified", ut
, f
);
865 void rgw_raw_obj::dump(Formatter
*f
) const
867 encode_json("pool", pool
, f
);
868 encode_json("oid", oid
, f
);
869 encode_json("loc", loc
, f
);
872 void rgw_raw_obj::decode_json(JSONObj
*obj
) {
873 JSONDecoder::decode_json("pool", pool
, obj
);
874 JSONDecoder::decode_json("oid", oid
, obj
);
875 JSONDecoder::decode_json("loc", loc
, obj
);
878 void rgw_obj::dump(Formatter
*f
) const
880 encode_json("bucket", bucket
, f
);
881 encode_json("key", key
, f
);
884 void RGWDefaultSystemMetaObjInfo::dump(Formatter
*f
) const {
885 encode_json("default_id", default_id
, f
);
888 void RGWDefaultSystemMetaObjInfo::decode_json(JSONObj
*obj
) {
889 JSONDecoder::decode_json("default_id", default_id
, obj
);
892 void RGWNameToId::dump(Formatter
*f
) const {
893 encode_json("obj_id", obj_id
, f
);
896 void RGWNameToId::decode_json(JSONObj
*obj
) {
897 JSONDecoder::decode_json("obj_id", obj_id
, obj
);
900 void RGWSystemMetaObj::dump(Formatter
*f
) const
902 encode_json("id", id
, f
);
903 encode_json("name", name
, f
);
906 void RGWSystemMetaObj::decode_json(JSONObj
*obj
)
908 JSONDecoder::decode_json("id", id
, obj
);
909 JSONDecoder::decode_json("name", name
, obj
);
912 void RGWPeriodLatestEpochInfo::dump(Formatter
*f
) const {
913 encode_json("latest_epoch", epoch
, f
);
916 void RGWPeriodLatestEpochInfo::decode_json(JSONObj
*obj
) {
917 JSONDecoder::decode_json("latest_epoch", epoch
, obj
);
920 void RGWPeriod::dump(Formatter
*f
) const
922 encode_json("id", id
, f
);
923 encode_json("epoch", epoch
, f
);
924 encode_json("predecessor_uuid", predecessor_uuid
, f
);
925 encode_json("sync_status", sync_status
, f
);
926 encode_json("period_map", period_map
, f
);
927 encode_json("master_zonegroup", master_zonegroup
, f
);
928 encode_json("master_zone", master_zone
, f
);
929 encode_json("period_config", period_config
, f
);
930 encode_json("realm_id", realm_id
, f
);
931 encode_json("realm_name", realm_name
, f
);
932 encode_json("realm_epoch", realm_epoch
, f
);
935 void RGWPeriod::decode_json(JSONObj
*obj
)
937 JSONDecoder::decode_json("id", id
, obj
);
938 JSONDecoder::decode_json("epoch", epoch
, obj
);
939 JSONDecoder::decode_json("predecessor_uuid", predecessor_uuid
, obj
);
940 JSONDecoder::decode_json("sync_status", sync_status
, obj
);
941 JSONDecoder::decode_json("period_map", period_map
, obj
);
942 JSONDecoder::decode_json("master_zonegroup", master_zonegroup
, obj
);
943 JSONDecoder::decode_json("master_zone", master_zone
, obj
);
944 JSONDecoder::decode_json("period_config", period_config
, obj
);
945 JSONDecoder::decode_json("realm_id", realm_id
, obj
);
946 JSONDecoder::decode_json("realm_name", realm_name
, obj
);
947 JSONDecoder::decode_json("realm_epoch", realm_epoch
, obj
);
950 void RGWZoneParams::dump(Formatter
*f
) const
952 RGWSystemMetaObj::dump(f
);
953 encode_json("domain_root", domain_root
, f
);
954 encode_json("control_pool", control_pool
, f
);
955 encode_json("gc_pool", gc_pool
, f
);
956 encode_json("lc_pool", lc_pool
, f
);
957 encode_json("log_pool", log_pool
, f
);
958 encode_json("intent_log_pool", intent_log_pool
, f
);
959 encode_json("usage_log_pool", usage_log_pool
, f
);
960 encode_json("reshard_pool", reshard_pool
, f
);
961 encode_json("user_keys_pool", user_keys_pool
, f
);
962 encode_json("user_email_pool", user_email_pool
, f
);
963 encode_json("user_swift_pool", user_swift_pool
, f
);
964 encode_json("user_uid_pool", user_uid_pool
, f
);
965 encode_json("otp_pool", otp_pool
, f
);
966 encode_json_plain("system_key", system_key
, f
);
967 encode_json("placement_pools", placement_pools
, f
);
968 encode_json("metadata_heap", metadata_heap
, f
);
969 encode_json("tier_config", tier_config
, f
);
970 encode_json("realm_id", realm_id
, f
);
973 void RGWZoneStorageClass::dump(Formatter
*f
) const
976 encode_json("data_pool", data_pool
.get(), f
);
978 if (compression_type
) {
979 encode_json("compression_type", compression_type
.get(), f
);
983 void RGWZoneStorageClass::decode_json(JSONObj
*obj
)
985 JSONDecoder::decode_json("data_pool", data_pool
, obj
);
986 JSONDecoder::decode_json("compression_type", compression_type
, obj
);
989 void RGWZoneStorageClasses::dump(Formatter
*f
) const
992 encode_json(i
.first
.c_str(), i
.second
, f
);
996 void RGWZoneStorageClasses::decode_json(JSONObj
*obj
)
999 decode_json_obj(f
, obj
);
1001 for (auto& field
: f
.object()) {
1002 JSONObj
*field_obj
= obj
->find_obj(field
.first
);
1005 decode_json_obj(m
[field
.first
], field_obj
);
1007 standard_class
= &m
[RGW_STORAGE_CLASS_STANDARD
];
1010 void RGWZonePlacementInfo::dump(Formatter
*f
) const
1012 encode_json("index_pool", index_pool
, f
);
1013 encode_json("storage_classes", storage_classes
, f
);
1014 encode_json("data_extra_pool", data_extra_pool
, f
);
1015 encode_json("index_type", (uint32_t)index_type
, f
);
1017 /* no real need for backward compatibility of compression_type and data_pool in here,
1018 * rather not clutter the output */
1021 void RGWZonePlacementInfo::decode_json(JSONObj
*obj
)
1023 JSONDecoder::decode_json("index_pool", index_pool
, obj
);
1024 JSONDecoder::decode_json("storage_classes", storage_classes
, obj
);
1025 JSONDecoder::decode_json("data_extra_pool", data_extra_pool
, obj
);
1027 JSONDecoder::decode_json("index_type", it
, obj
);
1028 index_type
= (RGWBucketIndexType
)it
;
1030 /* backward compatibility, these are now defined in storage_classes */
1031 string standard_compression_type
;
1032 string
*pcompression
= nullptr;
1033 if (JSONDecoder::decode_json("compression", standard_compression_type
, obj
)) {
1034 pcompression
= &standard_compression_type
;
1036 rgw_pool standard_data_pool
;
1037 rgw_pool
*ppool
= nullptr;
1038 if (JSONDecoder::decode_json("data_pool", standard_data_pool
, obj
)) {
1039 ppool
= &standard_data_pool
;
1041 if (ppool
|| pcompression
) {
1042 storage_classes
.set_storage_class(RGW_STORAGE_CLASS_STANDARD
, ppool
, pcompression
);
1046 void RGWZoneParams::decode_json(JSONObj
*obj
)
1048 RGWSystemMetaObj::decode_json(obj
);
1049 JSONDecoder::decode_json("domain_root", domain_root
, obj
);
1050 JSONDecoder::decode_json("control_pool", control_pool
, obj
);
1051 JSONDecoder::decode_json("gc_pool", gc_pool
, obj
);
1052 JSONDecoder::decode_json("lc_pool", lc_pool
, obj
);
1053 JSONDecoder::decode_json("log_pool", log_pool
, obj
);
1054 JSONDecoder::decode_json("intent_log_pool", intent_log_pool
, obj
);
1055 JSONDecoder::decode_json("reshard_pool", reshard_pool
, obj
);
1056 JSONDecoder::decode_json("usage_log_pool", usage_log_pool
, obj
);
1057 JSONDecoder::decode_json("user_keys_pool", user_keys_pool
, obj
);
1058 JSONDecoder::decode_json("user_email_pool", user_email_pool
, obj
);
1059 JSONDecoder::decode_json("user_swift_pool", user_swift_pool
, obj
);
1060 JSONDecoder::decode_json("user_uid_pool", user_uid_pool
, obj
);
1061 JSONDecoder::decode_json("otp_pool", otp_pool
, obj
);
1062 JSONDecoder::decode_json("system_key", system_key
, obj
);
1063 JSONDecoder::decode_json("placement_pools", placement_pools
, obj
);
1064 JSONDecoder::decode_json("metadata_heap", metadata_heap
, obj
);
1065 JSONDecoder::decode_json("tier_config", tier_config
, obj
);
1066 JSONDecoder::decode_json("realm_id", realm_id
, obj
);
1070 void RGWZone::dump(Formatter
*f
) const
1072 encode_json("id", id
, f
);
1073 encode_json("name", name
, f
);
1074 encode_json("endpoints", endpoints
, f
);
1075 encode_json("log_meta", log_meta
, f
);
1076 encode_json("log_data", log_data
, f
);
1077 encode_json("bucket_index_max_shards", bucket_index_max_shards
, f
);
1078 encode_json("read_only", read_only
, f
);
1079 encode_json("tier_type", tier_type
, f
);
1080 encode_json("sync_from_all", sync_from_all
, f
);
1081 encode_json("sync_from", sync_from
, f
);
1082 encode_json("redirect_zone", redirect_zone
, f
);
1085 void RGWZone::decode_json(JSONObj
*obj
)
1087 JSONDecoder::decode_json("id", id
, obj
);
1088 JSONDecoder::decode_json("name", name
, obj
);
1092 JSONDecoder::decode_json("endpoints", endpoints
, obj
);
1093 JSONDecoder::decode_json("log_meta", log_meta
, obj
);
1094 JSONDecoder::decode_json("log_data", log_data
, obj
);
1095 JSONDecoder::decode_json("bucket_index_max_shards", bucket_index_max_shards
, obj
);
1096 JSONDecoder::decode_json("read_only", read_only
, obj
);
1097 JSONDecoder::decode_json("tier_type", tier_type
, obj
);
1098 JSONDecoder::decode_json("sync_from_all", sync_from_all
, true, obj
);
1099 JSONDecoder::decode_json("sync_from", sync_from
, obj
);
1100 JSONDecoder::decode_json("redirect_zone", redirect_zone
, obj
);
1103 void RGWZoneGroupPlacementTarget::dump(Formatter
*f
) const
1105 encode_json("name", name
, f
);
1106 encode_json("tags", tags
, f
);
1107 encode_json("storage_classes", storage_classes
, f
);
1110 void RGWZoneGroupPlacementTarget::decode_json(JSONObj
*obj
)
1112 JSONDecoder::decode_json("name", name
, obj
);
1113 JSONDecoder::decode_json("tags", tags
, obj
);
1114 JSONDecoder::decode_json("storage_classes", storage_classes
, obj
);
1115 if (storage_classes
.empty()) {
1116 storage_classes
.insert(RGW_STORAGE_CLASS_STANDARD
);
1120 void RGWZoneGroup::dump(Formatter
*f
) const
1122 RGWSystemMetaObj::dump(f
);
1123 encode_json("api_name", api_name
, f
);
1124 encode_json("is_master", is_master
, f
);
1125 encode_json("endpoints", endpoints
, f
);
1126 encode_json("hostnames", hostnames
, f
);
1127 encode_json("hostnames_s3website", hostnames_s3website
, f
);
1128 encode_json("master_zone", master_zone
, f
);
1129 encode_json_map("zones", zones
, f
); /* more friendly representation */
1130 encode_json_map("placement_targets", placement_targets
, f
); /* more friendly representation */
1131 encode_json("default_placement", default_placement
, f
);
1132 encode_json("realm_id", realm_id
, f
);
1135 static void decode_zones(map
<string
, RGWZone
>& zones
, JSONObj
*o
)
1142 static void decode_placement_targets(map
<string
, RGWZoneGroupPlacementTarget
>& targets
, JSONObj
*o
)
1144 RGWZoneGroupPlacementTarget t
;
1146 targets
[t
.name
] = t
;
1150 void RGWZoneGroup::decode_json(JSONObj
*obj
)
1152 RGWSystemMetaObj::decode_json(obj
);
1154 derr
<< "old format " << dendl
;
1155 JSONDecoder::decode_json("name", name
, obj
);
1158 JSONDecoder::decode_json("api_name", api_name
, obj
);
1159 JSONDecoder::decode_json("is_master", is_master
, obj
);
1160 JSONDecoder::decode_json("endpoints", endpoints
, obj
);
1161 JSONDecoder::decode_json("hostnames", hostnames
, obj
);
1162 JSONDecoder::decode_json("hostnames_s3website", hostnames_s3website
, obj
);
1163 JSONDecoder::decode_json("master_zone", master_zone
, obj
);
1164 JSONDecoder::decode_json("zones", zones
, decode_zones
, obj
);
1165 JSONDecoder::decode_json("placement_targets", placement_targets
, decode_placement_targets
, obj
);
1166 JSONDecoder::decode_json("default_placement", default_placement
.name
, obj
);
1167 JSONDecoder::decode_json("default_storage_class", default_placement
.storage_class
, obj
);
1168 JSONDecoder::decode_json("realm_id", realm_id
, obj
);
1172 void RGWPeriodMap::dump(Formatter
*f
) const
1174 encode_json("id", id
, f
);
1175 encode_json_map("zonegroups", zonegroups
, f
);
1176 encode_json("short_zone_ids", short_zone_ids
, f
);
1179 static void decode_zonegroups(map
<string
, RGWZoneGroup
>& zonegroups
, JSONObj
*o
)
1183 zonegroups
[zg
.get_id()] = zg
;
1186 void RGWPeriodMap::decode_json(JSONObj
*obj
)
1188 JSONDecoder::decode_json("id", id
, obj
);
1189 JSONDecoder::decode_json("zonegroups", zonegroups
, decode_zonegroups
, obj
);
1190 /* backward compatability with region */
1191 if (zonegroups
.empty()) {
1192 JSONDecoder::decode_json("regions", zonegroups
, obj
);
1194 /* backward compatability with region */
1195 if (master_zonegroup
.empty()) {
1196 JSONDecoder::decode_json("master_region", master_zonegroup
, obj
);
1198 JSONDecoder::decode_json("short_zone_ids", short_zone_ids
, obj
);
1202 void RGWPeriodConfig::dump(Formatter
*f
) const
1204 encode_json("bucket_quota", bucket_quota
, f
);
1205 encode_json("user_quota", user_quota
, f
);
1208 void RGWPeriodConfig::decode_json(JSONObj
*obj
)
1210 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
1211 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
1214 void RGWRegionMap::dump(Formatter
*f
) const
1216 encode_json("regions", regions
, f
);
1217 encode_json("master_region", master_region
, f
);
1218 encode_json("bucket_quota", bucket_quota
, f
);
1219 encode_json("user_quota", user_quota
, f
);
1222 void RGWRegionMap::decode_json(JSONObj
*obj
)
1224 JSONDecoder::decode_json("regions", regions
, obj
);
1225 JSONDecoder::decode_json("master_region", master_region
, obj
);
1226 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
1227 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
1230 void RGWZoneGroupMap::dump(Formatter
*f
) const
1232 encode_json("zonegroups", zonegroups
, f
);
1233 encode_json("master_zonegroup", master_zonegroup
, f
);
1234 encode_json("bucket_quota", bucket_quota
, f
);
1235 encode_json("user_quota", user_quota
, f
);
1238 void RGWZoneGroupMap::decode_json(JSONObj
*obj
)
1240 JSONDecoder::decode_json("zonegroups", zonegroups
, obj
);
1241 /* backward compatability with region */
1242 if (zonegroups
.empty()) {
1243 JSONDecoder::decode_json("regions", zonegroups
, obj
);
1245 JSONDecoder::decode_json("master_zonegroup", master_zonegroup
, obj
);
1246 /* backward compatability with region */
1247 if (master_zonegroup
.empty()) {
1248 JSONDecoder::decode_json("master_region", master_zonegroup
, obj
);
1251 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
1252 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
1255 void RGWMetadataLogInfo::dump(Formatter
*f
) const
1257 encode_json("marker", marker
, f
);
1258 utime_t
ut(last_update
);
1259 encode_json("last_update", ut
, f
);
1262 void RGWMetadataLogInfo::decode_json(JSONObj
*obj
)
1264 JSONDecoder::decode_json("marker", marker
, obj
);
1266 JSONDecoder::decode_json("last_update", ut
, obj
);
1267 last_update
= ut
.to_real_time();
1270 void RGWDataChangesLogInfo::dump(Formatter
*f
) const
1272 encode_json("marker", marker
, f
);
1273 utime_t
ut(last_update
);
1274 encode_json("last_update", ut
, f
);
1277 void RGWDataChangesLogInfo::decode_json(JSONObj
*obj
)
1279 JSONDecoder::decode_json("marker", marker
, obj
);
1281 JSONDecoder::decode_json("last_update", ut
, obj
);
1282 last_update
= ut
.to_real_time();
1286 void RGWRealm::dump(Formatter
*f
) const
1288 RGWSystemMetaObj::dump(f
);
1289 encode_json("current_period", current_period
, f
);
1290 encode_json("epoch", epoch
, f
);
1294 void RGWRealm::decode_json(JSONObj
*obj
)
1296 RGWSystemMetaObj::decode_json(obj
);
1297 JSONDecoder::decode_json("current_period", current_period
, obj
);
1298 JSONDecoder::decode_json("epoch", epoch
, obj
);
1301 void rgw::keystone::TokenEnvelope::Token::decode_json(JSONObj
*obj
)
1303 string expires_iso8601
;
1306 JSONDecoder::decode_json("id", id
, obj
, true);
1307 JSONDecoder::decode_json("tenant", tenant_v2
, obj
, true);
1308 JSONDecoder::decode_json("expires", expires_iso8601
, obj
, true);
1310 if (parse_iso8601(expires_iso8601
.c_str(), &t
)) {
1311 expires
= internal_timegm(&t
);
1314 throw JSONDecoder::err("Failed to parse ISO8601 expiration date from Keystone response.");
1318 void rgw::keystone::TokenEnvelope::Role::decode_json(JSONObj
*obj
)
1320 JSONDecoder::decode_json("id", id
, obj
);
1321 JSONDecoder::decode_json("name", name
, obj
, true);
1324 void rgw::keystone::TokenEnvelope::Domain::decode_json(JSONObj
*obj
)
1326 JSONDecoder::decode_json("id", id
, obj
, true);
1327 JSONDecoder::decode_json("name", name
, obj
, true);
1330 void rgw::keystone::TokenEnvelope::Project::decode_json(JSONObj
*obj
)
1332 JSONDecoder::decode_json("id", id
, obj
, true);
1333 JSONDecoder::decode_json("name", name
, obj
, true);
1334 JSONDecoder::decode_json("domain", domain
, obj
);
1337 void rgw::keystone::TokenEnvelope::User::decode_json(JSONObj
*obj
)
1339 JSONDecoder::decode_json("id", id
, obj
, true);
1340 JSONDecoder::decode_json("name", name
, obj
, true);
1341 JSONDecoder::decode_json("domain", domain
, obj
);
1342 JSONDecoder::decode_json("roles", roles_v2
, obj
);
1345 void rgw::keystone::TokenEnvelope::decode_v3(JSONObj
* const root_obj
)
1347 std::string expires_iso8601
;
1349 JSONDecoder::decode_json("user", user
, root_obj
, true);
1350 JSONDecoder::decode_json("expires_at", expires_iso8601
, root_obj
, true);
1351 JSONDecoder::decode_json("roles", roles
, root_obj
, true);
1352 JSONDecoder::decode_json("project", project
, root_obj
, true);
1355 if (parse_iso8601(expires_iso8601
.c_str(), &t
)) {
1356 token
.expires
= internal_timegm(&t
);
1359 throw JSONDecoder::err("Failed to parse ISO8601 expiration date"
1360 "from Keystone response.");
1364 void rgw::keystone::TokenEnvelope::decode_v2(JSONObj
* const root_obj
)
1366 JSONDecoder::decode_json("user", user
, root_obj
, true);
1367 JSONDecoder::decode_json("token", token
, root_obj
, true);
1369 roles
= user
.roles_v2
;
1370 project
= token
.tenant_v2
;
1373 void rgw_slo_entry::decode_json(JSONObj
*obj
)
1375 JSONDecoder::decode_json("path", path
, obj
);
1376 JSONDecoder::decode_json("etag", etag
, obj
);
1377 JSONDecoder::decode_json("size_bytes", size_bytes
, obj
);
1380 void rgw_meta_sync_info::decode_json(JSONObj
*obj
)
1383 JSONDecoder::decode_json("status", s
, obj
);
1386 } else if (s
== "building-full-sync-maps") {
1387 state
= StateBuildingFullSyncMaps
;
1388 } else if (s
== "sync") {
1391 JSONDecoder::decode_json("num_shards", num_shards
, obj
);
1392 JSONDecoder::decode_json("period", period
, obj
);
1393 JSONDecoder::decode_json("realm_epoch", realm_epoch
, obj
);
1396 void rgw_meta_sync_info::dump(Formatter
*f
) const
1399 switch ((SyncState
)state
) {
1403 case StateBuildingFullSyncMaps
:
1404 s
= "building-full-sync-maps";
1413 encode_json("status", s
, f
);
1414 encode_json("num_shards", num_shards
, f
);
1415 encode_json("period", period
, f
);
1416 encode_json("realm_epoch", realm_epoch
, f
);
1419 void rgw_meta_sync_marker::decode_json(JSONObj
*obj
)
1422 JSONDecoder::decode_json("state", s
, obj
);
1424 JSONDecoder::decode_json("marker", marker
, obj
);
1425 JSONDecoder::decode_json("next_step_marker", next_step_marker
, obj
);
1426 JSONDecoder::decode_json("total_entries", total_entries
, obj
);
1427 JSONDecoder::decode_json("pos", pos
, obj
);
1429 JSONDecoder::decode_json("timestamp", ut
, obj
);
1430 timestamp
= ut
.to_real_time();
1431 JSONDecoder::decode_json("realm_epoch", realm_epoch
, obj
);
1434 void rgw_meta_sync_marker::dump(Formatter
*f
) const
1436 encode_json("state", (int)state
, f
);
1437 encode_json("marker", marker
, f
);
1438 encode_json("next_step_marker", next_step_marker
, f
);
1439 encode_json("total_entries", total_entries
, f
);
1440 encode_json("pos", pos
, f
);
1441 encode_json("timestamp", utime_t(timestamp
), f
);
1442 encode_json("realm_epoch", realm_epoch
, f
);
1445 void rgw_meta_sync_status::decode_json(JSONObj
*obj
)
1447 JSONDecoder::decode_json("info", sync_info
, obj
);
1448 JSONDecoder::decode_json("markers", sync_markers
, obj
);
1451 void rgw_meta_sync_status::dump(Formatter
*f
) const {
1452 encode_json("info", sync_info
, f
);
1453 encode_json("markers", sync_markers
, f
);
1456 void rgw_sync_error_info::dump(Formatter
*f
) const {
1457 encode_json("source_zone", source_zone
, f
);
1458 encode_json("error_code", error_code
, f
);
1459 encode_json("message", message
, f
);
1462 void rgw_bucket_shard_full_sync_marker::decode_json(JSONObj
*obj
)
1464 JSONDecoder::decode_json("position", position
, obj
);
1465 JSONDecoder::decode_json("count", count
, obj
);
1468 void rgw_bucket_shard_full_sync_marker::dump(Formatter
*f
) const
1470 encode_json("position", position
, f
);
1471 encode_json("count", count
, f
);
1474 void rgw_bucket_shard_inc_sync_marker::decode_json(JSONObj
*obj
)
1476 JSONDecoder::decode_json("position", position
, obj
);
1479 void rgw_bucket_shard_inc_sync_marker::dump(Formatter
*f
) const
1481 encode_json("position", position
, f
);
1484 void rgw_bucket_shard_sync_info::decode_json(JSONObj
*obj
)
1487 JSONDecoder::decode_json("status", s
, obj
);
1488 if (s
== "full-sync") {
1489 state
= StateFullSync
;
1490 } else if (s
== "incremental-sync") {
1491 state
= StateIncrementalSync
;
1495 JSONDecoder::decode_json("full_marker", full_marker
, obj
);
1496 JSONDecoder::decode_json("inc_marker", inc_marker
, obj
);
1499 void rgw_bucket_shard_sync_info::dump(Formatter
*f
) const
1501 const char *s
{nullptr};
1502 switch ((SyncState
)state
) {
1509 case StateIncrementalSync
:
1510 s
= "incremental-sync";
1516 encode_json("status", s
, f
);
1517 encode_json("full_marker", full_marker
, f
);
1518 encode_json("inc_marker", inc_marker
, f
);
1521 /* This utility function shouldn't conflict with the overload of std::to_string
1522 * provided by string_ref since Boost 1.54 as it's defined outside of the std
1523 * namespace. I hope we'll remove it soon - just after merging the Matt's PR
1524 * for bundled Boost. It would allow us to forget that CentOS 7 has Boost 1.53. */
1525 static inline std::string
to_string(const boost::string_ref
& s
)
1527 return std::string(s
.data(), s
.length());
1530 void rgw::keystone::AdminTokenRequestVer2::dump(Formatter
* const f
) const
1532 f
->open_object_section("token_request");
1533 f
->open_object_section("auth");
1534 f
->open_object_section("passwordCredentials");
1535 encode_json("username", ::to_string(conf
.get_admin_user()), f
);
1536 encode_json("password", conf
.get_admin_password(), f
);
1538 encode_json("tenantName", ::to_string(conf
.get_admin_tenant()), f
);
1543 void rgw::keystone::AdminTokenRequestVer3::dump(Formatter
* const f
) const
1545 f
->open_object_section("token_request");
1546 f
->open_object_section("auth");
1547 f
->open_object_section("identity");
1548 f
->open_array_section("methods");
1549 f
->dump_string("", "password");
1551 f
->open_object_section("password");
1552 f
->open_object_section("user");
1553 f
->open_object_section("domain");
1554 encode_json("name", ::to_string(conf
.get_admin_domain()), f
);
1556 encode_json("name", ::to_string(conf
.get_admin_user()), f
);
1557 encode_json("password", conf
.get_admin_password(), f
);
1561 f
->open_object_section("scope");
1562 f
->open_object_section("project");
1563 if (! conf
.get_admin_project().empty()) {
1564 encode_json("name", ::to_string(conf
.get_admin_project()), f
);
1566 encode_json("name", ::to_string(conf
.get_admin_tenant()), f
);
1568 f
->open_object_section("domain");
1569 encode_json("name", ::to_string(conf
.get_admin_domain()), f
);
1578 void rgw::keystone::BarbicanTokenRequestVer2::dump(Formatter
* const f
) const
1580 f
->open_object_section("token_request");
1581 f
->open_object_section("auth");
1582 f
->open_object_section("passwordCredentials");
1583 encode_json("username", cct
->_conf
->rgw_keystone_barbican_user
, f
);
1584 encode_json("password", cct
->_conf
->rgw_keystone_barbican_password
, f
);
1586 encode_json("tenantName", cct
->_conf
->rgw_keystone_barbican_tenant
, f
);
1591 void rgw::keystone::BarbicanTokenRequestVer3::dump(Formatter
* const f
) const
1593 f
->open_object_section("token_request");
1594 f
->open_object_section("auth");
1595 f
->open_object_section("identity");
1596 f
->open_array_section("methods");
1597 f
->dump_string("", "password");
1599 f
->open_object_section("password");
1600 f
->open_object_section("user");
1601 f
->open_object_section("domain");
1602 encode_json("name", cct
->_conf
->rgw_keystone_barbican_domain
, f
);
1604 encode_json("name", cct
->_conf
->rgw_keystone_barbican_user
, f
);
1605 encode_json("password", cct
->_conf
->rgw_keystone_barbican_password
, f
);
1609 f
->open_object_section("scope");
1610 f
->open_object_section("project");
1611 if (!cct
->_conf
->rgw_keystone_barbican_project
.empty()) {
1612 encode_json("name", cct
->_conf
->rgw_keystone_barbican_project
, f
);
1614 encode_json("name", cct
->_conf
->rgw_keystone_barbican_tenant
, f
);
1616 f
->open_object_section("domain");
1617 encode_json("name", cct
->_conf
->rgw_keystone_barbican_domain
, f
);
1625 void RGWOrphanSearchStage::dump(Formatter
*f
) const
1627 f
->open_object_section("orphan_search_stage");
1630 case ORPHAN_SEARCH_STAGE_INIT
:
1633 case ORPHAN_SEARCH_STAGE_LSPOOL
:
1636 case ORPHAN_SEARCH_STAGE_LSBUCKETS
:
1639 case ORPHAN_SEARCH_STAGE_ITERATE_BI
:
1640 s
= "iterate_bucket_index";
1642 case ORPHAN_SEARCH_STAGE_COMPARE
:
1648 f
->dump_string("search_stage", s
);
1649 f
->dump_int("shard",shard
);
1650 f
->dump_string("marker",marker
);
1654 void RGWOrphanSearchInfo::dump(Formatter
*f
) const
1656 f
->open_object_section("orphan_search_info");
1657 f
->dump_string("job_name", job_name
);
1658 encode_json("pool", pool
, f
);
1659 f
->dump_int("num_shards", num_shards
);
1660 encode_json("start_time", start_time
, f
);
1664 void RGWOrphanSearchState::dump(Formatter
*f
) const
1666 f
->open_object_section("orphan_search_state");
1667 encode_json("info", info
, f
);
1668 encode_json("stage", stage
, f
);
1672 void RGWObjTags::dump(Formatter
*f
) const
1674 for (auto& tag
: tag_map
){
1675 f
->open_object_section("tag_map");
1676 f
->dump_string("key", tag
.first
);
1677 f
->dump_string("value", tag
.second
);
1682 void lc_op::dump(Formatter
*f
) const
1684 f
->dump_bool("status", status
);
1685 f
->dump_bool("dm_expiration", dm_expiration
);
1687 f
->dump_int("expiration", expiration
);
1688 f
->dump_int("noncur_expiration", noncur_expiration
);
1689 f
->dump_int("mp_expiration", mp_expiration
);
1690 if (expiration_date
) {
1691 utime_t
ut(*expiration_date
);
1692 f
->dump_stream("expiration_date") << ut
;
1695 f
->dump_object("obj_tags", *obj_tags
);
1699 void LCFilter::dump(Formatter
*f
) const
1701 f
->dump_string("prefix", prefix
);
1702 f
->dump_object("obj_tags", obj_tags
);
1705 void LCExpiration::dump(Formatter
*f
) const
1707 f
->dump_string("days", days
);
1708 f
->dump_string("date", date
);
1711 void LCRule::dump(Formatter
*f
) const
1713 f
->dump_string("id", id
);
1714 f
->dump_string("prefix", prefix
);
1715 f
->dump_string("status", status
);
1716 f
->dump_object("expiration", expiration
);
1717 f
->dump_object("noncur_expiration", noncur_expiration
);
1718 f
->dump_object("mp_expiration", mp_expiration
);
1719 f
->dump_object("filter", filter
);
1720 f
->dump_bool("dm_expiration", dm_expiration
);
1723 void RGWLifecycleConfiguration::dump(Formatter
*f
) const
1725 f
->open_object_section("prefix_map");
1726 for (auto& prefix
: prefix_map
) {
1727 f
->dump_object(prefix
.first
.c_str(), prefix
.second
);
1731 f
->open_array_section("rule_map");
1732 for (auto& rule
: rule_map
) {
1733 f
->open_object_section("entry");
1734 f
->dump_string("id", rule
.first
);
1735 f
->open_object_section("rule");
1736 rule
.second
.dump(f
);
1743 void compression_block::dump(Formatter
*f
) const
1745 f
->dump_unsigned("old_ofs", old_ofs
);
1746 f
->dump_unsigned("new_ofs", new_ofs
);
1747 f
->dump_unsigned("len", len
);
1750 void RGWCompressionInfo::dump(Formatter
*f
) const
1752 f
->dump_string("compression_type", compression_type
);
1753 f
->dump_unsigned("orig_size", orig_size
);
1754 ::encode_json("blocks", blocks
, f
);