From 2fcbf2bae7803efcff82bb2b559a89e681b41449 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 21 Jun 2013 16:16:47 -0700 Subject: [PATCH] rgw: user configuration for bucket placement Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_common.h | 10 +++++++++- src/rgw/rgw_json_enc.cc | 4 ++++ src/rgw/rgw_rados.h | 9 +++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 3a4b76a09b050..7f8bb87c986eb 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -411,11 +411,13 @@ struct RGWUserInfo uint32_t max_buckets; RGWUserCaps caps; __u8 system; + string default_placement; + list placement_tags; RGWUserInfo() : auid(0), suspended(0), max_buckets(RGW_DEFAULT_MAX_BUCKETS) {} void encode(bufferlist& bl) const { - ENCODE_START(12, 9, bl); + ENCODE_START(13, 9, bl); ::encode(auid, bl); string access_key; string secret_key; @@ -447,6 +449,8 @@ struct RGWUserInfo ::encode(max_buckets, bl); ::encode(caps, bl); ::encode(system, bl); + ::encode(default_placement, bl); + ::encode(placement_tags, bl); ENCODE_FINISH(bl); } void decode(bufferlist::iterator& bl) { @@ -496,6 +500,10 @@ struct RGWUserInfo if (struct_v >= 12) { ::decode(system, bl); } + if (struct_v >= 13) { + ::decode(default_placement, bl); + ::decode(placement_tags, bl); /* tags of allowed placement rules */ + } DECODE_FINISH(bl); } void dump(Formatter *f) const; diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index 3dbd1e4207136..442e2a4294099 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -370,6 +370,8 @@ void RGWUserInfo::dump(Formatter *f) const if (system) { /* no need to show it for every user */ encode_json("system", (bool)system, f); } + encode_json("default_placement", default_placement, f); + encode_json("placement_tags", placement_tags, f); } @@ -413,6 +415,8 @@ void RGWUserInfo::decode_json(JSONObj *obj) bool sys; JSONDecoder::decode_json("system", sys, obj); system = (__u8)sys; + JSONDecoder::decode_json("default_placement", default_placement, obj); + JSONDecoder::decode_json("placement_tags", placement_tags, obj); } void rgw_bucket::dump(Formatter *f) const diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 5c48df9d80956..3331f36b6681f 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -524,6 +524,15 @@ struct RGWRegionPlacementTarget { string name; list tags; + bool tag_exists(const string& tag) { + for (list::iterator iter = tags.begin(); iter != tags.end(); ++iter) { + if (tag == *iter) { + return true; + } + } + return false; + } + void encode(bufferlist& bl) const { ENCODE_START(1, 1, bl); ::encode(name, bl); -- 2.39.5