Adds check to ensure that provided static_ip_range param is correct 25/1425/1
authorTim Rozet <trozet@redhat.com>
Tue, 8 Sep 2015 20:00:46 +0000 (16:00 -0400)
committerTim Rozet <trozet@redhat.com>
Tue, 8 Sep 2015 20:00:46 +0000 (16:00 -0400)
Patch adds a check to make sure that the user specified static_ip_range
argument (Ex. 192.168.0.10,192.168.0.20) falls within the valid public
subnet of the host (the same subnet as the default gateway).

JIRA: APEX-19

Change-Id: Ifc0b79074b887509617c2749e50d97d1800abad0
Signed-off-by: Tim Rozet <trozet@redhat.com>
foreman/ci/deploy.sh

index 6771da0..0803993 100755 (executable)
@@ -539,6 +539,13 @@ configure_network() {
     ##set variable info
     if [ ! -z "$static_ip_range" ]; then
       new_ip=$(echo $static_ip_range | cut -d , -f1)
+      subnet_mask=$(find_netmask $this_default_gw_interface)
+      host_subnet=$(find_subnet $interface_ip $subnet_mask)
+      ip_range_subnet=$(find_subnet $new_ip $subnet_mask)
+      if [ "$ip_range_subnet" != "$host_subnet" ]; then
+        echo "${red}static_ip_range: ${static_ip_range} is not in the same subnet as your default gateway interface: ${host_subnet}.  Please use a correct range!${reset}"
+        exit 1
+      fi
     else
       new_ip=$(next_usable_ip $interface_ip)
       if [ ! "$new_ip" ]; then