MR-Z
VMware Employee
VMware Employee

Assuming your VM has multiple vmdks and they could come from different datastore...Loop through your vmdks and the naa ID can be extracted like this:

# gather all your vmdks
my $devices = $vm->config->hardware->device;
foreach (@$devices) {
    if($_->isa('VirtualDisk')) {push (@vmdks, $_);
}

foreach (@vmdks) {
my
$ds = Vim::get_view(mo_ref=>$_->backing->datastore, properties => ['info','summary']); 
if ($ds->summary->type eq 'VMFS') {
       $naa = ${$ds->info->vmfs->extent}[0]->diskName;

       # try to get the real naa if there is rdm involved here. lunUuid is a sure sign
       ($naa = $_->backing->lunUuid) =~ s/[0-9a-z]{10}(.*)[0-9a-z]{12}/naa.$1/ if defined $_->backing->{'lunUuid'};
}
}

Reply
0 Kudos