Skip to content

Instantly share code, notes, and snippets.

@jbfriedrich
Last active February 19, 2023 21:14
Show Gist options
  • Save jbfriedrich/d2dafe2b1628f24156fccb13e0750eac to your computer and use it in GitHub Desktop.
Save jbfriedrich/d2dafe2b1628f24156fccb13e0750eac to your computer and use it in GitHub Desktop.
Check if vusb0 NIC link is up and add it to vDS uplink port group (based on script from https://labs.vmware.com/flings/usb-network-native-driver-for-esxi that only supports vSS)
# Add contents to /etc/rc.local.d/local.sh
vds_name="vDS"
vds_uplink_pg="dvportgroup-82"
free_vds_uplink_port=$(esxcli network vswitch dvs vmware list | grep -A 2 "DVPortgroup ID: $vds_uplink_pg" | grep -A 1 'In Use: false' | grep 'Port ID' | awk '{print $NF}' | head -1)
vusb0_status=$(esxcli network nic get -n vusb0 | grep 'Link Status' | awk '{print $NF}')
count=0
while [[ $count -lt 20 && "${vusb0_status}" != "Up" ]] ]
do
sleep 10
count=$(( $count + 1 ))
vusb0_status=$(esxcli network nic get -n vusb0 | grep 'Link Status' | awk '{print $NF}')
done
if [ "${vusb0_status}" = "Up" ]; then
esxcfg-vswitch -P vusb0 -V $free_vds_uplink_port $vds_name
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment