From: Orit Wasserman Date: Wed, 14 Oct 2015 15:37:33 +0000 (+0200) Subject: rgw: update zone endpoints when creating a new zone X-Git-Tag: v10.1.0~354^2~364 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fc3df345c562d3cae4ce6e9611dd8e574fa776f9;p=ceph.git rgw: update zone endpoints when creating a new zone Signed-off-by: Orit Wasserman --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index b82fbeac8905..c3e4877af40f 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -191,6 +191,7 @@ void _usage() cerr << " --rgw-zonegroup= zonegroup name\n"; cerr << " --zone= zone name\n"; cerr << " --rgw-zone= zone in which radosgw is running\n"; + cerr << " --endpoints= zone endpoints\n"; cerr << " --fix besides checking bucket index, will also fix it\n"; cerr << " --check-objects bucket check: rebuilds bucket index according to\n"; cerr << " actual objects state\n"; @@ -1357,6 +1358,7 @@ int main(int argc, char **argv) std::string realm_name, realm_id, realm_new_name; std::string zone_name, zone_id, zone_new_name; std::string zonegroup_name, zonegroup_id, zonegroup_new_name; + list endpoints; std::string master_url; int is_master = false; int key_type = KEY_TYPE_UNDEFINED; @@ -1694,6 +1696,9 @@ int main(int argc, char **argv) zone_id = val; } else if (ceph_argparse_witharg(args, i, &val, "--zone-new-name", (char*)NULL)) { zone_new_name = val; + } else if (ceph_argparse_witharg(args, i, &val, "--endpoints", (char*)NULL)) { + list::iterator iter; + get_str_list(val, endpoints); } else if (ceph_argparse_witharg(args, i, &val, "--source-zone", (char*)NULL)) { source_zone = val; } else if (strncmp(*i, "-", 1) == 0) { @@ -2635,7 +2640,7 @@ int main(int argc, char **argv) cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl; return -ret; } - ret = zonegroup.add_zone(zone, is_master); + ret = zonegroup.add_zone(zone, is_master, endpoints); if (ret < 0) { cerr << "failed to add zone " << zone_name << " to zonegroup " << zonegroup.get_name() << ": " << cpp_strerror(-ret) << std::endl; @@ -2710,7 +2715,7 @@ int main(int argc, char **argv) cerr << "ERROR: couldn't init realm:" << cpp_strerror(-ret) << std::endl; return ret; } - ret = zonegroup.add_zone(zone, is_master); + ret = zonegroup.add_zone(zone, is_master, endpoints); if (ret < 0) { cerr << "failed to add zone " << zone_name << " to zonegroup " << zonegroup.get_name() << ": " << cpp_strerror(-ret) << std::endl; @@ -2882,7 +2887,7 @@ int main(int argc, char **argv) return -ret; } - ret = zonegroup.add_zone(zone, is_master); + ret = zonegroup.add_zone(zone, is_master, endpoints); if (ret < 0) { cerr << "failed to update zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index ae7c7fc9e28c..eb063b6519eb 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -229,7 +229,7 @@ int RGWZoneGroup::equals(const string& other_zonegroup) const return (id == other_zonegroup); } -int RGWZoneGroup::add_zone(const RGWZoneParams& zone_params, bool is_master) +int RGWZoneGroup::add_zone(const RGWZoneParams& zone_params, bool is_master, const list& endpoints) { if (is_master) { if (!master_zone.empty() && master_zone != zone_params.get_id()) { @@ -245,7 +245,9 @@ int RGWZoneGroup::add_zone(const RGWZoneParams& zone_params, bool is_master) RGWZone& zone = zones[zone_params.get_id()]; zone.name = zone_params.get_name(); zone.id = zone_params.get_id(); - + if (!endpoints.empty()) { + zone.endpoints = endpoints; + } return update(); } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 03f524f6773d..c3eed5a5eda6 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1124,7 +1124,7 @@ struct RGWZoneGroup : public RGWSystemMetaObj { int create_default(bool old_format = false); int equals(const string& other_zonegroup) const; - int add_zone(const RGWZoneParams& zone_params, bool is_master); + int add_zone(const RGWZoneParams& zone_params, bool is_master, const list& endpoints); int remove_zone(const RGWZoneParams& zone_params); const string& get_pool_name(CephContext *cct);