Dell Host NIC Correlation Discovery Datasource

Dell.ManagedServer.HostNIC.Correlation.Discovery.DataSource (DataSourceModuleType)

Discovery Datasource for Host NIC Correlation

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

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

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval SecondsDell Host NIC Correlation discovery interval seconds
TimeoutSecondsint$Config/TimeoutSeconds$Timeout SecondsDell Host NIC Correlation discovery Timeout seconds
LogLevelint$Config/LogLevel$Log LevelDell Host NIC Correlation discovery logging level

Source Code:

<DataSourceModuleType ID="Dell.ManagedServer.HostNIC.Correlation.Discovery.DataSource" Accessibility="Internal" Batching="false">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>Windows!Microsoft.Windows.PowerShellSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="IntervalSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TimeoutSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="LogLevel" type="xsd:int"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="LogLevel" Selector="$Config/LogLevel$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>HostNICCorrelation.ps1</ScriptName>
<ScriptBody><Script>
param($sourceId, $managedEntityId, $LogLevel)
$api = New-Object -comObject 'MOM.ScriptAPI'
$discoveryData = $api.CreateDiscoveryData(0, $sourceId, $managedEntityId)

$scriptname = "HostNICCorrelation"
$logDirectory = "DellManagedServeriSM_log"

if (-not (Get-Module -Name "CimCmdlets")) {
Import-Module -Name "CimCmdlets"
}

try
{
$ErrorActionPreference = "SilentlyContinue"
if ($logLevel -ne 0)
{
$TempFolder = $env:SystemRoot + "\Temp"
$LogLocation = $TempFolder + "\" + $logDirectory + "\"
If(!(Test-Path -path($TempFolder)))
{
# create the directory if not present
New-Item $TempFolder -type directory
}

If(!(Test-Path -path($LogLocation)))
{
# create the directory if not present
New-Item $LogLocation -type directory
}
$Global:LogFileLocation = $LogLocation + $scriptname + ".log"
If(!(Test-Path -path($LogFileLocation)))
{
# create the file if it does not exist
New-Item $LogFileLocation -type file
}
Else
{
$logFileSize = Get-ChildItem $LogFileLocation | ForEach-Object {($_.Length/1KB)}
If ($logFileSize -gt 512)
{
# existingLogFile is greater than 512 KB
$archiveTime = Get-Date -f "yyyy-MM-dd_HH.mm"
Rename-Item $LogFileLocation ("ArchivedLog_" + $scriptname + "_" + $archiveTime + ".log")
New-Item $LogFileLocation ChildItem-type file
}
}
}
}
catch
{
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
$message = "Exception in creating log file. Exception-Message:" + $ErrorMessage + $FailedItem
$api.LogScriptEvent("HostNICCorrelation.ps1",1345,0,$message)
}

Function psDebugLog
{
param($level, $message)
if (($level -gt 0) -and ($level -le $logLevel))
{
$currentTime = Get-Date -f "yyyy-MM-dd_HH.mm.ss"
Out-File -FilePath $LogFileLocation -InputObject ($currentTime + " :: " + $message) -Append
}
}

psDebugLog -level 1 -message "Info: Dell Managed HostNIC Correlation Start"

$serverUID = "$Target/Host/Host/Property[Type="DellManagedServer!Dell.ManagedServer"]/UID$"
$instanceID = "$Target/Property[Type="DellManagedServer!Dell.ManagedServer.HostNIC"]/InstanceID$"
$fqdd = "$Target/Property[Type="DellManagedServer!Dell.ManagedServer.HostNIC"]/DeviceFQDD$"

psDebugLog -level 1 -message ("serverUID : " + $serverUID)
psDebugLog -level 1 -message ("instanceID : " + $instanceID)
psDebugLog -level 1 -message ("fqdd : " + $fqdd)

$hostNicInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']$")
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNICGroup']/ID$","HostNIC Group")
$hostNicInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.HostNIC']/InstanceID$", $instanceID)
$discoveryData.AddInstance($hostNicInst)

psDebugLog -level 1 -message "Created Host NIC object"

$nicUnitInst = $discoveryData.CreateClassInstance("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']$")
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer']/UID$", $serverUID)
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NICGroup']/ID$","NIC Group")
$nicUnitInst.AddProperty("$MPElement[Name='DellManagedServer!Dell.ManagedServer.NetworkInterfaceUnit']/ID$", $fqdd)
$discoveryData.AddInstance($nicUnitInst)

psDebugLog -level 1 -message "Created NIC object"

$nicRelationship = $discoveryData.CreateRelationshipInstance("$MPElement[Name='DellManagedServer!ManagedServerHostNIC.Contains.NetworkInterfaceUnit']$")
$nicRelationship.Source = $hostNicInst
$nicRelationship.Target = $nicUnitInst
$discoveryData.AddInstance($nicRelationship)

psDebugLog -level 1 -message "Created relationship between host NIC and NIC"

$discoveryData
psDebugLog -level 1 -message "Info: Dell Managed HostNIC Correlation End"
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>sourceID</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>managedEntityID</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>logLevel</Name>
<Value>$Config/LogLevel$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>