VMware Cloud Community
xlpnycm
Enthusiast
Enthusiast
Jump to solution

VMWARE-CMD Windows RCLI Question

Hi, all

I'm trying to SUSPEND/START Virtual Machines using the VMWARE-CMD.pl perl script from a Windows Station that has the last version of VI Remote Client installed (3.5 Build 104314).

The utility works OK, I'm able to connect to my ESX Hosts, and issue various commands. I'm able to stop/suspend/start VMs, but the problem is that I want to do it as part of an unattended script, and here comes the problem: the script always asks for username / password, waiting for input.

As far as I have read the documentation, it's possible to issue a command where you specify authentication params:

vmware-cmd.pl --server server.mydomain.com -U user -P password -l (p.e.,Works OK, The script doesn't stop asking for user and password)

working with VMs, I issue:

vmware-cmd.pl /vmfs/volumes/VMFS01/TESTVM/TESTVM.vmx suspend Trysoft (The script asks me for user and password, and then it does the job OK)

But if I try to combine the preceding orders, Here comes my surprise:

vmware-cmd.pl --server server.mydomain.com -U user -P password /vmfs/volumes/VMFS01/TESTVM/TESTVM.vmx suspend Trysoft

I expected the command to do all the work, but no way, I get the usage screen of VMWARE-CMD

Is there any way to do it??

Any comments would be greatly appreciated

Thanxalot

Reply
0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

Here's the document that should really help you out, if you can't define environment variables like in Linux then you can use something called a "sessionfile" that prompts for the username/password once and creates a temporaily cookie auth file and you can base it around using that sessionfile before executing the common set of tasks across set of ESX 3.5 or ESXi hosts.

http://www.vmware.com/pdf/vi3_35/esx_3/r35u2/vi3_35_25_u2_rcli.pdf

View solution in original post

Reply
0 Kudos
8 Replies
lamw
Community Manager
Community Manager
Jump to solution

Okay, so you have 2 Options, you can either provide the username/password in the script OR you can store this data in a metafile called ".visdkrc".

Option 1) Well you're actually passing in the wrong flags I believe, it should be --server=<server> --username=<username> --password=<password> and that should work

Option 2) If you run any of the RCLI commands like "vmware-cmd" or "esxcfg-" or "vicfg-*" or "svmotion" or "vifs" you'll get the list of flags that's associated with that command but you'll also be provided with special variables like VI_SERVER, VI_USERNAME, VI_PASSWORDetc. What you can do is store this information within a file named ".visdkrc", and for me I store it on my Linux home directory where I only have read access to the file and this allows you to populate your username/password/sdk port/etc and then you can do a general for loop across a set of hosts dynamically in your perl or bash script and it'll automatically try to look for this file to connect and execute your command, so instead of passing your username/password interactively you can just do "vmwware-cmd.pl /vmfs/volumes/VMFS01/TESTVM/TESTVM.vmx suspend Trysoft*"

/home/username/.visdkrc

VI_USERNAME=vcuser

VI_PASSWORD=vcpassword

Reply
0 Kudos
xlpnycm
Enthusiast
Enthusiast
Jump to solution

Thanks for your quick response & help!! Let me comment your answers:

1) No problem with the wrong flags, you can use -U or --username, -P or --password

2) I Think this is the right way, but, my problem is that i want to do it from a Windows Station (Windows Remote Client), not from LINUX, is there any way to define this flags analogous to the way you define them in Linux, on Windows??

Thanks again

Reply
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

I believe for Windows you might just have to define them in like a .bat file and create those environmental variables as you would in Linux, unfortunately I'm not too familiar with Windows RCLI but I pretty sure you can do the same. I believe VMware recently released RCLI document after they released Update 2 for ESX / VC and RCLI so that might provide you with additional information. If not, you can always download the RCLI applianance which is pre-configured in an ubuntu environment that has everything configured and allows you to SSH into the system to execute these commands.

Reply
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

Here's the document that should really help you out, if you can't define environment variables like in Linux then you can use something called a "sessionfile" that prompts for the username/password once and creates a temporaily cookie auth file and you can base it around using that sessionfile before executing the common set of tasks across set of ESX 3.5 or ESXi hosts.

