]>
Commit | Line | Data |
---|---|---|
c88ee46c | 1 | #!/usr/bin/env python3 |
1bd26988 FZ |
2 | # |
3 | # CentOS image | |
4 | # | |
5 | # Copyright 2018 Red Hat Inc. | |
6 | # | |
7 | # Authors: | |
8 | # Fam Zheng <famz@redhat.com> | |
9 | # | |
10 | # This code is licensed under the GPL version 2 or later. See | |
11 | # the COPYING file in the top-level directory. | |
12 | # | |
13 | ||
14 | import os | |
15 | import sys | |
16 | import subprocess | |
17 | import basevm | |
18 | import time | |
19 | ||
20 | class CentosVM(basevm.BaseVM): | |
21 | name = "centos" | |
31719c37 | 22 | arch = "x86_64" |
1bd26988 FZ |
23 | BUILD_SCRIPT = """ |
24 | set -e; | |
25 | cd $(mktemp -d); | |
26 | export SRC_ARCHIVE=/dev/vdb; | |
27 | sudo chmod a+r $SRC_ARCHIVE; | |
28 | tar -xf $SRC_ARCHIVE; | |
aea43913 WSM |
29 | make docker-test-block@centos7 {verbose} J={jobs} NETWORK=1; |
30 | make docker-test-quick@centos7 {verbose} J={jobs} NETWORK=1; | |
31 | make docker-test-mingw@fedora {verbose} J={jobs} NETWORK=1; | |
1bd26988 FZ |
32 | """ |
33 | ||
1bd26988 FZ |
34 | def build_image(self, img): |
35 | cimg = self._download_with_cache("https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1802.qcow2.xz") | |
36 | img_tmp = img + ".tmp" | |
920fff90 | 37 | sys.stderr.write("Extracting the image...\n") |
676d1f3e CR |
38 | subprocess.check_call(["ln", "-f", cimg, img_tmp + ".xz"]) |
39 | subprocess.check_call(["xz", "--keep", "-dvf", img_tmp + ".xz"]) | |
1e48931c | 40 | self.exec_qemu_img("resize", img_tmp, "50G") |
b081986c | 41 | self.boot(img_tmp, extra_args = ["-cdrom", self.gen_cloud_init_iso()]) |
1bd26988 FZ |
42 | self.wait_ssh() |
43 | self.ssh_root_check("touch /etc/cloud/cloud-init.disabled") | |
44 | self.ssh_root_check("yum update -y") | |
6cd7b608 | 45 | self.ssh_root_check("yum install -y docker make git python3") |
1bd26988 FZ |
46 | self.ssh_root_check("systemctl enable docker") |
47 | self.ssh_root("poweroff") | |
48 | self.wait() | |
1bd26988 FZ |
49 | os.rename(img_tmp, img) |
50 | return 0 | |
51 | ||
52 | if __name__ == "__main__": | |
53 | sys.exit(basevm.main(CentosVM)) |