From f9aa369af0de2288668c3a351be33a804b12ffdd 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e2956f7..a1ef569 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -206,10 +206,10 @@ deploy_http_proxy_node: export cmd="openstack server create" cmd+=" -c id -f value --image $HTTP_PROXY_IMAGE_ID" cmd+=" --flavor $INSTANCE_FLAVOR" - cmd+=" --network $PROXY_NETWORK" cmd+=" --security-group webserver_sec_group" cmd+=" --security-group allow-ssh" cmd+=" --user-data user_data.txt" + if [ -n "$PROXY_NETWORK" ];then cmd+=" --network $PROXY_NETWORK" fi if [ -n "$HTTP_PROXY_PORT" ];then cmd+=" --port $HTTP_PROXY_PORT"; fi cmd+=" --wait $HTTP_PROXY_INSTANCE_NAME" - export HTTP_PROXY_INSTANCE_ID=$(bash -c "$cmd") @@ -257,9 +257,9 @@ deploy_ssh_proxy_node: export cmd="openstack server create" cmd+=" -c id -f value --image $SSH_PROXY_IMAGE_ID" cmd+=" --flavor $INSTANCE_FLAVOR" - cmd+=" --network $PROXY_NETWORK" cmd+=" --security-group allow-ssh" cmd+=" --user-data user_data.txt" + if [ -n "$PROXY_NETWORK" ];then cmd+=" --network $PROXY_NETWORK" fi if [ -n "$SSH_PROXY_PORT" ];then cmd+=" --port $SSH_PROXY_PORT"; fi cmd+=" --wait $SSH_PROXY_INSTANCE_NAME" - export SSH_PROXY_INSTANCE_ID=$(bash -c "$cmd") @@ -308,9 +308,9 @@ deploy_login_node: export cmd="openstack server create" cmd+=" -c id -f value --image $LOGIN_IMAGE_ID" cmd+=" --flavor $INSTANCE_FLAVOR" - cmd+=" --network $INSTANCE_NETWORK" cmd+=" --security-group allow-ssh" cmd+=" --user-data user_data.txt" + if [ -n "$INSTANCE_NETWORK" ];then cmd+=" --network $INSTANCE_NETWORK" fi if [ -n "$LOGIN_PORT" ];then cmd+=" --port $LOGIN_PORT"; fi cmd+=" --wait $LOGIN_INSTANCE_NAME" - export LOGIN_INSTANCE_ID=$(bash -c "$cmd") -- GitLab