]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: allow 'period pull --url' without full multisite config
authorCasey Bodley <cbodley@redhat.com>
Fri, 8 Apr 2016 19:54:27 +0000 (15:54 -0400)
committerCasey Bodley <cbodley@redhat.com>
Tue, 12 Apr 2016 21:14:50 +0000 (17:14 -0400)
to support 'period pull --remote', radosgw-admin needs a complete
multisite configuration to look up remote endpoints by name

however, 'period pull' will also accept a --url argument, which doesn't
require a working configuration. this patch splits the handling of these
two cases, so that 'period pull --url' can succeed when run on a cluster
that hasn't yet been fully configured

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_admin.cc

index f95afc66bf58a7333b6e9609a5d2a25e2ac8f720..a8420cec5953a89abe336d92aad858432ea882f5 100644 (file)
@@ -2383,6 +2383,11 @@ int main(int argc, char **argv)
 
   RGWStreamFlusher f(formatter, cout);
 
+  // not a raw op if 'period update' needs to commit to master
+  bool raw_period_update = opt_cmd == OPT_PERIOD_UPDATE && !commit;
+  // not a raw op if 'period pull' needs to look up remotes
+  bool raw_period_pull = opt_cmd == OPT_PERIOD_PULL && remote.empty() && !url.empty();
+
   bool raw_storage_op = (opt_cmd == OPT_ZONEGROUP_ADD || opt_cmd == OPT_ZONEGROUP_CREATE || opt_cmd == OPT_ZONEGROUP_DELETE ||
                         opt_cmd == OPT_ZONEGROUP_GET || opt_cmd == OPT_ZONEGROUP_LIST ||  
                          opt_cmd == OPT_ZONEGROUP_SET || opt_cmd == OPT_ZONEGROUP_DEFAULT ||
@@ -2395,7 +2400,7 @@ int main(int argc, char **argv)
                         opt_cmd == OPT_REALM_CREATE || opt_cmd == OPT_PERIOD_PREPARE ||
                         opt_cmd == OPT_PERIOD_DELETE || opt_cmd == OPT_PERIOD_GET ||
                         opt_cmd == OPT_PERIOD_GET_CURRENT || opt_cmd == OPT_PERIOD_LIST ||
-                        (opt_cmd == OPT_PERIOD_UPDATE && !commit) ||
+                         raw_period_update || raw_period_pull ||
                         opt_cmd == OPT_REALM_DELETE || opt_cmd == OPT_REALM_GET || opt_cmd == OPT_REALM_LIST ||
                         opt_cmd == OPT_REALM_LIST_PERIODS ||
                         opt_cmd == OPT_REALM_GET_DEFAULT || opt_cmd == OPT_REALM_REMOVE ||
@@ -2536,6 +2541,26 @@ int main(int argc, char **argv)
        }
       }
       break;
+    case OPT_PERIOD_PULL: // period pull --url
+      {
+        if (url.empty()) {
+          cerr << "A --url or --remote must be provided." << std::endl;
+          return -EINVAL;
+        }
+        RGWPeriod period;
+        int ret = do_period_pull(remote, url, access_key, secret_key,
+                                 realm_id, realm_name, period_id, period_epoch,
+                                 &period);
+        if (ret < 0) {
+          cerr << "period pull failed: " << cpp_strerror(-ret) << std::endl;
+          return ret;
+        }
+
+        encode_json("period", period, formatter);
+        formatter->flush(cout);
+        cout << std::endl;
+      }
+      break;
     case OPT_REALM_CREATE:
       {
        if (realm_name.empty()) {
@@ -3732,9 +3757,9 @@ int main(int argc, char **argv)
       }
     }
     return 0;
-  case OPT_PERIOD_PULL:
+  case OPT_PERIOD_PULL: // period pull --remote
     {
-      if (remote.empty() && url.empty() ) {
+      if (remote.empty()) {
        /* use realm master zonegroup as remote */
        RGWRealm realm(realm_id, realm_name);
        int ret = realm.init(g_ceph_context, store);
@@ -3756,6 +3781,7 @@ int main(int argc, char **argv)
                                &period);
       if (ret < 0) {
         cerr << "period pull failed: " << cpp_strerror(-ret) << std::endl;
+        return ret;
       }
 
       encode_json("period", period, formatter);