From a04010e9490aa726d219c41139c27417dac836e2 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Mon, 22 Feb 2021 23:06:19 -0500 Subject: [PATCH] mon: peer_add should accept Ceph file system UUID Signed-off-by: Venky Shankar --- src/mon/FSCommands.cc | 12 +++++------- src/mon/MonCommands.h | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/mon/FSCommands.cc b/src/mon/FSCommands.cc index a401cc786588c..63ab1594642df 100644 --- a/src/mon/FSCommands.cc +++ b/src/mon/FSCommands.cc @@ -1132,8 +1132,10 @@ public: bool peer_add(FSMap &fsmap, Filesystem::const_ref &&fs, const cmdmap_t &cmdmap, std::stringstream &ss) { + string peer_uuid; string remote_spec; string remote_fs_name; + cmd_getval(cmdmap, "uuid", peer_uuid); cmd_getval(cmdmap, "remote_cluster_spec", remote_spec); cmd_getval(cmdmap, "remote_fs_name", remote_fs_name); @@ -1144,17 +1146,13 @@ public: return false; } - if (fs->mirror_info.has_peer((*remote_conf).first, - (*remote_conf).second, remote_fs_name)) { + if (fs->mirror_info.has_peer(peer_uuid)) { ss << "peer already exists"; return true; } - uuid_d uuid_gen; - uuid_gen.generate_random(); - - auto f = [uuid_gen, remote_conf, remote_fs_name](auto &&fs) { - fs->mirror_info.peer_add(stringify(uuid_gen), (*remote_conf).first, + auto f = [peer_uuid, remote_conf, remote_fs_name](auto &&fs) { + fs->mirror_info.peer_add(peer_uuid, (*remote_conf).first, (*remote_conf).second, remote_fs_name); }; fsmap.modify_filesystem(fs->fscid, std::move(f)); diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 323ad96bbad8d..2498ab6133564 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -437,6 +437,7 @@ COMMAND("fs mirror disable " "disable mirroring for a ceph filesystem", "mds", "rw") COMMAND("fs mirror peer_add " "name=fs_name,type=CephString " + "name=uuid,type=CephString " "name=remote_cluster_spec,type=CephString " "name=remote_fs_name,type=CephString", "add a mirror peer for a ceph filesystem", "mds", "rw") -- 2.39.5