Microsoft Analytics Platform System Components Discovery

Microsoft.SQLServerAppliance.APS.ApplianceComponents.Discovery (Discovery)

This object discovery detects any Microsoft Analytics Platform System Components.

Knowledge Base article:

Summary

This object discovery detects all Components of particular Microsoft Analytics Platform System.

Element properties:

TargetMicrosoft.SQLServerAppliance.APS.Appliance
EnabledTrue
Frequency14400
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.SQLServerAppliance.APS.ScriptedDiscoveryProvider Default

Source Code:

<Discovery ID="Microsoft.SQLServerAppliance.APS.ApplianceComponents.Discovery" Enabled="true" Target="APSLibrary!Microsoft.SQLServerAppliance.APS.Appliance">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.Network.Adapter"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.Network.Connectivity"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.Cluster.Node"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.Cluster.ResourceGroup"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.Cluster.Resource"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.Cluster.CSV"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.Software.ApplicationHeartbeat"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.Software.NonClusteredService"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.StorageExternal.Storage"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.StorageExternal.FibreChannel"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.StorageExternal.Sas"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.StorageExternal.Disk"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.StorageExternal.StoragePool"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.StorageExternal.VirtualDisk"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.StorageInternal.Disk"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.StorageInternal.Volume"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.StorageInternal.Controller"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.Cooling.Temperature"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.Cooling.Device"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.PowerSupply.PowerSupply"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.ServerProcessing.Memory"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.ServerProcessing.Processor"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.HDI.HDInsight.HadoopService"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.HDI.HDInsight.AmbariAgent"/>
<DiscoveryClass TypeID="APSLibrary!Microsoft.SQLServerAppliance.APS.HDI.HDInsight.SqlServer"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Microsoft.SQLServerAppliance.APS.ScriptedDiscoveryProvider">
<IntervalSeconds>14400</IntervalSeconds>
<SyncTime/>
<ScriptName>APSApplianceComponentsDiscovery.vbs</ScriptName>
<Arguments>"$MPElement$" "$Target/Id$" "$Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$" "$Target/Property[Type="SSALibrary!Microsoft.SQLServerAppliance.Appliance"]/ApplianceID$" "$Target/Property[Type="APSLibrary!Microsoft.SQLServerAppliance.APS.Appliance"]/NetworkAddress$" "$Target/Property[Type="APSLibrary!Microsoft.SQLServerAppliance.APS.Appliance"]/TdsAddress$"</Arguments>
<ScriptBody><Script>Option Explicit
SetLocale("en-us")
' Eventlog EventID for all errors generated by scripts
Const SCRIPT_EVENT_ID = 4320

' This string will be appended to the beginning of first Event description parameter (Params/Param[1])
' Use &lt;RegExExpression /&gt; to narrow alerts to this MP only
Const MANAGEMENT_PACK_ID = "SQL2012APS MP"

Dim USE_EVENT_LOG, USE_ERROR_LOG

Const DEBUG_MODE = False
Const DEBUG_SCRIPT_EVENT_ID = 4201

USE_EVENT_LOG = true
USE_ERROR_LOG = false

Const ManagementGroupName = "$Target/ManagementGroup/Name$"
Dim sApplianceID
sApplianceID = ""

Sub LogWarning(ByVal customMessage)
Dim logger
Set logger = new ScriptLogger
logger.LogWarning(customMessage)
End Sub

Sub HandleWarning(ByVal customMessage)
Dim logger
If Err.number &lt;&gt; 0 Then
Set logger = new ScriptLogger
logger.LogWarning(customMessage)
End If
End Sub

Sub HandleError(ByVal customMessage)
Dim logger
If Err.number &lt;&gt; 0 Then
Set logger = new ScriptLogger
logger.LogError(customMessage)
If Not USE_ERROR_LOG Then
Wscript.Quit 0
Else
Wscript.Quit 1
End If
End If
End Sub

