From db6b5c2026eada871ec5e38ed9cbd9037ed8cc38 Mon Sep 17 00:00:00 2001 From: Victor Moene Date: Wed, 23 Apr 2025 16:26:16 +0200 Subject: [PATCH] Added curl installation check when remote download Ticket: CFE-4405 Signed-off-by: Victor Moene --- cf_remote/nt-discovery.sh | 1 + cf_remote/remote.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cf_remote/nt-discovery.sh b/cf_remote/nt-discovery.sh index 506c677..4dc6e2f 100644 --- a/cf_remote/nt-discovery.sh +++ b/cf_remote/nt-discovery.sh @@ -51,4 +51,5 @@ run_command "command -v yum" "YUM" "Cannot find yum" run_command "command -v apt" "APT" "Cannot find apt" run_command "command -v pkg" "PKG" "Cannot find pkg" run_command "command -v zypper" "ZYPPER" "Cannot find zypper" +run_command "command -v curl" "CURL" "Cannot find curl" diff --git a/cf_remote/remote.py b/cf_remote/remote.py index 2ca3ede..3f6902a 100644 --- a/cf_remote/remote.py +++ b/cf_remote/remote.py @@ -255,7 +255,7 @@ def get_info(host, *, users=None, connection=None): data["agent_version"] = parse_version(discovery.get("NTD_CFAGENT_VERSION")) data["bin"] = {} - for bin in ["dpkg", "rpm", "yum", "apt", "pkg", "zypper"]: + for bin in ["dpkg", "rpm", "yum", "apt", "pkg", "zypper", "curl"]: path = discovery.get("NTD_{}".format(bin.upper())) if path: data["bin"][bin] = path @@ -515,6 +515,12 @@ def install_host( return 1 if remote_download: + if ("bin" not in data) or ("curl" not in data["bin"]): + log.error( + "Couldn't download remotely. Curl is not installed on host '%s'" % host + ) + return 1 + print("Downloading '%s' on '%s' using curl" % (package, host)) r = ssh_cmd( cmd="curl --fail -O {}".format(package), connection=connection, errors=True