]>
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" | |
24 | #include "common/errno.h" | |
11fdf7f2 TL |
25 | #include "include/ceph_assert.h" |
26 | ||
27 | #include "services/svc_zone.h" | |
7c673cae FG |
28 | |
29 | #define dout_context g_ceph_context | |
30 | #define dout_subsys ceph_subsys_rgw | |
31 | ||
32 | void RGWOp_ZoneGroupMap_Get::execute() { | |
9f95a23c | 33 | http_ret = zonegroup_map.read(g_ceph_context, store->svc()->sysobj); |
7c673cae FG |
34 | if (http_ret < 0) { |
35 | dout(5) << "failed to read zone_group map" << dendl; | |
36 | } | |
37 | } | |
38 | ||
39 | void RGWOp_ZoneGroupMap_Get::send_response() { | |
40 | set_req_state_err(s, http_ret); | |
41 | dump_errno(s); | |
42 | end_header(s); | |
43 | ||
44 | if (http_ret < 0) | |
45 | return; | |
46 | ||
47 | if (old_format) { | |
48 | RGWRegionMap region_map; | |
49 | region_map.regions = zonegroup_map.zonegroups; | |
50 | region_map.master_region = zonegroup_map.master_zonegroup; | |
51 | region_map.bucket_quota = zonegroup_map.bucket_quota; | |
52 | region_map.user_quota = zonegroup_map.user_quota; | |
53 | encode_json("region-map", region_map, s->formatter); | |
54 | } else { | |
55 | encode_json("zonegroup-map", zonegroup_map, s->formatter); | |
56 | } | |
57 | flusher.flush(); | |
58 | } | |
59 | ||
60 | void RGWOp_ZoneConfig_Get::send_response() { | |
9f95a23c | 61 | const RGWZoneParams& zone_params = store->svc()->zone->get_zone_params(); |
7c673cae FG |
62 | |
63 | set_req_state_err(s, http_ret); | |
64 | dump_errno(s); | |
65 | end_header(s); | |
66 | ||
67 | if (http_ret < 0) | |
68 | return; | |
69 | ||
70 | encode_json("zone_params", zone_params, s->formatter); | |
71 | flusher.flush(); | |
72 | } | |
73 | ||
74 | RGWOp* RGWHandler_Config::op_get() { | |
75 | bool exists; | |
76 | string type = s->info.args.get("type", &exists); | |
77 | ||
78 | if (type.compare("zonegroup-map") == 0) { | |
79 | return new RGWOp_ZoneGroupMap_Get(false); | |
80 | } else if (type.compare("zone") == 0) { | |
81 | return new RGWOp_ZoneConfig_Get(); | |
82 | } else { | |
83 | return new RGWOp_ZoneGroupMap_Get(true); | |
84 | } | |
85 | } |