]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: user configuration for bucket placement
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 21 Jun 2013 23:16:47 +0000 (16:16 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 21 Jun 2013 23:16:47 +0000 (16:16 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_common.h
src/rgw/rgw_json_enc.cc
src/rgw/rgw_rados.h

index 3a4b76a09b050375db1ecd41429b5db7b07be58f..7f8bb87c986eb0dfdd705cd161c4449350fa4bcb 100644 (file)
@@ -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;
index 3dbd1e4207136ef6e332e1304842dee5b0fb23f5..442e2a42940990f0b5ac97f7c1f6adb4d2070005 100644 (file)
@@ -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
index 5c48df9d80956f6ee6ec88e18d0f789d8797cf5f..3331f36b6681fd6b84074b10e542bd873060801a 100644 (file)
@@ -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);