]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_admin: commands to manage placement targets
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 29 Nov 2016 22:55:52 +0000 (14:55 -0800)
committerNathan Cutler <ncutler@suse.com>
Fri, 9 Dec 2016 22:43:53 +0000 (23:43 +0100)
Fixes: http://tracker.ceph.com/issues/18078
added the following commands:

 radosgw-admin zone placement add
 radosgw-admin zone placement modify
 radosgw-admin zone placement rm
 radosgw-admin zone placement list

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit ead132ae84bf3b2738fa0443f4f9666d59edbb43)

Conflicts:
src/rgw/rgw_admin.cc (jewel-next lacks the --tier* and --sync-from* options)
src/test/cli/radosgw-admin/help.t (jewel-next lacks the --tier* and --sync-from* options)

src/rgw/rgw_admin.cc
src/test/cli/radosgw-admin/help.t

index a06b6f814106d41f848458ce50becaded49fc3dc..996783a7ec465dff1d7ec71dc510f63a1b83033a 100644 (file)
@@ -118,6 +118,10 @@ void _usage()
   cout << "  zone set                   set zone cluster params (requires infile)\n";
   cout << "  zone list                  list all zones set on this cluster\n";
   cout << "  zone rename                rename a zone\n";
+  cout << "  zone placement list        list zone's placement targets\n";
+  cout << "  zone placement add         add a zone placement target\n";
+  cout << "  zone placement modify      modify a zone placement target\n";
+  cout << "  zone placement rm          remove a zone placement target\n";
   cout << "  pool add                   add an existing pool for data placement\n";
   cout << "  pool rm                    remove an existing pool from data placement set\n";
   cout << "  pools list                 list placement active set\n";
@@ -210,6 +214,11 @@ void _usage()
   cout << "   --tags-add=<list>         list of tags to add for zonegroup placement modify command\n";
   cout << "   --tags-rm=<list>          list of tags to remove for zonegroup placement modify command\n";
   cout << "   --endpoints=<list>        zone endpoints\n";
+  cout << "   --index_pool=<pool>       placment target index pool\n";
+  cout << "   --data_pool=<pool>        placment target data pool\n";
+  cout << "   --data_extra_pool=<pool>  placment target data extra (non-ec) pool\n";
+  cout << "   --placement-index-type=<type>\n";
+  cout << "                             placement target index type (normal, indexless, or #id)\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";
@@ -334,6 +343,10 @@ enum {
   OPT_ZONE_LIST,
   OPT_ZONE_RENAME,
   OPT_ZONE_DEFAULT,
+  OPT_ZONE_PLACEMENT_ADD,
+  OPT_ZONE_PLACEMENT_MODIFY,
+  OPT_ZONE_PLACEMENT_RM,
+  OPT_ZONE_PLACEMENT_LIST,
   OPT_CAPS_ADD,
   OPT_CAPS_RM,
   OPT_METADATA_GET,
@@ -641,6 +654,16 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_
       return OPT_ZONEGROUPMAP_SET;
     if (strcmp(cmd, "update") == 0)
       return OPT_ZONEGROUPMAP_UPDATE;
+  } else if ((prev_prev_cmd && strcmp(prev_prev_cmd, "zone") == 0) &&
+            (strcmp(prev_cmd, "placement") == 0)) {
+    if (strcmp(cmd, "add") == 0)
+      return OPT_ZONE_PLACEMENT_ADD;
+    if (strcmp(cmd, "modify") == 0)
+      return OPT_ZONE_PLACEMENT_MODIFY;
+    if (strcmp(cmd, "rm") == 0)
+      return OPT_ZONE_PLACEMENT_RM;
+    if (strcmp(cmd, "list") == 0)
+      return OPT_ZONE_PLACEMENT_LIST;
   } else if (strcmp(prev_cmd, "zone") == 0) {
     if (strcmp(cmd, "delete") == 0)
       return OPT_ZONE_DELETE;
@@ -2082,6 +2105,12 @@ int main(int argc, char **argv)
   string source_zone_name;
   string source_zone; /* zone id */
 
+  string index_pool;
+  string data_pool;
+  string data_extra_pool;
+  RGWBucketIndexType placement_index_type = RGWBIType_Normal;
+  bool index_type_specified = false;
+
   for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
       break;
@@ -2350,6 +2379,25 @@ 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, "--index-pool", (char*)NULL)) {
+      index_pool = val;
+    } else if (ceph_argparse_witharg(args, i, &val, "--data-pool", (char*)NULL)) {
+      data_pool = val;
+    } else if (ceph_argparse_witharg(args, i, &val, "--data-extra-pool", (char*)NULL)) {
+      data_extra_pool = val;
+    } else if (ceph_argparse_witharg(args, i, &val, "--placement-index-type", (char*)NULL)) {
+      if (val == "normal") {
+        placement_index_type = RGWBIType_Normal;
+      } else if (val == "indexless") {
+        placement_index_type = RGWBIType_Indexless;
+      } else {
+        placement_index_type = (RGWBucketIndexType)strict_strtol(val.c_str(), 10, &err);
+        if (!err.empty()) {
+          cerr << "ERROR: failed to parse index type index: " << err << std::endl;
+          return EINVAL;
+        }
+      }
+      index_type_specified = true;
     } else if (strncmp(*i, "-", 1) == 0) {
       cerr << "ERROR: invalid flag " << *i << std::endl;
       return EINVAL;
@@ -2454,6 +2502,8 @@ int main(int argc, char **argv)
                         OPT_ZONE_CREATE, OPT_ZONE_DELETE,
                          OPT_ZONE_GET, OPT_ZONE_SET, OPT_ZONE_RENAME,
                          OPT_ZONE_LIST, OPT_ZONE_MODIFY, OPT_ZONE_DEFAULT,
+                        OPT_ZONE_PLACEMENT_ADD, OPT_ZONE_PLACEMENT_RM,
+                        OPT_ZONE_PLACEMENT_MODIFY, OPT_ZONE_PLACEMENT_LIST,
                         OPT_REALM_CREATE,
                         OPT_PERIOD_DELETE, OPT_PERIOD_GET,
                         OPT_PERIOD_GET_CURRENT, OPT_PERIOD_LIST,
@@ -3707,6 +3757,63 @@ int main(int argc, char **argv)
        }
       }
       break;
