def rpm_dist(distro):
- # start using the el7 prefix now that rhel7 exists.
- if distro.normalized_name == 'redhat' and distro.release.startswith('7'):
- return 'el7'
- if distro.normalized_name == 'centos' and distro.release.startswith('7'):
- return 'el7'
+ release = int(float_or_zero(distro.release))
+ if distro.normalized_name in ['redhat', 'centos', 'scientific'] and release >= 6:
+ return 'el' + str(release)
return 'el6'
('Red Hat Enterprise Linux Server', '7.0', 'Maipo')
"""
- if distro.normalized_name == 'redhat':
- if distro.release.startswith('6'):
- return 'rhel6'
- elif distro.release.startswith('7'):
- return 'rhel7'
-
- if distro.normalized_name == 'centos':
- if distro.release.startswith('6'):
- return 'el6'
- if distro.release.startswith('7'):
- return 'el7'
+ release = int(float_or_zero(distro.release))
+ if release >= 6:
+ if distro.normalized_name == 'redhat':
+ return 'rhel' + str(release)
+ if distro.normalized_name in ['centos', 'scientific']:
+ return 'el' + str(release)
return 'el6'
pkg_managers.yum(distro.conn, 'wget')
pkg_managers.yum(distro.conn, 'ceph')
+
+
+def float_or_zero(value):
+ try:
+ return float(value)
+ except:
+ return 0.0
def test_url_detects_rhel6(self):
self.distro.normalized_name = 'redhat'
+ self.distro.release = "6.4"
assert centos.repository_url_part(self.distro) == 'rhel6'
def test_url_detects_rhel5(self):
self.distro.release = '7.0'
assert centos.repository_url_part(self.distro) == 'rhel7'
+ def test_url_detects_el5(self):
+ self.distro.normalized_name = 'centos'
+ self.distro.release = '5'
+ assert centos.repository_url_part(self.distro) == 'el6'
+
+ def test_url_detects_el6(self):
+ self.distro.normalized_name = 'centos'
+ self.distro.release = '6.2'
+ assert centos.repository_url_part(self.distro) == 'el6'
+
+ def test_url_detects_el7(self):
+ self.distro.normalized_name = 'centos'
+ self.distro.release = '7.0'
+ assert centos.repository_url_part(self.distro) == 'el7'
+
+ def test_url_detects_scientific_el5(self):
+ self.distro.normalized_name = 'scientific'
+ self.distro.release = '5'
+ assert centos.repository_url_part(self.distro) == 'el6'
+
+ def test_url_detects_scientific_el6(self):
+ self.distro.normalized_name = 'scientific'
+ self.distro.release = '6.2'
+ assert centos.repository_url_part(self.distro) == 'el6'
+
+ def test_url_detects_scientific_el7(self):
+ self.distro.normalized_name = 'scientific'
+ self.distro.release = '7.0'
+ assert centos.repository_url_part(self.distro) == 'el7'
+
def test_rpm_dist_fallsback_to_el6(self):
self.distro.normalized_name = 'redhat'
self.distro.release = '3'
self.distro.release = '7.0'
assert centos.rpm_dist(self.distro) == 'el7'
- def test_url_fallsback_to_el6_centos(self):
- self.distro.normalized_name = 'centos'
- self.distro.release = ''
- assert centos.repository_url_part(self.distro) == 'el6'
-
- def test_url_detects_el5(self):
+ def test_rpm_dist_fallsback_to_el6_centos(self):
self.distro.normalized_name = 'centos'
- self.distro.release = '5.0'
- assert centos.repository_url_part(self.distro) == 'el6'
+ self.distro.release = '4'
+ assert centos.rpm_dist(self.distro) == 'el6'
- def test_url_detects_el6(self):
+ def test_rpm_dist_detects_el6_centos(self):
self.distro.normalized_name = 'centos'
- self.distro.release = '6.0'
- assert centos.repository_url_part(self.distro) == 'el6'
+ self.distro.release = '6.6'
+ assert centos.rpm_dist(self.distro) == 'el6'
- def test_url_detects_el7(self):
+ def test_rpm_dist_detects_el7_centos(self):
self.distro.normalized_name = 'centos'
self.distro.release = '7.0'
- assert centos.repository_url_part(self.distro) == 'el7'
+ assert centos.rpm_dist(self.distro) == 'el7'
- def test_rpm_dist_fallsback_to_el6_centos(self):
- self.distro.normalized_name = 'centos'
+ def test_rpm_dist_fallsback_to_el6_scientific(self):
+ self.distro.normalized_name = 'scientific'
self.distro.release = '5'
assert centos.rpm_dist(self.distro) == 'el6'
- def test_rpm_dist_detects_el6_centos(self):
- self.distro.normalized_name = 'centos'
+ def test_rpm_dist_detects_el6_scientific(self):
+ self.distro.normalized_name = 'scientific'
self.distro.release = '6.6'
assert centos.rpm_dist(self.distro) == 'el6'
- def test_rpm_dist_detects_el7(self):
- self.distro.normalized_name = 'centos'
+ def test_rpm_dist_detects_el7_scientific(self):
+ self.distro.normalized_name = 'scientific'
self.distro.release = '7.0'
assert centos.rpm_dist(self.distro) == 'el7'