}
};
+ struct Source { /* rgw extension */
+ std::vector<string> zone_names;
+
+ void decode_xml(XMLObj *obj) {
+ RGWXMLDecoder::decode_xml("Zone", zone_names, obj);
+ }
+ };
+
struct Destination {
struct AccessControlTranslation {
string owner;
std::optional<string> account;
string bucket;
std::optional<string> storage_class;
+ std::vector<string> zone_names;
void decode_xml(XMLObj *obj) {
RGWXMLDecoder::decode_xml("AccessControlTranslation", acl_translation, obj);
if (storage_class && storage_class->empty()) {
storage_class.reset();
}
+ RGWXMLDecoder::decode_xml("Zone", zone_names, obj); /* rgw extension */
}
};
}
};
+ set<rgw_zone_id> get_zone_ids_from_names(rgw::sal::RGWRadosStore *store,
+ const vector<string>& zone_names) const {
+ set<rgw_zone_id> ids;
+
+ for (auto& name : zone_names) {
+ rgw_zone_id id;
+ if (store->svc()->zone->find_zone_id_by_name(name, &id)) {
+ ids.insert(std::move(id));
+ }
+ }
+
+ return std::move(ids);
+ }
+
std::optional<DeleteMarkerReplication> delete_marker_replication;
+ std::optional<Source> source;
Destination destination;
std::optional<Filter> filter;
string id;
void decode_xml(XMLObj *obj) {
RGWXMLDecoder::decode_xml("DeleteMarkerReplication", delete_marker_replication, obj);
+ RGWXMLDecoder::decode_xml("Source", source, obj);
RGWXMLDecoder::decode_xml("Destination", destination, obj);
RGWXMLDecoder::decode_xml("ID", id, obj);
return true;
}
- int to_sync_policy_pipe(req_state *s,
+ int to_sync_policy_pipe(req_state *s, rgw::sal::RGWRadosStore *store,
rgw_sync_bucket_pipes *pipe,
bool *enabled) const {
if (!is_valid(s->cct)) {
rgw_bucket_key dest_bk(user_id.tenant,
destination.bucket);
- pipe->source.set_all_zones(true); /*
- all zones that correspond with configured flow,
- we can introduce extended api to select specific
- zones
- */
- pipe->dest.set_all_zones(true);
+ if (source && !source->zone_names.empty()) {
+ pipe->source.zones = get_zone_ids_from_names(store, source->zone_names);
+ } else {
+ pipe->source.set_all_zones(true);
+ }
+ if (!destination.zone_names.empty()) {
+ pipe->dest.zones = get_zone_ids_from_names(store, destination.zone_names);
+ } else {
+ pipe->dest.set_all_zones(true);
+ }
pipe->dest.bucket.emplace(dest_bk);
if (filter) {
RGWXMLDecoder::decode_xml("Rule", rules, obj);
}
- int to_sync_policy_groups(req_state *s,
+ int to_sync_policy_groups(req_state *s, rgw::sal::RGWRadosStore *store,
vector<rgw_sync_policy_group> *result) const {
result->resize(2);
for (auto& rule : rules) {
rgw_sync_bucket_pipes pipe;
bool enabled;
- int r = rule.to_sync_policy_pipe(s, &pipe, &enabled);
+ int r = rule.to_sync_policy_pipe(s, store, &pipe, &enabled);
if (r < 0) {
ldout(s->cct, 5) << "NOTICE: failed to convert replication configuration into sync policy pipe (rule.id=" << rule.id << "): " << cpp_strerror(-r) << dendl;
return r;
return -ERR_MALFORMED_XML;
}
- r = conf.to_sync_policy_groups(s, &sync_policy_groups);
+ r = conf.to_sync_policy_groups(s, store, &sync_policy_groups);
if (r < 0) {
return r;
}