<Discovery ID="PureStorage.FlashArray.PurePort.Discovery" Target="PureStorage.FlashArray.PureArray" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="PureStorage.FlashArray.PurePort">
<Property PropertyID="IQN"/>
<Property PropertyID="WWN"/>
<Property PropertyID="Portal"/>
<Property PropertyID="Name"/>
</DiscoveryClass>
<DiscoveryRelationship TypeID="PureStorage.FlashArray.ArrayPort.Relationship"/>
</DiscoveryTypes>
<DataSource ID="PSDiscovery" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>3600</IntervalSeconds>
<SyncTime/>
<ScriptName>PureStorage.FlashArray.PurePort.Discovery.ps1</ScriptName>
<ScriptBody><Script># This discovery script scans for PurePorts on the host Pure Array
# Returns discovery objects if any Ports are found.
# Should get params from PureArrayDiscovery.ps1 (see PureStorage.FlashArray.PureArray.Discovery.ps1 in UITemplate.mpx)
param($SourceId, $ManagedEntityId, $Endpoint, $Username, $Password)
function PortExits ($ports, $name) {
return ($ports | Where {$_.name -eq $name}) -ne $null
}
function Discover-PurePorts($DiscoveryBag, $ClassReference) {
# Import the SCOM PowerShell module
$StartTime = Get-Date
$ScriptName = "PurePortDiscovery.ps1"
LoadOperationsManagerModule $ScriptName
# Attempts to connect to a FlashArray given the credentials, and retrieve Port information
try {
$IgnoreCertErrors = GetIgnoreCertErrors $true
$FlashArray = New-PfaArray -EndPoint $Endpoint -UserName $Username -Password $Password -ClientName $GLOBAL:clientName -ClientVersion $GLOBAL:mpVersion -IgnoreCertificateError:$IgnoreCertErrors -HttpTimeOutInMilliSeconds 60000
} catch {
Log $ScriptName $GLOBAL:ERROR_LEVEL "Connection to array failed on these credentials. $Username. Check that the PurePowershell cmdlet is installed, and your credentials are correct. Error: $_"
exit
}
# Add property to object instance and place object in dbag
$instance = $DiscoveryBag.CreateClassInstance($ClassReference)
$instance.AddProperty("Endpoint", $Endpoint)
$instance.AddProperty("IQN", $iqn)
$instance.AddProperty("WWN", $wwn)
$instance.AddProperty("Portal", $portal)
$instance.AddProperty("Name", $name)
$DiscoveryBag.AddInstance($instance)
Log $ScriptName $GLOBAL:VERBOSE_LEVEL "Discovery script PurePort object created. $Name"
}
# Discover disabled iSCSI ports (disabled FC ports can still be retrieved by Get-PfaArrayPorts)
$iSCSINetworkInterfaces = Get-PfaNetworkInterfaces -Array $FlashArray | Where {$_.services.Contains("iscsi")}
foreach ($interface in $iSCSINetworkInterfaces) {
$name = $interface.name.ToUpper()
Log $ScriptName $GLOBAL:VERBOSE_LEVEL "Checking disabled port $name"
if (-not (PortExits -Ports $Ports -Name $name)) {
# Add property to object instance and place object in dbag
$instance = $DiscoveryBag.CreateClassInstance($ClassReference)
$instance.AddProperty("Endpoint", $Endpoint)
$instance.AddProperty("Name", $name)
$instance.AddProperty("DisplayName", $name)
$DiscoveryBag.AddInstance($instance)
Log $ScriptName $GLOBAL:VERBOSE_LEVEL "Discovery script PurePort object for disabled iSCSI created. $name"
}
}