diff options
author | randyl <r.levensalor@cablelabs.com> | 2015-07-15 19:30:34 -0600 |
---|---|---|
committer | randyl <r.levensalor@cablelabs.com> | 2015-07-16 09:31:21 -0600 |
commit | c621b81549551823ecd1447bb18aa854bb90d8f1 (patch) | |
tree | f0eaa3cfb699ba07e1997718d37590e70caa913e /foreman | |
parent | 1a0c8ab300fdc4865683586ead5d803925d6bf93 (diff) |
Fixed public IP allocation JIRA: BGS-89
For bare metal deployments, the list IP of the last IP of the subnet
and 20 IPs before are reservered for neutron public IPs.
A new function to subtract a number from an IP was added.
Really fixed the logic for skipping 10 IP for VIPs was flipped to treat
no_dhcp with static IPs as a special case.
Removed a false print statement that the foreman VM is running.
Consolidated two identical print messages with the public IP range.
Change-Id: I189b9440dafd98e49d9a147515810e44b97ab256
Signed-off-by: randyl <r.levensalor@cablelabs.com>
Diffstat (limited to 'foreman')
-rwxr-xr-x | foreman/ci/deploy.sh | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/foreman/ci/deploy.sh b/foreman/ci/deploy.sh index a607350..d027779 100755 --- a/foreman/ci/deploy.sh +++ b/foreman/ci/deploy.sh @@ -124,6 +124,19 @@ function next_ip { echo $baseaddr.$lsv } +##subtracts a value from an IP address +##params: last ip, ip_count +##assumes ip_count is less than the last octect of the address +subtract_ip() { + IFS=. read -r i1 i2 i3 i4 <<< "$1" + ip_count=$2 + if [ $i4 -lt $ip_count ]; then + echo -e "\n\n${red}ERROR: Can't subtract $ip_count from IP address $1 Exiting${reset}\n\n" + exit 1 + fi + printf "%d.%d.%d.%d\n" "$i1" "$i2" "$i3" "$((i4 - $ip_count ))" +} + ##removes the network interface config from Vagrantfile ##params: interface ##assumes you are in the directory of Vagrantfile @@ -703,11 +716,11 @@ configure_network() { ##replace foreman site sed -i 's/^.*foreman_url:.*$/ foreman_url:'" https:\/\/$foreman_ip"'\/api\/v2\//' opnfv_ksgen_settings.yml ##replace public vips - ##no need to do this if virtual and no dhcp - if [ ! -z "$enable_virtual_dhcp" ]; then - next_public_ip=$(increment_ip $next_public_ip 10) - else + ##no need to do this if no dhcp + if [[ -z "$enable_virtual_dhcp" && ! -z "$virtual" ]]; then next_public_ip=$(next_usable_ip $next_public_ip) + else + next_public_ip=$(increment_ip $next_public_ip 10) fi public_output=$(grep -E '*public_vip' opnfv_ksgen_settings.yml) @@ -775,15 +788,13 @@ configure_network() { else public_allocation_start=$(next_ip $next_public_ip) public_allocation_end=$static_ip_range_end - echo "${blue}Neutron Floating IP range: $public_allocation_start to $public_allocation_end ${reset}" fi else last_ip_subnet=$(find_last_ip_subnet $next_public_ip $public_subnet_mask) - public_allocation_start=$(increment_subnet $public_subnet $(( $last_ip_subnet - $floating_ip_count )) ) - public_allocation_end=$(increment_subnet $public_subnet $(( $last_ip_subnet )) ) - echo "${blue}Neutron Floating IP range: $public_allocation_start to $public_allocation_end ${reset}" - echo "${blue}Foreman VM is up! ${reset}" + public_allocation_start=$(subtract_ip $last_ip_subnet $floating_ip_count ) + public_allocation_end=${last_ip_subnet} fi + echo "${blue}Neutron Floating IP range: $public_allocation_start to $public_allocation_end ${reset}" sed -i 's/^.*public_allocation_start:.*$/ public_allocation_start:'" $public_allocation_start"'/' opnfv_ksgen_settings.yml sed -i 's/^.*public_allocation_end:.*$/ public_allocation_end:'" $public_allocation_end"'/' opnfv_ksgen_settings.yml |