I am trying to figure out what port group a guest VM is using. So far, it appears to be impossible with the esxcli comand set. There is a command in the documentation, vsphere Command-Line Interface Concepts and Examples page 118, that appeared promising. However, ESXi 5.0 has no concept of this command. While the documentation is for 5.1, the table on page 15 states these commands are supported back to 4.x.
~ # esxcli network vm list
Error: Unknown command or namespace network vm list
Any idea why doesn't this work? Use something else is not really an option, unless there is a decent VMWare supported Python SDK.
Thanks.
Just to show esxcli sort of works.
~ # esxcli --version
Script 'esxcli' version: 5.0
~ # esxcli vm process list
Linux2Auto1
World ID: 7315
Process ID: 0
VMX Cartel ID: 7314
UUID: 42 04 a6 5e 30 62 16 81-93 d0 84 2a a4 ce 8b 32
Display Name: Linux2Auto1
Config File: /vmfs/volumes/5033e16d-4c278ebf-d220-e4115bb31b66/Linux2Auto1/Linux2Auto1.vmx
Linux1Auto1
World ID: 5440
Process ID: 0
VMX Cartel ID: 5439
UUID: 56 4d 46 8c 29 c2 f1 a3-03 4a dc a7 d2 75 d7 d5
Display Name: Linux1Auto1
Config File: /vmfs/volumes/5033e16d-4c278ebf-d220-e4115bb31b66/Linux1Auto1/Linux1Auto1.vmx
vSphere Management Assistant (vMA)
World ID: 3495
Process ID: 0
VMX Cartel ID: 3494
UUID: 56 4d 69 46 b0 19 3f da-93 71 12 87 1d 96 9d 57
Display Name: vSphere Management Assistant (vMA)
Config File: /vmfs/volumes/5033e16d-4c278ebf-d220-e4115bb31b66/vSphere Management Assistant (v/vSphere Management Assistant (v.vmx
~ # esxcli network vm list
Error: Unknown command or namespace network vm list
The "esxcli network vm" namespace is new in 5.1. If you can upgrade to the 5.1 VMA, your command should work just fine.
Here's the 5.0 doc if you're interested.
Great. Thanks. My main concern is that tests using 5.1 code will not be able to regression test earlier versions of ESX. I guess I am will try to work around that with a version check to only use the new commands with 5.1 and higher. Fortunately, as time goes by older versions are used less and less.
You bet. I'm not sure where you're adding the version check, but as long as the VMA itself is at least 5.1, the new commands are supported on hosts running ESX 4.1 or newer.
Okay. Now I am getting confused. I have found that the esxcli comands run direct on ESXi without using the vMA. The vi-cfg and vmware commands need to be run in the vMA. I was going to stop installing a vMA on hosts since I could run the esxcli comands directly on the host. Are you saying thay vMA is necessary to run esxcli commands? Even if you do not use it?
Ah, gotcha. I made an assumption when I saw the VMA messages up in an earlier post, and figured you were running all of your scripts from a VMA.
I've never tried installed/upgrading the vCLI locally to an ESX(i) host, so I'm not very familiar with the behavior. If you can't get the vCLI 5.1 to work locally, the VMA 5.1 may be a viable workaround, as it supports remoting to hosts 4.1-5.1 and contains the 5.1 vCLI, with the namespaces you need.
Here's a post by VMware that may or may not clear things up.
ESXCLI is available as both a local CLI on the ESXi Shell (SSH or via Console) as well as remote CLI. The syntax to the command is exactly the same whether you execute it locally on a single ESXi host or remotely (where you can authenticate centrally against a vCenter Server) with the only difference that you need to supply credentials when you're calling it remotely. The nice thing about ESXCLI compared to the legacy esxcfg-*/vicfg-* commands is that it's dynamic in nature based on the features available from the server. When you run ESXCLI connecting remotely, it will show you the available namespaces and hence if you're running an older version of ESXi, you will not see the new namespaces in ESXCLI such as the one you asked about earlier in the start of this thread.
The remote ESXCLI is bundled as part of the vCLI which are just remote Perl scripts that you can connect to either an ESXi host or proxy against vCenter Server. vMA is just a Linux appliance that is pre-installed with the vCLI which includes ESXCLI for easy of use/convience. It is not needed to manage/configure your vSphere environment but great way for new users to quickly get started.
vCLI can be install on a variety of systems Windows & Linux, so if you already have your own management systems, then you can just install vCLI and you'll have access to ESXCLI. You do not need to use vMA
Hopefully this clears up any confusion.
Okay. This is getting clearer for me. I was starting to wonder if I needed to install a vMA on a host, even if I went directly to the ESXi host. Not having to install the vMA on every host does make life easier, but then again the vMA does support the older comands which do give a bit more versatility. Thanks for all the help.
You do not need to install vMA on every host, a single vMA appliance can manage multiple ESXi hosts (it can be 1 or 10,000, it's just remote API calls to the hosts). Regarding the legacy commands, those are bundled together with the vCLI which includes ESXCLI as I mentioned earlier. Basically to manage your hosts remotely using ESXCLI and the legacy vCLI commands, you just need the vCLI package and vMA is just an appliance that has it installed for you already.
To learn more about the vCLI commands, take a look at http://www.vmware.com/support/developer/vcli/ and another useful reference is the ESXi 5.1 Reference poster (vmware.com/go/posters) which includes updated ESXCLI 5.1 commands, very useful when you're getting started or as a quick reference