Running the vmware-cmd command fails to display the datastore UUID of a virtual machine through vCenter Server in VMware vSphere Management Assistant (vMA) 5.1 and 5.5
book
Article ID: 342211
calendar_today
Updated On:
Products
VMware vCenter ServerVMware vSphere ESXi
Issue/Introduction
Symptoms:
Running the vmware-cmd command fails to display the datastore UUID of a virtual machine through vCenter Server in VMware vSphere Management Assistant (vMA) 5.1 and 5.5
When you use the vmware-cmd command to query vCenter Server, you see this information:
This issue occurs as result of how the virtual machines path to the vmx file is created for the ESXi host and vCenter Server.
Resolution
To resolve this issue, modify the vmware-cmd.pl file:
To modify the vmware-cmd.pl file:
Log in to the vMA appliance as vi-admin.
Note: Some of these commands may require elevated privileges and needs to be ran as:
sudo command
Navigate to /usr/bin/ with this command:
cd /usr/bin/
Run this command to back up the vmware-cmd.pl file with:
cp vmware-cmd.pl vmware-cmd.pl.old
Run this command to edit the current vmware-cmd.pl file with vi:
vi vmware-cmd.pl
Locate the section getconfigfile and modify this section to these:
sub getconfigfile { my ($vm_view, $vm_cfg_path) = @_; my @path_arr; my $hardlink; my @datastorearray = $vm_view->datastore; my @dsname = split(/\[|\]/, $vm_view->summary->config->vmPathName); my @temparr = split(/\] /,$vm_cfg_path); foreach my $dss (@datastorearray) { foreach my $ds (@$dss) { my $ds_view = Vim::get_view(mo_ref => $ds); if($dsname[1] eq $ds_view->summary->name) { my @url = split("/", $ds_view->info->url); my $service_content = Vim::get_service_content(); if ($service_content->about->apiType eq 'HostAgent') { $hardlink = $url[3]; } elsif ($service_content->about->apiType eq 'VirtualCenter') { if ($service_content->about->version ge '5.0.0') { my $hardlinkpos = @url; $hardlink = $url[$hardlinkpos - 1]; } else { my @hardlink = split(":", $url[2]); $hardlink = $hardlink[1]; if (!defined($hardlink)) { # bug 459802 $hardlink = $url[3]; } } } my $vmxpath = "/vmfs/volumes/".$hardlink . "/" . @temparr[1 .. $#temparr]; @path_arr = (@path_arr, $vmxpath); } } } return @path_arr; }
Save changes and exit the file.
Run the vmware-cmd command again to query the virtual machine information through vCenter Server. The information displayed now must include datastore UUID.