示例#1
0
    def os(self):
        if not hasattr(self, '_os'):
            try:
                os_release = self.sh('cat /etc/os-release').strip()
                self._os = OS.from_os_release(os_release)
                return self._os
            except CommandFailedError:
                pass

            lsb_release = self.sh('lsb_release -a').strip()
            self._os = OS.from_lsb_release(lsb_release)
        return self._os
示例#2
0
    def os(self):
        if not hasattr(self, '_os'):
            proc = self.run(args=['cat', '/etc/os-release'], stdout=StringIO(),
                            stderr=StringIO(), check_status=False)
            if proc.exitstatus == 0:
                self._os = OS.from_os_release(proc.stdout.getvalue().strip())
                return self._os

            proc = self.run(args=['lsb_release', '-a'], stdout=StringIO(),
                            stderr=StringIO())
            self._os = OS.from_lsb_release(proc.stdout.getvalue().strip())
        return self._os
示例#3
0
    def _init_from_config(self):
        """
        Initializes the class from a teuthology job config
        """
        self.arch = self.job_config.get('arch', 'x86_64')
        self.os_type = self.job_config.get("os_type")
        self.flavor = self.job_config.get("flavor")
        self.codename = self.job_config.get("codename")
        self.os_version = self._get_version()
        # if os_version is given, prefer version/codename derived from it
        if self.os_version:
            self.os_version, self.codename = \
                OS.version_codename(self.os_type, self.os_version)
        self.branch = self.job_config.get("branch")
        self.tag = self.job_config.get("tag")
        self.ref = self.job_config.get("ref")
        self.distro = self._get_distro(
            distro=self.os_type,
            version=self.os_version,
            codename=self.codename,
        )
        self.pkg_type = "deb" if self.os_type.lower() in (
            "ubuntu",
            "debian",
        ) else "rpm"

        if not getattr(self, 'flavor'):
            # avoiding circular imports
            from teuthology.suite.util import get_install_task_flavor
            # when we're initializing from a full teuthology config, not just a
            # task config we need to make sure we're looking at the flavor for
            # the install task
            self.flavor = get_install_task_flavor(self.job_config)
示例#4
0
def get_distro_defaults(distro, machine_type):
    """
    Given a distro (e.g. 'ubuntu') and machine type, return:
        (arch, release, pkg_type)

    This is used to default to:
        ('x86_64', 'trusty', 'deb') when passed 'ubuntu' and 'plana'
        ('armv7l', 'saucy', 'deb') when passed 'ubuntu' and 'saya'
        ('x86_64', 'wheezy', 'deb') when passed 'debian'
        ('x86_64', 'fedora20', 'rpm') when passed 'fedora'
    And ('x86_64', 'centos7', 'rpm') when passed anything else
    """
    arch = 'x86_64'
    if distro in (None, 'None'):
        os_type = 'centos'
        os_version = '7'
    elif distro in ('rhel', 'centos'):
        os_type = 'centos'
        os_version = '7'
    elif distro == 'ubuntu':
        os_type = distro
        if machine_type == 'saya':
            os_version = '13.10'
            arch = 'armv7l'
        else:
            os_version = '14.04'
    elif distro == 'debian':
        os_type = distro
        os_version = '7'
    elif distro == 'fedora':
        os_type = distro
        os_version = '20'
    elif distro == 'opensuse':
        os_type = distro
        os_version = '15.1'
    else:
        raise ValueError("Invalid distro value passed: %s", distro)
    _os = OS(name=os_type, version=os_version)
    release = get_builder_project()._get_distro(
        _os.name,
        _os.version,
        _os.codename,
    )
    template = "Defaults for machine_type {mtype} distro {distro}: " \
        "arch={arch}, release={release}, pkg_type={pkg}"
    log.debug(template.format(
        mtype=machine_type,
        distro=_os.name,
        arch=arch,
        release=release,
        pkg=_os.package_type)
    )
    return (
        arch,
        release,
        _os,
    )
