From: Tom Walsh Date: Fri, 8 Aug 2014 03:48:59 +0000 (-0500) Subject: Modified the system to handle subversion numbers in the release number. For instance... X-Git-Tag: v1.5.11~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2204afee8a14a7d80585f1e9cb03b4f24d5e2923;p=ceph-deploy.git Modified the system to handle subversion numbers in the release number. For instance in production our server was reporting a release version of 7.0.1406. This is not a valid float() so the system was returning an el6 value. I have added additional logic to find the first . (dot) in the string and convert that to a float value. I have also added a test to look for and test this corner case. --- diff --git a/ceph_deploy/hosts/centos/install.py b/ceph_deploy/hosts/centos/install.py index f3b5989..684e4df 100644 --- a/ceph_deploy/hosts/centos/install.py +++ b/ceph_deploy/hosts/centos/install.py @@ -1,5 +1,6 @@ from ceph_deploy.util import pkg_managers, templates from ceph_deploy.lib import remoto +import re def rpm_dist(distro): @@ -254,7 +255,9 @@ def repo_install(distro, reponame, baseurl, gpgkey, **kw): def float_or_zero(value): try: - return float(value) + regex = re.compile(r"^[^.]*") + newvalue = re.search(regex, value).group(0) + return float(newvalue) except: return 0.0 diff --git a/ceph_deploy/tests/unit/hosts/test_centos.py b/ceph_deploy/tests/unit/hosts/test_centos.py index 312fc4f..e09cceb 100644 --- a/ceph_deploy/tests/unit/hosts/test_centos.py +++ b/ceph_deploy/tests/unit/hosts/test_centos.py @@ -84,6 +84,11 @@ class TestCentosVersionDetection(object): self.distro.release = '7.0' assert centos.rpm_dist(self.distro) == 'el7' + def test_rpm_dist_detects_centos_version_with_subversion(self): + self.distro.normalized_name = 'centos' + self.distro.release = '7.0.1406' + assert centos.rpm_dist(self.distro) == 'el7' + def test_rpm_dist_fallsback_to_el6_scientific(self): self.distro.normalized_name = 'scientific' self.distro.release = '5'