Sorry if this is the wrong forum, I could not find a more relevant forum. I'm trying to create a script that automatically resignatures a cloned datastore in Perl. I've written it in PowerCLI and have it working but I get errors when trying to use Perl. Here's the PowerShell
Connect-CIServer vcenter-server
Get-VMHost -VM test-VM | Get-VMHostStorage -RescanAllHba
$hostView = get-vmhost -VM test-VM | get-view
$dsView = get-view $hostView.ConfigManager.DatastoreSystem
$unBound = $dsView.QueryUnresolvedVmfsVolumes()
$extPaths = @()
$Extents = $dstore.Extent
foreach ($ex in $Extents) {
$extPaths = $extPaths + $ex.DevicePath
}
$res = New-Object VMware.Vim.HostUnresolvedVmfsResignatureSpec
$res.ExtentDevicePath = $extPaths
$return = $dsView.ResignatureUnresolvedVmfsVolume($res)
Here's the Perl:
Util::connect();
my $vm_views = Vim::find_entity_views(
view_type => 'HostSystem',
filter => {
'name' => qr/esx-host/
}
);
print "Rescanning all HBAs to find new LUNs\n";
foreach $host (@$vm_views) {
my $storageSystem = Vim::get_view(mo_ref => $host->configManager->storageSystem);
$storageSystem->RescanAllHba();
}
$host = ${$vm_views}[0];
# Find the snap LUN and resignature it
print "Querying for unresolved VMFS volumes\n";
my $datastoreSystem = Vim::get_view(mo_ref => $host->configManager->datastoreSystem);
my @unbound = $datastoreSystem->QueryUnresolvedVmfsVolumes();
foreach my $dstore (@unbound) {
my $volume = ${$dstore}[0];
if($volume->{'vmfsLabel'} ne $vmfsLabel) {
print "Unresolved VMFS volume ".$volume->{'vmfsLabel'}." found but does not match ".$vmfsLabel."\n";
next;
}
my @extpaths;
my $extents = $volume->{'extent'};
foreach my $ex (@$extents) {
push @extpaths, $ex->devicePath;
}
my $res = bless ( {
'extentDevicePath' => [ @extpaths ]
}, 'HostUnresolvedVmfsResignatureSpec' );
print Dumper $res;
$datastoreSystem->ResignatureUnresolvedVmfsVolume(resolutionSpec => $res);
}
Util::disconnect();
This prints the following:
Rescanning all HBAs to find new LUNs
Querying for unresolved VMFS volumes
$VAR1 = bless( {
'extentDevicePath' => [
'/vmfs/devices/disks/naa.6006016083d226001cf20fdc0d27e311:1'
]
}, 'HostUnresolvedVmfsResignatureSpec' );
Undefined subroutine &HostUnresolvedVmfsResignatureSpec::serialize called at (eval 29) line 111
I've also tried with ResolveMultipleUnresolvedVmfsVolumes but I get the same error.