summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Brockners <fbrockne@cisco.com>2015-04-17 16:42:42 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2015-04-17 16:42:42 +0000
commit9671ae1f76a4174ba824f17aa8908759e82aa800 (patch)
tree46e69d19ca11d53d9c852eaf2871136957f8950c
parent4b5977c92d16d1f4af9293fc874645e671674c22 (diff)
parentbaa86cc250a0fcf44b6f4dea7c8aeb73f4f9f0fa (diff)
Merge "Adds support for subnets other than /24 and fixes issue where default_gw was set in the wrong place PATCHSET2: Fixes improper spacing in network_type for .yaml settings"
-rwxr-xr-xforeman/ci/deploy.sh42
1 files changed, 34 insertions, 8 deletions
diff --git a/foreman/ci/deploy.sh b/foreman/ci/deploy.sh
index d1bb24c..82fbef7 100755
--- a/foreman/ci/deploy.sh
+++ b/foreman/ci/deploy.sh
@@ -41,6 +41,28 @@ function find_ip {
ip addr show $1 | grep -Eo '^\s+inet\s+[\.0-9]+' | awk '{print $2}'
}
+##finds subnet of ip and netmask
+##params: ip, netmask
+function find_subnet {
+ IFS=. read -r i1 i2 i3 i4 <<< "$1"
+ IFS=. read -r m1 m2 m3 m4 <<< "$2"
+ printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
+}
+
+##finds netmask of interface
+##params: interface
+##returns long format 255.255.x.x
+function find_netmask {
+ ifconfig $1 | grep -Eo 'netmask\s+[\.0-9]+' | awk '{print $2}'
+}
+
+##finds short netmask of interface
+##params: interface
+##returns short format, ex: /21
+function find_short_netmask {
+ echo "/$(ip addr show $1 | grep -Eo '^\s+inet\s+[\/\.0-9]+' | awk '{print $2}' | cut -d / -f2)"
+}
+
##increments next IP
##params: ip
##assumes a /24 subnet
@@ -253,7 +275,12 @@ for interface in ${output}; do
continue
fi
interface_ip_arr[$if_counter]=$new_ip
- sed -i 's/^.*eth_replace'"$if_counter"'.*$/ config.vm.network "public_network", ip: '\""$new_ip"\"', bridge: '\'"$interface"\''/' Vagrantfile
+ subnet_mask=$(find_netmask $interface)
+ if [ "$if_counter" -eq 1 ]; then
+ private_subnet_mask=$subnet_mask
+ private_short_subnet_mask=$(find_short_netmask $interface)
+ fi
+ sed -i 's/^.*eth_replace'"$if_counter"'.*$/ config.vm.network "public_network", ip: '\""$new_ip"\"', bridge: '\'"$interface"\'', netmask: '\""$subnet_mask"\"'/' Vagrantfile
((if_counter++))
done
@@ -291,8 +318,6 @@ else
sed -i 's/^.*default_gw =.*$/ default_gw = '\""$defaultgw"\"'/' Vagrantfile
fi
-sed -i 's/^.*default_gw:.*$/default_gw:'" $defaultgw"'/' opnfv_ksgen_settings.yml
-
if [ $base_config ]; then
if ! cp -f $base_config opnfv_ksgen_settings.yml; then
echo "{red}ERROR: Unable to copy $base_config to opnfv_ksgen_settings.yml${reset}"
@@ -311,6 +336,8 @@ echo "${blue}Gathering network parameters for Target System...this may take a fe
##if single node deployment all the variables will have the same ip
##interface names will be enp0s3, enp0s8, enp0s9 in chef/centos7
+sed -i 's/^.*default_gw:.*$/default_gw:'" $defaultgw"'/' opnfv_ksgen_settings.yml
+
##replace private interface parameter
##private interface will be of hosts, so we need to know the provisioned host interface name
##we add biosdevname=0, net.ifnames=0 to the kickstart to use regular interface naming convention on hosts
@@ -328,7 +355,7 @@ elif [[ "$deployment_type" == "multi_network" || "$deployment_type" == "three_ne
if [ "$deployment_type" == "three_network" ]; then
sed -i 's/^.*storage_iface:.*$/ storage_iface: eth1/' opnfv_ksgen_settings.yml
- sed -i 's/^.*network_type:.*$/ network_type: three_network/' opnfv_ksgen_settings.yml
+ sed -i 's/^.*network_type:.*$/network_type: three_network/' opnfv_ksgen_settings.yml
else
sed -i 's/^.*storage_iface:.*$/ storage_iface: eth3/' opnfv_ksgen_settings.yml
fi
@@ -378,10 +405,9 @@ elif [[ "$deployment_type" == "multi_network" || "$deployment_type" == "three_ne
done
##replace private_subnet param
- network=.0
- baseaddr="$(echo $next_private_ip | cut -d. -f1-3)"
- private_subnet=$baseaddr$network
- sed -i 's/^.*private_subnet:.*$/ private_subnet:'" $private_subnet"''"\/24"'/' opnfv_ksgen_settings.yml
+ private_subnet=$(find_subnet $next_private_ip $private_subnet_mask)
+ private_subnet=$private_subnet'\'$private_short_subnet_mask
+ sed -i 's/^.*private_subnet:.*$/ private_subnet:'" $private_subnet"'/' opnfv_ksgen_settings.yml
else
printf '%s\n' 'deploy.sh: Unknown network type: $deployment_type' >&2
exit 1