From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/tools/rbd/MirrorDaemonServiceInfo.h | 78 +++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/tools/rbd/MirrorDaemonServiceInfo.h (limited to 'src/tools/rbd/MirrorDaemonServiceInfo.h') diff --git a/src/tools/rbd/MirrorDaemonServiceInfo.h b/src/tools/rbd/MirrorDaemonServiceInfo.h new file mode 100644 index 000000000..d667332e5 --- /dev/null +++ b/src/tools/rbd/MirrorDaemonServiceInfo.h @@ -0,0 +1,78 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_RBD_MIRROR_DAEMON_SERVICE_INFO_H +#define CEPH_RBD_MIRROR_DAEMON_SERVICE_INFO_H + +#include "include/rados/librados_fwd.hpp" +#include "tools/rbd/ArgumentTypes.h" + +#include +#include +#include +#include + +namespace rbd { + +enum MirrorHealth { + MIRROR_HEALTH_OK = 0, + MIRROR_HEALTH_UNKNOWN = 1, + MIRROR_HEALTH_WARNING = 2, + MIRROR_HEALTH_ERROR = 3 +}; + +std::ostream& operator<<(std::ostream& os, MirrorHealth mirror_health); + +struct MirrorService { + MirrorService() {} + explicit MirrorService(const std::string& service_id) + : service_id(service_id) { + } + + std::string service_id; + std::string instance_id; + bool leader = false; + std::string client_id; + std::string ceph_version; + std::string hostname; + std::list callouts; + + MirrorHealth health = MIRROR_HEALTH_UNKNOWN; + + std::string get_image_description() const; + void dump_image(argument_types::Format::Formatter formatter) const; +}; + +typedef std::list MirrorServices; + +class MirrorDaemonServiceInfo { +public: + MirrorDaemonServiceInfo(librados::IoCtx &io_ctx) : m_io_ctx(io_ctx) { + } + + int init(); + + const MirrorService* get_by_service_id(const std::string& service_id) const; + const MirrorService* get_by_instance_id(const std::string& instance_id) const; + + MirrorServices get_mirror_services() const; + MirrorHealth get_daemon_health() const { + return m_daemon_health; + } + +private: + librados::IoCtx &m_io_ctx; + + std::map m_mirror_services; + std::map m_instance_to_service_ids; + + MirrorHealth m_daemon_health = MIRROR_HEALTH_UNKNOWN; + + int get_mirror_service_dump(); + int get_mirror_service_status(); + +}; + +} // namespace rbd + +#endif // CEPH_RBD_MIRROR_DAEMON_SERVICE_INFO_H -- cgit v1.2.3