From 3d4d83b687f9992d531f987fac26b73537192dc2 Mon Sep 17 00:00:00 2001 From: Krish Moodbidri <krish94@uab.edu> Date: Fri, 16 May 2025 13:00:34 -0500 Subject: [PATCH] Added OpenStack VM deployment job - Add `deploy_user_defined_vm` job for configurable VM provisioning - Implement dynamic OpenStack CLI command construction supporting: * Image selection by name/UUID via $VM_IMAGE * Flavor specification with $VM_FLAVOR * Security group array input ($VM_SECURITY_GROUPS) * Network/port options ($VM_NETWORK/$VM_PORT) * Floating IP association ($VM_FLOATING_IPS) - Require core variables: VM_IMAGE, VM_FLAVOR, VM_SECURITY_GROUPS, VM_INSTANCE_NAME - Add pipeline rule trigger via $DEPLOY_VM == "true" --- .gitlab-ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 25048fe..7ff0068 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -426,3 +426,37 @@ deploy_ood_node: rules: - if: $PIPELINE_TARGET == "deploy" && $OOD_IMAGE_ID when: always + + +deploy_user_defined_vm: + stage: deploy + environment: + name: $ENV + tags: + - build + script: + - | + export cmd="openstack server create" + cmd+=" -c id -f value --image $VM_IMAGE" + cmd+=" --flavor $VM_FLAVOR" + for security_group in ${VM_SECURITY_GROUPS[@]}; + do + cmd+=" --security-group $security_group" + done + if [ -n "$VM_NETWORK" ]; then + cmd+=" --network $VM_NETWORK" + fi + if [ -n "$VM_PORT" ]; then + cmd+=" --port $VM_PORT" + fi + cmd+=" --wait $VM_INSTANCE_NAME" + - export VM_INSTANCE_ID=$(bash -c "$cmd") + - | + for FLOATING_IP in ${VM_FLOATING_IPS[@]}; + do + openstack server add floating ip $VM_INSTANCE_ID $FLOATING_IP + echo "Associated IP: $FLOATING_IP" + done + rules: + - if: $DEPLOY_VM == "true" + when: always -- GitLab