]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2013 eNovance SAS <licensing@enovance.com> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | #include "common/ceph_json.h" | |
15 | #include "common/strtol.h" | |
16 | #include "rgw_rest.h" | |
17 | #include "rgw_op.h" | |
18 | #include "rgw_rados.h" | |
19 | #include "rgw_rest_s3.h" | |
20 | #include "rgw_rest_config.h" | |
21 | #include "rgw_client_io.h" | |
22 | #include "common/errno.h" | |
23 | #include "include/assert.h" | |
24 | ||
25 | #define dout_context g_ceph_context | |
26 | #define dout_subsys ceph_subsys_rgw | |
27 | ||
28 | void RGWOp_ZoneGroupMap_Get::execute() { | |
29 | http_ret = zonegroup_map.read(g_ceph_context, store); | |
30 | if (http_ret < 0) { | |
31 | dout(5) << "failed to read zone_group map" << dendl; | |
32 | } | |
33 | } | |
34 | ||
35 | void RGWOp_ZoneGroupMap_Get::send_response() { | |
36 | set_req_state_err(s, http_ret); | |
37 | dump_errno(s); | |
38 | end_header(s); | |
39 | ||
40 | if (http_ret < 0) | |
41 | return; | |
42 | ||
43 | if (old_format) { | |
44 | RGWRegionMap region_map; | |
45 | region_map.regions = zonegroup_map.zonegroups; | |
46 | region_map.master_region = zonegroup_map.master_zonegroup; | |
47 | region_map.bucket_quota = zonegroup_map.bucket_quota; | |
48 | region_map.user_quota = zonegroup_map.user_quota; | |
49 | encode_json("region-map", region_map, s->formatter); | |
50 | } else { | |
51 | encode_json("zonegroup-map", zonegroup_map, s->formatter); | |
52 | } | |
53 | flusher.flush(); | |
54 | } | |
55 | ||
56 | void RGWOp_ZoneConfig_Get::send_response() { | |
57 | const RGWZoneParams& zone_params = store->get_zone_params(); | |
58 | ||
59 | set_req_state_err(s, http_ret); | |
60 | dump_errno(s); | |
61 | end_header(s); | |
62 | ||
63 | if (http_ret < 0) | |
64 | return; | |
65 | ||
66 | encode_json("zone_params", zone_params, s->formatter); | |
67 | flusher.flush(); | |
68 | } | |
69 | ||
70 | RGWOp* RGWHandler_Config::op_get() { | |
71 | bool exists; | |
72 | string type = s->info.args.get("type", &exists); | |
73 | ||
74 | if (type.compare("zonegroup-map") == 0) { | |
75 | return new RGWOp_ZoneGroupMap_Get(false); | |
76 | } else if (type.compare("zone") == 0) { | |
77 | return new RGWOp_ZoneConfig_Get(); | |
78 | } else { | |
79 | return new RGWOp_ZoneGroupMap_Get(true); | |
80 | } | |
81 | } |