From: Max Kellermann Date: Tue, 19 Aug 2025 12:15:00 +0000 (+0200) Subject: mon/MgrContext: move JSONCommand to separate header X-Git-Tag: v21.0.0~50^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=de566549310733b0eb6571402f51e464ae3e667a;p=ceph.git mon/MgrContext: move JSONCommand to separate header To reduce header dependency on ceph_json.h. Signed-off-by: Max Kellermann --- diff --git a/src/mgr/JSONCommand.h b/src/mgr/JSONCommand.h new file mode 100644 index 00000000000..2efc8e126f8 --- /dev/null +++ b/src/mgr/JSONCommand.h @@ -0,0 +1,40 @@ +// -*- 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) 2016 John Spray + * + * 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 MGR_JSON_COMMAND_H_ +#define MGR_JSON_COMMAND_H_ + +#include "MgrContext.h" +#include "common/ceph_json.h" + +class JSONCommand : public Command +{ +public: + json_spirit::mValue json_result; + + void wait() override + { + Command::wait(); + + if (r == 0) { + bool read_ok = json_spirit::read( + outbl.to_str(), json_result); + if (!read_ok) { + r = -EINVAL; + } + } + } +}; + +#endif + diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index 0225527c5ed..fc9b649f321 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -37,6 +37,7 @@ #include "MgrContext.h" #include "DaemonServer.h" +#include "JSONCommand.h" #include "PyModule.h" #include "Mgr.h" diff --git a/src/mgr/MgrContext.h b/src/mgr/MgrContext.h index a5490bef3d6..d9fdcab5934 100644 --- a/src/mgr/MgrContext.h +++ b/src/mgr/MgrContext.h @@ -16,7 +16,6 @@ #include -#include "common/ceph_json.h" #include "common/Cond.h" #include "mon/MonClient.h" @@ -49,25 +48,5 @@ public: virtual ~Command() {} }; - -class JSONCommand : public Command -{ -public: - json_spirit::mValue json_result; - - void wait() override - { - Command::wait(); - - if (r == 0) { - bool read_ok = json_spirit::read( - outbl.to_str(), json_result); - if (!read_ok) { - r = -EINVAL; - } - } - } -}; - #endif