From: Chang Liu Date: Mon, 6 May 2019 13:14:18 +0000 (+0800) Subject: rgw: add set_bucket_tags api X-Git-Tag: v15.1.0~2575^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e4ab9bf31c78238122f028b260b4e96062d6d316;p=ceph.git rgw: add set_bucket_tags api Signed-off-by: Chang Liu --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 807ffb227aa6..e2aac3455fa0 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -5122,6 +5122,28 @@ int RGWRados::bucket_suspended(rgw_bucket& bucket, bool *suspended) return 0; } +int RGWRados::set_bucket_tags(rgw_bucket& bucket, bufferlist tags_bl) +{ + RGWBucketInfo info; + map attrs; + auto obj_ctx = svc.sysobj->init_obj_ctx(); + int r; + if (bucket.bucket_id.empty()) { + r = get_bucket_info(obj_ctx, bucket.tenant, bucket.name, info, NULL, &attrs); + } else { + r = get_bucket_instance_info(obj_ctx, bucket, info, nullptr, &attrs); + } + + attrs[RGW_ATTR_TAGS] = tags_bl; + + r = put_bucket_instance_info(info, false, real_time(), &attrs); + if (r < 0) { + ldout(cct, 0) << "NOTICE: put_bucket_tags on bucket=" << bucket.name << " returned err=" << r << dendl; + return r; + } + return 0; +} + int RGWRados::Object::complete_atomic_modification() { if (!state->has_manifest || state->keep_tail) diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 4ef1791a6cb1..aee8c3c8aba4 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -2003,6 +2003,8 @@ public: int set_buckets_enabled(std::vector& buckets, bool enabled); int bucket_suspended(rgw_bucket& bucket, bool *suspended); + int set_bucket_tags(rgw_bucket& bucket, bufferlist tags_bl); + /** Delete an object.*/ int delete_obj(RGWObjectCtx& obj_ctx, const RGWBucketInfo& bucket_owner,