I would like to increase a an existing datastore capacity using the results of the QueryAvailableDisksForVmfs function without regard to content of the resulting local disks. I could do this on the web interface but I'm trying to figure this out using PowerCLI. Any pointers on how to get started will be appreciated. Thanks.
Try with this.
It wants the datastorename and the canonicalname of the LUN you want to use as an extent.
# Target datatstore
$dsName = 'MyDS'
# Extent LUN
$targetLun = 'naa.60050768017083af1800000000000123'
$ds = Get-Datastore -Name $dsName
$esx = Get-View -Id ($ds.ExtensionData.Host | Get-Random | Select -ExpandProperty Key)
$hdsSys = Get-View -Id $esx.ConfigManager.DatastoreSystem
$hssSys = Get-View -Id $esx.ConfigManager.StorageSystem
# Get LUN of datastore (assumes only 1 Extent)
$dsLun = $hssSys.StorageDeviceInfo.ScsiLun | where{$_.CanonicalName -eq $ds.ExtensionData.Info.Vmfs.Extent[0].DiskName}
# Find extent candidates and select the one we want
$scsiDisk = $hdsSys.QueryAvailableDisksForVmfs($ds.ExtensionData.MoRef) | where{$_.CanonicalName -eq $targetLun}
# Attach extent to datastore
if($scsiDisk){
$exp = $hdsSys.QueryVmfsDatastoreExtendOptions($ds.ExtensionData.MoRef,$scsiDisk.DevicePath,$false)
$hdsSys.ExtendVmfsDatastore($ds.ExtensionData.MoRef,$exp[0].Spec)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Could you perhaps include a screenshot of what you mean in the web client?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The datastore section in the "vmware vSphere web client" under the General Settings of a datastore has a button to increase datastore capacity. I am trying to do this with Powercli. The disks I want to add to the datastore do not have any existing extents. I'm guessing a new extent will be added to the datastore? Not sure of some of the methods to use for this after running the QueryAvailableDisksForVmfs method. Thanks.
Try with this.
It wants the datastorename and the canonicalname of the LUN you want to use as an extent.
# Target datatstore
$dsName = 'MyDS'
# Extent LUN
$targetLun = 'naa.60050768017083af1800000000000123'
$ds = Get-Datastore -Name $dsName
$esx = Get-View -Id ($ds.ExtensionData.Host | Get-Random | Select -ExpandProperty Key)
$hdsSys = Get-View -Id $esx.ConfigManager.DatastoreSystem
$hssSys = Get-View -Id $esx.ConfigManager.StorageSystem
# Get LUN of datastore (assumes only 1 Extent)
$dsLun = $hssSys.StorageDeviceInfo.ScsiLun | where{$_.CanonicalName -eq $ds.ExtensionData.Info.Vmfs.Extent[0].DiskName}
# Find extent candidates and select the one we want
$scsiDisk = $hdsSys.QueryAvailableDisksForVmfs($ds.ExtensionData.MoRef) | where{$_.CanonicalName -eq $targetLun}
# Attach extent to datastore
if($scsiDisk){
$exp = $hdsSys.QueryVmfsDatastoreExtendOptions($ds.ExtensionData.MoRef,$scsiDisk.DevicePath,$false)
$hdsSys.ExtendVmfsDatastore($ds.ExtensionData.MoRef,$exp[0].Spec)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks. I just couldn't figure out the correct syntax. The last couple of lines answered my question. Only thing I did differently was loop all available disk to extend the datastore. Thanks again.