qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>, Peter Puhov <peter.puhov@linaro.org>,
	Robert Foley <robert.foley@linaro.org>
Subject: Re: [PATCH v1 05/10] tests/vm: Added gen_cloud_init_iso() to basevm.py
Date: Mon, 2 Mar 2020 19:32:54 +0100	[thread overview]
Message-ID: <bf7ccc07-262b-51d5-afa0-4cc0b8d1d80d@redhat.com> (raw)
In-Reply-To: <20200302181907.32110-6-alex.bennee@linaro.org>

On 3/2/20 7:19 PM, Alex Bennée wrote:
> From: Robert Foley <robert.foley@linaro.org>
> 
> This method was located in both centos and ubuntu.i386.
> 
> Signed-off-by: Robert Foley <robert.foley@linaro.org>
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> Reviewed-by: Peter Puhov <peter.puhov@linaro.org>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> 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)
>   
> +    def gen_cloud_init_iso(self):
> +        cidir = self._tmpdir
> +        mdata = open(os.path.join(cidir, "meta-data"), "w")
> +        name = self.name.replace(".","-")
> +        mdata.writelines(["instance-id: {}-vm-0\n".format(name),
> +                          "local-hostname: {}-guest\n".format(name)])
> +        mdata.close()
> +        udata = 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=(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 = 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=cidir,
> +                               stdin=self._devnull, stdout=self._stdout,
> +                               stderr=self._stdout)
> +
> +        return os.path.join(cidir, "cloud-init.iso")
> +
>   def parse_args(vmcls):
>   
>       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={jobs} NETWORK=1;
>       """
>   
> -    def _gen_cloud_init_iso(self):
> -        cidir = self._tmpdir
> -        mdata = open(os.path.join(cidir, "meta-data"), "w")
> -        mdata.writelines(["instance-id: centos-vm-0\n",
> -                          "local-hostname: centos-guest\n"])
> -        mdata.close()
> -        udata = 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_PASS),
> -                          "  expire: False\n",
> -                          "users:\n",
> -                          "  - name: %s\n" % self.GUEST_USER,
> -                          "    sudo: ALL=(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=cidir,
> -                               stdin=self._devnull, stdout=self._stdout,
> -                               stderr=self._stdout)
> -        return os.path.join(cidir, "cloud-init.iso")
> -
>       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"
> @@ -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 = ["-cdrom", self._gen_cloud_init_iso()])
> +        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")
> 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};
>       """
>   
> -    def _gen_cloud_init_iso(self):
> -        cidir = self._tmpdir
> -        mdata = open(os.path.join(cidir, "meta-data"), "w")
> -        mdata.writelines(["instance-id: ubuntu-vm-0\n",
> -                          "local-hostname: ubuntu-guest\n"])
> -        mdata.close()
> -        udata = 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_PASS),
> -                          "  expire: False\n",
> -                          "users:\n",
> -                          "  - name: %s\n" % self.GUEST_USER,
> -                          "    sudo: ALL=(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 = 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=cidir,
> -                               stdin=self._devnull, stdout=self._stdout,
> -                               stderr=self._stdout)
> -        return os.path.join(cidir, "cloud-init.iso")
> -
>       def build_image(self, img):
>           cimg = self._download_with_cache(
>               "https://cloud-images.ubuntu.com/releases/bionic/release-20191114/ubuntu-18.04-server-cloudimg-i386.img",
> @@ -71,7 +36,7 @@ class UbuntuX86VM(basevm.BaseVM):
>           img_tmp = img + ".tmp"
>           subprocess.check_call(["cp", "-f", cimg, img_tmp])
>           self.exec_qemu_img("resize", img_tmp, "50G")
> -        self.boot(img_tmp, extra_args = ["-cdrom", self._gen_cloud_init_iso()])
> +        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("apt-get update")
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



  reply	other threads:[~2020-03-02 18:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02 18:18 [PATCH v1 00/10] testing/next updates (tweaks and re-greening) Alex Bennée
2020-03-02 18:18 ` [PATCH v1 01/10] tests/vm: use $(PYTHON) consistently Alex Bennée
2020-03-02 18:29   ` Philippe Mathieu-Daudé
2020-03-02 18:41     ` Alex Bennée
2020-03-02 18:50       ` Philippe Mathieu-Daudé
2020-03-02 18:18 ` [PATCH v1 02/10] tests/vm: Debug mode shows ssh output Alex Bennée
2020-03-02 18:30   ` Philippe Mathieu-Daudé
2020-03-02 18:19 ` [PATCH v1 03/10] tests/vm: increased max timeout for vm boot Alex Bennée
2020-03-02 18:32   ` Philippe Mathieu-Daudé
2020-03-02 18:19 ` [PATCH v1 04/10] tests/vm: give wait_ssh() option to wait for root Alex Bennée
2020-03-02 18:19 ` [PATCH v1 05/10] tests/vm: Added gen_cloud_init_iso() to basevm.py Alex Bennée
2020-03-02 18:32   ` Philippe Mathieu-Daudé [this message]
2020-03-02 18:19 ` [PATCH v1 06/10] travis: enable tools build on OS X Alex Bennée
2020-03-02 18:46   ` Philippe Mathieu-Daudé
2020-03-02 18:19 ` [PATCH v1 07/10] configure: fix check for libzstd Alex Bennée
2020-03-02 22:02   ` Alex Bennée
2020-03-05  9:43     ` Juan Quintela
2020-03-05 10:09       ` Alex Bennée
2020-03-05 10:28         ` Juan Quintela
2020-03-02 18:19 ` [PATCH v1 08/10] configure: detect and report genisoimage Alex Bennée
2020-03-02 18:25   ` Philippe Mathieu-Daudé
2020-03-02 18:19 ` [PATCH v1 09/10] tests/acceptance: move @skipUnless decoration to test itself Alex Bennée
2020-03-02 18:19 ` [PATCH v1 10/10] travis.yml: install python3 numpy and opencv libraries Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bf7ccc07-262b-51d5-afa0-4cc0b8d1d80d@redhat.com \
    --to=philmd@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=fam@euphon.net \
    --cc=peter.puhov@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=robert.foley@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).