services/svc_quota.cc
services/svc_sync_modules.cc
services/svc_rados.cc
+ services/svc_role.cc
services/svc_role_rados.cc
services/svc_sys_obj.cc
services/svc_sys_obj_cache.cc
--- /dev/null
+#include "svc_role.h"
+
+const std::string role_name_oid_prefix = "role_names.";
+const std::string role_oid_prefix = "roles.";
+const std::string role_path_oid_prefix = "role_paths.";
+const std::string role_arn_prefix = "arn:aws:iam::";
+
+std::string RGWSI_Role::get_role_meta_key(const std::string& role_id)
+{
+ return role_oid_prefix + role_id;
+}
+
+std::string RGWSI_Role::get_role_name_meta_key(const std::string& role_name, const std::string& tenant)
+{
+ return tenant + role_name_oid_prefix + role_name;
+}
+
+std::string RGWSI_Role::get_role_path_meta_key(const std::string& path, const std::string& role_id, const std::string& tenant)
+{
+ return tenant + role_path_oid_prefix + path + role_oid_prefix + role_id;
+}
#pragma once
#include "rgw/rgw_service.h"
+#include "rgw/rgw_role.h"
#include "svc_meta_be.h"
class RGWRole;
virtual ~RGWSI_Role() {}
virtual RGWSI_MetaBackend_Handler* get_be_handler() = 0;
+ static std::string get_role_meta_key(const std::string& role_id);
+ static std::string get_role_name_meta_key(const std::string& role_name, const std::string& tenant);
+ static std::string get_role_path_meta_key(const std::string& path, const std::string& role_id, const std::string& tenant);
virtual int store_info(RGWSI_MetaBackend::Context *ctx,
- const RGWRole& role,
+ const rgw::sal::RGWRole& role,
RGWObjVersionTracker * const objv_tracker,
const real_time& mtime,
bool exclusive,
std::map<std::string, bufferlist> * pattrs,
- optional_yield y) = 0;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) = 0;
virtual int store_name(RGWSI_MetaBackend::Context *ctx,
const std::string& name,
RGWObjVersionTracker * const objv_tracker,
real_time * const pmtime,
bool exclusive,
- optional_yield y) = 0;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) = 0;
virtual int store_path(RGWSI_MetaBackend::Context *ctx,
const std::string& path,
RGWObjVersionTracker * const objv_tracker,
real_time * const pmtime,
bool exclusive,
- optional_yield y) = 0;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) = 0;
virtual int read_info(RGWSI_MetaBackend::Context *ctx,
- RGWRole *role,
+ const std::string& role_id,
+ rgw::sal::RGWRole *role,
RGWObjVersionTracker * const objv_tracker,
real_time * const pmtime,
std::map<std::string, bufferlist> * pattrs,
- optional_yield y) = 0;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) = 0;
virtual int read_name(RGWSI_MetaBackend::Context *ctx,
std::string& name,
RGWObjVersionTracker * const objv_tracker,
real_time * const pmtime,
- optional_yield y) = 0;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) = 0;
virtual int read_path(RGWSI_MetaBackend::Context *ctx,
std::string& path,
RGWObjVersionTracker * const objv_tracker,
real_time * const pmtime,
- optional_yield y) = 0;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) = 0;
virtual int delete_info(RGWSI_MetaBackend::Context *ctx,
const std::string& name,
RGWObjVersionTracker * const objv_tracker,
- optional_yield y) = 0;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) = 0;
};
#include "svc_role_rados.h"
+#include "svc_meta_be_sobj.h"
+#include "rgw_role.h"
+
+#define dout_subsys ceph_subsys_rgw
RGWSI_MetaBackend_Handler* RGWSI_Role_RADOS::get_be_handler()
{
return be_handler;
}
+
+void RGWSI_Role_RADOS::init(RGWSI_Zone *_zone_svc,
+ RGWSI_Meta *_meta_svc,
+ RGWSI_MetaBackend *_meta_be_svc,
+ RGWSI_SysObj *_sysobj_svc)
+{
+ svc.zone = _zone_svc;
+ svc.meta = _meta_svc;
+ svc.meta_be = _meta_be_svc;
+ svc.sysobj = _sysobj_svc;
+}
+
+int RGWSI_Role_RADOS::store_info(RGWSI_MetaBackend::Context *ctx,
+ const rgw::sal::RGWRole& role,
+ RGWObjVersionTracker * const objv_tracker,
+ const real_time& mtime,
+ bool exclusive,
+ std::map<std::string, bufferlist> * pattrs,
+ optional_yield y,
+ const DoutPrefixProvider *dpp)
+{
+ bufferlist data_bl;
+ encode(role, data_bl);
+ RGWSI_MBSObj_PutParams params(data_bl, pattrs, mtime, exclusive);
+
+ return svc.meta_be->put(ctx, get_role_meta_key(role.get_id()), params, objv_tracker, y, dpp);
+}
+
+int RGWSI_Role_RADOS::read_info(RGWSI_MetaBackend::Context *ctx,
+ const std::string& role_id,
+ rgw::sal::RGWRole *role,
+ RGWObjVersionTracker * const objv_tracker,
+ real_time * const pmtime,
+ std::map<std::string, bufferlist> * pattrs,
+ optional_yield y,
+ const DoutPrefixProvider *dpp)
+{
+ bufferlist data_bl;
+ RGWSI_MBSObj_GetParams params(&data_bl, pattrs, pmtime);
+
+ int r = svc.meta_be->get_entry(ctx, get_role_meta_key(role_id), params, objv_tracker, y, dpp);
+ if (r < 0)
+ return r;
+
+ auto bl_iter = data_bl.cbegin();
+ try {
+ decode(*role, bl_iter);
+ } catch (buffer::error& err) {
+ ldout(svc.meta_be->ctx(),0) << "ERROR: failed to decode RGWRole, caught buffer::err " << dendl;
+ return -EIO;
+ }
+
+ return 0;
+}
+
+int RGWSI_Role_RADOS::delete_info(RGWSI_MetaBackend::Context *ctx,
+ const std::string& role_id,
+ RGWObjVersionTracker * const objv_tracker,
+ optional_yield y,
+ const DoutPrefixProvider *dpp)
+{
+ RGWSI_MBSObj_RemoveParams params;
+
+ int r = svc.meta_be->remove(ctx, get_role_meta_key(role_id), params, objv_tracker, y, dpp);
+ if (r < 0 && r != -ENOENT && r != -ECANCELED) {
+ ldout(svc.meta_be->ctx(),0) << "ERROR: could not remove RGWRole, id = "
+ << role_id << " r = "<< r << dendl;
+ return r;
+ }
+ return 0;
+}
class RGWSI_Role_RADOS: public RGWSI_Role
{
public:
+ struct Svc {
+ RGWSI_Zone *zone{nullptr};
+ RGWSI_Meta *meta{nullptr};
+ RGWSI_MetaBackend *meta_be{nullptr};
+ RGWSI_SysObj *sysobj{nullptr};
+ } svc;
+
RGWSI_Role_RADOS(CephContext *cct) : RGWSI_Role(cct) {}
~RGWSI_Role_RADOS() {}
+ void init(RGWSI_Zone *_zone_svc,
+ RGWSI_Meta *_meta_svc,
+ RGWSI_MetaBackend *_meta_be_svc,
+ RGWSI_SysObj *_sysobj_svc);
+
RGWSI_MetaBackend_Handler * get_be_handler() override;
int store_info(RGWSI_MetaBackend::Context *ctx,
- const RGWRole& role,
+ const rgw::sal::RGWRole& role,
RGWObjVersionTracker * const objv_tracker,
- real_time * const pmtime,
+ const real_time& pmtime,
bool exclusive,
std::map<std::string, bufferlist> * pattrs,
- optional_yield y) override;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) override;
int store_name(RGWSI_MetaBackend::Context *ctx,
const std::string& name,
RGWObjVersionTracker * const objv_tracker,
real_time * const pmtime,
bool exclusive,
- optional_yield y) override;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) override;
int store_path(RGWSI_MetaBackend::Context *ctx,
const std::string& path,
RGWObjVersionTracker * const objv_tracker,
real_time * const pmtime,
bool exclusive,
- optional_yield y) override;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) override;
int read_info(RGWSI_MetaBackend::Context *ctx,
- RGWRole *role,
+ const std::string& role_id,
+ rgw::sal::RGWRole *role,
RGWObjVersionTracker * const objv_tracker,
real_time * const pmtime,
std::map<std::string, bufferlist> * pattrs,
- optional_yield y) override;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) override;
int read_name(RGWSI_MetaBackend::Context *ctx,
std::string& name,
RGWObjVersionTracker * const objv_tracker,
real_time * const pmtime,
- optional_yield y) override;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) override;
int read_path(RGWSI_MetaBackend::Context *ctx,
std::string& path,
RGWObjVersionTracker * const objv_tracker,
real_time * const pmtime,
- optional_yield y) override;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) override;
int delete_info(RGWSI_MetaBackend::Context *ctx,
const std::string& name,
RGWObjVersionTracker * const objv_tracker,
- optional_yield y) override;
+ optional_yield y,
+ const DoutPrefixProvider *dpp) override;
private: