summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBabu Shanmugam <anbu@enovance.com>2013-06-28 18:40:52 +0530
committerYehuda Sadeh <yehuda@inktank.com>2013-06-28 16:25:48 -0700
commitcc301b272271b9c911ab0e0bffc73e9be55ba66d (patch)
tree75e958eeebe27506fc0c88d07ebef28cc8a3e2b5
parentceec8d4918ad5ac6901df8f88f38eeed73dce2b7 (diff)
downloadceph-cc301b272271b9c911ab0e0bffc73e9be55ba66d.tar.gz
RESTful implementation to dump regionmap implementation
Signed-off-by: Babu Shanmugam <anbu@enovance.com>
-rw-r--r--src/Makefile.am2
-rw-r--r--src/rgw/rgw_main.cc2
-rw-r--r--src/rgw/rgw_rest_config.cc47
-rw-r--r--src/rgw/rgw_rest_config.h55
4 files changed, 106 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index ecc5b5641a9..e8ef4c72626 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -425,6 +425,7 @@ radosgw_SOURCES = \
rgw/rgw_replica_log.cc \
rgw/rgw_rest_log.cc \
rgw/rgw_rest_replica_log.cc \
+ rgw/rgw_rest_config.cc \
rgw/rgw_http_client.cc \
rgw/rgw_swift.cc \
rgw/rgw_swift_auth.cc \
@@ -2145,6 +2146,7 @@ noinst_HEADERS = \
rgw/rgw_rest_metadata.h\
rgw/rgw_rest_log.h\
rgw/rgw_rest_replica_log.h\
+ rgw/rgw_rest_config.h\
rgw/rgw_usage.h\
rgw/rgw_user.h\
rgw/rgw_bucket.h\
diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc
index 547cb275a16..99746dcf71d 100644
--- a/src/rgw/rgw_main.cc
+++ b/src/rgw/rgw_main.cc
@@ -44,6 +44,7 @@
#include "rgw_rest_log.h"
#include "rgw_replica_log.h"
#include "rgw_rest_replica_log.h"
+#include "rgw_rest_config.h"
#include "rgw_swift_auth.h"
#include "rgw_swift.h"
#include "rgw_log.h"
@@ -509,6 +510,7 @@ int main(int argc, const char **argv)
admin_resource->register_resource("metadata", new RGWRESTMgr_Metadata);
admin_resource->register_resource("log", new RGWRESTMgr_Log);
admin_resource->register_resource("replica_log", new RGWRESTMgr_ReplicaLog);
+ admin_resource->register_resource("config", new RGWRESTMgr_Config);
rest.register_resource(g_conf->rgw_admin_entry, admin_resource);
}
diff --git a/src/rgw/rgw_rest_config.cc b/src/rgw/rgw_rest_config.cc
new file mode 100644
index 00000000000..27cc98976f0
--- /dev/null
+++ b/src/rgw/rgw_rest_config.cc
@@ -0,0 +1,47 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+#include "common/ceph_json.h"
+#include "common/strtol.h"
+#include "rgw_rest.h"
+#include "rgw_op.h"
+#include "rgw_rados.h"
+#include "rgw_rest_s3.h"
+#include "rgw_rest_config.h"
+#include "rgw_client_io.h"
+#include "common/errno.h"
+
+#define dout_subsys ceph_subsys_rgw
+
+void RGWOp_RegionMap_Get::execute() {
+ http_ret = regionmap.read(g_ceph_context, store);
+ if (http_ret < 0) {
+ dout(5) << "failed to read region map" << dendl;
+ }
+}
+
+void RGWOp_RegionMap_Get::send_response() {
+ set_req_state_err(s, http_ret);
+ dump_errno(s);
+ end_header(s);
+
+ if (http_ret < 0)
+ return;
+
+ encode_json("region-map", regionmap, s->formatter);
+ flusher.flush();
+}
+
+RGWOp* RGWHandler_Config::op_get() {
+ return new RGWOp_RegionMap_Get;
+}
diff --git a/src/rgw/rgw_rest_config.h b/src/rgw/rgw_rest_config.h
new file mode 100644
index 00000000000..cb1712ac3d7
--- /dev/null
+++ b/src/rgw/rgw_rest_config.h
@@ -0,0 +1,55 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+#ifndef CEPH_RGW_REST_CONFIG_H
+#define CEPH_RGW_REST_CONFIG_H
+
+class RGWOp_RegionMap_Get : public RGWRESTOp {
+ RGWRegionMap regionmap;
+public:
+ RGWOp_RegionMap_Get() {}
+ ~RGWOp_RegionMap_Get() {}
+
+ int verify_permission() {
+ return 0;
+ }
+ void execute();
+ virtual void send_response();
+ virtual const char *name() {
+ return "get_region_map";
+ }
+};
+
+class RGWHandler_Config : public RGWHandler_Auth_S3 {
+protected:
+ RGWOp *op_get();
+
+ int read_permissions(RGWOp*) {
+ return 0;
+ }
+public:
+ RGWHandler_Config() : RGWHandler_Auth_S3() {}
+ virtual ~RGWHandler_Config() {}
+};
+
+class RGWRESTMgr_Config : public RGWRESTMgr {
+public:
+ RGWRESTMgr_Config() {}
+ virtual ~RGWRESTMgr_Config() {}
+
+ virtual RGWHandler *get_handler(struct req_state *s){
+ return new RGWHandler_Config;
+ }
+};
+
+#endif