Dell Windows Server Detailed NIC Physical to Teamed Link Creator

Dell.WindowsServer.Detailed.NICUnitLinkCreator.DataSource (DataSourceModuleType)

Dell Windows Server Detailed NIC Physical to Teamed Link Creator Module

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval SecondsInterval Seconds
NetConnectionIDstring$Config/NetConnectionID$Teamed Network Connection NameTeamed Network Connection Name
LogLevelint$Config/LogLevel$Log LevelLog Level
EnableCorrelationbool$Config/EnableCorrelation$Enable CorrelationEnable Physical and Teamed network interface Correlation

Source Code:

<DataSourceModuleType ID="Dell.WindowsServer.Detailed.NICUnitLinkCreator.DataSource" Accessibility="Internal">
<Configuration>
<xsd:element name="IntervalSeconds" type="xsd:integer"/>
<xsd:element name="Computer" type="xsd:string"/>
<xsd:element name="NetConnectionID" type="xsd:string"/>
<xsd:element name="LogLevel" type="xsd:integer"/>
<xsd:element name="EnableCorrelation" type="xsd:boolean"/>
<xsd:element name="TeamNicIndex" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" ParameterType="int" Selector="$Config/IntervalSeconds$"/>
<OverrideableParameter ID="NetConnectionID" ParameterType="string" Selector="$Config/NetConnectionID$"/>
<OverrideableParameter ID="LogLevel" ParameterType="int" Selector="$Config/LogLevel$"/>
<OverrideableParameter ID="EnableCorrelation" ParameterType="bool" Selector="$Config/EnableCorrelation$"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>DellWinServerNicTeamingLink.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Config/Computer$ "$Config/NetConnectionID$" $Config/LogLevel$ $Config/EnableCorrelation$ $Config/TeamNicIndex$</Arguments>
<ScriptBody><Script>

'**********************************************************************************
' Script Name - Dell Server NIC Unit Component Discovery
' Author: Vaideeswaran Ganesan
'
' Description:
' Creates the link between the Physical and Teamed NICs.
' (c) Copyright &#xA9; 2009&#x2013; 2017 Dell Inc, or its subsidiaries. All Rights Reserved
'**********************************************************************************

' Target against TeamedEnrichedNetworkInterfaceUnits only.
' Assumption: OMVersion is &gt;= 6.2.0.1.

'*********************************
' MAIN begin
'*********************************

Option Explicit
On Error Resume Next
SetLocale("en-us")

Dim oArgs
Set oArgs = WScript.Arguments
If oArgs.Count &lt; 6 Then
Wscript.Quit -1
End If

Dim sourceId, managedEntityId, targetComputer, selectedTeamName
Dim nicFlag, virnicFlag, teamNicIndex
Dim logLevel, objLogTextFile, objLogFSO, logMessage, enableTeaming

nicFlag = 0
virnicFlag = 0
sourceId = oArgs(0)
managedEntityId = oArgs(1)
targetComputer = oArgs(2)
selectedTeamName = oArgs(3)
logLevel = oArgs(4)
enableTeaming = oArgs(5)
teamNicIndex = oArgs(6)

' Begin Logheader
If logLevel &lt;&gt; 0 Then
Dim fileSize, strOutFile
Const strFileName = "DellDiscoverNICLinks.log"
Const ForAppending = 8
Const ForWriting = 2
Const MaxFileSize = 524288 'File Size is limited to 512 KB

dim wsShell : Set wsShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wsShell.Environment
dim tFolder : tFolder = wshSysEnv("TEMP")
dim wshPrcEnv : Set wshPrcEnv = wsShell.Environment("Process")
tFolder = Replace(tFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)

Set objLogFSO = CreateObject("Scripting.FileSystemObject")
If Not objLogFSO.FolderExists(tFolder) Then
objLogFSO.CreateFolder(tFolder)
End If
strOutFile = tFolder &amp; "\"&amp; strFileName
If Not objLogFSO.FileExists(strOutFile) Then
Set objLogTextFile = objLogFSO.CreateTextFile(strOutFile)
objLogTextFile.Close()
End If
fileSize = objLogFSO.GetFile(strOutFile).Size
If (fileSize &gt; MaxFileSize) Then
Set objLogTextFile = objLogFSO.OpentextFile(strOutFile, ForWriting, True)
Else
Set objLogTextFile = objLogFSO.OpentextFile(strOutFile, ForAppending, True)
End If
logMessage = "------------------------------------------------------"
MOMDebugLog 1, logMessage
logMessage = "INFO: Script - Dell Server NIC Physical-Teamed Link Discovery : Start()"
MOMDebugLog 1, logMessage
Err.Clear
End If

