VMware Cloud Community
JasonBurrell
Enthusiast
Enthusiast

vmware-cmd.pl not case sensitive

I am trying to get the state of all virtual machines running on a host but it looks like vmware-cmd.pl on the Remote CLI does not understand case sensitive directories. For example I can do a vmware-cmd.pl -l and get this:

/vmfs/volumes/48dcf09b-1b6d5eab-70dd-001e0b5d9eec/HQLAB01/HQLAB01.vmx

/vmfs/volumes/48dcf09b-1b6d5eab-70dd-001e0b5d9eec/hqlab01/104/000104-R370-1.vmx

/vmfs/volumes/48dcf09b-1b6d5eab-70dd-001e0b5d9eec/hqlab01/105/000105-R370-2.vmx

/vmfs/volumes/48dcf09b-1b6d5eab-70dd-001e0b5d9eec/hqlab01/106/000106-R370I-1.vmx

When I try to get state of any machine with a lowercase hqlab01 i get this:

vmware-cmd.pl /vmfs/volumes/48dcf09b-1b6d5eab-70dd-001e0b5d9eec/hqlab01/104/000104-R370-1.vmx getstate

No virtual machine found

Upper case like this works fine:

vmware-cmd.pl /vmfs/volumes/48dcf09b-1b6d5eab-70dd-001e0b5d9eec/HQLAB01/HQLAB01.vmx getstate

getstate() = off

Tags (2)
Reply
0 Kudos
28 Replies
admin
Immortal
Immortal

Hmm, tried single quoting the /path/to/vmx bit?

Reply
0 Kudos
JasonBurrell
Enthusiast
Enthusiast

That did not work.

Reply
0 Kudos
lamw
Community Manager
Community Manager

Is there any reason why you can not take what "vmware-cmd -l" returns to you and run a getstate on that given VM? I would just run a for loop across all VMs and as it provides you with the path to the .vmx file, just do a getstate and then you can pretty print it or just output VM Name and State. This way you don't have to worry about the case sensitively of the command, I was always under the impression it was case sensitive.

Reply
0 Kudos
JasonBurrell
Enthusiast
Enthusiast

That is exactally what I am doing, but have the same problem when it loops through and trys to do a getstate I get the

"No virtual machine found" error.

Reply
0 Kudos
lamw
Community Manager
Community Manager

Are you doing something similar:

#!/bin/bash

IFS=$'\n'
echo -e "VM_NAME\t\tSTATE"
for i in `vmware-cmd -l`;
do
        VM_NAME=`vmware-cmd "$i" getconfig displayname | awk '{print $3}'`
        STATE=`vmware-cmd "$i" getstate | awk '{print $3}'`
        echo -e "${VM_NAME}\t\t${STATE}"
done
unset IFS

Give this a try and see if it works and if not, try doing "sh -x script.sh" to see what attributes are being passed in.

Reply
0 Kudos
JasonBurrell
Enthusiast
Enthusiast

I am using remote CLI because vmware-cmd is not on ESXi. But it is pretty much the same thing you have done.

Reply
0 Kudos
JasonBurrell
Enthusiast
Enthusiast

Yes what I am doing is similar but it is just using the remote CLI instead of on the host its self. ESXi does not have vmware-cmd so I cannot use the script you put down.

Reply
0 Kudos
JasonBurrell
Enthusiast
Enthusiast

Yes it is a similar script but I have to use the remote CLI instead of the host console because I am using ESXi.

Reply
0 Kudos
JasonBurrell
Enthusiast
Enthusiast

Yes it is a similar script but I have to use the remote CLI instead of the host console because I am using ESXi.

Reply
0 Kudos
JasonBurrell
Enthusiast
Enthusiast

Yes it is a similar script but I have to use the remote CLI instead of the host console because I am using ESXi.

Reply
0 Kudos
JasonBurrell
Enthusiast
Enthusiast

Yes it is a similar script but I have to use the remote CLI instead of the host console because I am using ESXi.

Reply
0 Kudos
JasonBurrell
Enthusiast
Enthusiast

Yes it is a similar script but I have to use the remote CLI instead of the host console because I am using ESXi.

Reply
0 Kudos
sdelmas
Contributor
Contributor

