From ba378f17783f66ef3f7e55c2aaf63f53d74a23d9 Mon Sep 17 00:00:00 2001 From: Nitesh Kumar Date: Thu, 26 Sep 2024 09:19:21 +0000 Subject: [PATCH] tools: Enhancing the tool to support iso build pytest: Adding test to build iso for 4.0 and 5.0 --- create-image-util | 23 ++++++++++++++++++++--- docker/Dockerfile | 4 ++-- tests/poi-container-test.py | 15 +++++++++++++-- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/create-image-util b/create-image-util index 4bc4d90..1207bb5 100755 --- a/create-image-util +++ b/create-image-util @@ -125,6 +125,10 @@ create_flavor_image() if [ $IMAGE_FLAVOR = "azure" ]; then #build azure exec_docker_cmd="$exec_docker_cmd create-azure --raw-image ${RAW_IMAGE}" + elif [ $IMAGE_FLAVOR = "iso" ]; then + #build iso + cd ${POI_PATH}/examples/${IMAGE_FLAVOR} + exec_docker_cmd="$exec_docker_cmd photon-iso-builder -f build-iso -v ${RELEASE_VERSION} -p ${KS_CONFIG_FILE}" elif [ $IMAGE_FLAVOR = "ova" ]; then #build ova exec_docker_cmd="$exec_docker_cmd create-ova --installer-config ${KS_CONFIG_FILE} --ova-config ${OVA_CONFIG} --ova-name ${OVA_NAME} --raw-image ${RAW_IMAGE}" @@ -236,6 +240,17 @@ usage() { echo "create 4.0 RPI with remote repo" echo "$0 --config-file rpi_ks.yaml --local-repo-path /home/dbx/poi/repo/4.0 --poi-path /home/dbx/workspace/poi_gitlab/photon-os-installer/ --flavor rpi --arch aarch64 --releasever 4.0 --src-repo-url=https://packages.vmware.com/photon/4.0/photon_updates_4.0_x86_64/" echo "============================================================" + echo " create ISO image " + echo "============================================================" + echo "create 5.0 ISO" + echo "$0 --config-file packages_minimal.json --local-repo-path /home/dbx/poi/repo/5.0 --poi-path /home/dbx/workspace/poi_gitlab/photon-os-installer/ --flavor iso" + echo "-------------------------------------------------------------" + echo "create 4.0 ISO" + echo "$0 --config-file packages_minimal.json --local-repo-path /home/dbx/poi/repo/4.0 --poi-path /home/dbx/workspace/poi_gitlab/photon-os-installer/ --flavor iso --releasever 4.0" + echo "-------------------------------------------------------------" + echo "create 4.0 ISO with remote repo" + echo "$0 --config-file packages_minimal.json --local-repo-path /home/dbx/poi/repo/4.0 --poi-path /home/dbx/workspace/poi_gitlab/photon-os-installer/ --flavor iso --releasever 4.0 --src-repo-url=https://packages.vmware.com/photon/4.0/photon_updates_4.0_x86_64/" + echo "============================================================" } @@ -271,7 +286,7 @@ while true; do done if [ -z "${RAW_IMAGE}" ]; then - if [ $IMAGE_FLAVOR != "ami" -a $IMAGE_FLAVOR != "rpi" ] ; then + if [ $IMAGE_FLAVOR != "ami" -a $IMAGE_FLAVOR != "rpi" -a $IMAGE_FLAVOR != "iso" ] ; then echo "raw image is missing" >&2 usage echo "Terminating." >&2 @@ -327,9 +342,11 @@ fi init_env #Create repository and raw image -create_repo_and_raw_image +if [ ${IMAGE_FLAVOR} != "iso" ] ; then + create_repo_and_raw_image +fi #Create final image -if [ ${IMAGE_FLAVOR} = "ova" -o ${IMAGE_FLAVOR} = "azure" ] ; then +if [ ${IMAGE_FLAVOR} = "ova" -o ${IMAGE_FLAVOR} = "azure" -o ${IMAGE_FLAVOR} = "iso" ] ; then create_flavor_image fi diff --git a/docker/Dockerfile b/docker/Dockerfile index ea7222c..c1d094b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -34,7 +34,7 @@ FROM ${DOCKER_PROXY}library/photon:5.0 as poi-rpm-builder ARG TDNF_OPTIONS RUN tdnf ${TDNF_OPTIONS} makecache && \ - tdnf ${TDNF_OPTIONS} -y install git rpm-build python3 createrepo + tdnf ${TDNF_OPTIONS} -y install git rpm-build python3 createrepo ca-certificates openssl COPY --from=poi-helper / /photon-os-installer @@ -61,7 +61,7 @@ RUN tdnf ${TDNF_OPTIONS} makecache && \ python3-rpm \ qemu-img \ open-vmdk ostree rpm-ostree \ - stig-hardening \ + stig-hardening ca-certificates openssl \ $([ "${TARGETARCH}" == "amd64" ] && echo grub2-pc) && \ rm -rf /var/cache/tdnf diff --git a/tests/poi-container-test.py b/tests/poi-container-test.py index 20d9d6b..9874263 100755 --- a/tests/poi-container-test.py +++ b/tests/poi-container-test.py @@ -15,7 +15,7 @@ LOCAL_REPO_PATH = POI_TEST_PATH + "/repo" BASE_COMMAND = f"{POI_PATH}/create-image-util --poi-path {POI_PATH} --local-repo-path" -IMAGE_FLAVOR = ["azure", "ova", "rpi", "ami"] +IMAGE_FLAVOR = ["azure", "ova", "rpi", "ami", "iso"] def create_repo_path(): @@ -23,7 +23,7 @@ def create_repo_path(): def remove_build_images(directory): - patterns = ["*.vhd.tar.gz", "*.ova", "*.ovf", "*.mf", "*.raw", "*.img", "poi-manifest.json"] + patterns = ["*.vhd.tar.gz", "*.ova", "*.ovf", "*.mf", "*.raw", "*.img"," *.iso", "poi-manifest.json"] files = [file for pattern in patterns for file in glob.glob(f"{directory}/{pattern}")] for file in files: @@ -93,6 +93,11 @@ def test_build_ph5_local_ami_image(self): subprocess.check_call(exec_command, shell = True) assert(image_exist("ami", "photon-ami.raw") == True) + def test_build_ph5_local_iso_image(self): + exec_command = f"{BASE_COMMAND} {LOCAL_REPO_PATH}/5.0 --config-file packages_minimal.json --flavor iso" + + subprocess.check_call(exec_command, shell = True) + assert(image_exist("iso", "something.iso") == True) ''' def test_build_ph5_local_rpi_image(self): exec_command = f"{BASE_COMMAND} {LOCAL_REPO_PATH}/5.0 --config-file rpi_ks.yaml --flavor rpi --arch aarch64" @@ -138,9 +143,15 @@ def test_build_ph4_local_lvm_ova_image(self): def test_build_ph4_local_ami_image(self): exec_command = f"{BASE_COMMAND} {LOCAL_REPO_PATH}/4.0 --config-file ami_40_ks.yaml --flavor ami --releasever 4.0" + subprocess.check_call(exec_command, shell = True) assert(image_exist("ami", "photon-ami-4.0.raw") == True) + def test_build_ph4_local_iso_image(self): + exec_command = f"{BASE_COMMAND} {LOCAL_REPO_PATH}/4.0 --config-file packages_minimal.json --flavor iso --releasever 4.0" + + subprocess.check_call(exec_command, shell = True) + assert(image_exist("iso", "something.iso") == True) ''' def test_build_ph4_local_rpi_image(self): exec_command = f"{BASE_COMMAND} {LOCAL_REPO_PATH}/4.0 --config-file rpi_ks.yaml --flavor rpi --arch aarch64 --releasever 4.0"