]>
git.proxmox.com Git - ceph.git/blob - 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
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2019 Red Hat, Inc.
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.
19 #include "cls/otp/cls_otp_types.h"
20 #include "cls/log/cls_log_types.h"
22 #include "rgw/rgw_service.h"
24 #include "svc_rados.h"
27 class RGWSI_Cls
: public RGWServiceInstance
29 RGWSI_Zone
*zone_svc
{nullptr};
30 RGWSI_RADOS
*rados_svc
{nullptr};
32 class ClsSubService
: public RGWServiceInstance
{
33 friend class RGWSI_Cls
;
35 RGWSI_Cls
*cls_svc
{nullptr};
36 RGWSI_Zone
*zone_svc
{nullptr};
37 RGWSI_RADOS
*rados_svc
{nullptr};
39 void init(RGWSI_Cls
*_cls_svc
, RGWSI_Zone
*_zone_svc
, RGWSI_RADOS
*_rados_svc
) {
41 zone_svc
= _cls_svc
->zone_svc
;
42 rados_svc
= _cls_svc
->rados_svc
;
46 ClsSubService(CephContext
*cct
) : RGWServiceInstance(cct
) {}
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
);
54 void prepare_mfa_write(librados::ObjectWriteOperation
*op
,
55 RGWObjVersionTracker
*objv_tracker
,
56 const ceph::real_time
& mtime
);
59 MFA(CephContext
*cct
): ClsSubService(cct
) {}
61 std::string
get_mfa_oid(const rgw_user
& user
) {
62 return std::string("user:") + user
.to_str();
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
,
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
);
83 class TimeLog
: public ClsSubService
{
84 int init_obj(const DoutPrefixProvider
*dpp
, const std::string
& oid
, RGWSI_RADOS::Obj
& obj
);
86 TimeLog(CephContext
*cct
): ClsSubService(cct
) {}
88 void prepare_entry(cls_log_entry
& entry
,
90 const std::string
& section
,
91 const std::string
& key
,
93 int add(const DoutPrefixProvider
*dpp
,
94 const std::string
& oid
,
96 const std::string
& section
,
97 const std::string
& key
,
100 int add(const DoutPrefixProvider
*dpp
,
101 const std::string
& oid
,
102 std::list
<cls_log_entry
>& entries
,
103 librados::AioCompletion
*completion
,
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
,
115 int info(const DoutPrefixProvider
*dpp
,
116 const std::string
& oid
,
117 cls_log_header
*header
,
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
,
134 class Lock
: public ClsSubService
{
135 int init_obj(const std::string
& oid
, RGWSI_RADOS::Obj
& obj
);
137 Lock(CephContext
*cct
): ClsSubService(cct
) {}
138 int lock_exclusive(const DoutPrefixProvider
*dpp
,
139 const rgw_pool
& pool
,
140 const std::string
& oid
,
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
);
153 RGWSI_Cls(CephContext
*cct
): RGWServiceInstance(cct
), mfa(cct
), timelog(cct
), lock(cct
) {}
155 void init(RGWSI_Zone
*_zone_svc
, RGWSI_RADOS
*_rados_svc
) {
156 rados_svc
= _rados_svc
;
157 zone_svc
= _zone_svc
;
159 mfa
.init(this, zone_svc
, rados_svc
);
160 timelog
.init(this, zone_svc
, rados_svc
);
161 lock
.init(this, zone_svc
, rados_svc
);
164 int do_start(optional_yield
, const DoutPrefixProvider
*dpp
) override
;