Fetches and deprecates images for openstack. Images to be fetched/deprecated can be defined within the input.json file which the python script reads.
Please remember to define IMAGEBUILDER_CLOUD and IMAGEBUILDER_NETWORK in your shell.
If you wish to disable ping tests, set the environment variable IMAGEBUILDER_DISABLE_PINGING to anything If you wish for a verbose output of all openstack commands being ran set the variable IMAGEBUILDER_DEBUG to anything
This project has been tested to work with Python version 3.12.3 but newer and versions down to 3.9 are very likely to work.
Install qemu-utils
(Debian/Ubuntu) or qemu-img
(AlmaLinux/CentOS/RHEL)
It is required for converting images into RAW files
Create a python virtual environment and activate it like this:
python3 -m venv env
source env/bin/activate
Install required packages from requirements.txt using pip in the virtual environment
pip install -r requirements.txt
Install required software (podman/docker) Build the container with:
podman build --network host -t imagebuilder .
Run it with:
podman run --rm --network host \
-v ./checksums:/app/checksums -v ./tmp:/app/tmp -v ./clouds.yaml:/app/clouds.yaml -v ./input.json:/app/input.json \
-v /path/to/cloud.log:/app/mycloud.log -e IMAGEBUILDER_CLOUD=mycloud -e IMAGEBUILDER_NETWORK=project_1234 \
imagebuilder
Configure a clouds.yaml file according to your needs and place it in one of these 3:
- the current directory
- ~/.config/openstack
- /etc/openstack
Instructions on how to compile a clouds.yaml file
Set your environment variables as such:
- IMAGEBUILDER_CLOUD should match your clouds.yaml cloud you would like to use
- IMAGEBUILDER_NETWORK should match the default network the openstack project uses
- IMAGEBUILDER_INPUT_FILE should match your input json file (defaults to input.json)
By default the program will log in your current directory under {cloud}.log if you wish to set your own log file set:
- IMAGEBUILDER_LOG_FILE to the file where you wish to log
Now the project is ready to be run!
The script is run like this:
IMAGEBUILDER_CLOUD="mycloud" IMAGEBUILDER_NETWORK="project_1234" IMAGEBUILDER_INPUT_FILE="input.json" python3 fetch.py
If you wish to write your logs to a specific folder then run the script like this:
IMAGEBUILDER_CLOUD="mycloud" IMAGEBUILDER_NETWORK="project_1234" IMAGEBUILDER_INPUT_FILE="input.json" IMAGEBUILDER_LOG_FILE="/path/to/cloud.log" python3 fetch.py
If an input file is not specified, input.json will be used
input.json should look something like this.
{
"current": [
{
"image_name": "Ubuntu-24.04",
"visibility": "public",
"image_url": "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img",
"checksum_url": "https://cloud-images.ubuntu.com/noble/current/SHA256SUMS",
"properties": {
"os_distro": "ubuntu"
}
}
],
"deprecated": [
{
"image_name": "Ubuntu-18.04",
"filename": "noble-server-cloudimg-amd64.img"
}
]
}
Note that checksum_url is optional but highly recommended if available.
Deprecated.filename is optional to use. Use it if you believe that there might still be files on disk.
The data in current also accepts custom properties for images. Here's a list of all possible property values you can set
If you are creating a non-Linux image, in data.current.properties set "os_type" to your operating system. As of writing Openstack allows these values to be "linux" or "windows". Setting it to something else will configure ephemeral drives to use fvat instead of ext4 (linux) or ntfs (windows). By default this script assumes you are creating a linux image unless something else is specified.