]>
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 | ||
20effc67 | 12 | using namespace std; |
9f95a23c TL |
13 | |
14 | RGWSI_MetaBackend_OTP::RGWSI_MetaBackend_OTP(CephContext *cct) : RGWSI_MetaBackend_SObj(cct) { | |
15 | } | |
16 | ||
17 | RGWSI_MetaBackend_OTP::~RGWSI_MetaBackend_OTP() { | |
18 | } | |
19 | ||
20 | string RGWSI_MetaBackend_OTP::get_meta_key(const rgw_user& user) | |
21 | { | |
22 | return string("otp:user:") + user.to_str(); | |
23 | } | |
24 | ||
25 | RGWSI_MetaBackend_Handler *RGWSI_MetaBackend_OTP::alloc_be_handler() | |
26 | { | |
27 | return new RGWSI_MetaBackend_Handler_OTP(this); | |
28 | } | |
29 | ||
30 | RGWSI_MetaBackend::Context *RGWSI_MetaBackend_OTP::alloc_ctx() | |
31 | { | |
32 | return new Context_OTP(sysobj_svc); | |
33 | } | |
34 | ||
35 | int RGWSI_MetaBackend_OTP::call_with_get_params(ceph::real_time *pmtime, std::function<int(RGWSI_MetaBackend::GetParams&)> cb) | |
36 | { | |
37 | otp_devices_list_t devices; | |
38 | RGWSI_MBOTP_GetParams params; | |
39 | params.pdevices = &devices; | |
40 | params.pmtime = pmtime; | |
41 | return cb(params); | |
42 | } | |
43 | ||
44 | int RGWSI_MetaBackend_OTP::get_entry(RGWSI_MetaBackend::Context *_ctx, | |
45 | const string& key, | |
46 | RGWSI_MetaBackend::GetParams& _params, | |
47 | RGWObjVersionTracker *objv_tracker, | |
b3b6e05e TL |
48 | optional_yield y, |
49 | const DoutPrefixProvider *dpp) | |
9f95a23c TL |
50 | { |
51 | RGWSI_MBOTP_GetParams& params = static_cast<RGWSI_MBOTP_GetParams&>(_params); | |
52 | ||
b3b6e05e | 53 | int r = cls_svc->mfa.list_mfa(dpp, key, params.pdevices, objv_tracker, params.pmtime, y); |
9f95a23c TL |
54 | if (r < 0) { |
55 | return r; | |
56 | } | |
57 | ||
58 | return 0; | |
59 | } | |
60 | ||
b3b6e05e TL |
61 | int RGWSI_MetaBackend_OTP::put_entry(const DoutPrefixProvider *dpp, |
62 | RGWSI_MetaBackend::Context *_ctx, | |
9f95a23c TL |
63 | const string& key, |
64 | RGWSI_MetaBackend::PutParams& _params, | |
65 | RGWObjVersionTracker *objv_tracker, | |
66 | optional_yield y) | |
67 | { | |
68 | RGWSI_MBOTP_PutParams& params = static_cast<RGWSI_MBOTP_PutParams&>(_params); | |
69 | ||
b3b6e05e | 70 | return cls_svc->mfa.set_mfa(dpp, key, params.devices, true, objv_tracker, params.mtime, y); |
9f95a23c TL |
71 | } |
72 |