DCAS-#004 (vCLI and Session Files)

Yesterday, as part of my studying process, I worked with VMA and a little with vCLI.

During working with VMA, I tried and worked with “vilogger” which acting as syslog server for centralizing the logs from different hosts, as VMware ESXi would be the only option from next edition, working with VMA and knowing how to gather log from ESXi is important.

Other command I worked with was “save_session” which is using for saving information of sessions (server name/ip, username, password, …) and “vicfg-xxxxxx –sessionfile” for sure; most of “vicfg” series command have the ability of pointing to these session files.

As I worked with sessions in VMA, I really liked the idea and thought with myself if we can use these session with vCLI as well.

I check some “vicfg” commands on my laptop and there was the same structure, most of them (at least all I checked) supported session files and one reason for this can be that “vicfg” command in VMA are came from vCLI installed in it.

So I create 5 session file on my VMA and test all of them then copied these files from VMA using WinSCP to my system and run “vicfg-nics.pl” for test while pointing to my first session files.

Well,it works fine, so I tested another session file, but unfortunately other 4 session file was not working at all; as long as those 4 session worked on VMA but not on my system and just one session file worked so I thought there must be a way to create a session on system as well as on VMA, and of course there is way, here the result of about 2 minutes search.

The path to the “save_session” or it’s better to say “save_session.pl” command is “%programfiles%VMwareVMware vSphere CLIPerlappssession

I used same structure of creating session files on VMA in order of creating 3 of them on my system and it went well with no error.
Creating session file on VMA would be like “save_session –server SRVNAME –username USRNAME –password PASS –savesessionfile SFNAME“, where SRVNAME is the full name (FQDN) or IP address of target server, USRNAME is the user account which going to be used with this session, PASS is password for the account and SFNAME is the name of session file with it’s full path; like “c:hlsvesxi41-2”.

Creating session file on vCLI would be like “save_session.pl –server SRVNAME –username USRNAME –password PASS –savesessionfile SFNAME“, where SRVNAME is the full name (FQDN) or IP address of target server, USRNAME is the user account which going to be used with this session, PASS is password for the account and SFNAME is the name of session file with it’s full path; like “c:hlsvesxi41-2”.

The only difference between VMA commands and vCLI commands is the “.pl” extension in vCLI commands and that’s because of these commands are written in perl. (up to know, I only know this difference)

After creating session files, it’s time for testing them with some command like “vicfg-nics.pl“.
Command would look like “vicfg-nics.pl –list –sessionfile Filename“, where “Filename” is the full path of the session file like “c:hlsesxi41-1”

This time, it went OK for all three session, but let me check other command for being sure about it, for example, let’s check “vicfg-vswitch.pl” with session files.
Command would look like “vicfg-vswitch.pl –list –sessionfile Filename“, where “Filename” is the full path of the session file like “c:hlsesxi41-1”

Documents:

vSphere Management Assistant 4.1 Guide
vSphere vCLI 4.1 Manual

Downloads:

vSphere Management Assistant 4.1
vSphere vCLI 4.1

Update:

I forgot to mention, for using the vCLI command in any directory (such as “c:users…” or “d:…”) I have added “%Program Files%VMwareVMware vSphere CLIbin” to windows “Path” variables so I can call any command from vCLI from any where.

2 Comments

Add a Comment

It's your kindness to leave a reply/feedback