Advertisement

news | articles | utilities | resources | about

News

displayName != Name on disk

On a couple occasions, I've run into ESX hosts that have died and haven't either had HA enabled, or HA working. So while I could see all of the guests on the ESX host through vCenter ( they show as disconnected ). I still had to go and manually register those VMs ( using the VIC datastore browser, or the vmware-cmd command ). What really sucks in this situation though is locating the VMs when you have a large number of datastores, what sucks even more is if the VM's display name doesn't match the name of the folder on the filesystem. You can still find the VMs by glancing at the .vmx for the VM and looking for the displayName attribute, but it's easier to keep on top of things by having the VMs named correctly on the filesystem. I wrote a quick script to compare the displayName to the name of the folder on the filesystem and then spit out the ones which don't match. To correct this you can use Storage VMotion, or a cold migration to move the VM from one datastore to another. If neither of those options are available, you can do a manual rename, though I don't encourage anyone to do that because there are a number of files that you need to rename to make that work. Script below:



#!/usr/bin/perl -w

use VMware::VIRuntime;

my $username = 'vi_username';
my $password = 'vi_password';
my $url = 'https://vcenter.yourdomain.com/sdk';

Vim::login( service_url => $url, user_name => $username, password => $password );

my $vms = Vim::find_entity_views(
view_type => 'VirtualMachine',
);


foreach my $vm ( @$vms ){
my $path = $vm->summary->config->vmPathName;
my $name = $vm->name;
$_ = $path;

# example syntax for $path [datastore] /.vmx
m/\[.+\]\s(.+)\//;

# Print out the VMs who have a folder that doesn't match their displayName
unless ( $name eq $1 ){
print "Mismatch: $name -> $1\n";
}

}

Labels: displayName Storage VMotion datastore sanity

Posted by Dominic Rivera at Wednesday, June 17, 2009.


Archives

10/01/2006 - 11/01/2006 | 03/01/2007 - 04/01/2007 | 04/01/2007 - 05/01/2007 | 05/01/2007 - 06/01/2007 | 06/01/2007 - 07/01/2007 | 07/01/2007 - 08/01/2007 | 09/01/2007 - 10/01/2007 | 10/01/2007 - 11/01/2007 | 11/01/2007 - 12/01/2007 | 12/01/2007 - 01/01/2008 | 01/01/2008 - 02/01/2008 | 02/01/2008 - 03/01/2008 | 03/01/2008 - 04/01/2008 | 04/01/2008 - 05/01/2008 | 05/01/2008 - 06/01/2008 | 06/01/2008 - 07/01/2008 | 08/01/2008 - 09/01/2008 | 09/01/2008 - 10/01/2008 | 10/01/2008 - 11/01/2008 | 03/01/2009 - 04/01/2009 | 06/01/2009 - 07/01/2009 |

 
Copyright © 2007 - vmprofessional. All rights reserved.