From 468f1466e520bba10cacb1fad3d2d24b80949b9f Mon Sep 17 00:00:00 2001 From: Saeed Padari Date: Mon, 4 Aug 2025 01:38:50 +0330 Subject: [PATCH] Add extra spec or property for nova bootstrap script Change-Id: I69bc1e0a428b8ed012bea33161c88633aedf024b Signed-off-by: Saeed Padari --- nova/templates/bin/_bootstrap.sh.tpl | 36 ++++++++++++------- releasenotes/notes/nova-b2ce6bcc83029d1b.yaml | 7 ++++ 2 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 releasenotes/notes/nova-b2ce6bcc83029d1b.yaml diff --git a/nova/templates/bin/_bootstrap.sh.tpl b/nova/templates/bin/_bootstrap.sh.tpl index 9cb48b1270..ff1421d849 100644 --- a/nova/templates/bin/_bootstrap.sh.tpl +++ b/nova/templates/bin/_bootstrap.sh.tpl @@ -18,20 +18,30 @@ set -ex export HOME=/tmp {{ if .Values.bootstrap.structured.flavors.enabled }} -{{ range .Values.bootstrap.structured.flavors.options }} -# NOTE(aostapenko) Since Wallaby with switch of osc to sdk '--id auto' is no -# longer treated specially. Though the same behavior can be achieved w/o specifying -#--id flag. -# https://review.opendev.org/c/openstack/python-openstackclient/+/750151 +{{- range $i, $params := .Values.bootstrap.structured.flavors.options }} { - openstack flavor show {{ .name }} || \ - openstack flavor create {{ .name }} \ -{{ if .id }} \ - --id {{ .id }} \ -{{ end }} \ - --ram {{ .ram }} \ - --disk {{ .disk }} \ - --vcpus {{ .vcpus }} +openstack flavor show {{ $params.name }} || \ + openstack flavor create \ + {{- range $key, $val := $params }} + {{- if ne $key "name" }} + {{- if eq $key "extra_specs" }} + {{- if kindIs "slice" $val }} + {{- range $idx, $spec := $val }} + --property {{ $spec }} \ + {{- end }} + {{- end }} + {{- else if eq $key "is_public" }} + {{- if $val }} + --public \ + {{- else if not $val }} + --private \ + {{- end }} + {{- else }} + --{{ $key }} {{ $val }} \ + {{- end }} + {{- end }} + {{- end }} + {{ $params.name }} } & {{ end }} wait diff --git a/releasenotes/notes/nova-b2ce6bcc83029d1b.yaml b/releasenotes/notes/nova-b2ce6bcc83029d1b.yaml new file mode 100644 index 0000000000..cf822de1a5 --- /dev/null +++ b/releasenotes/notes/nova-b2ce6bcc83029d1b.yaml @@ -0,0 +1,7 @@ +--- +nova: + - | + Refactored the flavor creation logic in the nova bootstrap script to simplify + and generalize flavor definitions using dynamic key/value iteration. This makes + the chart more maintainable and flexible for various flavor configurations. +...