VMware Cloud Community
pranags
Contributor
Contributor

How to find config file path for a VM

Hi All

From esx service console, is there a way to find out the location of vmx file for all the VMs ?

I see that vmware-cmd -l does this, but only with respect to the esx server.

I would like to get this info in the VI context.

It looks like vmware-cmd tool cannot connect to the Viretual center server?

Please let me know.

Thanks,

Prasad.

0 Kudos
13 Replies
admin
Immortal
Immortal

You are correct, vmware-cmd can't be pointed at a VC server. There is no way to retrieve this information with the built in tools, you need to use the SDK or do a 'find' on your VMFS volumes.

I use something like:

find /vmfs/volumes | grep .vmx\$[/code]

0 Kudos
pranags
Contributor
Contributor

Hi,

Thanks for the response.

But the VMNAME is subject to change. How can I find out the vmx for that ?

Prasad.

0 Kudos
admin
Immortal
Immortal

What do you mean? That was just an example, change to the name of the VM you are looking for.

0 Kudos
VirtualNoitall
Virtuoso
Virtuoso

Hello,

Try the following SQL command against the VCMS DB:

SELECT e.NAME, vm.DNS_NAME, vm.LOCAL_FILE_NAME

FROM VPX_VM vm LEFT OUTER JOIN

VPX_ENTITY e ON vm.ID = e.ID

It is quick and dirty so you might want to customize it to meet your needs but it gives you the general idea

0 Kudos
grasshopper
Virtuoso
Virtuoso

nice!

0 Kudos
admin
Immortal
Immortal

Here I've written a little script for you.

Usage: vm_search.sh VMNAME.

VMNAME is the name of the VM you want, and is not case sensitve.

Make sure you make the script executable with "chmod u+x".

#!/bin/bash

IFS='

'

vmname=$1

for location in `find /vmfs/volumes | grep .vmx\$ | grep -i $vmname`

do echo $location

done

0 Kudos
pranags
Contributor
Contributor

Hi,

Probably I was not clear in my question.

I want to find out the vmx location given a VM name.

I get the VM names by running the command

vcbVmName -h -u admin -p pswd -s any

There may not be any vmx file with the given name since Vm name can be changed from the VI client. Changing the VM name will not change the vmx file name.

Thanks,

Prasad.

0 Kudos
VirtualNoitall
Virtuoso
Virtuoso

Does the SQL query not give you that? simply add a line like so:

SELECT e.NAME, vm.DNS_NAME, vm.LOCAL_FILE_NAME

FROM VPX_VM vm LEFT OUTER JOIN

VPX_ENTITY e ON vm.ID = e.ID

Where e.Name = "vm_name"

0 Kudos
pranags
Contributor
Contributor

Hi,

I'm not familiar with sql. Trying to figure out how to connect to VCMS db and execute your query. Appreciate your help.

Thanks,

Prasad

0 Kudos
harryc
Enthusiast
Enthusiast

in bash shell

# find / -name \*.vmx -print[/b]

or if you are sure they are all in /vmfs/volumes

# find /vmfs/volumes -name \*.vmx -print[/b]

0 Kudos
VirtualNoitall
Virtuoso
Virtuoso

SQL2000 or SQL2005? or something else?

If SQL 2000 open up SQL query analyzer, select your VCMS db, adn then execute the query

0 Kudos
admin
Immortal
Immortal

Have a look at this script, it finds vmx files by VM display name.

http://www.xtravirt.com/index.php?option=com_content&task=view&id=100&Itemid=67

mbrkic
Hot Shot
Hot Shot

Or you can do something like:

find . -name \*.vmx -exec egrep -qi 'displayName = " is the name for the VM you are looking for.