summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCasey Bodley <cbodley@redhat.com>2023-11-01 20:47:59 +0100
committerCasey Bodley <cbodley@redhat.com>2024-04-10 18:53:04 +0200
commit59bbd65bac0ea41ec8cca844b9b65b9def026467 (patch)
tree03c654642f2f5aa21d51b2dda6e14342657a5c81
parentrgw: define account ids and names (diff)
downloadceph-59bbd65bac0ea41ec8cca844b9b65b9def026467.tar.xz
ceph-59bbd65bac0ea41ec8cca844b9b65b9def026467.zip
rgw: add struct RGWAccountInfo
initial design and prototype by Abhishek Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com> Signed-off-by: Casey Bodley <cbodley@redhat.com>
-rw-r--r--src/rgw/rgw_common.cc45
-rw-r--r--src/rgw/rgw_common.h59
-rw-r--r--src/tools/ceph-dencoder/rgw_types.h1
3 files changed, 105 insertions, 0 deletions
diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc
index 7ca010fb33a..b47b1ba749d 100644
--- a/src/rgw/rgw_common.cc
+++ b/src/rgw/rgw_common.cc
@@ -2971,6 +2971,51 @@ void RGWAccessKey::decode_json(JSONObj *obj, bool swift) {
JSONDecoder::decode_json("active", active, obj);
}
+
+void RGWAccountInfo::dump(Formatter * const f) const
+{
+ encode_json("id", id, f);
+ encode_json("tenant", tenant, f);
+ encode_json("name", name, f);
+ encode_json("email", email, f);
+ encode_json("quota", quota, f);
+ encode_json("max_users", max_users, f);
+ encode_json("max_roles", max_roles, f);
+ encode_json("max_groups", max_groups, f);
+ encode_json("max_buckets", max_buckets, f);
+ encode_json("max_access_keys", max_access_keys, f);
+}
+
+void RGWAccountInfo::decode_json(JSONObj* obj)
+{
+ JSONDecoder::decode_json("id", id, obj);
+ JSONDecoder::decode_json("tenant", tenant, obj);
+ JSONDecoder::decode_json("name", name, obj);
+ JSONDecoder::decode_json("email", email, obj);
+ JSONDecoder::decode_json("quota", quota, obj);
+ JSONDecoder::decode_json("max_users", max_users, obj);
+ JSONDecoder::decode_json("max_roles", max_roles, obj);
+ JSONDecoder::decode_json("max_groups", max_groups, obj);
+ JSONDecoder::decode_json("max_buckets", max_buckets, obj);
+ JSONDecoder::decode_json("max_access_keys", max_access_keys, obj);
+}
+
+void RGWAccountInfo::generate_test_instances(std::list<RGWAccountInfo*>& o)
+{
+ o.push_back(new RGWAccountInfo);
+ auto p = new RGWAccountInfo;
+ p->id = "account1";
+ p->tenant = "tenant1";
+ p->name = "name1";
+ p->email = "email@example.com";
+ p->max_users = 10;
+ p->max_roles = 10;
+ p->max_groups = 10;
+ p->max_buckets = 10;
+ p->max_access_keys = 10;
+ o.push_back(p);
+}
+
void RGWStorageStats::dump(Formatter *f) const
{
encode_json("size", size, f);
diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h
index 24392bc0caa..cb613b23b8d 100644
--- a/src/rgw/rgw_common.h
+++ b/src/rgw/rgw_common.h
@@ -747,6 +747,65 @@ struct RGWUserInfo
};
WRITE_CLASS_ENCODER(RGWUserInfo)
+// user account metadata
+struct RGWAccountInfo {
+ rgw_account_id id;
+ std::string tenant;
+ std::string name;
+ std::string email;
+ RGWQuotaInfo quota;
+
+ static constexpr int32_t DEFAULT_USER_LIMIT = 1000;
+ int32_t max_users = DEFAULT_USER_LIMIT;
+
+ static constexpr int32_t DEFAULT_ROLE_LIMIT = 1000;
+ int32_t max_roles = DEFAULT_ROLE_LIMIT;
+
+ static constexpr int32_t DEFAULT_GROUP_LIMIT = 1000;
+ int32_t max_groups = DEFAULT_GROUP_LIMIT;
+
+ static constexpr int32_t DEFAULT_BUCKET_LIMIT = 1000;
+ int32_t max_buckets = DEFAULT_BUCKET_LIMIT;
+
+ static constexpr int32_t DEFAULT_ACCESS_KEY_LIMIT = 4;
+ int32_t max_access_keys = DEFAULT_ACCESS_KEY_LIMIT;
+
+ void encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ encode(id, bl);
+ encode(tenant, bl);
+ encode(name, bl);
+ encode(email, bl);
+ encode(quota, bl);
+ encode(max_users, bl);
+ encode(max_roles, bl);
+ encode(max_groups, bl);
+ encode(max_buckets, bl);
+ encode(max_access_keys, bl);
+ ENCODE_FINISH(bl);
+ }
+
+ void decode(bufferlist::const_iterator& bl) {
+ DECODE_START(1, bl);
+ decode(id, bl);
+ decode(tenant, bl);
+ decode(name, bl);
+ decode(email, bl);
+ decode(quota, bl);
+ decode(max_users, bl);
+ decode(max_roles, bl);
+ decode(max_groups, bl);
+ decode(max_buckets, bl);
+ decode(max_access_keys, bl);
+ DECODE_FINISH(bl);
+ }
+
+ void dump(Formatter* f) const;
+ void decode_json(JSONObj* obj);
+ static void generate_test_instances(std::list<RGWAccountInfo*>& o);
+};
+WRITE_CLASS_ENCODER(RGWAccountInfo)
+
/// `RGWObjVersionTracker`
/// ======================
///
diff --git a/src/tools/ceph-dencoder/rgw_types.h b/src/tools/ceph-dencoder/rgw_types.h
index 05484c78fc1..6ab13e250e2 100644
--- a/src/tools/ceph-dencoder/rgw_types.h
+++ b/src/tools/ceph-dencoder/rgw_types.h
@@ -154,6 +154,7 @@ TYPE(obj_version)
TYPE(RGWAccessKey)
TYPE(RGWSubUser)
TYPE(RGWUserInfo)
+TYPE(RGWAccountInfo)
TYPE(rgw_bucket)
TYPE(RGWBucketInfo)
TYPE(RGWBucketEnt)