]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add free function rgw::get_zonegroup_endpoint()
authorCasey Bodley <cbodley@redhat.com>
Tue, 3 Oct 2023 18:12:35 +0000 (14:12 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 6 Nov 2023 16:09:04 +0000 (11:09 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/driver/rados/rgw_zone.h
src/rgw/rgw_zone.cc

index 140678fcdce5afc06b0e18fd6c375b5f727d76a4..6d55fd52c57586577a5da934dec60e6f83bad8e1 100644 (file)
@@ -885,6 +885,9 @@ int set_default_zonegroup(const DoutPrefixProvider* dpp, optional_yield y,
                           sal::ConfigStore* cfgstore, const RGWZoneGroup& info,
                           bool exclusive = false);
 
+/// Return an endpoint from the zonegroup or its master zone.
+std::string get_zonegroup_endpoint(const RGWZoneGroup& info);
+
 /// Add a zone to the zonegroup, or update an existing zone entry.
 int add_zone_to_group(const DoutPrefixProvider* dpp,
                       RGWZoneGroup& zonegroup,
index 784c9c53fdc60fb4408bd6bb2070125338381f21..f41d987ec549ab8b8f4a1fe82a2648feec907747 100644 (file)
@@ -1268,6 +1268,19 @@ int init_zone_pool_names(const DoutPrefixProvider *dpp, optional_yield y,
   return 0;
 }
 
+std::string get_zonegroup_endpoint(const RGWZoneGroup& info)
+{
+  if (!info.endpoints.empty()) {
+    return info.endpoints.front();
+  }
+  // use zonegroup's master zone endpoints
+  auto z = info.zones.find(info.master_zone);
+  if (z != info.zones.end() && !z->second.endpoints.empty()) {
+    return z->second.endpoints.front();
+  }
+  return "";
+}
+
 int add_zone_to_group(const DoutPrefixProvider* dpp, RGWZoneGroup& zonegroup,
                       const RGWZoneParams& zone_params,
                       const bool *pis_master, const bool *pread_only,