Sub HandleErrorInMonitoring(ByVal customMessage, ByRef oBag, ByRef oAPI)
Dim logger
If Err.number &lt;&gt; 0 Then
Set logger = new ScriptLogger
logger.LogError(customMessage)
Call oAPI.Return(oBag)
Wscript.Quit 0
End If
End Sub

Sub HandleErrorInDiscovery(ByVal customMessage, ByRef oDiscovery, ByRef oAPI)
Dim logger
If Err.number &lt;&gt; 0 Then
Set logger = new ScriptLogger
logger.LogError(customMessage)
oDiscovery.IsSnapshot = false
HandleDebugMessage("Discovery: IsSnapshot = false")
oAPI.Return(oDiscoveryData)
Wscript.Quit 0
End If
End Sub

Sub HandleNonCriticalErrorInDiscovery(ByVal customMessage, ByRef oDiscovery)
Dim logger
Set logger = new ScriptLogger
logger.LogError(customMessage)
oDiscovery.IsSnapshot = false
HandleDebugMessage("Discovery: IsSnapshot = false")
End Sub

Sub HandleDebugMessage(ByVal debugMessage)
Dim logger
Set logger = new ScriptLogger
logger.LogDebug(debugMessage)
End Sub


Const ERROR_EVENT_TYPE = 1
Const WARNING_EVENT_TYPE = 2
Const INFO_EVENT_TYPE = 4

Class ScriptLogger
Dim sourceLogEvent
Dim oAPI

Private Sub Class_Initialize()
sourceLogEvent = MANAGEMENT_PACK_ID
If (sApplianceID &lt;&gt; "") Then
sourceLogEvent = sourceLogEvent &amp; ". Appliance: " &amp; sApplianceID
End If
sourceLogEvent = sourceLogEvent &amp; ". Script: " &amp; WScript.ScriptName
Set oAPI = CreateObject("MOM.ScriptAPI")
End Sub

Private Function LogEvent(ByVal message, ByVal eventType, ByVal scriptEventID)
On Error Resume Next
Call oAPI.LogScriptEvent(sourceLogEvent, scriptEventID, eventType, message)
End Function

Public Function LogDebug(ByVal message)
if DEBUG_MODE Then
WScript.StdOut.WriteLine message
Call oAPI.LogScriptEvent(sourceLogEvent, DEBUG_SCRIPT_EVENT_ID, INFO_EVENT_TYPE, message)
End If
End Function

Public Function LogWarning(ByVal customMessage)
Dim message
If Err.number &lt;&gt; 0 Then
message = Replace(" Error Number: #P1# " &amp; VbCrLf &amp; " Description: #P2# ", "#P1#", CStr(Err.number and 65535) )
message = Replace(message, "#P2#", Err.Description )
message = customMessage &amp; VbCrLf &amp; message &amp; VbCrLf
Else
message = customMessage &amp; VbCrLf
End If

if DEBUG_MODE Then
WScript.StdOut.WriteLine message
End If
LogEvent message, WARNING_EVENT_TYPE, SCRIPT_EVENT_ID
End Function

Public Function LogError(ByVal customMessage)
Dim message
If Err.number &lt;&gt; 0 Then
message = Replace(" Error Number: #P1# " &amp; VbCrLf &amp; " Description: #P2# ", "#P1#", CStr(Err.number and 65535) )
message = Replace(message, "#P2#", Err.Description )
message = customMessage &amp; VbCrLf &amp; message &amp; VbCrLf
Else
message = customMessage &amp; VbCrLf
End If

If DEBUG_MODE Then
WScript.StdOut.WriteLine message
End If

If USE_EVENT_LOG Then
LogEvent message, ERROR_EVENT_TYPE, SCRIPT_EVENT_ID
End If
If USE_ERROR_LOG Then
WScript.StdErr.WriteLine message
End If
End Function

End Class

