Skip to content

Commit 83482d2

Browse files
authored
Add tool to set image properties (#829)
* add tool to set image properties * fix irrelevant linter bash warnings * add usage * add properties docs
1 parent 0dff59b commit 83482d2

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

dev/image-set-properties.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/bash
2+
# Set image properties correctly for Slurm Appliance images
3+
#
4+
# Usage:
5+
# dev/image-set-properties.sh $IMAGE_NAME_OR_ID
6+
7+
set -euo pipefail
8+
9+
image=${1?param missing - image name or ID}
10+
echo getting image format ...
11+
format=$(openstack image show -c disk_format -f value "${image}")
12+
13+
echo setting constant properties ...
14+
set -x
15+
openstack image set \
16+
--property hw_machine_type=q35 \
17+
--property hw_architecture=x86_64 \
18+
--property hw_vif_multiqueue_enabled=true \
19+
--property hw_firmware_type=uefi \
20+
--property os_distro=rocky \
21+
--property os_type=linux \
22+
--property os_admin_user=rocky \
23+
"$image"
24+
25+
set +x
26+
if [[ "$format" = raw ]]; then
27+
echo setting raw properties...
28+
set -x
29+
openstack image set \
30+
--property hw_scsi_model=virtio-scsi \
31+
--property hw_disk_bus=scsi \
32+
"$image"
33+
else
34+
echo setting qcow2 properties
35+
set -x
36+
openstack image set \
37+
--property hw_scsi_model=virtio-scsi \
38+
--property hw_disk_bus=scsi \
39+
--property hw_scsi_model=virtio \
40+
"$image"
41+
fi

docs/image-build.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,22 @@ For either a site-specific fat-image build or an extra-build:
128128
then delete the failed volume, select cancelling the build when Packer asks,
129129
and then retry. This is [OpenStack bug 1823445](https://bugs.launchpad.net/cinder/+bug/1823445).
130130

131+
The image name and UUID will be output near the end of a build, e.g.:
132+
133+
```shell
134+
==> openstack.openhpc: Waiting for image openhpc-251017-1156-046b6133 (image id: 86ac2073-0a86-4fbf-935c-f1b6e6392e90) to become ready...
135+
```
136+
131137
6. The built image will be automatically uploaded to OpenStack. By default it
132138
will have a name prefixed `openhpc` and including a timestamp and a shortened
133139
Git hash.
134140

141+
7. Set the image properties. From the repository root run:
142+
143+
```shell
144+
dev/image-set-properties.sh $IMAGE_NAME_OR_ID
145+
```
146+
135147
## Build Process
136148

137149
In summary, Packer creates an OpenStack VM, runs Ansible on that, shuts it down, then creates an image from the root disk.

0 commit comments

Comments
 (0)