]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab ft=cpp | |
3 | ||
4 | #include "svc_meta_be_otp.h" | |
5 | ||
6 | #include "rgw/rgw_tools.h" | |
7 | #include "rgw/rgw_metadata.h" | |
8 | #include "rgw/rgw_mdlog.h" | |
9 | ||
10 | #define dout_subsys ceph_subsys_rgw | |
11 | ||
12 | ||
13 | RGWSI_MetaBackend_OTP::RGWSI_MetaBackend_OTP(CephContext *cct) : RGWSI_MetaBackend_SObj(cct) { | |
14 | } | |
15 | ||
16 | RGWSI_MetaBackend_OTP::~RGWSI_MetaBackend_OTP() { | |
17 | } | |
18 | ||
19 | string RGWSI_MetaBackend_OTP::get_meta_key(const rgw_user& user) | |
20 | { | |
21 | return string("otp:user:") + user.to_str(); | |
22 | } | |
23 | ||
24 | RGWSI_MetaBackend_Handler *RGWSI_MetaBackend_OTP::alloc_be_handler() | |
25 | { | |
26 | return new RGWSI_MetaBackend_Handler_OTP(this); | |
27 | } | |
28 | ||
29 | RGWSI_MetaBackend::Context *RGWSI_MetaBackend_OTP::alloc_ctx() | |
30 | { | |
31 | return new Context_OTP(sysobj_svc); | |
32 | } | |
33 | ||
34 | int RGWSI_MetaBackend_OTP::call_with_get_params(ceph::real_time *pmtime, std::function<int(RGWSI_MetaBackend::GetParams&)> cb) | |
35 | { | |
36 | otp_devices_list_t devices; | |
37 | RGWSI_MBOTP_GetParams params; | |
38 | params.pdevices = &devices; | |
39 | params.pmtime = pmtime; | |
40 | return cb(params); | |
41 | } | |
42 | ||
43 | int RGWSI_MetaBackend_OTP::get_entry(RGWSI_MetaBackend::Context *_ctx, | |
44 | const string& key, | |
45 | RGWSI_MetaBackend::GetParams& _params, | |
46 | RGWObjVersionTracker *objv_tracker, | |
47 | optional_yield y) | |
48 | { | |
49 | RGWSI_MBOTP_GetParams& params = static_cast<RGWSI_MBOTP_GetParams&>(_params); | |
50 | ||
51 | int r = cls_svc->mfa.list_mfa(key, params.pdevices, objv_tracker, params.pmtime, y); | |
52 | if (r < 0) { | |
53 | return r; | |
54 | } | |
55 | ||
56 | return 0; | |
57 | } | |
58 | ||
59 | int RGWSI_MetaBackend_OTP::put_entry(RGWSI_MetaBackend::Context *_ctx, | |
60 | const string& key, | |
61 | RGWSI_MetaBackend::PutParams& _params, | |
62 | RGWObjVersionTracker *objv_tracker, | |
63 | optional_yield y) | |
64 | { | |
65 | RGWSI_MBOTP_PutParams& params = static_cast<RGWSI_MBOTP_PutParams&>(_params); | |
66 | ||
67 | return cls_svc->mfa.set_mfa(key, params.devices, true, objv_tracker, params.mtime, y); | |
68 | } | |
69 |