]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
Updates to the install.py rpm_dist() and repository_url_part()
authorTom Walsh <tom.walsh@expresshosting.net>
Fri, 8 Aug 2014 23:02:24 +0000 (18:02 -0500)
committerAlfredo Deza <alfredo.deza@inktank.com>
Fri, 8 Aug 2014 23:35:59 +0000 (19:35 -0400)
to remove type casting and using the native ints in the normalized_release
object.

Signed-off-by: Tom Walsh <tom.walsh@expresshosting.net>
Closes #230

ceph_deploy/hosts/centos/__init__.py
ceph_deploy/hosts/centos/install.py
ceph_deploy/tests/unit/hosts/test_centos.py

index 41a00be1636ef713e56401bd29d2bd3cfe0a331b..9ac46833860600b50028a6afbe46f1d8885a5d68 100644 (file)
@@ -1,6 +1,6 @@
 import mon  # noqa
 import pkg  # noqa
-from install import install, mirror_install, repo_install, repository_url_part, rpm_dist, normalize_release  # noqa
+from install import install, mirror_install, repo_install, repository_url_part, rpm_dist  # noqa
 from uninstall import uninstall  # noqa
 
 # Allow to set some information about this distro
index 148e7c48ddd61281c98451385600b56119cc8bc7..1b2776f0429bf462388ef61ef341ad086be2f0d2 100644 (file)
@@ -1,11 +1,10 @@
 from ceph_deploy.util import pkg_managers, templates
 from ceph_deploy.lib import remoto
-import re
 
 
 def rpm_dist(distro):
-    if distro.normalized_name in ['redhat', 'centos', 'scientific'] and int(distro.normalized_release.major) >= 6:
-        return 'el' + str(distro.normalized_release.major)
+    if distro.normalized_name in ['redhat', 'centos', 'scientific'] and distro.normalized_release.int_major >= 6:
+        return 'el' + distro.normalized_release.major
     return 'el6'
 
 
@@ -25,11 +24,11 @@ def repository_url_part(distro):
         ('Red Hat Enterprise Linux Server', '7.0', 'Maipo')
 
     """
-    if int(distro.normalized_release.major) >= 6:
+    if distro.normalized_release.int_major >= 6:
         if distro.normalized_name == 'redhat':
-            return 'rhel' + str(distro.normalized_release.major)
+            return 'rhel' + distro.normalized_release.major
         if distro.normalized_name in ['centos', 'scientific']:
-            return 'el' + str(distro.normalized_release.major)
+            return 'el' + distro.normalized_release.major
 
     return 'el6'
 
@@ -249,13 +248,3 @@ def repo_install(distro, reponame, baseurl, gpgkey, **kw):
         pkg_managers.yum(distro.conn, 'wget')
 
         pkg_managers.yum(distro.conn, 'ceph')
-
-
-def normalize_release(value):
-    try:
-        regex = re.compile(r"^[^.]*")
-        newvalue = re.search(regex, value).group(0)
-        return int(float(newvalue))
-    except:
-        return 0.0
-
index 3efd990cc69f258e9eb8c5170a820fcac75cfd69..5b3c65e5c4158eb2bede263c4d092c237ef4f5bb 100644 (file)
@@ -19,8 +19,8 @@ class TestCentosRepositoryUrlPart(object):
             dict(distro="CentOS Linux", release='7.0.1406', codename="Core", output='el7'),
             dict(distro="CentOS Linux", release='10.4.000', codename="Core", output='el10'),
             dict(distro="RedHat", release='4.3', codename="Foo", output='el6'),
-            dict(distro="RedHat", release='6.5', codename="Final", output='rhel6'),
-            dict(distro="RedHat", release='7.0', codename="Core", output='rhel7'),
+            dict(distro="Red Hat Enterprise Linux Server", release='5.8', codename="Tikanga", output="el6"),
+            dict(distro="Red Hat Enterprise Linux Server", release='6.5', codename="Santiago", output='rhel6'),
             dict(distro="RedHat", release='7.0.1406', codename="Core", output='rhel7'),
             dict(distro="RedHat", release='10.999.12', codename="Core", output='rhel10'),
             ],
@@ -31,7 +31,8 @@ class TestCentosRepositoryUrlPart(object):
             dict(distro="CentOS Linux", release='7.0.1406', codename="Core", output='el7'),
             dict(distro="CentOS Linux", release='10.10.9191', codename="Core", output='el10'),
             dict(distro="RedHat", release='4.3', codename="Foo", output='el6'),
-            dict(distro="RedHat", release='6.5', codename="Final", output='el6'),
+            dict(distro="Red Hat Enterprise Linux Server", release='5.8', codename="Tikanga", output="el6"),
+            dict(distro="Red Hat Enterprise Linux Server", release='6.5', codename="Santiago", output='el6'),
             dict(distro="RedHat", release='7.0', codename="Core", output='el7'),
             dict(distro="RedHat", release='7.0.1406', codename="Core", output='el7'),
             dict(distro="RedHat", release='10.9.8765', codename="Core", output='el10'),