Fixes bug with interface detection 21/1321/3
authorTim Rozet <trozet@redhat.com>
Wed, 26 Aug 2015 20:00:40 +0000 (16:00 -0400)
committerTim Rozet <trozet@redhat.com>
Fri, 28 Aug 2015 16:51:44 +0000 (12:51 -0400)
This patch addresses the detection of the physical NICs to bridge to.
There was a bug where the regexp would ignore some NICs on accident, and
the purpose of the expression was to ignore virtual NICs.  Rather than
ignore NICs by their name, this patch ensures that NICs are ignored if
they are actually virtual types.

Also fixes syntax issue with checking for nic_arg_flag.

JIRA: APEX-11

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

index a978e38..59254d1 100755 (executable)
@@ -324,7 +324,7 @@ parse_cmdline() {
   fi
 
   ##Validate nic args
-  if [ $nic_arg_flag -eq 1 ]; then
+  if [[ $nic_arg_flag -eq 1 ]]; then
     if [ -z "$virtual" ]; then
       for nic_type in admin_nic private_nic public_nic; do
         eval "nic_value=\$$nic_type"
@@ -500,7 +500,7 @@ configure_network() {
 
   ##if nic_arg_flag is set, then we don't figure out
   ##NICs dynamically
-  if [ $nic_arg_flag -eq 1 ]; then
+  if [[ $nic_arg_flag -eq 1 ]]; then
     echo "${blue}Static Network Interfaces Defined.  Updating Vagrantfile...${reset}"
     if [ $virtual ]; then
       nic_list="$public_nic"
@@ -516,7 +516,7 @@ configure_network() {
     echo "${blue}Detecting network configuration...${reset}"
     ##detect host 1 or 3 interface configuration
     #output=`ip link show | grep -E "^[0-9]" | grep -Ev ": lo|tun|virbr|vboxnet" | awk '{print $2}' | sed 's/://'`
-    output=`ifconfig | grep -E "^[a-zA-Z0-9]+:"| grep -Ev "lo|tun|virbr|vboxnet" | awk '{print $1}' | sed 's/://'`
+    output=`/bin/ls -l /sys/class/net | tail -n +2 | grep -v virtual | cut -d " " -f9`
   fi
 
   if [ ! "$output" ]; then