]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw, radosgw-admin: bucket link uses bucket instance id now 1653/head
authorYehuda Sadeh <yehuda@inktank.com>
Thu, 10 Apr 2014 23:42:49 +0000 (16:42 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Thu, 10 Apr 2014 23:48:23 +0000 (16:48 -0700)
Fixes: 7499
We need to link user to a specific bucket instance. This updates both
the radosgw-admin link command, and the RESTful admin api.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_bucket.cc
src/rgw/rgw_bucket.h
src/rgw/rgw_rest_bucket.cc

index d1b7e961ff66c62324d0feb629c212865ff0d633..cede8d9bf200d9f618c045ea6accd101eef52666 100644 (file)
@@ -1525,9 +1525,11 @@ int main(int argc, char **argv)
   }
 
   if (opt_cmd == OPT_BUCKET_LINK) {
-    int r = RGWBucketAdminOp::link(store, bucket_op);
+    bucket_op.set_bucket_id(bucket_id);
+    string err;
+    int r = RGWBucketAdminOp::link(store, bucket_op, &err);
     if (r < 0) {
-      cerr << "failure: " << cpp_strerror(-r) << std::endl;
+      cerr << "failure: " << cpp_strerror(-r) << ": " << err << std::endl;
       return -r;
     }
   }
index 9827bad309c9e3a195f698dab84ad5b09b68d861..65aa0338e988e742fc2984f704615f201db0b418 100644 (file)
@@ -461,6 +461,12 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg)
     return -EINVAL;
   }
 
+  string bucket_id = op_state.get_bucket_id();
+  if (bucket_id.empty()) {
+    set_err_msg(err_msg, "empty bucket instance id");
+    return -EINVAL;
+  }
+
   std::string no_oid;
 
   std::string display_name = op_state.get_user_display_name();
@@ -472,7 +478,8 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg)
   map<string, bufferlist> attrs;
   RGWBucketInfo bucket_info;
 
-  int r = store->get_bucket_info(NULL, bucket.name, bucket_info, NULL, &attrs);
+  string key = bucket.name + ":" + bucket_id;
+  int r = store->get_bucket_instance_info(NULL, key, bucket_info, NULL, &attrs);
   if (r < 0) {
     return r;
   }
@@ -857,7 +864,7 @@ int RGWBucketAdminOp::unlink(RGWRados *store, RGWBucketAdminOpState& op_state)
   return bucket.unlink(op_state);
 }
 
-int RGWBucketAdminOp::link(RGWRados *store, RGWBucketAdminOpState& op_state)
+int RGWBucketAdminOp::link(RGWRados *store, RGWBucketAdminOpState& op_state, string *err)
 {
   RGWBucket bucket;
 
@@ -865,7 +872,7 @@ int RGWBucketAdminOp::link(RGWRados *store, RGWBucketAdminOpState& op_state)
   if (ret < 0)
     return ret;
 
-  return bucket.link(op_state);
+  return bucket.link(op_state, err);
 
 }
 
index f113590f10e39b163f07e8a8f86e5f96e5aae3b1..fb764505f875ad23c4cce88df0206e6b071ab742 100644 (file)
@@ -158,6 +158,11 @@ struct RGWBucketAdminOpState {
     bucket_stored = true;
   }
 
+  void set_bucket_id(const string& bi) {
+    bucket_id = bi;
+  }
+  const string& get_bucket_id() { return bucket_id; };
+
   bool will_fetch_stats() { return stat_buckets; };
   bool will_fix_index() { return fix_index; };
   bool will_delete_children() { return delete_child_objects; };
@@ -226,7 +231,7 @@ public:
 
 
   static int unlink(RGWRados *store, RGWBucketAdminOpState& op_state);
-  static int link(RGWRados *store, RGWBucketAdminOpState& op_state);
+  static int link(RGWRados *store, RGWBucketAdminOpState& op_state, string *err_msg = NULL);
 
   static int check_index(RGWRados *store, RGWBucketAdminOpState& op_state,
                   RGWFormatterFlusher& flusher);
index e7068b43c49b84c8e29a04232b510ae29dd17d3b..9f011922b35f7761a74f7b618794d65a5c2574dc 100644 (file)
@@ -123,14 +123,17 @@ void RGWOp_Bucket_Link::execute()
 {
   std::string uid;
   std::string bucket;
+  std::string bucket_id;
 
   RGWBucketAdminOpState op_state;
 
   RESTArgs::get_string(s, "uid", uid, &uid);
   RESTArgs::get_string(s, "bucket", bucket, &bucket);
+  RESTArgs::get_string(s, "bucket-id", bucket_id, &bucket_id);
 
   op_state.set_user_id(uid);
   op_state.set_bucket_name(bucket);
+  op_state.set_bucket_id(bucket_id);
 
   http_ret = RGWBucketAdminOp::link(store, op_state);
 }