示例#5
0
    def create_initial_config(self):
        """
        Put together the config file used as the basis for each job in the run.
        Grabs hashes for the latest ceph, kernel and teuthology versions in the
        branches specified and specifies them so we know exactly what we're
        testing.

        :returns: A JobConfig object
        """
        self.kernel_dict = self.choose_kernel()
        ceph_hash = self.choose_ceph_hash()
        # We don't store ceph_version because we don't use it yet outside of
        # logging.
        self.choose_ceph_version(ceph_hash)
        suite_branch = self.choose_suite_branch()
        suite_hash = self.choose_suite_hash(suite_branch)
        if self.args.suite_dir:
            self.suite_repo_path = self.args.suite_dir
        else:
            self.suite_repo_path = util.fetch_repos(suite_branch,
                                                    test_name=self.name)
        teuthology_branch, teuthology_sha1 = self.choose_teuthology_branch()

        if self.args.distro_version:
            self.args.distro_version, _ = \
                OS.version_codename(self.args.distro, self.args.distro_version)
        self.config_input = dict(
            suite=self.args.suite,
            suite_branch=suite_branch,
            suite_hash=suite_hash,
            ceph_branch=self.args.ceph_branch,
            ceph_hash=ceph_hash,
            ceph_repo=config.get_ceph_git_url(),
            teuthology_branch=teuthology_branch,
            teuthology_sha1=teuthology_sha1,
            machine_type=self.args.machine_type,
            distro=self.args.distro,
            distro_version=self.args.distro_version,
            archive_upload=config.archive_upload,
            archive_upload_key=config.archive_upload_key,
            suite_repo=config.get_ceph_qa_suite_git_url(),
            suite_relpath=self.args.suite_relpath,
            flavor=self.args.flavor,
        )
        return self.build_base_config()
示例#6
0
    def _get_distro(cls, distro=None, version=None, codename=None):
        """
        Given a distro and a version, returned the combined string
        to use in a gitbuilder url.

        :param distro:   The distro as a string
        :param version:  The version as a string
        :param codename: The codename for the distro.
                         Used for deb based distros.
        """
        if distro in ('centos', 'rhel'):
            distro = "centos"
        elif distro == "fedora":
            distro = "fedora"
        elif distro == "opensuse":
            distro = "opensuse"
        elif distro == "sle":
            distro == "sle"
        else:
            # deb based systems use codename instead of a distro/version combo
            if not codename:
                # lookup codename based on distro string
                codename = OS._version_to_codename(distro, version)
                if not codename:
                    msg = "No codename found for: {distro} {version}".format(
                        distro=distro,
                        version=version,
                    )
                    log.exception(msg)
                    raise RuntimeError()
            return codename

        return "{distro}{version}".format(
            distro=distro,
            version=cls._parse_version(version),
        )
示例#7
0
 def test_version_codename_success(self):
     assert OS.version_codename('ubuntu', '14.04') == ('14.04', 'trusty')
     assert OS.version_codename('ubuntu', 'trusty') == ('14.04', 'trusty')
示例#8
0
 def test_eq_not_equal(self):
     os = OS(name='ubuntu', codename='trusty', version='16.04')
     assert OS(name='ubuntu', codename='trusty', version='14.04') != os
示例#9
0
 def test_debian_9_os_release(self):
     os = OS.from_os_release(self.str_debian_9_os_release)
     assert os.name == 'debian'
     assert os.version == '9'
     assert os.codename == 'stretch'
     assert os.package_type == 'deb'
示例#10
0
 def test_debian_8_os_release(self):
     os = OS.from_os_release(self.str_debian_8_os_release)
     assert os.name == 'debian'
     assert os.version == '8'
     assert os.codename == 'jessie'
     assert os.package_type == 'deb'
示例#11
0
 def test_codename_no_version(self):
     os = OS(name='ubuntu', codename='trusty')
     assert os.version == '14.04'
示例#12
0
 def test_distro_defaults_debian(self):
     expected = ('x86_64', 'wheezy',
                 OS(name='debian', version='7', codename='wheezy'))
     assert util.get_distro_defaults('debian', 'magna') == expected
