-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck_3par-AluaRule.ps1
68 lines (57 loc) · 2.43 KB
/
check_3par-AluaRule.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<#
.SYNOPSIS
Script to check for the existence of a 3PAR ALUA rule on ESXi hosts
.DESCRIPTION
The script connects to a vCenter to get a list of ESXi hosts and then
connects to each of these to create an ESXCLI object which is used
to check for the existence of a custom 3PAR VMW_SATP_ALUA rule
.COMPONENT
The script requires the VMware PowerCLI module which can be installed from the PSGallery
.NOTES
Author: Rudi Martinsen / Intility AS
Created: 02/05-2017
Version: 1.0.1
Revised: 03/05-2017
.LINK
#Add custom SATP claimrule for HP 3PAR to ESXi - vcloudnine.de
https://www.vcloudnine.de/add-custom-satp-claimrule-for-hp-3par-to-vmware-esxi/
.LINK
#Automating the 3PAR ESXi SATP Rule Creation - virtuallyhyper.com
http://virtuallyhyper.com/2013/10/automating-3par-satp-rule-creation-powercli/
.PARAMETER VCenter
VCenter to connet to
.PARAMETER Cluster
Cluster to get hosts from
.PARAMETER RootPass
Password of ESXi Root user
#>
param ($VCenter,$Cluster)
$RootPass = (Read-Host -Prompt "Please type password of ESXi Root user" -AsSecureString)
Connect-VIServer $VCenter
if($Cluster){
$vmhosts = Get-Cluster $Cluster | Get-VMHost -Server $vcenter | Where-Object {$_.PowerState -eq "PoweredOn"}
}
else{
$vmhosts = Get-VMHost -Server $vcenter | Where-Object {$_.PowerState -eq "PoweredOn"}
}
Disconnect-VIServer $vcenter -Confirm:$false
#$RootPass = "Password here"
$Pass = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($RootPass))
$outTbl = @()
foreach($vmhost in $vmhosts){
Connect-VIServer $vmhost -Username root -Password $Pass | Out-Null
$esxcli = Get-EsxCli -V2 -VMHost $vmhost.Name
$rule = $esxcli.storage.nmp.satp.rule.list.Invoke() | where {$_.description -like "*3par*"}
Disconnect-VIServer $vmhost.Name -Confirm:$false
$output = [PSCustomObject]@{
HostName = $vmhost.name;
RuleName = $rule.Name;
PSP = $rule.DefaultPSP;
RR_IOPS = $rule.PSPOptions;
ClaimOptions = $rule.ClaimOptions;
}
$outTbl += $output
#Command for setting the rule, could be added if it not exists
#$esxcli.storage.nmp.satp.rule.add($null,"tpgs_on","HP 3Par Custom Rule",$null,$null,$null,"VV",$null,"VMW_PSP_RR","iops=1","VMW_SATP_ALUA",$null,$null,"3PARdata")
}
$outTbl | Format-Table