http://www.vmware.com/pdf/vi3_35/esx_3/r35u2/vi3_35_25_u2_rcli.pdf

Reply
0 Kudos
xlpnycm
Enthusiast
Enthusiast
Jump to solution

Good!

Great Job, The doc point me exactly the way to do it!

Thanks for your help.

Reply
0 Kudos
Crenim
Contributor
Contributor
Jump to solution

Thanks for the great info guys.

I'm actually experiencing the exact same issue that you mention in this thread.

I have recently written a batch file that I have scheduled for kick of via my APC Powerchute UPS software....

This batch file connects to my ESXi 3.5 server and shuts down all virtual machines gracefully, puts ESXi

in maintenance mode and orders it to shut off.... I have this part of my plan working perfectly every time.

I know I cannot use the ESX 3.5 to turn on the virtual machines automatically since it was taken

down in maintenance mode (maintenance mode is mandatory since I'm using hostops.pl to perform that task)...

...so anyway, my plan has been to write another batch file that runs on my standalone windows controller

(the first box back online automatically when the power comes back).

This batch file will perform a check to verify that it was shutdown due to a power outage, and if it was, it

pauses for 5 minutes (to give the domain to fully come online), and then will power on the ESX server

(Dell PowerEdge 2950, power up via command line script through the DRAC card).. give it time

to boot, exit maintenance mode, and bring up the vms in the correct order...

Anyway.. long intro... but none the less, I cannot get the vmware-cmd.pl command that I need

to use to power on my virtual machine to work without prompting for a password.

I started testing with the following command:

vmware-cmd.pl --server ard1esx01.crls.local --username testuser --password testpassword -l

...works perfectly.

So I try

vmware-cmd.pl --server ard1esx01.crls.local --username testuser --password testpassword /vmfs/volumes/48b2f596-da8a1b96-c455-001ec9593566/ard1nav01/ard1nav01.vmx start

....no go... It just outputs a listing of the commands for the script..

So just for giggles.. I try

vmware-cmd.pl --server ard1esx01.crls.local /vmfs/volumes/48b2f596-da8a1b96-c455-001ec9593566/ard1nav01/ard1nav01.vmx start

I enter my user name and password when prompted... works just fine.... so I decided to try one more thing.

vmware-cmd.pl --server ard1esx01.crls.local --username testuser /vmfs/volumes/48b2f596-da8a1b96-c455-001ec9593566/ard1nav01/ard1nav01.vmx start

I enter my password when prompted (user name is in the command)... works fine.

So... all I have been able to determine is that with Windows RCLI, vmware-cmd.pl will NOT properly accept a password within the command.

I ran across this thread and after reading it, decided to give the sessionfile method a try.... but even after properly creating the session file,

running the vmware-cmd.pl --sessionfile command does not appear to actually read the session file (it still prompts me for host, user,

and password even through it's in the session file.)

I'm at a complete loss.

I'm trying to avoid having to enable SSH on the ESXi server and do this with scripted SSH. Any ideas anyone?

Apologies for my verboseness.

Reply
0 Kudos
xlpnycm
Enthusiast
Enthusiast
Jump to solution

FYI,

Hi, Sorry .... I was on Holidays

Don't Know if You have already solved your issue.

My particular problem, was using the parameter 'trysoft'; it always asked me for user & password:

vmware-cmd.pl -U root -P password -H myhost /vmfs/volumes/VMFS02/TEST/TEST.vmx suspend trysoft

Asks for user & password!! But,

vmware-cmd.pl -U root -P password -H myhost /vmfs/volumes/VMFS02/TEST/TEST.vmx suspend soft

Works Correctly!

I suppose this is a bug in the script ...

Hope this helps!

Regards.

Reply
0 Kudos
Evolution40
Contributor
Contributor
Jump to solution

I know this post is old, but I'm am trying to create the exact same batch file as the one you mention here.

"This batch file connects to my ESXi 3.5 server and shuts down all virtual machines gracefully, puts ESXi

in maintenance mode and orders it to shut off...."

Any chance you could let me see the syntax for your batch file? I have been pounding my head against the wall trying to figure out your solution thanks!

Reply
0 Kudos