From 0b55393c5d79d8a157d8c0d135719ae8c8530bf1 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 12 Sep 2018 09:08:53 -0400 Subject: [PATCH] rgw: remove rest handlers for /admin/opstate Signed-off-by: Casey Bodley --- src/rgw/CMakeLists.txt | 2 - src/rgw/rgw_common.cc | 1 - src/rgw/rgw_main.cc | 2 - src/rgw/rgw_rest_opstate.cc | 191 ------------------------------------ src/rgw/rgw_rest_opstate.h | 111 --------------------- 5 files changed, 307 deletions(-) delete mode 100644 src/rgw/rgw_rest_opstate.cc delete mode 100644 src/rgw/rgw_rest_opstate.h diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index 47142cfc684d9..0e5d9199266fa 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -92,7 +92,6 @@ set(librgw_common_srcs rgw_rest_conn.cc rgw_rest_log.cc rgw_rest_metadata.cc - rgw_rest_opstate.cc rgw_rest_realm.cc rgw_rest_role.cc rgw_rest_s3.cc @@ -134,7 +133,6 @@ set(rgw_a_srcs rgw_rest_config.cc rgw_rest_log.cc rgw_rest_metadata.cc - rgw_rest_opstate.cc rgw_rest_realm.cc rgw_rest_swift.cc rgw_rest_usage.cc diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 963539403eb1b..c66a3d53e52eb 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -1799,7 +1799,6 @@ bool RGWUserCaps::is_valid_cap_type(const string& tp) "bilog", "mdlog", "datalog", - "opstate", "roles", "user-policy"}; diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index b046a5764ca73..3ac76c47dadb1 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -25,7 +25,6 @@ #include "rgw_rest_bucket.h" #include "rgw_rest_metadata.h" #include "rgw_rest_log.h" -#include "rgw_rest_opstate.h" #include "rgw_rest_config.h" #include "rgw_rest_realm.h" #include "rgw_swift_auth.h" @@ -397,7 +396,6 @@ int main(int argc, const char **argv) /*Registering resource for /admin/metadata */ admin_resource->register_resource("metadata", new RGWRESTMgr_Metadata); admin_resource->register_resource("log", new RGWRESTMgr_Log); - admin_resource->register_resource("opstate", new RGWRESTMgr_Opstate); admin_resource->register_resource("config", new RGWRESTMgr_Config); admin_resource->register_resource("realm", new RGWRESTMgr_Realm); rest.register_resource(g_conf()->rgw_admin_entry, admin_resource); diff --git a/src/rgw/rgw_rest_opstate.cc b/src/rgw/rgw_rest_opstate.cc deleted file mode 100644 index 52e04b5a8d813..0000000000000 --- a/src/rgw/rgw_rest_opstate.cc +++ /dev/null @@ -1,191 +0,0 @@ -// -*- 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 - * - * 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_rest_s3.h" -#include "rgw_rest_opstate.h" -#include "rgw_client_io.h" -#include "common/errno.h" -#include "include/ceph_assert.h" - -#define dout_context g_ceph_context -#define OPSTATE_LIST_MAX_ENTRIES 1000 -#define dout_subsys ceph_subsys_rgw - -void RGWOp_Opstate_List::execute() { - string client_id = s->info.args.get("client-id"), - op_id = s->info.args.get("op-id"), - object = s->info.args.get("object"), - max_entries_str = s->info.args.get("max-entries"); - unsigned max_entries = OPSTATE_LIST_MAX_ENTRIES; - - if (!max_entries_str.empty()) { - string err; - max_entries = (unsigned)strict_strtol(max_entries_str.c_str(), 10, &err); - if (!err.empty()) { - dout(5) << "Error parsing max-entries " << max_entries_str << dendl; - http_ret = -EINVAL; - return; - } - } - - RGWOpState oc = RGWOpState(store); - void *handle; - bool done; - list entries; - - oc.init_list_entries(client_id, op_id, object, &handle); - - http_ret = 0; - send_response(); - do { - int ret = oc.list_entries(handle, max_entries, entries, &done); - - if (ret < 0) { - dout(5) << "oc.list_entries failed with error " << ret << dendl; - http_ret = ret; - oc.finish_list_entries(handle); - return; - } - - if (!max_entries_str.empty()) - max_entries -= entries.size(); - - send_response(entries); - } while (!done && max_entries > 0); - - oc.finish_list_entries(handle); - send_response_end(); -} - -void RGWOp_Opstate_List::send_response() { - if (sent_header) - return; - - set_req_state_err(s, http_ret); - dump_errno(s); - end_header(s); - - sent_header = true; - - if (http_ret < 0) - return; - - s->formatter->open_array_section("entries"); -} - -void RGWOp_Opstate_List::send_response(list entries) { - RGWOpState oc(store); - for (list::iterator it = entries.begin(); - it != entries.end(); ++it) { - oc.dump_entry(*it, s->formatter); - flusher.flush(); - } -} - -void RGWOp_Opstate_List::send_response_end() { - s->formatter->close_section(); - flusher.flush(); -} - -void RGWOp_Opstate_Set::execute() { - string client_id = s->info.args.get("client-id"), - op_id = s->info.args.get("op-id"), - object = s->info.args.get("object"), - state_str = s->info.args.get("state"); - - if (client_id.empty() || - op_id.empty() || - object.empty() || - state_str.empty()) { - dout(5) << "Error - invalid parameter list" << dendl; - http_ret = -EINVAL; - return; - } - - RGWOpState oc(store); - RGWOpState::OpState state; - - http_ret = oc.state_from_str(state_str, &state); - if (http_ret < 0) { - dout(5) << "Error - invalid state" << dendl; - return; - } - - http_ret = oc.set_state(client_id, op_id, object, state); - if (http_ret < 0) { - dout(5) << "Error - Unable to set state" << dendl; - return; - } -} - -void RGWOp_Opstate_Renew::execute() { - string client_id = s->info.args.get("client-id"), - op_id = s->info.args.get("op-id"), - object = s->info.args.get("object"), - state_str = s->info.args.get("state"); - - if (client_id.empty() || - op_id.empty() || - object.empty() || - state_str.empty()) { - dout(5) << "Error - invalid parameter list" << dendl; - http_ret = -EINVAL; - return; - } - RGWOpState oc(store); - RGWOpState::OpState state; - - http_ret = oc.state_from_str(state_str, &state); - if (http_ret < 0) { - dout(5) << "Error - invalid state" << dendl; - return; - } - - http_ret = oc.renew_state(client_id, op_id, object, state); - if (http_ret < 0) { - dout(5) << "Error - Unable to renew state" << dendl; - return; - } -} - -void RGWOp_Opstate_Delete::execute() { - string client_id = s->info.args.get("client-id"), - op_id = s->info.args.get("op-id"), - object = s->info.args.get("object"); - - if (client_id.empty() || - op_id.empty() || - object.empty()) { - dout(5) << "Error - invalid parameter list" << dendl; - http_ret = -EINVAL; - return; - } - - RGWOpState oc(store); - - http_ret = oc.remove_entry(client_id, op_id, object); - if (http_ret < 0) { - dout(5) << "Error - Unable to remove entry" << dendl; - } -} - -RGWOp *RGWHandler_Opstate::op_post() { - if (s->info.args.exists("renew")) { - return new RGWOp_Opstate_Renew; - } - return new RGWOp_Opstate_Set; -} diff --git a/src/rgw/rgw_rest_opstate.h b/src/rgw/rgw_rest_opstate.h deleted file mode 100644 index 0dce84eac9921..0000000000000 --- a/src/rgw/rgw_rest_opstate.h +++ /dev/null @@ -1,111 +0,0 @@ -// -*- 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 - * - * 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 RGW_REST_OPSTATE_H -#define RGW_REST_OPSTATE_H - -class RGWOp_Opstate_List : public RGWRESTOp { - bool sent_header; -public: - RGWOp_Opstate_List() : sent_header(false) {} - ~RGWOp_Opstate_List() override {} - - int check_caps(RGWUserCaps& caps) override { - return caps.check_cap("opstate", RGW_CAP_READ); - } - int verify_permission() override { - return check_caps(s->user->caps); - } - void execute() override; - void send_response() override; - virtual void send_response(list entries); - virtual void send_response_end(); - const char* name() const override { - return "opstate_list"; - } -}; - -class RGWOp_Opstate_Set : public RGWRESTOp { -public: - RGWOp_Opstate_Set() {} - ~RGWOp_Opstate_Set() override {} - - int check_caps(RGWUserCaps& caps) override { - return caps.check_cap("opstate", RGW_CAP_WRITE); - } - void execute() override; - const char* name() const override { - return "set_opstate"; - } -}; - -class RGWOp_Opstate_Renew : public RGWRESTOp { -public: - RGWOp_Opstate_Renew() {} - ~RGWOp_Opstate_Renew() override {} - - int check_caps(RGWUserCaps& caps) override { - return caps.check_cap("opstate", RGW_CAP_WRITE); - } - void execute() override; - const char* name() const override { - return "renew_opstate"; - } -}; - -class RGWOp_Opstate_Delete : public RGWRESTOp { -public: - RGWOp_Opstate_Delete() {} - ~RGWOp_Opstate_Delete() override {} - - int check_caps(RGWUserCaps& caps) override { - return caps.check_cap("opstate", RGW_CAP_WRITE); - } - void execute() override; - const char* name() const override { - return "delete_opstate"; - } -}; - -class RGWHandler_Opstate : public RGWHandler_Auth_S3 { -protected: - RGWOp *op_get() override { - return new RGWOp_Opstate_List; - } - RGWOp *op_delete() override { - return new RGWOp_Opstate_Delete; - } - RGWOp *op_post() override; - - int read_permissions(RGWOp*) override { - return 0; - } -public: - using RGWHandler_Auth_S3::RGWHandler_Auth_S3; - ~RGWHandler_Opstate() override = default; -}; - -class RGWRESTMgr_Opstate : public RGWRESTMgr { -public: - RGWRESTMgr_Opstate() = default; - ~RGWRESTMgr_Opstate() override = default; - - RGWHandler_REST* get_handler(struct req_state*, - const rgw::auth::StrategyRegistry& auth_registry, - const std::string&) override { - return new RGWHandler_Opstate(auth_registry); - } -}; - -#endif /*!RGW_REST_OPSTATE_H*/ -- 2.39.5