<ProbeActionModuleType ID="HP.DataProtector.PA.Device.DiscoveryProvider" Accessibility="Public" Batching="false" PassThrough="false">
<Configuration>
<xsd:element minOccurs="1" name="MPElement" type="xsd:string"/>
<xsd:element minOccurs="1" name="TargetID" type="xsd:string"/>
<xsd:element minOccurs="1" name="ComputerName" type="xsd:string"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="PA" TypeID="Windows!Microsoft.Windows.ScriptDiscoveryProbe">
<ScriptName>MPDPDeviceDiscoveryProvider.js</ScriptName>
<Arguments>$Config/MPElement$ $Config/TargetID$ $Config/ComputerName$ </Arguments>
<ScriptBody><Script>/* ============================================================================
|
| Copyright (c) 2013 ComTrade d.o.o. All rights reserved.
|
| Possession of this software does not grant any rights to use, reproduce,
| modify or distribute it or to use any concept it may contain.
|
| Licensed under ComTrade d.o.o. license ("the License"); you may not use
| this software unless in compliance with the License. Any use of the software
| without such license is a violation of copyright laws and may be subject to
| legal actions (remedies and/or criminal prosecution).
|
| NOTE:
| If you receive this content in error, please let us know by contacting
| ComTrade d.o.o. legal department ([email protected]) and destroy any
| copy you may have.
|
+=============================================================================*/
//check if MPDP agent is installed on node!
var MPDPInstalled = false;
agtPath = utility.readFromRegistry(utility.agentPathRegistryKey, "");
if (agtPath.length > 0) {
MPDPInstalled = true;
}
var xmlDoc;
try {
xmlDoc = utility.getXmlDataDoc();
} catch (e) {
//WScript.Echo(e.message);
//log this only if agent is already installed!
if (MPDPInstalled == true) {
oAPI.LogScriptEvent("MPDPDeviceDiscoveryProvider.js", 101, 1, "utility.getXmlDataDoc(): " + e.message);
}
oAPI.Return(oDiscoveryData);
WScript.Quit(0);
}
var cell_node, cellserver_node;
var bLicensed;
bLicensed = false;
var computerName = TargetComputer.toLowerCase();
// there will be always only one cell in xml document
cell_node = xmlDoc.getElementsByTagName("cell")[0];
if (typeof(cell_node) != "undefined" && cell_node != null) {
cellserver_node = cell_node.getElementsByTagName("cellserver")[0];
if (typeof(cellserver_node) != "undefined" && cellserver_node != null) {
var v_cellID = cell_node.getAttribute("id");
var devices_node, dc_nodes, dc_node;
// lock data file and load the content
var fs = WScript.CreateObject("Scripting.FileSystemObject");
var fileLock,
lockFileName;
var repeatCount = 100; // the number of tries for retreiving the lock
lockFileName = agtPath + "\\" + this.dataFileLock;
do {
try {
fileLock = fs.OpenTextFile(lockFileName, 2, true);
break;
} catch (e) {
repeatCount--;
WScript.Sleep(100);
}
} while (repeatCount > 0);
if (repeatCount == 0) {
throw new Error("Could not acquire lock for reading MPDP MP data file '" + lockFileName + "'.");
}
if (!xmlDoc.load(datFilePath)) {
// before throwing exception close the lock
fileLock.Close();
throw new Error("Error loading MPDP MP data file '" + datFilePath + "'. Error code: " + xmlDoc.parseError.reason);
}
// afther we read the data file contnent we can unlock it
fileLock.Close();
// return the xml doc object
return xmlDoc;
}
this.getAgentPath = function () {
if (this.agentPath.length == 0) {
agtPath = this.readFromRegistry(this.agentPathRegistryKey, "");
if (agtPath.length <= 0) {
throw new Error("Cannot resolve MPDP Agent path. No registry key '" + this.agentPathRegistryKey + "'.");
}
this.agentPath = agtPath;
}