From: Casey Bodley Date: Wed, 30 Nov 2016 19:36:38 +0000 (-0500) Subject: radosgw-admin: 'zone placement modify' doesnt require pool names X-Git-Tag: v10.2.6~60^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ddb5403605f843b4bc5abd1093b034e087c07f8b;p=ceph.git radosgw-admin: 'zone placement modify' doesnt require pool names Signed-off-by: Casey Bodley (cherry picked from commit b59afea4dbb06454b1e14f03dd65ba2449674a15) Conflicts: src/rgw/rgw_admin.cc (jewel-next lacks --tier* options) --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 99bfe8d5eee..3cc257a68ac 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2109,9 +2109,9 @@ int main(int argc, char **argv) string source_zone_name; string source_zone; /* zone id */ - string index_pool; - string data_pool; - string data_extra_pool; + boost::optional index_pool; + boost::optional data_pool; + boost::optional data_extra_pool; RGWBucketIndexType placement_index_type = RGWBIType_Normal; bool index_type_specified = false; @@ -3785,19 +3785,41 @@ int main(int argc, char **argv) return -ret; } - if (opt_cmd == OPT_ZONE_PLACEMENT_ADD || - opt_cmd == OPT_ZONE_PLACEMENT_MODIFY) { - RGWZonePlacementInfo& info = zone.placement_pools[placement_id]; - - if (index_pool.empty() || data_pool.empty()) { + 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; return EINVAL; } - info.index_pool = index_pool; - info.data_pool = data_pool; - info.data_extra_pool = data_extra_pool; + RGWZonePlacementInfo& info = zone.placement_pools[placement_id]; + info.index_pool = *index_pool; + info.data_pool = *data_pool; + if (data_extra_pool) { + info.data_extra_pool = *data_extra_pool; + } + if (index_type_specified) { + info.index_type = placement_index_type; + } + } else if (opt_cmd == OPT_ZONE_PLACEMENT_MODIFY) { + auto p = zone.placement_pools.find(placement_id); + if (p == zone.placement_pools.end()) { + cerr << "ERROR: zone placement target '" << placement_id + << "' not found" << std::endl; + return -ENOENT; + } + auto& info = p->second; + if (index_pool && !index_pool->empty()) { + info.index_pool = *index_pool; + } + if (data_pool && !data_pool->empty()) { + info.data_pool = *data_pool; + } + if (data_extra_pool) { + info.data_extra_pool = *data_extra_pool; + } if (index_type_specified) { info.index_type = placement_index_type; }