]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_rest_info.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / rgw / rgw_rest_info.cc
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 "rgw_op.h"
5 #include "rgw_rest_info.h"
6 #include "rgw_sal.h"
7
8 #define dout_subsys ceph_subsys_rgw
9
10 class RGWOp_Info_Get : public RGWRESTOp {
11
12 public:
13 RGWOp_Info_Get() {}
14
15 int check_caps(const RGWUserCaps& caps) override {
16 return caps.check_cap("info", RGW_CAP_READ);
17 }
18 void execute(optional_yield y) override;
19
20 const char* name() const override { return "get_info"; }
21 };
22
23 void RGWOp_Info_Get::execute(optional_yield y) {
24 Formatter *formatter = flusher.get_formatter();
25 flusher.start(0);
26
27 /* extensible array of general info sections, currently only
28 * storage backend is defined:
29 * {"info":{"storage_backends":[{"name":"rados","cluster_id":"75d1938b-2949-4933-8386-fb2d1449ff03"}]}}
30 */
31 formatter->open_object_section("dummy");
32 formatter->open_object_section("info");
33 formatter->open_array_section("storage_backends");
34 // for now, just return the backend that is accessible
35 formatter->open_object_section("dummy");
36 formatter->dump_string("name", store->get_name());
37 formatter->dump_string("cluster_id", store->get_cluster_id(this, y));
38 formatter->close_section();
39 formatter->close_section();
40 formatter->close_section();
41 formatter->close_section();
42
43 flusher.flush();
44 } /* RGWOp_Info_Get::execute */
45
46 RGWOp *RGWHandler_Info::op_get()
47 {
48 return new RGWOp_Info_Get;
49 }