From nobody Thu Nov 13 23:27:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1583248168; cv=none; d=zohomail.com; s=zohoarc; b=iG/wZVU40lDdiNHd5Gk5S1O9nM/f6LaUVk286ByOBYQ4kY/+Zd8D+YgLVrXL/t0Nrxxp541YlfGk/A2Zp5AfKkipiuasLExe3bNTUiObqvw6JdIMuAkK3DraKyvfj0iCYSr9j+dECmUCcB2NyAo8LAraLBzUC6fONXoShQ4rKKQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583248168; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ijdyySbr5Pr5tu/6iL3NJ3hKubBXGURsFPuH6qfE7XM=; b=Bizz2z/whkNVROcARkND9KbC1XYqJYW/83SfXN2bUF/5BCuldFTwbkzLSNJjCya08VcsKWl11y2+Z+8Mzkmh5LwS4xjLm3BlzgV2pl1O4KQL2AqNyodF4+I47h9Exw0WNNd27uXljPXf6cyBJOuJPBxR0qN3gys9543fRupHhLk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583248168089180.93035500524456; Tue, 3 Mar 2020 07:09:28 -0800 (PST) Received: from localhost ([::1]:48700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j99Ak-0000Oq-Tq for importer@patchew.org; Tue, 03 Mar 2020 10:09:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42649) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9981-0003CD-4T for qemu-devel@nongnu.org; Tue, 03 Mar 2020 10:06:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j997z-0001lS-GL for qemu-devel@nongnu.org; Tue, 03 Mar 2020 10:06:37 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:40411) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j997z-0001l8-9L for qemu-devel@nongnu.org; Tue, 03 Mar 2020 10:06:35 -0500 Received: by mail-wr1-x432.google.com with SMTP id r17so4770281wrj.7 for ; Tue, 03 Mar 2020 07:06:35 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id o9sm35544399wrw.20.2020.03.03.07.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 07:06:29 -0800 (PST) Received: from zen.home.arpa (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5B66A1FF92; Tue, 3 Mar 2020 15:06:23 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ijdyySbr5Pr5tu/6iL3NJ3hKubBXGURsFPuH6qfE7XM=; b=qj+3xr+fsB+VVYDJp7yguPBDXZ2CPns1k4bvMqkNBRasJKC7XtLejnvjCZ6L5yADVe ARsEp53j51XANsj49YT80pXLpfOb7EpARfV7Te+CjElR1DHdmj9+guuMksifTgAeD6Rm EZEWmyCjDekMkWz4dzWy9BoRwSqp9cZVaJQu+0ylx3z2RA8q3cqQEkKJYo/nAUUS7UTG wPkp2SNqlQuy/Vlb39BkiTpLyAOyjFNRCqF+GJFy1PcENSzKCnOCt6UA0dApn67IBwds rla3smyMlF3K7FewUGOqcLC+Pc+DR+6qbvvhzRz5uoes3mwWF+5hjb6MWKU2bjUxzSw3 R3Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ijdyySbr5Pr5tu/6iL3NJ3hKubBXGURsFPuH6qfE7XM=; b=UDnMaG4J5CZhL6Xwij73UYZCWXQZqcJc/eEGyDkREzljU8N/u9sJlATKJt67eFC35d 9+DHtZWHqqxarndJUG3dy1wn4LAPlMgLk3pjkKIfRdOhzH1l7sX8HUzHeyNrJGQsJX68 L4Eu+GYGHhbUQvC/WL9/Wn7+jyZ/H+ukrWcUv5wxy5ad4Q0bRnp0//kWFbYRtYQQ2i0W Z1Tix2zCTq/+71qTlR5Mi8WJVzPr9945K4YQm9ZLJPP5BaDKWvSDI/+N/K06W3z8j5k+ bbcwi5zo2GnRfmGBMNfkmtJIJeW6DDqBiKtsv/XP6k5pmsDo7pH9vPwscAj6MSQrCBhn hnfQ== X-Gm-Message-State: ANhLgQ3LjiYNnzZcsNgE1xfwX2Z8hPPFReNHj9N9UTMYhd2Bqvubm0FJ y6cWjG9nccEjAXZwKiY/zMGIwg== X-Google-Smtp-Source: ADFU+vsKSDK8ONYTDJmdardp5wKG26yZvWUsrKY8G2xq9SW5agFZ3ygryZ3xd4JDpmtj7hU4+Dd4PA== X-Received: by 2002:adf:a114:: with SMTP id o20mr5834864wro.7.1583247994125; Tue, 03 Mar 2020 07:06:34 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 5/9] tests/vm: Added gen_cloud_init_iso() to basevm.py Date: Tue, 3 Mar 2020 15:06:18 +0000 Message-Id: <20200303150622.20133-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200303150622.20133-1-alex.bennee@linaro.org> References: <20200303150622.20133-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Puhov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Robert Foley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Robert Foley This method was located in both centos and ubuntu.i386. Signed-off-by: Robert Foley Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Puhov Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200219163537.22098-6-robert.foley@linaro.org> --- tests/vm/basevm.py | 40 ++++++++++++++++++++++++++++++++++++++++ tests/vm/centos | 33 +-------------------------------- tests/vm/ubuntu.i386 | 37 +------------------------------------ 3 files changed, 42 insertions(+), 68 deletions(-) diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 7f268922685..8400b0e07f6 100644 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -345,6 +345,46 @@ class BaseVM(object): def qmp(self, *args, **kwargs): return self._guest.qmp(*args, **kwargs) =20 + def gen_cloud_init_iso(self): + cidir =3D self._tmpdir + mdata =3D open(os.path.join(cidir, "meta-data"), "w") + name =3D self.name.replace(".","-") + mdata.writelines(["instance-id: {}-vm-0\n".format(name), + "local-hostname: {}-guest\n".format(name)]) + mdata.close() + udata =3D open(os.path.join(cidir, "user-data"), "w") + print("guest user:pw {}:{}".format(self._config['guest_user'], + self._config['guest_pass'])) + udata.writelines(["#cloud-config\n", + "chpasswd:\n", + " list: |\n", + " root:%s\n" % self._config['root_pass'], + " %s:%s\n" % (self._config['guest_user'], + self._config['guest_pass']), + " expire: False\n", + "users:\n", + " - name: %s\n" % self._config['guest_user'], + " sudo: ALL=3D(ALL) NOPASSWD:ALL\n", + " ssh-authorized-keys:\n", + " - %s\n" % self._config['ssh_pub_key'], + " - name: root\n", + " ssh-authorized-keys:\n", + " - %s\n" % self._config['ssh_pub_key'], + "locale: en_US.UTF-8\n"]) + proxy =3D os.environ.get("http_proxy") + if not proxy is None: + udata.writelines(["apt:\n", + " proxy: %s" % proxy]) + udata.close() + subprocess.check_call(["genisoimage", "-output", "cloud-init.iso", + "-volid", "cidata", "-joliet", "-rock", + "user-data", "meta-data"], + cwd=3Dcidir, + stdin=3Dself._devnull, stdout=3Dself._stdou= t, + stderr=3Dself._stdout) + + return os.path.join(cidir, "cloud-init.iso") + def parse_args(vmcls): =20 def get_default_jobs(): diff --git a/tests/vm/centos b/tests/vm/centos index a41ff109eb5..0ad4ecf4190 100755 --- a/tests/vm/centos +++ b/tests/vm/centos @@ -31,37 +31,6 @@ class CentosVM(basevm.BaseVM): make docker-test-mingw@fedora {verbose} J=3D{jobs} NETWORK=3D1; """ =20 - def _gen_cloud_init_iso(self): - cidir =3D self._tmpdir - mdata =3D open(os.path.join(cidir, "meta-data"), "w") - mdata.writelines(["instance-id: centos-vm-0\n", - "local-hostname: centos-guest\n"]) - mdata.close() - udata =3D open(os.path.join(cidir, "user-data"), "w") - udata.writelines(["#cloud-config\n", - "chpasswd:\n", - " list: |\n", - " root:%s\n" % self.ROOT_PASS, - " %s:%s\n" % (self.GUEST_USER, self.GUEST_PAS= S), - " expire: False\n", - "users:\n", - " - name: %s\n" % self.GUEST_USER, - " sudo: ALL=3D(ALL) NOPASSWD:ALL\n", - " ssh-authorized-keys:\n", - " - %s\n" % basevm.SSH_PUB_KEY, - " - name: root\n", - " ssh-authorized-keys:\n", - " - %s\n" % basevm.SSH_PUB_KEY, - "locale: en_US.UTF-8\n"]) - udata.close() - subprocess.check_call(["genisoimage", "-output", "cloud-init.iso", - "-volid", "cidata", "-joliet", "-rock", - "user-data", "meta-data"], - cwd=3Dcidir, - stdin=3Dself._devnull, stdout=3Dself._stdou= t, - stderr=3Dself._stdout) - return os.path.join(cidir, "cloud-init.iso") - def build_image(self, img): cimg =3D self._download_with_cache("https://cloud.centos.org/cento= s/7/images/CentOS-7-x86_64-GenericCloud-1802.qcow2.xz") img_tmp =3D img + ".tmp" @@ -69,7 +38,7 @@ class CentosVM(basevm.BaseVM): 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 =3D ["-cdrom", self._gen_cloud_init_= iso()]) + self.boot(img_tmp, extra_args =3D ["-cdrom", self.gen_cloud_init_i= so()]) self.wait_ssh() self.ssh_root_check("touch /etc/cloud/cloud-init.disabled") self.ssh_root_check("yum update -y") diff --git a/tests/vm/ubuntu.i386 b/tests/vm/ubuntu.i386 index 48e9cb1ad3d..3266038fbde 100755 --- a/tests/vm/ubuntu.i386 +++ b/tests/vm/ubuntu.i386 @@ -29,41 +29,6 @@ class UbuntuX86VM(basevm.BaseVM): make --output-sync {target} -j{jobs} {verbose}; """ =20 - def _gen_cloud_init_iso(self): - cidir =3D self._tmpdir - mdata =3D open(os.path.join(cidir, "meta-data"), "w") - mdata.writelines(["instance-id: ubuntu-vm-0\n", - "local-hostname: ubuntu-guest\n"]) - mdata.close() - udata =3D open(os.path.join(cidir, "user-data"), "w") - udata.writelines(["#cloud-config\n", - "chpasswd:\n", - " list: |\n", - " root:%s\n" % self.ROOT_PASS, - " %s:%s\n" % (self.GUEST_USER, self.GUEST_PAS= S), - " expire: False\n", - "users:\n", - " - name: %s\n" % self.GUEST_USER, - " sudo: ALL=3D(ALL) NOPASSWD:ALL\n", - " ssh-authorized-keys:\n", - " - %s\n" % basevm.SSH_PUB_KEY, - " - name: root\n", - " ssh-authorized-keys:\n", - " - %s\n" % basevm.SSH_PUB_KEY, - "locale: en_US.UTF-8\n"]) - proxy =3D os.environ.get("http_proxy") - if not proxy is None: - udata.writelines(["apt:\n", - " proxy: %s" % proxy]) - udata.close() - subprocess.check_call(["genisoimage", "-output", "cloud-init.iso", - "-volid", "cidata", "-joliet", "-rock", - "user-data", "meta-data"], - cwd=3Dcidir, - stdin=3Dself._devnull, stdout=3Dself._stdou= t, - stderr=3Dself._stdout) - return os.path.join(cidir, "cloud-init.iso") - def build_image(self, img): cimg =3D self._download_with_cache( "https://cloud-images.ubuntu.com/releases/bionic/release-20191= 114/ubuntu-18.04-server-cloudimg-i386.img", @@ -71,7 +36,7 @@ class UbuntuX86VM(basevm.BaseVM): img_tmp =3D img + ".tmp" subprocess.check_call(["cp", "-f", cimg, img_tmp]) self.exec_qemu_img("resize", img_tmp, "50G") - self.boot(img_tmp, extra_args =3D ["-cdrom", self._gen_cloud_init_= iso()]) + self.boot(img_tmp, extra_args =3D ["-cdrom", self.gen_cloud_init_i= so()]) self.wait_ssh() self.ssh_root_check("touch /etc/cloud/cloud-init.disabled") self.ssh_root_check("apt-get update") --=20 2.20.1