From 53e92f62a049fe04b8ac02eb1c7b2f131140c335 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Wed, 12 Feb 2014 16:45:40 +0100 Subject: [PATCH] mon: split prepare_command in two So that it is possible to call prepare_command without a session established and a cmdmap that has already been parsed. Signed-off-by: Loic Dachary --- src/mon/OSDMonitor.cc | 25 ++++++++++++++++--------- src/mon/OSDMonitor.h | 1 + 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index a3ff89abedcbb..eea7bcb7d6a10 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3230,12 +3230,7 @@ int OSDMonitor::prepare_command_pool_set(map &cmdmap, bool OSDMonitor::prepare_command(MMonCommand *m) { - bool ret = false; stringstream ss; - string rs; - bufferlist rdata; - int err = 0; - map cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); @@ -3243,16 +3238,28 @@ bool OSDMonitor::prepare_command(MMonCommand *m) return true; } - string format; - cmd_getval(g_ceph_context, cmdmap, "format", format, string("plain")); - boost::scoped_ptr f(new_formatter(format)); - MonSession *session = m->get_session(); if (!session) { mon->reply_command(m, -EACCES, "access denied", get_last_committed()); return true; } + return prepare_command_impl(m, cmdmap); +} + +bool OSDMonitor::prepare_command_impl(MMonCommand *m, + map &cmdmap) +{ + bool ret = false; + stringstream ss; + string rs; + bufferlist rdata; + int err = 0; + + string format; + cmd_getval(g_ceph_context, cmdmap, "format", format, string("plain")); + boost::scoped_ptr f(new_formatter(format)); + string prefix; cmd_getval(g_ceph_context, cmdmap, "prefix", prefix); diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index fc225d5ed70c1..73f8a9a26300c 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -348,6 +348,7 @@ private: list > *detail) const; bool preprocess_command(MMonCommand *m); bool prepare_command(MMonCommand *m); + bool prepare_command_impl(MMonCommand *m, map &cmdmap); int prepare_command_pool_set(map &cmdmap, stringstream& ss); -- 2.39.5