[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
This commit is contained in:
Michael Polenchuk 2019-09-19 15:09:14 +04:00
parent a6ccab5270
commit 73639ee4f2
2 changed files with 28 additions and 29 deletions

View File

@ -17,4 +17,21 @@ limitations under the License.
*/}} */}}
set -ex 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'" }} {{ .Values.bootstrap.image.script | default "echo 'Not Enabled'" }}
{{ end }}

View File

@ -228,35 +228,17 @@ bootstrap:
openstack: openstack:
enabled: true enabled: true
ks_user: ironic ks_user: ironic
script: | # NOTE: if source_base is null the source will be used as is
RELEASE="ocata" source_base: http://tarballs.openstack.org/ironic-python-agent/tinyipa/files
IMAGE_URL_BASE="http://tarballs.openstack.org/ironic-python-agent/tinyipa/files" structured:
IMAGE_INITRAMFS="ironic-agent.initramfs" ironic-agent.initramfs:
IMAGE_INITRAMFS_URL="${IMAGE_URL_BASE}/tinyipa-stable-${RELEASE}.gz" source: tinyipa-stable-ocata.gz
IMAGE_KERNEL="ironic-agent.kernel" disk_format: ari
IMAGE_KERNEL_URL="${IMAGE_URL_BASE}/tinyipa-stable-${RELEASE}.vmlinuz" container_format: ari
openstack image show ${IMAGE_INITRAMFS} || ( ironic-agent.kernel:
IMAGE_LOC=$(mktemp) source: tinyipa-stable-ocata.vmlinuz
curl -L ${IMAGE_INITRAMFS_URL} -o ${IMAGE_LOC} disk_format: aki
openstack image create \ container_format: aki
--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}
)
network: network:
enabled: true enabled: true
openstack: openstack: