From 501cf14342dd5519f064bca2ec999d204c00bc67 Mon Sep 17 00:00:00 2001 From: Jimmy McCrory Date: Thu, 14 Mar 2024 11:28:45 -0700 Subject: [PATCH] Ensure nova_device_spec is templated as JSON string When the nova_device_spec variable is provided as either a string or a mapping, ensure that it's templated as a JSON string. Also handle either strings or mappings within nova_device_spec if it's provided as a list. Closes-Bug: 2057961 Change-Id: I7041a19547af580408ff704578cb8f12d37da1ae --- templates/nova.conf.j2 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/templates/nova.conf.j2 b/templates/nova.conf.j2 index 06d04729..5f9030dd 100644 --- a/templates/nova.conf.j2 +++ b/templates/nova.conf.j2 @@ -342,11 +342,17 @@ device_addresses = {{ (record.address is string) | ternary(record.address, recor [pci] {% if nova_device_spec %} # PCI devices available to VMs -{% if nova_device_spec is mapping %} +{% if nova_device_spec is string %} device_spec = {{ nova_device_spec }} +{% elif nova_device_spec is mapping %} +device_spec = {{ nova_device_spec | to_json }} {% else %} {% for item in nova_device_spec %} +{% if item is string %} device_spec = {{ item }} +{% elif item is mapping %} +device_spec = {{ item | to_json }} +{% endif %} {% endfor %} {% endif %} {% endif %}