From: Nathan Cutler Date: Thu, 15 Dec 2016 22:57:57 +0000 (+0100) Subject: platform.linux_distribution() is deprecated; stop using it X-Git-Tag: 1.1.0~321^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1cbe2926bae75603384aed4290c4d30b35a435f9;p=teuthology.git platform.linux_distribution() is deprecated; stop using it Fixes: http://tracker.ceph.com/issues/18141 Signed-off-by: Nathan Cutler --- diff --git a/teuthology/orchestra/opsys.py b/teuthology/orchestra/opsys.py index a2d9b7895b..56f70b51e0 100644 --- a/teuthology/orchestra/opsys.py +++ b/teuthology/orchestra/opsys.py @@ -1,4 +1,3 @@ -import ast import re DISTRO_CODENAME_MAP = { @@ -78,37 +77,6 @@ class OS(object): codename, )) - @classmethod - def from_python(cls, python_val): - """ - Parse output from platform.linux_distribution() and populate attributes - - Given a tuple or str()'ed tuple like this: - ('Ubuntu', '14.04', 'trusty') - - Attributes will be: - name = 'ubuntu' - version = '14.04' - codename = 'trusty' - Additionally, we set the package type: - package_type = 'deb' - """ - if not isinstance(python_val, tuple): - python_val = ast.literal_eval(python_val) - - (name, version, codename) = python_val - name = name.lower().replace(' ', '') - if name.startswith('redhat'): - name = 'rhel' - elif name.startswith('centos'): - name = 'centos' - elif name.startswith('fedora'): - name = 'fedora' - elif name.startswith('opensuse'): - name = 'opensuse' - obj = cls(name=name, version=version, codename=codename.lower()) - return obj - @classmethod def from_lsb_release(cls, lsb_release_str): """ diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index 7d06445966..a93a9a208b 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -391,15 +391,6 @@ class Remote(object): @property def os(self): if not hasattr(self, '_os'): - proc = self.run( - args=[ - 'python', '-c', - 'import platform; print platform.linux_distribution()'], - stdout=StringIO(), stderr=StringIO(), check_status=False) - if proc.exitstatus == 0: - self._os = OS.from_python(proc.stdout.getvalue().strip()) - return self._os - proc = self.run(args=['cat', '/etc/os-release'], stdout=StringIO(), stderr=StringIO(), check_status=False) if proc.exitstatus == 0: diff --git a/teuthology/orchestra/test/test_opsys.py b/teuthology/orchestra/test/test_opsys.py index 0aa7479397..ca6903351b 100644 --- a/teuthology/orchestra/test/test_opsys.py +++ b/teuthology/orchestra/test/test_opsys.py @@ -36,8 +36,6 @@ class TestOS(object): BUG_REPORT_URL="http://bugs.debian.org/" """) - str_ubuntu_12_04_python = "('Ubuntu', '12.04', 'precise')" - str_ubuntu_12_04_lsb_release = dedent(""" Distributor ID: Ubuntu Description: Ubuntu 12.04.4 LTS @@ -62,8 +60,6 @@ class TestOS(object): Codename: Santiago """) - str_rhel_7_python = "('Red Hat Enterprise Linux Server', '7.0', 'Maipo')" - str_rhel_7_lsb_release = dedent(""" LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch Distributor ID: RedHatEnterpriseServer @@ -111,13 +107,6 @@ class TestOS(object): assert os.codename == 'wheezy' assert os.package_type == 'deb' - def test_ubuntu_12_04_python(self): - os = OS.from_python(self.str_ubuntu_12_04_python) - assert os.name == 'ubuntu' - assert os.version == '12.04' - assert os.codename == 'precise' - assert os.package_type == 'deb' - def test_ubuntu_12_04_lsb_release(self): os = OS.from_lsb_release(self.str_ubuntu_12_04_lsb_release) assert os.name == 'ubuntu' @@ -139,13 +128,6 @@ class TestOS(object): assert os.codename == 'santiago' assert os.package_type == 'rpm' - def test_rhel_7_python(self): - os = OS.from_python(self.str_rhel_7_python) - assert os.name == 'rhel' - assert os.version == '7.0' - assert os.codename == 'maipo' - assert os.package_type == 'rpm' - def test_rhel_7_lsb_release(self): os = OS.from_lsb_release(self.str_rhel_7_lsb_release) assert os.name == 'rhel'