From c3c3e4e90ba6b09e29879b500f211d607ebabb53 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 27 Jul 2017 11:49:45 -0400 Subject: [PATCH] mon/MgrMonitor: store services in map and expose with command Signed-off-by: John Spray --- src/mon/MgrMonitor.cc | 14 ++++++++++++++ src/mon/MonCommands.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index 9a340d950eff7..a1a2b2b94fd62 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -302,6 +302,13 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op) bool updated = false; if (pending_map.active_gid == m->get_gid()) { + if (pending_map.services != m->get_services()) { + dout(4) << "updated services from mgr." << m->get_name() + << ": " << m->get_services() << dendl; + pending_map.services = m->get_services(); + updated = true; + } + // A beacon from the currently active daemon if (pending_map.active_addr != m->get_server_addr()) { dout(4) << "learned address " << m->get_server_addr() @@ -695,6 +702,13 @@ bool MgrMonitor::preprocess_command(MonOpRequestRef op) } f->close_section(); f->flush(rdata); + } else if (prefix == "mgr services") { + f->open_object_section("services"); + for (const auto &i : map.services) { + f->dump_string(i.first.c_str(), i.second); + } + f->close_section(); + f->flush(rdata); } else if (prefix == "mgr metadata") { string name; cmd_getval(g_ceph_context, cmdmap, "id", name); diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 40c843ef64122..4694c1102b462 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -1064,6 +1064,9 @@ COMMAND("mgr fail name=who,type=CephString", \ "treat the named manager daemon as failed", "mgr", "rw", "cli,rest") COMMAND("mgr module ls", "list active mgr modules", "mgr", "r", "cli,rest") +COMMAND("mgr services", + "list service endpoints provided by mgr modules", + "mgr", "r", "cli,rest") COMMAND("mgr module enable " \ "name=module,type=CephString " \ "name=force,type=CephChoices,strings=--force,req=false", -- 2.39.5