|
|
<HTML> <HEAD> <STYLE> BODY { font-family:Verdana; font-size:5pt; margin:0px; color:teal; } .instructions { font-style:italic; text-align:right; color:gray; margin-left:.5em; } .headline { background-color:teal; color:white; font-family:Arial Black; font-size:10pt; text-align:center; padding-top:1em; } .group { font-family:Arial Black; font-size:8pt; margin-top:.5em; margin-left:.5em; margin-bottom:.5em; } .button { font-family:Verdana; font-size:10pt; font-weight:bold; text-align:right; color:gray; } .arrow { font-family:Webdings; } </STYLE> </HEAD>
<SCRIPT> var source; var style; var liststyle; var utilizationstyle; var methodDataStyle; var theRequest; var sourceURL; var styleURL; var oldXSLitem; var theXMLResponse; var operationId; var g_strDevID; var timeoutID;
// Script to execute method function ExecuteMethods() { theMethodData = theXMLResponse.transformNode(methodDataStyle); // We have a list of methods now, and their arguments // Pop up a dialogu asking for the method to be executed. thePage = '<HTML><BODY><BUTTON onClick="parents.results.display(\"Hi\")">Hi</BUTTON></BODY></HTML>'; parent.results.display(thePage); } function UpdateOperationId () { operationId = operation.value; } function UpdateStylesheet () { var theXSL = new String (stylesheetSelect.value); if (theXSL == "Raw") changeXSL("raw-xml.xsl"); else if (theXSL == "Summary") changeXSL("summary.xsl"); else alert ("Unsupported stylesheet: " + theXSL); } function DoOperation (bSend) { operationId = "EnumerateInstances"; var theOp = new String (operationId); var theBody;
theBody = EnumInstance (); if (bSend) ShowList(theRequest, theBody); else if (null != theBody) ShowRequest(theBody); } function DoFullOperation (strDevID) { //revoke the previous time (if it exists) if(timeoutID > 0) { window.clearInterval(timeoutID); timeoutID = 0; } operationId = "GetInstance"; var theOp = new String (operationId); var theBody;
theBody = GetInstance(strDevID);
ShowResults(theRequest, theBody, strDevID); } function displayList(xslHTML) { document.all.item("xsllist").innerHTML = xslHTML;
// Include the following line to view the HTML source as well // document.all.item("xsldebug").innerHTML = "<XMP>" + xslHTML + "</XMP>"; } // ----- Scripts to control XSL Processing ------ function update() { parent.results.display(theXMLResponse.transformNode(style)); } function updateUtilization() { operationId = "GetInstance"; var theOp = new String (operationId); var theBody; var theXMLRequest = new ActiveXObject("Microsoft.XMLHTTP"); var theLocalXMLResponse = new ActiveXObject("Microsoft.XMLDOM"); theXMLRequest.open("POST", document.all.urlbox.value, false); theXMLRequest.setRequestHeader("Content-Type", "application/xml;charset=\"utf-8\""); theXMLRequest.setRequestHeader("CIMOperation", "MethodCall"); theXMLRequest.setRequestHeader("CIMMethod", "GetInstance"); theXMLRequest.setRequestHeader("CIMObject", "root\\cimv2"); theXMLRequest.setRequestHeader("CIMProtocolVersion", "1.0"); theBody = RequestPreamble ("GetInstance") + GetInstanceNameParameter (g_strDevID) + "<IPARAMVALUE NAME=\"IncludeQualifiers\"><VALUE>" + "TRUE" + "</VALUE></IPARAMVALUE>" + "<IPARAMVALUE NAME=\"LocalOnly\"><VALUE>" + "FALSE" + "</VALUE></IPARAMVALUE>" + "<IPARAMVALUE NAME=\"IncludeClassOrigin\"><VALUE>" + "TRUE" + "</VALUE></IPARAMVALUE>" + "<IPARAMVALUE NAME=\"DeepInheritance\"><VALUE>" + "TRUE" + "</VALUE></IPARAMVALUE>" + RequestPostamble (); theXMLRequest.send (theBody); theLocalXMLResponse.async = false; theLocalXMLResponse.validateOnParse = false;
theLocalXMLResponse.loadXML(theXMLRequest.responseText); var parseError = theLocalXMLResponse.parseError; if (parseError && (0 < parseError.errorCode)) { alert (parseError.errorCode); alert (parseError.reason); } iValue = GetUsage(theLocalXMLResponse); if(iValue == "") { iValue = 0; } parent.results.displayUtilization(theLocalXMLResponse.transformNode(utilizationstyle), iValue); } function GetUsage(XMLDOM) { if(XMLDOM.nodeName == "VALUE.NAMEDOBJECT") { for(f = 0; f < XMLDOM.childNodes.length; f++) { if(XMLDOM.childNodes.item(f).nodeName == "INSTANCE") { newXMLDOM = XMLDOM.childNodes.item(f) for(t = 0; t < newXMLDOM.childNodes.length; t++) { if(newXMLDOM.childNodes.item(t).nodeName == "PROPERTY") { if(newXMLDOM.childNodes.item(t).attributes.getNamedItem("NAME").text == "LoadPercentage") { for(k = 0; k < newXMLDOM.childNodes.item(t).childNodes.length; k++){ if(newXMLDOM.childNodes.item(t).childNodes.item(k).nodeName == "VALUE") { //we got what we're looking for return newXMLDOM.childNodes.item(t).childNodes.item(k).text; } } } } } } } }
for(i = 0; i < XMLDOM.childNodes.length; i++) { strValue = GetUsage(XMLDOM.childNodes.item(i)); if(strValue != "") { //we got something decent... return it return strValue; } } return ""; } function updateList() { displayList(theXMLResponse.transformNode(liststyle)); }
function changeXSL(xsldoc) { styleURL = xsldoc; style.load(styleURL); update(); }
// ----- Scripts to activate buttons ------ function over(item) { item.style.color = "black"; }
function out(item) { item.style.color = "gray"; }
// called by parent frame when the whole frameset is ready function init() { methodDataStyle = new ActiveXObject("Microsoft.XMLDOM"); methodDataStyle.async = false; methodDataStyle.load("methoddata.xsl"); theRequest = new ActiveXObject("Microsoft.XMLHTTP"); theXMLResponse = new ActiveXObject("Microsoft.XMLDOM"); operationId = "EnumerateInstances"; style = new ActiveXObject("Microsoft.XMLDOM"); style.async = false; style.load("summary.xsl"); liststyle = new ActiveXObject("Microsoft.XMLDOM"); liststyle.async = false; liststyle.load("list.xsl"); utilizationstyle = new ActiveXObject("Microsoft.XMLDOM"); utilizationstyle.async = false; utilizationstyle.load("utilization.xsl"); timeoutID = 0; }
function GetOptions() { document.all("ResponseStatus").innerText = ""; theRequest.open("OPTIONS", document.all.urlbox.value, false); return null; }
function InitOperation (method) { theRequest.open("POST", document.all.urlbox.value, false); theRequest.setRequestHeader("Content-Type", "application/xml;charset=\"utf-8\""); theRequest.setRequestHeader("CIMOperation", "MethodCall"); theRequest.setRequestHeader("CIMMethod", method); theRequest.setRequestHeader("CIMObject", "root\\cimv2"); theRequest.setRequestHeader("CIMProtocolVersion", "1.0"); }
function GetObjectNameParameter () { var str = "<IPARAMVALUE NAME=\"ObjectName\">"; var objectPath = new String (document.all.classbox.value); if (-1 == objectPath.indexOf (".", 0)) { // a class name str = str + "<CLASSNAME NAME=\"" + objectPath + "\">"; } else { // an instance name str = str + GetInstanceName (objectPath); } str = str + "</IPARAMVALUE>"; return str; } function GetClassNameParameter () { return ("<IPARAMVALUE NAME=\"ClassName\"><CLASSNAME NAME=\"" + document.all.classbox.value + "\"/></IPARAMVALUE>"); } function GetInstanceNameParameter (strDeviceID) { var str = "<IPARAMVALUE NAME=\"InstanceName\">"; str = str + GetInstanceName (strDeviceID); str = str + "</IPARAMVALUE>"; return str; } function GetReference (inStr) { // TODO - just handle INSTANCENAME case for now return GetInstanceName (inStr); } function GetInstanceName (inStr) { var pathValue = new String (inStr); var str = "<INSTANCENAME CLASSNAME=\""; // Step 1 - get the class name var startIndex = pathValue.indexOf ("."); str = str + pathValue.substr (0, startIndex) + "\">"; startIndex = startIndex + 1; // Step 2 - get the keybindings while (-1 != (index = pathValue.indexOf ("=", startIndex))) { str = str + '<KEYBINDING NAME="' + pathValue.substr (startIndex, index - startIndex) + '">'; // Get the key value startIndex = index + 1; var valueStr; if (-1 != (index = pathValue.indexOf (",", startIndex))) { valueStr = new String (pathValue.substr (startIndex, index - startIndex)); startIndex = index + 1; } else { valueStr = new String (pathValue.substr (startIndex)); startIndex = pathValue.length; } str = str + '<KEYVALUE'; // Work out VALUETYPE attribute if (valueStr.charAt (0) == '"') { // string str = str + '>' + valueStr.substr (1, valueStr.length-2); // TODO - this COULD be an object path - need to // trap that case and do a VALUE.REFERENCE instead } else if (!isNaN (parseInt (valueStr))) { // numeric str = str + ' VALUETYPE="numeric">' + valueStr; } else { // assume boolean str = str + ' VALUETYPE="boolean">' + valueStr; } str = str + "</KEYVALUE></KEYBINDING>"; } str = str + "</INSTANCENAME>"; return (str); } function GetIncludeQualifiersParameter () { var IncludeQualifiers = "FALSE"; if (includeQualifiers.checked) IncludeQualifiers = "TRUE"; return ("<IPARAMVALUE NAME=\"IncludeQualifiers\"><VALUE>" + IncludeQualifiers + "</VALUE></IPARAMVALUE>"); } function GetLocalOnlyParameter () { var LocalOnly = "FALSE"; if (localOnly.checked) LocalOnly = "TRUE"; return ("<IPARAMVALUE NAME=\"LocalOnly\"><VALUE>" + LocalOnly + "</VALUE></IPARAMVALUE>"); } function GetClassOriginParameter () { var ClassOrigin = "FALSE"; if (includeClassOrigin.checked) ClassOrigin = "TRUE"; return ("<IPARAMVALUE NAME=\"IncludeClassOrigin\"><VALUE>" + ClassOrigin + "</VALUE></IPARAMVALUE>"); } function GetPropertyNameParameter () { return ("<IPARAMVALUE NAME=\"PropertyName\"><VALUE>" + propertyBox.value + "</VALUE></IPARAMVALUE>"); } function GetAssocClassParameter () { if (assocClass.value) { return ("<IPARAMVALUE NAME=\"AssocClass\"><VALUE>" + assocClass.value + "</VALUE></IPARAMVALUE>"); } else return ""; } function GetResultClassParameter () { if (document.all.resultClass.value) { return ("<IPARAMVALUE NAME=\"ResultClass\"><VALUE>" + document.all.resultClass.value + "</VALUE></IPARAMVALUE>"); } else return ""; } function GetRoleParameter () { if (role.value) return ("<IPARAMVALUE NAME=\"Role\"><VALUE>" + role.value + "</VALUE></IPARAMVALUE>"); else return ""; } function GetResultRoleParameter () { if (resultRole.value) return ("<IPARAMVALUE NAME=\"ResultRole\"><VALUE>" + resultRole.value + "</VALUE></IPARAMVALUE>"); else return ""; } function GetPropertyListParameter () { var strValue = new String (propertyBox.value); var value = ""; if (0 < strValue.length) { value = "<IPARAMVALUE NAME=\"PropertyList\"><VALUE.ARRAY>"; var startIndex = 0; while (-1 != (index = strValue.indexOf (",", startIndex))) { value = value + "<VALUE>" + strValue.substr (startIndex, index - startIndex) + "</VALUE>"; startIndex = index + 1; } // Get the last element (TODO - empty arrays?) value = value + "<VALUE>" + strValue.substr (startIndex) + "</VALUE>"; value = value + "</VALUE.ARRAY></IPARAMVALUE>" } return value; } function GetPropertyValueParameter () { var strValue = new String (propertyValueBox.value); var value = "<IPARAMVALUE NAME=\"NewValue\""; // TODO - if first characters are "ref:" then treat // as reference value if (strValue.length == 0) { // NULL value value = value + "/>"; } else if (strValue.substring (0,4) == new String("ref:")) { if (4 == strValue.length) value = value + "/>"; else { value = value + "><VALUE.REFERENCE>" + GetReference (strValue.substr (4)) + "</VALUE.REFERENCE></IPARAMVALUE>"; } } else if (strValue.charAt (0) == '{') { value = value + "><VALUE.ARRAY>"; // Assume an array value var startIndex = 1; while (-1 != (index = strValue.indexOf (",", startIndex))) { // TODO - build up <VALUE.ARRAY> for this value = value + "<VALUE>" + strValue.substr (startIndex, index - startIndex) + "</VALUE>"; startIndex = index + 1; } // Get the last element (TODO - empty arrays?) value = value + "<VALUE>" + strValue.substr (startIndex, strValue.indexOf("}",startIndex) - startIndex) + "</VALUE>"; value = value + "</VALUE.ARRAY></IPARAMVALUE>"; } else value = value + "><VALUE>" + strValue + "</VALUE></IPARAMVALUE>"; return value; } function GetDeepInheritanceParameter () { var DeepInheritance = "FALSE"; if (deepInheritance.checked) DeepInheritance = "TRUE"; return ("<IPARAMVALUE NAME=\"DeepInheritance\"><VALUE>" + DeepInheritance + "</VALUE></IPARAMVALUE>"); } function GetQueryParameter () { return ("<IPARAMVALUE NAME=\"Query\"><VALUE>" + document.all.querybox.value + "</VALUE></IPARAMVALUE>" ); } function GetQueryLanguageParameter () { return ("<IPARAMVALUE NAME=\"QueryLanguage\"><VALUE>" + "WQL" + "</VALUE></IPARAMVALUE>"); } function DoCustomOperation() { var fso = new ActiveXObject("Scripting.FileSystemObject"); var theFile = fso.OpenTextFile(".\multireq.xml"); alert ("Hello"); } function EnumInstance() { InitOperation ("EnumerateInstances"); return RequestPreamble ("EnumerateInstances") + "<IPARAMVALUE NAME=\"ClassName\"><CLASSNAME NAME=\"" + "CIM_Processor" + "\"/></IPARAMVALUE>" + "<IPARAMVALUE NAME=\"IncludeQualifiers\"><VALUE>" + "TRUE" + "</VALUE></IPARAMVALUE>" + "<IPARAMVALUE NAME=\"LocalOnly\"><VALUE>" + "FALSE" + "</VALUE></IPARAMVALUE>" + "<IPARAMVALUE NAME=\"IncludeClassOrigin\"><VALUE>" + "TRUE" + "</VALUE></IPARAMVALUE>" + "<IPARAMVALUE NAME=\"DeepInheritance\"><VALUE>" + "TRUE" + "</VALUE></IPARAMVALUE>" + RequestPostamble (); } function GetInstance(strDevID) { InitOperation ("GetInstance"); return RequestPreamble ("GetInstance") + GetInstanceNameParameter (strDevID) + "<IPARAMVALUE NAME=\"IncludeQualifiers\"><VALUE>" + "TRUE" + "</VALUE></IPARAMVALUE>" + "<IPARAMVALUE NAME=\"LocalOnly\"><VALUE>" + "FALSE" + "</VALUE></IPARAMVALUE>" + "<IPARAMVALUE NAME=\"IncludeClassOrigin\"><VALUE>" + "TRUE" + "</VALUE></IPARAMVALUE>" + "<IPARAMVALUE NAME=\"DeepInheritance\"><VALUE>" + "TRUE" + "</VALUE></IPARAMVALUE>" + RequestPostamble (); }
function ShowResults(theXMLRequest, theXMLBody, strDevID) { theXMLRequest.send (theXMLBody); theXMLResponse.async = false; theXMLResponse.validateOnParse = false;
// document.all("ResponseHeaders").innerText = theXMLRequest.getAllResponseHeaders(); theXMLResponse.loadXML(theXMLRequest.responseText); var parseError = theXMLResponse.parseError; if (parseError && (0 < parseError.errorCode)) { alert (parseError.errorCode); alert (parseError.reason); } update(theXMLResponse); g_strDevID = strDevID; updateUtilization(); timeoutID = window.setInterval("updateUtilization()", 2000); } function ShowList(theXMLRequest, theXMLBody) { theXMLRequest.send (theXMLBody); theXMLResponse.async = false; theXMLResponse.validateOnParse = false;
theXMLResponse.loadXML(theXMLRequest.responseText); var parseError = theXMLResponse.parseError; if (parseError && (0 < parseError.errorCode)) { alert (parseError.errorCode); alert (parseError.reason); } updateList(theXMLResponse); } function ShowRequest(theBody) { theXMLResponse.loadXML(theBody); update(theXMLResponse); } function ParseNamespace (nsPath) { var parsedPath = ""; var inputPath = new String (nsPath); var startIndex = 0; while ((-1 != (index = inputPath.indexOf ("/", startIndex))) || (-1 != (index = inputPath.indexOf ("\\", startIndex)))) { parsedPath = parsedPath + '<NAMESPACE NAME="' + inputPath.substr (startIndex, index - startIndex) + '"/>'; startIndex = index + 1; } parsedPath = parsedPath + '<NAMESPACE NAME="' + inputPath.substr (startIndex) + '"/>'; return (parsedPath); } function RequestPreamble (method) { var str = "<?xml version=\"1.0\" ?>" + "<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\">" + "<MESSAGE ID=\"877\" PROTOCOLVERSION=\"1.0\">" + "<SIMPLEREQ>" + "<IMETHODCALL NAME=\"" + method + "\">" + "<LOCALNAMESPACEPATH>" + ParseNamespace ("root\\cimv2") + "</LOCALNAMESPACEPATH>"; return (str); } function RequestPostamble () { return ("</IMETHODCALL></SIMPLEREQ></MESSAGE></CIM>"); } </SCRIPT>
<BODY> <DIV CLASS="headline">CIM Processor Monitor</DIV> <DIV class=group> <TABLE align=left border=0 cellPadding=1 cellSpacing=1 width="75%"> <TR> <TD><FONT size=1><LABEL>CIM Server URL </LABEL></FONT></TD> </TR> <TD><INPUT id=urlbox size=35 value=http://rajeshr72/cimom style="HEIGHT: 22px; WIDTH: 235px"></TD></TR> <TR> <TD></TD> <TD></TD></TR></TABLE></DIV> <P>
<DIV class=group> </DIV> <DIV class=group> </DIV> <DIV class=group><CENTER><BUTTON id=operationButton onclick=DoOperation(true) style="LEFT: 221px; TOP: 248px">Get Processor List</BUTTON></CENTER></DIV> <DIV class=instructions> </DIV> <DIV class=instructions> <HR> </DIV>
<DIV id="xsllist"><!-- resulting HTML will be inserted here --></DIV> </BODY> </HTML>
|