}
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;
}
}
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();
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;
}
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;
if (ret < 0)
return ret;
- return bucket.link(op_state);
+ return bucket.link(op_state, err);
}
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; };
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);
{
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);
}