From 2b1720db73ffd1f7292184956041def242ec9a31 Mon Sep 17 00:00:00 2001
From: Eesaan Atluri <atlurie@uab.edu>
Date: Tue, 14 Jan 2025 21:53:09 -0500
Subject: [PATCH] feat: Use conditional to make --network optional

Closes https://gitlab.rc.uab.edu/rc/hpc-factory/-/issues/181

Defining a network can be optional when a port is already defined when
deploying a VM.

This commit adds flexibility where you can either use --port or
--network options to define a network during the deployment.

Alternatively, you can define both but the port cannot be from the same
network you used in the --network option. Otherwise, you will have two
ips from the same network which will cause network reachability issues.
---
 .gitlab-ci.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e2956f7..7cb2fc7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -308,7 +308,9 @@ deploy_login_node:
       export cmd="openstack server create"
       cmd+=" -c id -f value --image $LOGIN_IMAGE_ID"
       cmd+=" --flavor $INSTANCE_FLAVOR"
+      if [ -n "$INSTANCE_NETWORK" ];then
       cmd+=" --network $INSTANCE_NETWORK"
+      fi
       cmd+=" --security-group allow-ssh"
       cmd+=" --user-data user_data.txt"
       if [ -n "$LOGIN_PORT" ];then cmd+=" --port $LOGIN_PORT"; fi
-- 
GitLab