Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

704 lines
18 KiB

  1. <HTML>
  2. <HEAD>
  3. <STYLE>
  4. BODY { font-family:Verdana; font-size:5pt; margin:0px; color:teal; }
  5. .instructions { font-style:italic; text-align:right; color:gray; margin-left:.5em; }
  6. .headline { background-color:teal; color:white; font-family:Arial Black; font-size:10pt;
  7. text-align:center; padding-top:1em; }
  8. .group { font-family:Arial Black; font-size:8pt; margin-top:.5em; margin-left:.5em;
  9. margin-bottom:.5em; }
  10. .button { font-family:Verdana; font-size:10pt; font-weight:bold; text-align:right;
  11. color:gray; }
  12. .arrow { font-family:Webdings; }
  13. </STYLE>
  14. </HEAD>
  15. <SCRIPT>
  16. var source;
  17. var style;
  18. var liststyle;
  19. var utilizationstyle;
  20. var methodDataStyle;
  21. var theRequest;
  22. var sourceURL;
  23. var styleURL;
  24. var oldXSLitem;
  25. var theXMLResponse;
  26. var operationId;
  27. var g_strDevID;
  28. var timeoutID;
  29. // Script to execute method
  30. function ExecuteMethods()
  31. {
  32. theMethodData = theXMLResponse.transformNode(methodDataStyle);
  33. // We have a list of methods now, and their arguments
  34. // Pop up a dialogu asking for the method to be executed.
  35. thePage = '<HTML><BODY><BUTTON onClick="parents.results.display(\"Hi\")">Hi</BUTTON></BODY></HTML>';
  36. parent.results.display(thePage);
  37. }
  38. function UpdateOperationId ()
  39. {
  40. operationId = operation.value;
  41. }
  42. function UpdateStylesheet ()
  43. {
  44. var theXSL = new String (stylesheetSelect.value);
  45. if (theXSL == "Raw")
  46. changeXSL("raw-xml.xsl");
  47. else if (theXSL == "Summary")
  48. changeXSL("summary.xsl");
  49. else
  50. alert ("Unsupported stylesheet: " + theXSL);
  51. }
  52. function DoOperation (bSend)
  53. {
  54. operationId = "EnumerateInstances";
  55. var theOp = new String (operationId);
  56. var theBody;
  57. theBody = EnumInstance ();
  58. if (bSend)
  59. ShowList(theRequest, theBody);
  60. else if (null != theBody)
  61. ShowRequest(theBody);
  62. }
  63. function DoFullOperation (strDevID)
  64. {
  65. //revoke the previous time (if it exists)
  66. if(timeoutID > 0)
  67. {
  68. window.clearInterval(timeoutID);
  69. timeoutID = 0;
  70. }
  71. operationId = "GetInstance";
  72. var theOp = new String (operationId);
  73. var theBody;
  74. theBody = GetInstance(strDevID);
  75. ShowResults(theRequest, theBody, strDevID);
  76. }
  77. function displayList(xslHTML)
  78. {
  79. document.all.item("xsllist").innerHTML = xslHTML;
  80. // Include the following line to view the HTML source as well
  81. // document.all.item("xsldebug").innerHTML = "<XMP>" + xslHTML + "</XMP>";
  82. }
  83. // ----- Scripts to control XSL Processing ------
  84. function update()
  85. {
  86. parent.results.display(theXMLResponse.transformNode(style));
  87. }
  88. function updateUtilization()
  89. {
  90. operationId = "GetInstance";
  91. var theOp = new String (operationId);
  92. var theBody;
  93. var theXMLRequest = new ActiveXObject("Microsoft.XMLHTTP");
  94. var theLocalXMLResponse = new ActiveXObject("Microsoft.XMLDOM");
  95. theXMLRequest.open("POST", document.all.urlbox.value, false);
  96. theXMLRequest.setRequestHeader("Content-Type", "application/xml;charset=\"utf-8\"");
  97. theXMLRequest.setRequestHeader("CIMOperation", "MethodCall");
  98. theXMLRequest.setRequestHeader("CIMMethod", "GetInstance");
  99. theXMLRequest.setRequestHeader("CIMObject", "root\\cimv2");
  100. theXMLRequest.setRequestHeader("CIMProtocolVersion", "1.0");
  101. theBody = RequestPreamble ("GetInstance") +
  102. GetInstanceNameParameter (g_strDevID) +
  103. "<IPARAMVALUE NAME=\"IncludeQualifiers\"><VALUE>" +
  104. "TRUE" + "</VALUE></IPARAMVALUE>" +
  105. "<IPARAMVALUE NAME=\"LocalOnly\"><VALUE>" + "FALSE" +
  106. "</VALUE></IPARAMVALUE>" +
  107. "<IPARAMVALUE NAME=\"IncludeClassOrigin\"><VALUE>" +
  108. "TRUE" + "</VALUE></IPARAMVALUE>" +
  109. "<IPARAMVALUE NAME=\"DeepInheritance\"><VALUE>" +
  110. "TRUE" + "</VALUE></IPARAMVALUE>" +
  111. RequestPostamble ();
  112. theXMLRequest.send (theBody);
  113. theLocalXMLResponse.async = false;
  114. theLocalXMLResponse.validateOnParse = false;
  115. theLocalXMLResponse.loadXML(theXMLRequest.responseText);
  116. var parseError = theLocalXMLResponse.parseError;
  117. if (parseError && (0 < parseError.errorCode))
  118. {
  119. alert (parseError.errorCode);
  120. alert (parseError.reason);
  121. }
  122. iValue = GetUsage(theLocalXMLResponse);
  123. if(iValue == "")
  124. {
  125. iValue = 0;
  126. }
  127. parent.results.displayUtilization(theLocalXMLResponse.transformNode(utilizationstyle), iValue);
  128. }
  129. function GetUsage(XMLDOM)
  130. {
  131. if(XMLDOM.nodeName == "VALUE.NAMEDOBJECT")
  132. {
  133. for(f = 0; f < XMLDOM.childNodes.length; f++)
  134. {
  135. if(XMLDOM.childNodes.item(f).nodeName == "INSTANCE")
  136. {
  137. newXMLDOM = XMLDOM.childNodes.item(f)
  138. for(t = 0; t < newXMLDOM.childNodes.length; t++)
  139. {
  140. if(newXMLDOM.childNodes.item(t).nodeName == "PROPERTY")
  141. {
  142. if(newXMLDOM.childNodes.item(t).attributes.getNamedItem("NAME").text == "LoadPercentage")
  143. {
  144. for(k = 0; k < newXMLDOM.childNodes.item(t).childNodes.length; k++){
  145. if(newXMLDOM.childNodes.item(t).childNodes.item(k).nodeName == "VALUE")
  146. {
  147. //we got what we're looking for
  148. return newXMLDOM.childNodes.item(t).childNodes.item(k).text;
  149. }
  150. }
  151. }
  152. }
  153. }
  154. }
  155. }
  156. }
  157. for(i = 0; i < XMLDOM.childNodes.length; i++)
  158. {
  159. strValue = GetUsage(XMLDOM.childNodes.item(i));
  160. if(strValue != "")
  161. {
  162. //we got something decent... return it
  163. return strValue;
  164. }
  165. }
  166. return "";
  167. }
  168. function updateList()
  169. {
  170. displayList(theXMLResponse.transformNode(liststyle));
  171. }
  172. function changeXSL(xsldoc)
  173. {
  174. styleURL = xsldoc;
  175. style.load(styleURL);
  176. update();
  177. }
  178. // ----- Scripts to activate buttons ------
  179. function over(item)
  180. {
  181. item.style.color = "black";
  182. }
  183. function out(item) {
  184. item.style.color = "gray";
  185. }
  186. // called by parent frame when the whole frameset is ready
  187. function init()
  188. {
  189. methodDataStyle = new ActiveXObject("Microsoft.XMLDOM");
  190. methodDataStyle.async = false;
  191. methodDataStyle.load("methoddata.xsl");
  192. theRequest = new ActiveXObject("Microsoft.XMLHTTP");
  193. theXMLResponse = new ActiveXObject("Microsoft.XMLDOM");
  194. operationId = "EnumerateInstances";
  195. style = new ActiveXObject("Microsoft.XMLDOM");
  196. style.async = false;
  197. style.load("summary.xsl");
  198. liststyle = new ActiveXObject("Microsoft.XMLDOM");
  199. liststyle.async = false;
  200. liststyle.load("list.xsl");
  201. utilizationstyle = new ActiveXObject("Microsoft.XMLDOM");
  202. utilizationstyle.async = false;
  203. utilizationstyle.load("utilization.xsl");
  204. timeoutID = 0;
  205. }
  206. function GetOptions()
  207. {
  208. document.all("ResponseStatus").innerText = "";
  209. theRequest.open("OPTIONS", document.all.urlbox.value, false);
  210. return null;
  211. }
  212. function InitOperation (method)
  213. {
  214. theRequest.open("POST", document.all.urlbox.value, false);
  215. theRequest.setRequestHeader("Content-Type", "application/xml;charset=\"utf-8\"");
  216. theRequest.setRequestHeader("CIMOperation", "MethodCall");
  217. theRequest.setRequestHeader("CIMMethod", method);
  218. theRequest.setRequestHeader("CIMObject", "root\\cimv2");
  219. theRequest.setRequestHeader("CIMProtocolVersion", "1.0");
  220. }
  221. function GetObjectNameParameter ()
  222. {
  223. var str = "<IPARAMVALUE NAME=\"ObjectName\">";
  224. var objectPath = new String (document.all.classbox.value);
  225. if (-1 == objectPath.indexOf (".", 0))
  226. {
  227. // a class name
  228. str = str + "<CLASSNAME NAME=\"" +
  229. objectPath + "\">";
  230. }
  231. else
  232. {
  233. // an instance name
  234. str = str + GetInstanceName (objectPath);
  235. }
  236. str = str + "</IPARAMVALUE>";
  237. return str;
  238. }
  239. function GetClassNameParameter ()
  240. {
  241. return ("<IPARAMVALUE NAME=\"ClassName\"><CLASSNAME NAME=\"" +
  242. document.all.classbox.value + "\"/></IPARAMVALUE>");
  243. }
  244. function GetInstanceNameParameter (strDeviceID)
  245. {
  246. var str = "<IPARAMVALUE NAME=\"InstanceName\">";
  247. str = str + GetInstanceName (strDeviceID);
  248. str = str + "</IPARAMVALUE>";
  249. return str;
  250. }
  251. function GetReference (inStr)
  252. {
  253. // TODO - just handle INSTANCENAME case for now
  254. return GetInstanceName (inStr);
  255. }
  256. function GetInstanceName (inStr)
  257. {
  258. var pathValue = new String (inStr);
  259. var str = "<INSTANCENAME CLASSNAME=\"";
  260. // Step 1 - get the class name
  261. var startIndex = pathValue.indexOf (".");
  262. str = str + pathValue.substr (0, startIndex) + "\">";
  263. startIndex = startIndex + 1;
  264. // Step 2 - get the keybindings
  265. while (-1 != (index = pathValue.indexOf ("=", startIndex)))
  266. {
  267. str = str +
  268. '<KEYBINDING NAME="' + pathValue.substr (startIndex,
  269. index - startIndex) + '">';
  270. // Get the key value
  271. startIndex = index + 1;
  272. var valueStr;
  273. if (-1 != (index = pathValue.indexOf (",", startIndex)))
  274. {
  275. valueStr = new String (pathValue.substr (startIndex,
  276. index - startIndex));
  277. startIndex = index + 1;
  278. }
  279. else
  280. {
  281. valueStr = new String (pathValue.substr (startIndex));
  282. startIndex = pathValue.length;
  283. }
  284. str = str + '<KEYVALUE';
  285. // Work out VALUETYPE attribute
  286. if (valueStr.charAt (0) == '"')
  287. {
  288. // string
  289. str = str + '>' + valueStr.substr (1, valueStr.length-2);
  290. // TODO - this COULD be an object path - need to
  291. // trap that case and do a VALUE.REFERENCE instead
  292. }
  293. else if (!isNaN (parseInt (valueStr)))
  294. {
  295. // numeric
  296. str = str + ' VALUETYPE="numeric">' + valueStr;
  297. }
  298. else
  299. {
  300. // assume boolean
  301. str = str + ' VALUETYPE="boolean">' + valueStr;
  302. }
  303. str = str + "</KEYVALUE></KEYBINDING>";
  304. }
  305. str = str + "</INSTANCENAME>";
  306. return (str);
  307. }
  308. function GetIncludeQualifiersParameter ()
  309. {
  310. var IncludeQualifiers = "FALSE";
  311. if (includeQualifiers.checked)
  312. IncludeQualifiers = "TRUE";
  313. return ("<IPARAMVALUE NAME=\"IncludeQualifiers\"><VALUE>" +
  314. IncludeQualifiers + "</VALUE></IPARAMVALUE>");
  315. }
  316. function GetLocalOnlyParameter ()
  317. {
  318. var LocalOnly = "FALSE";
  319. if (localOnly.checked)
  320. LocalOnly = "TRUE";
  321. return ("<IPARAMVALUE NAME=\"LocalOnly\"><VALUE>" + LocalOnly +
  322. "</VALUE></IPARAMVALUE>");
  323. }
  324. function GetClassOriginParameter ()
  325. {
  326. var ClassOrigin = "FALSE";
  327. if (includeClassOrigin.checked)
  328. ClassOrigin = "TRUE";
  329. return ("<IPARAMVALUE NAME=\"IncludeClassOrigin\"><VALUE>" +
  330. ClassOrigin + "</VALUE></IPARAMVALUE>");
  331. }
  332. function GetPropertyNameParameter ()
  333. {
  334. return ("<IPARAMVALUE NAME=\"PropertyName\"><VALUE>" +
  335. propertyBox.value + "</VALUE></IPARAMVALUE>");
  336. }
  337. function GetAssocClassParameter ()
  338. {
  339. if (assocClass.value)
  340. {
  341. return ("<IPARAMVALUE NAME=\"AssocClass\"><VALUE>" +
  342. assocClass.value + "</VALUE></IPARAMVALUE>");
  343. }
  344. else
  345. return "";
  346. }
  347. function GetResultClassParameter ()
  348. {
  349. if (document.all.resultClass.value)
  350. {
  351. return ("<IPARAMVALUE NAME=\"ResultClass\"><VALUE>" +
  352. document.all.resultClass.value + "</VALUE></IPARAMVALUE>");
  353. }
  354. else
  355. return "";
  356. }
  357. function GetRoleParameter ()
  358. {
  359. if (role.value)
  360. return ("<IPARAMVALUE NAME=\"Role\"><VALUE>" +
  361. role.value + "</VALUE></IPARAMVALUE>");
  362. else
  363. return "";
  364. }
  365. function GetResultRoleParameter ()
  366. {
  367. if (resultRole.value)
  368. return ("<IPARAMVALUE NAME=\"ResultRole\"><VALUE>" +
  369. resultRole.value + "</VALUE></IPARAMVALUE>");
  370. else
  371. return "";
  372. }
  373. function GetPropertyListParameter ()
  374. {
  375. var strValue = new String (propertyBox.value);
  376. var value = "";
  377. if (0 < strValue.length)
  378. {
  379. value = "<IPARAMVALUE NAME=\"PropertyList\"><VALUE.ARRAY>";
  380. var startIndex = 0;
  381. while (-1 != (index = strValue.indexOf (",", startIndex)))
  382. {
  383. value = value +
  384. "<VALUE>" + strValue.substr (startIndex,
  385. index - startIndex) + "</VALUE>";
  386. startIndex = index + 1;
  387. }
  388. // Get the last element (TODO - empty arrays?)
  389. value = value + "<VALUE>"
  390. + strValue.substr (startIndex) + "</VALUE>";
  391. value = value + "</VALUE.ARRAY></IPARAMVALUE>"
  392. }
  393. return value;
  394. }
  395. function GetPropertyValueParameter ()
  396. {
  397. var strValue = new String (propertyValueBox.value);
  398. var value = "<IPARAMVALUE NAME=\"NewValue\"";
  399. // TODO - if first characters are "ref:" then treat
  400. // as reference value
  401. if (strValue.length == 0)
  402. {
  403. // NULL value
  404. value = value + "/>";
  405. }
  406. else if (strValue.substring (0,4) == new String("ref:"))
  407. {
  408. if (4 == strValue.length)
  409. value = value + "/>";
  410. else
  411. {
  412. value = value + "><VALUE.REFERENCE>" +
  413. GetReference (strValue.substr (4)) +
  414. "</VALUE.REFERENCE></IPARAMVALUE>";
  415. }
  416. }
  417. else if (strValue.charAt (0) == '{')
  418. {
  419. value = value + "><VALUE.ARRAY>";
  420. // Assume an array value
  421. var startIndex = 1;
  422. while (-1 != (index = strValue.indexOf (",", startIndex)))
  423. {
  424. // TODO - build up <VALUE.ARRAY> for this
  425. value = value +
  426. "<VALUE>" + strValue.substr (startIndex,
  427. index - startIndex) + "</VALUE>";
  428. startIndex = index + 1;
  429. }
  430. // Get the last element (TODO - empty arrays?)
  431. value = value + "<VALUE>"
  432. + strValue.substr (startIndex,
  433. strValue.indexOf("}",startIndex) - startIndex) + "</VALUE>";
  434. value = value + "</VALUE.ARRAY></IPARAMVALUE>";
  435. }
  436. else
  437. value = value + "><VALUE>" + strValue + "</VALUE></IPARAMVALUE>";
  438. return value;
  439. }
  440. function GetDeepInheritanceParameter ()
  441. {
  442. var DeepInheritance = "FALSE";
  443. if (deepInheritance.checked)
  444. DeepInheritance = "TRUE";
  445. return ("<IPARAMVALUE NAME=\"DeepInheritance\"><VALUE>" +
  446. DeepInheritance + "</VALUE></IPARAMVALUE>");
  447. }
  448. function GetQueryParameter ()
  449. {
  450. return ("<IPARAMVALUE NAME=\"Query\"><VALUE>" +
  451. document.all.querybox.value + "</VALUE></IPARAMVALUE>" );
  452. }
  453. function GetQueryLanguageParameter ()
  454. {
  455. return ("<IPARAMVALUE NAME=\"QueryLanguage\"><VALUE>" +
  456. "WQL" + "</VALUE></IPARAMVALUE>");
  457. }
  458. function DoCustomOperation()
  459. {
  460. var fso = new ActiveXObject("Scripting.FileSystemObject");
  461. var theFile = fso.OpenTextFile(".\multireq.xml");
  462. alert ("Hello");
  463. }
  464. function EnumInstance()
  465. {
  466. InitOperation ("EnumerateInstances");
  467. return RequestPreamble ("EnumerateInstances") +
  468. "<IPARAMVALUE NAME=\"ClassName\"><CLASSNAME NAME=\"" +
  469. "CIM_Processor" + "\"/></IPARAMVALUE>" +
  470. "<IPARAMVALUE NAME=\"IncludeQualifiers\"><VALUE>" +
  471. "TRUE" + "</VALUE></IPARAMVALUE>" +
  472. "<IPARAMVALUE NAME=\"LocalOnly\"><VALUE>" + "FALSE" +
  473. "</VALUE></IPARAMVALUE>" +
  474. "<IPARAMVALUE NAME=\"IncludeClassOrigin\"><VALUE>" +
  475. "TRUE" + "</VALUE></IPARAMVALUE>" +
  476. "<IPARAMVALUE NAME=\"DeepInheritance\"><VALUE>" +
  477. "TRUE" + "</VALUE></IPARAMVALUE>" +
  478. RequestPostamble ();
  479. }
  480. function GetInstance(strDevID)
  481. {
  482. InitOperation ("GetInstance");
  483. return RequestPreamble ("GetInstance") +
  484. GetInstanceNameParameter (strDevID) +
  485. "<IPARAMVALUE NAME=\"IncludeQualifiers\"><VALUE>" +
  486. "TRUE" + "</VALUE></IPARAMVALUE>" +
  487. "<IPARAMVALUE NAME=\"LocalOnly\"><VALUE>" + "FALSE" +
  488. "</VALUE></IPARAMVALUE>" +
  489. "<IPARAMVALUE NAME=\"IncludeClassOrigin\"><VALUE>" +
  490. "TRUE" + "</VALUE></IPARAMVALUE>" +
  491. "<IPARAMVALUE NAME=\"DeepInheritance\"><VALUE>" +
  492. "TRUE" + "</VALUE></IPARAMVALUE>" +
  493. RequestPostamble ();
  494. }
  495. function ShowResults(theXMLRequest, theXMLBody, strDevID)
  496. {
  497. theXMLRequest.send (theXMLBody);
  498. theXMLResponse.async = false;
  499. theXMLResponse.validateOnParse = false;
  500. // document.all("ResponseHeaders").innerText = theXMLRequest.getAllResponseHeaders();
  501. theXMLResponse.loadXML(theXMLRequest.responseText);
  502. var parseError = theXMLResponse.parseError;
  503. if (parseError && (0 < parseError.errorCode))
  504. {
  505. alert (parseError.errorCode);
  506. alert (parseError.reason);
  507. }
  508. update(theXMLResponse);
  509. g_strDevID = strDevID;
  510. updateUtilization();
  511. timeoutID = window.setInterval("updateUtilization()", 2000);
  512. }
  513. function ShowList(theXMLRequest, theXMLBody)
  514. {
  515. theXMLRequest.send (theXMLBody);
  516. theXMLResponse.async = false;
  517. theXMLResponse.validateOnParse = false;
  518. theXMLResponse.loadXML(theXMLRequest.responseText);
  519. var parseError = theXMLResponse.parseError;
  520. if (parseError && (0 < parseError.errorCode))
  521. {
  522. alert (parseError.errorCode);
  523. alert (parseError.reason);
  524. }
  525. updateList(theXMLResponse);
  526. }
  527. function ShowRequest(theBody)
  528. {
  529. theXMLResponse.loadXML(theBody);
  530. update(theXMLResponse);
  531. }
  532. function ParseNamespace (nsPath)
  533. {
  534. var parsedPath = "";
  535. var inputPath = new String (nsPath);
  536. var startIndex = 0;
  537. while ((-1 != (index = inputPath.indexOf ("/", startIndex))) ||
  538. (-1 != (index = inputPath.indexOf ("\\", startIndex))))
  539. {
  540. parsedPath = parsedPath +
  541. '<NAMESPACE NAME="' + inputPath.substr (startIndex,
  542. index - startIndex) + '"/>';
  543. startIndex = index + 1;
  544. }
  545. parsedPath = parsedPath + '<NAMESPACE NAME="'
  546. + inputPath.substr (startIndex) + '"/>';
  547. return (parsedPath);
  548. }
  549. function RequestPreamble (method)
  550. {
  551. var str = "<?xml version=\"1.0\" ?>" +
  552. "<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\">" +
  553. "<MESSAGE ID=\"877\" PROTOCOLVERSION=\"1.0\">" +
  554. "<SIMPLEREQ>" +
  555. "<IMETHODCALL NAME=\"" + method + "\">" +
  556. "<LOCALNAMESPACEPATH>" +
  557. ParseNamespace ("root\\cimv2") +
  558. "</LOCALNAMESPACEPATH>";
  559. return (str);
  560. }
  561. function RequestPostamble ()
  562. {
  563. return ("</IMETHODCALL></SIMPLEREQ></MESSAGE></CIM>");
  564. }
  565. </SCRIPT>
  566. <BODY>
  567. <DIV CLASS="headline">CIM Processor Monitor</DIV>
  568. <DIV class=group>
  569. <TABLE align=left border=0 cellPadding=1 cellSpacing=1 width="75%">
  570. <TR>
  571. <TD><FONT size=1><LABEL>CIM Server URL&nbsp;</LABEL></FONT></TD>
  572. </TR>
  573. <TD><INPUT id=urlbox size=35 value=http://rajeshr72/cimom
  574. style="HEIGHT: 22px; WIDTH: 235px"></TD></TR>
  575. <TR>
  576. <TD></TD>
  577. <TD></TD></TR></TABLE></DIV>
  578. <P>
  579. <DIV class=group>&nbsp;</DIV>
  580. <DIV class=group>&nbsp;</DIV>
  581. <DIV class=group><CENTER><BUTTON
  582. id=operationButton onclick=DoOperation(true) style="LEFT: 221px; TOP: 248px">Get
  583. Processor List</BUTTON></CENTER></DIV>
  584. <DIV class=instructions>
  585. </DIV>
  586. <DIV class=instructions>
  587. <HR>
  588. &nbsp;</DIV>
  589. <DIV id="xsllist"><!-- resulting HTML will be inserted here --></DIV>
  590. </BODY>
  591. </HTML>