make specification of fabric interfaces configurable
Change-Id: Id6db46e3bb0c13d1c2916255c5bd6419bc906e4b
(cherry picked from commit b247b1d3efa81b3d1fa5b30be537d5d50c5c18c8)
diff --git a/roles/compute-node/files/rename_ifaces.sh b/roles/compute-node/files/rename_ifaces.sh
index a490717..aa8e07c 100755
--- a/roles/compute-node/files/rename_ifaces.sh
+++ b/roles/compute-node/files/rename_ifaces.sh
@@ -48,24 +48,15 @@
fi
local DRIVER=$(ethtool -i $1 2>/dev/null | grep driver | awk '{print $2}')
local RESULT="DNC"
- case $DRIVER in
- mlx4_en)
- RESULT="MLX4_EN"
- ;;
- i40e)
- RESULT="I40G"
- ;;
- ixgbe)
- RESULT="10G"
- ;;
- *)
- IS_PHY=$(ls -l /sys/class/net/$1 | grep -v virtual | wc -l)
- if [ $IS_PHY -eq 1 ]; then
+ MATCH=$(echo "|$FABRIC_IFACE_SPEC|" | grep "|$DRIVER|" | wc -l)
+ if [ $MATCH -ne 0 ]; then
+ RESULT="FABRIC"
+ else
+ IS_PHY=$(ls -l /sys/class/net/$1 | grep -v virtual | wc -l)
+ if [ $IS_PHY -eq 1 ]; then
RESULT="ETH"
- fi
- ;;
- *) ;;
- esac
+ fi
+ fi
echo $RESULT
}
@@ -209,6 +200,9 @@
test -z $MGT_GW && MGT_GW=$(first $MGT_ADDR)
fi
+FABRIC_IFACE_SPEC=$9
+test -z $FABRIC_IFACE_SPEC && FABRIC_IFACE_SPEC="i40e|mlx4_en"
+
LIST_ETH=$(mktemp -u)
LIST_FABRIC=$(mktemp -u)
IFACES_FILE=$(mktemp -u)
@@ -222,7 +216,7 @@
ETH)
echo "$(get_mac $i)" >> $LIST_ETH
;;
- I40G|MLX4_EN|10G)
+ FABRIC)
echo "$(get_mac $i)" >> $LIST_FABRIC
;;
*) ;;
diff --git a/roles/compute-node/tasks/main.yml b/roles/compute-node/tasks/main.yml
index 236fae4..f74ab55 100644
--- a/roles/compute-node/tasks/main.yml
+++ b/roles/compute-node/tasks/main.yml
@@ -152,7 +152,7 @@
- name: Consistent Interface Naming
become: yes
- script: files/rename_ifaces.sh "{{ compute_node.interfaces.fabric }}" "{{ compute_node.addresses.fabric }}" "{{ compute_node.interfaces.external }}" "{{ compute_node.addresses.external }}" "{{ compute_node.gateway.external }}" "{{ compute_node.interfaces.management }}" "{{ compute_node.addresses.management }}" "{{ compute_node.gateway.management }}"
+ script: files/rename_ifaces.sh "{{ compute_node.interfaces.fabric }}" "{{ compute_node.addresses.fabric }}" "{{ compute_node.interfaces.external }}" "{{ compute_node.addresses.external }}" "{{ compute_node.gateway.external }}" "{{ compute_node.interfaces.management }}" "{{ compute_node.addresses.management }}" "{{ compute_node.gateway.management }}" "{{ compute_node.fabric_iface_match }}"
register: ifaces_changed
changed_when: ifaces_changed.stdout.find("true") != -1
tags:
diff --git a/roles/compute-node/vars/main.yml b/roles/compute-node/vars/main.yml
index 05425ea..62c9f19 100644
--- a/roles/compute-node/vars/main.yml
+++ b/roles/compute-node/vars/main.yml
@@ -1,6 +1,7 @@
pub_ssh_key: "{{ lookup('file', 'files/id_rsa.pub') }}"
compute_node:
+ fabric_iface_match: "{{ fabric_iface_spec | default('i40e|mlx4_en') }}"
interfaces:
fabric: "{{ fabric_iface | default('fabric') }}"
management: "{{ management_iface | default('mgmtbr') }}"