Workflow for discovering StruxureWare Operations endpoints for use in Virtual Machine Manager
Knowledge Base article:
Summary
This discovery looks for settings in the registry specifying the location of the StruxureWare Operations service and the Virtual Machine Manager service.
//
// Unpack the arguments into module-level vars.
//
var m_strRuleID = WScript.Arguments(0);
var m_strTargetID = WScript.Arguments(1);
var m_strPrincipalName = WScript.Arguments(2);
//
// The main point: using the API, create a Discovery DataItem
//
var m_oAPI = new ActiveXObject("MOM.ScriptAPI");
if (debug)
m_oAPI.LogScriptEvent(m_strScriptName, 2720, 0, "Script started.");
var m_oDiscoveryData = m_oAPI.CreateDiscoveryData(0, m_strRuleID, m_strTargetID);
//
// This is the top of the discovery logic tree...
//
discoverOperations();
//
// Return the Discovery DataItem, as populated.
//
m_oAPI.Return(m_oDiscoveryData);
if (debug)
m_oAPI.LogScriptEvent(m_strScriptName, 2721, 0, "Script completed.");
function discoverOperations() {
var oShell = new ActiveXObject("Wscript.Shell");
var strOperationsName = "";
var strVMMServer = "";
var strVMMServerPort = "";
var strISXOEndpoint = "";
// Only discover valid registry entries.
if (strOperationsName.length > 0 && strISXOEndpoint.length > 0 && strVMMServer.length > 0) {
if (debug)
m_oAPI.LogScriptEvent(m_strScriptName, 2720, 0, "Discovered operations.");
// Create an instance of an Operations.
var oOperationsInstance = m_oDiscoveryData.CreateClassInstance("$MPElement[Name='com.apcc.ISXO.PRO.Operations']$");
// Set the properties, as required.
oOperationsInstance.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.Operations']/HealthServicePrincipalName$", m_strPrincipalName);
oOperationsInstance.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.Operations']/ISXOEndpoint$", strISXOEndpoint);
oOperationsInstance.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.Operations']/VMMServer$", strVMMServer);
oOperationsInstance.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.Operations']/Port$", strVMMServerPort);
oOperationsInstance.AddProperty("$MPElement[Name='com.apcc.ISXO.PRO.Operations']/Name$", strOperationsName);
oOperationsInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", strOperationsName);
// Now add the central the Discovery DataItem returning to OpsMgr.
m_oDiscoveryData.AddInstance(oOperationsInstance);
// Create a ShouldManage relationship between the Health Service and this Central instance
var oHealthServiceToCentralRelationshipInstance = m_oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$");
var oHealthServiceInstance = m_oDiscoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$");
oHealthServiceInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", m_strPrincipalName);
oHealthServiceToCentralRelationshipInstance.Source = oHealthServiceInstance;
oHealthServiceToCentralRelationshipInstance.Target = oOperationsInstance;
m_oDiscoveryData.AddInstance(oHealthServiceToCentralRelationshipInstance);
}
iCount++;
WScript.Sleep(0); // Yield control on loops to keep the overall system responsive.
}
while (strISXOEndpoint.length > 0);
}</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>