]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
platform.linux_distribution() is deprecated; stop using it
authorNathan Cutler <ncutler@suse.com>
Thu, 15 Dec 2016 22:57:57 +0000 (23:57 +0100)
committerNathan Cutler <ncutler@suse.com>
Sat, 21 Jul 2018 15:14:29 +0000 (17:14 +0200)
Fixes: http://tracker.ceph.com/issues/18141
Signed-off-by: Nathan Cutler <ncutler@suse.com>
teuthology/orchestra/opsys.py
teuthology/orchestra/remote.py
teuthology/orchestra/test/test_opsys.py

index a2d9b7895bfbeb7f26dae40725273f059e8ebd0c..56f70b51e0d609a9d4b0322ff123a4e8df386e41 100644 (file)
@@ -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):
         """
index 7d06445966893afc1775f943e346a8de713a64eb..a93a9a208bd2fba005824ae7255986de187dd391 100644 (file)
@@ -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:
index 0aa74793978b3d72ecf75ef29277e36e9c3e7667..ca6903351b7d00ea1c867e7d3353469326b844b6 100644 (file)
@@ -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'