]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/services/svc_cls.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rgw / services / svc_cls.h
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 /*
5 * Ceph - scalable distributed file system
6 *
7 * Copyright (C) 2019 Red Hat, Inc.
8 *
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
13 *
14 */
15
16
17 #pragma once
18
19 #include "cls/otp/cls_otp_types.h"
20 #include "cls/log/cls_log_types.h"
21
22 #include "rgw/rgw_service.h"
23
24 #include "svc_rados.h"
25
26
27 class RGWSI_Cls : public RGWServiceInstance
28 {
29 RGWSI_Zone *zone_svc{nullptr};
30 RGWSI_RADOS *rados_svc{nullptr};
31
32 class ClsSubService : public RGWServiceInstance {
33 friend class RGWSI_Cls;
34
35 RGWSI_Cls *cls_svc{nullptr};
36 RGWSI_Zone *zone_svc{nullptr};
37 RGWSI_RADOS *rados_svc{nullptr};
38
39 void init(RGWSI_Cls *_cls_svc, RGWSI_Zone *_zone_svc, RGWSI_RADOS *_rados_svc) {
40 cls_svc = _cls_svc;
41 zone_svc = _cls_svc->zone_svc;
42 rados_svc = _cls_svc->rados_svc;
43 }
44
45 public:
46 ClsSubService(CephContext *cct) : RGWServiceInstance(cct) {}
47 };
48
49 public:
50 class MFA : public ClsSubService {
51 int get_mfa_obj(const DoutPrefixProvider *dpp, const rgw_user& user, std::optional<RGWSI_RADOS::Obj> *obj);
52 int get_mfa_ref(const DoutPrefixProvider *dpp, const rgw_user& user, rgw_rados_ref *ref);
53
54 void prepare_mfa_write(librados::ObjectWriteOperation *op,
55 RGWObjVersionTracker *objv_tracker,
56 const ceph::real_time& mtime);
57
58 public:
59 MFA(CephContext *cct): ClsSubService(cct) {}
60
61 std::string get_mfa_oid(const rgw_user& user) {
62 return std::string("user:") + user.to_str();
63 }
64
65 int check_mfa(const DoutPrefixProvider *dpp, const rgw_user& user, const std::string& otp_id, const std::string& pin, optional_yield y);
66 int create_mfa(const DoutPrefixProvider *dpp, const rgw_user& user, const rados::cls::otp::otp_info_t& config,
67 RGWObjVersionTracker *objv_tracker, const ceph::real_time& mtime, optional_yield y);
68 int remove_mfa(const DoutPrefixProvider *dpp,
69 const rgw_user& user, const std::string& id,
70 RGWObjVersionTracker *objv_tracker,
71 const ceph::real_time& mtime,
72 optional_yield y);
73 int get_mfa(const DoutPrefixProvider *dpp, const rgw_user& user, const std::string& id, rados::cls::otp::otp_info_t *result, optional_yield y);
74 int list_mfa(const DoutPrefixProvider *dpp, const rgw_user& user, std::list<rados::cls::otp::otp_info_t> *result, optional_yield y);
75 int otp_get_current_time(const DoutPrefixProvider *dpp, const rgw_user& user, ceph::real_time *result, optional_yield y);
76 int set_mfa(const DoutPrefixProvider *dpp, const std::string& oid, const std::list<rados::cls::otp::otp_info_t>& entries,
77 bool reset_obj, RGWObjVersionTracker *objv_tracker,
78 const real_time& mtime, optional_yield y);
79 int list_mfa(const DoutPrefixProvider *dpp, const std::string& oid, std::list<rados::cls::otp::otp_info_t> *result,
80 RGWObjVersionTracker *objv_tracker, ceph::real_time *pmtime, optional_yield y);
81 } mfa;
82
83 class TimeLog : public ClsSubService {
84 int init_obj(const DoutPrefixProvider *dpp, const std::string& oid, RGWSI_RADOS::Obj& obj);
85 public:
86 TimeLog(CephContext *cct): ClsSubService(cct) {}
87
88 void prepare_entry(cls_log_entry& entry,
89 const real_time& ut,
90 const std::string& section,
91 const std::string& key,
92 bufferlist& bl);
93 int add(const DoutPrefixProvider *dpp,
94 const std::string& oid,
95 const real_time& ut,
96 const std::string& section,
97 const std::string& key,
98 bufferlist& bl,
99 optional_yield y);
100 int add(const DoutPrefixProvider *dpp,
101 const std::string& oid,
102 std::list<cls_log_entry>& entries,
103 librados::AioCompletion *completion,
104 bool monotonic_inc,
105 optional_yield y);
106 int list(const DoutPrefixProvider *dpp,
107 const std::string& oid,
108 const real_time& start_time,
109 const real_time& end_time,
110 int max_entries, std::list<cls_log_entry>& entries,
111 const std::string& marker,
112 std::string *out_marker,
113 bool *truncated,
114 optional_yield y);
115 int info(const DoutPrefixProvider *dpp,
116 const std::string& oid,
117 cls_log_header *header,
118 optional_yield y);
119 int info_async(const DoutPrefixProvider *dpp,
120 RGWSI_RADOS::Obj& obj,
121 const std::string& oid,
122 cls_log_header *header,
123 librados::AioCompletion *completion);
124 int trim(const DoutPrefixProvider *dpp,
125 const std::string& oid,
126 const real_time& start_time,
127 const real_time& end_time,
128 const std::string& from_marker,
129 const std::string& to_marker,
130 librados::AioCompletion *completion,
131 optional_yield y);
132 } timelog;
133
134 class Lock : public ClsSubService {
135 int init_obj(const std::string& oid, RGWSI_RADOS::Obj& obj);
136 public:
137 Lock(CephContext *cct): ClsSubService(cct) {}
138 int lock_exclusive(const DoutPrefixProvider *dpp,
139 const rgw_pool& pool,
140 const std::string& oid,
141 timespan& duration,
142 std::string& zone_id,
143 std::string& owner_id,
144 std::optional<std::string> lock_name = std::nullopt);
145 int unlock(const DoutPrefixProvider *dpp,
146 const rgw_pool& pool,
147 const std::string& oid,
148 std::string& zone_id,
149 std::string& owner_id,
150 std::optional<std::string> lock_name = std::nullopt);
151 } lock;
152
153 RGWSI_Cls(CephContext *cct): RGWServiceInstance(cct), mfa(cct), timelog(cct), lock(cct) {}
154
155 void init(RGWSI_Zone *_zone_svc, RGWSI_RADOS *_rados_svc) {
156 rados_svc = _rados_svc;
157 zone_svc = _zone_svc;
158
159 mfa.init(this, zone_svc, rados_svc);
160 timelog.init(this, zone_svc, rados_svc);
161 lock.init(this, zone_svc, rados_svc);
162 }
163
164 int do_start(optional_yield, const DoutPrefixProvider *dpp) override;
165 };
166