}
if (opt_cmd == OPT_ZONE_PLACEMENT_ADD) {
- // pool names are required
- if (!index_pool || index_pool->empty() ||
- !data_pool || data_pool->empty()) {
- cerr << "ERROR: need to specify both --index-pool and --data-pool" << std::endl;
+ RGWZonePlacementInfo& info = zone.placement_pools[placement_id];
+
+ string opt_index_pool = index_pool.value_or(string());
+ string opt_data_pool = data_pool.value_or(string());
+
+ if (!opt_index_pool.empty()) {
+ info.index_pool = opt_index_pool;
+ }
+
+ if (info.index_pool.empty()) {
+ cerr << "ERROR: index pool not configured, need to specify --index-pool" << std::endl;
return EINVAL;
- }
+ }
- RGWZonePlacementInfo& info = zone.placement_pools[placement_id];
+ if (opt_data_pool.empty()) {
+ const RGWZoneStorageClass *porig_sc{nullptr};
+ if (info.storage_classes.find(storage_class, &porig_sc)) {
+ if (porig_sc->data_pool) {
+ opt_data_pool = porig_sc->data_pool->to_str();
+ }
+ }
+ if (opt_data_pool.empty()) {
+ cerr << "ERROR: data pool not configured, need to specify --data-pool" << std::endl;
+ return EINVAL;
+ }
+ }
- info.index_pool = *index_pool;
- rgw_pool dp = data_pool.get();
+ rgw_pool dp = opt_data_pool;
info.storage_classes.set_storage_class(storage_class, &dp, compression_type.get_ptr());
if (data_extra_pool) {
info.data_extra_pool = *data_extra_pool;
}
if (index_type_specified) {
- info.index_type = placement_index_type;
+ info.index_type = placement_index_type;
}
ret = check_pool_support_omap(info.get_data_extra_pool());
boost::optional<RGWPutObj_Compress> compressor;
CompressorRef plugin;
- const auto& compression_type = svc.zone->get_zone_params().get_compression_type(
- dest_bucket_info.placement_rule);
- if (compression_type != "none") {
- plugin = Compressor::create(cct, compression_type);
- if (!plugin) {
- ldout(cct, 1) << "Cannot load plugin for compression type "
- << compression_type << dendl;
- }
- }
-
+ rgw_placement_rule dest_rule;
RGWRadosPutObj cb(cct, plugin, compressor, &processor, progress_cb, progress_data,
[&](const map<string, bufferlist>& obj_attrs) {
if (!ptail_rule) {
auto iter = obj_attrs.find(RGW_ATTR_STORAGE_CLASS);
if (iter != obj_attrs.end()) {
- rgw_placement_rule dest_rule;
dest_rule.storage_class = iter->second.to_str();
dest_rule.inherit_from(dest_bucket_info.placement_rule);
processor.set_tail_placement(std::move(dest_rule));
+ ptail_rule = &dest_rule;
+ } else {
+ ptail_rule = &dest_bucket_info.placement_rule;
}
}
return 0;
});
+ const auto& compression_type = svc.zone->get_zone_params().get_compression_type(
+ *ptail_rule);
+ if (compression_type != "none") {
+ plugin = Compressor::create(cct, compression_type);
+ if (!plugin) {
+ ldout(cct, 1) << "Cannot load plugin for compression type "
+ << compression_type << dendl;
+ }
+ }
+
string etag;
real_time set_mtime;