Fix preseed MAC address fetch method 19/30619/1
authorQiLiang <liangqi1@huawei.com>
Thu, 16 Mar 2017 02:07:45 +0000 (10:07 +0800)
committerQiLiang <liangqi1@huawei.com>
Thu, 16 Mar 2017 02:31:47 +0000 (10:31 +0800)
JIRA: -

e.g.:

root@host1:~# ip link show eth4
6: eth4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether ec:38:8f:79:fa:5c brd ff:ff:ff:ff:ff:ff
root@host1:~# echo $(echo $@ | cut -d' ' -f17)
ec:38:8f:79:fa:5c

root@host4:~# ip link show eth4
6: eth4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop portid 0100000000000000000000000000003000 state DOWN mode DEFAULT group default qlen 1000
    link/ether e0:36:76:d2:34:73 brd ff:ff:ff:ff:ff:ff
root@host4:~# echo $(echo $@ | cut -d' ' -f17)
1000
root@host4:~# echo $(echo $@ | cut -d' ' -f19)
e0:36:76:d2:34:73

Change-Id: I916c19807da724e9ba471376f81f3c763b9340d5
Signed-off-by: QiLiang <liangqi1@huawei.com>
deploy/adapters/cobbler/snippets/preseed_post_install_network_config

index cb79c55..a2abbf7 100644 (file)
@@ -50,14 +50,7 @@ echo "physical interfaces: \${physical_interfaces}" >> /tmp/network_log
 # map physical interface to mac address
 mac_names=""
 for physical_interface in \${physical_interfaces}; do
-    set \$(ip link show \${physical_interface})
-#if $osversion == "trusty"
-    mac=\$(echo \$@ | cut -d' ' -f17)
-#elif $osversion == "xenial"
-    mac=\$(echo \$@ | cut -d' ' -f17)
-#else
-    mac=\$(echo \$@ | cut -d' ' -f13)
-#end if
+    mac=\$(ip link show \${physical_interface} | awk 'match(\$0,/link\/ether/) {print \$2}')
     mac_name=\$(echo \${mac} |tr 'a-z' 'A-Z' | tr ':' '_')
     if [ -z "\${mac_name}" ]; then
         mac_names="\${mac_name}"