-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from arif-ali/allocate_vip_script_ps6
Add a script to allocate VIPs in PS6
- Loading branch information
Showing
2 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/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)) | ||
|
||
vip_start_suffix=$((net_end - 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}) | ||
do | ||
echo 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 |