Automation

 View Only
  • 1.  Modify Path Policy PowerCLI syntax

    Posted Apr 04, 2011 10:08 AM

    I'm trying to find the right syntax to do the following;

    1) Connect to vCenter

    2) Select all hosts in maintenance mode

    3) Select each LUN configured to use MRU or Fixed

    4) Configure each LUN to use RoundRobin for the path selection policy

    Connect-VIServer vCenterServerName.fqdn.com

    Get-VMHost|Get-ScsiLun -LunType “disk”|where {$_.State -eq “Maintenance”}|where {$_.MultipathPolicy –ne “RoundRobin”}|Set-ScsiLun -MultipathPolicy “RoundRobin”}

    If someone could confirm the syntax for me that would be brilliant.

    The reason I want this script is because I need something simple that I can use to update a host or several at a time, that has recently been added or re-imaged to an environment where the storage Vendor recommendation is to use RR.

    Cheers,

    Paul



  • 2.  RE: Modify Path Policy PowerCLI syntax
    Best Answer

    Posted Apr 04, 2011 10:59 AM

    The filtering of the VMhosts that are in maintenance mode should come sooner.

    Like this

    Connect-VIServer vCenterServerName.fqdn.com

    Get-VMHost | where {$_.State -eq “Maintenance”} | `
        Get-ScsiLun -LunType "disk" |where {$_.MultipathPolicy –ne "RoundRobin"} | `
        Set-ScsiLun -MultipathPolicy "RoundRobin"

    Disconnect-VIServer vCenterServerName.fqdn.com



  • 3.  RE: Modify Path Policy PowerCLI syntax

    Posted Apr 04, 2011 11:08 AM

    I had a feeling that was the case.

    It makes logical sense that I would first look for hosts that are in maintenance mode, rather then first look for disks of a certain type.

    Thank you very much.

    One more question if I may;

    I'm worried that this script might change settings for the locally attached ESXi OS disks and/or the HBA, are my fears unfounded?

    Regards,

    Paul



  • 4.  RE: Modify Path Policy PowerCLI syntax

    Posted Apr 04, 2011 11:24 AM

    No, no, your fear is founded.

    But you can limit the LUNs by adding the HBA parameter and only report on FibreChannel HBAs

    Connect-VIServer vCenterServerName.fqdn.com

    Get-VMHost|where {$_.State -eq “Maintenance”} | `

         Get-ScsiLun -LunType "disk" -Hba (Get-VMHostHba -Type "FibreChannel") | `
        where {$_.MultipathPolicy –ne "RoundRobin" | `
        Set-ScsiLun -MultipathPolicy "RoundRobin"

    Disconnect-VIServer vCenterServerName.fqdn.com


  • 5.  RE: Modify Path Policy PowerCLI syntax

    Posted Apr 04, 2011 12:22 PM

    Again, my thanks. I really appreciate your input very much.



  • 6.  RE: Modify Path Policy PowerCLI syntax

    Posted Apr 04, 2011 12:35 PM

    Hmmm

    Would it be bad to also use RR to your local disks?

    Does it matter? (i mean when theres only 1 path)

    Regards

    Tyler 



  • 7.  RE: Modify Path Policy PowerCLI syntax

    Posted Apr 04, 2011 12:47 PM

    Good point. At the very least it would be a non standard configuration.

    I prefer for my implementations to stay as close to vanilla or standard as possible unless otherwise required.