return result;
}
+class JSONFormatter_PrettyZone : public JSONFormatter {
+ class Handler : public JSONEncodeFilter::Handler<rgw_zone_id> {
+ void encode_json(const char *name, const void *pval, ceph::Formatter *f) const override {
+ auto zone_id = *(static_cast<const rgw_zone_id *>(pval));
+ string zone_name;
+ RGWZone *zone;
+ if (store->svc()->zone->find_zone(zone_id, &zone)) {
+ zone_name = zone->name;
+ } else {
+ cerr << "WARNING: cannot find zone name for id=" << zone_id << std::endl;
+ zone_name = zone_id.id;
+ }
+
+ ::encode_json(name, zone_name, f);
+ }
+ } zone_id_type_handler;
+
+ JSONEncodeFilter encode_filter;
+public:
+ JSONFormatter_PrettyZone(bool pretty_format) : JSONFormatter(pretty_format) {
+ encode_filter.register_type(&zone_id_type_handler);
+ }
+
+ void *get_external_feature_handler(const std::string& feature) override {
+ if (feature != "JSONEncodeFilter") {
+ return nullptr;
+ }
+ return &encode_filter;
+ }
+};
+
int main(int argc, const char **argv)
{
vector<const char*> args;
string bucket_id;
string new_bucket_name;
Formatter *formatter = NULL;
+ Formatter *zone_formatter = nullptr;
int purge_data = false;
int pretty_format = false;
int show_log_entries = true;
exit(1);
}
+ zone_formatter = new JSONFormatter_PrettyZone(pretty_format);
+
realm_name = g_conf()->rgw_realm;
zone_name = g_conf()->rgw_zone;
zonegroup_name = g_conf()->rgw_zonegroup;
}
if (opt_cmd == OPT::SYNC_INFO) {
- sync_info(opt_effective_zone_id, opt_bucket, formatter);
+ sync_info(opt_effective_zone_id, opt_bucket, zone_formatter);
}
if (opt_cmd == OPT::SYNC_STATUS) {
return -ret;
}
- show_result(sync_policy, formatter, cout);
+ show_result(sync_policy, zone_formatter, cout);
}
if (opt_cmd == OPT::SYNC_GROUP_GET) {
auto& groups = sync_policy.groups;
if (!opt_group_id) {
- show_result(groups, formatter, cout);
+ show_result(groups, zone_formatter, cout);
} else {
auto iter = sync_policy.groups.find(*opt_group_id);
if (iter == sync_policy.groups.end()) {
return ENOENT;
}
- show_result(iter->second, formatter, cout);
+ show_result(iter->second, zone_formatter, cout);
}
}
}
{
- Formatter::ObjectSection os(*formatter, "result");
- encode_json("sync_policy", sync_policy, formatter);
+ Formatter::ObjectSection os(*zone_formatter, "result");
+ encode_json("sync_policy", sync_policy, zone_formatter);
}
- formatter->flush(cout);
+ zone_formatter->flush(cout);
}
if (opt_cmd == OPT::SYNC_GROUP_FLOW_CREATE) {
return -ret;
}
- show_result(sync_policy, formatter, cout);
+ show_result(sync_policy, zone_formatter, cout);
}
if (opt_cmd == OPT::SYNC_GROUP_FLOW_REMOVE) {
return -ret;
}
- show_result(sync_policy, formatter, cout);
+ show_result(sync_policy, zone_formatter, cout);
}
if (opt_cmd == OPT::SYNC_GROUP_PIPE_CREATE ||
opt_dest_bucket_name,
opt_dest_bucket_id);
- pipe->params.filter.set_prefix(opt_prefix, !!opt_prefix_rm);
- pipe->params.filter.set_tags(tags_add, tags_rm);
+ pipe->params.source.filter.set_prefix(opt_prefix, !!opt_prefix_rm);
+ pipe->params.source.filter.set_tags(tags_add, tags_rm);
if (opt_priority) {
pipe->params.priority = *opt_priority;
}
return -ret;
}
- show_result(sync_policy, formatter, cout);
+ show_result(sync_policy, zone_formatter, cout);
}
if (opt_cmd == OPT::SYNC_GROUP_PIPE_REMOVE) {
return -ret;
}
- show_result(sync_policy, formatter, cout);
+ show_result(sync_policy, zone_formatter, cout);
}
if (opt_cmd == OPT::SYNC_POLICY_GET) {
}
auto& sync_policy = sync_policy_ctx.get_policy();
- show_result(sync_policy, formatter, cout);
+ show_result(sync_policy, zone_formatter, cout);
}
if (opt_cmd == OPT::BILOG_TRIM) {
JSONDecoder::decode_json("owner", owner, obj);
}
+void rgw_sync_pipe_source_params::dump(Formatter *f) const
+{
+ encode_json("filter", filter, f);
+}
+
+void rgw_sync_pipe_source_params::decode_json(JSONObj *obj)
+{
+ JSONDecoder::decode_json("filter", filter, obj);
+}
+
void rgw_sync_pipe_dest_params::dump(Formatter *f) const
{
encode_json("acl_translation", acl_translation, f);
void rgw_sync_pipe_params::dump(Formatter *f) const
{
- encode_json("filter", filter, f);
- encode_json("dest_params", dest_params, f);
+ encode_json("source", source, f);
+ encode_json("dest", dest, f);
encode_json("priority", priority, f);
}
void rgw_sync_pipe_params::decode_json(JSONObj *obj)
{
- JSONDecoder::decode_json("filter", filter, obj);
- JSONDecoder::decode_json("dest_params", dest_params, obj);
+ JSONDecoder::decode_json("source", source, obj);
+ JSONDecoder::decode_json("dest", dest, obj);
JSONDecoder::decode_json("priority", priority, obj);
}
};
WRITE_CLASS_ENCODER(rgw_sync_pipe_acl_translation)
+struct rgw_sync_pipe_source_params {
+ rgw_sync_pipe_filter filter;
+
+ void encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ encode(filter, bl);
+ ENCODE_FINISH(bl);
+ }
+
+ void decode(bufferlist::const_iterator& bl) {
+ DECODE_START(1, bl);
+ decode(filter, bl);
+ DECODE_FINISH(bl);
+ }
+
+ void dump(ceph::Formatter *f) const;
+ void decode_json(JSONObj *obj);
+};
+WRITE_CLASS_ENCODER(rgw_sync_pipe_source_params)
+
struct rgw_sync_pipe_dest_params {
std::optional<rgw_sync_pipe_acl_translation> acl_translation;
std::optional<string> storage_class;
};
WRITE_CLASS_ENCODER(rgw_sync_pipe_dest_params)
-struct rgw_sync_pipe_params {
- rgw_sync_pipe_filter filter;
- rgw_sync_pipe_dest_params dest_params;
+struct rgw_sync_pipe_params {
+ rgw_sync_pipe_source_params source;
+ rgw_sync_pipe_dest_params dest;
int32_t priority{0};
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
- encode(filter, bl);
- encode(dest_params, bl);
+ encode(source, bl);
+ encode(dest, bl);
encode(priority, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::const_iterator& bl) {
DECODE_START(1, bl);
- decode(filter, bl);
- decode(dest_params, bl);
+ decode(source, bl);
+ decode(dest, bl);
decode(priority, bl);
DECODE_FINISH(bl);
}