From 50fe670726f2229ef963517a890fef2d821b8821 Mon Sep 17 00:00:00 2001 From: Tim Rozet Date: Tue, 8 Sep 2015 16:00:46 -0400 Subject: [PATCH] Adds check to ensure that provided static_ip_range param is correct 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 --- foreman/ci/deploy.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/foreman/ci/deploy.sh b/foreman/ci/deploy.sh index 6771da0..0803993 100755 --- a/foreman/ci/deploy.sh +++ b/foreman/ci/deploy.sh @@ -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 -- 2.16.6