Skip to content

Commit

Permalink
Add a script to allocate VIPs in PS6
Browse files Browse the repository at this point in the history
This eneusres that these IP addresses don't get used by OpenStack and
the relevant VIPs can be utilised and hence don't have conflicts
  • Loading branch information
arif-ali committed Aug 2, 2024
1 parent 14153ff commit 77a7f72
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions openstack/tools/allocate_vips.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Allocate the last 20 IP addresses, which could be considered for
# VIPs in OpenStack

source ~/novarc
num_vips=20
subnet="subnet_${OS_USERNAME}-psd"

cidr=$(openstack subnet show ${subnet} -c cidr -f value 2>/dev/null)

net_end=$(awk -F'.' '/HostMax/{print $NF}' <<<$(ipcalc -b $cidr))

net_end_suffix=${net_end##*\.}

vip_start_suffix=$((net_end_suffix - ${num_vips} + 1))
net_pre=$(echo $cidr| sed -r 's/([0-9]+\.[0-9]+\.[0-9]+).+/\1/g')

j=1

for i in $(seq ${vip_start_suffix} ${net_end_suffix})
do
openstack port create --network net_${OS_USERNAME}-psd \
--fixed-ip subnet=subnet_${OS_USERNAME}-psd,ip-address=${net_pre}.$i \
--disable --os-cloud ps6 ps6-vip-ip$( printf "%02d" $j )
((j++))
done

0 comments on commit 77a7f72

Please sign in to comment.