VMWare VI3 - Sample Script to Configure VM Switches and VMotion

#!/bin/sh

  1. VI3 Server Customization v1.0
  2. Jason M. Langone
  3. Veni, vidi, vici
  4. read var1 var2
  5. echo var1 = $var1 and var2 = $var2
  6. Remove default network configuration
#
  1. Ask if internal or DMZ?
#
  1. INTERNAL BLADE VERSION =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

echo ———————————- VMotion & vSwitch Configuration —————————-
echo Enter VMotion IP Address:
read vi3vmip
echo Enter VMotion Subnet Mask:
read vi3vmsm
echo Enter VMotion Default Gateway:
read vi3vmdg
echo ———————————————————————————-
echo VMotion IP Address will be $vi3vmip
echo VMotion Subnet Mask will be $vi3vmsm
echo VMotion Default Gateway will be $vi3vmdg
echo ———————————————————————————-

#esxcfg-vswitch vSwitch0 -D “VM Network” #esxcfg-vswitch -U vmnic0 vSwitch0 #esxcfg-vswitch -U vmnic1 vSwitch0 #esxcfg-vswif -d vswif0 #esxcfg-vswitch -d vSwitch0 #service mgmt-vmware restart
echo ———————————————————————————-
echo Setting up VMotion…
echo “Setting up vMotion…” >> /root/PostInstall/PostInstall.log
echo Create VMotion Port Group…
esxcfg-vswitch vKernel -A VMotion

  1. If Internal, uncomment and comment the 131
#esxcfg-vswitch vKernel -p VMotion -v 130
esxcfg-vswitch vKernel -p VMotion -v 130
echo …DONE!
echo Configure VMotion IP Details…
esxcfg-vmknic -a VMotion -i $vi3vmip -n $vi3vmsm
esxcfg-route $vi3vmdg
echo …DONE!
echo ———————————————————————————-
  1. Setup the xxx Port Groups

echo Create Production Switch…
esxcfg-vswitch -a Production
echo …DONE!
echo Bind NICs to Production Switch…
esxcfg-vswitch Production -L vmnic1
esxcfg-vswitch Production -L vmnic2
echo …DONE!
  1. For internal blade uncomment
#echo Create VLAN100 Port Group… #esxcfg-vswitch Production -A VLAN100 #esxcfg-vswitch Production -p VLAN100 -v 100 #echo Create VLAN136 Port Group… #esxcfg-vswitch Production -A VLAN136 #esxcfg-vswitch Production -p VLAN136 -v 136
echo Create VLAN151 Port Group…
esxcfg-vswitch Production -A VLAN151
esxcfg-vswitch Production -p VLAN151 -v 100
echo Create VLAN136 Port Group…
esxcfg-vswitch Production -A VLAN136
esxcfg-vswitch Production -p VLAN136 -v 136
echo …DONE!
echo ““ >>/etc/vmware/hostd/hostsvc.xml
echo ““ >>/etc/vmware/hostd/hostsvc.xml
echo “portgroup4“ >>/etc/vmware/hostd/hostsvc.xml
echo “
“ >>/etc/vmware/hostd/hostsvc.xml
echo “
“ >>/etc/vmware/hostd/hostsvc.xml # # #portgroup4 # # #EOF
  1. Craps out

esxcfg-advcfg -s 1 /Migrate/Enable
service mgmt-vmware restart
exit 0

- Jason Langone

Posted on Jul 11, 05:26 PM by Jason Langone

Commenting is closed for this article.

Commenting is closed for this article.