Function IsStringEmpty(ByVal sValue)
If sValue = EMPTY Or Trim(sValue) = "" Then
IsStringEmpty = true
Else
IsStringEmpty = false
End If
End Function
Const DEFAULT_SCHEMA = "[sys]"

'This class is wrapper for ADODB typical operations (Connect and Run SQL query)
Class SQLQuery
PRIVATE adodbConnection

Private Sub Class_Initialize()
On Error Resume Next
Set adodbConnection = CreateObject("ADODB.Connection")
Call HandleError("Cannot create ADODB.Connection")
End Sub

Private Sub Class_Terminate()
On Error Resume Next

'adodbConnection.State = 0 - Closed
If adodbConnection.State &gt; 0 Then
Call adodbConnection.Close()
End If

Call HandleError("Cannot close ADODB.Connection")
End Sub

'This method create and open connection to the server
'&lt;connectionString&gt; - host address to be used for connection;
Public Sub Connect(ByVal connectionString, ByVal sUser, ByVal sPass, ByVal nTimeout)
On Error Resume Next

Dim providerString, bSuccess, sDriver
bSuccess = False
Dim aSupportedDrivers : aSupportedDrivers = Array("10.0","11.0")

adodbConnection.ConnectionTimeout = nTimeout
' Since PDW allows for either SNAC 10 or 11 versions, the connection logic
' should retry for both if one failed to connect.
For Each sDriver In aSupportedDrivers
Call Err.Clear
providerString = "Driver={SQL Server Native Client " &amp; sDriver &amp; "};Server=" &amp; connectionString &amp; ";UID=" &amp; sUser &amp; ";PWD=" &amp; sPass
Call adodbConnection.Open(providerString)
If adodbConnection.State &lt;&gt; 1 Then
' Retry if connection failed with next version number
Else
bSuccess = True
Exit For
End If
Next
End Sub

'This function execute &lt;query&gt; with &lt;parameters&gt; and returns ADODB.RecordSet
'&lt;parameters&gt; must be array, and must be with the same order as sql query &lt;?&gt; paremetrs
Public Function ExecuteQueryToRecordSet(ByVal query, ByVal parameters)
Dim adodbCommand, oResults
Set adodbCommand = CreateObject("ADODB.Command")
adodbCommand.ActiveConnection = adodbConnection
adodbCommand.CommandText = query
Dim i, dataType, dataSize, parameter, length
length = UBound(parameters)
'Put parameters in to ADODB.Command
For i=0 To length
parameter = parameters(i)
dataType = GetDataTypeEnum(parameter)
dataSize = GetDataTypeSize(parameter)
adodbCommand.Parameters.Append(adodbCommand.CreateParameter("p"&amp;i, dataType, 1, dataSize, parameter)) '1 - this is adParamInput in ADODB. see http://www.w3schools.com/ado/met_comm_createparameter.asp#parameterdirenum
Next
Set ExecuteQueryToRecordSet = adodbCommand.Execute()
End Function

'returns size of string or 0 for others types
Private Function GetDataTypeSize(ByVal vValue)
If TypeName(vValue)="String" Then
GetDataTypeSize = Len(vValue)
Else
GetDataTypeSize = 0
End If
End Function

'this function returns int value of some DataTypeEnum
'values of adodb types see on http://www.w3schools.com/ado/met_comm_createparameter.asp#datatypeenum
Private Function GetDataTypeEnum(ByVal vValue)
If TypeName(vValue) = "Byte" Then
GetDataTypeEnum = 2 ' adSmallInt=2
End If
If TypeName(vValue)="Integer" or TypeName(vValue)="Long" Then
GetDataTypeEnum = 3 ' adInteger=3
End If
If TypeName(vValue)="Double" Then
GetDataTypeEnum = 5 ' adDouble=5
End If
If TypeName(vValue)="String" Then
GetDataTypeEnum = 8 ' adBSTR = 8
End If
End Function