+    case OPT_ZONE_PLACEMENT_ADD:
+    case OPT_ZONE_PLACEMENT_MODIFY:
+    case OPT_ZONE_PLACEMENT_RM:
+      {
+        if (placement_id.empty()) {
+          cerr << "ERROR: --placement-id not specified" << std::endl;
+          return EINVAL;
+        }
+       RGWZoneParams zone(zone_id, zone_name);
+       int ret = zone.init(g_ceph_context, store);
+        if (ret < 0) {
+         cerr << "failed to init zone: " << cpp_strerror(-ret) << std::endl;
+         return -ret;
+       }
+
+        if (opt_cmd == OPT_ZONE_PLACEMENT_ADD ||
+            opt_cmd == OPT_ZONE_PLACEMENT_MODIFY) {
+          RGWZonePlacementInfo& info = zone.placement_pools[placement_id];
+
+          if (index_pool.empty() || data_pool.empty()) {
+            cerr << "ERROR: need to specify both --index-pool and --data-pool" << std::endl;
+            return EINVAL;
+          }
+
+          info.index_pool = index_pool;
+          info.data_pool = data_pool;
+          info.data_extra_pool = data_extra_pool;
+
+          if (index_type_specified) {
+            info.index_type = placement_index_type;
+          }
+        } else if (opt_cmd == OPT_ZONE_PLACEMENT_RM) {
+          zone.placement_pools.erase(placement_id);
+        }
+
+        ret = zone.update();
+        if (ret < 0) {
+          cerr << "failed to save zone info: " << cpp_strerror(-ret) << std::endl;
+          return -ret;
+        }
+
+        encode_json("zone", zone, formatter);
+        formatter->flush(cout);
+      }
+      break;
+    case OPT_ZONE_PLACEMENT_LIST:
+      {
+       RGWZoneParams zone(zone_id, zone_name);
+       int ret = zone.init(g_ceph_context, store);
+       if (ret < 0) {
+         cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl;
+         return -ret;
+       }
+       encode_json("placement_pools", zone.placement_pools, formatter);
+       formatter->flush(cout);
+      }
+      break;
     }
     return 0;
   }
index e159d9503a801b69458df833f8a0d4710dce40d6..b2068bcf30479896555bd8435ca1890de36a3c2b 100644 (file)
     zone set                   set zone cluster params (requires infile)
     zone list                  list all zones set on this cluster
     zone rename                rename a zone
+    zone placement list        list zone's placement targets
+    zone placement add         add a zone placement target
+    zone placement modify      modify a zone placement target
+    zone placement rm          remove a zone placement target
     pool add                   add an existing pool for data placement
     pool rm                    remove an existing pool from data placement set
     pools list                 list placement active set
      --tags-add=<list>         list of tags to add for zonegroup placement modify command
      --tags-rm=<list>          list of tags to remove for zonegroup placement modify command
      --endpoints=<list>        zone endpoints
+     --index_pool=<pool>       placment target index pool
+     --data_pool=<pool>        placment target data pool
+     --data_extra_pool=<pool>  placment target data extra (non-ec) pool
+     --placement-index-type=<type>
+                               placement target index type (normal, indexless, or #id)
      --fix                     besides checking bucket index, will also fix it
      --check-objects           bucket check: rebuilds bucket index according to
                                actual objects state