示例#13
0
 def test_distro_defaults_default(self):
     expected = ('x86_64', 'centos7',
                 OS(name='centos', version='7', codename='core'))
     assert util.get_distro_defaults('rhel', 'magna') == expected
示例#14
0
 def test_ubuntu_12_04_os_release(self):
     os = OS.from_os_release(self.str_ubuntu_12_04_os_release)
     assert os.name == 'ubuntu'
     assert os.version == '12.04'
     assert os.codename == 'precise'
     assert os.package_type == 'deb'
示例#15
0
 def test_distro_defaults_saya(self):
     expected = ('armv7l', 'saucy',
                 OS(name='ubuntu', version='13.10', codename='saucy'))
     assert util.get_distro_defaults('ubuntu', 'saya') == expected
示例#16
0
 def test_opensuse_15_1_os_release(self):
     os = OS.from_os_release(self.str_opensuse_15_1_os_release)
     assert os.name == 'opensuse'
     assert os.version == '15.1'
     assert os.codename == 'leap'
     assert os.package_type == 'rpm'
示例#17
0
 def test_fedora_26_os_release(self):
     os = OS.from_os_release(self.str_fedora_26_os_release)
     assert os.name == 'fedora'
     assert os.version == '26'
     assert os.codename == '26'
     assert os.package_type == 'rpm'
示例#18
0
 def test_rhel_7_os_release(self):
     os = OS.from_os_release(self.str_rhel_7_os_release)
     assert os.name == 'rhel'
     assert os.version == '7.0'
     assert os.codename == 'maipo'
     assert os.package_type == 'rpm'
示例#19
0
 def test_rhel_6_4_lsb_release(self):
     os = OS.from_lsb_release(self.str_rhel_6_4_lsb_release)
     assert os.name == 'rhel'
     assert os.version == '6.4'
     assert os.codename == 'santiago'
     assert os.package_type == 'rpm'
示例#20
0
 def test_ubuntu_18_04_os_release(self):
     os = OS.from_os_release(self.str_ubuntu_18_04_os_release)
     assert os.name == 'ubuntu'
     assert os.version == '18.04'
     assert os.codename == 'bionic'
     assert os.package_type == 'deb'
示例#21
0
 def test_version_codename_failure(self):
     with pytest.raises(KeyError) as excinfo:
         OS.version_codename('ubuntu', 'frog')
     assert excinfo.type == KeyError
     assert 'frog' in excinfo.value.args[0]
示例#22
0
 def test_repr(self):
     os = OS(name='NAME', version='0.1.2', codename='code')
     assert repr(os) == "OS(name='NAME', version='0.1.2', codename='code')"
示例#23
0
 def test_distro_defaults_plana(self):
     expected = ('x86_64', 'trusty',
                 OS(name='ubuntu', version='14.04', codename='trusty'))
     assert util.get_distro_defaults('ubuntu', 'plana') == expected
示例#24
0
 def test_centos_7_os_release_newer(self):
     os = OS.from_os_release(self.str_centos_7_os_release_newer)
     assert os.name == 'centos'
     assert os.version == '7'
     assert os.codename == 'core'
     assert os.package_type == 'rpm'
示例#25
0
 def test_distro_defaults_fedora(self):
     expected = ('x86_64', 'fedora20',
                 OS(name='fedora', version='20', codename='heisenbug'))
     assert util.get_distro_defaults('fedora', 'magna') == expected
示例#26
0
 def test_version_no_codename(self):
     os = OS(name='ubuntu', version='16.04')
     assert os.codename == 'xenial'
示例#27
0
 def test_to_dict(self):
     os = OS(name='NAME', version='0.1.2', codename='code')
     ref_dict = dict(name='NAME', version='0.1.2', codename='code')
     assert os.to_dict() == ref_dict
示例#28
0
 def test_debian_7_os_release(self):
     os = OS.from_os_release(self.str_debian_7_os_release)
     assert os.name == 'debian'
     assert os.version == '7'
     assert os.codename == 'wheezy'
     assert os.package_type == 'deb'