]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/lua: allow read/write of StorageClass field 43529/head
authorCurt Bruns <curt.e.bruns@gmail.com>
Wed, 13 Oct 2021 21:05:28 +0000 (17:05 -0400)
committerCurt Bruns <curt.e.bruns@gmail.com>
Mon, 18 Oct 2021 22:51:14 +0000 (18:51 -0400)
Admins may setup different pools for RGW objects and
having the StorageClass field mutable allows the steering
of RGW objects to the proper pools.

Signed-off-by: Curt Bruns <curt.e.bruns@gmail.com>
doc/radosgw/lua-scripting.rst
src/rgw/rgw_lua_request.cc

index 728a8514f1c1ea2b818a7f32a62705acc3283403..8541ed4d9cbcb2f7a7b8e5dd0327d017fa0236b1 100644 (file)
@@ -262,6 +262,8 @@ Request Fields
 +----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+
 | ``Request.HTTP.Metadata``                          | table    | string to string metadata map                                | yes      | yes       | no       |
 +----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+
+| ``Request.HTTP.StorageClass``                      | string   | storage class                                                | no       | yes       | yes      |
++----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+
 | ``Request.HTTP.Host``                              | string   | host name                                                    | no       | no        | no       |
 +----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+
 | ``Request.HTTP.Method``                            | string   | HTTP method                                                  | no       | no        | no       |
index a8ea4ee19b2c9f4a3b88c24cd051c145ceb0a063..184c9eca54c18f9b36522d46d5008d1d9b9931e8 100644 (file)
@@ -640,11 +640,26 @@ struct HTTPMetaTable : public EmptyMetaTable {
       pushstring(L, info->request_params);
     } else if (strcasecmp(index, "Domain") == 0) {
       pushstring(L, info->domain);
+    } else if (strcasecmp(index, "StorageClass") == 0) {
+      pushstring(L, info->storage_class);
     } else {
       return error_unknown_field(L, index, TableName());
     }
     return ONE_RETURNVAL;
   }
+
+  static int NewIndexClosure(lua_State* L) {
+    auto info = reinterpret_cast<req_info*>(lua_touserdata(L, lua_upvalueindex(1)));
+
+    const char* index = luaL_checkstring(L, 2);
+
+    if (strcasecmp(index, "StorageClass") == 0) {
+      info->storage_class = luaL_checkstring(L, 3);
+   } else {
+      return error_unknown_field(L, index, TableName());
+   }
+    return NO_RETURNVAL;
+  }
 };
 
 struct CopyFromMetaTable : public EmptyMetaTable {