End Class
On Error Resume Next

Dim GetComponentsQuery

GetComponentsQuery = Replace("SELECT " &amp; _
" nodes.[pdw_node_id] " &amp; _
" , nodes.[name] " &amp; _
" , groups.[group_id] " &amp; _
" , groups.[group_name] " &amp; _
" , components.[component_id] " &amp; _
" , components.[component_name] " &amp; _
" FROM " &amp; _
" {0}.[dm_pdw_component_health_status] healthStatus " &amp; _
" INNER JOIN {0}.dm_pdw_nodes nodes " &amp; _
" ON healthStatus.pdw_node_id = nodes.pdw_node_id " &amp; _
" INNER JOIN {0}.pdw_health_components components " &amp; _
" ON healthStatus.component_id = components.component_id " &amp; _
" INNER JOIN {0}.pdw_health_component_groups groups " &amp; _
" ON components.group_id = groups.group_id " &amp; _
" INNER JOIN {0}.pdw_health_component_properties properties " &amp; _
" ON healthStatus.property_id = properties.property_id " &amp; _
" AND healthStatus.component_id = properties.component_id " &amp; _
" WHERE " &amp; _
" properties.[property_name] = 'Status' " &amp; _
" GROUP BY " &amp; _
" nodes.[pdw_node_id] " &amp; _
" , nodes.[name] " &amp; _
" , groups.[group_id] " &amp; _
" , groups.[group_name] " &amp; _
" , components.[component_id] " &amp; _
" , components.[component_name] " &amp; _
" OPTION (LABEL = 'SCOM-APS-MP');", "{0}", DEFAULT_SCHEMA)

Dim oAPI, oDiscoveryData
Dim SourceID, ManagedEntityID, sPrincipalName, sNetworkAddress, sTdsAddress
Dim sUser, sPass
Dim oSqlQry

Set oAPI = CreateObject("MOM.ScriptAPI")
Call HandleError("Cannot create MOM.ScriptAPI object")

Call Main()

Sub Main()
On Error Resume Next

Dim oSecureInput
oSecureInput = Split(WScript.StdIn.ReadLine(), "@@secureseparator@@")

sUser = oSecureInput(0)
Call HandleError("Cannot read Username from SecureInput")
sPass = oSecureInput(1)
Call HandleError("Cannot read Password from SecureInput")

Dim oParams
Set oParams = WScript.Arguments

SourceID = oParams(0)
Call HandleError("Cannot read Source ID from parameters")

ManagedEntityID = oParams(1)
Call HandleError("Cannot read Managed Entity ID from parameters")

sPrincipalName = oParams(2)
Call HandleError("Cannot read Principal Name from parameters")

sApplianceID = oParams(3)
Call HandleError("Cannot read Appliance ID from parameters")

sNetworkAddress = oParams(4)
Call HandleError("Cannot read Network Address from parameters")

sTdsAddress = oParams(5)
Call HandleError("Cannot read TDS Address from parameters")

Set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityID)
Call HandleError("Cannot create Discovery Data object")

Set oSqlQry = new SQLQuery
Call oSqlQry.Connect(sTdsAddress, sUser, sPass, 60)
Call HandleErrorInDiscovery("Connection failed", oDiscoveryData, oAPI)

Call DiscoverComponents()

Call oAPI.Return(oDiscoveryData)
End Sub

' Adds containment relationship between specified Source and Target objects
Sub AddContainmentRelationship(ByVal sRealtionshipType, ByRef oSource, ByRef oTarget)
Dim oRelationship
Set oRelationship = oDiscoveryData.CreateRelationshipInstance(sRealtionshipType)
oRelationship.Source = oSource
oRelationship.Target = oTarget
Call oDiscoveryData.AddInstance(oRelationship)
End Sub

Sub DiscoverComponents()
On Error Resume Next

