From nobody Thu Nov 13 23:21:06 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=1583316332; cv=none; d=zohomail.com; s=zohoarc; b=NGLsgPLEQ/XcdDXxKErbPQhVwDjdzvuvGYTGuJYAW28RtfUA/LMGYs+XIuZAaLSZec7ZXVdXwwVF01DBde51+l4T0eLhyTo4Xv81qYe3nfDUdAnl3zwm/zEeTyNA1p8z3GzQkEcTOWYZ2zgO/J2l8x/xIa+tfR14cGLlxcO2rjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583316332; 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=YDS2krmEOwHmyFHZND8chhdsDOBM1s0eAUxp7rCjnHk=; b=WMjRzBKxNzEdB1vQhDmbUc9VX1XIPrxYvd/bzfANuq9Jh+VLt2fNMsHD5xyjDVZxFAREqnWQE6PVwQfIZSqf1b48lT/jAZAUc6rT/8YU2CdVT4CbpHLMU/bLPwonsLRSYJuwHGLHZiBFkMl8zf/cZIF7HHjfgjSMpNNeuY//DYE= 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 1583316332331308.37585420727555; Wed, 4 Mar 2020 02:05:32 -0800 (PST) Received: from localhost ([::1]:60016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9QuA-0003kh-KD for importer@patchew.org; Wed, 04 Mar 2020 05:05:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41707) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Qqs-00070O-IZ for qemu-devel@nongnu.org; Wed, 04 Mar 2020 05:02:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9Qqq-0000cd-Ps for qemu-devel@nongnu.org; Wed, 04 Mar 2020 05:02:06 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:54337) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j9Qqq-0000aD-Da for qemu-devel@nongnu.org; Wed, 04 Mar 2020 05:02:04 -0500 Received: by mail-wm1-x329.google.com with SMTP id i9so1281265wml.4 for ; Wed, 04 Mar 2020 02:02:04 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h16sm3318625wmd.10.2020.03.04.02.01.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 02:02:00 -0800 (PST) Received: from zen.home.arpa (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 572AF1FF92; Wed, 4 Mar 2020 10:01:55 +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=YDS2krmEOwHmyFHZND8chhdsDOBM1s0eAUxp7rCjnHk=; b=gi7t4uivDk4XaBJ8/Opj2+UHYexHhEaaOtGLWu6aNoNxguNL1I1ctEGcq6mjuejGgZ LOMmNLKJ5FZ4TEN6cGCuePL/JGF4fztlQiMkie2j5ypabAEBCwgC77zLNX7hM4lRvFZ+ kro9bh1nfzVliF3f4AOf6ZkvpxM7QVCR4DdwX+yGxCwpsF7xkx4V16A4aSSEqb7/Doyj tp7trLm7M8Pi8J3ezazifJSMB9oBqfoaBF7ezVKLFPsXooKfhczg7h2iZ9BLysnKzxZ3 zelqTlCxGsg9zX5YMcrDWyoG1bwdW5jQXBHeYQUfXy49QSxivfX6/Mup1PaRh8MYlevd +RLA== 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=YDS2krmEOwHmyFHZND8chhdsDOBM1s0eAUxp7rCjnHk=; b=H2c1n87KnXGwDa8m6ueQCaGpU2BKex7mDCo+VW9QnGPQECxlvpFOlta7azioFoq1Xa /MZQtw1DCTFyBo0eAZWqewsNADjXXx7GNJK5+HxPm7j8EEfebBKNAomjXUwfx9H+8l78 PEKxNyHv3UW1zVBapxjkqrgZKO/SWZ/US+TnoaKoCj/ujduHFpP1OJyQHEaOnMVy6C1q z+Q46efGxwiSY0ee0rKtV5ywmGcGAxMB1WAwRqCYKjAEKAKfOZVJg2998gUsM6JwqqIK t4nnqHLDESW+TciIhnEjNpAi6QOjm0kRxe7BulCUtSuDIjl4sfM1m7ed/J4TU2nLfXvA nz1w== X-Gm-Message-State: ANhLgQ2GTp2qXY0VHaNPg7WPgrlkmXiw1aVDMVUVYyF248Yb4nKp8rOs p2ITu8nzHlJcTRR4/X4R9n2NcuaRmZs= X-Google-Smtp-Source: ADFU+vv5GwxIoo9Kc7vi+MXPP9koJtc3BXb99d27YwSA+ppE8wCyCCOEFrJnaWUPoZnqNXGjDeiOSg== X-Received: by 2002:a7b:cb03:: with SMTP id u3mr2811611wmj.41.1583316123360; Wed, 04 Mar 2020 02:02:03 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 5/9] tests/vm: Added gen_cloud_init_iso() to basevm.py Date: Wed, 4 Mar 2020 10:01:50 +0000 Message-Id: <20200304100154.14822-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200304100154.14822-1-alex.bennee@linaro.org> References: <20200304100154.14822-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::329 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 , Robert Foley , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Peter Puhov , =?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> Message-Id: <20200303150622.20133-6-alex.bennee@linaro.org> 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