Virtual Machine Host Impact Timed Discovery

com.apcc.ISXO.PRO.VMHostImpact.TimedDiscovery (Discovery)

Workflow for discovery instances of managed Virtual Machine Hosts which are represented in the InfraStruxure Operations data model

Knowledge Base article:

Summary

This discovery aggregates information on existing virtual machine hosts from the Virtual Machine Manager service with knowledge of these hosts in the InfraStruxure Operations service. The discovery workflow will instantiate objects for all existing virtual machine hosts modeled in InfraStruxure Operations and append any location information for these hosts.

Element properties:

Targetcom.apcc.ISXO.PRO.Operations
EnabledTrue
Frequency14400
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:
  • com.apcc.ISXO.PRO.VMHostImpact
    • ISXOEndpoint
    • Identifier
    • VMMServer
    • Port
    • LocationName
    • BladeMountingPosition
    • MountingPosition
    • RackName
    • RowName
    • RoomName
    • DisplayName
Discovered relationships and their attribuets:

Member Modules:

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

Source Code:

<Discovery ID="com.apcc.ISXO.PRO.VMHostImpact.TimedDiscovery" Enabled="true" Target="com.apcc.ISXO.PRO.Operations" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="com.apcc.ISXO.PRO.VMHostImpact">
<Property PropertyID="ISXOEndpoint"/>
<Property PropertyID="Identifier"/>
<Property PropertyID="VMMServer"/>
<Property PropertyID="Port"/>
<Property PropertyID="LocationName"/>
<Property PropertyID="BladeMountingPosition"/>
<Property PropertyID="MountingPosition"/>
<Property PropertyID="RackName"/>
<Property PropertyID="RowName"/>
<Property PropertyID="RoomName"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryRelationship TypeID="com.apcc.ISXO.PRO.Operations_Contains_VMHostImpacts"/>
</DiscoveryTypes>
<DataSource ID="PSScript" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>14400</IntervalSeconds>
<SyncTime/>
<ScriptName>com.apcc.ISXO.PRO.VMHostImpact.Discovery.ps1</ScriptName>
<ScriptBody><Script>#############################################################################
# Filename: com.apcc.ISXO.PRO.VMHostImpact.Discovery.ps1
#############################################################################
Param($strRuleID, $strTargetID, $principalName, $ISXOEndpoint, $username, $password, $vmmServerName, $vmmServerPort)

$isDebug = $false;

function LogInfo($logMessage, $doLog = $isDebug) {
if ($doLog) {
[Diagnostics.EventLog]::WriteEntry("ITImpact Discovery", "Info: " + $logMessage);
}
}

function LogError($logMessage) {
[Diagnostics.EventLog]::WriteEntry("ITImpact Discovery", "Error: " + $logMessage);
}

LogInfo("Request: Discovery on VMM server: " + $vmmServerName + ":" + $vmmServerPort + " from: " + $ISXOEndpoint) $true;

if ($username -eq $null -or $password -eq $null) {
LogError("Credentials missing");
eventcreate /T Error /ID 100 /L APPLICATION /SO VMMPro /D 'Discovery credentials missing.';
return;
}

LogInfo("Discovery started");

$momAPI = New-Object -comObject 'MOM.ScriptAPI'
if ($Error.Count -ne 0) {
LogError("Unable create script API: " + $Error[0]);
return;
}

$discoveryData = $momAPI.CreateDiscoveryData(0, $strRuleID, $strTargetID);

if ($Error.Count -ne 0) {
LogError("Unable to create discovery data: " + $Error[0]);
return;
}

$vmmServer = get-vmmserver -computerName $vmmServerName -TCPPort $vmmServerPort;
if ($Error.Count -ne 0) {
LogError("Unable to connect to VMM server: " + $Error[0]);
return;
}

# Convert VMM server name from request to fully qualified domain name
$vmmServerName = $vmmServer.FQDN;

$vmhosts = get-vmhost -vmmserver $vmmServer;
if ($Error.Count -ne 0) {
LogError("Unable to get information about VM hosts from VMM server: " + $vmmServerName + ": " + $Error[0]);
$vmmServer.Disconnect();
return;
}

$vmclients = get-vm -vmmserver $vmmServer;
if ($Error.Count -ne 0) {
LogError("Unable to get information about VM clients from VMM server: " + $vmmServerName + ": " + $Error[0]);
$vmmServer.Disconnect();
return;
}

