Skip to content

Commit

Permalink
Devstack: Make boot volume optional on openstack
Browse files Browse the repository at this point in the history
This makes it possible to choose if the devstack should be created with
or without volumes when running on openstack. It also bumps the default
image name to ubuntu-2404-lts to match the other resource types.

Signed-off-by: Lennart Jern <lennart.jern@est.tech>
  • Loading branch information
lentzi90 committed Dec 11, 2024
1 parent 7074d80 commit b45c700
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions hack/ci/openstack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ set -x -o errexit -o nounset -o pipefail
# SSH_PRIVATE_KEY_FILE
# OPENSTACK_PUBLIC_NETWORK
# OPENSTACK_PUBLIC_IP (optional, will be created on OPENSTACK_PUBLIC_NETWORK if not defined)
# USE_VOLUMES (optional, default true)

function cloud_init {
OPENSTACK_NETWORK_NAME=${OPENSTACK_NETWORK_NAME:-${CLUSTER_NAME}-network}
OPENSTACK_SUBNET_NAME=${OPENSTACK_SUBNET_NAME:-${CLUSTER_NAME}-subnet}
OPENSTACK_SECGROUP_NAME=${OPENSTACK_SECGROUP_NAME:-${CLUSTER_NAME}-secgroup}
OPENSTACK_ROUTER_NAME=${OPENSTACK_ROUTER_NAME:-${CLUSTER_NAME}-router}
OPENSTACK_IMAGE_NAME=${OPENSTACK_IMAGE_NAME:-ubuntu-2204-lts}
OPENSTACK_IMAGE_NAME=${OPENSTACK_IMAGE_NAME:-ubuntu-2404-lts}

OPENSTACK_FLAVOR=${OPENSTACK_FLAVOR:-m1.xlarge}
OPENSTACK_FLAVOR_controller=${OPENSTACK_FLAVOR_controller:-$OPENSTACK_FLAVOR}
Expand Down Expand Up @@ -109,24 +110,29 @@ function create_vm {
secgroupid=${secgroupid:-${OPENSTACK_SECGROUP_NAME}}
imageid=${imageid:-${OPENSTACK_IMAGE_NAME}}

local volumename="${CLUSTER_NAME}-${name}"
local volumeid
if ! volumeid=$(openstack volume show "$volumename" -f value -c id 2>/dev/null)
then
volumeid=$(openstack volume create -f value -c id --size 200 \
--bootable --image "$imageid" "$volumename")
while [ "$(openstack volume show "$volumename" -f value -c status 2>/dev/null)" != "available" ]; do
echo "Waiting for volume to become available"
sleep 5
done
local storage_medium_flag="--image=$imageid"

if [ "${USE_VOLUMES:-true}" == "true" ]; then
local volumename="${CLUSTER_NAME}-${name}"
local volumeid
if ! volumeid=$(openstack volume show "$volumename" -f value -c id 2>/dev/null)
then
volumeid=$(openstack volume create -f value -c id --size 200 \
--bootable --image "$imageid" "$volumename")
while [ "$(openstack volume show "$volumename" -f value -c status 2>/dev/null)" != "available" ]; do
echo "Waiting for volume to become available"
sleep 5
done
fi
storage_medium_flag="--volume=$volumeid"
fi

local serverid
if ! serverid=$(openstack server show "$servername" -f value -c id 2>/dev/null)
then
serverid=$(openstack server create -f value -c id \
--os-compute-api-version 2.52 --tag "$CLUSTER_NAME" \
--flavor "$flavor" --volume "$volumeid" \
--flavor "$flavor" "$storage_medium_flag" \
--nic net-id="$networkid",v4-fixed-ip="$ip" \
--security-group "$secgroupid" \
--user-data "$userdata" \
Expand Down

0 comments on commit b45c700

Please sign in to comment.