From 73639ee4f25813155da8366fa440f47691538689 Mon Sep 17 00:00:00 2001 From: Michael Polenchuk Date: Thu, 19 Sep 2019 15:09:14 +0400 Subject: [PATCH] [ironic] Support override of agent image Make bootstrap script structured to be able to override version of agent or even image source itself. Change-Id: Ibdba2222176833b5a593bfc1619e2a0913b6fac1 --- ironic/templates/bin/_bootstrap.sh.tpl | 17 +++++++++++ ironic/values.yaml | 40 +++++++------------------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/ironic/templates/bin/_bootstrap.sh.tpl b/ironic/templates/bin/_bootstrap.sh.tpl index 403d25bd91..6beeb5d87f 100644 --- a/ironic/templates/bin/_bootstrap.sh.tpl +++ b/ironic/templates/bin/_bootstrap.sh.tpl @@ -17,4 +17,21 @@ limitations under the License. */}} set -ex + +{{ $source_base := .Values.bootstrap.image.source_base | default "" }} +{{ range $name, $opts := .Values.bootstrap.image.structured }} +{{ $source := empty $source_base | ternary $opts.source (printf "%s/%s" $source_base $opts.source) }} +openstack image show {{ $name | quote }} -fvalue -cid || ( + IMAGE_LOC=$(mktemp) + curl --fail -sSL {{ $source }} -o ${IMAGE_LOC} + openstack image create {{ $name | quote }} \ + --disk-format {{ $opts.disk_format }} \ + --container-format {{ $opts.container_format }} \ + --file ${IMAGE_LOC} \ + {{ if $opts.properties -}} {{ range $k, $v := $opts.properties }}--property {{$k}}={{$v}} {{ end }}{{ end -}} \ + --{{ $opts.visibility | default "public" }} + rm -f ${IMAGE_LOC} +) +{{ else }} {{ .Values.bootstrap.image.script | default "echo 'Not Enabled'" }} +{{ end }} diff --git a/ironic/values.yaml b/ironic/values.yaml index d9c4d840ef..7f5f9871d3 100644 --- a/ironic/values.yaml +++ b/ironic/values.yaml @@ -228,35 +228,17 @@ bootstrap: openstack: enabled: true ks_user: ironic - script: | - RELEASE="ocata" - IMAGE_URL_BASE="http://tarballs.openstack.org/ironic-python-agent/tinyipa/files" - IMAGE_INITRAMFS="ironic-agent.initramfs" - IMAGE_INITRAMFS_URL="${IMAGE_URL_BASE}/tinyipa-stable-${RELEASE}.gz" - IMAGE_KERNEL="ironic-agent.kernel" - IMAGE_KERNEL_URL="${IMAGE_URL_BASE}/tinyipa-stable-${RELEASE}.vmlinuz" - openstack image show ${IMAGE_INITRAMFS} || ( - IMAGE_LOC=$(mktemp) - curl -L ${IMAGE_INITRAMFS_URL} -o ${IMAGE_LOC} - openstack image create \ - --file ${IMAGE_LOC} \ - --disk-format ari \ - --container-format ari \ - --public \ - ${IMAGE_INITRAMFS} - rm -f ${IMAGE_LOC} - ) - openstack image show ${IMAGE_KERNEL} || ( - IMAGE_LOC=$(mktemp) - curl -L ${IMAGE_KERNEL_URL} -o ${IMAGE_LOC} - openstack image create \ - --file ${IMAGE_LOC} \ - --disk-format aki \ - --container-format aki \ - --public \ - ${IMAGE_KERNEL} - rm -f ${IMAGE_LOC} - ) + # NOTE: if source_base is null the source will be used as is + source_base: http://tarballs.openstack.org/ironic-python-agent/tinyipa/files + structured: + ironic-agent.initramfs: + source: tinyipa-stable-ocata.gz + disk_format: ari + container_format: ari + ironic-agent.kernel: + source: tinyipa-stable-ocata.vmlinuz + disk_format: aki + container_format: aki network: enabled: true openstack: