#!/usr/bin/env python3
#
# CentOS image
#
# Copyright 2018 Red Hat Inc.
#
# Authors:
#  Fam Zheng <famz@redhat.com>
#
# This code is licensed under the GPL version 2 or later.  See
# the COPYING file in the top-level directory.
#

import os
import sys
import subprocess
import basevm
import time

class CentosVM(basevm.BaseVM):
    name = "centos"
    arch = "x86_64"
    BUILD_SCRIPT = """
        set -e;
        cd $(mktemp -d);
        export SRC_ARCHIVE=/dev/vdb;
        sudo chmod a+r $SRC_ARCHIVE;
        tar -xf $SRC_ARCHIVE;
        make docker-test-block@centos7 {verbose} J={jobs} NETWORK=1;
        make docker-test-quick@centos7 {verbose} J={jobs} NETWORK=1;
        make docker-test-mingw@fedora  {verbose} J={jobs} NETWORK=1;
    """

    def build_image(self, img):
        cimg = self._download_with_cache("https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1802.qcow2.xz")
        img_tmp = img + ".tmp"
        sys.stderr.write("Extracting the image...\n")
        subprocess.check_call(["ln", "-f", cimg, img_tmp + ".xz"])
        subprocess.check_call(["xz", "--keep", "-dvf", img_tmp + ".xz"])
        self.exec_qemu_img("resize", img_tmp, "50G")
        self.boot(img_tmp, extra_args = ["-cdrom", self.gen_cloud_init_iso()])
        self.wait_ssh()
        self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")
        self.ssh_root_check("yum update -y")
        self.ssh_root_check("yum install -y docker make ninja-build git python3")
        self.ssh_root_check("systemctl enable docker")
        self.ssh_root("poweroff")
        self.wait()
        os.rename(img_tmp, img)
        return 0

if __name__ == "__main__":
    sys.exit(basevm.main(CentosVM))
