Automation

 View Only
Expand all | Collapse all

fetches all eligible disks (unclaimed) info

  • 1.  fetches all eligible disks (unclaimed) info

    Posted Jun 25, 2023 05:05 PM

    hi guys

    please am trying to fetches all eligible disks (unclaimed) info that can be utilized to create a VSAN disk
    group.

    and  should also be able to fetch info of all the eligible disks in vcenter with details
    including Canonical Name of disk, linked Hosts.

    below is the required output i wish to get 

    Disk type (Cache disk/ Capacity disk),

    • Drive type( Flash / HDD),
    • canonical name of the disk 
    • cluster name linked to.
    • Host it is linked with.



  • 2.  RE: fetches all eligible disks (unclaimed) info
    Best Answer

    Posted Jun 25, 2023 06:14 PM

    Have a look at the PowerCLI Cookbook for VSAN, more specifically page 34.



  • 3.  RE: fetches all eligible disks (unclaimed) info

    Posted Jun 26, 2023 12:25 PM

    Thank you so much this was so helpful as i can now see most of the fields i needed, but my only problem is some of the other fields are not showing when i use 

    Get-VMHost -Name $ESXiHost | Get-VMHostHba | Get-ScsiLun | Where-Object {$_.VsanStatus -eq “Eligible”} | format-list 
     
    drivetype, disktype are messing, is there a way i can get this using powercli


  • 4.  RE: fetches all eligible disks (unclaimed) info

    Posted Jun 26, 2023 05:46 PM

    The DriveType is found in the IsSsd property.
    Not sure what you mean by DiskType



  • 5.  RE: fetches all eligible disks (unclaimed) info

    Posted Jun 26, 2023 06:30 PM

    on the isssd property is there a way i can select Disktype: (Cache disk/ Capacity disk)

    and when i say drive type this is what i mean: Drive type( Flash / HDD),



  • 6.  RE: fetches all eligible disks (unclaimed) info
    Best Answer

    Posted Jun 27, 2023 06:08 PM

    When you are looking for eligible disks, there is no indication of Cache or Capacity yet.
    That is only available for disks that are already used for VSAN.

    You can test the IsSsd property and return the desired text.
    For example, in a calculated property you could do

    Get-VMHost -Name $VMHost |
    Get-VMHostHba | Get-ScsiLun |
     Where-Object { $_.VsanStatus -eq "InEligible" } |
    Select CanonicalName,CapacityGB,MultipathPolicy,
    	@{N='Type';E={if($_.IsSsd){'Flash'}else{'HDD'}}}


  • 7.  RE: fetches all eligible disks (unclaimed) info

    Posted Jun 29, 2023 09:57 PM

    Thank you, this worked but am still finding challenges on how to know how to fetch all eligible disks (unclaimed) info using exsi and cluster.



  • 8.  RE: fetches all eligible disks (unclaimed) info
    Best Answer

    Posted Jun 29, 2023 11:25 PM

    You could do

    Get-Cluster -PipelineVariable cluster |
    Get-VMHost -PipelineVariable esx |
    Get-VMHostHba | Get-ScsiLun |
    Where-Object { $_.VsanStatus -eq "Eligible" } |
    Select @{N='Cluster';E={$cluster.Name}},
       @{N='VMHost';E={$esx.Name}}, 
       CanonicalName,CapacityGB,MultipathPolicy,
       @{N='Type';E={if($_.IsSsd){'Flash'}else{'HDD'}}}


  • 9.  RE: fetches all eligible disks (unclaimed) info

    Posted Jul 04, 2023 01:58 PM

    thank you this really worked but it print all of the disk information i just needed it to print the one attached to a particular exsi_hostname, powercli print alot of information on the screen, i wanted to print my json output so it can display on an artefact so i can easily download is there a way i can do this in powercli?



  • 10.  RE: fetches all eligible disks (unclaimed) info

    Posted Jul 04, 2023 03:32 PM

    Not sure what you mean by "to print my JSON output"?
    To limit to a specific ESXi node, drop the Get-CLuster and use the Name parameter on the Get-VMHost cmdlet.

    Get-VMHost -Name <MyEsx> -PipelineVariable esx |
    Get-VMHostHba | Get-ScsiLun |
    Where-Object { $_.VsanStatus -eq "Eligible" } |
       Select @{N='VMHost';E={$esx.Name}}, 
       CanonicalName, CapacityGB, MultipathPolicy,
       @{N='Type';E={if($_.IsSsd){'Flash'}else{'HDD'}}} |
    ConvertTo-Json


  • 11.  RE: fetches all eligible disks (unclaimed) info
    Best Answer

    Posted Jul 04, 2023 03:42 PM

     thank you LuCD, but this was what i meant Can you please rework it so that it should be able filter on ESXI host or cluster level. Module should be able to print the unclaimed disks only for that given input cluster or esxi hosts.   and also 

    i should be able to print all the invocation in the artefact output



  • 12.  RE: fetches all eligible disks (unclaimed) info
    Best Answer

    Posted Jul 04, 2023 04:19 PM

    I have no clue what "artefact output" means.
    How does that look?

    You can use a Name parameter on the Get-Cluster and Get-VMHost cmdlets, which would allow you to limit the output.



  • 13.  RE: fetches all eligible disks (unclaimed) info

    Posted Jul 04, 2023 04:41 PM

     

    I WANT AN OUTPUT LIKE THIS

    { "results": { "disk info": [ { "six hostname": "10.10.10.220", "disks": { "disk1": { "disk type": "Capacity", "drive type": "Flash", "canonical name": "t10.ATA__MZ7L3480HCHQAD3________________S6NANA0W401440", "claim state": "ineligible", "cluster": "test cluster" }, "disk2": { "disk type": "Cache", "drive type": "HDD", "canonical name": "t10.ATA__MZ7L3480HCHQAD3________________S6NANA0W40006A", "claim state": "unclaimed", "cluster": "test cluster" } } }, { "six": "1.2.3.4.5", "disks": { "disk1": { "Disk type": "Capacity", "drive type": "Flash", "canonical name": "t10.ATA__MZ7L3480HCHQAD3________________S6NANA0W401XXX", "claim state": "ineligible", "cluster": "test cluster" }, "status message": "Disk Info has been fetched Successfully.", "timestamp": "Thu Apr 20 14:58:07 UTC 2023" }, "return code": 0, "invocation": { "vSphere hostname": "vcenter.gridirontest.com" } }