]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/services/svc_cls.h
80674a286bcf3c5230cbe2d926ca9653208ab4e4
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 rgw_user
& user
, std::optional
<RGWSI_RADOS::Obj
> *obj
);
52 int get_mfa_ref(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 string
get_mfa_oid(const rgw_user
& user
) {
62 return string("user:") + user
.to_str();
65 int check_mfa(const rgw_user
& user
, const string
& otp_id
, const string
& pin
, optional_yield y
);
66 int create_mfa(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 rgw_user
& user
, const string
& id
,
69 RGWObjVersionTracker
*objv_tracker
,
70 const ceph::real_time
& mtime
,
72 int get_mfa(const rgw_user
& user
, const string
& id
, rados::cls::otp::otp_info_t
*result
, optional_yield y
);
73 int list_mfa(const rgw_user
& user
, list
<rados::cls::otp::otp_info_t
> *result
, optional_yield y
);
74 int otp_get_current_time(const rgw_user
& user
, ceph::real_time
*result
, optional_yield y
);
75 int set_mfa(const string
& oid
, const list
<rados::cls::otp::otp_info_t
>& entries
,
76 bool reset_obj
, RGWObjVersionTracker
*objv_tracker
,
77 const real_time
& mtime
, optional_yield y
);
78 int list_mfa(const string
& oid
, list
<rados::cls::otp::otp_info_t
> *result
,
79 RGWObjVersionTracker
*objv_tracker
, ceph::real_time
*pmtime
, optional_yield y
);
82 class TimeLog
: public ClsSubService
{
83 int init_obj(const string
& oid
, RGWSI_RADOS::Obj
& obj
);
85 TimeLog(CephContext
*cct
): ClsSubService(cct
) {}
87 void prepare_entry(cls_log_entry
& entry
,
89 const string
& section
,
92 int add(const string
& oid
,
94 const string
& section
,
98 int add(const string
& oid
,
99 std::list
<cls_log_entry
>& entries
,
100 librados::AioCompletion
*completion
,
103 int list(const string
& oid
,
104 const real_time
& start_time
,
105 const real_time
& end_time
,
106 int max_entries
, list
<cls_log_entry
>& entries
,
107 const string
& marker
,
111 int info(const string
& oid
,
112 cls_log_header
*header
,
114 int info_async(RGWSI_RADOS::Obj
& obj
,
116 cls_log_header
*header
,
117 librados::AioCompletion
*completion
);
118 int trim(const string
& oid
,
119 const real_time
& start_time
,
120 const real_time
& end_time
,
121 const string
& from_marker
,
122 const string
& to_marker
,
123 librados::AioCompletion
*completion
,
127 class Lock
: public ClsSubService
{
128 int init_obj(const string
& oid
, RGWSI_RADOS::Obj
& obj
);
130 Lock(CephContext
*cct
): ClsSubService(cct
) {}
131 int lock_exclusive(const rgw_pool
& pool
,
136 std::optional
<string
> lock_name
= std::nullopt
);
137 int unlock(const rgw_pool
& pool
,
141 std::optional
<string
> lock_name
= std::nullopt
);
144 RGWSI_Cls(CephContext
*cct
): RGWServiceInstance(cct
), mfa(cct
), timelog(cct
), lock(cct
) {}
146 void init(RGWSI_Zone
*_zone_svc
, RGWSI_RADOS
*_rados_svc
) {
147 rados_svc
= _rados_svc
;
148 zone_svc
= _zone_svc
;
150 mfa
.init(this, zone_svc
, rados_svc
);
151 timelog
.init(this, zone_svc
, rados_svc
);
152 lock
.init(this, zone_svc
, rados_svc
);
155 int do_start(optional_yield
) override
;