From f527342a8d9cf45b564c0cd86c6f838d1fe6e1dd Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Sat, 8 Apr 2017 12:55:36 -0400 Subject: [PATCH] radosgw-admin: get remote connections from given period/zonegroup helper functions to create connections to arbitrary remotes, rather than depending on RGWRados to construct them in zone[group]_conn_map Signed-off-by: Casey Bodley --- src/rgw/rgw_admin.cc | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index c7d087c0765c8..771ce692dfd00 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1511,6 +1511,41 @@ int do_check_object_locator(const string& tenant_name, const string& bucket_name return 0; } +/// search for a matching zone/zonegroup id and return a connection if found +static boost::optional get_remote_conn(RGWRados *store, + const RGWZoneGroup& zonegroup, + const std::string& remote) +{ + boost::optional conn; + if (remote == zonegroup.get_id()) { + conn.emplace(store->ctx(), store, remote, zonegroup.endpoints); + } else { + for (const auto& z : zonegroup.zones) { + const auto& zone = z.second; + if (remote == zone.id) { + conn.emplace(store->ctx(), store, remote, zone.endpoints); + break; + } + } + } + return conn; +} + +/// search each zonegroup for a connection +static boost::optional get_remote_conn(RGWRados *store, + const RGWPeriodMap& period_map, + const std::string& remote) +{ + boost::optional conn; + for (const auto& zg : period_map.zonegroups) { + conn = get_remote_conn(store, zg.second, remote); + if (conn) { + break; + } + } + return conn; +} + #define MAX_REST_RESPONSE (128 * 1024) // we expect a very small response static int send_to_remote_gateway(const string& remote, req_info& info, bufferlist& in_data, JSONParser& parser) -- 2.39.5