Sub MOMDebugLog (ByVal debugLevel, ByVal Message)
On Error Resume Next
If (debugLevel &gt; 0) and (debugLevel &lt;= logLevel) Then
objLogTextFile.WriteLine(Now() &amp; " ---- " &amp; Message)
Err.Clear
End If
End Sub
' End of Logheader

Dim oAPI, oDiscoveryData, oInst, strComputer, objDellConnection, omVer

Set oAPI = CreateObject("MOM.ScriptAPI")
set oDiscoveryData = oAPI.CreateDiscoveryData(0, sourceId, managedEntityId)
If enableTeaming = True Or LCase(enableTeaming) = "true" Then
logMessage = "INFO: enable Physical/Teamed NIC Correlation is " &amp; enableTeaming
MOMDebugLog 1, logMessage
logMessage = "INFO: Creating Links for " &amp; selectedTeamName
MOMDebugLog 1, logMessage
EnrichedPhysicalTeamedLinkDiscovery
Else
logMessage = "INFO: enable Physical/Teamed is " &amp; enableTeaming
MOMDebugLog 1, logMessage
End If
Call oAPI.Return(oDiscoveryData)
Set oDiscoveryData = Nothing
Set oAPI = Nothing

logMessage = "INFO: Script - Dell Server NIC Physical-Teamed Link Discovery : end()"
MOMDebugLog 1, logMessage
logMessage = "------------------------------------------------------"
MOMDebugLog 1, logMessage

' Close file used for logs
If logLevel &lt;&gt; 0 Then
objLogTextFile.Close
Set objLogTextFile = Nothing
Set objLogFSO = Nothing
End If

' **********************************************
' End Main
' **********************************************


'*************************************************************************
' Function : EnrichedPhysicalTeamedLinkDiscovery()
' Desc : To return Physical &amp; Teamed Links using OMSA 6.2.0.1+
' Arguments : None
'*************************************************************************
Function EnrichedPhysicalTeamedLinkDiscovery()
On Error Resume Next

Dim OMSABinPath ' Store Path from Registry key
Dim drive ' Drive letter
Dim version, regError, rc
regError = 0
' Get OMSA Lib Path
rc = GetOMABinPath(OMSABinPath, regError)
If rc &lt;&gt; 0 Then
logMessage = "GetOMSAHealth:GetOMABinPath Error"
MOMDebugLog 1, logMessage
Err.Clear
WScript.Quit()
End If
' Get Install root path
rc = GetOMInstallRoot(drive, OMSABinPath) ' return the current absolute path or the root path for the OMSA Install
If rc &lt;&gt; 0 Then
logMessage = "GetOMSAHealth:GetOMInstallRoot Error"
MOMDebugLog 1, logMessage
Err.Clear
WScript.Quit()
End If
If regError = 1 Then
logMessage = "Task Fail: OMSA not installed / OMSA Registry Value not found."
MOMDebugLog 1, logMessage
Err.Clear
WScript.Quit()
End If

Dim guid1, wintemp_path, nicFilePath
GetTempFolderPath wintemp_path, drive
GetOMReportFileGUID guid1

On Error Resume Next
Dim guid22, timer, oShell, strCommand
Const TIMEOUT = 20
GetOMReportFileGUID guid22
nicFilePath = wintemp_path &amp; "\" &amp; "niclink" &amp; guid22 &amp; ".xml"
strCommand = "cmd /C " &amp; chr(34) &amp; OMSABinPath &amp; "\" &amp; "omreport.exe" &amp; Chr(34) &amp; " chassis nics config=team index=" &amp; teamNicIndex &amp; " -fmt xml -outc " &amp; nicFilePath
Set oShell = CreateObject ("WScript.Shell")
rc = oShell.run (strCommand,0,true)
If rc &lt;&gt; 0 Then
DelFile(nicFilePath)
Err.Clear
Exit Function
End If
' Infinite Loop Until file OM_REPORT_FILE_NAME is created
timer = 0
Do While bFileExists(nicFilePath) &lt;&gt; -1
WScript.Sleep(1000)
timer = timer + 1
if (timer &gt; TIMEOUT) Then
MOMDebugLog "Exit RunCmd. Reason: OMREPORT CHASSIS NICS not responding"
Exit Do
End If
Loop
If Not bFileExists(nicFilePath) Then
logMessage = "NIC CLI XML Output File does not exist - " &amp; nicFilePath
MOMDebugLog 1, logMessage
End If

