summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-06-21 16:16:47 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-06-21 16:16:47 -0700
commit2fcbf2bae7803efcff82bb2b559a89e681b41449 (patch)
treeb5d3cdf690df1271ceb7dd0383bab9d8bede2f97
parente5e924ca710f1012051fa398fb22225f18167f52 (diff)
downloadceph-2fcbf2bae7803efcff82bb2b559a89e681b41449.tar.gz
rgw: user configuration for bucket placement
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_common.h10
-rw-r--r--src/rgw/rgw_json_enc.cc4
-rw-r--r--src/rgw/rgw_rados.h9
3 files changed, 22 insertions, 1 deletions
diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h
index 3a4b76a09b0..7f8bb87c986 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<string> 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 3dbd1e42071..442e2a42940 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 5c48df9d809..3331f36b668 100644
--- a/src/rgw/rgw_rados.h
+++ b/src/rgw/rgw_rados.h
@@ -524,6 +524,15 @@ struct RGWRegionPlacementTarget {
string name;
list<string> tags;
+ bool tag_exists(const string& tag) {
+ for (list<string>::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);