xref: /openbmc/qemu/tests/vm/centos (revision fb1fa97c)
1c88ee46cSPhilippe Mathieu-Daudé#!/usr/bin/env python3
21bd26988SFam Zheng#
31bd26988SFam Zheng# CentOS image
41bd26988SFam Zheng#
51bd26988SFam Zheng# Copyright 2018 Red Hat Inc.
61bd26988SFam Zheng#
71bd26988SFam Zheng# Authors:
81bd26988SFam Zheng#  Fam Zheng <famz@redhat.com>
91bd26988SFam Zheng#
101bd26988SFam Zheng# This code is licensed under the GPL version 2 or later.  See
111bd26988SFam Zheng# the COPYING file in the top-level directory.
121bd26988SFam Zheng#
131bd26988SFam Zheng
141bd26988SFam Zhengimport os
151bd26988SFam Zhengimport sys
161bd26988SFam Zhengimport subprocess
171bd26988SFam Zhengimport basevm
181bd26988SFam Zhengimport time
191bd26988SFam Zheng
201bd26988SFam Zhengclass CentosVM(basevm.BaseVM):
211bd26988SFam Zheng    name = "centos"
2231719c37SPhilippe Mathieu-Daudé    arch = "x86_64"
231bd26988SFam Zheng    BUILD_SCRIPT = """
241bd26988SFam Zheng        set -e;
251bd26988SFam Zheng        cd $(mktemp -d);
261bd26988SFam Zheng        export SRC_ARCHIVE=/dev/vdb;
271bd26988SFam Zheng        sudo chmod a+r $SRC_ARCHIVE;
281bd26988SFam Zheng        tar -xf $SRC_ARCHIVE;
29*fb1fa97cSDaniel P. Berrangé        make docker-test-block@centos8 {verbose} J={jobs} NETWORK=1;
30*fb1fa97cSDaniel P. Berrangé        make docker-test-quick@centos8 {verbose} J={jobs} NETWORK=1;
31aea43913SWainer dos Santos Moschetta        make docker-test-mingw@fedora  {verbose} J={jobs} NETWORK=1;
321bd26988SFam Zheng    """
331bd26988SFam Zheng
341bd26988SFam Zheng    def build_image(self, img):
35*fb1fa97cSDaniel P. Berrangé        cimg = self._download_with_cache("https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.3.2011-20201204.2.x86_64.qcow2")
361bd26988SFam Zheng        img_tmp = img + ".tmp"
37*fb1fa97cSDaniel P. Berrangé        subprocess.check_call(["ln", "-f", cimg, img_tmp])
381e48931cSWainer dos Santos Moschetta        self.exec_qemu_img("resize", img_tmp, "50G")
39b081986cSRobert Foley        self.boot(img_tmp, extra_args = ["-cdrom", self.gen_cloud_init_iso()])
401bd26988SFam Zheng        self.wait_ssh()
411bd26988SFam Zheng        self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")
42*fb1fa97cSDaniel P. Berrangé        self.ssh_root_check("dnf update -y")
43*fb1fa97cSDaniel P. Berrangé        self.ssh_root_check("dnf install -y dnf-plugins-core")
44*fb1fa97cSDaniel P. Berrangé        self.ssh_root_check("dnf config-manager --set-enabled powertools")
45*fb1fa97cSDaniel P. Berrangé        self.ssh_root_check("dnf install -y podman make ninja-build git python3")
461bd26988SFam Zheng        self.ssh_root("poweroff")
471bd26988SFam Zheng        self.wait()
481bd26988SFam Zheng        os.rename(img_tmp, img)
491bd26988SFam Zheng        return 0
501bd26988SFam Zheng
511bd26988SFam Zhengif __name__ == "__main__":
521bd26988SFam Zheng    sys.exit(basevm.main(CentosVM))
53