Wednesday, March 28, 2012

The power of the esxcli command in Esxi 5

The esxcli continues go grow as new versions of esxi and vsphere are introduced.
This command can be executed inside the esxi host (via ssh or the esxi shell) or remotely
using the vcli by adding the --server flag.

Here are some examples of the power of this command:

1. List how many nfs mounts exist.

# esxcli storage nfs list

2. Get information about fcoe adapters and cards

# esxcli fcoe nic list
# esxcli fcoe adapter list

3. Get information about installed packages

# esxcli software vib list

4. Find out how much memory exist on your esxi server

# esxcli hardware memory get

5. Find out how many cpus exist on your esxi server

# esxcli hardware cpu list

6. Find out the name of your iscsi adapter

# esxli iscsi adapter list

7. Find out how many physical nics exist

# esxcli network nic list

8. Find out the state of your firewall

# esxcli network firewall get
# esxcli network firewall ruleset list

9. Find out information about your vmfs file systems

# esxcli storage vmfs extent list

10. Find out the version of esxi

# esxcli system version list

How to query a virtual machine from the command line

To quickly get information, an administrator can use the vim-cmd vmsvc/get.summary command:

Here are some examples:

Step # 1: Get information about all the existing vms and select the identifier of one of them

# vim-cmd vmsvc/getallvms

Step # 2: Find out how many cpus a virtual machine has

# vim-cmd vmsvc/get.summary 1 | grep numCpu

Step # 3: Find out how much memory was allocated to a virtual machine

# vim-cmd vmsvc/get.summary 1 | grep memorySize

Step # 4: Find out if vmware tools is installed

# vim-cmd vmsvc/get.summary 1 | grep toolsStatus

Step # 5: Find out how many network cards were allocated to a virtual machine

# vim-cmd vmsvc/get.summary 1 | grep numEthernetCards

Step # 6: Find out how many virtual disks a virtual machine has

# vim-cmd vmsvc/get.summary 1 | grep numVirtualDisks

Step # 7: Find out if a virtual machine has a cpu reservation

# vim-cmd vmsvc/get.summary 1 | grep cpuReservation

Step # 8: Find out if a virtual machine has a memory reservation

# vim-cmd vmsvc/get.summary 1 | grep memoryReservation

Step # 9: Find out the name of a virtual machine

# vim-cmd vmsvc/get.summary 1 | grep name

Step # 10: Find out if the virtual machine has been configured for fault tolerance

# vim-cmd vmsvc/get.summary 1 | grep faultTolerance

Wednesday, March 14, 2012

How to prepare a Linux iscsi server for Esxi testing

To prepare an iscsi server for esxi testing, one can use linux very easily.

Here are the steps. In this example, the boot drive is partitioned during the install and the
partition to make available for esxi testing is slice/partition 6 on the boot drive (/dev/sda).
In this example, Chap (authentication) is not used.

Steps:

1. Install the iscsi packages into your ubuntu desktop.

$ sudo apt-get update
$ sudo apt-get install iscsitarget open-iscsi

2. Edit the /etc/default/iscsitarget and enable the iscsi functionality

$ sudo echo ISCSITARGET_ENABLE=true > /etc/default/iscsitarget

3. Edit the /etc/ietd.conf file (ietd=iscsi enterprise target daemon) and specify what to share.

$ sudo vi /etc/ietd.conf
TARGET iqn.2012-03.com.example:share1
Lun 0 Path=/dev/sda6,Type=fileio

4. Reboot the desktop to start the iscsi functionality

$ sudo reboot

5 Verify that iscsi is running and the partition is shared

$ sudo iscsiadm -m discovery -t st -p your_ip_here

That is all is needed.

How to prepare an nfs server in Linux for Esxi

If one needs to create an nfs server to test esxi, all one needs is a linux nfs server.
Some people prefer freenas or openfiler, others simply use solaris, hpux and so forth.

Here, I prepared an nfs server using ubuntu linux. Plain ubuntu linux, desktop edition.

Steps:

1. Install the nfs server packages to turn your desktop into an nfs server.

$ sudo apt-get update
$ sudo apt-get install nfs-kernel-server

2. Prepare a directory to be shared. For testing, allow anybody to mount it and write into it.

$ sudo mkdir /share1
$ sudo chmod 777 /share1

3. Edit the /etc/exports file to share the directory share1 with everybody

$ sudo echo /share1 * >> /etc/exports
$ cat /etc/fstab

4. Start the nfs daemons and verify that nfs is working

$ sudo /etc/init.d/nfs-kernel-server start
$ sudo showmount -e

That is it; this is all it takes.