summaryrefslogtreecommitdiffstats
path: root/src/rgw
diff options
context:
space:
mode:
authorCasey Bodley <cbodley@redhat.com>2015-10-16 22:59:06 +0200
committerYehuda Sadeh <yehuda@redhat.com>2016-02-12 01:13:20 +0100
commit5704bcd1b78fb84fed04c2916f170aa55106c060 (patch)
tree992c03b1e913008ab3ce368808afc1083893c38b /src/rgw
parentrgw: add realm params to period pull (diff)
downloadceph-5704bcd1b78fb84fed04c2916f170aa55106c060.tar.xz
ceph-5704bcd1b78fb84fed04c2916f170aa55106c060.zip
rgw: add op for GET /admin/realm
this is for the radosgw-admin 'realm pull' command, which gets the realm object by name or id Signed-off-by: Casey Bodley <cbodley@redhat.com>
Diffstat (limited to 'src/rgw')
-rw-r--r--src/rgw/rgw_rest_realm.cc49
-rw-r--r--src/rgw/rgw_rest_realm.h2
2 files changed, 51 insertions, 0 deletions
diff --git a/src/rgw/rgw_rest_realm.cc b/src/rgw/rgw_rest_realm.cc
index 6dbdac2b718..d175945dcb2 100644
--- a/src/rgw/rgw_rest_realm.cc
+++ b/src/rgw/rgw_rest_realm.cc
@@ -92,8 +92,57 @@ class RGWRESTMgr_Period : public RGWRESTMgr {
}
};
+
+// GET /admin/realm
+class RGWOp_Realm_Get : public RGWRESTOp {
+ std::unique_ptr<RGWRealm> realm;
+public:
+ int verify_permission() override { return 0; }
+ void execute() override;
+ void send_response() override;
+ const string name() { return "get_realm"; }
+};
+
+void RGWOp_Realm_Get::execute()
+{
+ string id;
+ RESTArgs::get_string(s, "id", id, &id);
+ string name;
+ RESTArgs::get_string(s, "name", name, &name);
+
+ // read realm
+ realm.reset(new RGWRealm(id, name));
+ http_ret = realm->init(g_ceph_context, store);
+ if (http_ret < 0)
+ lderr(store->ctx()) << "failed to read realm id=" << id
+ << " name=" << name << dendl;
+}
+
+void RGWOp_Realm_Get::send_response()
+{
+ set_req_state_err(s, http_ret);
+ dump_errno(s);
+ end_header(s);
+
+ if (http_ret < 0)
+ return;
+
+ encode_json("realm", *realm, s->formatter);
+ flusher.flush();
+}
+
+class RGWHandler_Realm : public RGWHandler_Auth_S3 {
+protected:
+ RGWOp *op_get() { return new RGWOp_Realm_Get; }
+};
+
RGWRESTMgr_Realm::RGWRESTMgr_Realm()
{
// add the /admin/realm/period resource
register_resource("period", new RGWRESTMgr_Period);
}
+
+RGWHandler* RGWRESTMgr_Realm::get_handler(struct req_state*)
+{
+ return new RGWHandler_Realm;
+}
diff --git a/src/rgw/rgw_rest_realm.h b/src/rgw/rgw_rest_realm.h
index c6c1ae0517c..d53e0607e7e 100644
--- a/src/rgw/rgw_rest_realm.h
+++ b/src/rgw/rgw_rest_realm.h
@@ -9,6 +9,8 @@
class RGWRESTMgr_Realm : public RGWRESTMgr {
public:
RGWRESTMgr_Realm();
+
+ RGWHandler* get_handler(struct req_state*) override;
};
#endif