From a3273c8425d2ee91a032a71d71488d27794492f3 Mon Sep 17 00:00:00 2001 From: Jiffin Tony Thottan Date: Wed, 12 Jun 2024 15:28:23 +0530 Subject: [PATCH] rgw/adminops: add option to provide storageclass adminops user apis 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 --- doc/radosgw/adminops.rst | 26 ++++++++++++++++++++++++++ src/rgw/driver/rados/rgw_rest_user.cc | 14 ++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/doc/radosgw/adminops.rst b/doc/radosgw/adminops.rst index 643190123d3..19c694421ce 100644 --- a/doc/radosgw/adminops.rst +++ b/doc/radosgw/adminops.rst @@ -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 ~~~~~~~~~~~~~~~~~ diff --git a/src/rgw/driver/rados/rgw_rest_user.cc b/src/rgw/driver/rados/rgw_rest_user.cc index 34112c94727..71bb8c4c039 100644 --- a/src/rgw/driver/rados/rgw_rest_user.cc +++ b/src/rgw/driver/rados/rgw_rest_user.cc @@ -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; -- 2.39.5