From: Abhishek Lekshmanan Date: Wed, 30 Sep 2020 13:50:39 +0000 (+0200) Subject: rgw_role: define RGWRoleCtl X-Git-Tag: v17.2.6~119^2~45 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=03405b39ddf9b024f9bec20b7c5dfd0fee05ed9a;p=ceph.git rgw_role: define RGWRoleCtl Signed-off-by: Abhishek Lekshmanan (cherry picked from commit 150f78b2d6cd8fae224af1bc0c75b2d581393148) --- diff --git a/src/rgw/rgw_role.cc b/src/rgw/rgw_role.cc index af7f7f6f8fd0..dd0114d5a84f 100644 --- a/src/rgw/rgw_role.cc +++ b/src/rgw/rgw_role.cc @@ -21,6 +21,7 @@ #include "services/svc_zone.h" #include "services/svc_sys_obj.h" +#include "services/svc_role.h" #define dout_subsys ceph_subsys_rgw @@ -230,5 +231,143 @@ const string& RGWRole::get_path_oid_prefix() { return role_path_oid_prefix; } - } } // namespace rgw::sal + +int RGWRoleCtl::store_info(const rgw::sal::RGWRole* role, + optional_yield y, + const DoutPrefixProvider *dpp, + const PutParams& params) +{ + return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { + return svc.role->store_info(op->ctx(), + *role, + params.objv_tracker, + params.mtime, + params.exclusive, + params.attrs, + y, dpp); + }); +} + +int RGWRoleCtl::store_name(const std::string& role_id, + const std::string& name, + const std::string& tenant, + optional_yield y, + const DoutPrefixProvider *dpp, + const PutParams& params) +{ + return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { + return svc.role->store_name(op->ctx(), + role_id, + name, + tenant, + params.objv_tracker, + params.mtime, + params.exclusive, + y, dpp); + }); +} + +int RGWRoleCtl::store_path(const std::string& role_id, + const std::string& path, + const std::string& tenant, + optional_yield y, + const DoutPrefixProvider *dpp, + const PutParams& params) +{ + return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { + return svc.role->store_path(op->ctx(), + role_id, + path, + tenant, + params.objv_tracker, + params.mtime, + params.exclusive, + y, dpp); + }); +} + +int +RGWRoleCtl::read_info(const std::string& role_id, + optional_yield y, + const DoutPrefixProvider *dpp, + rgw::sal::RGWRole* info, + const GetParams& params) +{ + int ret = be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { + return svc.role->read_info(op->ctx(), + role_id, + info, + params.objv_tracker, + params.mtime, + params.attrs, + y, dpp); + }); + return ret; +} + +std::pair +RGWRoleCtl::read_name(const std::string& name, + const std::string& tenant, + optional_yield y, + const DoutPrefixProvider *dpp, + const GetParams& params) +{ + std::string role_id; + int ret = be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { + return svc.role->read_name(op->ctx(), + name, + tenant, + role_id, + params.objv_tracker, + params.mtime, + y, dpp); + }); + return make_pair(ret, role_id); +} + +int RGWRoleCtl::delete_info(const std::string& role_id, + optional_yield y, + const DoutPrefixProvider *dpp, + const RemoveParams& params) +{ + return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { + return svc.role->delete_info(op->ctx(), + role_id, + params.objv_tracker, + y, dpp); + }); +} + +int RGWRoleCtl::delete_name(const std::string& name, + const std::string& tenant, + optional_yield y, + const DoutPrefixProvider *dpp, + const RemoveParams& params) +{ + return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { + return svc.role->delete_name(op->ctx(), + name, + tenant, + params.objv_tracker, + y, dpp); + }); +} + +int RGWRoleCtl::delete_path(const std::string& role_id, + const std::string& path, + const std::string& tenant, + optional_yield y, + const DoutPrefixProvider *dpp, + const RemoveParams& params) +{ + return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { + return svc.role->delete_path(op->ctx(), + role_id, + path, + tenant, + params.objv_tracker, + y, dpp); + }); +} + diff --git a/src/rgw/rgw_role.h b/src/rgw/rgw_role.h index 5669e0c06a7a..c1ac9a8756c6 100644 --- a/src/rgw/rgw_role.h +++ b/src/rgw/rgw_role.h @@ -10,10 +10,13 @@ #include "common/ceph_json.h" #include "common/ceph_context.h" - #include "rgw/rgw_rados.h" +//#include "svc_meta_be.h" class RGWRados; +class RGWRoleMetadataHandler; +class RGWSI_Role; +class RGWSI_MetaBackend_Handler; namespace rgw { namespace sal { class RGWRole @@ -138,10 +141,7 @@ public: static const std::string& get_path_oid_prefix(); }; WRITE_CLASS_ENCODER(RGWRole) - -class RGWRoleMetadataHandler; -class RGWSI_Role; -class RGWSI_MetaBackend_Handler; +} } // namespace rgw::sal class RGWRoleCtl { struct Svc { @@ -159,12 +159,110 @@ public: RGWObjVersionTracker *objv_tracker {nullptr}; std::map *attrs {nullptr}; - PutParams() {}; + PutParams() {} + + PutParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) { + objv_tracker = _objv_tracker; + return *this; + } + + PutParams& set_mtime(const ceph::real_time& _mtime) { + mtime = _mtime; + return *this; + } + + PutParams& set_exclusive(bool _exclusive) { + exclusive = _exclusive; + return *this; + } + + PutParams& set_attrs(std::map *_attrs) { + attrs = _attrs; + return *this; + } + }; + + struct GetParams { + ceph::real_time *mtime{nullptr}; + std::map *attrs{nullptr}; + RGWObjVersionTracker *objv_tracker {nullptr}; + + GetParams() {} + + GetParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) { + objv_tracker = _objv_tracker; + return *this; + } + + GetParams& set_mtime(ceph::real_time *_mtime) { + mtime = _mtime; + return *this; + } + + GetParams& set_attrs(std::map *_attrs) { + attrs = _attrs; + return *this; + } }; - int store_info(const RGWRole& role, + struct RemoveParams { + RGWObjVersionTracker *objv_tracker{nullptr}; + + RemoveParams() {} + + RemoveParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) { + objv_tracker = _objv_tracker; + return *this; + } + }; + + int store_info(const rgw::sal::RGWRole* role, + optional_yield y, + const DoutPrefixProvider *dpp, + const PutParams& params = {}); + + int store_name(const std::string& role_id, + const std::string& name, + const std::string& tenant, + optional_yield y, + const DoutPrefixProvider *dpp, + const PutParams& params = {}); + + int store_path(const std::string& role_id, + const std::string& path, + const std::string& tenant, optional_yield y, + const DoutPrefixProvider *dpp, const PutParams& params = {}); + + int read_info(const std::string& role_id, + optional_yield y, + const DoutPrefixProvider *dpp, + rgw::sal::RGWRole* role, + const GetParams& params = {}); + + std::pair read_name(const std::string& name, + const std::string& tenant, + optional_yield y, + const DoutPrefixProvider *dpp, + const GetParams& params = {}); + + int delete_info(const std::string& role_id, + optional_yield y, + const DoutPrefixProvider *dpp, + const RemoveParams& params = {}); + + int delete_name(const std::string& name, + const std::string& tenant, + optional_yield y, + const DoutPrefixProvider *dpp, + const RemoveParams& params = {}); + + int delete_path(const std::string& role_id, + const std::string& path, + const std::string& tenant, + optional_yield y, + const DoutPrefixProvider *dpp, + const RemoveParams& params = {}); }; -} } // namespace rgw::sal #endif /* CEPH_RGW_ROLE_H */