]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw-admin: sync group get command
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 17 Oct 2019 19:55:22 +0000 (12:55 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 28 Jan 2020 18:20:37 +0000 (10:20 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc

index 1717fbfd84f4a84f63405eb80588b0def15e8fd6..c7b71d94267a53f0eb1aa33ab7aece51ac1c8734 100644 (file)
@@ -650,6 +650,7 @@ enum class OPT {
   SYNC_ERROR_LIST,
   SYNC_ERROR_TRIM,
   SYNC_GROUP_CREATE,
+  SYNC_GROUP_GET,
   SYNC_GROUP_REMOVE,
   SYNC_GROUP_FLOW_ADD,
   SYNC_GROUP_FLOW_REMOVE,
@@ -849,6 +850,7 @@ static SimpleCmd::Commands all_cmds = {
   { "sync error trim", OPT::SYNC_ERROR_TRIM },
   { "sync policy get", OPT::SYNC_POLICY_GET },
   { "sync group create", OPT::SYNC_GROUP_CREATE },
+  { "sync group get", OPT::SYNC_GROUP_GET },
   { "sync group remove", OPT::SYNC_GROUP_REMOVE },
   { "sync group flow add", OPT::SYNC_GROUP_FLOW_ADD },
   { "sync group flow remove", OPT::SYNC_GROUP_FLOW_REMOVE },
@@ -3375,6 +3377,7 @@ int main(int argc, const char **argv)
                         OPT::MDLOG_LIST,
                         OPT::MDLOG_STATUS,
                         OPT::SYNC_ERROR_LIST,
+                        OPT::SYNC_GROUP_GET,
                         OPT::SYNC_POLICY_GET,
                         OPT::BILOG_LIST,
                         OPT::BILOG_STATUS,
@@ -7662,6 +7665,29 @@ next:
     formatter->flush(cout);
   }
 
+  if (opt_cmd == OPT::SYNC_GROUP_GET) {
+    RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name);
+    ret = zonegroup.init(g_ceph_context, store->svc()->sysobj);
+    if (ret < 0) {
+      cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
+      return -ret;
+    }
+
+    auto& groups = zonegroup.sync_policy.groups;
+
+    if (!opt_group_id) {
+      show_result(groups, formatter, cout);
+    } else {
+      auto iter = zonegroup.sync_policy.groups.find(*opt_group_id);
+      if (iter == zonegroup.sync_policy.groups.end()) {
+        cerr << "ERROR: could not find group '" << *opt_group_id << "'" << std::endl;
+        return ENOENT;
+      }
+
+      show_result(iter->second, formatter, cout);
+    }
+  }
+
   if (opt_cmd == OPT::SYNC_GROUP_REMOVE) {
     CHECK_TRUE(require_opt(opt_group_id, "ERROR: --group-id not specified"), EINVAL);