$message = "InfraStruxure Operations PROPack does not support IT Impact with an InfraStruxure Operations license only. To enable this feature, make sure you have complete configuration of InfraStruxure Operations including a valid InfraStruxure Capacity license.";
$eventLogs = Get-EventLog "Application" | Where-Object {$_.Message -eq $message}
if($eventLogs -eq $null){
Get-ISXOInformation $isxoEndPoint $username $password
}

set-vmhostinformation $ISXOEndpoint $username $password $vmmServer $vmhosts $vmclients
if ($Error.Count -ne 0) {
LogError("Unable to push VM host information to: " + $ISXOEndpoint + ": " + $Error[0]);
$vmmServer.Disconnect();
return;
}

LogInfo("Sent information about " + $vmhosts.Count + " VM host(s) to: " + $ISXOEndpoint);

$knownVMHosts = get-knownvmhost $ISXOEndpoint $username $password $vmmServer
if ($Error.Count -ne 0) {
LogError("Unable to get information about known VM hosts for VMM server: " + $vmmServerName + " from: " + $ISXOEndpoint + ": " + $Error[0]);
$vmmServer.Disconnect();
return;
}

LogInfo("Retrieved information about " + $knownVMHosts.Count + " known VM host(s) for VMM server: " + $vmmServerName + " from: " + $ISXOEndpoint);

foreach ($knownVMHost in $knownVMHosts) {
LogInfo("Creating discovery objecy for: " + $knownVMHost.Identifier);
$hostInfo = $discoveryData.CreateClassInstance("$MPElement[Name='com.apcc.ISXO.PRO.VMHostImpact']$");
$hostInfo.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.VMHostImpact']/Identifier$", $knownVMHost.Identifier);
$hostInfo.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.VMHostImpact']/ISXOEndpoint$", $ISXOEndpoint);
$hostInfo.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.VMHostImpact']/VMMServer$", $vmmServerName);
$hostInfo.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.VMHostImpact']/Port$", $vmmServerPort);
$hostInfo.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.VMHostImpact']/LocationName$", $knownVMHost.Name);
$hostInfo.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.VMHostImpact']/BladeMountingPosition$", $knownVMHost.BladeMountingPosition);
$hostInfo.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.VMHostImpact']/MountingPosition$", $knownVMHost.MountingPosition);
$hostInfo.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.VMHostImpact']/RackName$", $knownVMHost.Rack);
$hostInfo.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.VMHostImpact']/RoomName$", $knownVMHost.Room);
$hostInfo.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.VMHostImpact']/RowName$", $knownVMHost.Row);
$hostInfo.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $principalName);
$hostInfo.AddProperty("$MPElement[Name='SCVMM!Microsoft.SystemCenter.VirtualMachineManager.Pro.2008.Base']/Name$", $knownVMHost.Identifier);
$hostInfo.AddProperty("$MPElement[Name='SCVMM!Microsoft.SystemCenter.VirtualMachineManager.Pro.2008.Base']/VMMServer$", $vmmServerName);
$hostInfo.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $knownVMHost.Identifier);

$discoveryData.AddInstance($hostInfo);
}

$vmmServer.Disconnect();
LogInfo("Discovery ended");

$discoveryData
</Script></ScriptBody>
<SnapIns>
<SnapIn>Microsoft.SystemCenter.VirtualMachineManager</SnapIn>
<SnapIn>APC.ISXO.ITImpact</SnapIn>
</SnapIns>
<Parameters>
<Parameter>
<Name>strRuleID</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>strTargetID</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>principalName</Name>
<Value>$Target/Property[Type="com.apcc.ISXO.PRO.Operations"]/HealthServicePrincipalName$</Value>
</Parameter>
<Parameter>
<Name>ISXOEndpoint</Name>
<Value>$Target/Property[Type="com.apcc.ISXO.PRO.Operations"]/ISXOEndpoint$</Value>
</Parameter>
<Parameter>
<Name>username</Name>
<Value>$RunAs[Name="com.apcc.ISXO.PRO.Operations.Login"]/UserName$</Value>
</Parameter>
<Parameter>
<Name>password</Name>
<Value>$RunAs[Name="com.apcc.ISXO.PRO.Operations.Login"]/Password$</Value>
</Parameter>
<Parameter>
<Name>vmmServerName</Name>
<Value>$Target/Property[Type="com.apcc.ISXO.PRO.Operations"]/VMMServer$</Value>
</Parameter>
<Parameter>
<Name>vmmServerPort</Name>
<Value>$Target/Property[Type="com.apcc.ISXO.PRO.Operations"]/Port$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>