]> git.proxmox.com Git - ceph.git/blame - ceph/src/tools/rbd/MirrorDaemonServiceInfo.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / tools / rbd / MirrorDaemonServiceInfo.h
CommitLineData
11fdf7f2
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#ifndef CEPH_RBD_MIRROR_DAEMON_SERVICE_INFO_H
5#define CEPH_RBD_MIRROR_DAEMON_SERVICE_INFO_H
6
7#include "include/rados/librados_fwd.hpp"
8#include "tools/rbd/ArgumentTypes.h"
9
9f95a23c
TL
10#include <iosfwd>
11#include <list>
11fdf7f2 12#include <map>
9f95a23c 13#include <string>
11fdf7f2
TL
14
15namespace rbd {
16
9f95a23c
TL
17enum MirrorHealth {
18 MIRROR_HEALTH_OK = 0,
19 MIRROR_HEALTH_UNKNOWN = 1,
20 MIRROR_HEALTH_WARNING = 2,
21 MIRROR_HEALTH_ERROR = 3
22};
23
24std::ostream& operator<<(std::ostream& os, MirrorHealth mirror_health);
25
26struct MirrorService {
27 MirrorService() {}
28 explicit MirrorService(const std::string& service_id)
29 : service_id(service_id) {
30 }
31
32 std::string service_id;
33 std::string instance_id;
34 bool leader = false;
35 std::string client_id;
36 std::string ceph_version;
37 std::string hostname;
38 std::list<std::string> callouts;
39
40 MirrorHealth health = MIRROR_HEALTH_UNKNOWN;
41
42 std::string get_image_description() const;
43 void dump_image(argument_types::Format::Formatter formatter) const;
44};
45
46typedef std::list<MirrorService> MirrorServices;
47
11fdf7f2
TL
48class MirrorDaemonServiceInfo {
49public:
50 MirrorDaemonServiceInfo(librados::IoCtx &io_ctx) : m_io_ctx(io_ctx) {
51 }
52
53 int init();
54
9f95a23c
TL
55 const MirrorService* get_by_service_id(const std::string& service_id) const;
56 const MirrorService* get_by_instance_id(const std::string& instance_id) const;
57
58 MirrorServices get_mirror_services() const;
59 MirrorHealth get_daemon_health() const {
60 return m_daemon_health;
61 }
11fdf7f2
TL
62
63private:
64 librados::IoCtx &m_io_ctx;
9f95a23c
TL
65
66 std::map<std::string, MirrorService> m_mirror_services;
67 std::map<std::string, std::string> m_instance_to_service_ids;
68
69 MirrorHealth m_daemon_health = MIRROR_HEALTH_UNKNOWN;
70
71 int get_mirror_service_dump();
72 int get_mirror_service_status();
73
11fdf7f2
TL
74};
75
76} // namespace rbd
77
78#endif // CEPH_RBD_MIRROR_DAEMON_SERVICE_INFO_H