]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw/adminops: add option to provide storageclass adminops user apis
authorJiffin Tony Thottan <thottanjiffin@gmail.com>
Wed, 12 Jun 2024 09:58:23 +0000 (15:28 +0530)
committerJiffin Tony Thottan <thottanjiffin@gmail.com>
Thu, 13 Jun 2024 11:20:07 +0000 (16:50 +0530)
In the `radosgw-admin user` command, the default storage class can
defined. This capability is missing in the adminops api.

Fixes https://tracker.ceph.com/issues/66439

Signed-off-by: Jiffin Tony Thottan <thottanjiffin@gmail.com>
doc/radosgw/adminops.rst
src/rgw/driver/rados/rgw_rest_user.cc

index 643190123d3f6ea8ecbb9717fa6bc44d6d3de80d..19c694421cee06e6f02b24bb440f81aa3c0a21ad 100644 (file)
@@ -486,6 +486,19 @@ A tenant name may also specified as a part of ``uid``, by following the syntax
 :Example: tenant1
 :Required: No
 
+``default-placement``
+
+:Description: default placement for the user.
+:Type: string
+:Example: default-placement
+:Required: No
+
+``default-storage-class``
+:Description: default storage class for the user, default-placement must be defined when setting this option.
+:Type: string
+:Example: STANDARD-1A
+:Required: No
+
 Response Entities
 ~~~~~~~~~~~~~~~~~
 
@@ -683,6 +696,19 @@ Request Parameters
 :Example: ``read, write, delete, *``
 :Required: No
 
+``default-placement``
+
+:Description: default placement for the user.
+:Type: string
+:Example: default-placement
+:Required: No
+
+``default-storage-class``
+:Description: default storage class for the user, default-placement must be defined when setting this option.
+:Type: string
+:Example: STANDARD-1A
+:Required: No
+
 Response Entities
 ~~~~~~~~~~~~~~~~~
 
index 34112c9472792e6cf392b49a71dc377eda088c9b..71bb8c4c0390c34f028c1908aa15ae8ccf0b1ec7 100644 (file)
@@ -157,6 +157,7 @@ void RGWOp_User_Create::execute(optional_yield y)
   std::string op_mask_str;
   std::string default_placement_str;
   std::string placement_tags_str;
+  std::string default_storage_class_str;
 
   bool gen_key;
   bool suspended;
@@ -188,6 +189,7 @@ void RGWOp_User_Create::execute(optional_yield y)
   RESTArgs::get_bool(s, "exclusive", false, &exclusive);
   RESTArgs::get_string(s, "op-mask", op_mask_str, &op_mask_str);
   RESTArgs::get_string(s, "default-placement", default_placement_str, &default_placement_str);
+  RESTArgs::get_string(s, "default-storage-class", default_storage_class_str, &default_storage_class_str);
   RESTArgs::get_string(s, "placement-tags", placement_tags_str, &placement_tags_str);
   RESTArgs::get_string(s, "account-id", "", &op_state.account_id);
   RESTArgs::get_string(s, "path", "", &op_state.path);
@@ -251,7 +253,10 @@ void RGWOp_User_Create::execute(optional_yield y)
 
   if (!default_placement_str.empty()) {
     rgw_placement_rule target_rule;
-    target_rule.from_str(default_placement_str);
+    target_rule.name = default_placement_str;
+    if (!default_storage_class_str.empty()){
+      target_rule.storage_class = default_storage_class_str;
+    }
     if (!driver->valid_placement(target_rule)) {
       ldpp_dout(this, 0) << "NOTICE: invalid dest placement: " << target_rule.to_str() << dendl;
       op_ret = -EINVAL;
@@ -309,6 +314,7 @@ void RGWOp_User_Modify::execute(optional_yield y)
   std::string op_mask_str;
   std::string default_placement_str;
   std::string placement_tags_str;
+  std::string default_storage_class_str;
 
   bool gen_key;
   bool suspended;
@@ -336,6 +342,7 @@ void RGWOp_User_Modify::execute(optional_yield y)
   RESTArgs::get_bool(s, "account-root", false, &account_root);
   RESTArgs::get_string(s, "op-mask", op_mask_str, &op_mask_str);
   RESTArgs::get_string(s, "default-placement", default_placement_str, &default_placement_str);
+  RESTArgs::get_string(s, "default-storage-class", default_storage_class_str, &default_storage_class_str);
   RESTArgs::get_string(s, "placement-tags", placement_tags_str, &placement_tags_str);
   RESTArgs::get_string(s, "account-id", "", &op_state.account_id);
   RESTArgs::get_string(s, "path", "", &op_state.path);
@@ -404,7 +411,10 @@ void RGWOp_User_Modify::execute(optional_yield y)
 
   if (!default_placement_str.empty()) {
     rgw_placement_rule target_rule;
-    target_rule.from_str(default_placement_str);
+    target_rule.name = default_placement_str;
+    if (!default_storage_class_str.empty()){
+      target_rule.storage_class = default_storage_class_str;
+    }
     if (!driver->valid_placement(target_rule)) {
       ldpp_dout(this, 0) << "NOTICE: invalid dest placement: " << target_rule.to_str() << dendl;
       op_ret = -EINVAL;