Hi Guys,
I want to create the data store only on based on the available free disk which is remote LUN from storage and not on the local storage.
here are few google command i tried but list is getting listed with local disk also
this command list all the free disk ( including remote & local )
$disk_list=(get-view (get-vmhost -name $vmhost | Get-View ).ConfigManager.DatastoreSystem).QueryAvailableDisksForVmfs($null)
is there way to only get including remote ?
FYI--
based on the list of the disk will create loop to create the datastore hence the requirement..
Thanks
Hi Luc
Now this how i have done it.. this script will create the Datastore on free available disk for VMFS datastore only, it will not list the LocalDisk.
param(
[String] $vcenter_fqdn,
[String] $vcenter_username,
[String] $vcenter_password,
[String] $cluster_name,
[String] $datastore_name
)
Connect-VIServer -Server $vcenter_fqdn -User $vcenter_username -Password $vcenter_password
$clustername = get-cluster $cluster_name
$vmhost = Get-Cluster $clustername | Get-VMhost | Select -First 1
$disk_list=(get-view (get-vmhost -name $vmhost | Get-View ).ConfigManager.DatastoreSystem).QueryAvailableDisksForVmfs($null)
$free_disk=$disk_list | Where-Object{$_.Ssd -eq "true"}
$disk_ca=($free_disk).CanonicalName
$free_disk | foreach{
$i++
$ds_name=$datastore_name
New-Datastore -vmhost $vmhost -Name $ds_name -Path $disk_ca -Vmfs -FileSystemVersion 6
}
Even I tried below command--but list all the disk used & unused including local disk
Get-SCSILun -VMhost 192.168.200.136 -LunType Disk | Select CanonicalName,Capacity
CanonicalName Capacity
------------- --------
naa.6f47acc100000000653874730000005a
naa.6f47acc100000000653874730000005b
mpx.vmhba0:C0:T0:L0
Did you try my function in Find Free SCSI LUNs?
It uses the API to find free LUNs that are available to create a VMFS datastore.
I'm not sure what you mean by local and remote LUNs.
Or do you mean a LUN over a specific HBA?
An another option is to find the free LUNs on all the ESXi nodes, and then only use a LUN that is visible on all ESXi nodes.
Or you can use the IsLocal property on the LUNs returned by esxcli
$esxcli.storage.core.device.list.Invoke() |
where{-not $_.IsLocal} | Select Device,DisplayName
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Thanks for your reply--
Local i mean the disk on which we installed OS, that is also getting listed as disk..
and i tried your command but not getting any output for command red in color.
$esxcli = Get-EsxCli -VMHost MyEsx
$esxcli.storage.core.device.list.Invoke() |
where{-not $_.IsLocal} | Select Device,DisplayName
Thanks
My bad, I forgot to copy the V2 switch
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Thanks for your reply..
I tried your command it did not work and dont know why here is the screenshot
You didn't use the V2 switch
$esxcli = Get-EsxCli -VMHost MyEsx -V2
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc
Now this how i have done it.. this script will create the Datastore on free available disk for VMFS datastore only, it will not list the LocalDisk.
param(
[String] $vcenter_fqdn,
[String] $vcenter_username,
[String] $vcenter_password,
[String] $cluster_name,
[String] $datastore_name
)
Connect-VIServer -Server $vcenter_fqdn -User $vcenter_username -Password $vcenter_password
$clustername = get-cluster $cluster_name
$vmhost = Get-Cluster $clustername | Get-VMhost | Select -First 1
$disk_list=(get-view (get-vmhost -name $vmhost | Get-View ).ConfigManager.DatastoreSystem).QueryAvailableDisksForVmfs($null)
$free_disk=$disk_list | Where-Object{$_.Ssd -eq "true"}
$disk_ca=($free_disk).CanonicalName
$free_disk | foreach{
$i++
$ds_name=$datastore_name
New-Datastore -vmhost $vmhost -Name $ds_name -Path $disk_ca -Vmfs -FileSystemVersion 6
}