[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
{{ $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 }}

View File

@ -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: