Cleaned up code.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8190 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -1,4 +1,4 @@ | ||||
| /***************** Dialogs *****************/ | ||||
| /*--------------- Dialogs ---------------*/ | ||||
| .ui-dialog input { | ||||
| 	border: solid 1px #BDBDBD; | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| @@ -12,7 +12,7 @@ | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| } | ||||
|  | ||||
| /***************** Tooltip *****************/ | ||||
| /*--------------- Tooltip ---------------*/ | ||||
| .tooltip { | ||||
| 	background-color: #000; | ||||
| 	border: 1px solid #fff; | ||||
| @@ -31,7 +31,7 @@ | ||||
| 	margin: 0px; | ||||
| } | ||||
|  | ||||
| /****************** Header ******************/ | ||||
| /*--------------- Header ---------------*/ | ||||
| #header { | ||||
| 	height: 40px; | ||||
| 	width: 1000px; | ||||
| @@ -107,7 +107,7 @@ | ||||
| 	display: block; | ||||
| } | ||||
|  | ||||
| /****************** Content section ******************/ | ||||
| /*--------------- Body and content ---------------*/ | ||||
| body { | ||||
| 	background-color: #1C1C1C; | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| @@ -124,7 +124,7 @@ body { | ||||
| 	overflow: auto; | ||||
| } | ||||
|  | ||||
| /****************** Groups section ******************/ | ||||
| /*--------------- Groups ---------------*/ | ||||
| #groups { | ||||
| 	width: 150px; | ||||
| 	vertical-align: top; | ||||
| @@ -158,14 +158,14 @@ body { | ||||
| 	color: #FF0000; | ||||
| } | ||||
|  | ||||
| /****************** Nodes section ******************/ | ||||
| /*--------------- Nodes section ---------------*/ | ||||
| #nodes { | ||||
| 	width: 700px; | ||||
| 	margin: 20px; | ||||
| 	display: inline-table; | ||||
| } | ||||
|  | ||||
| /****************** Info/warning bar ******************/ | ||||
| /*--------------- Info/warning bar ---------------*/ | ||||
| span.ui-icon-info { | ||||
| 	float: left; | ||||
| 	margin-right: 0.3em; | ||||
| @@ -193,7 +193,7 @@ span.ui-icon-info { | ||||
| 		50% 50% repeat-x; | ||||
| } | ||||
|  | ||||
| /****************** Tabs ******************/ | ||||
| /*--------------- jQuery tabs ---------------*/ | ||||
| .tab { | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| 	border-style: none; | ||||
| @@ -214,7 +214,7 @@ span.ui-icon-info { | ||||
| 	cursor: pointer; | ||||
| } | ||||
|  | ||||
| /****************** Inventory and user entry ******************/ | ||||
| /*--------------- Inventory and user entry ---------------*/ | ||||
| .tab table { | ||||
| 	border-width: 1px; | ||||
| 	border-spacing: 0px; | ||||
| @@ -292,7 +292,7 @@ legend { | ||||
| 	height: 300px; | ||||
| } | ||||
|  | ||||
| /****************** Action bar ******************/ | ||||
| /*--------------- Actions bar ---------------*/ | ||||
| .actionBar { | ||||
| 	display: inline-table; | ||||
| } | ||||
| @@ -317,7 +317,7 @@ legend { | ||||
| 	margin: 0; | ||||
| } | ||||
|  | ||||
| /****************** Status bar ******************/ | ||||
| /*--------------- Status bar ---------------*/ | ||||
| .statusBar { | ||||
| 	border: solid 1px #F5D0A9; | ||||
| 	-moz-border-radius: .5em; | ||||
| @@ -333,7 +333,7 @@ legend { | ||||
| 	word-wrap: break-word; | ||||
| } | ||||
|  | ||||
| /****************** Info bar ******************/ | ||||
| /*--------------- Info bar ---------------*/ | ||||
| .infoBar { | ||||
| 	border: solid 1px #D8D8D8; | ||||
| 	padding: 0px 10px; | ||||
| @@ -351,7 +351,7 @@ legend { | ||||
| 	word-wrap: break-word; | ||||
| } | ||||
|  | ||||
| /****************** Datatable ******************/ | ||||
| /*--------------- jQuery datatable ---------------*/ | ||||
| .dataTables_wrapper { | ||||
| 	overflow: auto; | ||||
| 	width: 700px; | ||||
| @@ -461,7 +461,7 @@ legend { | ||||
| 	color: #FF0000; | ||||
| } | ||||
|  | ||||
| /****************** Editable column ******************/ | ||||
| /*--------------- Editable column ---------------*/ | ||||
| .tab .datatable textarea { | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| 	border: solid 1px #BDBDBD; | ||||
| @@ -483,7 +483,7 @@ legend { | ||||
| 	background-color: #E6E6E6; | ||||
| } | ||||
|  | ||||
| /****************** Context menu ******************/ | ||||
| /*--------------- jQuery context menu ---------------*/ | ||||
| .context-menu-theme-vista { | ||||
| 	background: #FAFAFA url(../images/context-menu-bg.gif) repeat-y left top | ||||
| 		; | ||||
| @@ -530,7 +530,7 @@ legend { | ||||
| 	color: #A7A7A7; | ||||
| } | ||||
|  | ||||
| /****************** Forms ******************/ | ||||
| /*--------------- Forms ---------------*/ | ||||
| .form label { | ||||
| 	color: #424242; | ||||
| 	line-height: 1.5; | ||||
| @@ -597,7 +597,7 @@ table a:hover { | ||||
| 	border: solid 1px #d4d4d4; | ||||
| } | ||||
|  | ||||
| /****************** Provision disk table ******************/ | ||||
| /*--------------- Provision disk table ---------------*/ | ||||
| .provision table { | ||||
| 	border-width: 1px; | ||||
| 	border-spacing: 0px; | ||||
| @@ -614,7 +614,7 @@ table a:hover { | ||||
| 	width: 60px; | ||||
| } | ||||
|  | ||||
| /****************** Provision and clone table ******************/ | ||||
| /*--------------- Provision and clone table ---------------*/ | ||||
| .special table { | ||||
| 	border-width: 1px; | ||||
| 	border-spacing: 0px; | ||||
| @@ -630,7 +630,7 @@ table a:hover { | ||||
| 	padding: 3px; | ||||
| } | ||||
|  | ||||
| /****************** Provision and monitor forms ******************/ | ||||
| /*--------------- Provision and monitor forms ---------------*/ | ||||
| .provision div,.monitor div { | ||||
| 	margin: 10px 0; | ||||
| 	display: block; | ||||
| @@ -658,7 +658,7 @@ table a:hover { | ||||
| 	margin: 0px 0px 15px 0px; | ||||
| } | ||||
|  | ||||
| /****************** Physical layout section ******************/ | ||||
| /*--------------- Physical layout section ---------------*/ | ||||
| .frameDiv { | ||||
| 	width: 179px; | ||||
| 	height: 500px; | ||||
|   | ||||
| Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB | 
| @@ -15,36 +15,4 @@ if (!isAuthenticated()) { | ||||
| } else { | ||||
| 	loadContent(); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Test lib/cmd.php | ||||
|  */ | ||||
| function testCmdPhp() { | ||||
| 	$xml = docmd('rinv', 'gpok6', array('all')); | ||||
| 	$rsp = array(); | ||||
| 		 | ||||
| 	foreach ($xml->children() as $child) { | ||||
| 		foreach ($child->children() as $data) { | ||||
| 			if($data->name) { | ||||
| 				$node = $data->name; | ||||
| 				 | ||||
| 				if($data->data->contents){ | ||||
| 					$cont = $data->data->contents; | ||||
| 				} | ||||
| 				else{ | ||||
| 					$cont = $data->data; | ||||
| 				} | ||||
| 				 | ||||
| 				$cont = str_replace(":|:", "\n", $cont); | ||||
| 				array_push($rsp, "$node: $cont"); | ||||
| 			} else if(strlen("$data") > 2) { | ||||
| 				$data = str_replace(":|:", "\n", $data); | ||||
| 				array_push($rsp, "$data"); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|   	 | ||||
| 	$rtn = array("rsp" => $rsp, "msg" => ''); | ||||
| 	echo json_encode($rtn); | ||||
| } | ||||
| ?> | ||||
| @@ -1,296 +1,323 @@ | ||||
| /** | ||||
|  * Load update page | ||||
|  * | ||||
|  *  | ||||
|  * @return Nothing | ||||
|  */ | ||||
|  function loadUpdatePage() { | ||||
|     var repositoryDiv = $('<div id="repository"></div>'); | ||||
|     var rpmDiv = $('<div id="rpm"></div>'); | ||||
|     var statusDiv = createStatusBar("update"); | ||||
|     statusDiv.hide(); | ||||
|      | ||||
|     $('#updateTab').append(statusDiv); | ||||
| function loadUpdatePage() { | ||||
| 	var repositoryDiv = $('<div id="repository"></div>'); | ||||
| 	var rpmDiv = $('<div id="rpm"></div>'); | ||||
| 	var statusDiv = createStatusBar("update"); | ||||
| 	statusDiv.hide(); | ||||
|  | ||||
| 	$('#updateTab').append(statusDiv); | ||||
| 	$('#updateTab').append('<br>'); | ||||
|     $('#updateTab').append(repositoryDiv); | ||||
|     $('#updateTab').append(rpmDiv); | ||||
|          | ||||
|     var infoBar = createInfoBar('Select the RPM and repository, then press Update'); | ||||
|     repositoryDiv.append(infoBar); | ||||
|      | ||||
|     repositoryDiv.append("<fieldset><legend>Repository</legend></fieldset>"); | ||||
| 	$('#updateTab').append(repositoryDiv); | ||||
| 	$('#updateTab').append(rpmDiv); | ||||
|  | ||||
|     $.ajax({ | ||||
|         url : 'lib/systemcmd.php', | ||||
|         dataType : 'json', | ||||
|         data : { | ||||
|             cmd : 'ostype' | ||||
|         }, | ||||
| 	var infoBar = createInfoBar('Select the RPM and repository, then press Update'); | ||||
| 	repositoryDiv.append(infoBar); | ||||
|  | ||||
|         success : showRepository | ||||
|     }); | ||||
| 	repositoryDiv.append("<fieldset><legend>Repository</legend></fieldset>"); | ||||
|  | ||||
|     rpmDiv.append("<fieldset></fieldset>"); | ||||
| 	$.ajax( { | ||||
| 		url : 'lib/systemcmd.php', | ||||
| 		dataType : 'json', | ||||
| 		data : { | ||||
| 			cmd : 'ostype' | ||||
| 		}, | ||||
|  | ||||
|     $.ajax({ | ||||
|         url: 'lib/systemcmd.php', | ||||
|         dataType : 'json', | ||||
|         data : { | ||||
|             cmd : 'rpm -q xCAT-client perl-xCAT xCAT-server xCAT xCAT-rmc xCAT-UI' | ||||
|         }, | ||||
| 		success : showRepository | ||||
| 	}); | ||||
|  | ||||
|         success : showRpmInfo | ||||
|     }); | ||||
| 	rpmDiv.append("<fieldset></fieldset>"); | ||||
|  | ||||
| 	$.ajax( { | ||||
| 		url : 'lib/systemcmd.php', | ||||
| 		dataType : 'json', | ||||
| 		data : { | ||||
| 			cmd : 'rpm -q xCAT-client perl-xCAT xCAT-server xCAT xCAT-rmc xCAT-UI' | ||||
| 		}, | ||||
|  | ||||
| 		success : showRpmInfo | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Show the RPM Repository, it can use user's last choice and input | ||||
|  * | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data returned from HTTP request | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function showRepository(data) { | ||||
|     var DevelRepository = ""; | ||||
|     var StableRepository = ""; | ||||
|     var Show = ""; | ||||
| 	var DevelRepository = ""; | ||||
| 	var StableRepository = ""; | ||||
| 	var Show = ""; | ||||
|  | ||||
|     // get the corresponding repository by OS Type | ||||
|     if ("aix" == data.rsp) { | ||||
|         DevelRepository = "http://xcat.sourceforge.net/aix/devel/xcat-core/"; | ||||
|         StableRepository = "http://xcat.sourceforge.net/aix/xcat-core/"; | ||||
|     } else { | ||||
|         DevelRepository = "http://xcat.sourceforge.net/yum/devel/xcat-core/"; | ||||
|         StableRepository = "http://xcat.sourceforge.net/yum/xcat-core/"; | ||||
|     } | ||||
| 	// get the corresponding repository by OS Type | ||||
| 	if ("aix" == data.rsp) { | ||||
| 		DevelRepository = "http://xcat.sourceforge.net/aix/devel/xcat-core/"; | ||||
| 		StableRepository = "http://xcat.sourceforge.net/aix/xcat-core/"; | ||||
| 	} else { | ||||
| 		DevelRepository = "http://xcat.sourceforge.net/yum/devel/xcat-core/"; | ||||
| 		StableRepository = "http://xcat.sourceforge.net/yum/xcat-core/"; | ||||
| 	} | ||||
|  | ||||
|     var repoList = $('<ol></ol>'); | ||||
|      | ||||
|     //display the Devel Repository, remember user's last selection | ||||
|     Show = Show + "<li><input type='radio' "; | ||||
|     if (1 == $.cookie('xcatrepository')) { | ||||
|         Show = Show + "checked='true'"; | ||||
|     } | ||||
| 	var repoList = $('<ol></ol>'); | ||||
|  | ||||
|     Show = Show + "name='reporadio' value='" + DevelRepository + "'>"; | ||||
|     Show = Show + DevelRepository + "(<strong>Devel</strong>)</li>"; | ||||
| 	// display the Devel Repository, remember user's last selection | ||||
| 	Show = Show + "<li><input type='radio' "; | ||||
| 	if (1 == $.cookie('xcatrepository')) { | ||||
| 		Show = Show + "checked='true'"; | ||||
| 	} | ||||
|  | ||||
|     repoList.append(Show); | ||||
| 	Show = Show + "name='reporadio' value='" + DevelRepository + "'>"; | ||||
| 	Show = Show + DevelRepository + "(<strong>Devel</strong>)</li>"; | ||||
|  | ||||
|     //display the Stable Repository, remember user's last selection | ||||
|     Show = "<li><input type='radio' "; | ||||
|     if (2 == $.cookie('xcatrepository')) { | ||||
|         Show = Show + "checked='true'"; | ||||
|     } | ||||
| 	repoList.append(Show); | ||||
|  | ||||
|     Show = Show + "name='reporadio' value='" + StableRepository + "'>"; | ||||
|     Show = Show + StableRepository + "(<strong>Stable</strong>)</li>"; | ||||
| 	// display the Stable Repository, remember user's last selection | ||||
| 	Show = "<li><input type='radio' "; | ||||
| 	if (2 == $.cookie('xcatrepository')) { | ||||
| 		Show = Show + "checked='true'"; | ||||
| 	} | ||||
|  | ||||
|     repoList.append(Show); | ||||
| 	Show = Show + "name='reporadio' value='" + StableRepository + "'>"; | ||||
| 	Show = Show + StableRepository + "(<strong>Stable</strong>)</li>"; | ||||
|  | ||||
|     //display the Input Repository, remember user's last selection | ||||
|     if (($.cookie('xcatrepository')) | ||||
|         && (1 != $.cookie('xcatrepository')) | ||||
|         && (2 != $.cookie('xcatrepository'))) { | ||||
|         Show = "<li><input type='radio' checked='true' name='reporadio' value=''>Other: "; | ||||
|         Show += "<input style='width: 500px' id='repositoryaddr' value='" + $.cookie('xcatrepository') + "'</li>"; | ||||
|     } else { | ||||
|         Show = "<li><input type='radio' name='reporadio' value=''>Other: "; | ||||
|         Show += "<input style='width: 500px' id='repositoryaddr' value=''</li>"; | ||||
|     } | ||||
| 	repoList.append(Show); | ||||
|  | ||||
|     repoList.append(Show); | ||||
|     $('#repository fieldset').append(repoList); | ||||
| 	// display the Input Repository, remember user's last selection | ||||
| 	if (($.cookie('xcatrepository')) && (1 != $.cookie('xcatrepository')) && (2 != $.cookie('xcatrepository'))) { | ||||
| 		Show = "<li><input type='radio' checked='true' name='reporadio' value=''>Other: "; | ||||
| 		Show += "<input style='width: 500px' id='repositoryaddr' value='" + $.cookie('xcatrepository') + "'</li>"; | ||||
| 	} else { | ||||
| 		Show = "<li><input type='radio' name='reporadio' value=''>Other: "; | ||||
| 		Show += "<input style='width: 500px' id='repositoryaddr' value=''</li>"; | ||||
| 	} | ||||
|  | ||||
| 	repoList.append(Show); | ||||
| 	$('#repository fieldset').append(repoList); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Show all xCAT RPMs | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data returned from HTTP request | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function showRpmInfo(data) { | ||||
|     var Rpms = null; | ||||
|     var Show = ""; | ||||
|     var RpmNames = new Array("xCAT-client","perl-xCAT","xCAT-server","xCAT","xCAT-rmc","xCAT-UI"); | ||||
|     var temp = 0; | ||||
|     if(null == data.rsp) { | ||||
|         $('#rpm fieldset').append("Get Rpm Info Error!"); | ||||
|         return; | ||||
|     } | ||||
| 	var Rpms = null; | ||||
| 	var Show = ""; | ||||
| 	var RpmNames = new Array("xCAT-client", "perl-xCAT", "xCAT-server", "xCAT", "xCAT-rmc", "xCAT-UI"); | ||||
| 	var temp = 0; | ||||
| 	if (null == data.rsp) { | ||||
| 		$('#rpm fieldset').append("Get Rpm Info Error!"); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
|     Rpms = data.rsp.split(/\n/); | ||||
|     // no rpm installed, return | ||||
|     if (1 > Rpms.length) { | ||||
|         $('#rpm fieldset').append("No Rpm installed!"); | ||||
|         return; | ||||
|     } | ||||
| 	Rpms = data.rsp.split(/\n/); | ||||
| 	// no rpm installed, return | ||||
| 	if (1 > Rpms.length) { | ||||
| 		$('#rpm fieldset').append("No Rpm installed!"); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
|     // clear the old data | ||||
|     $('#rpm fieldset').children().remove(); | ||||
|     $('#rpm fieldset').append("<legend>xCAT Rpm Info</legend>"); | ||||
|      | ||||
|     Show = "<table id=rpmtable >"; | ||||
|     Show += "<thead><tr>"; | ||||
|     Show += "<th><input type='checkbox' id='selectall' value='' onclick='updateSelectAll()'></th>"; | ||||
|     Show += "<th><b>Package Name</b></th><th><b>Version</b></th>"; | ||||
|     Show += "</tr></thead>"; | ||||
| 	// clear the old data | ||||
| 	$('#rpm fieldset').children().remove(); | ||||
| 	$('#rpm fieldset').append("<legend>xCAT Rpm Info</legend>"); | ||||
|  | ||||
|     for (temp = 0; temp < Rpms.length; temp++) { | ||||
|         // empty line continue | ||||
|         if ("" == Rpms[temp]) { | ||||
|             continue; | ||||
|         } | ||||
| 	Show = "<table id=rpmtable >"; | ||||
| 	Show += "<thead><tr>"; | ||||
| 	Show += "<th><input type='checkbox' id='selectall' value='' onclick='updateSelectAll()'></th>"; | ||||
| 	Show += "<th><b>Package Name</b></th><th><b>Version</b></th>"; | ||||
| 	Show += "</tr></thead>"; | ||||
|  | ||||
|         // the rpm is not installed, continue | ||||
|         if (-1 != Rpms[temp].indexOf("not")) { | ||||
|             continue; | ||||
|         } | ||||
| 	for (temp = 0; temp < Rpms.length; temp++) { | ||||
| 		// empty line continue | ||||
| 		if ("" == Rpms[temp]) { | ||||
| 			continue; | ||||
| 		} | ||||
|  | ||||
|         // show the version in table | ||||
|         Show += "<tr>"; | ||||
|         Show += "<td><input type='checkbox' value='" + RpmNames[temp] + "'></td>"; | ||||
|         Show += "<td>" + RpmNames[temp] + "</td><td>" + Rpms[temp].substr(RpmNames[temp].length + 1) + "</td>"; | ||||
|         Show += "</tr>"; | ||||
|     } | ||||
|     Show += "</table>"; | ||||
|     Show += "<br\>"; | ||||
|     $('#rpm fieldset').append(Show); | ||||
| 		// the rpm is not installed, continue | ||||
| 		if (-1 != Rpms[temp].indexOf("not")) { | ||||
| 			continue; | ||||
| 		} | ||||
|  | ||||
|     // add the update button | ||||
|     var updateButton = createButton('Update'); | ||||
|     $('#rpm fieldset').append(updateButton); | ||||
|     updateButton.bind('click', function(){ | ||||
|     		updateRpm(); | ||||
|     }); | ||||
| 		// show the version in table | ||||
| 		Show += "<tr>"; | ||||
| 		Show += "<td><input type='checkbox' value='" + RpmNames[temp] + "'></td>"; | ||||
| 		Show += "<td>" + RpmNames[temp] + "</td><td>" + Rpms[temp].substr(RpmNames[temp].length + 1) + "</td>"; | ||||
| 		Show += "</tr>"; | ||||
| 	} | ||||
| 	Show += "</table>"; | ||||
| 	Show += "<br\>"; | ||||
| 	$('#rpm fieldset').append(Show); | ||||
|  | ||||
| 	// add the update button | ||||
| 	var updateButton = createButton('Update'); | ||||
| 	$('#rpm fieldset').append(updateButton); | ||||
| 	updateButton.bind('click', function() { | ||||
| 		updateRpm(); | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Select all checkboxes | ||||
|  *  | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function updateSelectAll() { | ||||
|     var check_status = $('#selectall').attr('checked'); | ||||
|     $('input:checkbox').attr('checked', check_status); | ||||
| 	var check_status = $('#selectall').attr('checked'); | ||||
| 	$('input:checkbox').attr('checked', check_status); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Update selected xCAT RPMs | ||||
|  *  | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function updateRpm() { | ||||
| 	// Remove any warning messages | ||||
| 	$('#updateTab').find('.ui-state-error').remove(); | ||||
| 	 | ||||
|     var rpmPath = $('input[type=radio]:checked').val(); | ||||
|     var rpmPathType = "0"; | ||||
|     var rpms = ""; | ||||
|     var temp = ""; | ||||
|  | ||||
|     if (undefined == rpmPath) { | ||||
|         rpmPath = ""; | ||||
|     } | ||||
| 	var rpmPath = $('input[type=radio]:checked').val(); | ||||
| 	var rpmPathType = "0"; | ||||
| 	var rpms = ""; | ||||
| 	var temp = ""; | ||||
|  | ||||
|     // select other and we should use the value in the input | ||||
|     if ("" == rpmPath) { | ||||
|         //user input the repo, and we must stroe it in the cookie | ||||
|         rpmPath = $('#repositoryaddr').val(); | ||||
|         rpmPathType = rpmPath; | ||||
|     } else { | ||||
|         if(-1 == rpmPath.toLowerCase().indexOf("devel")) { | ||||
|             rpmPathType = "2"; | ||||
|         } else { | ||||
|             rpmPathType = "1";; | ||||
|         } | ||||
|     } | ||||
| 	if (undefined == rpmPath) { | ||||
| 		rpmPath = ""; | ||||
| 	} | ||||
|  | ||||
|     $("input[type=checkbox]:checked").each(function(){ | ||||
|         temp = $(this).val(); | ||||
|         if("" == temp) { | ||||
|             //continue; | ||||
|             return true; | ||||
|         } | ||||
|          | ||||
|         var pattern = new RegExp("^" + temp + ",|," + temp + ",");; | ||||
|         if (pattern.test(rpms)) { | ||||
|             return true; | ||||
|         } | ||||
|         rpms = rpms + temp + ","; | ||||
|     }); | ||||
| 	// select other and we should use the value in the input | ||||
| 	if ("" == rpmPath) { | ||||
| 		// user input the repo, and we must stroe it in the cookie | ||||
| 		rpmPath = $('#repositoryaddr').val(); | ||||
| 		rpmPathType = rpmPath; | ||||
| 	} else { | ||||
| 		if (-1 == rpmPath.toLowerCase().indexOf("devel")) { | ||||
| 			rpmPathType = "2"; | ||||
| 		} else { | ||||
| 			rpmPathType = "1"; | ||||
| 			; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|     if (0 < rpms.length) { | ||||
|         rpms = rpms.slice(0, -1); | ||||
|     } | ||||
|      | ||||
|     // Check RPM and repository | ||||
|     var errMsg = ''; | ||||
|     if (!rpms) { | ||||
|     	errMsg = "Please select the rpm!<br>"; | ||||
|     } | ||||
| 	$("input[type=checkbox]:checked").each(function() { | ||||
| 		temp = $(this).val(); | ||||
| 		if ("" == temp) { | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
|     if (!rpmPath) { | ||||
|         errMsg += "Please select or input the repository!"; | ||||
|     } | ||||
|      | ||||
|     if (!rpms || !rpmPath) { | ||||
|     	// Show warning message | ||||
|     	var warn = createWarnBar(errMsg); | ||||
|     	warn.prependTo($('#updateTab')); | ||||
|     	return; | ||||
|     } | ||||
| 		var pattern = new RegExp("^" + temp + ",|," + temp + ","); | ||||
|  | ||||
|     // remember users' choice and input | ||||
|     $.cookie('xcatrepository', rpmPathType, { path: '/xcat', expires: 10 }); | ||||
| 		if (pattern.test(rpms)) { | ||||
| 			return true; | ||||
| 		} | ||||
| 		rpms = rpms + temp + ","; | ||||
| 	}); | ||||
|  | ||||
|     $('#update').show(); | ||||
|     $('#update').empty(); | ||||
|     $('#update').append("<p>Updating <b>" + rpms + "</b> from <b>" + rpmPath + "</b></p>"); | ||||
|     $('#update').append("<img id='loadingpic' src='images/loader.gif'>"); | ||||
|     $('#rpm button').attr('disabled', 'true'); | ||||
| 	if (0 < rpms.length) { | ||||
| 		rpms = rpms.slice(0, -1); | ||||
| 	} | ||||
|  | ||||
|     // send the update command to server | ||||
|     $.ajax( { | ||||
|         url : 'lib/cmd.php', | ||||
|         dataType : 'json', | ||||
|         data : { | ||||
|             cmd : 'webrun', | ||||
|             tgt : '', | ||||
|             args : 'update;' + rpms + ";" + rpmPath, | ||||
|             msg : '' | ||||
|         }, | ||||
| 	// Check RPM and repository | ||||
| 	var errMsg = ''; | ||||
| 	if (!rpms) { | ||||
| 		errMsg = "Please select the rpm!<br>"; | ||||
| 	} | ||||
|  | ||||
|         success : ShowUpdateResult | ||||
|     }); | ||||
| 	if (!rpmPath) { | ||||
| 		errMsg += "Please select or input the repository!"; | ||||
| 	} | ||||
|  | ||||
| 	if (!rpms || !rpmPath) { | ||||
| 		// Show warning message | ||||
| 		var warn = createWarnBar(errMsg); | ||||
| 		warn.prependTo($('#updateTab')); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	// remember users' choice and input | ||||
| 	$.cookie('xcatrepository', rpmPathType, { | ||||
| 		path : '/xcat', | ||||
| 		expires : 10 | ||||
| 	}); | ||||
|  | ||||
| 	$('#update').show(); | ||||
| 	$('#update').empty(); | ||||
| 	$('#update').append("<p>Updating <b>" + rpms + "</b> from <b>" + rpmPath + "</b></p>"); | ||||
| 	$('#update').append("<img id='loadingpic' src='images/loader.gif'>"); | ||||
| 	$('#rpm button').attr('disabled', 'true'); | ||||
|  | ||||
| 	// send the update command to server | ||||
| 	$.ajax( { | ||||
| 		url : 'lib/cmd.php', | ||||
| 		dataType : 'json', | ||||
| 		data : { | ||||
| 			cmd : 'webrun', | ||||
| 			tgt : '', | ||||
| 			args : 'update;' + rpms + ";" + rpmPath, | ||||
| 			msg : '' | ||||
| 		}, | ||||
|  | ||||
| 		success : ShowUpdateResult | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Show the results of the RPM update | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data returned from HTTP request | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function ShowUpdateResult(data) { | ||||
|     var temp = 0; | ||||
| 	var temp = 0; | ||||
| 	$('#loadingpic').remove(); | ||||
|      | ||||
|     var resArray = data.rsp[0].split(/\n/); | ||||
|     if (0 < resArray.length) { | ||||
|     	// Show last lines | ||||
|         if (('' == resArray[resArray.length - 1]) && (resArray.length > 1)){ | ||||
|         	$('#update').append(resArray[resArray.length - 2]); | ||||
|         } | ||||
|         else { | ||||
|         	$('#update').append(resArray[resArray.length - 1]); | ||||
|         } | ||||
|          | ||||
|         // Create link to show details | ||||
|         $('#update').append('<br><a>Show details</a>'); | ||||
|         $('#update a').bind('click', function(){ | ||||
|         	// Toggle details and change text | ||||
|         	$('#resDetail').toggle(); | ||||
|         	if ($('#update a').text() == 'Show details') { | ||||
|         		$('#update a').text('Hide details'); | ||||
|         	} else { | ||||
|         		$('#update a').text('Show details'); | ||||
|         	} | ||||
|         }); | ||||
|          | ||||
|         var resDetail = $('<div id="resDetail"></div>'); | ||||
|         resDetail.hide(); | ||||
|         $('#update').append(resDetail); | ||||
|          | ||||
|         for (temp = 0; temp < resArray.length; temp++) { | ||||
|         	resDetail.append(resArray[temp] + "<br>"); | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     //update the rpm info | ||||
|     $.ajax({ | ||||
|         url: 'lib/systemcmd.php', | ||||
|         dataType : 'json', | ||||
|         data : { | ||||
|             cmd : 'rpm -q xCAT-client perl-xCAT xCAT-server xCAT xCAT-rmc xCAT-UI' | ||||
|         }, | ||||
|  | ||||
|         success : showRpmInfo | ||||
|     }); | ||||
|      | ||||
|     $('#rpm button').attr('disabled', ''); | ||||
| 	var resArray = data.rsp[0].split(/\n/); | ||||
| 	if (0 < resArray.length) { | ||||
| 		// Show last lines | ||||
| 		if (('' == resArray[resArray.length - 1]) && (resArray.length > 1)) { | ||||
| 			$('#update').append(resArray[resArray.length - 2]); | ||||
| 		} else { | ||||
| 			$('#update').append(resArray[resArray.length - 1]); | ||||
| 		} | ||||
|  | ||||
| 		// Create link to show details | ||||
| 		$('#update').append('<br><a>Show details</a>'); | ||||
| 		$('#update a').bind('click', function() { | ||||
| 			// Toggle details and change text | ||||
| 			$('#resDetail').toggle(); | ||||
| 			if ($('#update a').text() == 'Show details') { | ||||
| 				$('#update a').text('Hide details'); | ||||
| 			} else { | ||||
| 				$('#update a').text('Show details'); | ||||
| 			} | ||||
| 		}); | ||||
|  | ||||
| 		var resDetail = $('<div id="resDetail"></div>'); | ||||
| 		resDetail.hide(); | ||||
| 		$('#update').append(resDetail); | ||||
|  | ||||
| 		for (temp = 0; temp < resArray.length; temp++) { | ||||
| 			resDetail.append(resArray[temp] + "<br>"); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// update the rpm info | ||||
| 	$.ajax( { | ||||
| 		url : 'lib/systemcmd.php', | ||||
| 		dataType : 'json', | ||||
| 		data : { | ||||
| 			cmd : 'rpm -q xCAT-client perl-xCAT xCAT-server xCAT xCAT-rmc xCAT-UI' | ||||
| 		}, | ||||
|  | ||||
| 		success : showRpmInfo | ||||
| 	}); | ||||
|  | ||||
| 	$('#rpm button').attr('disabled', ''); | ||||
| } | ||||
| @@ -43,7 +43,7 @@ zvmPlugin.prototype.loadClonePage = function(node) { | ||||
|  | ||||
| 		// Get hardware control point | ||||
| 		var nodeRow = $('#' + node).parent().parent(); | ||||
| 		var dTable = getNodesDataTable(); | ||||
| 		var dTable = $('#nodesDataTable').dataTable(); | ||||
| 		var rowPos = dTable.fnGetPosition(nodeRow.get(0)); | ||||
| 		var aData = dTable.fnGetData(rowPos); | ||||
| 		var hcp = aData[hcpCol]; | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
| function loadGangliaMon() { | ||||
| 	// Get Ganglia tab | ||||
| 	var gangliaTab = $('#gangliamon'); | ||||
| 		 | ||||
|  | ||||
| 	// Check whether Ganglia RPMs are installed on the xCAT MN | ||||
| 	$.ajax( { | ||||
| 		url : 'lib/systemcmd.php', | ||||
| @@ -17,7 +17,7 @@ function loadGangliaMon() { | ||||
|  | ||||
| 		success : checkGangliaRPMs | ||||
| 	}); | ||||
| 		 | ||||
|  | ||||
| 	// Create groups and nodes DIV | ||||
| 	var groups = $('<div id="groups"></div>'); | ||||
| 	var nodes = $('<div id="nodes"></div>'); | ||||
| @@ -54,7 +54,7 @@ function loadGangliaMon() { | ||||
|  */ | ||||
| function checkGangliaRPMs(data) { | ||||
| 	var gangliaTab = $('#gangliamon'); | ||||
| 	 | ||||
|  | ||||
| 	// Get the list of Ganglia RPMs installed | ||||
| 	var status = data.rsp.split(/\n/); | ||||
| 	var gangliaRPMs = [ "rrdtool", "ganglia-gmetad", "ganglia-gmond", "ganglia-web" ]; | ||||
| @@ -66,11 +66,11 @@ function checkGangliaRPMs(data) { | ||||
| 			missingRPMs = true; | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	// Append Ganglia PDF | ||||
| 	if (missingRPMs) { | ||||
| 		warningMsg += ". Refer to <a href='http://xcat.svn.sourceforge.net/viewvc/xcat/xcat-core/trunk/xCAT-client/share/doc/xCAT2-Monitoring.pdf'>xCAT2-Monitoring.pdf</a> for more information."; | ||||
| 		 | ||||
|  | ||||
| 		var warningBar = createWarnBar(warningMsg); | ||||
| 		warningBar.css('margin-bottom', '10px'); | ||||
| 		warningBar.prependTo(gangliaTab); | ||||
| @@ -96,37 +96,37 @@ function checkGangliaRPMs(data) { | ||||
| 			success : function(data) { | ||||
| 				if (data.rsp[0].indexOf("not-monitored") > -1) { | ||||
| 					// Create link to start Ganglia | ||||
| 					var startLnk = $('<a href="#">Click here</a>'); | ||||
| 					startLnk.css( { | ||||
| 						'color' : 'blue', | ||||
| 						'text-decoration' : 'none' | ||||
| 					}); | ||||
| 					startLnk.click(function() { | ||||
| 						// Turn on Ganglia for all nodes | ||||
| 						monitorNode('', 'on'); | ||||
| 					}); | ||||
| 			var startLnk = $('<a href="#">Click here</a>'); | ||||
| 			startLnk.css( { | ||||
| 				'color' : 'blue', | ||||
| 				'text-decoration' : 'none' | ||||
| 			}); | ||||
| 			startLnk.click(function() { | ||||
| 				// Turn on Ganglia for all nodes | ||||
| 				monitorNode('', 'on'); | ||||
| 			}); | ||||
|  | ||||
| 					// Create warning bar | ||||
| 					var warningBar = $('<div class="ui-state-error ui-corner-all"></div>'); | ||||
| 					var msg = $('<p></p>'); | ||||
| 					msg.append('<span class="ui-icon ui-icon-alert"></span>'); | ||||
| 					msg.append('Please start Ganglia Monitoring on xCAT. '); | ||||
| 					msg.append(startLnk); | ||||
| 					msg.append(' to start Ganglia Monitoring.'); | ||||
| 					warningBar.append(msg); | ||||
| 					warningBar.css('margin-bottom', '10px'); | ||||
| 					 | ||||
| 					// If there are any warning messages, append this warning after it | ||||
| 					var curWarnings = $('#gangliamon').find('.ui-state-error'); | ||||
| 					var gangliaTab = $('#gangliamon'); | ||||
| 					if (curWarnings.length) { | ||||
| 						curWarnings.after(warningBar); | ||||
| 					} else {					 | ||||
| 						warningBar.prependTo(gangliaTab); | ||||
| 					} | ||||
| 				} | ||||
| 			// Create warning bar | ||||
| 			var warningBar = $('<div class="ui-state-error ui-corner-all"></div>'); | ||||
| 			var msg = $('<p></p>'); | ||||
| 			msg.append('<span class="ui-icon ui-icon-alert"></span>'); | ||||
| 			msg.append('Please start Ganglia Monitoring on xCAT. '); | ||||
| 			msg.append(startLnk); | ||||
| 			msg.append(' to start Ganglia Monitoring.'); | ||||
| 			warningBar.append(msg); | ||||
| 			warningBar.css('margin-bottom', '10px'); | ||||
|  | ||||
| 			// If there are any warning messages, append this warning after it | ||||
| 			var curWarnings = $('#gangliamon').find('.ui-state-error'); | ||||
| 			var gangliaTab = $('#gangliamon'); | ||||
| 			if (curWarnings.length) { | ||||
| 				curWarnings.after(warningBar); | ||||
| 			} else { | ||||
| 				warningBar.prependTo(gangliaTab); | ||||
| 			} | ||||
| 		});		 | ||||
| 		} | ||||
| 	} | ||||
| 		}); | ||||
| 	} | ||||
| 	return; | ||||
| } | ||||
| @@ -141,7 +141,7 @@ function checkGangliaRPMs(data) { | ||||
| function loadGroups4Ganglia(data) { | ||||
| 	// Remove loader | ||||
| 	$('#groups').find('img').remove(); | ||||
| 	 | ||||
|  | ||||
| 	var groups = data.rsp; | ||||
| 	setGroupsCookies(data); | ||||
|  | ||||
| @@ -163,21 +163,24 @@ function loadGroups4Ganglia(data) { | ||||
| 	// Turn groups list into a tree | ||||
| 	$('#groups').append(ul); | ||||
| 	$('#groups').jstree( { | ||||
| 		core : { "initially_open" : [ "root" ] }, | ||||
| 		core : { | ||||
| 			"initially_open" : [ "root" ] | ||||
| 		}, | ||||
| 		themes : { | ||||
| 			"theme" : "default", | ||||
| 			"dots" : false,	// No dots | ||||
| 			"icons" : false	// No icons | ||||
| 			"dots" : false, // No dots | ||||
| 			"icons" : false // No icons | ||||
| 		} | ||||
| 	}); | ||||
| 	 | ||||
|  | ||||
| 	// Load nodes onclick | ||||
| 	$('#groups').bind('select_node.jstree', function(event, data) { | ||||
| 		var thisGroup = jQuery.trim(data.rslt.obj.text()); | ||||
| 		if (thisGroup) { | ||||
| 			// Clear nodes division | ||||
| 	$('#groups') | ||||
| 		.bind('select_node.jstree', function(event, data) { | ||||
| 			var thisGroup = jQuery.trim(data.rslt.obj.text()); | ||||
| 			if (thisGroup) { | ||||
| 				// Clear nodes division | ||||
| 			$('#nodes').children().remove(); | ||||
| 			 | ||||
|  | ||||
| 			// Create link to Ganglia | ||||
| 			var gangliaLnk = $('<a href="#">click here</a>'); | ||||
| 			gangliaLnk.css( { | ||||
| @@ -193,7 +196,8 @@ function loadGroups4Ganglia(data) { | ||||
| 			var info = $('<div class="ui-state-highlight ui-corner-all"></div>'); | ||||
| 			var msg = $('<p></p>'); | ||||
| 			msg.append('<span class="ui-icon ui-icon-info"></span>'); | ||||
| 			msg.append('Review the nodes that are monitored by Ganglia.  You can turn on Ganglia monitoring on a node by selecting it and clicking on Monitor. If you are satisfied with the nodes you want to monitor, '); | ||||
| 			msg | ||||
| 				.append('Review the nodes that are monitored by Ganglia.  You can turn on Ganglia monitoring on a node by selecting it and clicking on Monitor. If you are satisfied with the nodes you want to monitor, '); | ||||
| 			msg.append(gangliaLnk); | ||||
| 			msg.append(' to open Ganglia page.'); | ||||
| 			info.append(msg); | ||||
| @@ -209,7 +213,7 @@ function loadGroups4Ganglia(data) { | ||||
| 			tab.init(); | ||||
| 			$('#nodes').append(tab.object()); | ||||
| 			tab.add('nodesTab', 'Nodes', loader, false); | ||||
| 			 | ||||
|  | ||||
| 			// Get nodes within selected group | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| @@ -223,25 +227,25 @@ function loadGroups4Ganglia(data) { | ||||
|  | ||||
| 				success : loadNodes4Ganglia | ||||
| 			}); | ||||
| 			 | ||||
|  | ||||
| 			// Get subgroups within selected group | ||||
| 			// only when this is the parent group and not a subgroup | ||||
| 			if (data.rslt.obj.attr('id').indexOf('Subgroup') < 0) { | ||||
|     			$.ajax( { | ||||
|     				url : 'lib/cmd.php', | ||||
|     				dataType : 'json', | ||||
|     				data : { | ||||
|     					cmd : 'extnoderange', | ||||
|     					tgt : thisGroup, | ||||
|     					args : 'subgroups', | ||||
|     					msg : thisGroup | ||||
|     				}, | ||||
|      | ||||
|     				success : loadSubgroups | ||||
|     			}); | ||||
| 				$.ajax( { | ||||
| 					url : 'lib/cmd.php', | ||||
| 					dataType : 'json', | ||||
| 					data : { | ||||
| 						cmd : 'extnoderange', | ||||
| 						tgt : thisGroup, | ||||
| 						args : 'subgroups', | ||||
| 						msg : thisGroup | ||||
| 					}, | ||||
|  | ||||
| 					success : loadSubgroups | ||||
| 				}); | ||||
| 			} | ||||
| 		} // End of if (thisGroup) | ||||
| 	}); | ||||
| 	}   ); | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -342,9 +346,7 @@ function loadNodes4Ganglia(data) { | ||||
| 	 */ | ||||
| 	var powerLnk = $('<a>Power</a>'); | ||||
|  | ||||
| 	/* | ||||
| 	 * Power on | ||||
| 	 */ | ||||
| 	// Power on | ||||
| 	var powerOnLnk = $('<a>Power on</a>'); | ||||
| 	powerOnLnk.bind('click', function(event) { | ||||
| 		var tgtNodes = getNodesChecked('nodesDataTable'); | ||||
| @@ -353,9 +355,7 @@ function loadNodes4Ganglia(data) { | ||||
| 		} | ||||
| 	}); | ||||
|  | ||||
| 	/* | ||||
| 	 * Power off | ||||
| 	 */ | ||||
| 	// Power off | ||||
| 	var powerOffLnk = $('<a>Power off</a>'); | ||||
| 	powerOffLnk.bind('click', function(event) { | ||||
| 		var tgtNodes = getNodesChecked('nodesDataTable'); | ||||
| @@ -378,10 +378,8 @@ function loadNodes4Ganglia(data) { | ||||
|  | ||||
| 		} | ||||
| 	}); | ||||
| 	 | ||||
| 	/* | ||||
| 	 * Turn monitoring on | ||||
| 	 */ | ||||
|  | ||||
| 	// Turn monitoring on | ||||
| 	var monitorOnLnk = $('<a>Monitor on</a>'); | ||||
| 	monitorOnLnk.bind('click', function(event) { | ||||
| 		var tgtNodes = getNodesChecked('nodesDataTable'); | ||||
| @@ -390,9 +388,7 @@ function loadNodes4Ganglia(data) { | ||||
| 		} | ||||
| 	}); | ||||
|  | ||||
| 	/* | ||||
| 	 * Turn monitoring off | ||||
| 	 */ | ||||
| 	// Turn monitoring off | ||||
| 	var monitorOffLnk = $('<a>Monitor off</a>'); | ||||
| 	monitorOffLnk.bind('click', function(event) { | ||||
| 		var tgtNodes = getNodesChecked('nodesDataTable'); | ||||
| @@ -400,7 +396,7 @@ function loadNodes4Ganglia(data) { | ||||
| 			monitorNode(tgtNodes, 'off'); | ||||
| 		} | ||||
| 	}); | ||||
| 	 | ||||
|  | ||||
| 	// Power actions | ||||
| 	var monitorActions = [ monitorOnLnk, monitorOffLnk ]; | ||||
| 	var monitorActionMenu = createMenu(monitorActions); | ||||
| @@ -480,7 +476,7 @@ function loadNodes4Ganglia(data) { | ||||
|  | ||||
| 		success : loadPingStatus | ||||
| 	}); | ||||
| 	 | ||||
|  | ||||
| 	// Get the status of Ganglia | ||||
| 	$.ajax( { | ||||
| 		url : 'lib/cmd.php', | ||||
| @@ -505,7 +501,7 @@ function loadNodes4Ganglia(data) { | ||||
|  */ | ||||
| function loadGangliaStatus(data) { | ||||
| 	// Get datatable | ||||
| 	var dTable = getNodesDataTable(); | ||||
| 	var dTable = $('#nodesDataTable').dataTable(); | ||||
| 	var ganglia = data.rsp; | ||||
| 	var rowNum, node, status, args; | ||||
|  | ||||
| @@ -520,7 +516,7 @@ function loadGangliaStatus(data) { | ||||
| 		// Update the power status column | ||||
| 		dTable.fnUpdate(status, rowNum, 4); | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	// Hide Ganglia loader | ||||
| 	var gangliaCol = $('#nodesDataTable thead tr th').eq(4); | ||||
| 	gangliaCol.find('img').hide(); | ||||
| @@ -537,7 +533,7 @@ function refreshGangliaStatus(group) { | ||||
| 	// Show ganglia loader | ||||
| 	var gangliaCol = $('#nodesDataTable thead tr th').eq(4); | ||||
| 	gangliaCol.find('img').show(); | ||||
| 	 | ||||
|  | ||||
| 	// Get the status of Ganglia | ||||
| 	$.ajax( { | ||||
| 		url : 'lib/cmd.php', | ||||
| @@ -564,7 +560,7 @@ function refreshGangliaStatus(group) { | ||||
|  */ | ||||
| function monitorNode(node, monitor) { | ||||
| 	var args; | ||||
| 	 | ||||
|  | ||||
| 	if (monitor == 'on') { | ||||
| 		// Append loader to warning bar | ||||
| 		var gangliaLoader = createLoader(''); | ||||
| @@ -572,13 +568,13 @@ function monitorNode(node, monitor) { | ||||
| 		if (warningBar.length) { | ||||
| 			warningBar.append(gangliaLoader); | ||||
| 		} | ||||
| 				 | ||||
|  | ||||
| 		if (node) { | ||||
| 			args = 'gangliastart;' + node; | ||||
| 		} else { | ||||
| 			args = 'gangliastart'; | ||||
| 		} | ||||
| 		 | ||||
|  | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
| @@ -600,7 +596,7 @@ function monitorNode(node, monitor) { | ||||
| 		} else { | ||||
| 			args = 'gangliastop'; | ||||
| 		} | ||||
| 		 | ||||
|  | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
|   | ||||
| @@ -1,36 +1,36 @@ | ||||
| var hardwareInfo = { | ||||
| 		'7037-A50' : ['P5-185',  '5' ], | ||||
| 		'9115-505' : ['P5-505',  '1' ], | ||||
| 		'9110-510' : ['P5-510',  '2' ], | ||||
| 		'9110-51A' : ['P5-510',  '2' ], | ||||
| 		'9111-520' : ['P5-520',  '4' ], | ||||
| 		'913A-52A' : ['P5-52A',  '4' ], | ||||
| 		'9113-550' : ['P5-550',  '4' ], | ||||
| 		'9133-55A' : ['P5-55A',  '4' ], | ||||
| 		'9116-561' : ['P5-560Q', '4' ], | ||||
| 		'9117-570' : ['P5-570',  '4' ], | ||||
| 		'9118-575' : ['P5-575',  '42'], | ||||
| 		'9119-590' : ['P5-590',  '42'], | ||||
| 		'9119-595' : ['P5-595',  '42'], | ||||
| 	'7037-A50' : [ 'P5-185', '5' ], | ||||
| 	'9115-505' : [ 'P5-505', '1' ], | ||||
| 	'9110-510' : [ 'P5-510', '2' ], | ||||
| 	'9110-51A' : [ 'P5-510', '2' ], | ||||
| 	'9111-520' : [ 'P5-520', '4' ], | ||||
| 	'913A-52A' : [ 'P5-52A', '4' ], | ||||
| 	'9113-550' : [ 'P5-550', '4' ], | ||||
| 	'9133-55A' : [ 'P5-55A', '4' ], | ||||
| 	'9116-561' : [ 'P5-560Q', '4' ], | ||||
| 	'9117-570' : [ 'P5-570', '4' ], | ||||
| 	'9118-575' : [ 'P5-575', '42' ], | ||||
| 	'9119-590' : [ 'P5-590', '42' ], | ||||
| 	'9119-595' : [ 'P5-595', '42' ], | ||||
|  | ||||
| 		//P6 | ||||
| 		'8203-E4A' : ['P6-520',  '4' ], | ||||
| 		'9407-M15' : ['P6-520',  '4' ], | ||||
| 		'9408-M25' : ['P6-520',  '4' ], | ||||
| 		'8204-E8A' : ['P6-550',  '4' ], | ||||
| 		'9409-M50' : ['P6-550',  '4' ], | ||||
| 		'8234-EMA' : ['P6-560',  '4' ], | ||||
| 		'9117-MMA' : ['P6-570',  '4' ], | ||||
| 		'9125-F2A' : ['P6-575',  '42'], | ||||
| 		'9119-FHA' : ['P6-595',  '42'], | ||||
| 	// P6 | ||||
| 	'8203-E4A' : [ 'P6-520', '4' ], | ||||
| 	'9407-M15' : [ 'P6-520', '4' ], | ||||
| 	'9408-M25' : [ 'P6-520', '4' ], | ||||
| 	'8204-E8A' : [ 'P6-550', '4' ], | ||||
| 	'9409-M50' : [ 'P6-550', '4' ], | ||||
| 	'8234-EMA' : [ 'P6-560', '4' ], | ||||
| 	'9117-MMA' : [ 'P6-570', '4' ], | ||||
| 	'9125-F2A' : [ 'P6-575', '42' ], | ||||
| 	'9119-FHA' : [ 'P6-595', '42' ], | ||||
|  | ||||
| 		//P7 | ||||
| 		'8202-E4B' : ['P7-720',  '4' ], | ||||
| 		'8205-E6B' : ['P7-740',  '4' ], | ||||
| 		'8231-E2B' : ['P7-710/730',  '2' ], | ||||
| 		'8233-E8B' : ['P7-750',  '4' ], | ||||
| 		'8236-E8C' : ['P7-755',  '4' ], | ||||
| 		'9117-MMB' : ['P7-770',  '4' ], | ||||
| 		'9119-FHB' : ['P7-795',  '42'], | ||||
| 		'9179-MHB' : ['P7-780',  '42'] | ||||
| 	// P7 | ||||
| 	'8202-E4B' : [ 'P7-720', '4' ], | ||||
| 	'8205-E6B' : [ 'P7-740', '4' ], | ||||
| 	'8231-E2B' : [ 'P7-710/730', '2' ], | ||||
| 	'8233-E8B' : [ 'P7-750', '4' ], | ||||
| 	'8236-E8C' : [ 'P7-755', '4' ], | ||||
| 	'9117-MMB' : [ 'P7-770', '4' ], | ||||
| 	'9119-FHB' : [ 'P7-795', '42' ], | ||||
| 	'9179-MHB' : [ 'P7-780', '42' ] | ||||
| }; | ||||
| @@ -2,7 +2,6 @@ | ||||
|  * Global variables | ||||
|  */ | ||||
| var nodesTabs; 		// Node tabs | ||||
| var nodesDataTable; // Datatable containing all nodes within a group | ||||
| var origAttrs = new Object();	// Original node attributes | ||||
|  | ||||
| /** | ||||
| @@ -26,27 +25,6 @@ function getNodesTab() { | ||||
| 	return nodesTabs; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get the nodes datatable | ||||
|  *  | ||||
|  * @param Nothing | ||||
|  * @return Data table object | ||||
|  */ | ||||
| function getNodesDataTable() { | ||||
| 	return nodesDataTable; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Set the nodes datatable | ||||
|  *  | ||||
|  * @param table | ||||
|  *            Data table object | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function setNodesDataTable(table) { | ||||
| 	nodesDataTable = table; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Load nodes page | ||||
|  *  | ||||
| @@ -189,6 +167,7 @@ function loadGroups(data) { | ||||
|     			}); | ||||
| 			} | ||||
| 			 | ||||
| 			// Get physical layout | ||||
| 			$.ajax({ | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| @@ -267,7 +246,7 @@ function loadGroups(data) { | ||||
| 	addNodeLink.tooltip({ | ||||
| 		position: "center right",	// Place tooltip on the right edge | ||||
| 		offset: [-2, 10],	// A little tweaking of the position | ||||
| 		effect: "fade",		// Use the built-in fadeIn/fadeOut effect			 | ||||
| 		effect: "fade",		// Use the built-in fadeIn/fadeOut effect | ||||
| 		opacity: 0.7		// Custom opacity setting | ||||
| 	}); | ||||
| 	 | ||||
| @@ -317,7 +296,7 @@ function loadNodes(data) { | ||||
| 	// Node attributes | ||||
| 	var headers = new Object(); | ||||
| 	 | ||||
| 	// Clear cookie containing list of nodes where  | ||||
| 	// Clear cookie containing list of nodes where | ||||
| 	// their attributes need to be updated | ||||
| 	$.cookie('Nodes2Update', ''); | ||||
| 	// Clear hash table containing node attributes | ||||
| @@ -414,7 +393,8 @@ function loadNodes(data) { | ||||
| 			position: "center right",	// Place tooltip on the right edge | ||||
| 			offset: [-2, 10],			// A little tweaking of the position | ||||
| 			relative: true, | ||||
| 			effect: "fade",				// Use the built-in fadeIn/fadeOut effect			 | ||||
| 			effect: "fade",				// Use the built-in fadeIn/fadeOut | ||||
| 										// effect | ||||
| 			opacity: 0.8				// Custom opacity setting | ||||
| 		}); | ||||
| 		 | ||||
| @@ -626,7 +606,6 @@ function loadNodes(data) { | ||||
| 	var myDataTable = $('#nodesDataTable').dataTable({ | ||||
| 		'iDisplayLength': 50 | ||||
| 	}); | ||||
| 	setNodesDataTable(myDataTable); | ||||
| 	 | ||||
| 	// Do not sort ping, power, and comment column | ||||
| 	var pingCol = $('#nodesDataTable thead tr th').eq(2); | ||||
| @@ -662,7 +641,7 @@ function loadNodes(data) { | ||||
| 			var colPos = this.cellIndex; | ||||
| 						 | ||||
| 			// Get row index | ||||
| 			var dTable = getNodesDataTable(); | ||||
| 			var dTable = $('#nodesDataTable').dataTable(); | ||||
| 			var rowPos = dTable.fnGetPosition(this.parentNode); | ||||
| 			 | ||||
| 			// Update datatable | ||||
| @@ -679,7 +658,8 @@ function loadNodes(data) { | ||||
|  | ||||
| 			return (value); | ||||
| 		}, { | ||||
| 			onblur : 'submit', 	// Clicking outside editable area submits changes | ||||
| 			onblur : 'submit', 	// Clicking outside editable area submits | ||||
| 								// changes | ||||
| 			type : 'textarea', | ||||
| 			placeholder: ' ', | ||||
| 			height : '30px' 	// The height of the text area | ||||
| @@ -765,7 +745,7 @@ function loadNodes(data) { | ||||
|  */ | ||||
| function loadPowerStatus(data) { | ||||
| 	// Get datatable | ||||
| 	var dTable = getNodesDataTable(); | ||||
| 	var dTable = $('#nodesDataTable').dataTable(); | ||||
| 	var power = data.rsp; | ||||
| 	var rowNum, node, status, args; | ||||
|  | ||||
| @@ -823,7 +803,7 @@ function refreshPowerStatus(group) { | ||||
|  */ | ||||
| function loadPingStatus(data) { | ||||
| 	// Get data table | ||||
| 	var dTable = getNodesDataTable(); | ||||
| 	var dTable = $('#nodesDataTable').dataTable(); | ||||
| 	var ping = data.rsp; | ||||
| 	var rowPos, node, status; | ||||
|  | ||||
| @@ -990,7 +970,7 @@ function loadUnlockPage(tgtNodes) { | ||||
| 	unlockForm.find('div input[title]').tooltip({ | ||||
| 		position: "center right",	// Place tooltip on the right edge | ||||
| 		offset: [-2, 10],	// A little tweaking of the position | ||||
| 		effect: "fade",		// Use the built-in fadeIn/fadeOut effect			 | ||||
| 		effect: "fade",		// Use the built-in fadeIn/fadeOut effect | ||||
| 		opacity: 0.7		// Custom opacity setting | ||||
| 	}); | ||||
| 	 | ||||
| @@ -1094,7 +1074,7 @@ function loadScriptPage(tgtNodes) { | ||||
| 	scriptForm.find('div input[title]').tooltip({ | ||||
| 		position: "center right",	// Place tooltip on the right edge | ||||
| 		offset: [-2, 10],	// A little tweaking of the position | ||||
| 		effect: "fade",		// Use the built-in fadeIn/fadeOut effect			 | ||||
| 		effect: "fade",		// Use the built-in fadeIn/fadeOut effect | ||||
| 		opacity: 0.7		// Custom opacity setting | ||||
| 	}); | ||||
|  | ||||
| @@ -1311,7 +1291,7 @@ function updateStatusBar(data) { | ||||
| 		$('#' + statBarId).append(prg);	 | ||||
| 	} else if (cmd == 'rmvm') { | ||||
| 		// Get data table | ||||
| 		var dTable = getNodesDataTable(); | ||||
| 		var dTable = $('#nodesDataTable').dataTable(); | ||||
| 		var failed = false; | ||||
|  | ||||
| 		// Hide loader | ||||
| @@ -1404,7 +1384,7 @@ function formComplete(tabId) { | ||||
|  */ | ||||
| function updatePowerStatus(data) { | ||||
| 	// Get datatable | ||||
| 	var dTable = getNodesDataTable(); | ||||
| 	var dTable = $('#nodesDataTable').dataTable(); | ||||
|  | ||||
| 	// Get all nodes within the datatable | ||||
| 	var rows = dTable.fnGetNodes(); | ||||
| @@ -1489,7 +1469,7 @@ function runScript(inst) { | ||||
|  * @param node | ||||
|  *            The node | ||||
|  * @param attrName | ||||
|  * 			  The attribute | ||||
|  *            The attribute | ||||
|  * @return The attribute of the node | ||||
|  */ | ||||
| function getNodeAttr(node, attrName) { | ||||
| @@ -1508,7 +1488,7 @@ function getNodeAttr(node, attrName) { | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	// If the column containing the attribute is found  | ||||
| 	// If the column containing the attribute is found | ||||
| 	if (attrCol) { | ||||
| 		// Get the attribute column index | ||||
| 		var attrIndex = attrCol.index(); | ||||
| @@ -1624,7 +1604,7 @@ function getNodeRow(tgtNode, rows) { | ||||
|  * Get nodes that are checked in a given datatable | ||||
|  *  | ||||
|  * @param datatableId | ||||
|  * 				The datatable ID | ||||
|  *            The datatable ID | ||||
|  * @return Nodes that were checked | ||||
|  */ | ||||
| function getNodesChecked(datatableId) { | ||||
| @@ -1652,7 +1632,7 @@ function getNodesChecked(datatableId) { | ||||
|  * Get the column index for a given column name | ||||
|  *  | ||||
|  * @param colName | ||||
|  * 				The column name to search | ||||
|  *            The column name to search | ||||
|  * @return The index containing the column name | ||||
|  */ | ||||
| function getColNum(colName){ | ||||
| @@ -1671,12 +1651,12 @@ function getColNum(colName){ | ||||
|  * Get the row index for a given node name | ||||
|  *  | ||||
|  * @param nodeName | ||||
|  * 				Node name | ||||
|  *            Node name | ||||
|  * @return The row index containing the node name | ||||
|  */ | ||||
| function getRowNum(nodeName){ | ||||
| 	// Get datatable | ||||
| 	var dTable = getNodesDataTable(); | ||||
| 	var dTable = $('#nodesDataTable').dataTable(); | ||||
| 	 | ||||
| 	// Get all data from datatable | ||||
| 	var data = dTable.fnGetData(); | ||||
| @@ -1798,7 +1778,8 @@ function updateNodeAttrs(group) { | ||||
| 					begin = out[i].indexOf('(') + 1; | ||||
| 					end = out[i].indexOf(')'); | ||||
| 					 | ||||
| 					// Split the attribute, e.g. Table:nodetype - Key:node - Column:arch | ||||
| 					// Split the attribute, e.g. Table:nodetype - Key:node - | ||||
| 					// Column:arch | ||||
| 					tmp = out[i].substring(begin, end).split('-'); | ||||
| 					key = jQuery.trim(tmp[2].replace('Column:', '')); | ||||
| 					value = jQuery.trim(tmp[0].replace('Table:', '')); | ||||
| @@ -1807,7 +1788,7 @@ function updateNodeAttrs(group) { | ||||
| 			} | ||||
| 			 | ||||
| 			// Get the nodes datatable | ||||
| 			var dTable = getNodesDataTable(); | ||||
| 			var dTable = $('#nodesDataTable').dataTable(); | ||||
| 			// Get all nodes within the datatable | ||||
| 			var rows = dTable.fnGetNodes(); | ||||
| 			 | ||||
| @@ -1872,7 +1853,7 @@ function updateNodeAttrs(group) { | ||||
| 				} // End of if | ||||
| 			} // End of for | ||||
| 			 | ||||
| 			// Clear cookie containing list of nodes where  | ||||
| 			// Clear cookie containing list of nodes where | ||||
| 			// their attributes need to be updated | ||||
| 			$.cookie('Nodes2Update', ''); | ||||
| 		} // End of function | ||||
| @@ -1890,7 +1871,7 @@ function restoreNodeAttrs() { | ||||
| 	var nodes = nodesList.split(';'); | ||||
| 	 | ||||
| 	// Get the nodes datatable | ||||
| 	var dTable = getNodesDataTable(); | ||||
| 	var dTable = $('#nodesDataTable').dataTable(); | ||||
| 	// Get table headers | ||||
| 	var headers = $('#nodesDataTable thead tr th'); | ||||
| 	// Get all nodes within the datatable | ||||
| @@ -1923,7 +1904,7 @@ function restoreNodeAttrs() { | ||||
| 		} // End of if | ||||
| 	} // End of for | ||||
| 	 | ||||
| 	// Clear cookie containing list of nodes where  | ||||
| 	// Clear cookie containing list of nodes where | ||||
| 	// their attributes need to be updated | ||||
| 	$.cookie('Nodes2Update', ''); | ||||
| } | ||||
|   | ||||
| @@ -1,10 +1,9 @@ | ||||
|  | ||||
|  | ||||
| var bpaList; | ||||
| var fspList; | ||||
| var lparList; | ||||
| var nodeList; | ||||
| var selectNode = new Object(); | ||||
|  | ||||
| /** | ||||
|  * extract all nodes userful data into a hash, which is used for creating graphical | ||||
|  *  | ||||
|   | ||||
| @@ -37,7 +37,7 @@ function loadProvisionPage() { | ||||
| 	} | ||||
|  | ||||
| 	// Create info bar | ||||
| 	var infoBar = createInfoBar('Provision a node'); | ||||
| 	var infoBar = createInfoBar('Provision or re-provision a node on a selected platform'); | ||||
| 	$('#content').append(infoBar); | ||||
|  | ||||
| 	// Create provision form | ||||
| @@ -51,7 +51,7 @@ function loadProvisionPage() { | ||||
| 	$('#content').append(tab.object()); | ||||
|  | ||||
| 	// Create radio buttons for platforms | ||||
| 	var hwList =$('<ol>Select a platform to provision on:</ol>'); | ||||
| 	var hwList = $('<ol>Select a platform to provision on:</ol>'); | ||||
| 	var ipmi = $('<li><input type="radio" name="hw" value="ipmi" checked/>ipmi</li>'); | ||||
| 	var blade = $('<li><input type="radio" name="hw" value="blade"/>blade</li>'); | ||||
| 	var hmc = $('<li><input type="radio" name="hw" value="hmc"/>hmc</li>'); | ||||
| @@ -74,7 +74,7 @@ function loadProvisionPage() { | ||||
| 	okBtn.bind('click', function(event) { | ||||
| 		// Get hardware that was selected | ||||
| 		var hw = $(this).parent().find('input[name="hw"]:checked').val(); | ||||
| 		 | ||||
|  | ||||
| 		// Generate new tab ID | ||||
| 		var instance = 0; | ||||
| 		var newTabId = hw + 'ProvisionTab' + instance; | ||||
| @@ -88,27 +88,27 @@ function loadProvisionPage() { | ||||
|  | ||||
| 		// Create an instance of the plugin | ||||
| 		var plugin; | ||||
| 		switch(hw) { | ||||
| 			case "blade": | ||||
| 	    		plugin = new bladePlugin(); | ||||
| 	    		break; | ||||
| 			case "fsp": | ||||
| 				plugin = new fspPlugin(); | ||||
| 				break; | ||||
| 			case "hmc": | ||||
| 				plugin = new hmcPlugin(); | ||||
| 				break; | ||||
| 			case "ipmi": | ||||
| 				plugin = new ipmiPlugin(); | ||||
| 				break;		 | ||||
| 			case "ivm": | ||||
| 				plugin = new ivmPlugin(); | ||||
| 				break; | ||||
| 			case "zvm": | ||||
| 				plugin = new zvmPlugin(); | ||||
| 				break; | ||||
| 		switch (hw) { | ||||
| 		case "blade": | ||||
| 			plugin = new bladePlugin(); | ||||
| 			break; | ||||
| 		case "fsp": | ||||
| 			plugin = new fspPlugin(); | ||||
| 			break; | ||||
| 		case "hmc": | ||||
| 			plugin = new hmcPlugin(); | ||||
| 			break; | ||||
| 		case "ipmi": | ||||
| 			plugin = new ipmiPlugin(); | ||||
| 			break; | ||||
| 		case "ivm": | ||||
| 			plugin = new ivmPlugin(); | ||||
| 			break; | ||||
| 		case "zvm": | ||||
| 			plugin = new zvmPlugin(); | ||||
| 			break; | ||||
| 		} | ||||
| 		 | ||||
|  | ||||
| 		// Select tab | ||||
| 		tab.select(newTabId); | ||||
| 		plugin.loadProvisionPage(newTabId); | ||||
|   | ||||
| @@ -1,71 +1,70 @@ | ||||
| <?php | ||||
|  | ||||
| 	require_once "functions.php"; | ||||
| 	require_once "jsonwrapper.php"; | ||||
| 	 | ||||
| 	$query = ''; | ||||
| 	$output = ''; | ||||
| 	$temp = ''; | ||||
| 	$pythonProcess = ''; | ||||
| 	if (!isAuthenticated()){ | ||||
| 		echo ("Please log in firsr."); | ||||
| require_once "functions.php"; | ||||
| require_once "jsonwrapper.php"; | ||||
|  | ||||
| $query = ''; | ||||
| $output = ''; | ||||
| $temp = ''; | ||||
| $pythonProcess = ''; | ||||
| if (!isAuthenticated()){ | ||||
| 	echo ("Please log in firsr."); | ||||
| } | ||||
|  | ||||
| $query = 's=' . $_POST['s'] . '&w=' . $_POST['w'] . '&h=' . $_POST['h']; | ||||
| if (isset($_POST['q'])){ | ||||
| 	$query .= '&q=1'; | ||||
| } | ||||
| else{ | ||||
| 	$query .= '&q=0'; | ||||
| } | ||||
|  | ||||
| if (isset($_POST['f'])){ | ||||
| 	$pythonProcess = exec('ps -aef | grep -v grep | grep ajaxterm.py'); | ||||
| 	if ('' == $pythonProcess){ | ||||
| 		exec('nohup ' . dirname(__FILE__) . '/ajaxterm/ajaxterm.py >/dev/null 2>&1 &'); | ||||
| 	} | ||||
| 	 | ||||
| 	$query = 's=' . $_POST['s'] . '&w=' . $_POST['w'] . '&h=' . $_POST['h']; | ||||
| 	if (isset($_POST['q'])){ | ||||
| 		$query .= '&q=1'; | ||||
| 	} | ||||
| 	else{ | ||||
| 		$query .= '&q=0'; | ||||
| 	} | ||||
| 	 | ||||
| 	if (isset($_POST['f'])){ | ||||
| 		$pythonProcess = exec('ps -aef | grep -v grep | grep ajaxterm.py'); | ||||
| 		if ('' == $pythonProcess){ | ||||
| 			exec('nohup ' . dirname(__FILE__) . '/ajaxterm/ajaxterm.py >/dev/null 2>&1 &'); | ||||
| 		} | ||||
| 		 | ||||
| 		sleep(1); | ||||
| 				 | ||||
| 		$temp = $query . '&k=' . urlencode($_SESSION["username"] . "\r"); | ||||
| 		$output = rconsSynchronise($temp); | ||||
| 		if (0 < substr_count($output, 'error')){ | ||||
| 			echo json_encode(array('err'=>$output)); | ||||
| 			exit; | ||||
| 		} | ||||
| 		sleep(1); | ||||
| 		 | ||||
| 		$temp = $query . '&k=' . urlencode(getpassword() . "\r"); | ||||
| 		$output = rconsSynchronise($temp); | ||||
| 		if (0 < substr_count($output, 'error')){ | ||||
| 			echo json_encode(array('err'=>$output)); | ||||
| 			exit; | ||||
| 		} | ||||
| 		sleep(1); | ||||
| 		 | ||||
| 		$temp = $query . '&c=1&k=' . urlencode('rcons ' . $_POST['s'] . "\r"); | ||||
| 	} | ||||
| 	else{ | ||||
| 		$temp = $query . '&c=1&k=' . urlencode($_POST['k']); | ||||
| 	} | ||||
|       | ||||
|     $output = rconsSynchronise($temp); | ||||
|  | ||||
| 	sleep(1); | ||||
|  | ||||
| 	$temp = $query . '&k=' . urlencode($_SESSION["username"] . "\r"); | ||||
| 	$output = rconsSynchronise($temp); | ||||
| 	if (0 < substr_count($output, 'error')){ | ||||
| 		echo (array('err'=>$output)); | ||||
| 		echo json_encode(array('err'=>$output)); | ||||
| 		exit; | ||||
| 	} | ||||
| 	sleep(1); | ||||
|  | ||||
| 	$temp = $query . '&k=' . urlencode(getpassword() . "\r"); | ||||
| 	$output = rconsSynchronise($temp); | ||||
| 	if (0 < substr_count($output, 'error')){ | ||||
| 		echo json_encode(array('err'=>$output)); | ||||
| 		exit; | ||||
| 	} | ||||
| 	sleep(1); | ||||
|  | ||||
| 	$temp = $query . '&c=1&k=' . urlencode('rcons ' . $_POST['s'] . "\r"); | ||||
| } | ||||
| else{ | ||||
| 	$temp = $query . '&c=1&k=' . urlencode($_POST['k']); | ||||
| } | ||||
|   | ||||
| $output = rconsSynchronise($temp); | ||||
| if (0 < substr_count($output, 'error')){ | ||||
| 	echo (array('err'=>$output)); | ||||
| } | ||||
| else{ | ||||
| 	$xml = simplexml_load_string($output); | ||||
| 	if ('pre' == $xml->getName()){ | ||||
| 		$output = $xml->asXML(); | ||||
| 		$output = preg_replace('/'. chr(160) . '/', ' ', $output); | ||||
|  | ||||
| 		echo json_encode(array('term'=>$output)); | ||||
| 	} | ||||
| 	else{ | ||||
| 		$xml = simplexml_load_string($output); | ||||
| 		if ('pre' == $xml->getName()){ | ||||
| 			$output = $xml->asXML(); | ||||
| 			$output = preg_replace('/'. chr(160) . '/', ' ', $output); | ||||
|  | ||||
| 			echo json_encode(array('term'=>$output)); | ||||
| 		} | ||||
| 		else{ | ||||
| 			echo json_encode(array('nc'=>'nc')); | ||||
| 		} | ||||
| 		echo json_encode(array('nc'=>'nc')); | ||||
| 	} | ||||
|  | ||||
| } | ||||
|  | ||||
| function rconsSynchronise($parameter){ | ||||
| 	$flag = false; | ||||
| @@ -73,29 +72,29 @@ function rconsSynchronise($parameter){ | ||||
| 	$out = ""; | ||||
| 	$fp = fsockopen("127.0.0.1", 8022, $errno, $errstr, 30); | ||||
| 	if (!$fp) { | ||||
|     	return "<error>$errstr($errno)</error>"; | ||||
| 		return "<error>$errstr($errno)</error>"; | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	$out = "GET /u?$parameter HTTP/1.1\r\nHost: 127.0.0.1:8022\r\nConnection: Close\r\n\r\n"; | ||||
| 	 | ||||
|  | ||||
| 	fwrite($fp, $out); | ||||
| 	while(!feof($fp)){ | ||||
|         $line = fgets($fp,1024); | ||||
|         if (0 == strlen($line)){ | ||||
|             continue; | ||||
|         } | ||||
|         if('<' == substr($line, 0, 1)){ | ||||
|             $flag = true; | ||||
|             $return .= $line; | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
|     if ($flag){ | ||||
|         while(!feof($fp)){ | ||||
|             $return .= fgets($fp, 1024); | ||||
|         } | ||||
|     } | ||||
| 		$line = fgets($fp,1024); | ||||
| 		if (0 == strlen($line)){ | ||||
| 			continue; | ||||
| 		} | ||||
| 		if('<' == substr($line, 0, 1)){ | ||||
| 			$flag = true; | ||||
| 			$return .= $line; | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 	if ($flag){ | ||||
| 		while(!feof($fp)){ | ||||
| 			$return .= fgets($fp, 1024); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|     return ($return); | ||||
| 	return ($return); | ||||
| } | ||||
| ?> | ||||
| @@ -17,17 +17,17 @@ if (!isAuthenticated()){ | ||||
| } | ||||
|  | ||||
| if (isset($_GET["cmd"])) { | ||||
|     // HTTP GET requests | ||||
|     $cmd = $_GET["cmd"]; | ||||
|     $ret = ""; | ||||
| 	// HTTP GET requests | ||||
| 	$cmd = $_GET["cmd"]; | ||||
| 	$ret = ""; | ||||
|  | ||||
|     if ("ostype" == $cmd) { | ||||
|         $ret = strtolower(PHP_OS); | ||||
|     } | ||||
|     else { | ||||
|         $ret = shell_exec($cmd); | ||||
|     } | ||||
| 	if ("ostype" == $cmd) { | ||||
| 		$ret = strtolower(PHP_OS); | ||||
| 	} | ||||
| 	else { | ||||
| 		$ret = shell_exec($cmd); | ||||
| 	} | ||||
|  | ||||
|     echo json_encode(array("rsp"=>$ret)); | ||||
| 	echo json_encode(array("rsp"=>$ret)); | ||||
| } | ||||
| ?> | ||||
| @@ -11,7 +11,7 @@ function loadPage(){ | ||||
| 	'<html> | ||||
| 		<head> | ||||
| 			<title>xCAT Console</title> | ||||
| 			<link rel="shortcut icon" href="favicon.ico"> | ||||
| 			<link rel="shortcut icon" href="images/favicon.ico"> | ||||
| 			<link href="css/jquery.autocomplete.css" rel=stylesheet type="text/css"> | ||||
| 			<link href="css/jquery-ui-1.8.custom.css" rel=stylesheet type="text/css"> | ||||
| 			<link href="css/jquery.dataTables.css" rel=stylesheet type="text/css"> | ||||
|   | ||||
| @@ -21,11 +21,10 @@ Requires: python >= 2.3 | ||||
| %ifos linux | ||||
| # httpd is provided by apache2 on SLES and httpd on RHEL | ||||
| Requires: httpd | ||||
| # we also require php4-session on SLES, but this does not exist on RHEL, so do not know how to do the Require | ||||
| %endif | ||||
|  | ||||
| %description | ||||
| Provides a browser-based interface for xCAT (extreme Cluster Administration Tool). | ||||
| Provides a browser-based interface for xCAT (Extreme Cloud Administration Toolkit). | ||||
|  | ||||
| %prep | ||||
| %setup -q -n xCAT-UI | ||||
| @@ -47,100 +46,96 @@ set -x | ||||
| %{prefix}/ui | ||||
|  | ||||
| %pre | ||||
| # the %pre part is used to inspect whether the php-related rpm packages are installed into linux or not | ||||
| # if they're not installed, the installation of "xCAT-UI" will be failed. | ||||
| #---------- Pre-install ---------- | ||||
| # Inspect whether PHP related RPM packages are installed | ||||
| %ifos linux | ||||
| if [ -e "/etc/redhat-release" ]; then | ||||
| 	rpm -q php >/dev/null | ||||
| 	if [ $? != 0 ]; then | ||||
| 		echo "" | ||||
| 		echo "Error! php has not been installed yet;please run 'yum install php' before installing xCAT-UI"; | ||||
| 		echo "Error! php has not been installed. Please run 'yum install php' before installing xCAT-UI."; | ||||
| 		exit -1; | ||||
| 	fi | ||||
| else	#SUSE | ||||
| else 	# SuSE | ||||
| 	rpm -q apache2-mod_php5 php5 >/dev/null | ||||
| 	if [ $? != 0 ]; then | ||||
| 		echo "" | ||||
| 		echo "Error! apache2-mod_php5 and php5 have not been installed yet; please run 'zypper install apache2-mod_php5 php5'before installing xCAT-UI" | ||||
| 		echo "Error! apache2-mod_php5 and php5 have not been installed. Please run 'zypper install apache2-mod_php5 php5' before installing xCAT-UI." | ||||
| 		exit -1; | ||||
| 	fi | ||||
| fi | ||||
|  | ||||
| %else   #on AIX | ||||
| %else   # AIX | ||||
|     if [ -e "/usr/IBM/HTTPServer/conf/httpd.conf" ]; then | ||||
|         echo "Installing xCAT-UI on AIX..." | ||||
|     else | ||||
|         echo "" | ||||
|         echo "Error!" | ||||
| 	    echo "The IBM HTTP Server is not installed or not installed into the default directory(/usr/IBM/HTTPServer/)" | ||||
|         echo "Error! IBM HTTP Server is not installed or not installed in the default directory (/usr/IBM/HTTPServer/)." | ||||
|         exit -1; | ||||
|     fi | ||||
|  | ||||
| %endif | ||||
|  | ||||
| %post | ||||
| # Post-install script--------------------------------------------------- | ||||
| #---------- Post-install ---------- | ||||
| # Get apache name | ||||
| %ifos linux | ||||
| # Set variables for apache because the names vary on redhat and suse | ||||
| if [ -e "/etc/redhat-release" ]; then | ||||
|   	apachedaemon='httpd' | ||||
|   	apacheuser='apache' | ||||
| else    # SuSE | ||||
|  | ||||
|   	apachedaemon='apache2' | ||||
|   	apacheuser='wwwrun' | ||||
| fi | ||||
|  | ||||
| if [ "$1" = 1 ]    # initial install | ||||
| if [ "$1" = 1 ]    # Install | ||||
| then | ||||
|   # Update the apache config | ||||
|   # Update apache conf | ||||
|   /bin/rm -f /etc/$apachedaemon/conf.d/xcat-ui.conf | ||||
|   /bin/ln -s %{prefix}/ui/etc/apache2/conf.d/xcat-ui.conf /etc/$apachedaemon/conf.d/xcat-ui.conf | ||||
|   /etc/init.d/$apachedaemon reload | ||||
|   # automatically put the encrypted passwd into the xcat passwd db | ||||
|   # Automatically put encrypted password into the xCAT passwd database | ||||
|   %{prefix}/sbin/chtab key=xcat,username=root passwd.password=`grep root /etc/shadow|cut -d : -f 2` | ||||
|  | ||||
|   echo "To use xCAT-UI, point your browser to http://"`hostname -f`"/xcat" | ||||
| fi | ||||
|  | ||||
| if [ "$1" = 1 ] || [ "$1" = 2 ]        # initial install, or upgrade and this is the newer rpm | ||||
| if [ "$1" = 1 ] || [ "$1" = 2 ]        # Install or upgrade | ||||
| then | ||||
|   # Uncomment this if we change xcat-ui.conf again | ||||
|   #/etc/init.d/$apachedaemon reload | ||||
|   # /etc/init.d/$apachedaemon reload | ||||
|   true | ||||
| fi | ||||
|  | ||||
| %else #on AIX, it's different | ||||
| %else # AIX | ||||
| ihs_config_dir='/usr/IBM/HTTPServer/conf' | ||||
| if [ "$1" = 1 ] #initial install | ||||
| then | ||||
|     # check if IBM HTTP Server is installed into the default directory or not | ||||
|     # Check if IBM HTTP Server is installed in the default directory | ||||
|     # Update the apache config | ||||
|     echo "Updating ibm http server configuration for xCAT..." | ||||
|     echo "Updating IBM HTTP server configuration for xCAT..." | ||||
|     bin/rm -f /usr/IBM/HTTPServer/conf/xcat-ui.conf | ||||
|     cp /usr/IBM/HTTPServer/conf/httpd.conf /usr/IBM/HTTPServer/conf/httpd.conf.xcat.ui.bak | ||||
|     cat /opt/xcat/ui/etc/apache2/conf.d/xcat-ui.conf >> /usr/IBM/HTTPServer/conf/httpd.conf | ||||
|     /usr/IBM/HTTPServer/bin/apachectl restart | ||||
|  | ||||
|     # put the encrypted password in /etc/security/passwd to the xcat passwd db | ||||
|     # Put the encrypted password in /etc/security/passwd into the xcat passwd database | ||||
|     CONT=`cat /etc/security/passwd` | ||||
|     %{prefix}/sbin/chtab key=xcat,username=root passwd.password=`echo $CONT |cut -d ' ' -f 4` | ||||
| fi | ||||
|  | ||||
| if [ "$1" = 1 ] || [ "$1" = 2 ]      # initial install, or upgrade and this is the newer rpm | ||||
| if [ "$1" = 1 ] || [ "$1" = 2 ]      # Install or upgrade | ||||
| then | ||||
|     # Uncomment this if we change xcat-ui.conf again | ||||
|     #/etc/init.d/$apachedaemon reload | ||||
|     # /etc/init.d/$apachedaemon reload | ||||
|     true | ||||
| fi | ||||
|  | ||||
| %endif | ||||
|  | ||||
| %preun | ||||
| # Pre-uninstall script ------------------------------------------------- | ||||
|  | ||||
| #---------- Pre-uninstall ---------- | ||||
| %ifos linux | ||||
| if [ "$1" = 0 ]         # final rpm being removed | ||||
| if [ "$1" = 0 ]         # RPM being removed | ||||
| then | ||||
|   if [ -e "/etc/redhat-release" ]; then | ||||
|   	apachedaemon='httpd' | ||||
| @@ -155,7 +150,7 @@ then | ||||
|   /bin/rm -f /etc/$apachedaemon/conf.d/xcat-ui.conf | ||||
|   /etc/init.d/$apachedaemon reload | ||||
| fi | ||||
| %else   #for AIX | ||||
| %else   # AIX | ||||
| # Remove links made during the post install script | ||||
| echo "Undoing IBM HTTP Server configuration for xCAT..." | ||||
| if [ -e "/usr/IBM/HTTPServer/conf/httpd.conf.xcat.ui.bak" ];then | ||||
| @@ -163,5 +158,4 @@ if [ -e "/usr/IBM/HTTPServer/conf/httpd.conf.xcat.ui.bak" ];then | ||||
|     rm -rf /usr/IBM/HTTPServer/conf/httpd.conf.xcat.ui.bak | ||||
| fi | ||||
| /usr/IBM/HTTPServer/bin/apachectl restart | ||||
| %endif | ||||
|  | ||||
| %endif | ||||
		Reference in New Issue
	
	Block a user