mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 03:12:30 +00:00 
			
		
		
		
	Split nodes page into nodeset, rnetboot, and updatenode pages. Cleaned up code.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6908 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -60,7 +60,7 @@ function loadUserEntry(data) { | ||||
| 	var ueDivId = args[0].replace('out=', ''); | ||||
| 	// Get node | ||||
| 	var node = args[1].replace('node=', ''); | ||||
| 	// Get node user entry | ||||
| 	// Get user entry | ||||
| 	var userEntry = data.rsp[0].split(node + ':'); | ||||
|  | ||||
| 	// Remove loader | ||||
| @@ -69,7 +69,7 @@ function loadUserEntry(data) { | ||||
|  | ||||
| 	var toggleLinkId = node + 'ToggleLink'; | ||||
| 	$('#' + toggleLinkId).click(function() { | ||||
| 		// Get the text within this link | ||||
| 		// Get text within this link | ||||
| 		var lnkText = $(this).text(); | ||||
|  | ||||
| 		// Toggle user entry division | ||||
| @@ -114,11 +114,12 @@ function loadUserEntry(data) { | ||||
| 		saveBtn.show(); | ||||
| 		cancelBtn.show(); | ||||
| 	}); | ||||
|  | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Save | ||||
| 	 */ | ||||
| 	var saveBtn = createButton('Save'); | ||||
| 	saveBtn.css('display', 'inline-table'); | ||||
| 	saveBtn.hide(); | ||||
| 	saveBtn.bind('click', function(event) { | ||||
| 		// Show loader | ||||
| @@ -153,8 +154,7 @@ function loadUserEntry(data) { | ||||
| 			'border-width' : '0px' | ||||
| 		}); | ||||
|  | ||||
| 		// Stop this function from executing again | ||||
| 		// Unbind event | ||||
| 		// Disable save button | ||||
| 		$(this).unbind(event); | ||||
| 		$(this).hide(); | ||||
| 		cancelBtn.hide(); | ||||
| @@ -164,6 +164,7 @@ function loadUserEntry(data) { | ||||
| 	 * Cancel | ||||
| 	 */ | ||||
| 	var cancelBtn = createButton('Cancel'); | ||||
| 	cancelBtn.css('display', 'inline-table'); | ||||
| 	cancelBtn.hide(); | ||||
| 	cancelBtn.bind('click', function(event) { | ||||
| 		txtArea.attr('readonly', 'readonly'); | ||||
| @@ -186,14 +187,14 @@ function loadUserEntry(data) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Set a cookie to track the number of processes for a given node | ||||
|  * Increment number of processes running against a node | ||||
|  *  | ||||
|  * @param node | ||||
|  *            Node to set cookie for | ||||
|  *            Node to increment running processes | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function incrementNodeProcess(node) { | ||||
| 	// Set cookie for number actions performed against node | ||||
| 	// Get current processes | ||||
| 	var procs = $.cookie(node + 'Processes'); | ||||
| 	if (procs) { | ||||
| 		// One more process | ||||
| @@ -205,7 +206,7 @@ function incrementNodeProcess(node) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Update the provision new node status | ||||
|  * Update provision new node status | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data returned from HTTP request | ||||
| @@ -220,87 +221,83 @@ function updateProvisionNewStatus(data) { | ||||
| 	var cmd = args[0].replace('cmd=', ''); | ||||
| 	// Get output ID | ||||
| 	var out2Id = args[1].replace('out=', ''); | ||||
| 	// Get status bar and provision tab ID | ||||
| 	 | ||||
| 	// Get status bar ID | ||||
| 	var statBarId = 'zProvisionStatBar' + out2Id; | ||||
| 	// Get provision tab ID | ||||
| 	var tabId = 'zvmProvisionTab' + out2Id; | ||||
| 	// Get loader ID | ||||
| 	var loaderId = 'zProvisionLoader' + out2Id; | ||||
|  | ||||
| 	// Get node name | ||||
| 	var node = $('#' + tabId + ' input[name=nodeName]').val(); | ||||
| 	// Get userId | ||||
| 	var userId = $('#' + tabId + ' input[name=userId]').val(); | ||||
| 	// Get hardware control point | ||||
| 	var hcp = $('#' + tabId + ' input[name=hcp]').val(); | ||||
| 	// Get group | ||||
| 	var group = $('#' + tabId + ' input[name=group]').val(); | ||||
| 	// Get user entry | ||||
| 	var userEntry = $('#' + tabId + ' textarea').val(); | ||||
| 	// Get operating system | ||||
| 	var osImage = $('#' + tabId + ' input[name=os]').val(); | ||||
|  | ||||
| 	/** | ||||
| 	 * (2) Update /etc/hosts | ||||
| 	 */ | ||||
| 	if (cmd == 'nodeadd') { | ||||
| 		// If no output, no errors occurred | ||||
| 		// If there was an error | ||||
| 		// Do not continue | ||||
| 		if (rsp.length) { | ||||
| 			$('#' + loaderId).hide(); | ||||
| 			$('#' + statBarId).append('<p>(Error) Failed to create node definition</p>'); | ||||
| 		} else { | ||||
| 			$('#' + statBarId).append('<p>Node definition created for ' + node + '</p>'); | ||||
|     		$.ajax( { | ||||
|     			url : 'lib/cmd.php', | ||||
|     			dataType : 'json', | ||||
|     			data : { | ||||
|     				cmd : 'makehosts', | ||||
|     				tgt : '', | ||||
|     				args : '', | ||||
|     				msg : 'cmd=makehosts;out=' + out2Id | ||||
|     			}, | ||||
|      | ||||
|     			success : updateProvisionNewStatus | ||||
|     		}); | ||||
| 		} | ||||
|  | ||||
| 		// Update /etc/hosts | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
| 			data : { | ||||
| 				cmd : 'makehosts', | ||||
| 				tgt : '', | ||||
| 				args : '', | ||||
| 				msg : 'cmd=makehosts;out=' + out2Id | ||||
| 			}, | ||||
|  | ||||
| 			success : updateProvisionNewStatus | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * (3) Update DNS | ||||
| 	 */ | ||||
| 	else if (cmd == 'makehosts') { | ||||
| 		// If no output, no errors occurred | ||||
| 		// If there was an error | ||||
| 		// Do not continue | ||||
| 		if (rsp.length) { | ||||
| 			$('#' + statBarId).append( | ||||
| 				'<p>(Error) Failed to update /etc/hosts</p>'); | ||||
| 			$('#' + loaderId).hide(); | ||||
| 			$('#' + statBarId).append('<p>(Error) Failed to update /etc/hosts</p>'); | ||||
| 		} else { | ||||
| 			$('#' + statBarId).append('<p>/etc/hosts updated</p>'); | ||||
| 		} | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| 				data : { | ||||
| 					cmd : 'makedns', | ||||
| 					tgt : '', | ||||
| 					args : '', | ||||
| 					msg : 'cmd=makedns;out=' + out2Id | ||||
| 				}, | ||||
|  | ||||
| 		// Update DNS | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
| 			data : { | ||||
| 				cmd : 'makedns', | ||||
| 				tgt : '', | ||||
| 				args : '', | ||||
| 				msg : 'cmd=makedns;out=' + out2Id | ||||
| 			}, | ||||
|  | ||||
| 			success : updateProvisionNewStatus | ||||
| 		}); | ||||
| 				success : updateProvisionNewStatus | ||||
| 			}); | ||||
| 		}		 | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * (4) Create user entry | ||||
| 	 */ | ||||
| 	else if (cmd == 'makedns') { | ||||
| 		// Reset the number of tries | ||||
| 	else if (cmd == 'makedns') {		 | ||||
| 		// Reset number of tries | ||||
| 		$.cookie('tries4' + tabId, 0); | ||||
|  | ||||
| 		// Write ajax response to status bar | ||||
| 		var prg = writeRsp(rsp, '');	 | ||||
| 		$('#' + statBarId).append(prg); | ||||
|  | ||||
| 		// Get user entry | ||||
| 		var userEntry = $('#' + tabId + ' textarea').val(); | ||||
| 		 | ||||
| 		// Create user entry | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/zCmd.php', | ||||
| @@ -320,7 +317,7 @@ function updateProvisionNewStatus(data) { | ||||
| 	/** | ||||
| 	 * (5) Add disk | ||||
| 	 */ | ||||
| 	else if (cmd == 'mkvm') { | ||||
| 	else if (cmd == 'mkvm') {		 | ||||
| 		// Write ajax response to status bar | ||||
| 		var prg = writeRsp(rsp, '');	 | ||||
| 		$('#' + statBarId).append(prg); | ||||
| @@ -328,10 +325,7 @@ function updateProvisionNewStatus(data) { | ||||
| 		// If there was an error | ||||
| 		// Do not continue | ||||
| 		if (prg.html().indexOf('Error') > -1) { | ||||
| 			var loaderId = 'zProvisionLoader' + inst; | ||||
| 			$('#' + loaderId).remove(); | ||||
| 			 | ||||
| 			// Try again (at least 2 times) | ||||
| 			// Try again | ||||
| 			var tries = parseInt($.cookie('tries4' + tabId)); | ||||
| 			if (tries < 2) { | ||||
| 				$('#' + statBarId).append('<p>Trying again</p>'); | ||||
| @@ -340,6 +334,8 @@ function updateProvisionNewStatus(data) { | ||||
| 				// One more try | ||||
| 				$.cookie('tries4' + tabId, tries); | ||||
|  | ||||
| 				// Get user entry | ||||
| 				var userEntry = $('#' + tabId + ' textarea').val(); | ||||
| 				// Create user entry | ||||
| 				$.ajax( { | ||||
| 					url : 'lib/zCmd.php', | ||||
| @@ -355,14 +351,10 @@ function updateProvisionNewStatus(data) { | ||||
| 					success : updateProvisionNewStatus | ||||
| 				}); | ||||
| 			} else { | ||||
| 				// Failed - Do not continue | ||||
| 				var loaderId = 'zProvisionLoader' + out2Id; | ||||
| 				$('#' + loaderId).hide(); | ||||
| 			} | ||||
| 		} | ||||
| 		// If there were no errors | ||||
| 		else { | ||||
| 			// Reset the number of tries | ||||
| 		} else { | ||||
| 			// Reset number of tries | ||||
| 			$.cookie('tries4' + tabId, 0); | ||||
|  | ||||
| 			// Set cookie for number of disks | ||||
| @@ -370,6 +362,7 @@ function updateProvisionNewStatus(data) { | ||||
| 			$.cookie('zProvisionDisks2Add' + out2Id, diskRows.length); | ||||
| 			if (diskRows.length > 0) { | ||||
| 				for ( var i = 0; i < diskRows.length; i++) { | ||||
| 					// Get disk type, address, size, pool, and password | ||||
| 					var diskArgs = diskRows.eq(i).find('td'); | ||||
| 					var type = diskArgs.eq(1).find('select').val(); | ||||
| 					var address = diskArgs.eq(2).find('input').val(); | ||||
| @@ -377,7 +370,7 @@ function updateProvisionNewStatus(data) { | ||||
| 					var pool = diskArgs.eq(4).find('input').val(); | ||||
| 					var password = diskArgs.eq(5).find('input').val(); | ||||
|  | ||||
| 					// Add disk and format disk | ||||
| 					// Add disk | ||||
| 					if (type == '3390') { | ||||
| 						$.ajax( { | ||||
| 							url : 'lib/cmd.php', | ||||
| @@ -394,21 +387,17 @@ function updateProvisionNewStatus(data) { | ||||
| 							success : updateProvisionNewStatus | ||||
| 						}); | ||||
| 					} else { | ||||
| 						// Virtual server created | ||||
| 						var loaderId = 'zProvisionLoader' + out2Id; | ||||
| 						$('#' + loaderId).hide(); | ||||
| 					} | ||||
| 				} | ||||
| 			} else { | ||||
| 				// Virtual server created (no OS, no disks) | ||||
| 				var loaderId = 'zProvisionLoader' + out2Id; | ||||
| 				$('#' + loaderId).hide(); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * (6) Set the operating system for given node | ||||
| 	 * (6) Set operating system for given node | ||||
| 	 */ | ||||
| 	else if (cmd == 'chvm') { | ||||
| 		// Write ajax response to status bar | ||||
| @@ -418,10 +407,9 @@ function updateProvisionNewStatus(data) { | ||||
| 		// If there was an error | ||||
| 		// Do not continue | ||||
| 		if (prg.html().indexOf('Error') > -1) { | ||||
| 			var loaderId = 'zProvisionLoader' + inst; | ||||
| 			$('#' + loaderId).remove(); | ||||
| 			$('#' + loaderId).hide(); | ||||
|  | ||||
| 			// Try again (at least 2 times) | ||||
| 			// Try again | ||||
| 			var tries = parseInt($.cookie('tries4' + tabId)); | ||||
| 			if (tries < 2) { | ||||
| 				$('#' + statBarId).append('<p>Trying again</p>'); | ||||
| @@ -435,13 +423,14 @@ function updateProvisionNewStatus(data) { | ||||
| 				$.cookie('zProvisionDisks2Add' + out2Id, diskRows.length); | ||||
| 				if (diskRows.length > 0) { | ||||
| 					for ( var i = 0; i < diskRows.length; i++) { | ||||
| 						// Get disk type, address, size, pool, and password | ||||
| 						var diskArgs = diskRows.eq(i).find('td'); | ||||
| 						var address = diskArgs.eq(1).find('input').val(); | ||||
| 						var size = diskArgs.eq(2).find('input').val(); | ||||
| 						var pool = diskArgs.eq(3).find('input').val(); | ||||
| 						var password = diskArgs.eq(4).find('input').val(); | ||||
|  | ||||
| 						// Add disk and format disk | ||||
| 						// Add disk | ||||
| 						$.ajax( { | ||||
| 							url : 'lib/cmd.php', | ||||
| 							dataType : 'json', | ||||
| @@ -458,18 +447,18 @@ function updateProvisionNewStatus(data) { | ||||
| 						}); | ||||
| 					} | ||||
| 				} else { | ||||
| 					// Virtual server created (no OS, no disks) | ||||
| 					var loaderId = 'zProvisionLoader' + out2Id; | ||||
| 					$('#' + loaderId).hide(); | ||||
| 				} | ||||
| 			} else { | ||||
| 				var loaderId = 'zProvisionLoader' + out2Id; | ||||
| 				$('#' + loaderId).remove(); | ||||
| 				$('#' + loaderId).hide(); | ||||
| 			} | ||||
| 		} else { | ||||
| 			// Reset the number of tries | ||||
| 			// Reset number of tries | ||||
| 			$.cookie('tries4' + tabId, 0); | ||||
|  | ||||
| 			 | ||||
| 			// Get operating system image | ||||
| 			var osImage = $('#' + tabId + ' input[name=os]').val(); | ||||
| 			 | ||||
| 			// Get cookie for number of disks | ||||
| 			var disks2add = $.cookie('zProvisionDisks2Add' + out2Id); | ||||
| 			// One less disk to add | ||||
| @@ -477,17 +466,18 @@ function updateProvisionNewStatus(data) { | ||||
| 			// Set cookie for number of disks | ||||
| 			$.cookie('zProvisionDisks2Add' + out2Id, disks2add); | ||||
|  | ||||
| 			// If an operating system is given | ||||
| 			// If an operating system image is given | ||||
| 			if (osImage) { | ||||
| 				var tmp = osImage.split('-'); | ||||
| 				 | ||||
| 				// Get operating system, architecture, provision method, and profile | ||||
| 				var os = tmp[0]; | ||||
| 				var arch = tmp[1]; | ||||
| 				var provisionMethod = tmp[2]; | ||||
| 				var profile = tmp[3]; | ||||
|  | ||||
| 				// If this is the last disk added | ||||
| 				// If the last disk is added | ||||
| 				if (disks2add < 1) { | ||||
| 					// Set operating system | ||||
| 					$.ajax( { | ||||
| 						url : 'lib/cmd.php', | ||||
| 						dataType : 'json', | ||||
| @@ -504,8 +494,6 @@ function updateProvisionNewStatus(data) { | ||||
| 					}); | ||||
| 				} | ||||
| 			} else { | ||||
| 				// Virtual server created (no OS) | ||||
| 				var loaderId = 'zProvisionLoader' + out2Id; | ||||
| 				$('#' + loaderId).hide(); | ||||
| 			} | ||||
| 		} | ||||
| @@ -515,36 +503,32 @@ function updateProvisionNewStatus(data) { | ||||
| 	 * (7) Update DHCP | ||||
| 	 */ | ||||
| 	else if (cmd == 'noderes') { | ||||
| 		// If no output, no errors occurred | ||||
| 		// If there was an error | ||||
| 		// Do not continue | ||||
| 		if (rsp.length) { | ||||
| 			$('#' + statBarId).append( | ||||
| 				'<p>(Error) Failed to set operating system</p>'); | ||||
| 			$('#' + loaderId).hide(); | ||||
| 			$('#' + statBarId).append('<p>(Error) Failed to set operating system</p>'); | ||||
| 		} else { | ||||
| 			$('#' + statBarId).append( | ||||
| 				'<p>Operating system for ' + node + ' set</p>'); | ||||
| 		} | ||||
| 			$('#' + statBarId).append('<p>Operating system for ' + node + ' set</p>'); | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| 				data : { | ||||
| 					cmd : 'makedhcp', | ||||
| 					tgt : '', | ||||
| 					args : '-a', | ||||
| 					msg : 'cmd=makedhcp;out=' + out2Id | ||||
| 				}, | ||||
|  | ||||
| 		// Update DHCP | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
| 			data : { | ||||
| 				cmd : 'makedhcp', | ||||
| 				tgt : '', | ||||
| 				args : '-a', | ||||
| 				msg : 'cmd=makedhcp;out=' + out2Id | ||||
| 			}, | ||||
|  | ||||
| 			success : updateProvisionNewStatus | ||||
| 		}); | ||||
| 				success : updateProvisionNewStatus | ||||
| 			}); | ||||
| 		}		 | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * (8) Prepare node for boot | ||||
| 	 */ | ||||
| 	else if (cmd == 'makedhcp') { | ||||
| 		var failed = false; | ||||
|  | ||||
| 		// Write ajax response to status bar | ||||
| 		var prg = writeRsp(rsp, '');	 | ||||
| 		$('#' + statBarId).append(prg); | ||||
| @@ -568,8 +552,6 @@ function updateProvisionNewStatus(data) { | ||||
| 	 * (9) Boot node to network | ||||
| 	 */ | ||||
| 	else if (cmd == 'nodeset') { | ||||
| 		var failed = false; | ||||
|  | ||||
| 		// Write ajax response to status bar | ||||
| 		var prg = writeRsp(rsp, '');	 | ||||
| 		$('#' + statBarId).append(prg); | ||||
| @@ -577,11 +559,8 @@ function updateProvisionNewStatus(data) { | ||||
| 		// If there was an error | ||||
| 		// Do not continue | ||||
| 		if (prg.html().indexOf('Error') > -1) { | ||||
| 			var loaderId = 'zProvisionLoader' + out2Id; | ||||
| 			$('#' + loaderId).remove(); | ||||
| 			failed = true; | ||||
| 			$('#' + loaderId).hide(); | ||||
| 		} else { | ||||
| 			// Boot node from network | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| @@ -601,24 +580,15 @@ function updateProvisionNewStatus(data) { | ||||
| 	 * (10) Done | ||||
| 	 */ | ||||
| 	else if (cmd == 'rnetboot') { | ||||
| 		var failed = false; | ||||
|  | ||||
| 		// Write ajax response to status bar | ||||
| 		var prg = writeRsp(rsp, '');	 | ||||
| 		$('#' + statBarId).append(prg); | ||||
|  | ||||
| 		// If there was an error | ||||
| 		// Do not continue | ||||
| 		if (prg.html().indexOf('Error') > -1) { | ||||
| 			var loaderId = 'zProvisionLoader' + out2Id; | ||||
| 			$('#' + loaderId).remove(); | ||||
| 			failed = true; | ||||
| 		} else { | ||||
| 		if (prg.html().indexOf('Error') < 0) { | ||||
| 			$('#' + statBarId).append('<p>Open a VNC viewer to see the installation progress.  It might take a couple of minutes before you can connect.</p>'); | ||||
| 		} | ||||
|  | ||||
| 		// Hide loader | ||||
| 		$('#' + statBarId).find('img').hide(); | ||||
| 		$('#' + loaderId).hide(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -748,19 +718,21 @@ function updateZNodeStatus(data) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Update the clone status | ||||
|  * Update clone status | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data returned from HTTP request | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function updateZCloneStatus(data) { | ||||
| 	// Get ajax response | ||||
| 	var rsp = data.rsp; | ||||
| 	var args = data.msg.split(';'); | ||||
| 	var cmd = args[0].replace('cmd=', ''); | ||||
|  | ||||
| 	// Get provision instance | ||||
| 	var inst = args[1].replace('inst=', ''); | ||||
| 	// Get output division ID | ||||
| 	var out2Id = args[2].replace('out=', ''); | ||||
|  | ||||
| 	/** | ||||
| @@ -769,59 +741,57 @@ function updateZCloneStatus(data) { | ||||
| 	if (cmd == 'nodeadd') { | ||||
| 		var node = args[3].replace('node=', ''); | ||||
|  | ||||
| 		// If no output, no errors occurred | ||||
| 		// If there was an error | ||||
| 		// Do not continue | ||||
| 		if (rsp.length) { | ||||
| 			$('#' + out2Id).append( | ||||
| 				'<p>(Error) Failed to create node definition</p>'); | ||||
| 			$('#' + out2Id).find('img').hide(); | ||||
| 			$('#' + out2Id).append('<p>(Error) Failed to create node definition</p>'); | ||||
| 		} else { | ||||
| 			$('#' + out2Id).append( | ||||
| 				'<p>Node definition created for ' + node + '</p>'); | ||||
| 		} | ||||
| 			$('#' + out2Id).append('<p>Node definition created for ' + node + '</p>'); | ||||
| 			 | ||||
| 			// If last node definition was created | ||||
| 			var tmp = inst.split('/'); | ||||
| 			if (tmp[0] == tmp[1]) { | ||||
| 				$.ajax( { | ||||
| 					url : 'lib/cmd.php', | ||||
| 					dataType : 'json', | ||||
| 					data : { | ||||
| 						cmd : 'makehosts', | ||||
| 						tgt : '', | ||||
| 						args : '', | ||||
| 						msg : 'cmd=makehosts;inst=' + inst + ';out=' + out2Id | ||||
| 					}, | ||||
|  | ||||
| 		// Is this the last instance | ||||
| 		var tmp = inst.split('/'); | ||||
| 		if (tmp[0] == tmp[1]) { | ||||
| 			// Update /etc/hosts | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| 				data : { | ||||
| 					cmd : 'makehosts', | ||||
| 					tgt : '', | ||||
| 					args : '', | ||||
| 					msg : 'cmd=makehosts;inst=' + inst + ';out=' + out2Id | ||||
| 				}, | ||||
|  | ||||
| 				success : updateCloneStatus | ||||
| 			}); | ||||
| 		} | ||||
| 					success : updateZCloneStatus | ||||
| 				}); | ||||
| 			} | ||||
| 		}		 | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * (3) Update DNS | ||||
| 	 */ | ||||
| 	else if (cmd == 'makehosts') { | ||||
| 		// If no output, no errors occurred | ||||
| 		// If there was an error | ||||
| 		// Do not continue | ||||
| 		if (rsp.length) { | ||||
| 			$('#' + out2Id) | ||||
| 				.append('<p>(Error) Failed to update /etc/hosts</p>'); | ||||
| 			$('#' + out2Id).find('img').hide(); | ||||
| 			$('#' + out2Id).append('<p>(Error) Failed to update /etc/hosts</p>'); | ||||
| 		} else { | ||||
| 			$('#' + out2Id).append('<p>/etc/hosts updated</p>'); | ||||
| 		} | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| 				data : { | ||||
| 					cmd : 'makedns', | ||||
| 					tgt : '', | ||||
| 					args : '', | ||||
| 					msg : 'cmd=makedns;inst=' + inst + ';out=' + out2Id | ||||
| 				}, | ||||
|  | ||||
| 		// Update DNS | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
| 			data : { | ||||
| 				cmd : 'makedns', | ||||
| 				tgt : '', | ||||
| 				args : '', | ||||
| 				msg : 'cmd=makedns;inst=' + inst + ';out=' + out2Id | ||||
| 			}, | ||||
|  | ||||
| 			success : updateCloneStatus | ||||
| 		}); | ||||
| 				success : updateZCloneStatus | ||||
| 			}); | ||||
| 		}		 | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| @@ -847,7 +817,6 @@ function updateZCloneStatus(data) { | ||||
| 			var nodeStart = parseInt(tmp[0].match(/\d+/)); | ||||
| 			// Get the ending index | ||||
| 			var nodeEnd = parseInt(tmp[1]); | ||||
|  | ||||
| 			for ( var i = nodeStart; i <= nodeEnd; i++) { | ||||
| 				// Do not append comma for last node | ||||
| 				if (i == nodeEnd) { | ||||
| @@ -881,7 +850,7 @@ function updateZCloneStatus(data) { | ||||
| 				msg : 'cmd=mkvm;inst=' + inst + ';out=' + out2Id | ||||
| 			}, | ||||
|  | ||||
| 			success : updateCloneStatus | ||||
| 			success : updateZCloneStatus | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| @@ -1046,7 +1015,7 @@ function addProcessor(v, m, f) { | ||||
| 			success : updateZNodeStatus | ||||
| 		}); | ||||
|  | ||||
| 		// Increment node process and save it in a cookie | ||||
| 		// Increment node process | ||||
| 		incrementNodeProcess(node); | ||||
|  | ||||
| 		// Show loader | ||||
| @@ -1095,7 +1064,7 @@ function addDisk(v, m, f) { | ||||
| 				success : updateZNodeStatus | ||||
| 			}); | ||||
|  | ||||
| 			// Increment node process and save it in a cookie | ||||
| 			// Increment node process | ||||
| 			incrementNodeProcess(node); | ||||
|  | ||||
| 			// Show loader | ||||
| @@ -1135,7 +1104,6 @@ function addNic(v, m, f) { | ||||
| 			var lanName = temp[1]; | ||||
| 			var lanOwner = temp[0]; | ||||
|  | ||||
| 			// Add NIC | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| @@ -1157,7 +1125,6 @@ function addNic(v, m, f) { | ||||
| 			var temp = f.nicVSwitchName.split(' '); | ||||
| 			var vswitchName = temp[1]; | ||||
|  | ||||
| 			// Add NIC | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| @@ -1173,7 +1140,7 @@ function addNic(v, m, f) { | ||||
| 			}); | ||||
| 		} | ||||
|  | ||||
| 		// Increment node process and save it in a cookie | ||||
| 		// Increment node process | ||||
| 		incrementNodeProcess(node); | ||||
|  | ||||
| 		// Show loader | ||||
| @@ -1194,7 +1161,6 @@ function addNic(v, m, f) { | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function removeProcessor(node, address) { | ||||
| 	// Remove processor | ||||
| 	$.ajax( { | ||||
| 		url : 'lib/cmd.php', | ||||
| 		dataType : 'json', | ||||
| @@ -1208,7 +1174,7 @@ function removeProcessor(node, address) { | ||||
| 		success : updateZNodeStatus | ||||
| 	}); | ||||
|  | ||||
| 	// Increment node process and save it in a cookie | ||||
| 	// Increment node process | ||||
| 	incrementNodeProcess(node); | ||||
|  | ||||
| 	// Show loader | ||||
| @@ -1228,7 +1194,6 @@ function removeProcessor(node, address) { | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function removeDisk(node, address) { | ||||
| 	// Remove disk | ||||
| 	$.ajax( { | ||||
| 		url : 'lib/cmd.php', | ||||
| 		dataType : 'json', | ||||
| @@ -1242,7 +1207,7 @@ function removeDisk(node, address) { | ||||
| 		success : updateZNodeStatus | ||||
| 	}); | ||||
|  | ||||
| 	// Increment node process and save it in a cookie | ||||
| 	// Increment node process | ||||
| 	incrementNodeProcess(node); | ||||
|  | ||||
| 	// Show loader | ||||
| @@ -1265,7 +1230,6 @@ function removeNic(node, nic) { | ||||
| 	var args = nic.split('.'); | ||||
| 	var address = args[0]; | ||||
|  | ||||
| 	// Remove NIC | ||||
| 	$.ajax( { | ||||
| 		url : 'lib/cmd.php', | ||||
| 		dataType : 'json', | ||||
| @@ -1279,7 +1243,7 @@ function removeNic(node, nic) { | ||||
| 		success : updateZNodeStatus | ||||
| 	}); | ||||
|  | ||||
| 	// Set cookie for number actions performed against node | ||||
| 	// Increment node process | ||||
| 	incrementNodeProcess(node); | ||||
|  | ||||
| 	// Show loader | ||||
| @@ -1290,14 +1254,13 @@ function removeNic(node, nic) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Set a cookie for the disk pool names of a given node | ||||
|  * Set a cookie for disk pool names of a given node | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data from HTTP request | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function setDiskPoolCookies(data) { | ||||
| 	// Do not set cookie if there is no output | ||||
| 	if (data.rsp) { | ||||
| 		var node = data.msg; | ||||
| 		var pools = data.rsp[0].split(node + ': '); | ||||
| @@ -1313,7 +1276,6 @@ function setDiskPoolCookies(data) { | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function setNetworkCookies(data) { | ||||
| 	// Do not set cookie if there is no output | ||||
| 	if (data.rsp) { | ||||
| 		var node = data.msg; | ||||
| 		var networks = data.rsp[0].split(node + ': '); | ||||
| @@ -1322,7 +1284,7 @@ function setNetworkCookies(data) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get the contents of each disk pool | ||||
|  * Get contents of each disk pool | ||||
|  *  | ||||
|  * @param data | ||||
|  *            HTTP request data | ||||
| @@ -1333,7 +1295,7 @@ function getDiskPool(data) { | ||||
| 		var hcp = data.msg; | ||||
| 		var pools = data.rsp[0].split(hcp + ': '); | ||||
|  | ||||
| 		// Get the contents of each disk pool | ||||
| 		// Get contents of each disk pool | ||||
| 		for ( var i in pools) { | ||||
| 			if (pools[i]) { | ||||
| 				// Get used space | ||||
| @@ -1370,7 +1332,7 @@ function getDiskPool(data) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get the details of each network | ||||
|  * Get details of each network | ||||
|  *  | ||||
|  * @param data | ||||
|  *            HTTP request data | ||||
| @@ -1381,7 +1343,7 @@ function getNetwork(data) { | ||||
| 		var hcp = data.msg; | ||||
| 		var networks = data.rsp[0].split(hcp + ': '); | ||||
|  | ||||
| 		// Get the network details | ||||
| 		// Loop through each network | ||||
| 		for ( var i = 1; i < networks.length; i++) { | ||||
| 			var args = networks[i].split(' '); | ||||
| 			var type = args[0]; | ||||
| @@ -1405,7 +1367,7 @@ function getNetwork(data) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Load the disk pool contents into a table | ||||
|  * Load disk pool contents into a table | ||||
|  *  | ||||
|  * @param data | ||||
|  *            HTTP request data | ||||
| @@ -1427,7 +1389,7 @@ function loadDiskPoolTable(data) { | ||||
| 	// Resource tab ID | ||||
| 	var tabID = 'zvmResourceTab'; | ||||
|  | ||||
| 	// Get datatable (if any) | ||||
| 	// Get datatable | ||||
| 	var dTable = getDiskDataTable(); | ||||
| 	if (!dTable) { | ||||
| 		// Create disks section | ||||
| @@ -1439,8 +1401,7 @@ function loadDiskPoolTable(data) { | ||||
| 		var tableID = 'zDiskDataTable'; | ||||
| 		var table = new DataTable(tableID); | ||||
| 		// Resource headers: volume ID, device type, start address, and size | ||||
| 		table.init( [ 'Hardware control point', 'Pool', 'Status', 'Volume ID', | ||||
| 			'Device type', 'Start address', 'Size' ]); | ||||
| 		table.init( [ 'Hardware control point', 'Pool', 'Status', 'Volume ID', 'Device type', 'Start address', 'Size' ]); | ||||
|  | ||||
| 		// Append datatable to tab | ||||
| 		fieldSet.append(table.object()); | ||||
| @@ -1454,13 +1415,12 @@ function loadDiskPoolTable(data) { | ||||
| 	// Skip index 0 and 1 because it contains nothing | ||||
| 	for ( var i = 2; i < tmp.length; i++) { | ||||
| 		var diskAttrs = tmp[i].split(' '); | ||||
| 		dTable.fnAddData( [ hcp, pool, stat, diskAttrs[0], diskAttrs[1], | ||||
| 			diskAttrs[2], diskAttrs[3] ]); | ||||
| 		dTable.fnAddData( [ hcp, pool, stat, diskAttrs[0], diskAttrs[1], diskAttrs[2], diskAttrs[3] ]); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Load the network details into a table | ||||
|  * Load network details into a table | ||||
|  *  | ||||
|  * @param data | ||||
|  *            HTTP request data | ||||
| @@ -1482,7 +1442,7 @@ function loadNetworkTable(data) { | ||||
| 	// Resource tab ID | ||||
| 	var tabID = 'zvmResourceTab'; | ||||
|  | ||||
| 	// Get datatable (if any) | ||||
| 	// Get datatable | ||||
| 	var dTable = getNetworkDataTable(); | ||||
| 	if (!dTable) { | ||||
| 		// Create networks section | ||||
|   | ||||
| @@ -109,7 +109,6 @@ function loadGroups(data) { | ||||
| 	for ( var i = groups.length; i--;) { | ||||
| 		var subItem = $('<li></li>'); | ||||
| 		var link = $('<a href="#"><ins></ins>' + groups[i] + '</a>'); | ||||
|  | ||||
| 		subItem.append(link); | ||||
| 		subUL.append(subItem); | ||||
| 	} | ||||
| @@ -118,11 +117,11 @@ function loadGroups(data) { | ||||
| 	$('#groups').append(ul); | ||||
| 	$('#groups').tree( { | ||||
| 		callback : { | ||||
| 			// Open the group onclick | ||||
| 			// Open group onclick | ||||
|     		onselect : function(node, tree) { | ||||
|     			var thisGroup = tree.get_text(node); | ||||
|     			if (thisGroup) { | ||||
|     				// Clear the nodes DIV | ||||
|     				// Clear nodes division | ||||
|     				$('#nodes').children().remove(); | ||||
|     				// Create loader | ||||
|     				var loader = $('<center></center>').append(createLoader()); | ||||
| @@ -202,8 +201,7 @@ function loadNodes(data) { | ||||
| 	sorted.sort(); | ||||
|  | ||||
| 	// Add column for check box, node, ping, and power | ||||
| 	sorted.unshift('', 'node', 'ping', 'power'); | ||||
| 	sorted[0] = '<input type="checkbox" onclick="selectAllCheckbox(event, $(this))">'; | ||||
| 	sorted.unshift('<input type="checkbox" onclick="selectAllCheckbox(event, $(this))">', 'node', 'ping', 'power'); | ||||
|  | ||||
| 	// Create a datatable | ||||
| 	var dTable = new DataTable('nodesDataTable'); | ||||
| @@ -216,9 +214,7 @@ function loadNodes(data) { | ||||
| 		// Create a check box | ||||
| 		var checkBx = '<input type="checkbox" name="' + node + '"/>'; | ||||
| 		// Open node onclick | ||||
| 		var nodeLink = $( | ||||
| 			'<a class="node" id="' + node + '" href="#">' + node + '</a>') | ||||
| 			.bind('click', loadNode); | ||||
| 		var nodeLink = $('<a class="node" id="' + node + '" href="#">' + node + '</a>').bind('click', loadNode); | ||||
| 		row.push(checkBx, nodeLink, '', ''); | ||||
|  | ||||
| 		// Go through each header | ||||
| @@ -442,15 +438,14 @@ function loadNodes(data) { | ||||
| 	}); | ||||
|  | ||||
| 	/** | ||||
| 	 * Only for zVM | ||||
| 	 * Additional ajax requests need to be made for zVM | ||||
| 	 */ | ||||
|  | ||||
| 	// Get the index of the HCP column | ||||
| 	var i = $.inArray('hcp', sorted); | ||||
| 	if (i) { | ||||
| 		// Get hardware control point | ||||
| 		var rows = dTable.object().find('tbody tr'); | ||||
|  | ||||
| 		// Get HCP | ||||
| 		var hcps = new Object(); | ||||
| 		for ( var j = 0; j < rows.length; j++) { | ||||
| 			var val = rows.eq(j).find('td').eq(i).html(); | ||||
| @@ -494,7 +489,7 @@ function loadNodes(data) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Load the power status for each node | ||||
|  * Load power status for each node | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data returned from HTTP request | ||||
| @@ -521,7 +516,7 @@ function loadPowerStatus(data) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Load the ping status for each node | ||||
|  * Load ping status for each node | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data returned from HTTP request | ||||
| @@ -668,7 +663,7 @@ function loadUnlockPage(tgtNodes) { | ||||
| 	 */ | ||||
| 	var okBtn = createButton('Ok'); | ||||
| 	okBtn.bind('click', function(event) { | ||||
| 		// If the form is complete | ||||
| 		// If form is complete | ||||
| 		var ready = formComplete(newTabId); | ||||
| 		if (ready) { | ||||
| 			var password = $('#' + newTabId + ' input[name=password]').val(); | ||||
| @@ -690,8 +685,7 @@ function loadUnlockPage(tgtNodes) { | ||||
|     		// Show status bar | ||||
|     		statusBar.show(); | ||||
|      | ||||
|     		// Stop this function from executing again | ||||
|     		// Unbind event | ||||
|     		// Disable Ok button | ||||
|     		$(this).unbind(event); | ||||
|     		$(this).css( { | ||||
|     			'background-color' : '#F2F2F2', | ||||
| @@ -814,648 +808,6 @@ function loadScriptPage(tgtNodes) { | ||||
| 	tab.select(newTabId); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Load nodeset page | ||||
|  *  | ||||
|  * @param trgtNodes | ||||
|  *            Targets to run nodeset against | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function loadNodesetPage(trgtNodes) { | ||||
| 	// Get the OS images | ||||
| 	$.ajax( { | ||||
| 		url : 'lib/cmd.php', | ||||
| 		dataType : 'json', | ||||
| 		data : { | ||||
| 			cmd : 'tabdump', | ||||
| 			tgt : '', | ||||
| 			args : 'osimage', | ||||
| 			msg : '' | ||||
| 		}, | ||||
|  | ||||
| 		success : setOSImageCookies | ||||
| 	}); | ||||
|  | ||||
| 	// Get nodes tab | ||||
| 	var tab = getNodesTab(); | ||||
|  | ||||
| 	// Generate new tab ID | ||||
| 	var inst = 0; | ||||
| 	var tabId = 'nodesetTab' + inst; | ||||
| 	while ($('#' + tabId).length) { | ||||
| 		// If one already exists, generate another one | ||||
| 		inst = inst + 1; | ||||
| 		tabId = 'nodesetTab' + inst; | ||||
| 	} | ||||
|  | ||||
| 	// Open new tab | ||||
| 	// Create nodeset form | ||||
| 	var nodesetForm = $('<div class="form"></div>'); | ||||
|  | ||||
| 	// Create status bar | ||||
| 	var statBarId = 'nodesetStatusBar' + inst; | ||||
| 	var statBar = createStatusBar(statBarId); | ||||
| 	statBar.hide(); | ||||
| 	nodesetForm.append(statBar); | ||||
|  | ||||
| 	// Create loader | ||||
| 	var loader = createLoader('nodesetLoader'); | ||||
| 	statBar.append(loader); | ||||
|  | ||||
| 	// Create info bar | ||||
| 	var infoBar = createInfoBar('Set the boot state for a node range'); | ||||
| 	nodesetForm.append(infoBar); | ||||
|  | ||||
| 	// Target node or group | ||||
| 	var tgt = $('<div><label for="target">Target node or group:</label><input type="text" name="target" value="' + trgtNodes + '"/></div>'); | ||||
| 	nodesetForm.append(tgt); | ||||
|  | ||||
| 	// Boot method (boot, install, stat, iscsiboot, netboot, statelite) | ||||
| 	var method = $('<div></div>'); | ||||
| 	var methodLabel = $('<label for="method">Boot method:</label>'); | ||||
| 	var methodSelect = $('<select id="bootMethod" name="bootMethod"></select>'); | ||||
| 	methodSelect.append('<option value="boot">boot</option>'); | ||||
| 	methodSelect.append('<option value="install">install</option>'); | ||||
| 	methodSelect.append('<option value="iscsiboot">iscsiboot</option>'); | ||||
| 	methodSelect.append('<option value="netboot">netboot</option>'); | ||||
| 	methodSelect.append('<option value="statelite">statelite</option>'); | ||||
| 	method.append(methodLabel); | ||||
| 	method.append(methodSelect); | ||||
| 	nodesetForm.append(method); | ||||
|  | ||||
| 	// Boot type (zvm, pxe, yaboot) | ||||
| 	var type = $('<div></div>'); | ||||
| 	var typeLabel = $('<label for="type">Boot type:</label>'); | ||||
| 	var typeSelect = $('<select id="bootType" name="bootType"></select>'); | ||||
| 	typeSelect.append('<option value="zvm">zvm</option>'); | ||||
| 	typeSelect.append('<option value="install">pxe</option>'); | ||||
| 	typeSelect.append('<option value="iscsiboot">yaboot</option>'); | ||||
| 	type.append(typeLabel); | ||||
| 	type.append(typeSelect); | ||||
| 	nodesetForm.append(type); | ||||
|  | ||||
| 	// Operating system | ||||
| 	var os = $('<div></div>'); | ||||
| 	var osLabel = $('<label for="os">Operating system:</label>'); | ||||
| 	var osInput = $('<input type="text" name="os"/>'); | ||||
|  | ||||
| 	// Get the OS versions on-focus | ||||
| 	var tmp; | ||||
| 	osInput.one('focus', function(){ | ||||
| 		tmp = $.cookie('OSVers'); | ||||
|  | ||||
| 		// If there are any, turn on auto-complete | ||||
| 		if (tmp) { | ||||
| 			$(this).autocomplete(tmp.split(',')); | ||||
| 		} | ||||
| 	}); | ||||
| 	os.append(osLabel); | ||||
| 	os.append(osInput); | ||||
| 	nodesetForm.append(os); | ||||
|  | ||||
| 	// Architecture | ||||
| 	var arch = $('<div></div>'); | ||||
| 	var archLabel = $('<label for="arch">Architecture:</label>'); | ||||
| 	var archInput = $('<input type="text" name="arch"/>'); | ||||
|  | ||||
| 	// Get the OS architectures on-focus | ||||
| 	archInput.one('focus', function(){ | ||||
| 		tmp = $.cookie('OSArchs'); | ||||
|  | ||||
| 		// If there are any, turn on auto-complete | ||||
| 		if (tmp) { | ||||
| 			$(this).autocomplete(tmp.split(',')); | ||||
| 		} | ||||
| 	}); | ||||
| 	arch.append(archLabel); | ||||
| 	arch.append(archInput); | ||||
| 	nodesetForm.append(arch); | ||||
|  | ||||
| 	// Profiles | ||||
| 	var profile = $('<div></div>'); | ||||
| 	var profileLabel = $('<label for="profile">Profile:</label>'); | ||||
| 	var profileInput = $('<input type="text" name="profile"/>'); | ||||
|  | ||||
| 	// Get the profiles on-focus | ||||
| 	profileInput.one('focus', function(){ | ||||
| 		tmp = $.cookie('Profiles'); | ||||
|  | ||||
| 		// If there are any, turn on auto-complete | ||||
| 		if (tmp) { | ||||
| 			$(this).autocomplete(tmp.split(',')); | ||||
| 		} | ||||
| 	}); | ||||
| 	profile.append(profileLabel); | ||||
| 	profile.append(profileInput); | ||||
| 	nodesetForm.append(profile); | ||||
|  | ||||
| 	/** | ||||
| 	 * Ok | ||||
| 	 */ | ||||
| 	var okBtn = createButton('Ok'); | ||||
| 	okBtn.bind('click', function(event) { | ||||
| 		var ready = true; | ||||
|  | ||||
| 		// Check state, OS, arch, and profile | ||||
| 		var inputs = $('#' + tabId + ' input'); | ||||
| 		for ( var i = 0; i < inputs.length; i++) { | ||||
| 			if (!inputs.eq(i).val() && inputs.eq(i).attr('name') != 'diskPw') { | ||||
| 				inputs.eq(i).css('border', 'solid #FF0000 1px'); | ||||
| 				ready = false; | ||||
| 			} else { | ||||
| 				inputs.eq(i).css('border', 'solid #BDBDBD 1px'); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// If no inputs are empty | ||||
| 		if (ready) { | ||||
| 			// Get nodes | ||||
| 			var tgts = $('#' + tabId + ' input[name=target]').val(); | ||||
|  | ||||
| 			// Get boot method | ||||
| 			var method = $('#' + tabId + ' select[id=bootMethod]').val(); | ||||
|  | ||||
| 			// Get boot type | ||||
| 			var type = $('#' + tabId + ' select[id=bootType]').val(); | ||||
|  | ||||
| 			// Get OS, arch, and profile | ||||
| 			var os = $('#' + tabId + ' input[name=os]').val(); | ||||
| 			var arch = $('#' + tabId + ' input[name=arch]').val(); | ||||
| 			var profile = $('#' + tabId + ' input[name=profile]').val(); | ||||
|  | ||||
| 			// Stop this function from executing again | ||||
| 			// Unbind event | ||||
| 			$(this).unbind(event); | ||||
| 			$(this).css( { | ||||
| 				'background-color' : '#F2F2F2', | ||||
| 				'color' : '#424242' | ||||
| 			}); | ||||
|  | ||||
| 			/** | ||||
| 			 * (1) Set the OS, arch, and profile | ||||
| 			 */ | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| 				data : { | ||||
| 					cmd : 'nodeadd', | ||||
| 					tgt : '', | ||||
| 					args : tgts + ';noderes.netboot=' + type + ';nodetype.os=' | ||||
| 						+ os + ';nodetype.arch=' + arch + ';nodetype.profile=' | ||||
| 						+ profile, | ||||
| 					msg : 'cmd=nodeadd;inst=' + inst | ||||
| 				}, | ||||
|  | ||||
| 				success : updateNodesetStatus | ||||
| 			}); | ||||
|  | ||||
| 			// Show status bar | ||||
| 			statBar.show(); | ||||
| 		} else { | ||||
| 			alert('You are missing some values'); | ||||
| 		} | ||||
| 	}); | ||||
| 	nodesetForm.append(okBtn); | ||||
|  | ||||
| 	// Append to discover tab | ||||
| 	tab.add(tabId, 'Nodeset', nodesetForm); | ||||
|  | ||||
| 	// Select new tab | ||||
| 	tab.select(tabId); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Load netboot page | ||||
|  *  | ||||
|  * @param tgtNodes | ||||
|  *            Targets to run rnetboot against | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function loadNetbootPage(tgtNodes) { | ||||
| 	// Get nodes tab | ||||
| 	var tab = getNodesTab(); | ||||
|  | ||||
| 	// Generate new tab ID | ||||
| 	var inst = 0; | ||||
| 	var newTabId = 'netbootTab' + inst; | ||||
| 	while ($('#' + newTabId).length) { | ||||
| 		// If one already exists, generate another one | ||||
| 		inst = inst + 1; | ||||
| 		newTabId = 'netbootTab' + inst; | ||||
| 	} | ||||
|  | ||||
| 	// Open new tab | ||||
| 	// Create netboot form | ||||
| 	var netbootForm = $('<div class="form"></div>'); | ||||
|  | ||||
| 	// Create status bar | ||||
| 	var barId = 'netbootStatusBar' + inst; | ||||
| 	var statusBar = createStatusBar(barId); | ||||
| 	statusBar.hide(); | ||||
| 	netbootForm.append(statusBar); | ||||
|  | ||||
| 	// Create loader | ||||
| 	var loader = createLoader('netbootLoader'); | ||||
| 	statusBar.append(loader); | ||||
|  | ||||
| 	// Create info bar | ||||
| 	var infoBar = createInfoBar('Cause the range of nodes to boot to network'); | ||||
| 	netbootForm.append(infoBar); | ||||
|  | ||||
| 	// Target node or group | ||||
| 	var target = $('<div><label for="target">Target node or group:</label><input type="text" name="target" value="' + tgtNodes + '"/></div>'); | ||||
| 	netbootForm.append(target); | ||||
|  | ||||
| 	// Create options | ||||
| 	var optsDIV = $('<div></div>'); | ||||
| 	var optsLabel = $('<label>Options:</label>');	 | ||||
| 	var optsList = $('<ul></ul>'); | ||||
| 	var opt = $('<li></li>'); | ||||
| 	optsList.append(opt); | ||||
| 	optsDIV.append(optsLabel); | ||||
| 	optsDIV.append(optsList); | ||||
| 	netbootForm.append(optsDIV); | ||||
| 	 | ||||
| 	// Boot order | ||||
| 	var bootOrderChkBox = $('<input type="checkbox" id="s" name="s"/>'); | ||||
| 	opt.append(bootOrderChkBox); | ||||
| 	opt.append('Set the boot device order'); | ||||
| 	var bootOrder = $('<li><label for="bootOrder">Boot order:</label><input type="text" name="bootOrder"/></li>'); | ||||
| 	bootOrder.hide(); | ||||
| 	optsList.append(bootOrder); | ||||
| 	// Force reboot | ||||
| 	optsList.append('<li><input type="checkbox" id="F" name="F"/>Force reboot</li>'); | ||||
| 	// Force shutdown | ||||
| 	optsList.append('<li><input type="checkbox" id="f" name="f"/>Force immediate shutdown of the partition</li>'); | ||||
| 	// Iscsi dump | ||||
| 	optsList.append('<li><input type="checkbox" id="I" name="I"/>Do a iscsi dump on AIX</li>'); | ||||
| 	 | ||||
| 	// Show boot order when checkbox is checked | ||||
| 	bootOrderChkBox.bind('click', function(event) { | ||||
| 		if ($(this).is(':checked')) { | ||||
| 			bootOrder.show(); | ||||
| 		} else { | ||||
| 			bootOrder.hide(); | ||||
| 		} | ||||
| 	}); | ||||
|  | ||||
| 	// Determine plugin | ||||
| 	var tmp = tgtNodes.split(','); | ||||
| 	for ( var i = 0; i < tmp.length; i++) { | ||||
| 		var mgt = getNodeMgt(tmp[i]); | ||||
| 		// If it is zvm | ||||
| 		if (mgt == 'zvm') { | ||||
| 			// Add IPL input | ||||
| 			netbootForm.append('<div><label for="ipl">IPL:</label><input type="text" name="ipl"/></div>'); | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Ok | ||||
| 	 */ | ||||
| 	var okBtn = createButton('Ok'); | ||||
| 	okBtn.bind('click', function(event) { | ||||
| 		var ready = true; | ||||
|  | ||||
| 		// Check inputs | ||||
| 		var inputs = $("#" + newTabId + " input[type='text']:visible"); | ||||
| 		for ( var i = 0; i < inputs.length; i++) { | ||||
| 			if (!inputs.eq(i).val()) { | ||||
| 				inputs.eq(i).css('border', 'solid #FF0000 1px'); | ||||
| 				ready = false; | ||||
| 			} else { | ||||
| 				inputs.eq(i).css('border', 'solid #BDBDBD 1px'); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// Generate arguments | ||||
| 		var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked"); | ||||
| 		var optStr = ''; | ||||
| 		var opt; | ||||
| 		for ( var i = 0; i < chkBoxes.length; i++) { | ||||
| 			opt = chkBoxes.eq(i).attr('name'); | ||||
| 			optStr += '-' + opt; | ||||
| 			 | ||||
| 			// If it is the boot order | ||||
| 			if (opt == 's') { | ||||
| 				// Get the boot order | ||||
| 				optStr += ';' + $('#' + newTabId + ' input[name=bootOrder]').val(); | ||||
| 			} | ||||
| 			 | ||||
| 			// Append ; to end of string | ||||
| 			if (i < (chkBoxes.length - 1)) { | ||||
| 				optStr += ';'; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// If no inputs are empty | ||||
| 		if (ready) { | ||||
| 			// Get nodes | ||||
| 			var tgts = $('#' + newTabId + ' input[name=target]').val(); | ||||
|  | ||||
| 			// Get IPL address | ||||
| 			var ipl = $('#' + newTabId + ' input[name=ipl]'); | ||||
| 			if (ipl) { | ||||
| 				optStr += 'ipl=' + ipl.val(); | ||||
| 			} | ||||
|  | ||||
| 			// Stop this function from executing again | ||||
| 			// Unbind event | ||||
| 			$(this).unbind(event); | ||||
| 			$(this).css( { | ||||
| 				'background-color' : '#F2F2F2', | ||||
| 				'color' : '#424242' | ||||
| 			}); | ||||
|  | ||||
| 			/** | ||||
| 			 * (1) Boot to network | ||||
| 			 */ | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| 				data : { | ||||
| 					cmd : 'rnetboot', | ||||
| 					tgt : tgts, | ||||
| 					args : optStr, | ||||
| 					msg : 'out=' + barId + ';cmd=rnetboot;tgt=' + tgts | ||||
| 				}, | ||||
|  | ||||
| 				success : updateStatusBar | ||||
| 			}); | ||||
|  | ||||
| 			// Show status bar | ||||
| 			statusBar.show(); | ||||
| 		} else { | ||||
| 			alert('You are missing some values'); | ||||
| 		} | ||||
| 	}); | ||||
| 	netbootForm.append(okBtn); | ||||
|  | ||||
| 	// Append to discover tab | ||||
| 	tab.add(newTabId, 'Netboot', netbootForm); | ||||
|  | ||||
| 	// Select new tab | ||||
| 	tab.select(newTabId); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Load updatenode page | ||||
|  *  | ||||
|  * @param tgtNodes | ||||
|  *            Targets to run updatenode against | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function loadUpdatenodePage(tgtNodes) { | ||||
| 	// Get nodes tab | ||||
| 	var tab = getNodesTab(); | ||||
|  | ||||
| 	// Generate new tab ID | ||||
| 	var inst = 0; | ||||
| 	var newTabId = 'updatenodeTab' + inst; | ||||
| 	while ($('#' + newTabId).length) { | ||||
| 		// If one already exists, generate another one | ||||
| 		inst = inst + 1; | ||||
| 		newTabId = 'updatenodeTab' + inst; | ||||
| 	} | ||||
|  | ||||
| 	// Open new tab | ||||
| 	// Create updatenode form | ||||
| 	var updatenodeForm = $('<div class="form"></div>'); | ||||
|  | ||||
| 	// Create status bar | ||||
| 	var statBarId = 'updatenodeStatusBar' + inst; | ||||
| 	var statusBar = createStatusBar(statBarId); | ||||
| 	statusBar.hide(); | ||||
| 	updatenodeForm.append(statusBar); | ||||
|  | ||||
| 	// Create loader | ||||
| 	var loader = createLoader('updatenodeLoader'); | ||||
| 	statusBar.append(loader); | ||||
|  | ||||
| 	// Create info bar | ||||
| 	var infoBar = createInfoBar('Update nodes in an xCAT environment'); | ||||
| 	updatenodeForm.append(infoBar); | ||||
|  | ||||
| 	// Target node or group | ||||
| 	var target = $('<div><label for="target">Target node or group:</label><input type="text" name="target" value="' + tgtNodes + '"/></div>'); | ||||
| 	updatenodeForm.append(target); | ||||
|  | ||||
| 	// Create options | ||||
| 	var optsDIV = $('<div></div>'); | ||||
| 	var optsLabel = $('<label>Options:</label>');	 | ||||
| 	var optsList = $('<ul></ul>'); | ||||
| 	optsDIV.append(optsLabel); | ||||
| 	optsDIV.append(optsList); | ||||
| 	updatenodeForm.append(optsDIV); | ||||
| 		 | ||||
| 	// Update all software | ||||
| 	var updateAllChkBox = $('<input type="checkbox" id="A" name="A"/>'); | ||||
| 	var updateAllOpt = $('<li></li>'); | ||||
| 	optsList.append(updateAllOpt); | ||||
| 	updateAllOpt.append(updateAllChkBox); | ||||
| 	updateAllOpt.append('Install or update all software contained in the source directory'); | ||||
| 		 | ||||
| 	var allSwScrDirectory = $('<li><label for="allSwSrcDirectory">Alternate source directory:</label><input type="text" name="allSwSrcDirectory"/></li>'); | ||||
| 	allSwScrDirectory.hide(); | ||||
| 	optsList.append(allSwScrDirectory); | ||||
| 			 | ||||
| 	// Show alternate source directory when checked | ||||
| 	updateAllChkBox.bind('click', function(event) { | ||||
| 		if ($(this).is(':checked')) { | ||||
| 			allSwScrDirectory.show(); | ||||
| 		} else { | ||||
| 			allSwScrDirectory.hide(); | ||||
| 		} | ||||
| 	}); | ||||
| 	 | ||||
| 	// Update software | ||||
| 	var updateChkBox = $('<input type="checkbox" id="S" name="S"/>'); | ||||
| 	var updateOpt = $('<li></li>'); | ||||
| 	optsList.append(updateOpt); | ||||
| 	updateOpt.append(updateChkBox); | ||||
| 	updateOpt.append('Update software'); | ||||
| 		 | ||||
| 	var scrDirectory = $('<li><label for="srcDirectory">Alternate source directory:</label><input type="text" name="srcDirectory"/></li>'); | ||||
| 	scrDirectory.hide(); | ||||
| 	optsList.append(scrDirectory); | ||||
| 	 | ||||
| 	var otherPkgs = $('<li><label for="otherpkgs">otherpkgs:</label><input type="text" name="otherpkgs"/></li>'); | ||||
| 	otherPkgs.hide(); | ||||
| 	optsList.append(otherPkgs); | ||||
| 	 | ||||
| 	var rpmFlags = $('<li><label for="rpm_flags">rpm_flags:</label><input type="text" name="rpm_flags"/></li>'); | ||||
| 	rpmFlags.hide(); | ||||
| 	optsList.append(rpmFlags); | ||||
| 	 | ||||
| 	var installPFlags = $('<li><label for="installp_flags">installp_flags:</label><input type="text" name="installp_flags"/></li>'); | ||||
| 	installPFlags.hide(); | ||||
| 	optsList.append(installPFlags); | ||||
| 	 | ||||
| 	// Show alternate source directory when checked | ||||
| 	updateChkBox.bind('click', function(event) { | ||||
| 		if ($(this).is(':checked')) { | ||||
| 			scrDirectory.show(); | ||||
| 			otherPkgs.show(); | ||||
| 			rpmFlags.show(); | ||||
| 			installPFlags.show(); | ||||
| 		} else { | ||||
| 			scrDirectory.hide(); | ||||
| 			otherPkgs.hide(); | ||||
| 			rpmFlags.hide(); | ||||
| 			installPFlags.hide(); | ||||
| 		} | ||||
| 	}); | ||||
| 	 | ||||
| 	// Postscripts | ||||
| 	var postChkBox = $('<input type="checkbox" id="P" name="P"/>'); | ||||
| 	var postOpt = $('<li></li>'); | ||||
| 	optsList.append(postOpt); | ||||
| 	postOpt.append(postChkBox); | ||||
| 	postOpt.append('Run postscripts'); | ||||
| 	var postscripts = $('<li><label for="postscripts">Postscripts:</label><input type="text" name="postscripts"/></li>'); | ||||
| 	postscripts.hide(); | ||||
| 	optsList.append(postscripts); | ||||
| 	 | ||||
| 	// Show alternate source directory when checked | ||||
| 	postChkBox.bind('click', function(event) { | ||||
| 		if ($(this).is(':checked')) { | ||||
| 			postscripts.show(); | ||||
| 		} else { | ||||
| 			postscripts.hide(); | ||||
| 		} | ||||
| 	}); | ||||
| 	 | ||||
| 	optsList.append('<li><input type="checkbox" id="F" name="F"/>Distribute and synchronize files</li>'); | ||||
| 	optsList.append('<li><input type="checkbox" id="k" name="k"/>Update the ssh keys and host keys for the service nodes and compute nodes</li>'); | ||||
| 	 | ||||
| 	// Update OS | ||||
| 	var osChkBox = $('<input type="checkbox" id="o" name="o"/>'); | ||||
| 	var osOpt = $('<li></li>'); | ||||
| 	optsList.append(osOpt); | ||||
| 	osOpt.append(osChkBox); | ||||
| 	osOpt.append('Update the operating system'); | ||||
| 	var os = $('<li><label for="scripts">Operating system:</label><input type="text" name="os"/></li>'); | ||||
| 	os.hide(); | ||||
| 	optsList.append(os); | ||||
| 	 | ||||
| 	// Show alternate source directory when checked | ||||
| 	osChkBox.bind('click', function(event) { | ||||
| 		if ($(this).is(':checked')) { | ||||
| 			os.show(); | ||||
| 		} else { | ||||
| 			os.hide(); | ||||
| 		} | ||||
| 	}); | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Ok | ||||
| 	 */ | ||||
| 	var okBtn = createButton('Ok'); | ||||
| 	okBtn.bind('click', function(event) { | ||||
| 		var ready = true; | ||||
| 		 | ||||
| 		// Generate arguments | ||||
| 		var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked"); | ||||
| 		var optStr = ''; | ||||
| 		var opt; | ||||
| 		for ( var i = 0; i < chkBoxes.length; i++) { | ||||
| 			opt = chkBoxes.eq(i).attr('name'); | ||||
| 			optStr += '-' + opt; | ||||
| 			 | ||||
| 			// If update all software is checked | ||||
| 			if (opt == 'S') { | ||||
| 				var srcDir = $('#' + newTabId + ' input[name=allSwSrcDirectory]').val(); | ||||
| 				if (srcDir) { | ||||
| 					optStr += ';-d ' + srcDir; | ||||
| 				}				 | ||||
| 			} | ||||
| 			 | ||||
| 			// If update software is checked | ||||
| 			if (opt == 'S') { | ||||
| 				var srcDir = $('#' + newTabId + ' input[name=srcDirectory]').val(); | ||||
| 				if (srcDir) { | ||||
| 					optStr += ';-d;' + srcDir; | ||||
| 				} | ||||
| 				 | ||||
| 				var otherpkgs = $('#' + newTabId + ' input[name=otherpkgs]').val(); | ||||
| 				if (otherpkgs) { | ||||
| 					optStr += ';otherpkgs=' + otherpkgs; | ||||
| 				} | ||||
| 				 | ||||
| 				var rpm_flags = $('#' + newTabId + ' input[name=rpm_flags]').val(); | ||||
| 				if (rpm_flags) { | ||||
| 					optStr += ';rpm_flags=' + rpm_flags; | ||||
| 				} | ||||
| 				 | ||||
| 				var installp_flags = $('#' + newTabId + ' input[name=installp_flags]').val(); | ||||
| 				if (installp_flags) { | ||||
| 					optStr += ';installp_flags=' + installp_flags; | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			// If postscripts is checked | ||||
| 			if (opt == 'P') { | ||||
| 				// Get postscripts | ||||
| 				optStr += ';' + $('#' + newTabId + ' input[name=postscripts]').val(); | ||||
| 			} | ||||
| 			 | ||||
| 			// If operating system is checked | ||||
| 			if (opt == 'o') { | ||||
| 				// Get the OS | ||||
| 				optStr += ';' + $('#' + newTabId + ' input[name=os]').val(); | ||||
| 			} | ||||
| 			 | ||||
| 			// Append ; to end of string | ||||
| 			if (i < (chkBoxes.length - 1)) { | ||||
| 				optStr += ';'; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		// If no inputs are empty | ||||
| 		if (ready) { | ||||
| 			// Get nodes | ||||
| 			var tgts = $('#' + newTabId + ' input[name=target]').val(); | ||||
|  | ||||
| 			// Stop this function from executing again | ||||
| 			// Unbind event | ||||
| 			$(this).unbind(event); | ||||
| 			$(this).css( { | ||||
| 				'background-color' : '#F2F2F2', | ||||
| 				'color' : '#424242' | ||||
| 			}); | ||||
|  | ||||
| 			/** | ||||
| 			 * (1) Boot to network | ||||
| 			 */ | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| 				data : { | ||||
| 					cmd : 'updatenode', | ||||
| 					tgt : tgts, | ||||
| 					args : optStr, | ||||
| 					msg : 'out=' + statBarId + ';cmd=updatenode;tgt=' + tgts | ||||
| 				}, | ||||
|  | ||||
| 				success : updateStatusBar | ||||
| 			}); | ||||
|  | ||||
| 			// Show status bar | ||||
| 			statusBar.show(); | ||||
| 		} else { | ||||
| 			alert('You are missing some values'); | ||||
| 		} | ||||
| 	}); | ||||
| 	updatenodeForm.append(okBtn); | ||||
|  | ||||
| 	// Append to discover tab | ||||
| 	tab.add(newTabId, 'Updatenode', updatenodeForm); | ||||
|  | ||||
| 	// Select new tab | ||||
| 	tab.select(newTabId); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Sort a list | ||||
|  *  | ||||
| @@ -1480,8 +832,6 @@ function sortAlpha(a, b) { | ||||
|  */ | ||||
| function powerNode(node, power2) { | ||||
| 	node = node.replace('Power', ''); | ||||
|  | ||||
| 	// Power on/off node | ||||
| 	$.ajax( { | ||||
| 		url : 'lib/cmd.php', | ||||
| 		dataType : 'json', | ||||
| @@ -1603,179 +953,14 @@ function deleteNode(tgtNodes) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Update nodeset status | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data returned from HTTP request | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function updateNodesetStatus(data) { | ||||
| 	var rsp = data.rsp; | ||||
| 	var args = data.msg.split(';'); | ||||
| 	var cmd = args[0].replace('cmd=', ''); | ||||
|  | ||||
| 	// Get nodeset instance | ||||
| 	var inst = args[1].replace('inst=', ''); | ||||
| 	var statBarId = 'nodesetStatusBar' + inst; | ||||
| 	var tabId = 'nodesetTab' + inst; | ||||
|  | ||||
| 	// Get nodes | ||||
| 	var tgts = $('#' + tabId + ' input[name=target]').val(); | ||||
|  | ||||
| 	// Get boot method | ||||
| 	var method = $('#' + tabId + ' select[id=bootMethod]').val(); | ||||
|  | ||||
| 	/** | ||||
| 	 * (2) Update /etc/hosts | ||||
| 	 */ | ||||
| 	if (cmd == 'nodeadd') { | ||||
| 		// If no output, no errors occurred | ||||
| 		if (rsp.length) { | ||||
| 			$('#' + statBarId).append( | ||||
| 				'<p>(Error) Failed to create node definition</p>'); | ||||
| 		} else { | ||||
| 			// Create target nodes string | ||||
| 			var tgtNodesStr = ''; | ||||
| 			var nodes = tgts.split(','); | ||||
| 			// Loop through each node | ||||
| 			for ( var i in nodes) { | ||||
| 				// If it is the 1st and only node | ||||
| 				if (i == 0 && i == nodes.length - 1) { | ||||
| 					tgtNodesStr += nodes[i]; | ||||
| 				} | ||||
| 				// If it is the 1st node of many nodes | ||||
| 				else if (i == 0 && i != nodes.length - 1) { | ||||
| 					// Append a comma to the string | ||||
| 					tgtNodesStr += nodes[i] + ', '; | ||||
| 				} else { | ||||
| 					// If it is the last node | ||||
| 					if (i == nodes.length - 1) { | ||||
| 						// Append nothing to the string | ||||
| 						tgtNodesStr += nodes[i]; | ||||
| 					} else { | ||||
| 						// For every 10 nodes, append a break | ||||
| 						if ((i % 10) > 0) { | ||||
| 							tgtNodesStr += nodes[i] + ', '; | ||||
| 						} else { | ||||
| 							tgtNodesStr += nodes[i] + ', <br>'; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			$('#' + statBarId).append( | ||||
| 				'<p>Node definition created for ' + tgtNodesStr + '</p>'); | ||||
| 		} | ||||
|  | ||||
| 		// Update /etc/hosts | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
| 			data : { | ||||
| 				cmd : 'makehosts', | ||||
| 				tgt : '', | ||||
| 				args : '', | ||||
| 				msg : 'cmd=makehosts;inst=' + inst | ||||
| 			}, | ||||
|  | ||||
| 			success : updateNodesetStatus | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * (4) Update DNS | ||||
| 	 */ | ||||
| 	else if (cmd == 'makehosts') { | ||||
| 		// If no output, no errors occurred | ||||
| 		if (rsp.length) { | ||||
| 			$('#' + statBarId).append( | ||||
| 				'<p>(Error) Failed to update /etc/hosts</p>'); | ||||
| 		} else { | ||||
| 			$('#' + statBarId).append('<p>/etc/hosts updated</p>'); | ||||
| 		} | ||||
|  | ||||
| 		// Update DNS | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
| 			data : { | ||||
| 				cmd : 'makedns', | ||||
| 				tgt : '', | ||||
| 				args : '', | ||||
| 				msg : 'cmd=makedns;inst=' + inst | ||||
| 			}, | ||||
|  | ||||
| 			success : updateNodesetStatus | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * (5) Update DHCP | ||||
| 	 */ | ||||
| 	else if (cmd == 'makedns') { | ||||
| 		// Write ajax response to status bar | ||||
| 		var prg = writeRsp(rsp, '');	 | ||||
| 		$('#' + statBarId).append(prg);	 | ||||
| 		 | ||||
| 		// Update DHCP | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
| 			data : { | ||||
| 				cmd : 'makedhcp', | ||||
| 				tgt : '', | ||||
| 				args : '-a', | ||||
| 				msg : 'cmd=makedhcp;inst=' + inst | ||||
| 			}, | ||||
|  | ||||
| 			success : updateNodesetStatus | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * (6) Prepare node for boot | ||||
| 	 */ | ||||
| 	else if (cmd == 'makedhcp') { | ||||
| 		// Write ajax response to status bar | ||||
| 		var prg = writeRsp(rsp, '');	 | ||||
| 		$('#' + statBarId).append(prg);	 | ||||
|  | ||||
| 		// Prepare node for boot | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
| 			data : { | ||||
| 				cmd : 'nodeset', | ||||
| 				tgt : tgts, | ||||
| 				args : method, | ||||
| 				msg : 'cmd=nodeset;inst=' + inst | ||||
| 			}, | ||||
|  | ||||
| 			success : updateNodesetStatus | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * (7) Boot node from network | ||||
| 	 */ | ||||
| 	else if (cmd == 'nodeset') { | ||||
| 		// Write ajax response to status bar | ||||
| 		var prg = writeRsp(rsp, '');	 | ||||
| 		$('#' + statBarId).append(prg);	 | ||||
|  | ||||
| 		// Hide loader | ||||
| 		$('#' + statBarId).find('img').hide(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Update the status bar of a given tab | ||||
|  * Update status bar of a given tab | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data returned from HTTP request | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function updateStatusBar(data) { | ||||
| 	// Get ajax response | ||||
| 	var rsp = data.rsp; | ||||
| 	var args = data.msg.split(';'); | ||||
| 	var statBarId = args[0].replace('out=', ''); | ||||
| @@ -1855,7 +1040,7 @@ function formComplete(tabId) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Update the power status of a node in the datatable | ||||
|  * Update power status of a node in the datatable | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data from HTTP request | ||||
| @@ -2031,13 +1216,11 @@ function setOSImageCookies(data) { | ||||
|  */ | ||||
| function setGroupsCookies(data) { | ||||
| 	var rsp = data.rsp; | ||||
|  | ||||
| 	// Save groups names in a cookie | ||||
| 	$.cookie('Groups', rsp); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get the row element that contains the given node | ||||
|  * Get row element that contains given node | ||||
|  *  | ||||
|  * @param tgtNode | ||||
|  *            Node to find | ||||
| @@ -2065,7 +1248,7 @@ function getNodeRow(tgtNode, rows) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get the nodes that are checked in a given datatable | ||||
|  * Get nodes that are checked in a given datatable | ||||
|  *  | ||||
|  * @param datatableId | ||||
|  * 				The datatable ID | ||||
|   | ||||
							
								
								
									
										355
									
								
								xCAT-UI/js/nodes/nodeset.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										355
									
								
								xCAT-UI/js/nodes/nodeset.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,355 @@ | ||||
| /** | ||||
|  * Load nodeset page | ||||
|  *  | ||||
|  * @param trgtNodes | ||||
|  *            Targets to run nodeset against | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function loadNodesetPage(trgtNodes) { | ||||
| 	// Get OS images | ||||
| 	$.ajax( { | ||||
| 		url : 'lib/cmd.php', | ||||
| 		dataType : 'json', | ||||
| 		data : { | ||||
| 			cmd : 'tabdump', | ||||
| 			tgt : '', | ||||
| 			args : 'osimage', | ||||
| 			msg : '' | ||||
| 		}, | ||||
|  | ||||
| 		success : setOSImageCookies | ||||
| 	}); | ||||
|  | ||||
| 	// Get nodes tab | ||||
| 	var tab = getNodesTab(); | ||||
|  | ||||
| 	// Generate new tab ID | ||||
| 	var inst = 0; | ||||
| 	var tabId = 'nodesetTab' + inst; | ||||
| 	while ($('#' + tabId).length) { | ||||
| 		// If one already exists, generate another one | ||||
| 		inst = inst + 1; | ||||
| 		tabId = 'nodesetTab' + inst; | ||||
| 	} | ||||
|  | ||||
| 	// Open new tab | ||||
| 	// Create nodeset form | ||||
| 	var nodesetForm = $('<div class="form"></div>'); | ||||
|  | ||||
| 	// Create status bar | ||||
| 	var statBarId = 'nodesetStatusBar' + inst; | ||||
| 	var statBar = createStatusBar(statBarId); | ||||
| 	statBar.hide(); | ||||
| 	nodesetForm.append(statBar); | ||||
|  | ||||
| 	// Create loader | ||||
| 	var loader = createLoader('nodesetLoader'); | ||||
| 	statBar.append(loader); | ||||
|  | ||||
| 	// Create info bar | ||||
| 	var infoBar = createInfoBar('Set the boot state for a node range'); | ||||
| 	nodesetForm.append(infoBar); | ||||
|  | ||||
| 	// Create target node or group | ||||
| 	var tgt = $('<div><label for="target">Target node or group:</label><input type="text" name="target" value="' + trgtNodes + '"/></div>'); | ||||
| 	nodesetForm.append(tgt); | ||||
|  | ||||
| 	// Create boot method drop down | ||||
| 	var method = $('<div></div>'); | ||||
| 	var methodLabel = $('<label for="method">Boot method:</label>'); | ||||
| 	var methodSelect = $('<select id="bootMethod" name="bootMethod"></select>'); | ||||
| 	methodSelect.append('<option value="boot">boot</option>'); | ||||
| 	methodSelect.append('<option value="install">install</option>'); | ||||
| 	methodSelect.append('<option value="iscsiboot">iscsiboot</option>'); | ||||
| 	methodSelect.append('<option value="netboot">netboot</option>'); | ||||
| 	methodSelect.append('<option value="statelite">statelite</option>'); | ||||
| 	method.append(methodLabel); | ||||
| 	method.append(methodSelect); | ||||
| 	nodesetForm.append(method); | ||||
|  | ||||
| 	// Create boot type drop down | ||||
| 	var type = $('<div></div>'); | ||||
| 	var typeLabel = $('<label for="type">Boot type:</label>'); | ||||
| 	var typeSelect = $('<select id="bootType" name="bootType"></select>'); | ||||
| 	typeSelect.append('<option value="zvm">zvm</option>'); | ||||
| 	typeSelect.append('<option value="install">pxe</option>'); | ||||
| 	typeSelect.append('<option value="iscsiboot">yaboot</option>'); | ||||
| 	type.append(typeLabel); | ||||
| 	type.append(typeSelect); | ||||
| 	nodesetForm.append(type); | ||||
|  | ||||
| 	// Create operating system input | ||||
| 	var os = $('<div></div>'); | ||||
| 	var osLabel = $('<label for="os">Operating system:</label>'); | ||||
| 	var osInput = $('<input type="text" name="os"/>'); | ||||
| 	osInput.one('focus', function(){ | ||||
| 		var tmp = $.cookie('OSVers'); | ||||
| 		if (tmp) { | ||||
| 			// Turn on auto complete | ||||
| 			$(this).autocomplete(tmp.split(',')); | ||||
| 		} | ||||
| 	}); | ||||
| 	os.append(osLabel); | ||||
| 	os.append(osInput); | ||||
| 	nodesetForm.append(os); | ||||
|  | ||||
| 	// Create architecture input | ||||
| 	var arch = $('<div></div>'); | ||||
| 	var archLabel = $('<label for="arch">Architecture:</label>'); | ||||
| 	var archInput = $('<input type="text" name="arch"/>'); | ||||
| 	archInput.one('focus', function(){ | ||||
| 		var tmp = $.cookie('OSArchs'); | ||||
| 		if (tmp) { | ||||
| 			// Turn on auto complete | ||||
| 			$(this).autocomplete(tmp.split(',')); | ||||
| 		} | ||||
| 	}); | ||||
| 	arch.append(archLabel); | ||||
| 	arch.append(archInput); | ||||
| 	nodesetForm.append(arch); | ||||
|  | ||||
| 	// Create profiles input | ||||
| 	var profile = $('<div></div>'); | ||||
| 	var profileLabel = $('<label for="profile">Profile:</label>'); | ||||
| 	var profileInput = $('<input type="text" name="profile"/>'); | ||||
| 	profileInput.one('focus', function(){ | ||||
| 		tmp = $.cookie('Profiles'); | ||||
| 		if (tmp) { | ||||
| 			// Turn on auto complete | ||||
| 			$(this).autocomplete(tmp.split(',')); | ||||
| 		} | ||||
| 	}); | ||||
| 	profile.append(profileLabel); | ||||
| 	profile.append(profileInput); | ||||
| 	nodesetForm.append(profile); | ||||
|  | ||||
| 	/** | ||||
| 	 * Ok | ||||
| 	 */ | ||||
| 	var okBtn = createButton('Ok'); | ||||
| 	okBtn.bind('click', function(event) { | ||||
| 		// Check state, OS, arch, and profile | ||||
| 		var ready = true; | ||||
| 		var inputs = $('#' + tabId + ' input'); | ||||
| 		for ( var i = 0; i < inputs.length; i++) { | ||||
| 			if (!inputs.eq(i).val() && inputs.eq(i).attr('name') != 'diskPw') { | ||||
| 				inputs.eq(i).css('border', 'solid #FF0000 1px'); | ||||
| 				ready = false; | ||||
| 			} else { | ||||
| 				inputs.eq(i).css('border', 'solid #BDBDBD 1px'); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if (ready) { | ||||
| 			// Get nodes | ||||
| 			var tgts = $('#' + tabId + ' input[name=target]').val(); | ||||
| 			// Get boot method | ||||
| 			var method = $('#' + tabId + ' select[id=bootMethod]').val(); | ||||
| 			// Get boot type | ||||
| 			var type = $('#' + tabId + ' select[id=bootType]').val(); | ||||
|  | ||||
| 			// Get OS, arch, and profile | ||||
| 			var os = $('#' + tabId + ' input[name=os]').val(); | ||||
| 			var arch = $('#' + tabId + ' input[name=arch]').val(); | ||||
| 			var profile = $('#' + tabId + ' input[name=profile]').val(); | ||||
|  | ||||
| 			// Disable Ok button | ||||
| 			$(this).unbind(event); | ||||
| 			$(this).css( { | ||||
| 				'background-color' : '#F2F2F2', | ||||
| 				'color' : '#424242' | ||||
| 			}); | ||||
|  | ||||
| 			/** | ||||
| 			 * (1) Set the OS, arch, and profile | ||||
| 			 */ | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| 				data : { | ||||
| 					cmd : 'nodeadd', | ||||
| 					tgt : '', | ||||
| 					args : tgts + ';noderes.netboot=' + type  | ||||
| 						+ ';nodetype.os=' + os  | ||||
| 						+ ';nodetype.arch=' + arch  | ||||
| 						+ ';nodetype.profile=' + profile, | ||||
| 					msg : 'cmd=nodeadd;inst=' + inst | ||||
| 				}, | ||||
|  | ||||
| 				success : updateNodesetStatus | ||||
| 			}); | ||||
|  | ||||
| 			// Show status bar | ||||
| 			statBar.show(); | ||||
| 		} else { | ||||
| 			alert('You are missing some values'); | ||||
| 		} | ||||
| 	}); | ||||
| 	nodesetForm.append(okBtn); | ||||
|  | ||||
| 	// Append to discover tab | ||||
| 	tab.add(tabId, 'Nodeset', nodesetForm); | ||||
|  | ||||
| 	// Select new tab | ||||
| 	tab.select(tabId); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Update nodeset status | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data returned from HTTP request | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function updateNodesetStatus(data) { | ||||
| 	// Get ajax response | ||||
| 	var rsp = data.rsp; | ||||
| 	var args = data.msg.split(';'); | ||||
| 	var cmd = args[0].replace('cmd=', ''); | ||||
|  | ||||
| 	// Get nodeset instance | ||||
| 	var inst = args[1].replace('inst=', ''); | ||||
| 	// Get status bar ID | ||||
| 	var statBarId = 'nodesetStatusBar' + inst; | ||||
| 	// Get tab ID | ||||
| 	var tabId = 'nodesetTab' + inst; | ||||
|  | ||||
| 	// Get nodes | ||||
| 	var tgts = $('#' + tabId + ' input[name=target]').val(); | ||||
| 	// Get boot method | ||||
| 	var method = $('#' + tabId + ' select[id=bootMethod]').val(); | ||||
|  | ||||
| 	/** | ||||
| 	 * (2) Update /etc/hosts | ||||
| 	 */ | ||||
| 	if (cmd == 'nodeadd') { | ||||
| 		if (rsp.length) { | ||||
| 			$('#' + statBarId).find('img').hide(); | ||||
| 			$('#' + statBarId).append('<p>(Error) Failed to create node definition</p>'); | ||||
| 		} else { | ||||
| 			// Create target nodes string | ||||
| 			var tgtNodesStr = ''; | ||||
| 			// Loop through each node | ||||
| 			for ( var i in nodes) { | ||||
| 				// If it is the 1st and only node | ||||
| 				if (i == 0 && i == nodes.length - 1) { | ||||
| 					tgtNodesStr += nodes[i]; | ||||
| 				} | ||||
| 				// If it is the 1st node of many nodes | ||||
| 				else if (i == 0 && i != nodes.length - 1) { | ||||
| 					// Append a comma to the string | ||||
| 					tgtNodesStr += nodes[i] + ', '; | ||||
| 				} else { | ||||
| 					// If it is the last node | ||||
| 					if (i == nodes.length - 1) { | ||||
| 						// Append nothing to the string | ||||
| 						tgtNodesStr += nodes[i]; | ||||
| 					} else { | ||||
| 						// Append a comma to the string | ||||
| 						tgtNodesStr += nodes[i] + ', '; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			$('#' + statBarId).append('<p>Node definition created for ' + tgtNodesStr + '</p>'); | ||||
| 		} | ||||
|  | ||||
| 		// Update /etc/hosts | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
| 			data : { | ||||
| 				cmd : 'makehosts', | ||||
| 				tgt : '', | ||||
| 				args : '', | ||||
| 				msg : 'cmd=makehosts;inst=' + inst | ||||
| 			}, | ||||
|  | ||||
| 			success : updateNodesetStatus | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * (4) Update DNS | ||||
| 	 */ | ||||
| 	else if (cmd == 'makehosts') { | ||||
| 		// If no output, no errors occurred | ||||
| 		if (rsp.length) { | ||||
| 			$('#' + statBarId).append('<p>(Error) Failed to update /etc/hosts</p>'); | ||||
| 		} else { | ||||
| 			$('#' + statBarId).append('<p>/etc/hosts updated</p>'); | ||||
| 		} | ||||
|  | ||||
| 		// Update DNS | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
| 			data : { | ||||
| 				cmd : 'makedns', | ||||
| 				tgt : '', | ||||
| 				args : '', | ||||
| 				msg : 'cmd=makedns;inst=' + inst | ||||
| 			}, | ||||
|  | ||||
| 			success : updateNodesetStatus | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * (5) Update DHCP | ||||
| 	 */ | ||||
| 	else if (cmd == 'makedns') { | ||||
| 		// Write ajax response to status bar | ||||
| 		var prg = writeRsp(rsp, '');	 | ||||
| 		$('#' + statBarId).append(prg);	 | ||||
| 		 | ||||
| 		// Update DHCP | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
| 			data : { | ||||
| 				cmd : 'makedhcp', | ||||
| 				tgt : '', | ||||
| 				args : '-a', | ||||
| 				msg : 'cmd=makedhcp;inst=' + inst | ||||
| 			}, | ||||
|  | ||||
| 			success : updateNodesetStatus | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * (6) Prepare node for boot | ||||
| 	 */ | ||||
| 	else if (cmd == 'makedhcp') { | ||||
| 		// Write ajax response to status bar | ||||
| 		var prg = writeRsp(rsp, '');	 | ||||
| 		$('#' + statBarId).append(prg);	 | ||||
|  | ||||
| 		// Prepare node for boot | ||||
| 		$.ajax( { | ||||
| 			url : 'lib/cmd.php', | ||||
| 			dataType : 'json', | ||||
| 			data : { | ||||
| 				cmd : 'nodeset', | ||||
| 				tgt : tgts, | ||||
| 				args : method, | ||||
| 				msg : 'cmd=nodeset;inst=' + inst | ||||
| 			}, | ||||
|  | ||||
| 			success : updateNodesetStatus | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * (7) Boot node from network | ||||
| 	 */ | ||||
| 	else if (cmd == 'nodeset') { | ||||
| 		// Write ajax response to status bar | ||||
| 		var prg = writeRsp(rsp, '');	 | ||||
| 		$('#' + statBarId).append(prg);	 | ||||
|  | ||||
| 		// Hide loader | ||||
| 		$('#' + statBarId).find('img').hide(); | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										173
									
								
								xCAT-UI/js/nodes/rnetboot.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										173
									
								
								xCAT-UI/js/nodes/rnetboot.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,173 @@ | ||||
| /** | ||||
|  * Load netboot page | ||||
|  *  | ||||
|  * @param tgtNodes | ||||
|  *            Targets to run rnetboot against | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function loadNetbootPage(tgtNodes) { | ||||
| 	// Get nodes tab | ||||
| 	var tab = getNodesTab(); | ||||
|  | ||||
| 	// Generate new tab ID | ||||
| 	var inst = 0; | ||||
| 	var newTabId = 'netbootTab' + inst; | ||||
| 	while ($('#' + newTabId).length) { | ||||
| 		// If one already exists, generate another one | ||||
| 		inst = inst + 1; | ||||
| 		newTabId = 'netbootTab' + inst; | ||||
| 	} | ||||
|  | ||||
| 	// Create netboot form | ||||
| 	var netbootForm = $('<div class="form"></div>'); | ||||
|  | ||||
| 	// Create status bar | ||||
| 	var barId = 'netbootStatusBar' + inst; | ||||
| 	var statusBar = createStatusBar(barId); | ||||
| 	statusBar.hide(); | ||||
| 	netbootForm.append(statusBar); | ||||
|  | ||||
| 	// Create loader | ||||
| 	var loader = createLoader('netbootLoader'); | ||||
| 	statusBar.append(loader); | ||||
|  | ||||
| 	// Create info bar | ||||
| 	var infoBar = createInfoBar('Cause the range of nodes to boot to network'); | ||||
| 	netbootForm.append(infoBar); | ||||
|  | ||||
| 	// Create target node or group input | ||||
| 	var target = $('<div><label for="target">Target node or group:</label><input type="text" name="target" value="' + tgtNodes + '"/></div>'); | ||||
| 	netbootForm.append(target); | ||||
|  | ||||
| 	// Create options | ||||
| 	var optsDIV = $('<div></div>'); | ||||
| 	var optsLabel = $('<label>Options:</label>');	 | ||||
| 	var optsList = $('<ul></ul>'); | ||||
| 	var opt = $('<li></li>'); | ||||
| 	optsList.append(opt); | ||||
| 	optsDIV.append(optsLabel); | ||||
| 	optsDIV.append(optsList); | ||||
| 	netbootForm.append(optsDIV); | ||||
| 	 | ||||
| 	// Create boot order checkbox | ||||
| 	var bootOrderChkBox = $('<input type="checkbox" id="s" name="s"/>'); | ||||
| 	opt.append(bootOrderChkBox); | ||||
| 	opt.append('Set the boot device order'); | ||||
| 	// Create boot order input | ||||
| 	var bootOrder = $('<li><label for="bootOrder">Boot order:</label><input type="text" name="bootOrder"/></li>'); | ||||
| 	bootOrder.hide(); | ||||
| 	optsList.append(bootOrder); | ||||
| 	 | ||||
| 	// Create force reboot checkbox | ||||
| 	optsList.append('<li><input type="checkbox" id="F" name="F"/>Force reboot</li>'); | ||||
| 	// Create force shutdown checkbox | ||||
| 	optsList.append('<li><input type="checkbox" id="f" name="f"/>Force immediate shutdown of the partition</li>'); | ||||
| 	// Create iscsi dump checkbox | ||||
| 	optsList.append('<li><input type="checkbox" id="I" name="I"/>Do a iscsi dump on AIX</li>'); | ||||
| 	 | ||||
| 	// Show boot order when checkbox is checked | ||||
| 	bootOrderChkBox.bind('click', function(event) { | ||||
| 		if ($(this).is(':checked')) { | ||||
| 			bootOrder.show(); | ||||
| 		} else { | ||||
| 			bootOrder.hide(); | ||||
| 		} | ||||
| 	}); | ||||
|  | ||||
| 	// Determine plugin | ||||
| 	var tmp = tgtNodes.split(','); | ||||
| 	for ( var i = 0; i < tmp.length; i++) { | ||||
| 		var mgt = getNodeMgt(tmp[i]); | ||||
| 		// If it is zvm | ||||
| 		if (mgt == 'zvm') { | ||||
| 			// Add IPL input | ||||
| 			netbootForm.append('<div><label for="ipl">IPL:</label><input type="text" name="ipl"/></div>'); | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Ok | ||||
| 	 */ | ||||
| 	var okBtn = createButton('Ok'); | ||||
| 	okBtn.bind('click', function(event) { | ||||
| 		// Check inputs | ||||
| 		var ready = true; | ||||
| 		var inputs = $("#" + newTabId + " input[type='text']:visible"); | ||||
| 		for ( var i = 0; i < inputs.length; i++) { | ||||
| 			if (!inputs.eq(i).val()) { | ||||
| 				inputs.eq(i).css('border', 'solid #FF0000 1px'); | ||||
| 				ready = false; | ||||
| 			} else { | ||||
| 				inputs.eq(i).css('border', 'solid #BDBDBD 1px'); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// Generate arguments | ||||
| 		var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked"); | ||||
| 		var optStr = ''; | ||||
| 		var opt; | ||||
| 		for ( var i = 0; i < chkBoxes.length; i++) { | ||||
| 			opt = chkBoxes.eq(i).attr('name'); | ||||
| 			optStr += '-' + opt; | ||||
| 			 | ||||
| 			// If it is the boot order | ||||
| 			if (opt == 's') { | ||||
| 				// Get the boot order | ||||
| 				optStr += ';' + $('#' + newTabId + ' input[name=bootOrder]').val(); | ||||
| 			} | ||||
| 			 | ||||
| 			// Append ; to end of string | ||||
| 			if (i < (chkBoxes.length - 1)) { | ||||
| 				optStr += ';'; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// If no inputs are empty | ||||
| 		if (ready) { | ||||
| 			// Get nodes | ||||
| 			var tgts = $('#' + newTabId + ' input[name=target]').val(); | ||||
|  | ||||
| 			// Get IPL address | ||||
| 			var ipl = $('#' + newTabId + ' input[name=ipl]'); | ||||
| 			if (ipl) { | ||||
| 				optStr += 'ipl=' + ipl.val(); | ||||
| 			} | ||||
|  | ||||
| 			// Disable Ok button | ||||
| 			$(this).unbind(event); | ||||
| 			$(this).css( { | ||||
| 				'background-color' : '#F2F2F2', | ||||
| 				'color' : '#424242' | ||||
| 			}); | ||||
|  | ||||
| 			/** | ||||
| 			 * (1) Boot to network | ||||
| 			 */ | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| 				data : { | ||||
| 					cmd : 'rnetboot', | ||||
| 					tgt : tgts, | ||||
| 					args : optStr, | ||||
| 					msg : 'out=' + barId + ';cmd=rnetboot;tgt=' + tgts | ||||
| 				}, | ||||
|  | ||||
| 				success : updateStatusBar | ||||
| 			}); | ||||
|  | ||||
| 			// Show status bar | ||||
| 			statusBar.show(); | ||||
| 		} else { | ||||
| 			alert('You are missing some values'); | ||||
| 		} | ||||
| 	}); | ||||
| 	netbootForm.append(okBtn); | ||||
|  | ||||
| 	// Append to discover tab | ||||
| 	tab.add(newTabId, 'Netboot', netbootForm); | ||||
|  | ||||
| 	// Select new tab | ||||
| 	tab.select(newTabId); | ||||
| } | ||||
							
								
								
									
										255
									
								
								xCAT-UI/js/nodes/updatenode.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										255
									
								
								xCAT-UI/js/nodes/updatenode.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,255 @@ | ||||
| /** | ||||
|  * Load updatenode page | ||||
|  *  | ||||
|  * @param tgtNodes | ||||
|  *            Targets to run updatenode against | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function loadUpdatenodePage(tgtNodes) { | ||||
| 	// Get nodes tab | ||||
| 	var tab = getNodesTab(); | ||||
|  | ||||
| 	// Generate new tab ID | ||||
| 	var inst = 0; | ||||
| 	var newTabId = 'updatenodeTab' + inst; | ||||
| 	while ($('#' + newTabId).length) { | ||||
| 		// If one already exists, generate another one | ||||
| 		inst = inst + 1; | ||||
| 		newTabId = 'updatenodeTab' + inst; | ||||
| 	} | ||||
|  | ||||
| 	// Create updatenode form | ||||
| 	var updatenodeForm = $('<div class="form"></div>'); | ||||
|  | ||||
| 	// Create status bar | ||||
| 	var statBarId = 'updatenodeStatusBar' + inst; | ||||
| 	var statusBar = createStatusBar(statBarId); | ||||
| 	statusBar.hide(); | ||||
| 	updatenodeForm.append(statusBar); | ||||
|  | ||||
| 	// Create loader | ||||
| 	var loader = createLoader('updatenodeLoader'); | ||||
| 	statusBar.append(loader); | ||||
|  | ||||
| 	// Create info bar | ||||
| 	var infoBar = createInfoBar('Update nodes in an xCAT environment'); | ||||
| 	updatenodeForm.append(infoBar); | ||||
|  | ||||
| 	// Create target node or group input | ||||
| 	var target = $('<div><label for="target">Target node or group:</label><input type="text" name="target" value="' + tgtNodes + '"/></div>'); | ||||
| 	updatenodeForm.append(target); | ||||
|  | ||||
| 	// Create options | ||||
| 	var optsDIV = $('<div></div>'); | ||||
| 	var optsLabel = $('<label>Options:</label>');	 | ||||
| 	var optsList = $('<ul></ul>'); | ||||
| 	optsDIV.append(optsLabel); | ||||
| 	optsDIV.append(optsList); | ||||
| 	updatenodeForm.append(optsDIV); | ||||
| 		 | ||||
| 	// Create update all software checkbox | ||||
| 	var updateAllChkBox = $('<input type="checkbox" id="A" name="A"/>'); | ||||
| 	var updateAllOpt = $('<li></li>'); | ||||
| 	optsList.append(updateAllOpt); | ||||
| 	updateAllOpt.append(updateAllChkBox); | ||||
| 	updateAllOpt.append('Install or update all software contained in the source directory'); | ||||
| 	var allSwScrDirectory = $('<li><label for="allSwSrcDirectory">Alternate source directory:</label><input type="text" name="allSwSrcDirectory"/></li>'); | ||||
| 	allSwScrDirectory.hide(); | ||||
| 	optsList.append(allSwScrDirectory); | ||||
| 			 | ||||
| 	// Show alternate source directory when checked | ||||
| 	updateAllChkBox.bind('click', function(event) { | ||||
| 		if ($(this).is(':checked')) { | ||||
| 			allSwScrDirectory.show(); | ||||
| 		} else { | ||||
| 			allSwScrDirectory.hide(); | ||||
| 		} | ||||
| 	}); | ||||
| 	 | ||||
| 	// Create update software checkbox | ||||
| 	var updateChkBox = $('<input type="checkbox" id="S" name="S"/>'); | ||||
| 	var updateOpt = $('<li></li>'); | ||||
| 	optsList.append(updateOpt); | ||||
| 	updateOpt.append(updateChkBox); | ||||
| 	updateOpt.append('Update software'); | ||||
| 		 | ||||
| 	// Create source directory input | ||||
| 	var scrDirectory = $('<li><label for="srcDirectory">Alternate source directory:</label><input type="text" name="srcDirectory"/></li>'); | ||||
| 	scrDirectory.hide(); | ||||
| 	optsList.append(scrDirectory); | ||||
| 	 | ||||
| 	// Create other packages input | ||||
| 	var otherPkgs = $('<li><label for="otherpkgs">otherpkgs:</label><input type="text" name="otherpkgs"/></li>'); | ||||
| 	otherPkgs.hide(); | ||||
| 	optsList.append(otherPkgs); | ||||
| 	 | ||||
| 	// Create RPM flags input | ||||
| 	var rpmFlags = $('<li><label for="rpm_flags">rpm_flags:</label><input type="text" name="rpm_flags"/></li>'); | ||||
| 	rpmFlags.hide(); | ||||
| 	optsList.append(rpmFlags); | ||||
| 	 | ||||
| 	// Create installp flags input | ||||
| 	var installPFlags = $('<li><label for="installp_flags">installp_flags:</label><input type="text" name="installp_flags"/></li>'); | ||||
| 	installPFlags.hide(); | ||||
| 	optsList.append(installPFlags); | ||||
| 	 | ||||
| 	// Show alternate source directory when checked | ||||
| 	updateChkBox.bind('click', function(event) { | ||||
| 		if ($(this).is(':checked')) { | ||||
| 			scrDirectory.show(); | ||||
| 			otherPkgs.show(); | ||||
| 			rpmFlags.show(); | ||||
| 			installPFlags.show(); | ||||
| 		} else { | ||||
| 			scrDirectory.hide(); | ||||
| 			otherPkgs.hide(); | ||||
| 			rpmFlags.hide(); | ||||
| 			installPFlags.hide(); | ||||
| 		} | ||||
| 	}); | ||||
| 	 | ||||
| 	// Create postscripts input | ||||
| 	var postChkBox = $('<input type="checkbox" id="P" name="P"/>'); | ||||
| 	var postOpt = $('<li></li>'); | ||||
| 	optsList.append(postOpt); | ||||
| 	postOpt.append(postChkBox); | ||||
| 	postOpt.append('Run postscripts'); | ||||
| 	var postscripts = $('<li><label for="postscripts">Postscripts:</label><input type="text" name="postscripts"/></li>'); | ||||
| 	postscripts.hide(); | ||||
| 	optsList.append(postscripts); | ||||
| 	// Show alternate source directory when checked | ||||
| 	postChkBox.bind('click', function(event) { | ||||
| 		if ($(this).is(':checked')) { | ||||
| 			postscripts.show(); | ||||
| 		} else { | ||||
| 			postscripts.hide(); | ||||
| 		} | ||||
| 	}); | ||||
| 	optsList.append('<li><input type="checkbox" id="F" name="F"/>Distribute and synchronize files</li>'); | ||||
| 	optsList.append('<li><input type="checkbox" id="k" name="k"/>Update the ssh keys and host keys for the service nodes and compute nodes</li>'); | ||||
| 	 | ||||
| 	// Create update OS checkbox | ||||
| 	var osChkBox = $('<input type="checkbox" id="o" name="o"/>'); | ||||
| 	var osOpt = $('<li></li>'); | ||||
| 	optsList.append(osOpt); | ||||
| 	osOpt.append(osChkBox); | ||||
| 	osOpt.append('Update the operating system'); | ||||
| 	var os = $('<li><label for="scripts">Operating system:</label><input type="text" name="os"/></li>'); | ||||
| 	os.hide(); | ||||
| 	optsList.append(os); | ||||
| 	 | ||||
| 	// Show alternate source directory when checked | ||||
| 	osChkBox.bind('click', function(event) { | ||||
| 		if ($(this).is(':checked')) { | ||||
| 			os.show(); | ||||
| 		} else { | ||||
| 			os.hide(); | ||||
| 		} | ||||
| 	}); | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Ok | ||||
| 	 */ | ||||
| 	var okBtn = createButton('Ok'); | ||||
| 	okBtn.bind('click', function(event) { | ||||
| 		var ready = true; | ||||
| 		 | ||||
| 		// Generate arguments | ||||
| 		var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked"); | ||||
| 		var optStr = ''; | ||||
| 		var opt; | ||||
| 		for ( var i = 0; i < chkBoxes.length; i++) { | ||||
| 			opt = chkBoxes.eq(i).attr('name'); | ||||
| 			optStr += '-' + opt; | ||||
| 			 | ||||
| 			// If update all software is checked | ||||
| 			if (opt == 'S') { | ||||
| 				var srcDir = $('#' + newTabId + ' input[name=allSwSrcDirectory]').val(); | ||||
| 				if (srcDir) { | ||||
| 					optStr += ';-d ' + srcDir; | ||||
| 				}				 | ||||
| 			} | ||||
| 			 | ||||
| 			// If update software is checked | ||||
| 			if (opt == 'S') { | ||||
| 				var srcDir = $('#' + newTabId + ' input[name=srcDirectory]').val(); | ||||
| 				if (srcDir) { | ||||
| 					optStr += ';-d;' + srcDir; | ||||
| 				} | ||||
| 				 | ||||
| 				var otherpkgs = $('#' + newTabId + ' input[name=otherpkgs]').val(); | ||||
| 				if (otherpkgs) { | ||||
| 					optStr += ';otherpkgs=' + otherpkgs; | ||||
| 				} | ||||
| 				 | ||||
| 				var rpm_flags = $('#' + newTabId + ' input[name=rpm_flags]').val(); | ||||
| 				if (rpm_flags) { | ||||
| 					optStr += ';rpm_flags=' + rpm_flags; | ||||
| 				} | ||||
| 				 | ||||
| 				var installp_flags = $('#' + newTabId + ' input[name=installp_flags]').val(); | ||||
| 				if (installp_flags) { | ||||
| 					optStr += ';installp_flags=' + installp_flags; | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			// If postscripts is checked | ||||
| 			if (opt == 'P') { | ||||
| 				// Get postscripts | ||||
| 				optStr += ';' + $('#' + newTabId + ' input[name=postscripts]').val(); | ||||
| 			} | ||||
| 			 | ||||
| 			// If operating system is checked | ||||
| 			if (opt == 'o') { | ||||
| 				// Get the OS | ||||
| 				optStr += ';' + $('#' + newTabId + ' input[name=os]').val(); | ||||
| 			} | ||||
| 			 | ||||
| 			// Append ; to end of string | ||||
| 			if (i < (chkBoxes.length - 1)) { | ||||
| 				optStr += ';'; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		// If no inputs are empty | ||||
| 		if (ready) { | ||||
| 			// Get nodes | ||||
| 			var tgts = $('#' + newTabId + ' input[name=target]').val(); | ||||
|  | ||||
| 			// Disable Ok button | ||||
| 			$(this).unbind(event); | ||||
| 			$(this).css( { | ||||
| 				'background-color' : '#F2F2F2', | ||||
| 				'color' : '#424242' | ||||
| 			}); | ||||
|  | ||||
| 			/** | ||||
| 			 * (1) Boot to network | ||||
| 			 */ | ||||
| 			$.ajax( { | ||||
| 				url : 'lib/cmd.php', | ||||
| 				dataType : 'json', | ||||
| 				data : { | ||||
| 					cmd : 'updatenode', | ||||
| 					tgt : tgts, | ||||
| 					args : optStr, | ||||
| 					msg : 'out=' + statBarId + ';cmd=updatenode;tgt=' + tgts | ||||
| 				}, | ||||
|  | ||||
| 				success : updateStatusBar | ||||
| 			}); | ||||
|  | ||||
| 			// Show status bar | ||||
| 			statusBar.show(); | ||||
| 		} else { | ||||
| 			alert('You are missing some values'); | ||||
| 		} | ||||
| 	}); | ||||
| 	updatenodeForm.append(okBtn); | ||||
|  | ||||
| 	// Append to discover tab | ||||
| 	tab.add(newTabId, 'Updatenode', updatenodeForm); | ||||
|  | ||||
| 	// Select new tab | ||||
| 	tab.select(newTabId); | ||||
| } | ||||
| @@ -38,8 +38,7 @@ function loadProvisionPage() { | ||||
|  | ||||
| 	// Create status bar, hide on load | ||||
| 	var statBarId = 'ProvisionStatusBar'; | ||||
| 	var statBar = $('<div class="statusBar" id="' + statBarId + '"></div>') | ||||
| 		.hide(); | ||||
| 	var statBar = $('<div class="statusBar" id="' + statBarId + '"></div>').hide(); | ||||
|  | ||||
| 	// Create info bar | ||||
| 	var infoBar = createInfoBar('Provision a node'); | ||||
| @@ -56,8 +55,7 @@ function loadProvisionPage() { | ||||
| 	tab.init(); | ||||
| 	$('#content').append(tab.object()); | ||||
|  | ||||
| 	// Create drop-down menu | ||||
| 	// Hardware available to provision - ipmi, blade, hmc, ivm, fsp, and zvm | ||||
| 	// Create drop down menu for platforms | ||||
| 	var div = $('<div></div>'); | ||||
| 	provForm.append(div); | ||||
|  | ||||
|   | ||||
| @@ -29,10 +29,9 @@ Tab.prototype.init = function() { | ||||
| 	this.tab.append(tabList); | ||||
|  | ||||
| 	// Create a template with close button | ||||
| 	var tabs = this.tab | ||||
| 		.tabs( { | ||||
| 			tabTemplate : "<li><a href=\"#{href}\">#{label}</a><span class=\"tab-close ui-icon ui-icon-close\"></span></li>" | ||||
| 		}); | ||||
| 	var tabs = this.tab.tabs( { | ||||
| 		tabTemplate : "<li><a href=\"#{href}\">#{label}</a><span class=\"tab-close ui-icon ui-icon-close\"></span></li>" | ||||
| 	}); | ||||
|  | ||||
| 	// Remove dummy tab | ||||
| 	this.tab.tabs("remove", 0); | ||||
| @@ -103,7 +102,6 @@ Tab.prototype.select = function(id) { | ||||
|  * @return Nothing | ||||
|  */ | ||||
| Tab.prototype.remove = function(id) { | ||||
| 	// To be continued | ||||
| 	var selectorStr = 'a[href="\#' + id + '"]';	 | ||||
| 	var selectTab = $(selectorStr, this.tab).parent(); | ||||
| 	var index = ($('li', this.tab).index(selectTab)); | ||||
| @@ -391,8 +389,6 @@ function createMenu(items) { | ||||
|  */ | ||||
| function initPage() { | ||||
| 	// Load javascripts | ||||
| 	// TODO: We need to determine which page needs which script | ||||
| 	// and load less | ||||
| 	includeJs("js/jquery/jquery.dataTables.min.js"); | ||||
| 	includeJs("js/jquery/jquery.form.js"); | ||||
| 	includeJs("js/jquery/jquery.jeditable.js"); | ||||
| @@ -427,6 +423,10 @@ function initPage() { | ||||
| 	// Show the page | ||||
| 	$("#content").children().remove(); | ||||
| 	if (page == 'index.php') { | ||||
| 		includeJs("js/nodes/nodeset.js"); | ||||
| 		includeJs("js/nodes/rnetboot.js"); | ||||
| 		includeJs("js/nodes/updatenode.js"); | ||||
| 		 | ||||
| 		headers.eq(0).css('background-color', '#A9D0F5'); | ||||
| 		loadNodesPage(); | ||||
| 	} else if (page == 'configure.php') { | ||||
| @@ -473,7 +473,7 @@ function includeJs(file) { | ||||
|  * @param rsp | ||||
|  * 			Ajax response | ||||
|  * @param pattern | ||||
|  * 			Pattern to insert a break in between | ||||
|  * 			Pattern to replace with a break | ||||
|  * @return Paragraph containing ajax response | ||||
|  */ | ||||
| function writeRsp(rsp, pattern) { | ||||
| @@ -481,6 +481,8 @@ function writeRsp(rsp, pattern) { | ||||
| 	var prg = $('<p></p>'); | ||||
| 	for ( var i in rsp) { | ||||
| 		if (rsp[i]) { | ||||
| 			// Create regular expression for given pattern | ||||
| 			// Replace pattern with break | ||||
| 			if (pattern) { | ||||
| 				rsp[i] = rsp[i].replace(new RegExp(pattern, 'g'), '<br>'); | ||||
| 			} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user