blob: a840224978b34ae41036f8b6ace55c3d79e31da6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#include "svc_role_rados.h"
#include "svc_meta_be_sobj.h"
#include "svc_meta.h"
#include "rgw_role.h"
#include "rgw_zone.h"
#include "svc_zone.h"
#include "rgw_tools.h"
#define dout_subsys ceph_subsys_rgw
class RGWSI_Role_Module : public RGWSI_MBSObj_Handler_Module {
RGWSI_Role_RADOS::Svc& svc;
const std::string prefix;
public:
RGWSI_Role_Module(RGWSI_Role_RADOS::Svc& _svc): RGWSI_MBSObj_Handler_Module("roles"),
svc(_svc),
prefix(role_oid_prefix) {}
void get_pool_and_oid(const std::string& key,
rgw_pool *pool,
std::string *oid) override
{
if (pool) {
*pool = svc.zone->get_zone_params().roles_pool;
}
if (oid) {
*oid = key_to_oid(key);
}
}
bool is_valid_oid(const std::string& oid) override {
return boost::algorithm::starts_with(oid, prefix);
}
std::string key_to_oid(const std::string& key) override {
return prefix + key;
}
// This is called after `is_valid_oid` and is assumed to be a valid oid
std::string oid_to_key(const std::string& oid) override {
return oid.substr(prefix.size());
}
const std::string& get_oid_prefix() {
return prefix;
}
};
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::do_start(optional_yield y, const DoutPrefixProvider *dpp)
{
int r = svc.meta->create_be_handler(RGWSI_MetaBackend::Type::MDBE_SOBJ,
&be_handler);
if (r < 0) {
ldout(ctx(), 0) << "ERROR: failed to create be_handler for Roles: r="
<< r <<dendl;
return r;
}
auto module = new RGWSI_Role_Module(svc);
RGWSI_MetaBackend_Handler_SObj* bh= static_cast<RGWSI_MetaBackend_Handler_SObj *>(be_handler);
be_module.reset(module);
bh->set_module(module);
return 0;
}
|