Did you ever figure this out? I am running into the exact same problem... I am taking the exact output from the vmware-cmd.pl script and put it into the subsequent call to vmware-cmd.pl, and still I get "No virtual machine found"... for eaxample:

/vmfs/volumes/483411be-874070d6-23e8-001d09709fa3/VM/39854/039854-aeolus-w2k3.vmx (this is the output from the -l invocation)

vmware-cmd.pl -H vmconsole1.electric-cloud.com -U root -P password /vmfs/volume/483411be-874070d6-23e8-001d09709fa3/VM/39854/039854-aeolus-w2k3.vmx getstate

No virtual machine found

I tried with quotes around the .vmx file name (which shold not make any difference as there are no spaces in the path), and that indeed did't change anything. If I log in to the server I can do an ls on the file and it's there, with proper permissions... the server is a Linux box.

Thanks,

Sven

Reply
0 Kudos
JasonBurrell
Enthusiast
Enthusiast

I never got it to work. I think it is just a bug. Does anyone know where I can file this so we can have this resolved?

Reply
0 Kudos
sdelmas
Contributor
Contributor

I believe my problem was probably different than yours... (sorry for cluttering the thread). I traced this down to this scenario/issue:

I am using the vmware-cmd.pl remote access feature. When I issue the command on the local ESX server the getstate works just fine. If I do it remotely it fails with the aforementioned error. What it comes down to is this code in vmware-cmd.pl (well... actually the functions that are being called):

my $vm_cfg_path = generate_cfg_path($cmdarray[0]);

my $vm_view;

if (defined $vm_cfg_path) {

$vm_view = get_vm($vm_cfg_path);

}

As the function name suggests, generate_cfg_path generates the path to the configuration. In the remote case, the get_vm call does not actually append the actual configuration file name (the one with the .vmx). I haven't looked into why that happens, but the function returns just the original path and then things fail. If I pass in the already resloved name as "[Volume] VM/12345/vmwconfig.vmx" then things work fine.

Looks like a name lookup issue in vm_view, and a lack of testing this tool in remote mode. Another workaround would be to take the tail of the original cmdarray[0] (after the last /) and append that to $vm_view if it is identical to $vm_cfg_path.

Thanks,

Sven

Reply
0 Kudos
lamw
Community Manager
Community Manager

I assume you're passing in the fullpath to the .vmx to the command in either of these formats:

/vmfs/volumes/somedatastorename/my_vm.vmx

or

\[somedatastorename\] my_vm/my_vm.vmx

If that's the case, then it "should" function like version on the Service Console

=========================================================================

--William

VMware ESX/ESXi scripts and resources at:

Reply
0 Kudos
sdelmas
Contributor
Contributor

Yes... I am passing the exact path in that is returned by vmware-cmd.pl. The exact same command works fine on the local esx server. In my case that would be the absolute file system path. One thing that may confuse thinks for vmware-cmd.pl (not sure... I haven't looked into the underlying code), is that the server is linux, while the client is windows. Nevertheless... using the already resolved name as "[Volume] blah/blah.vmx" works fine remotely, so something with the finding of the vmx file seems to be messed up.

If you want me to run any debugging code I am happy to do that...

Thanks,

Sven

Reply
0 Kudos
lamw
Community Manager
Community Manager

I'm using VMware VIMA and the RCLI and it works fine:

[vi-admin@vima-primp-industries ~]$ vmware-cmd.pl /vmfs/volumes/48c3a8cb-92b015b9-de33-003048670886/VIMA/VIMA.vmx getstate --server himalaya.primp-industries.com
Enter username: root
Enter password:
getstate() = on[vi-admin@vima-primp-industries ~]$

Are you using the latest RCLI, on Windows or Linux? I would highly recommend VIMA to manage your hosts and automate scripted tasks/queries

=========================================================================

--William

VMware ESX/ESXi scripts and resources at:

Reply
0 Kudos
sdelmas
Contributor
Contributor

I am using VMWareVIRemoteCLI on Windows... I take it VIMA is your appliance VM? Can't use that because I need to collect that info on a machine that also has other infrastructure information available. Or is there a different set of CLI tools? If yes, please send me the link for the download.

Thanks,

Sven

Reply
0 Kudos