Dim oRecordSet
Set oRecordSet = oSqlQry.ExecuteQueryToRecordSet(GetComponentsQuery, Array())
Call HandleErrorInDiscovery("Cannot run query", oDiscoveryData, oAPI)

Dim oComponentGroup, oComponent, hComponentGroups, sGroupKey
Dim nNodeID, sNodeName, nGroupID, sGroupName, nFullComponentID, nComponentID, sComponentName

Set hComponentGroups = CreateObject("Scripting.Dictionary")
Call HandleError("Cannot create Scripting.Dictionary object")

Do While Not oRecordSet.EOF
nNodeID = oRecordSet(0)
sNodeName = ExtractDisplayName(oRecordSet(1))
nGroupID = RemoveVendorID(oRecordSet(2))

sGroupName = oRecordSet(3)
nFullComponentID = oRecordSet(4)
nComponentID = RemoveVendorID(nFullComponentID)
If nComponentID = 70100 Then
nGroupID = 60000
ElseIf nComponentID = 70300 Then
nGroupID = 10000
End If
sComponentName = oRecordSet(5)

' Create Component Group
sGroupKey = CStr(nNodeID) &amp; "-" &amp; CStr(nGroupID)
If Not hComponentGroups.Exists(sGroupKey) Then
Call CreateComponentGroup(nGroupID, oComponentGroup)
If Not IsEmpty(oComponentGroup) Then
Call hComponentGroups.Add(sGroupKey, oComponentGroup)
Call FillComponentGroupProperties(oComponentGroup, nNodeID, nGroupID, sGroupName)
Call oDiscoveryData.AddInstance(oComponentGroup)
End If
End If

' Create Component
Call CreateComponent(nComponentID, oComponent)
If Not IsEmpty(oComponent) Then
Call FillComponentProperties(oComponent, nNodeID, sNodeName, sGroupName, nFullComponentID, sComponentName)
Call oDiscoveryData.AddInstance(oComponent)
Call AddContainmentRelationship("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.ComponentGroupContainsComponent']$", hComponentGroups.Item(sGroupKey), oComponent)
End If

Call oRecordSet.MoveNext()
Loop
Call oRecordSet.Close()
End Sub

Function RemoveVendorID(ByVal nID)
Dim sID
sID = CStr(nID)
RemoveVendorID = CLng(Right(sID, Len(sID) -3))
End Function

' Extracts display name from Node or Cluster name
Function ExtractDisplayName(ByVal sFullName)
ExtractDisplayName = Mid(sFullName, InStr(sFullName, "-") + 1)
End Function

' Creates new Component Group
Sub CreateComponentGroup(ByVal nComponentGroupID, ByRef oComponentGroup)
If nComponentGroupID = 80000 Then
Set oComponentGroup = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Cluster']$")
ElseIf nComponentGroupID = 60000 Then
Set oComponentGroup = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Network']$")
ElseIf nComponentGroupID = 20000 Then
Set oComponentGroup = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.StorageExternal']$")
ElseIf nComponentGroupID = 10000 Then
Set oComponentGroup = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.StorageInternal']$")
ElseIf nComponentGroupID = 100000 Then
Set oComponentGroup = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Software']$")
ElseIf nComponentGroupID = 50000 Then
Set oComponentGroup = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Cooling']$")
ElseIf nComponentGroupID = 40000 Then
Set oComponentGroup = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.PowerSupply']$")
ElseIf nComponentGroupID = 30000 Then
Set oComponentGroup = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.ServerProcessing']$")
ElseIf nComponentGroupID = 200000 Then
Set oComponentGroup = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.HDI.HDInsight']$")
Else
oComponentGroup = Empty
End If
End Sub

