]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_admin: can set/modify zone tier's config
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 3 Aug 2016 17:24:44 +0000 (10:24 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 7 Oct 2016 16:58:21 +0000 (09:58 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 4dbac39ac1c8ea263eca68a52a0fdc273a9ea856..dac0aef839276bb806db89a0b306c9216c5466f9 100644 (file)
@@ -209,6 +209,12 @@ void _usage()
   cout << "   --default                 set entity (realm, zonegroup, zone) as default\n";
   cout << "   --read-only               set zone as read-only (when adding to zonegroup)\n";
   cout << "   --endpoints=<list>        zone endpoints\n";
+  cout << "   --tier-type=<type>        zone tier type\n";
+  cout << "   --tier-config=<k>=<v>[,...]\n";
+  cout << "                             set zone tier config keys, values\n";
+  cout << "   --tier-config-rm=<k>[,...]\n";
+  cout << "                             unset zone tier config keys\n";
+  cout << "   --tier_type=<type>        zone tier type\n";
   cout << "   --fix                     besides checking bucket index, will also fix it\n";
   cout << "   --check-objects           bucket check: rebuilds bucket index according to\n";
   cout << "                             actual objects state\n";
@@ -1966,7 +1972,21 @@ static void sync_status(Formatter *formatter)
   tab_dump("data sync", width, data_status);
 }
 
-int main(int argc, char **argv)
+static void parse_tier_config_param(const string& s, map<string, string>& out)
+{
+  list<string> confs;
+  get_str_list(s, ",", confs);
+  for (auto c : confs) {
+    ssize_t pos = c.find("=");
+    if (pos < 0) {
+      out[c] = "";
+    } else {
+      out[c.substr(0, pos)] = c.substr(pos + 1);
+    }
+  }
+}
+
+int main(int argc, char **argv) 
 {
   vector<const char*> args;
   argv_to_vec(argc, (const char **)argv, args);
@@ -2087,6 +2107,13 @@ int main(int argc, char **argv)
   string source_zone_name;
   string source_zone; /* zone id */
 
+  string tier_type;
+  bool tier_type_specified = false;
+
+  map<string, string> tier_config_add;
+  map<string, string> tier_config_rm;
+
+
   for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
       break;
@@ -2351,6 +2378,13 @@ int main(int argc, char **argv)
       get_str_list(val, endpoints);
     } else if (ceph_argparse_witharg(args, i, &val, "--source-zone", (char*)NULL)) {
       source_zone_name = val;
+    } else if (ceph_argparse_witharg(args, i, &val, "--tier-type", (char*)NULL)) {
+      tier_type = val;
+      tier_type_specified = true;
+    } else if (ceph_argparse_witharg(args, i, &val, "--tier-config", (char*)NULL)) {
+      parse_tier_config_param(val, tier_config_add);
+    } else if (ceph_argparse_witharg(args, i, &val, "--tier-config-rm", (char*)NULL)) {
+      parse_tier_config_param(val, tier_config_rm);
     } else if (strncmp(*i, "-", 1) == 0) {
       cerr << "ERROR: invalid flag " << *i << std::endl;
       return EINVAL;
@@ -2884,10 +2918,13 @@ int main(int argc, char **argv)
          cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl;
          return -ret;
        }
+        string *ptier_type = (tier_type_specified ? &tier_type : nullptr);
+        zone.tier_config = tier_config_add;
+
         ret = zonegroup.add_zone(zone,
                                  (is_master_set ? &is_master : NULL),
                                  (is_read_only_set ? &read_only : NULL),
-                                 endpoints);
+                                 endpoints, ptier_type);
        if (ret < 0) {
          cerr << "failed to add zone " << zone_name << " to zonegroup " << zonegroup.get_name() << ": "
               << cpp_strerror(-ret) << std::endl;
@@ -3302,10 +3339,12 @@ int main(int argc, char **argv)
        }
 
        if (!zonegroup_id.empty() || !zonegroup_name.empty()) {
+          string *ptier_type = (tier_type_specified ? &tier_type : nullptr);
          ret = zonegroup.add_zone(zone,
                                    (is_master_set ? &is_master : NULL),
                                    (is_read_only_set ? &read_only : NULL),
-                                   endpoints);
+                                   endpoints,
+                                   ptier_type);
          if (ret < 0) {
            cerr << "failed to add zone " << zone_name << " to zonegroup " << zonegroup.get_name()
                 << ": " << cpp_strerror(-ret) << std::endl;
@@ -3547,6 +3586,16 @@ int main(int argc, char **argv)
           need_zone_update = true;
         }
 
+        for (auto add : tier_config_add) {
+          zone.tier_config[add.first] = add.second;
+          need_zone_update = true;
+        }
+
+        for (auto rm : tier_config_rm) {
+          zone.tier_config.erase(rm.first);
+          need_zone_update = true;
+        }
+
         if (need_zone_update) {
           ret = zone.update();
           if (ret < 0) {
@@ -3561,11 +3610,12 @@ int main(int argc, char **argv)
          cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
          return -ret;
        }
+        string *ptier_type = (tier_type_specified ? &tier_type : nullptr);
 
         ret = zonegroup.add_zone(zone,
                                  (is_master_set ? &is_master : NULL),
                                  (is_read_only_set ? &read_only : NULL),
-                                 endpoints);
+                                 endpoints, ptier_type);
        if (ret < 0) {
          cerr << "failed to update zonegroup: " << cpp_strerror(-ret) << std::endl;
          return -ret;
index 6c41f7d8cebfd0e65220d6ec760dd463db3dee91..84b63bd0e87ae56222b3ed83929e910f99c93f7f 100644 (file)
@@ -247,7 +247,8 @@ int RGWZoneGroup::equals(const string& other_zonegroup) const
   return (id  == other_zonegroup);
 }
 
-int RGWZoneGroup::add_zone(const RGWZoneParams& zone_params, bool *is_master, bool *read_only, const list<string>& endpoints)
+int RGWZoneGroup::add_zone(const RGWZoneParams& zone_params, bool *is_master, bool *read_only, const list<string>& endpoints,
+                           const string *ptier_type)
 {
   auto& zone_id = zone_params.get_id();
   auto& zone_name = zone_params.get_name();
@@ -283,6 +284,9 @@ int RGWZoneGroup::add_zone(const RGWZoneParams& zone_params, bool *is_master, bo
   if (read_only) {
     zone.read_only = *read_only;
   }
+  if (ptier_type) {
+    zone.tier_type = *ptier_type;
+  }
 
   post_process_params();
 
index 13e1a7b3c97f6e862485c87ee0700b2ba32e8069..209269332cf4429c6aa99aadd387fcde95c06f0a 100644 (file)
@@ -1216,7 +1216,7 @@ struct RGWZoneGroup : public RGWSystemMetaObj {
   int set_as_default(bool exclusive = false) override;
   int create_default(bool old_format = false);
   int equals(const string& other_zonegroup) const;
-  int add_zone(const RGWZoneParams& zone_params, bool *is_master, bool *read_only, const list<string>& endpoints);
+  int add_zone(const RGWZoneParams& zone_params, bool *is_master, bool *read_only, const list<string>& endpoints, const string *ptier_type);
   int remove_zone(const std::string& zone_id);
   int rename_zone(const RGWZoneParams& zone_params);
   const string& get_pool_name(CephContext *cct);