]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
9f95a23c | 2 | // vim: ts=8 sw=2 smarttab ft=cpp |
11fdf7f2 | 3 | |
7c673cae FG |
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 | */ | |
11fdf7f2 | 15 | |
7c673cae FG |
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" | |
f67539c2 | 24 | #include "rgw_sal_rados.h" |
7c673cae | 25 | #include "common/errno.h" |
11fdf7f2 TL |
26 | #include "include/ceph_assert.h" |
27 | ||
28 | #include "services/svc_zone.h" | |
7c673cae FG |
29 | |
30 | #define dout_context g_ceph_context | |
31 | #define dout_subsys ceph_subsys_rgw | |
32 | ||
20effc67 TL |
33 | using namespace std; |
34 | ||
f67539c2 | 35 | void RGWOp_ZoneGroupMap_Get::execute(optional_yield y) { |
20effc67 | 36 | op_ret = zonegroup_map.read(this, g_ceph_context, static_cast<rgw::sal::RadosStore*>(store)->svc()->sysobj, y); |
f67539c2 | 37 | if (op_ret < 0) { |
b3b6e05e | 38 | ldpp_dout(this, 5) << "failed to read zone_group map" << dendl; |
7c673cae FG |
39 | } |
40 | } | |
41 | ||
42 | void RGWOp_ZoneGroupMap_Get::send_response() { | |
f67539c2 | 43 | set_req_state_err(s, op_ret); |
7c673cae FG |
44 | dump_errno(s); |
45 | end_header(s); | |
46 | ||
f67539c2 | 47 | if (op_ret < 0) |
7c673cae FG |
48 | return; |
49 | ||
50 | if (old_format) { | |
51 | RGWRegionMap region_map; | |
52 | region_map.regions = zonegroup_map.zonegroups; | |
53 | region_map.master_region = zonegroup_map.master_zonegroup; | |
54 | region_map.bucket_quota = zonegroup_map.bucket_quota; | |
f67539c2 | 55 | region_map.user_quota = zonegroup_map.user_quota; |
7c673cae FG |
56 | encode_json("region-map", region_map, s->formatter); |
57 | } else { | |
58 | encode_json("zonegroup-map", zonegroup_map, s->formatter); | |
59 | } | |
60 | flusher.flush(); | |
61 | } | |
62 | ||
63 | void RGWOp_ZoneConfig_Get::send_response() { | |
20effc67 | 64 | const RGWZoneParams& zone_params = store->get_zone()->get_params(); |
7c673cae | 65 | |
f67539c2 | 66 | set_req_state_err(s, op_ret); |
7c673cae FG |
67 | dump_errno(s); |
68 | end_header(s); | |
69 | ||
f67539c2 | 70 | if (op_ret < 0) |
7c673cae FG |
71 | return; |
72 | ||
73 | encode_json("zone_params", zone_params, s->formatter); | |
74 | flusher.flush(); | |
75 | } | |
76 | ||
77 | RGWOp* RGWHandler_Config::op_get() { | |
78 | bool exists; | |
79 | string type = s->info.args.get("type", &exists); | |
80 | ||
81 | if (type.compare("zonegroup-map") == 0) { | |
82 | return new RGWOp_ZoneGroupMap_Get(false); | |
83 | } else if (type.compare("zone") == 0) { | |
84 | return new RGWOp_ZoneConfig_Get(); | |
85 | } else { | |
86 | return new RGWOp_ZoneGroupMap_Get(true); | |
87 | } | |
88 | } |