Skip to content

Commit d23ff5e

Browse files
committed
CP-308116: Update hard code eth in network-init
This hard code in rename_network_label is used to find NIC position by ethN. Change to use bridge name to find the position. Signed-off-by: Changlei Li <[email protected]>
1 parent 0d4a096 commit d23ff5e

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

scripts/network-init

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,28 @@ prepare_networking() {
100100

101101
rename_network_label() {
102102
# In common criteria certification deployment, user must ensure:
103-
# - The 1st NIC (eth0) is for Management Network
104-
# - The 2nd NIC (eth1) is for Storage Network
105-
# - others (ethX, X>=2) is for Guest Network
103+
# - The 1st NIC is for Management Network
104+
# - The 2nd NIC is for Storage Network
105+
# - others (X>=2) is for Guest Network
106106
# This function is to rename these network labels to appropriate.
107107

108108
if [ "${CC_PREPARATIONS}" != "true" ]; then
109109
echo "Skipped common criteria settings"
110110
return
111111
fi
112112

113-
for device in $(ls /sys/class/net | grep -E '^eth[0-9]+$')
113+
for device_path in /sys/class/net/*
114114
do
115-
device_id=$(echo ${device} | sed 's/^eth//')
115+
device=$(basename "${device_path}")
116+
network_uuid=$(${XE} pif-list device="${device}" params=network-uuid --minimal)
117+
if [ -z "${network_uuid}" ]; then
118+
continue
119+
fi
120+
bridge=$(${XE} network-list uuid="${network_uuid}" params=bridge --minimal)
121+
if [ -z "${bridge}" ]; then
122+
continue
123+
fi
124+
device_id=$(echo ${bridge} | sed 's/^xenbr//')
116125
if [ ${device_id} -eq 0 ]; then
117126
name_label="Management Network"
118127
elif [ ${device_id} -eq 1 ]; then
@@ -127,8 +136,7 @@ rename_network_label() {
127136
continue
128137
fi
129138

130-
network_uuid=$(${XE} pif-list device=${device} params=network-uuid --minimal)
131-
${XE} network-param-set uuid=${network_uuid} name-label="${name_label}"
139+
${XE} network-param-set uuid="${network_uuid}" name-label="${name_label}"
132140
echo "Renamed network label of ${network_uuid} to ${name_label}, device: ${device}"
133141
done
134142
}

0 commit comments

Comments
 (0)