From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8363037E for ; Thu, 7 Mar 2024 00:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709770469; cv=none; b=GJtnksRavhMAFQVbCRgqFg5V6fVPymet5rFrWCOQQ8IIDdOlGNJcUStc+x5ldh3TldnS2R5qvnPTKSGhO9bUFR5JwVI3X8uu788nbRuTvV7eAVP7WKlUCnJQph/BQEGcEgHI8ie5ZNoqIEpTA7wzAiDNYQyfrX5cqM4gSjPtKn4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709770469; c=relaxed/simple; bh=OPS3cGZr6r06M2ulvoNV37/1FBGOKbe65dtT4ZRuQtk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JN9TdKerXwmTIDg8+sCSvpwtRh1ksEnpuh2yOQy482Y7PJceAQ4ZkeyFqzZ9ew8jAK1/Br2MkPHQ5WdkZcrX6djhbBAF2f2PqV0YUh9/D1vn3ZeJhbtyM2dfQdUpDtP0XFmjtiwx0VhmbkaLZcOshhrUQKwBHiJzQWO492fehLQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=dlovN0OE; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="dlovN0OE" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=NNu9x++EjmgHSnikw5XJQsYUYtsd9Jpze2x3TAV4LPA=; b=dlovN0OE0e8062kn7AWq0t/pWv g+XjOAn/k1jUKRnTj46ifYyA0faJRe2RovNFmTBUvLM+piKVJDxiRFLjqBwMBMrnp3sXtc/CisSMt Wa7REJW1dZIysfYuONEmPUQUkqmnD1agvKhde0u1wsvugOS1jrv6vQDIsA6J3R7k/ei5qd4flucgG joYRaYMeczPu77+PQLJ9rm40JoeSBPsAjB/B0464/LToNCBQuEoqY6OLeI0xVb9KR/waKt7rOvBWK nOCxf7qau9NPrnyldT48yUFRmTxyoaKw3bapvMIsOA6aHIAHQmJAKnzqeW4aMRCbGrvRWem9HNEYU GLVO5RBg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ri1P1-00000002N5d-0UkF; Thu, 07 Mar 2024 00:14:27 +0000 From: Luis Chamberlain To: kdevops@lists.linux.dev Cc: Luis Chamberlain Subject: [PATCH 4/5] gen_nodes: move drive generation for guestfs to macros Date: Wed, 6 Mar 2024 16:14:25 -0800 Message-ID: <20240307001426.565390-5-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240307001426.565390-1-mcgrof@kernel.org> References: <20240307001426.565390-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain Make the guestfs template easier to read by using macros for the different types of drive generation methods. This will also let us scale this to more easily support other architectures with as much shared code as possible later. Signed-off-by: Luis Chamberlain --- playbooks/roles/gen_nodes/templates/drives.j2 | 76 +++++++++++++++++++ .../gen_nodes/templates/guestfs_q35.j2.xml | 59 +++++++------- 2 files changed, 104 insertions(+), 31 deletions(-) create mode 100644 playbooks/roles/gen_nodes/templates/drives.j2 diff --git a/playbooks/roles/gen_nodes/templates/drives.j2 b/playbooks/roles/gen_nodes/templates/drives.j2 new file mode 100644 index 00000000..4878cff9 --- /dev/null +++ b/playbooks/roles/gen_nodes/templates/drives.j2 @@ -0,0 +1,76 @@ +{# +This is a collection of macros to generate extra drives used by guestfs, +the drives can vary by type, so we have one macro by type of drive. +#} +{%- macro gen_drive_ide(num_drives, + kdevops_storage_pool_path, + hostname, + libvirt_extra_drive_format, + libvirt_extra_storage_aio_mode, + libvirt_extra_storage_aio_cache_mode) -%} + +{% for n in range(0,num_drives) %} + + + + + +{% endfor %} + +{%- endmacro -%} +{%- macro gen_drive_virtio(num_drives, + kdevops_storage_pool_path, + hostname, + libvirt_extra_drive_format, + libvirt_extra_storage_aio_mode, + libvirt_extra_storage_aio_cache_mode, + libvirt_extra_storage_virtio_logical_block_size, + libvirt_extra_storage_virtio_physical_block_size) -%} + +{% for n in range(0,num_drives) %} + + + + + + + + + +{% endfor %} + +{%- endmacro -%} +{%- macro gen_drive_nvme(num_drives, + kdevops_storage_pool_path, + hostname, + libvirt_extra_drive_format, + libvirt_extra_storage_aio_mode, + libvirt_extra_storage_aio_cache_mode, + libvirt_extra_storage_nvme_logical_block_size) -%} + +{% for n in range(0,num_drives) %} + + + + + + + + + +{% endfor %} + +{%- endmacro -%} +{% macro gen_9p_mount(bootlinux_9p_driver, + bootlinux_9p_fsdev, + bootlinux_9p_host_path, + bootlinux_9p_mount_tag, + bootlinux_9p_security_model, + pcie_addr) %} + + + + + + +{% endmacro %} diff --git a/playbooks/roles/gen_nodes/templates/guestfs_q35.j2.xml b/playbooks/roles/gen_nodes/templates/guestfs_q35.j2.xml index 266ced32..16364ea2 100644 --- a/playbooks/roles/gen_nodes/templates/guestfs_q35.j2.xml +++ b/playbooks/roles/gen_nodes/templates/guestfs_q35.j2.xml @@ -1,3 +1,4 @@ +{% import './templates/drives.j2' as drives %} {{ hostname }} {{ libvirt_mem_mb }} @@ -178,41 +179,37 @@ {% if libvirt_extra_storage_drive_ide %} -{% for n in range(0,4) %} - - - - -{% endfor %} +{{ drives.gen_drive_ide(4, + kdevops_storage_pool_path, + hostname, + libvirt_extra_drive_format, + libvirt_extra_storage_aio_mode, + libvirt_extra_storage_aio_cache_mode) }} {% elif libvirt_extra_storage_drive_virtio %} -{% for n in range(0,4) %} - - - - - - - - -{% endfor %} +{{ drives.gen_drive_virtio(4, + kdevops_storage_pool_path, + hostname, + libvirt_extra_drive_format, + libvirt_extra_storage_aio_mode, + libvirt_extra_storage_aio_cache_mode, + libvirt_extra_storage_virtio_logical_block_size, + libvirt_extra_storage_virtio_physical_block_size) }} {% elif libvirt_extra_storage_drive_nvme %} -{% for n in range(0,4) %} - - - - - - - - -{% endfor %} +{{ drives.gen_drive_nvme(4, + kdevops_storage_pool_path, + hostname, + libvirt_extra_drive_format, + libvirt_extra_storage_aio_mode, + libvirt_extra_storage_aio_cache_mode, + libvirt_extra_storage_nvme_logical_block_size) }} {% endif %} {% if bootlinux_9p %} - - - - + {{ drives.gen_9p_mount(bootlinux_9p_driver, + bootlinux_9p_fsdev, + bootlinux_9p_host_path, + bootlinux_9p_mount_tag, + bootlinux_9p_security_model, + 10) }} {% endif %} - -- 2.43.0