diff --git a/src/sysinfo b/src/sysinfo index 5338e2593..103898802 100755 --- a/src/sysinfo +++ b/src/sysinfo @@ -25,7 +25,7 @@ fi # helper to set global "normalized" to the expanded version of MAC ($1) function normalize_mac() { - mac=$1 + local mac=$1 if [ -z "${mac}" ]; then echo "FATAL: unable to normalize empty mac!" exit 1 @@ -167,6 +167,7 @@ function get_nic_mappings() function get_network_interfaces() { count=1 + nic_tag_count=1 # ignore 'LINK SLOT ADDRESS INUSE CLIENT' line for line in $(pfexec /sbin/dladm show-phys -m | grep -v "^LINK " | awk '{ print $1,$3 }' | tr ' ' '='); do nicnames= @@ -191,6 +192,19 @@ function get_network_interfaces() NIC_internal=${iface} fi + for tag in "${NicTagsMacs[@]}"; do + tag_fields=(${tag//=/ }) + tag_name=${tag_fields[0]} + normalize_mac ${tag_fields[1]} + tag_mac=${normalized} + if [[ "${tag_mac}" == "${mac}" ]]; then + [[ -n ${nicnames} ]] && nicnames="${nicnames}," + nicnames="${nicnames}${tag_name}" + NicTags[${nic_tag_count}]="${tag_name}=${iface}" + ((nic_tag_count++)) + fi + done + NetworkInterfaces[${count}]=${iface} eval "Network_Interface_${iface}_MAC_Address=${mac}" eval "Network_Interface_${iface}_IPv4_Address=${ip4addr}" @@ -212,6 +226,19 @@ function get_network_interfaces() #done } +function get_nic_tags() +{ + count=1 + for line in $(/usr/bin/bootparams 2>/dev/null | grep "^[a-z0-9_]*_nic" ; grep "^[a-z0-9]*_nic" ${configfile} 2>/dev/null); do + fields=(${line//=/ }) + key=${fields[0]} + if [[ $key != "admin_nic" ]] && [[ $key != "external_nic" ]] && [[ $key != "internal_nic" ]]; then + NicTagsMacs[${count}]=$(echo ${line} | sed -e 's/_nic//') + ((count++)) + fi + done +} + function get_bootparams() { count=1 @@ -265,6 +292,13 @@ END [[ -n ${NIC_external} ]] && echo "NIC_external='${NIC_external}'" [[ -n ${NIC_internal} ]] && echo "NIC_internal='${NIC_internal}'" + for tag in "${NicTags[@]}"; do + tag_fields=(${tag//=/ }) + tag_name=${tag_fields[0]} + int=${tag_fields[1]} + echo "NIC_${tag_name}='${int}'" + done + for iface in "${NetworkInterfaces[@]}"; do mac_var="Network_Interface_${iface}_MAC_Address" ipv4_var="Network_Interface_${iface}_IPv4_Address" @@ -370,6 +404,7 @@ get_live_image_buildstamp get_disks get_hostname get_nic_mappings +get_nic_tags get_network_interfaces get_bootparams