From 4e599868974b2ffd8c090219aa0926cd2d240ced Mon Sep 17 00:00:00 2001 From: Yogesh Prasad Date: Wed, 5 Feb 2020 11:03:41 +0530 Subject: [PATCH] Fix to extend OS support using the distro (#20) * Fix to extend OS support using the distro * incorporated review comments --- wavefront_cli/__init__.py | 2 +- wavefront_cli/lib/agent.py | 17 +++++++---------- wavefront_cli/lib/proxy.py | 18 ++++++------------ 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/wavefront_cli/__init__.py b/wavefront_cli/__init__.py index 8adc5be..304c3da 100644 --- a/wavefront_cli/__init__.py +++ b/wavefront_cli/__init__.py @@ -1,2 +1,2 @@ """Initialize wavefront cli version.""" -__version__ = '0.0.118' +__version__ = '0.0.119' diff --git a/wavefront_cli/lib/agent.py b/wavefront_cli/lib/agent.py index bf30edd..b248247 100644 --- a/wavefront_cli/lib/agent.py +++ b/wavefront_cli/lib/agent.py @@ -23,24 +23,21 @@ def get_install_agent_cmd(): " support@wavefront.com.") return cmd - if dist.strip() in ("Oracle Linux Server", "Fedora", - "Red Hat Enterprise Linux Server", - "Red Hat Enterprise Linux Workstation", - "CentOS", "CentOS Linux" - ) or dist.startswith("Amazon Linux"): + if dist.strip().startswith(("Oracle Linux Server", "Fedora", + "Amazon Linux", "CentOS", + "Red Hat Enterprise Linux")): cmd = "curl -s %s | bash" % (agent_pkg_rpm) cmd += " && yum -y -q install telegraf" - elif dist == "Ubuntu": + elif dist.strip().startswith("Ubuntu"): cmd = "curl -s %s | bash" % (agent_pkg_deb) cmd += ' && apt-get -y -qq -o Dpkg::Options::="--force-confold"' \ ' install telegraf' - elif dist == "debian": + elif dist.strip().lower().startswith("debian"): cmd = "curl -s %s | bash" % (agent_pkg_deb) cmd += ' && apt-get -o Dpkg::Options::="--force-confnew"' \ ' -y install telegraf' - elif dist.strip() == "openSUSE" or\ - dist.strip() == "SUSE Linux Enterprise Server" or \ - dist.strip() == "SLES": + elif dist.strip().startswith(("openSUSE", "SUSE Linux Enterprise Server", + "SLES")): cmd = "curl -s %s | bash" % (agent_pkg_rpm) cmd += ' && zypper install telegraf' else: diff --git a/wavefront_cli/lib/proxy.py b/wavefront_cli/lib/proxy.py index 1eb929c..42595f8 100644 --- a/wavefront_cli/lib/proxy.py +++ b/wavefront_cli/lib/proxy.py @@ -33,30 +33,24 @@ def get_proxy_install_cmd(proxy_next): " install the latest beta version proxy.") print("Detected ", dist) - if dist.strip() in ("CentOS", "CentOS Linux", "Fedora", - "Oracle Linux Server", - "Red Hat Enterprise Linux Server", - "Red Hat Enterprise Linux Workstation", - ) or dist.startswith("Amazon Linux"): - + if dist.strip().startswith(("Oracle Linux Server", "Fedora", + "Amazon Linux", "CentOS", + "Red Hat Enterprise Linux")): pkg = proxy_pkg_rpm if proxy_next: pkg = proxy_next_pkg_rpm cmd = "curl -s %s | bash" % (pkg) cmd += " && yum -y -q install wavefront-proxy" - elif dist in ("Ubuntu", "debian"): - + elif dist.strip().lower().startswith(("ubuntu", "debian")): pkg = proxy_pkg_deb if proxy_next: pkg = proxy_next_pkg_deb cmd = "curl -s %s | bash" % pkg cmd += " && apt-get -y -q install wavefront-proxy" - elif dist.strip() == "openSUSE" or\ - dist.strip() == "SUSE Linux Enterprise Server" or \ - dist.strip() == "SLES": - + elif dist.strip().startswith(("openSUSE", "SUSE Linux Enterprise Server", + "SLES")): pkg = proxy_pkg_rpm if proxy_next: pkg = proxy_next_pkg_rpm