]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw-admin: sync policy related commands
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 5 Sep 2019 09:26:33 +0000 (02:26 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 28 Jan 2020 18:20:36 +0000 (10:20 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_bucket_sync.cc
src/rgw/rgw_sync_policy.h

index 6235964b182623b50c9a37dd70b946307fb72944..b30113a5209a7228fe8e8af9783cfa820d9aa481 100644 (file)
@@ -649,6 +649,8 @@ enum class OPT {
   MDLOG_STATUS,
   SYNC_ERROR_LIST,
   SYNC_ERROR_TRIM,
+  SYNC_POLICY_GET,
+  SYNC_POLICY_CONNECT,
   BILOG_LIST,
   BILOG_TRIM,
   BILOG_STATUS,
@@ -3276,6 +3278,7 @@ int main(int argc, const char **argv)
                         OPT::MDLOG_LIST,
                         OPT::MDLOG_STATUS,
                         OPT::SYNC_ERROR_LIST,
+                        OPT::SYNC_POLICY_GET,
                         OPT::BILOG_LIST,
                         OPT::BILOG_STATUS,
                         OPT::DATA_SYNC_STATUS,
@@ -3298,6 +3301,7 @@ int main(int argc, const char **argv)
                         OPT::RESHARD_STATUS,
   };
 
+
   bool raw_storage_op = (raw_storage_ops_list.find(opt_cmd) != raw_storage_ops_list.end() ||
                          raw_period_update);
   bool need_cache = readonly_ops_list.find(opt_cmd) == readonly_ops_list.end();
@@ -7526,6 +7530,22 @@ next:
     }
   }
 
+  if (opt_cmd == OPT::SYNC_POLICY_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;
+    }
+
+    {
+      Formatter::ObjectSection os(*formatter, "result");
+      encode_json("sync_policy", zonegroup.sync_policy, formatter);
+    }
+
+    formatter->flush(cout);
+  }
+
   if (opt_cmd == OPT::BILOG_TRIM) {
     if (bucket_name.empty()) {
       cerr << "ERROR: bucket not specified" << std::endl;
index 61722627f23398f6cbf8f9bf8e2c288ab3781fa3..92d70fff1cd6685f9a6bfd787b0839ac908d9c4b 100644 (file)
@@ -28,6 +28,7 @@ void RGWBucketSyncPolicyInfo::post_init()
 int RGWBucketSyncPolicyHandler::init()
 {
   const auto& zone_id = zone_svc->get_zone().id;
+  auto& zg = svc.zone->get_zonegroup();
 
   if (!bucket_info.sync_policy) {
     return 0;
index 4acbafb7255970147932dc5a3caed8d5fb6cd6aa..0dbc3572d68d5f1cabf6f3ce9a8fdf3dea239f8d 100644 (file)
@@ -102,7 +102,8 @@ WRITE_CLASS_ENCODER(rgw_sync_source)
 struct rgw_sync_target {
   string id;
   string type;
-  std::vector<rgw_sync_flow_rule> flow_rules; /* flow rules for trivial sources */
+  std::optional<std::vector<rgw_sync_flow_rule> > flow_rules; /* flow rules for trivial sources,
+                                                                if set then needs to be a subset of higher level rules */
   std::set<string> zones;  /* target zones. Can be wildcard */
   /* FIXME: add config */