VMware Cloud Community
dumbNuts
Contributor
Contributor
Jump to solution

Trying to increase datastore capacity using available local disks

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.

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

4 Replies
LucD
Leadership
Leadership
Jump to solution

Could you perhaps include a screenshot of what you mean in the web client?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
dumbNuts
Contributor
Contributor
Jump to solution

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.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

dumbNuts
Contributor
Contributor
Jump to solution

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.

0 Kudos