]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: add 'realm default rm' command
authorCasey Bodley <cbodley@redhat.com>
Fri, 23 Aug 2024 18:53:46 +0000 (14:53 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 26 Aug 2024 21:59:37 +0000 (17:59 -0400)
the 'realm default' command could only set a different realm as the
default, and provided no way to clear the default

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit e946c4f5cfd6f356dbc18c5c42d8d639cb49270d)

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

index ac913342ddc16cf2cf0bfdf04774509a55c50850..0ce00d993e962a2c7f0a3cedcec67fa762e8a821 100644 (file)
@@ -223,6 +223,7 @@ void usage()
   cout << "  realm rename                     rename a realm\n";
   cout << "  realm set                        set realm info (requires infile)\n";
   cout << "  realm default                    set realm as default\n";
+  cout << "  realm default rm                 clear the current default realm\n";
   cout << "  realm pull                       pull a realm and its current period\n";
   cout << "  zonegroup add                    add a zone to a zonegroup\n";
   cout << "  zonegroup create                 create a new zone group info\n";
@@ -815,6 +816,7 @@ enum class OPT {
   REALM_RENAME,
   REALM_SET,
   REALM_DEFAULT,
+  REALM_DEFAULT_RM,
   REALM_PULL,
   PERIOD_DELETE,
   PERIOD_GET,
@@ -1056,6 +1058,7 @@ static SimpleCmd::Commands all_cmds = {
   { "realm rename", OPT::REALM_RENAME },
   { "realm set", OPT::REALM_SET },
   { "realm default", OPT::REALM_DEFAULT },
+  { "realm default rm", OPT::REALM_DEFAULT_RM },
   { "realm pull", OPT::REALM_PULL },
   { "period delete", OPT::PERIOD_DELETE },
   { "period get", OPT::PERIOD_GET },
@@ -4252,7 +4255,7 @@ int main(int argc, const char **argv)
                         OPT::REALM_LIST_PERIODS,
                         OPT::REALM_GET_DEFAULT,
                         OPT::REALM_RENAME, OPT::REALM_SET,
-                        OPT::REALM_DEFAULT, OPT::REALM_PULL};
+                        OPT::REALM_DEFAULT, OPT::REALM_DEFAULT_RM, OPT::REALM_PULL};
 
     std::set<OPT> readonly_ops_list = {
                          OPT::USER_INFO,
@@ -5108,6 +5111,12 @@ int main(int argc, const char **argv)
        }
       }
       break;
+    case OPT::REALM_DEFAULT_RM:
+      if (int ret = cfgstore->delete_default_realm_id(dpp(), null_yield); ret < 0) {
+        cerr << "failed to remove default realm: " << cpp_strerror(-ret) << std::endl;
+        return -ret;
+      }
+      break;
     case OPT::REALM_PULL:
       {
         if (url.empty()) {
index b370427c59c6296b7218ca53bfee96721d6d4665..987bd57995380008506653d957d1e2751689ee2f 100644 (file)
@@ -88,6 +88,7 @@
     realm rename                     rename a realm
     realm set                        set realm info (requires infile)
     realm default                    set realm as default
+    realm default rm                 clear the current default realm
     realm pull                       pull a realm and its current period
     zonegroup add                    add a zone to a zonegroup
     zonegroup create                 create a new zone group info