' Populates ComponentGroup's properties
Sub FillComponentGroupProperties(ByRef oComponentGroup, ByVal nNodeID, ByVal nGroupID, ByVal sGroupName)
Call oComponentGroup.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sPrincipalName)
Call oComponentGroup.AddProperty("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.ComponentGroup']/ApplianceID$", sApplianceID)
Call oComponentGroup.AddProperty("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.ComponentGroup']/NodeID$", nNodeID)
Call oComponentGroup.AddProperty("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.ComponentGroup']/ID$", nGroupID)
End Sub

' Creates new Component
Sub CreateComponent(ByVal nComponentID, ByRef oComponent)
If nComponentID = 80100 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Cluster.Node']$")
ElseIf nComponentID = 80200 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Cluster.ResourceGroup']$")
ElseIf nComponentID = 80300 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Cluster.Resource']$")
ElseIf nComponentID = 80400 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Cluster.CSV']$")

ElseIf nComponentID = 60300 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Network.Adapter']$")
ElseIf nComponentID = 60400 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Network.Connectivity']$")

ElseIf nComponentID = 20100 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.StorageExternal.Storage']$")
ElseIf nComponentID = 20600 Or nComponentID = 70100 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.StorageExternal.FibreChannel']$")
ElseIf nComponentID = 21100 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.StorageExternal.Sas']$")
ElseIf nComponentID = 20800 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.StorageExternal.Disk']$")
ElseIf nComponentID = 20900 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.StorageExternal.StoragePool']$")
ElseIf nComponentID = 21000 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.StorageExternal.VirtualDisk']$")

ElseIf nComponentID = 10100 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.StorageInternal.Disk']$")
ElseIf nComponentID = 10200 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.StorageInternal.Controller']$")
ElseIf nComponentID = 10300 Or nComponentID = 70300 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.StorageInternal.Volume']$")

ElseIf nComponentID = 100100 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Software.NonClusteredService']$")
ElseIf nComponentID = 100200 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Software.ApplicationHeartbeat']$")

ElseIf nComponentID = 200100 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.HDI.HDInsight.HadoopService']$")
ElseIf nComponentID = 200200 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.HDI.HDInsight.AmbariAgent']$")
ElseIf nComponentID = 200300 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.HDI.HDInsight.SqlServer']$")

ElseIf nComponentID = 50100 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Cooling.Temperature']$")
ElseIf nComponentID = 50200 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Cooling.Device']$")

ElseIf nComponentID = 40100 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.PowerSupply.PowerSupply']$")

ElseIf nComponentID = 30100 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.ServerProcessing.Memory']$")
ElseIf nComponentID = 30200 Then
Set oComponent = oDiscoveryData.CreateClassInstance("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.ServerProcessing.Processor']$")

Else
oComponent = Empty
End If
End Sub

' Populates Component's properties
Sub FillComponentProperties(ByRef oComponent, ByVal nNodeID, ByVal sNodeName, ByVal sGroupName, ByVal nComponentID, ByVal sComponentName)
Call oComponent.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", sComponentName)
Call oComponent.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sPrincipalName)
Call oComponent.AddProperty("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Component']/ApplianceID$", sApplianceID)
Call oComponent.AddProperty("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Component']/NodeID$", nNodeID)
Call oComponent.AddProperty("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Component']/NodeName$", sNodeName)
Call oComponent.AddProperty("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Component']/GroupName$", sGroupName)
Call oComponent.AddProperty("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Component']/ID$", nComponentID)
Call oComponent.AddProperty("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Component']/ApplianceNetworkAddress$", sNetworkAddress)
Call oComponent.AddProperty("$MPElement[Name='APSLibrary!Microsoft.SQLServerAppliance.APS.Component']/ApplianceTdsAddress$", sTdsAddress)
End Sub
</Script></ScriptBody>
<SecureInput>$RunAs[Name="APSLibrary!Microsoft.SQLServerAppliance.APS.ActionProfile"]/UserName$@@secureseparator@@$RunAs[Name="APSLibrary!Microsoft.SQLServerAppliance.APS.ActionProfile"]/Password$</SecureInput>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>