From f13f25669d4c888906623cc98a81f4af34d265a0 Mon Sep 17 00:00:00 2001 From: Michael Fritch Date: Mon, 3 Feb 2020 09:30:45 -0700 Subject: [PATCH] cephadm: check port in use Signed-off-by: Michael Fritch --- src/cephadm/cephadm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index e7fbb2d486bed..6c1393832b75e 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -168,6 +168,10 @@ class NFSGanesha(object): required_files = ['ganesha.conf'] + port_map = { + "nfs" : 2049, + } + def __init__(self, fsid, daemon_id, @@ -196,6 +200,14 @@ class NFSGanesha(object): # type: (str, Union[int, str]) -> NFSGanesha return cls(fsid, daemon_id, get_parm(args.config_json), args.image) + @staticmethod + def port_in_use(): + # type () -> None + for (srv, port) in NFSGanesha.port_map.items(): + if port_in_use(port): + msg = 'TCP port {} required for {} is already in use'.format(port, srv) + raise Error(msg) + @staticmethod def get_container_mounts(data_dir): # type: (str) -> Dict[str, str] @@ -2353,6 +2365,7 @@ def command_deploy(): reconfig=args.reconfig) elif daemon_type == NFSGanesha.daemon_type: + NFSGanesha.port_in_use() (config, keyring) = get_config_and_keyring() # TODO: extract ganesha uid/gid (997, 994) ? (uid, gid) = extract_uid_gid() -- 2.39.5