From b59afea4dbb06454b1e14f03dd65ba2449674a15 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 30 Nov 2016 14:36:38 -0500 Subject: [PATCH] radosgw-admin: 'zone placement modify' doesnt require pool names Signed-off-by: Casey Bodley --- src/rgw/rgw_admin.cc | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 26b8d2e32a39c..940bca28bda8f 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2374,9 +2374,9 @@ int main(int argc, char **argv) map tier_config_add; map tier_config_rm; - 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; @@ -4084,19 +4084,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; } -- 2.39.5