]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_rest_config.cc
import ceph pacific 16.2.5
[ceph.git] / ceph / src / rgw / rgw_rest_config.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 /*
5 * Ceph - scalable distributed file system
6 *
7 * Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
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 #include "common/ceph_json.h"
17 #include "common/strtol.h"
18 #include "rgw_rest.h"
19 #include "rgw_op.h"
20 #include "rgw_rados.h"
21 #include "rgw_rest_s3.h"
22 #include "rgw_rest_config.h"
23 #include "rgw_client_io.h"
24 #include "rgw_sal_rados.h"
25 #include "common/errno.h"
26 #include "include/ceph_assert.h"
27
28 #include "services/svc_zone.h"
29
30 #define dout_context g_ceph_context
31 #define dout_subsys ceph_subsys_rgw
32
33 void RGWOp_ZoneGroupMap_Get::execute(optional_yield y) {
34 op_ret = zonegroup_map.read(this, g_ceph_context, store->svc()->sysobj, y);
35 if (op_ret < 0) {
36 ldpp_dout(this, 5) << "failed to read zone_group map" << dendl;
37 }
38 }
39
40 void RGWOp_ZoneGroupMap_Get::send_response() {
41 set_req_state_err(s, op_ret);
42 dump_errno(s);
43 end_header(s);
44
45 if (op_ret < 0)
46 return;
47
48 if (old_format) {
49 RGWRegionMap region_map;
50 region_map.regions = zonegroup_map.zonegroups;
51 region_map.master_region = zonegroup_map.master_zonegroup;
52 region_map.bucket_quota = zonegroup_map.bucket_quota;
53 region_map.user_quota = zonegroup_map.user_quota;
54 encode_json("region-map", region_map, s->formatter);
55 } else {
56 encode_json("zonegroup-map", zonegroup_map, s->formatter);
57 }
58 flusher.flush();
59 }
60
61 void RGWOp_ZoneConfig_Get::send_response() {
62 const RGWZoneParams& zone_params = store->svc()->zone->get_zone_params();
63
64 set_req_state_err(s, op_ret);
65 dump_errno(s);
66 end_header(s);
67
68 if (op_ret < 0)
69 return;
70
71 encode_json("zone_params", zone_params, s->formatter);
72 flusher.flush();
73 }
74
75 RGWOp* RGWHandler_Config::op_get() {
76 bool exists;
77 string type = s->info.args.get("type", &exists);
78
79 if (type.compare("zonegroup-map") == 0) {
80 return new RGWOp_ZoneGroupMap_Get(false);
81 } else if (type.compare("zone") == 0) {
82 return new RGWOp_ZoneConfig_Get();
83 } else {
84 return new RGWOp_ZoneGroupMap_Get(true);
85 }
86 }