' Parse XML block
Dim xmlDoc, i, str
Dim interfaceDesc, interfaceDescVal, nicStatus, nicStatusVal


Set xmlDoc = CreateObject("Microsoft.XMLDOM")
If (IsObject(xmlDoc) = True) Then
xmlDoc.async = "false"
xmlDoc.load(nicFilePath)
If (xmlDoc.parseError.errorCode &lt;&gt; 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
logMessage = "XML Parse Error Reason: " &amp; myErr.reason
MOMDebugLog 1, logMessage
logMessage = "XML Parse Error Line: " &amp; myErr.line
MOMDebugLog 1, logMessage
logMessage = "XML Parse Error Character: " &amp; myErr.linepos
MOMDebugLog 1, logMessage
logMessage = "XML Parse Error Text: " &amp; myErr.srcText
MOMDebugLog 1, logMessage
DelFile(nicFilePath)
Exit Function
End If
Else
DelFile(nicFilePath)
logMessage = "Error: DOM object not created using CreateObject - Microsoft.XMLDOM"
MOMDebugLog 1, logMessage
End IF
Dim teamedNic, teamName
Set teamedNic = xmlDoc.SelectSingleNode("//VirNicObj")
MOMDebugLog 1, "Obtained team Nic Details."
teamName = ""

If (Not (teamedNic is Nothing)) Then
If (Not (teamedNic.SelectSingleNode("IfDescription") is Nothing)) Then
teamName = teamedNic.SelectSingleNode("IfDescription").nodeTypedValue
MOMDebugLog 1, "Team Name : " &amp; teamName
End If
End If

set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.TeamedEnrichedNetworkInterfaceUnit']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", TargetComputer)
call oInst.AddProperty("$MPElement[Name='Dell.WindowsServer.TeamedEnrichedNetworkInterfaceUnit']/NetConnectionID$", selectedTeamName)
call oDiscoveryData.AddInstance(oInst)

Dim oRelationship, oInst1
Dim teamMemberList, teamMember
Set teamMemberList = xmlDoc.getElementsByTagName("teamMemberList")
MOMDebugLog 1, "Number of Team Members : " &amp; teamMemberList.length

If ((teamName = selectedTeamName) And (Not (teamMemberList Is Nothing))) Then
For i = 0 To (teamMemberList.length - 1)
Set teamMember = teamMemberList(i)

Set interfaceDesc = teamMember.SelectSingleNode("IfDescription") 'Collecting the Interface Description for every Team Member
Set nicStatus = teamMember.SelectSingleNode("nicStatus") 'Collecting the Nic Status for every Team Member

If interfaceDesc Is Nothing Then
interfaceDescVal = ""
Else
interfaceDescVal = interfaceDesc.nodeTypedValue
End If

If nicStatus Is Nothing Then
nicStatusVal = "Not Available"
Else
nicStatusVal = nicStatus.nodeTypedValue
End If
logMessage = interfaceDescVal &amp; "," &amp; " selected=" &amp; selectedTeamName &amp; ", status=" &amp; nicStatusVal
MOMDebugLog 1, logMessage

If nicStatusVal = "4" Then
logMessage = interfaceDescVal &amp; " is disabled. Will not be monitored"
MOMDebugLog 1, logMessage
ElseIf teamName &lt;&gt; interfaceDescVal Then
set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Dell.WindowsServer.EnrichedPhysicalNIC.References.EnrichedTeamedNICUnit']$")
MOMDebugLog 1, "Linking: physical(" &amp; interfaceDescVal &amp; ") with Team(" &amp; teamName &amp; ")"
set oInst1 = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.WindowsServer.EnrichedNetworkInterfaceUnit']$")
call oInst1.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
call oInst1.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", TargetComputer)
call oInst1.AddProperty("$MPElement[Name='Dell.WindowsServer.EnrichedNetworkInterfaceUnit']/NetConnectionID$", interfaceDescVal)
call oDiscoveryData.AddInstance(oInst1)

oRelationship.Source = oInst1
oRelationship.Target = oInst
call oDiscoveryData.AddInstance(oRelationship)
End If
Next
Else
logMessage = "Either the TeamMemberList Tag is empty or Team Name does not match"
MOMDebugLog 1, logMessage
End If

' Clean up the CLI Output : Delete OM_REPORT_FILE_NAME for NICs
DelFile(nicFilePath)
Set nicFilePath = Nothing
Set strCommand = Nothing
Set oShell = Nothing
End Function

'*****************************************************************
'GetOMABinPath
'Routine to read the registry to query the OMA Install Path
'*****************************************************************
Function GetOMABinPath(o_sPath, ByRef regError)
On Error Resume Next
Dim strOMAKey
Dim oShell, tmp

Const DEF_OMSA_BIN_PATH = "C:\Program Files\Dell\OpenManage\oma\bin"
Const OMSA_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Dell Computer Corporation\Dell OMA\InstallPath"
Const OMSA64_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Dell Computer Corporation\Dell OMA\InstallPath"

Set oShell = CreateObject ("WScript.Shell")
o_sPath = ""

o_sPath = oShell.RegRead(OMSA_REG_INTALL_PATH)
If o_sPath = "" Then
o_sPath = oShell.RegRead(OMSA64_REG_INTALL_PATH)
End If
If o_sPath = "" Then
tmp = DEF_OMSA_BIN_PATH &amp; "\omreport.exe"
If(bFileExists(tmp)) Then
o_sPath = DEF_OMSA_BIN_PATH
logMessage = "GetOMABinPath - OMSABinPath is empty, Using Default Existing Path" &amp; DEF_OMSA_BIN_PATH
MOMDebugLog 1, logMessage
Else
regError = 1
End If
Else
o_sPath = o_sPath &amp; "\bin"
End If

If Err &lt;&gt; 0 Then
GetOMSABinPath = Err.Number
Err.Clear
End If
End Function

'*****************************************************************
'GetOMInstallRoot
'Routine to determine the Drive letter where OMSA is installed
'*****************************************************************
Private Function GetOMInstallRoot(ByRef path, ByVal OMSAInstallPath)
On Error Resume Next
' Return the root drive of the OMInstall Path
path = Left(OMSAInstallPath, 2)
End Function

'*****************************************************************
'bFileExists
'Routine to determine if the OMSA Report file is created
'*****************************************************************
Function bFileExists(ByVal filespec1)
On Error Resume Next
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
bFileExists = (fso.FileExists(filespec1))
Set fso = Nothing
End Function

'*****************************************************************
'DelFile
'Routine to delete the OMSA Report file
'*****************************************************************
Function DelFile(ByVal filespec2)
On Error Resume Next
Dim fso, oFile
If bFileExists(filespec2) Then
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile filespec2, True
Set fso = Nothing
End If
If Err &lt;&gt; 0 Then
DelFile = Err.Number
Err.Clear
End If
End Function

'*****************************************************************
'GetTempFolderPath
'Routine to Get Win Temp Folder path
'*****************************************************************
Function GetTempFolderPath(ByRef WinTempFolder, ByVal drive_letter)
On Error Resume Next
Dim FldrExistFlag, fso
FldrExistFlag = False
dim wshShell : Set wshShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wshShell.Environment
dim strSysTempFolder : strSysTempFolder = wshSysEnv("TEMP")
dim wshPrcEnv : Set wshPrcEnv = wshShell.Environment("Process")
strSysTempFolder = Replace(strSysTempFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)
WinTempFolder = strSysTempFolder

Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(WinTempFolder)) Then
FldrExistFlag = True
Else
FldrExistFlag = False
End If

