From 11f67b1de7266378c1873fbf646415782056f620 Mon Sep 17 00:00:00 2001 From: yuliyang Date: Tue, 29 Oct 2019 09:32:59 +0800 Subject: [PATCH] rgw: radosgw-admin zone placement rm and radosgw-admin zonegroup placement rm support --storage-class to remove specify storage class config Signed-off-by: yuliyang --- src/rgw/rgw_admin.cc | 20 ++++++++++++++++++-- src/rgw/rgw_zone.h | 6 ++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 4a9dadae7d5..604041ed7a4 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -4338,7 +4338,15 @@ int main(int argc, const char **argv) } target.storage_classes.insert(rule.get_storage_class()); } else if (opt_cmd == OPT_ZONEGROUP_PLACEMENT_RM) { - zonegroup.placement_targets.erase(placement_id); + if (storage_class.empty()) { + zonegroup.placement_targets.erase(placement_id); + } else { + auto iter = zonegroup.placement_targets.find(placement_id); + if (iter != zonegroup.placement_targets.end()) { + RGWZoneGroupPlacementTarget& info = zonegroup.placement_targets[placement_id]; + info.storage_classes.erase(storage_class); + } + } } else if (opt_cmd == OPT_ZONEGROUP_PLACEMENT_DEFAULT) { if (!zonegroup.placement_targets.count(placement_id)) { cerr << "failed to find a zonegroup placement target named '" @@ -4843,7 +4851,15 @@ int main(int argc, const char **argv) return ret; } } else if (opt_cmd == OPT_ZONE_PLACEMENT_RM) { - zone.placement_pools.erase(placement_id); + if (storage_class.empty()) { + zone.placement_pools.erase(placement_id); + } else { + auto iter = zone.placement_pools.find(placement_id); + if (iter != zone.placement_pools.end()) { + RGWZonePlacementInfo& info = zone.placement_pools[placement_id]; + info.storage_classes.remove_storage_class(storage_class); + } + } } ret = zone.update(); diff --git a/src/rgw/rgw_zone.h b/src/rgw/rgw_zone.h index 9ce902040b3..eeab5709612 100644 --- a/src/rgw/rgw_zone.h +++ b/src/rgw/rgw_zone.h @@ -238,6 +238,12 @@ public: } } + void remove_storage_class(const string& sc) { + if (!sc.empty()) { + m.erase(sc); + } + } + void encode(bufferlist& bl) const { ENCODE_START(1, 1, bl); encode(m, bl); -- 2.47.3