From: Tom Walsh Date: Fri, 8 Aug 2014 23:02:24 +0000 (-0500) Subject: Updates to the install.py rpm_dist() and repository_url_part() X-Git-Tag: v1.5.11~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=09a722db170c4876b900e557ce9e45ae2d947cd8;p=ceph-deploy.git Updates to the install.py rpm_dist() and repository_url_part() to remove type casting and using the native ints in the normalized_release object. Signed-off-by: Tom Walsh Closes #230 --- diff --git a/ceph_deploy/hosts/centos/__init__.py b/ceph_deploy/hosts/centos/__init__.py index 41a00be..9ac4683 100644 --- a/ceph_deploy/hosts/centos/__init__.py +++ b/ceph_deploy/hosts/centos/__init__.py @@ -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 diff --git a/ceph_deploy/hosts/centos/install.py b/ceph_deploy/hosts/centos/install.py index 148e7c4..1b2776f 100644 --- a/ceph_deploy/hosts/centos/install.py +++ b/ceph_deploy/hosts/centos/install.py @@ -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 - diff --git a/ceph_deploy/tests/unit/hosts/test_centos.py b/ceph_deploy/tests/unit/hosts/test_centos.py index 3efd990..5b3c65e 100644 --- a/ceph_deploy/tests/unit/hosts/test_centos.py +++ b/ceph_deploy/tests/unit/hosts/test_centos.py @@ -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'),