If WinTempFolder = "" OR FldrExistFlag = False Then
WinTempFolder = drive_letter
End If

Set wshShell = Nothing
Set wshSysEnv = Nothing
Set strSysTempFolder = Nothing
Set wshPrcEnv = Nothing

If Err &lt;&gt; 0 Then
GetTempFolderPath = Err.Number
Err.Clear
End If
End Function

'*****************************************************************
'GetOMReportFileGUID
'Routine to generate unique GUIDs for OMREPORT FILE
'*****************************************************************
Function GetOMReportFileGUID(ByRef o_guid)
On Error Resume Next
Dim TypeLib, NewGUID
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
o_guid = (left(NewGUID, len(NewGUID)-2))
Set TypeLib = Nothing
End Function

'**********************************************************
' CheckVBScriptEngine()
' Check VBScript engine version:
'**********************************************************
Function CheckVBScriptEngine()
On Error Resume Next
Dim bIsCompatV, var
Const VBSCRIPT_MIN_VERSION = 56
var = ((ScriptEngineMajorVersion * 10) + ScriptEngineMinorVersion)
If ((var) &lt; VBSCRIPT_MIN_VERSION) Then
bIsCompatV = False
Else
bIsCompatV = True
End If
If Err &lt;&gt; 0 Then
CheckVBScriptEngine = Err.Number
Err.Clear
Else
CheckVBScriptEngine = bIsCompatV
End If
End Function

</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>