]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonClient: interpret numeric mon target name as rank
authorSage Weil <sage@redhat.com>
Mon, 30 Sep 2019 15:58:40 +0000 (10:58 -0500)
committerSage Weil <sage@redhat.com>
Fri, 4 Oct 2019 14:07:03 +0000 (09:07 -0500)
This allows us to behave when a rank is passed to mon_command(..., target=),
which will call rados_mon_command_target() -> MonClient::start_mon_command
with a (string) target name.

We could make an integer variant of rados_mon_command_target, and do the
int vs string differentiation in python, but this is much easier.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/MonClient.cc

index 70b97c549638579aec6b7a623187aa97bd1a7e10..a1a0c7b9b4468587e1d62da60828af403d6f3c10 100644 (file)
@@ -1340,7 +1340,17 @@ void MonClient::start_mon_command(const string &mon_name,
     return;
   }
   MonCommand *r = new MonCommand(++last_mon_command_tid);
-  r->target_name = mon_name;
+
+  // detect/tolerate mon *rank* passed as a string
+  string err;
+  int rank = strict_strtoll(mon_name.c_str(), 10, &err);
+  if (err.size() == 0 && rank >= 0) {
+    ldout(cct,10) << __func__ << " interpreting name '" << mon_name
+                 << "' as rank " << rank << dendl;
+    r->target_rank = rank;
+  } else {
+    r->target_name = mon_name;
+  }
   r->cmd = cmd;
   r->inbl = inbl;
   r->poutbl = outbl;