Hi,
here is a list of some cli’s to control a VMware ESXi host from the command line. Enable the ESXi shell and login to console or connect with a ssh client remotely.
Management
Restart Management, HA Services
/sbin/services restart
Installing Software. List/Install/Uninstall VIBs (vSphere Installation bundle)
List vibs
esxcli software vib list
Install a vib
esxcli software vib install -v file:/tmp/[NewVIB].vib
Uninstall a vib (determine the Name of the VIB by the list command)
esxcli software vib remove -n VIBname
Install a patch
esxcli software vib install /tmp/[patchName].zip
Network
firewall state
esxcli network firewall get
Firewall rules
esxcli network firewall ruleset list
Firewall activate a Ruleset, i.e. sshClient
esxcli network firewall ruleset set --ruleset-id=sshClient --enabled=true
Only allow an IP Range for the ssh daemon
esxcli network firewall ruleset allowedip add --ruleset-id sshServer --ip-address 192.168.254.0/24
List Kernel Network Interfaces
esxcli network ip interface list
List physical Network Interfaces
esxcli network nic list
Shutdown physical network interface
esxcli network nic down -n vmnic4
List routing table
esxcli network ip route ipv4 list
Add a route
esxcli network ip route ipv4 add --gateway 10.1.1.254 --network 10.1.2.0/24
To make the route persistent add the command line to a ESXi startup script. In ESXi 5.1
/etc/rc.local.d/local.sh
in ESXi <=5.0
/etc/rc.local
List arp cache
esxcli network ip neighbor list
Remove arp cache entry
esxcli network ip neighbor remove -a 10.192.10.3 -v 4
SNMP
Set Community (Communityname: MGMCOM)
esxcli system snmp set --communities MGMCOM
Set Trap destintion (IP Address Management station: 192.168.254.100)
esxcli system snmp set --targets 192.168.254.100/MGMCOM
Send test trap
esxcli system snmp test
State
esxcli system snmp get
enable IPMI as SNMP source
esxcli system snmp set --hwsrc sensors
enable CIM as SNMP source
esxcli system snmp set --hwsrc indications
Enable snmp
esxcli system snmp set --enable true
Virtual disks
extend a virtual disk, i.e. to 40GB
vmkfstools -X 40G /vmfs/volumes/datastore1/Test/test.vmdk
Convert a Workstation based virtual Disk to a VMFS Disk for use at ESXi. Disk to convert: Computer.vmdk
Rename Disk Computer.vmdk to Computer_WS.vmdk
mv Computer.vmdk Computer_WS.vmdk
Clone the disk
vmkfstools -i Computer_WS.vmdk -d zeroedthick Computer.vmdk
Destination disk format: VMFS thin-provisioned
Cloning disk 'Computer.vmdk'...
Clone: 100% done.
Remove Workstation disk
rm Computer_WS.vmdk
Note: if you have manually copied the virtual machine from a Workstation to the ESXi, remove the Computer.vmx.lck folder. Otherwise the virtual machine could not be altered. The prefered way to bring your workstation based virtual machine to an ESXi host is to you the vmware converter or use the VMware Workstation Upload function.
To be continued….in Part 2
Michael