Check in self-service portal code. This is currently set for System z, more work needs to be done to customize it for other platforms.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10543 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		
							
								
								
									
										365
									
								
								xCAT-UI/css/service.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										365
									
								
								xCAT-UI/css/service.css
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,365 @@ | ||||
| /*--- Dialogs ---*/ | ||||
| .ui-dialog input { | ||||
| 	border: solid 1px; | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| } | ||||
|  | ||||
| .ui-dialog label,.ui-dialog input,.ui-dialog p,.ui-dialog button,.ui-dialog td { | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| } | ||||
|  | ||||
| .ui-widget { | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| } | ||||
|  | ||||
| /*--- Tooltip ---*/ | ||||
| .tooltip { | ||||
| 	background-color: #000; | ||||
| 	border: 1px solid #fff; | ||||
| 	padding: 10px 15px; | ||||
| 	display: none; | ||||
| 	color: #fff; | ||||
| 	text-align: left; | ||||
| 	max-width: 300px; | ||||
| 	font-size: 10px; | ||||
| 	/* Outline radius for firefox only */ | ||||
| 	-moz-box-shadow: 0 0 10px #000; | ||||
| 	-webkit-box-shadow: 0 0 10px #000; | ||||
| } | ||||
|  | ||||
| .tooltip h3 { | ||||
| 	margin: 0px; | ||||
| } | ||||
|  | ||||
| /*--- Login dialog ---*/ | ||||
| #logdialog { | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| 	width: 600px; | ||||
| } | ||||
|  | ||||
| #logdialog table { | ||||
| 	border: solid 0px; | ||||
| } | ||||
|  | ||||
| #logdialog td { | ||||
| 	width: 100px; | ||||
| 	height: 35px; | ||||
| 	color: #0078AE; | ||||
| 	font-weight: bold; | ||||
| 	border: solid 0px; | ||||
| } | ||||
|  | ||||
| #logdialog input { | ||||
| 	width: 210px; | ||||
| 	border: solid 1px #0078AE; | ||||
| 	font-size: 12px; | ||||
| 	padding-bottom: 5px; | ||||
| } | ||||
|  | ||||
| #logdialog p { | ||||
| 	font-size: 18px; | ||||
| } | ||||
|  | ||||
| #logdialog button { | ||||
| 	font-weight: bold; | ||||
| 	width: 90px; | ||||
| 	float: right; | ||||
| } | ||||
|  | ||||
| #loginput { | ||||
| 	background-color: #f5f5f5; | ||||
| 	height: 300px; | ||||
| } | ||||
|  | ||||
| #loginfo { | ||||
| 	margin: 5px 0px; | ||||
| 	text-align: right; | ||||
| 	color: #f5f5f5; | ||||
| 	font-weight:bold; | ||||
| } | ||||
|  | ||||
| /*--- Header ---*/ | ||||
| #header { | ||||
| 	height: 40px; | ||||
| 	width: 1000px; | ||||
| 	margin: 0px auto; | ||||
| 	-moz-border-radius: .3em; | ||||
| 	-webkit-border-radius: .3em; | ||||
| 	border-radius: .3em; | ||||
| } | ||||
|  | ||||
| /* User name and log out */ | ||||
| #header div { | ||||
| 	float: right; | ||||
| } | ||||
|  | ||||
| #header div span { | ||||
| 	color: #424242; | ||||
| 	padding: 2px 15px 0px 2px; /* Top right left bottom*/ | ||||
| 	text-align: right; | ||||
| 	text-decoration: none; | ||||
| 	display: block; | ||||
| } | ||||
|  | ||||
| #header div a { | ||||
| 	padding: 3px 15px 0px 3px; /* Top right left bottom*/ | ||||
| 	text-align: right; | ||||
| 	color: blue; | ||||
| 	font-weight: normal; | ||||
| 	text-decoration: none; | ||||
| 	display: block; | ||||
| 	cursor: pointer; | ||||
| } | ||||
|  | ||||
| #header div a:hover { | ||||
| 	color: red; | ||||
| } | ||||
|  | ||||
| #layoutselector { | ||||
| 	padding: 2px 10px 0px 2px; /* Top right left bottom*/ | ||||
| 	text-align: right; | ||||
| 	color: #FFC125; | ||||
| 	text-decoration: none; | ||||
| 	display: block; | ||||
| } | ||||
|  | ||||
| /*--- Body and content ---*/ | ||||
| body { | ||||
| 	background-color: #1C1C1C; | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| } | ||||
|  | ||||
| .content { | ||||
| 	-moz-border-radius: .3em; | ||||
| 	-webkit-border-radius: .3em; | ||||
| 	border-radius: .3em; | ||||
| 	width: 1000px; | ||||
| 	min-height: 600px; | ||||
| 	margin: 10px auto; | ||||
| 	background-color: white; | ||||
| 	overflow: auto; | ||||
| } | ||||
|  | ||||
| #content ul.ui-widget-header { | ||||
| 	border-color: #4297D7 #4297D7 #7BB642; | ||||
| 	border-width: 1px 1px 4px; | ||||
| } | ||||
|  | ||||
| .ui-state-highlight { | ||||
| 	vertical-align: top; | ||||
| 	word-wrap: break-word; | ||||
| } | ||||
|  | ||||
| /*--- jQuery tabs ---*/ | ||||
| .tab { | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| 	border-style: none; | ||||
| 	overflow: visible; | ||||
| } | ||||
|  | ||||
| .ui-icon-close { | ||||
| 	float: left; | ||||
| 	margin: 0.4em 0.2em 0 0; | ||||
| 	cursor: pointer; | ||||
| } | ||||
|  | ||||
| /*--- Inventory and user entry ---*/ | ||||
| table { | ||||
| 	border-width: 1px; | ||||
| 	border-spacing: 0px; | ||||
| 	border-style: solid; | ||||
| 	border-collapse: collapse; | ||||
| } | ||||
|  | ||||
| /*--- jQuery datatable ---*/ | ||||
| .dataTables_wrapper { | ||||
| 	overflow: auto; | ||||
| 	width: auto; | ||||
| 	margin: 10px auto; | ||||
| } | ||||
|  | ||||
| /*** Show X entries ***/ | ||||
| .dataTables_length { | ||||
| 	width: 40%; | ||||
| 	float: left; | ||||
| 	padding: 10px 20px; | ||||
| 	text-align: left; | ||||
| } | ||||
|  | ||||
| /*** Search ***/ | ||||
| .dataTables_filter { | ||||
| 	width: 40%; | ||||
| 	margin: 10px 0px; | ||||
| 	display: block; | ||||
| 	float: right; | ||||
| 	text-align: right; | ||||
| } | ||||
|  | ||||
| .tab input,select { | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| 	border: solid 1px; | ||||
| 	padding: 4px; | ||||
| } | ||||
|  | ||||
| .sorting,.sorting_asc,.sorting_desc { | ||||
| 	background: none; | ||||
| } | ||||
|  | ||||
| /*** Showing X to X of X entries ***/ | ||||
| .dataTables_info { | ||||
| 	padding: 10px 20px; | ||||
| 	width: 40%; | ||||
| 	float: left; | ||||
| } | ||||
|  | ||||
| /*** < > buttons ***/ | ||||
| .paginate_disabled_previous,.paginate_enabled_previous,.paginate_disabled_next,.paginate_enabled_next | ||||
| 	{ | ||||
| 	height: 19px; | ||||
| 	width: 19px; | ||||
| 	margin-left: 2px; | ||||
| 	float: left; | ||||
| } | ||||
|  | ||||
| /*** Table ***/ | ||||
| .datatable { | ||||
| 	width: 100%; | ||||
| 	border-width: 1px; | ||||
| 	border-spacing: 0px; | ||||
| 	border-style: solid; | ||||
| 	border-collapse: collapse; | ||||
| 	display: inline-table; | ||||
| } | ||||
|  | ||||
| /*** Row color (odd) ***/ | ||||
| .datatable tr.odd { | ||||
| 	background-color: white; | ||||
| } | ||||
|  | ||||
| .datatable tr.odd td.sorting_1 { | ||||
| 	background-color: white; | ||||
| } | ||||
|  | ||||
| /*** Row color (even) ***/ | ||||
| .datatable tr.even { | ||||
| 	background-color: white; | ||||
| } | ||||
|  | ||||
| .datatable tr.even td.sorting_1 { | ||||
| 	background-color: white; | ||||
| } | ||||
|  | ||||
| .datatable a { | ||||
| 	text-decoration: none; | ||||
| 	color: blue; | ||||
| 	cursor: pointer; | ||||
| } | ||||
|  | ||||
| .datatable a:hover { | ||||
| 	color: red; | ||||
| } | ||||
|  | ||||
| /*--- Superfish menu ---*/ | ||||
| .sf-menu { | ||||
| 	background : none repeat scroll 0 0 #2191C0; | ||||
| 	border :1px solid #f5f5f5; | ||||
| 	border-radius: 0.3em 0.3em 0.3em 0.3em; | ||||
| } | ||||
|  | ||||
| .sf-menu a { | ||||
| 	color: white; | ||||
| 	padding: 10px 25px; | ||||
| 	font-weight: bold; | ||||
| } | ||||
|  | ||||
| .sf-sub-indicator{ | ||||
| 	right:0; | ||||
| } | ||||
|  | ||||
| .sf-shadow ul { | ||||
| 	padding: 0px; | ||||
| } | ||||
|  | ||||
| .sf-menu li:hover, .sf-menu li.sfHover { | ||||
| 	background: #79C9EC; | ||||
| } | ||||
|  | ||||
| /*--- Generic tags ---*/ | ||||
| p { | ||||
| 	word-wrap: break-word; | ||||
| } | ||||
|  | ||||
| a { | ||||
| 	cursor: pointer; | ||||
| 	color: blue; | ||||
| } | ||||
|  | ||||
| th { | ||||
| 	font: bold 12px verdana, arial, helvetica, sans-serif; | ||||
| 	border-width: 1px; | ||||
| 	padding: 8px 0px; | ||||
| 	min-width: 50px; | ||||
| 	border-style: solid; | ||||
| 	vertical-align: middle; | ||||
| 	text-align: center; | ||||
| } | ||||
|  | ||||
| td { | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| 	color: #424242; | ||||
| 	padding: 8px 0px; | ||||
| 	border-width: 1px; | ||||
| 	border-style: solid; | ||||
| 	vertical-align: middle; | ||||
| 	text-align: center; | ||||
| } | ||||
|  | ||||
| fieldset { | ||||
| 	margin-bottom: 5px; | ||||
| 	border-width: 1px 0 0 0; | ||||
| 	border-style: solid none none none; | ||||
| } | ||||
|  | ||||
| label { | ||||
| 	color: #424242; | ||||
| 	display: inline-block; | ||||
| 	line-height: 1.5; | ||||
| 	vertical-align: top; | ||||
| 	width: 140px; | ||||
| } | ||||
|  | ||||
| legend { | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| 	color: #424242; | ||||
| 	font-weight: bold; | ||||
| 	padding: 10px 15px; | ||||
| } | ||||
|  | ||||
| ol { | ||||
| 	margin: 0; | ||||
| 	padding: 0; | ||||
| } | ||||
|  | ||||
| li { | ||||
| 	list-style: none; | ||||
| 	padding: 5px 5px 5px 20px; | ||||
| 	margin: 0; | ||||
| } | ||||
|  | ||||
| input,textarea,select { | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| 	border: solid 1px; | ||||
| 	padding: 5px; | ||||
| 	display: inline-table; | ||||
| } | ||||
|  | ||||
| table a { | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| 	text-decoration: none; | ||||
| 	color: blue; | ||||
| 	cursor: pointer; | ||||
| } | ||||
|  | ||||
| table a:hover { | ||||
| 	color: red; | ||||
| } | ||||
| @@ -31,43 +31,50 @@ | ||||
| 	margin: 0px; | ||||
| } | ||||
|  | ||||
| /*--------------- login dialog ---------*/ | ||||
| /*--- Login dialog ---*/ | ||||
| #logdialog { | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| 	width: 600px; | ||||
| } | ||||
|  | ||||
| #logdialog td{ | ||||
| 	width: 110px; | ||||
| 	height: 30px; | ||||
| #logdialog table { | ||||
| 	border: solid 0px; | ||||
| 	margin: 0px auto; | ||||
| } | ||||
|  | ||||
| #logdialog td { | ||||
| 	width: 100px; | ||||
| 	height: 35px; | ||||
| 	color: #0078AE; | ||||
| 	font-size: 14px; | ||||
| 	font-weight: bold; | ||||
| 	border-width: 0px; | ||||
| 	border: solid 0px; | ||||
| } | ||||
|  | ||||
| #logdialog input{ | ||||
| 	width: 219px; | ||||
| #logdialog input { | ||||
| 	width: 210px; | ||||
| 	border: solid 1px #0078AE; | ||||
| 	font-size: 14px; | ||||
| 	font-size: 12px; | ||||
| 	padding-bottom: 5px; | ||||
| } | ||||
|  | ||||
| #logdialog p{ | ||||
| 	 | ||||
| #logdialog p { | ||||
| 	font-size: 18px; | ||||
| } | ||||
|  | ||||
| #logdialog button{ | ||||
| #logdialog button { | ||||
| 	font-weight: bold; | ||||
| 	width: 90px; | ||||
| 	float: right; | ||||
| } | ||||
|  | ||||
| #loginput { | ||||
| 	background-color: #f5f5f5; | ||||
| 	height: 260px; | ||||
| 	height: 280px; | ||||
| } | ||||
|  | ||||
| #loginfo{ | ||||
| 	text-align:right; | ||||
| #loginfo { | ||||
| 	margin: 5px 0px; | ||||
| 	text-align: right; | ||||
| 	color: #f5f5f5; | ||||
| 	font-weight:bold; | ||||
| } | ||||
| @@ -77,7 +84,7 @@ | ||||
| 	height: 39px; | ||||
| 	width: 1000px; | ||||
| 	margin: 0px auto; | ||||
| 	background: url(../images/header-gloss-wave.png) 50% 50% repeat-x; | ||||
| 	background: url(../images/jquery/default/ui-bg_highlight-soft_75_2191c0_1x100.png) 50% 50% repeat-x; | ||||
| 	-moz-border-radius: .5em; | ||||
| 	-webkit-border-radius: .5em; | ||||
| 	border-radius: .5em; | ||||
| @@ -149,7 +156,7 @@ | ||||
|  | ||||
| /*--------------- Body and content ---------------*/ | ||||
| body { | ||||
| 	background-color: #1C1C1C; | ||||
| 	background: #1C1C1C; | ||||
| 	font: 12px verdana, arial, helvetica, sans-serif; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -122,7 +122,7 @@ hmcPlugin.prototype.loadProvisionPage = function(tabId) { | ||||
|     var provForm = $('<div class="form"></div>'); | ||||
|  | ||||
|     // Create info bar | ||||
|     var infoBar = createInfoBar('Provision a node on system P server.'); | ||||
|     var infoBar = createInfoBar('Provision a node on System p.'); | ||||
|     provForm.append(infoBar); | ||||
|  | ||||
|     // Append to provision tab | ||||
| @@ -369,7 +369,7 @@ function addHmcNode(){ | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Add system p node, contains frame, cec, lpar  | ||||
|  * Add System p node, contains frame, cec, lpar  | ||||
|  *  | ||||
|  * @return Nothing | ||||
|  */ | ||||
|   | ||||
							
								
								
									
										2350
									
								
								xCAT-UI/js/service/service.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2350
									
								
								xCAT-UI/js/service/service.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										321
									
								
								xCAT-UI/js/service/utils.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										321
									
								
								xCAT-UI/js/service/utils.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,321 @@ | ||||
| /** | ||||
|  * Get nodes currently shown in datatable | ||||
|  *  | ||||
|  * @param tableId | ||||
|  *            Datatable ID | ||||
|  * @return String of nodes shown | ||||
|  */ | ||||
| function getNodesShown(tableId) { | ||||
| 	// String of nodes shown | ||||
| 	var shownNodes = ''; | ||||
| 	 | ||||
| 	// Get rows of shown nodes | ||||
| 	var nodes = $('#' + tableId + ' tbody tr'); | ||||
| 				 | ||||
| 	// Go through each row | ||||
| 	var cols; | ||||
| 	for (var i = 0; i < nodes.length; i++) { | ||||
| 		// Get second column containing node name | ||||
| 		cols = nodes.eq(i).find('td'); | ||||
| 		shownNodes += cols.eq(1).text() + ','; | ||||
| 	} | ||||
| 	 | ||||
| 	// Remove last comma | ||||
| 	shownNodes = shownNodes.substring(0, shownNodes.length-1); | ||||
| 	return shownNodes; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Find the row index containing a column with a given string | ||||
|  *  | ||||
|  * @param str | ||||
|  *            String to search for | ||||
|  * @param table | ||||
|  *            Table to check | ||||
|  * @param col | ||||
|  *            Column to find string under | ||||
|  * @return The row index containing the search string | ||||
|  */ | ||||
| function findRow(str, table, col){ | ||||
| 	var dTable, rows; | ||||
| 	 | ||||
| 	// Get datatable | ||||
| 	dTable = $(table).dataTable(); | ||||
| 	rows = dTable.fnGetData(); | ||||
| 	 | ||||
| 	// Loop through each row | ||||
| 	for (var i in rows) { | ||||
| 		// If the column contains the search string | ||||
| 		if (rows[i][col].indexOf(str) > -1) { | ||||
| 			return i; | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	return -1; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Select all checkboxes in the datatable | ||||
|  *  | ||||
|  * @param event | ||||
|  *            Event on element | ||||
|  * @param obj | ||||
|  *            Object triggering event | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function selectAll(event, obj) { | ||||
| 	var status = obj.attr('checked'); | ||||
| 	var checkboxes = obj.parents('.dataTables_scroll').find('.dataTables_scrollBody input:checkbox'); | ||||
| 	if (status) { | ||||
| 		checkboxes.attr('checked', true); | ||||
| 	} else { | ||||
| 		checkboxes.attr('checked', false); | ||||
| 	} | ||||
| 	 | ||||
| 	event.stopPropagation(); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get node attributes from HTTP request data | ||||
|  *  | ||||
|  * @param propNames | ||||
|  *            Hash table of property names | ||||
|  * @param keys | ||||
|  *            Property keys | ||||
|  * @param data | ||||
|  *            Data from HTTP request | ||||
|  * @return Hash table of property values | ||||
|  */ | ||||
| function getAttrs(keys, propNames, data) { | ||||
| 	// Create hash table for property values | ||||
| 	var attrs = new Object(); | ||||
|  | ||||
| 	// Go through inventory and separate each property out | ||||
| 	var curKey; // Current property key | ||||
| 	var addLine; // Add a line to the current property? | ||||
| 	for ( var i = 1; i < data.length; i++) { | ||||
| 		addLine = true; | ||||
|  | ||||
| 		// Loop through property keys | ||||
| 		// Does this line contains one of the properties? | ||||
| 		for ( var j = 0; j < keys.length; j++) { | ||||
| 			// Find property name | ||||
| 			if (data[i].indexOf(propNames[keys[j]]) > -1) { | ||||
| 				attrs[keys[j]] = new Array(); | ||||
|  | ||||
| 				// Get rid of property name in the line | ||||
| 				data[i] = data[i].replace(propNames[keys[j]], ''); | ||||
| 				// Trim the line | ||||
| 				data[i] = jQuery.trim(data[i]); | ||||
|  | ||||
| 				// Do not insert empty line | ||||
| 				if (data[i].length > 0) { | ||||
| 					attrs[keys[j]].push(data[i]); | ||||
| 				} | ||||
|  | ||||
| 				curKey = keys[j]; | ||||
| 				addLine = false; // This line belongs to a property | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// Line does not contain a property | ||||
| 		// Must belong to previous property | ||||
| 		if (addLine && data[i].length > 1) { | ||||
| 			data[i] = jQuery.trim(data[i]); | ||||
| 			attrs[curKey].push(data[i]); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return attrs; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Create a tool tip for comments | ||||
|  *  | ||||
|  * @param comment | ||||
|  *            Comments to be placed in a tool tip | ||||
|  * @return Tool tip | ||||
|  */ | ||||
| function createCommentsToolTip(comment) { | ||||
| 	// Create tooltip container | ||||
| 	var toolTip = $('<div class="tooltip"></div>'); | ||||
| 	// Create textarea to hold comment | ||||
| 	var txtArea = $('<textarea>' + comment + '</textarea>').css({ | ||||
| 		'font-size': '10px', | ||||
| 		'height': '50px', | ||||
| 		'width': '200px', | ||||
| 		'background-color': '#000', | ||||
| 		'color': '#fff', | ||||
| 		'border': '0px', | ||||
| 		'display': 'block' | ||||
| 	}); | ||||
| 	 | ||||
| 	// Create links to save and cancel changes | ||||
| 	var lnkStyle = { | ||||
| 		'color': '#58ACFA', | ||||
| 		'font-size': '10px', | ||||
| 		'display': 'inline-block', | ||||
| 		'padding': '5px', | ||||
| 		'float': 'right' | ||||
| 	}; | ||||
| 	 | ||||
| 	var saveLnk = $('<a>Save</a>').css(lnkStyle).hide(); | ||||
| 	var cancelLnk = $('<a>Cancel</a>').css(lnkStyle).hide(); | ||||
| 	var infoSpan = $('<span>Click to edit</span>').css(lnkStyle); | ||||
| 	 | ||||
| 	// Save changes onclick | ||||
| 	saveLnk.bind('click', function(){ | ||||
| 		// Get node and comment | ||||
| 		var node = $(this).parent().parent().find('img').attr('id').replace('Tip', ''); | ||||
| 		var comments = $(this).parent().find('textarea').val(); | ||||
| 		 | ||||
| 		// Save comment | ||||
| 		$.ajax( { | ||||
|     		url : 'lib/srv_cmd.php', | ||||
|     		dataType : 'json', | ||||
|     		data : { | ||||
|     			cmd : 'chdef', | ||||
|     			tgt : '', | ||||
|     			args : '-t;node;-o;' + node + ';usercomment=' + comments, | ||||
|     			msg : 'out=manageTab;tgt=' + node | ||||
|     		}, | ||||
|     		 | ||||
|     		success: showChdefOutput | ||||
| 		}); | ||||
| 		 | ||||
| 		// Hide cancel and save links | ||||
| 		$(this).hide(); | ||||
| 		cancelLnk.hide(); | ||||
| 	}); | ||||
| 		 | ||||
| 	// Cancel changes onclick | ||||
| 	cancelLnk.bind('click', function(){ | ||||
| 		// Get original comment and put it back | ||||
| 		var orignComments = $(this).parent().find('textarea').text(); | ||||
| 		$(this).parent().find('textarea').val(orignComments); | ||||
| 		 | ||||
| 		// Hide cancel and save links | ||||
| 		$(this).hide(); | ||||
| 		saveLnk.hide(); | ||||
| 		infoSpan.show(); | ||||
| 	}); | ||||
| 	 | ||||
| 	// Show save link when comment is edited | ||||
| 	txtArea.bind('click', function(){ | ||||
| 		saveLnk.show(); | ||||
| 		cancelLnk.show(); | ||||
| 		infoSpan.hide(); | ||||
| 	}); | ||||
| 		 | ||||
| 	toolTip.append(txtArea); | ||||
| 	toolTip.append(cancelLnk); | ||||
| 	toolTip.append(saveLnk); | ||||
| 	toolTip.append(infoSpan); | ||||
| 	 | ||||
| 	return toolTip; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Open a dialog and show given message | ||||
|  *  | ||||
|  * @param type | ||||
|  * 			Type of dialog, i.e. warn or info | ||||
|  * @param msg | ||||
|  * 			Message to show | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function prompt(type, msg) { | ||||
| 	var style = { | ||||
| 		'display': 'inline-block', | ||||
| 		'margin': '5px', | ||||
| 		'vertical-align': 'middle' | ||||
| 	}; | ||||
| 	msg.css({ | ||||
| 		'display': 'inline', | ||||
| 		'margin': '5px', | ||||
| 		'vertical-align': 'middle' | ||||
| 	}); | ||||
| 	 | ||||
| 	// Append icon | ||||
| 	var icon; | ||||
| 	var dialog = $('<div></div>'); | ||||
| 	if (type == "Warning") { | ||||
| 		icon = $('<span class="ui-icon ui-icon-alert"></span>').css(style); | ||||
| 	} else { | ||||
| 		icon = $('<span class="ui-icon ui-icon-info"></span>').css(style); | ||||
| 	} | ||||
| 	 | ||||
| 	dialog.append(icon); | ||||
| 	dialog.append(msg); | ||||
| 		 | ||||
| 	// Open dialog | ||||
| 	dialog.dialog({ | ||||
| 		title: type, | ||||
| 		modal: true, | ||||
| 		width: 400, | ||||
| 		buttons: { | ||||
| 			"Ok": function(){  | ||||
| 				$(this).dialog("close"); | ||||
| 			} | ||||
| 		} | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get nodes that are checked in a given datatable | ||||
|  *  | ||||
|  * @param dTableId | ||||
|  *            The datatable ID | ||||
|  * @return Nodes that were checked | ||||
|  */ | ||||
| function getNodesChecked(dTableId) { | ||||
| 	var tgts = ''; | ||||
|  | ||||
| 	// Get nodes that were checked | ||||
| 	var nodes = $('#' + dTableId + ' input[type=checkbox]:checked'); | ||||
| 	for (var i in nodes) { | ||||
| 		var tgtNode = nodes.eq(i).attr('name'); | ||||
| 		 | ||||
| 		if (tgtNode){ | ||||
| 			tgts += tgtNode; | ||||
| 			 | ||||
| 			// Add a comma at the end | ||||
| 			if (i < nodes.length - 1) { | ||||
| 				tgts += ','; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return tgts; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Show chdef output | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data returned from HTTP request | ||||
|  * @return Nothing | ||||
|  */ | ||||
| function showChdefOutput(data) { | ||||
| 	// Get output | ||||
| 	var out = data.rsp; | ||||
| 	var args = data.msg.split(';'); | ||||
| 	var tabID = args[0].replace('out=', ''); | ||||
| 	var tgt = args[1].replace('tgt=', ''); | ||||
| 	 | ||||
| 	// Find info bar on nodes tab, if any | ||||
| 	var info = $('#' + tabID).find('.ui-state-highlight'); | ||||
| 	if (!info.length) { | ||||
| 		// Create info bar if one does not exist | ||||
| 		info = createInfoBar(''); | ||||
| 		$('#' + tabID).append(info); | ||||
| 	} | ||||
| 		 | ||||
| 	// Go through output and append to paragraph | ||||
| 	var prg = $('<p></p>'); | ||||
| 	for (var i in out) { | ||||
| 		prg.append(tgt + ': ' + out[i] + '<br>'); | ||||
| 	} | ||||
| 	 | ||||
| 	info.append(prg); | ||||
| } | ||||
							
								
								
									
										90
									
								
								xCAT-UI/js/srv_xcatauth.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								xCAT-UI/js/srv_xcatauth.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,90 @@ | ||||
| /** | ||||
|  * Open login dialog | ||||
|  */ | ||||
| $(document).ready(function() { | ||||
|     $('#header').remove(); | ||||
|     $('#content').remove(); | ||||
|      | ||||
|     var winHeight = document.body.clientHeight; | ||||
|     var diagHeight = $('#logdialog').css('height'); | ||||
|     diagHeight = diagHeight.substr(0, diagHeight.length - 2); | ||||
|     diagHeight = Number(diagHeight); | ||||
|      | ||||
|     // The window's height is to small to show the dialog | ||||
|     var tmpHeight = 0; | ||||
|     if ((winHeight - 50) < diagHeight){ | ||||
|     	tmpHeight = 0; | ||||
|     } else { | ||||
|     	tmpHeight = parseInt((winHeight - diagHeight - 50) / 2);  | ||||
|     } | ||||
|      | ||||
|     $('#logdialog').css('margin', tmpHeight + 'px auto'); | ||||
|     $('button').bind('click', function(){ | ||||
|     	authenticate(); | ||||
|     }).button(); | ||||
|      | ||||
| 	if (document.location.protocol == 'http:') { | ||||
| 		$('#logstatus').html('You are using an unencrypted session!'); | ||||
| 		$('#logstatus').css('color', 'red'); | ||||
| 	} | ||||
| 	 | ||||
| 	if (!$('#username').val()) { | ||||
| 		$('#username').focus(); | ||||
| 	} else { | ||||
| 		$('#password').focus(); | ||||
| 	} | ||||
|  | ||||
| 	// When enter is hit while in username, advance to password | ||||
| 	$('#username').keydown(function(event) { | ||||
| 		if (event.keyCode == 13) { | ||||
| 			$('#password').focus(); | ||||
| 		} | ||||
| 	}); | ||||
|  | ||||
| 	// Submit authentication if enter is pressed in password field | ||||
| 	$('#password').keydown(function(event) { | ||||
| 		if (event.keyCode == 13) { | ||||
| 			authenticate(); | ||||
| 		} | ||||
| 	}); | ||||
| }); | ||||
|  | ||||
| /** | ||||
|  * Update login dialog | ||||
|  *  | ||||
|  * @param data | ||||
|  *            Data returned from AJAX call | ||||
|  * @param txtStatus | ||||
|  *            Status of login | ||||
|  */ | ||||
| function onlogin(data, txtStatus) { | ||||
| 	// Clear password field regardless of what happens | ||||
| 	var usrName = $('#username').val(); | ||||
| 	$('#password').val(''); | ||||
| 	if (data.authenticated == 'yes') { | ||||
| 		$('#logstatus').text('Login successful'); | ||||
| 		window.location = 'service.php'; | ||||
| 		 | ||||
| 		// Set user name cookie		 | ||||
| 		var exDate = new Date(); | ||||
| 		exDate.setTime(exDate.getTime() + (240 * 60 * 1000)); | ||||
| 		$.cookie('srv_usrname', usrName, { expires: exDate }); | ||||
| 	} else { | ||||
| 		$('#logstatus').text('Authentication failure'); | ||||
| 		$('#logstatus').css('color', '#FF0000'); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Authenticate user for new session | ||||
|  */ | ||||
| function authenticate() { | ||||
| 	$('#logstatus').css('color', '#000000'); | ||||
| 	$('#logstatus').html('Authenticating...'); | ||||
| 	 | ||||
| 	var passwd = $('#password').val(); | ||||
| 	$.post('lib/srv_log.php', { | ||||
| 		username : $('#username').val(), | ||||
| 		password : passwd | ||||
| 	}, onlogin, 'json'); | ||||
| } | ||||
							
								
								
									
										192
									
								
								xCAT-UI/lib/srv_cmd.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										192
									
								
								xCAT-UI/lib/srv_cmd.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,192 @@ | ||||
| <?php | ||||
| /* Required libraries */ | ||||
| $TOPDIR = '..'; | ||||
| require_once "$TOPDIR/lib/srv_functions.php"; | ||||
| require_once "$TOPDIR/lib/jsonwrapper.php"; | ||||
|  | ||||
| /** | ||||
|  * Issue a xCAT command, e.g. rinv gpok123 all | ||||
|  * This will handle most commands.  If not, you can create your | ||||
|  * own .php.  Look at zCmd.php for an example. | ||||
|  * | ||||
|  * @param 	$cmd	The xCAT command | ||||
|  * @param	$tgt	The target node or group | ||||
|  * @param 	$args	The xCAT command arguments, separated by semicolons | ||||
|  * @param	$opts	The xCAT command options, separated by semicolons | ||||
|  * @return 	The xCAT response.  Replies are in the form of JSON | ||||
|  */ | ||||
| if (isset($_GET["cmd"])) { | ||||
| 	// HTTP GET requests | ||||
| 	$cmd = $_GET["cmd"]; | ||||
| 	$tgt = $_GET["tgt"]; | ||||
| 	$args = $_GET["args"]; | ||||
| 	 | ||||
| 	// Special messages put here | ||||
| 	// This gets sent back to the AJAX request as is. | ||||
| 	$msg = $_GET["msg"]; | ||||
|  | ||||
| 	// If no $tgt is given, set $tgt to NULL | ||||
| 	if (!$tgt) { | ||||
| 		$tgt = NULL; | ||||
| 	} | ||||
| 	 | ||||
| 	// If no $msg is given, set $msg to NULL | ||||
| 	if (!$msg) { | ||||
| 		$msg = NULL; | ||||
| 	} | ||||
|  | ||||
| 	// If no $args are given, set $args_array to NULL | ||||
| 	$args_array = array(); | ||||
| 	if ($args) { | ||||
| 		// If $args contains multiple arguments, split it into an array | ||||
| 		if (strpos($args,";")) { | ||||
| 			// Split the arguments into an array | ||||
| 			$args_array = array(); | ||||
| 			$args_array = explode(";", $args); | ||||
| 		} else { | ||||
| 			$args_array = array($args); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	// If no $opts are given, set $opts_array to NULL | ||||
| 	$opts_array = array(); | ||||
| 	if (isset($_GET["opts"])) { | ||||
| 		$opts = $_GET["opts"]; | ||||
| 		 | ||||
| 		// If $args contains multiple arguments, split it into an array | ||||
| 		if (strpos($opts,";")) { | ||||
| 			// Split the arguments into an array | ||||
| 			$opts_array = array(); | ||||
| 			$opts_array = explode(";", $opts); | ||||
| 		} else { | ||||
| 			$opts_array = array($opts); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Submit request and get response | ||||
| 	$xml = docmd($cmd, $tgt, $args_array, $opts_array); | ||||
| 	// If the output is flushed, do not return output in JSON | ||||
| 	if (in_array("flush", $opts_array)) { | ||||
| 		return; | ||||
| 	} | ||||
| 	 | ||||
| 	$rsp = array(); | ||||
|  | ||||
| 	// webrun pping and gangliastatus output needs special handling | ||||
| 	if(strncasecmp($cmd, "webrun", 6) == 0 && (stristr($args, "pping") || stristr($args, "gangliastatus") || stristr($args, "chtab"))) { | ||||
| 		$rsp = extractWebrun($xml); | ||||
| 	} | ||||
| 	// nodels output needs special handling | ||||
| 	else if(strncasecmp($cmd, "nodels", 6) == 0) { | ||||
| 		// Handle the output the same way as webrun | ||||
| 		$rsp = extractNodels($xml); | ||||
| 	} | ||||
| 	// extnoderange output needs special handling | ||||
| 	// This command gets the nodes and groups | ||||
| 	else if(strncasecmp($cmd, "extnoderange", 12) == 0) { | ||||
| 		$rsp = extractExtnoderange($xml); | ||||
| 	} | ||||
| 	// Handle the typical output | ||||
| 	else { | ||||
| 		foreach ($xml->children() as $child) { | ||||
| 			foreach ($child->children() as $data) { | ||||
| 				if($data->name) { | ||||
| 					$node = $data->name; | ||||
| 					 | ||||
| 					if($data->data->contents){ | ||||
| 						$cont = $data->data->contents; | ||||
| 					} | ||||
| 					else{ | ||||
| 						$cont = $data->data; | ||||
| 					} | ||||
| 					 | ||||
| 					$cont = str_replace(":|:", "\n", $cont); | ||||
| 					array_push($rsp, "$node: $cont"); | ||||
| 				} else if(strlen("$data") > 2) { | ||||
| 					$data = str_replace(":|:", "\n", $data); | ||||
| 					array_push($rsp, "$data"); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Reply in the form of JSON | ||||
| 	$rtn = array("rsp" => $rsp, "msg" => $msg); | ||||
| 	echo json_encode($rtn); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Extract the output for a webrun command | ||||
|  * | ||||
|  * @param	$xml 	The XML output from docmd() | ||||
|  * @return 	An array containing the output | ||||
|  */ | ||||
| function extractWebrun($xml) { | ||||
| 	$rsp = array(); | ||||
| 	$i = 0; | ||||
|  | ||||
| 	// Extract data returned | ||||
| 	foreach($xml->children() as $nodes){ | ||||
| 		foreach($nodes->children() as $node){ | ||||
| 			// Get the node name | ||||
| 			$name = $node->name; | ||||
| 			 | ||||
| 			// Get the content | ||||
| 			$status = $node->data; | ||||
| 			$status = str_replace(":|:", "\n", $status); | ||||
|  | ||||
| 			// Add to return array | ||||
| 			$rsp[$i] = array("$name", "$status"); | ||||
| 			$i++; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return $rsp; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Extract the output for a nodels command | ||||
|  * | ||||
|  * @param	$xml 	The XML output from docmd() | ||||
|  * @return 	An array containing the output | ||||
|  */ | ||||
| function extractNodels($xml) { | ||||
| 	$rsp = array(); | ||||
| 	$i = 0; | ||||
|  | ||||
| 	// Extract data returned | ||||
| 	foreach($xml->children() as $nodes){ | ||||
| 		foreach($nodes->children() as $node){ | ||||
| 			// Get the node name | ||||
| 			$name = $node->name; | ||||
| 			// Get the content | ||||
| 			$status = $node->data->contents; | ||||
| 			$status = str_replace(":|:", "\n", $status); | ||||
|  | ||||
| 			$description = $node->data->desc; | ||||
| 			// Add to return array | ||||
| 			$rsp[$i] = array("$name", "$status", "$description"); | ||||
| 			$i++; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return $rsp; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Extract the output for a extnoderange command | ||||
|  * | ||||
|  * @param 	$xml 	The XML output from docmd() | ||||
|  * @return 	The nodes and groups | ||||
|  */ | ||||
| function extractExtnoderange($xml) { | ||||
| 	$rsp = array(); | ||||
|  | ||||
| 	// Extract data returned | ||||
| 	foreach ($xml->xcatresponse->intersectinggroups as $group) { | ||||
| 		array_push($rsp, "$group"); | ||||
| 	} | ||||
|  | ||||
| 	return $rsp; | ||||
| } | ||||
| ?> | ||||
							
								
								
									
										324
									
								
								xCAT-UI/lib/srv_functions.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										324
									
								
								xCAT-UI/lib/srv_functions.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,324 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Contains all common PHP functions needed by most pages | ||||
|  */ | ||||
|  | ||||
| // Retain session variables across page requests | ||||
| session_start(); | ||||
|  | ||||
| // The settings below display error on the screen, | ||||
| // instead of giving blank pages. | ||||
| error_reporting(E_ALL); | ||||
| ini_set('display_errors', true); | ||||
|  | ||||
| /** | ||||
|  * Run a command using the xCAT client/server protocol | ||||
|  * | ||||
|  * @param 	$cmd			The xCAT command | ||||
|  * @param	$nr				Node range or group | ||||
|  * @param	$args_array		Command arguments | ||||
|  * @param	$opts_array		Command options | ||||
|  * @return 	A tree of SimpleXML objects. | ||||
|  * 			See perl-xCAT/xCAT/Client.pm for the format | ||||
|  */ | ||||
| function docmd($cmd, $nr, $args_array, $opts_array){ | ||||
| 	// If we are not logged in, | ||||
| 	// do not try to communicate with xcatd | ||||
| 	if (!is_logged()) { | ||||
| 		echo "<p>You are not logged in! Failed to run command.</p>"; | ||||
| 		return simplexml_load_string('<xcat></xcat>', 'SimpleXMLElement', LIBXML_NOCDATA); | ||||
| 	} | ||||
|  | ||||
| 	// Create xCAT request | ||||
| 	// Add command, node range, and arguments to request | ||||
| 	$request = simplexml_load_string('<xcatrequest></xcatrequest>'); | ||||
| 	$request->addChild('command', $cmd); | ||||
| 	if(!empty($nr)) { $request->addChild('noderange', $nr); } | ||||
| 	if (!empty($args_array)) { | ||||
| 		foreach ($args_array as $a) { | ||||
| 			$request->addChild('arg',$a); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Add user and password to request | ||||
| 	$usernode=$request->addChild('becomeuser'); | ||||
| 	$usernode->addChild('username',$_SESSION["srv_username"]); | ||||
| 	$usernode->addChild('password',getpassword()); | ||||
|  | ||||
| 	$xml = submit_request($request, 0, $opts_array); | ||||
| 	return $xml; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Used by docmd() to submit request to xCAT | ||||
|  * | ||||
|  * @param 	$req			Tree of SimpleXML objects | ||||
|  * @param 	$opts_array		Request options | ||||
|  * @return 	A tree of SimpleXML objects | ||||
|  */ | ||||
| function submit_request($req, $skipVerify, $opts_array){ | ||||
| 	$xcathost = "localhost"; | ||||
| 	$port = "3001"; | ||||
| 	$rsp = FALSE; | ||||
| 	$response = ''; | ||||
| 	$cleanexit = 0; | ||||
| 	 | ||||
| 	// Determine whether to flush output or not | ||||
| 	$flush = false; | ||||
| 	if ($opts_array && in_array("flush", $opts_array)) { | ||||
| 		$flush = true; | ||||
| 	} | ||||
| 	 | ||||
| 	// Determine how to handle the flush output | ||||
| 	// You can specify a function name, in place of TBD, to handle the flush output | ||||
| 	$flush_format = ""; | ||||
| 	if ($opts_array && in_array("flush-format=TBD", $opts_array)) { | ||||
| 		$flush_format = "TBD"; | ||||
| 	} | ||||
| 	 | ||||
| 	// Open syslog, include the process ID and also send | ||||
| 	// the log to standard error, and use a user defined | ||||
| 	// logging mechanism | ||||
| 	openlog("xCAT-UI", LOG_PID | LOG_PERROR, LOG_LOCAL0); | ||||
|  | ||||
| 	// Open a socket to xcatd | ||||
| 	syslog(LOG_INFO, "Opening socket to xcatd..."); | ||||
| 	if($fp = stream_socket_client('ssl://'.$xcathost.':'.$port, $errno, $errstr, 30, STREAM_CLIENT_CONNECT)){ | ||||
| 		$reqXML = $req->asXML(); | ||||
| 		$nr = $req->noderange; | ||||
| 		$cmd = $req->command; | ||||
| 		 | ||||
| 		syslog(LOG_INFO, "Sending request: $cmd $nr"); | ||||
| 		stream_set_blocking($fp, 0);	// Set as non-blocking | ||||
| 		fwrite($fp,$req->asXML());		// Send XML to xcatd | ||||
| 		set_time_limit(900);			// Set 15 minutes timeout (for long running requests)  | ||||
| 										// The default is 30 seconds which is too short for some requests | ||||
| 		 | ||||
| 		// Turn on output buffering | ||||
| 		ob_start(); | ||||
| 		while(!feof($fp)) {				// Read until there is no more	 | ||||
| 			// Remove newlines and add it to the response | ||||
| 			$str = fread($fp, 8192); | ||||
| 			if ($str) { | ||||
| 				$response .= preg_replace('/>\n\s*</', '><', $str); | ||||
| 				 | ||||
| 				// Flush output to browser | ||||
| 				if ($flush) { | ||||
| 					// Strip HTML tags from output | ||||
| 					if ($tmp = trim(strip_tags($str))) { | ||||
| 						// Format the output based on what was given for $flush_format | ||||
| 						if ($flush_format == "TDB") { | ||||
| 							format_TBD($tmp); | ||||
| 						} else { | ||||
| 							// Print out output by default | ||||
| 							echo '<pre>' . $tmp . '</pre>'; | ||||
| 							ob_flush(); | ||||
| 							flush(); | ||||
| 						} | ||||
| 					} | ||||
| 				}				 | ||||
| 			} | ||||
| 							 | ||||
| 			// Look for serverdone response | ||||
| 			$fullpattern = '/<xcatresponse>\s*<serverdone>\s*<\/serverdone>\s*<\/xcatresponse>/'; | ||||
| 			$mixedpattern = '/<serverdone>\s*<\/serverdone>.*<\/xcatresponse>/'; | ||||
| 			$recentpattern = '/<\/xcatresponse>/'; | ||||
| 			if(preg_match($recentpattern,$str) && preg_match($mixedpattern,$response)) { | ||||
| 				// Transaction is done, | ||||
| 				// Package up XML and return it | ||||
| 				// Remove the serverdone response and put an xcat tag around the rest | ||||
| 				$count = 0; | ||||
| 				$response = preg_replace($fullpattern,'', $response, -1, $count);		// 1st try to remove the long pattern | ||||
| 				if (!$count) { $response = preg_replace($mixedpattern,'', $response) . '</xcatresponse>/'; }		// if its not there, then remove the short pattern | ||||
| 				$response = "<xcat>$response</xcat>"; | ||||
| 				//delete the \n between '>' and '<' | ||||
| 				$response = preg_replace('/>\n\s*</', '><', $response); | ||||
| 				//replace the '\n' by ':|:' in the data area. | ||||
| 				$response = preg_replace('/\n/', ':|:', $response); | ||||
| 				$rsp = simplexml_load_string($response,'SimpleXMLElement', LIBXML_NOCDATA); | ||||
| 				$cleanexit = 1; | ||||
| 				break; | ||||
| 			} | ||||
| 		} // End of while(!feof($fp)) | ||||
| 		 | ||||
| 		syslog(LOG_INFO, "($cmd $nr) Sending response"); | ||||
| 		fclose($fp); | ||||
| 	} else { | ||||
| 		echo "<p>xCAT submit request socket error: $errno - $errstr</p>"; | ||||
| 	} | ||||
| 	 | ||||
| 	// Flush (send) the output buffer and turn off output buffering | ||||
| 	ob_end_flush(); | ||||
|  | ||||
| 	// Close syslog | ||||
| 	closelog(); | ||||
| 	 | ||||
| 	if(! $cleanexit) { | ||||
| 		if (preg_match('/^\s*<xcatresponse>.*<\/xcatresponse>\s*$/',$response)) { | ||||
| 			// Probably an error message | ||||
| 			$response = "<xcat>$response</xcat>"; | ||||
| 			$rsp = simplexml_load_string($response,'SimpleXMLElement', LIBXML_NOCDATA); | ||||
| 		} | ||||
| 		elseif(!$skipVerify) { | ||||
| 			echo "<p>(Error) xCAT response ended prematurely: ", htmlentities($response), "</p>"; | ||||
| 			$rsp = FALSE; | ||||
| 		} | ||||
| 	} | ||||
| 	return $rsp; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Enable password storage to split between cookie and session variable | ||||
|  * | ||||
|  * @param 	$data | ||||
|  * @param	$key | ||||
|  * @return | ||||
|  */ | ||||
| function xorcrypt($data, $key) { | ||||
| 	$datalen = strlen($data); | ||||
| 	$keylen = strlen($key); | ||||
| 	for ($i=0;$i<$datalen;$i++) { | ||||
| 		$data[$i] = chr(ord($data[$i])^ord($key[$i])); | ||||
| 	} | ||||
|  | ||||
| 	return $data; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get RAND characters | ||||
|  * | ||||
|  * @param 	$length		Length of characters | ||||
|  * @return 	RAND characters | ||||
|  */ | ||||
| function getrandchars($length) { | ||||
| 	$charset = '0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*'; | ||||
| 	$charsize = strlen($charset); | ||||
| 	srand(); | ||||
| 	$chars = ''; | ||||
| 	for ($i=0;$i<$length;$i++) { | ||||
| 		$num=rand()%$charsize; | ||||
| 		$chars=$chars.substr($charset,$num,1); | ||||
| 	} | ||||
|  | ||||
| 	return $chars; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Format a given string and echo it back to the browser | ||||
|  *  | ||||
|  * @param 	$str	String | ||||
|  * @return 	Nothing | ||||
|  */ | ||||
| function format_TBD($str) { | ||||
| 	// Format a given string however you want it  | ||||
| 	echo $tmp . '<br/>'; | ||||
| 	flush(); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get password | ||||
|  * | ||||
|  * @param 	Nothing | ||||
|  * @return | ||||
|  */ | ||||
| function getpassword() { | ||||
| 	if (isset($GLOBALS['xcatauthsecret'])) { | ||||
| 		$cryptext = $GLOBALS['xcatauthsecret']; | ||||
| 	} else if (isset($_COOKIE["xcatauthsecret"])) { | ||||
| 		$cryptext = $_COOKIE["xcatauthsecret"]; | ||||
| 	} else { | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	return xorcrypt($_SESSION["secretkey"], base64_decode($cryptext)); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get the password splitting knowledge between server | ||||
|  * and client side persistant storage.  Caller should regenerate | ||||
|  * session ID when contemplating a new user/password, to preclude | ||||
|  * session fixation, though fixation is limited without the secret. | ||||
|  * | ||||
|  * @param 	$password	Password | ||||
|  * @return 	Nothing | ||||
|  */ | ||||
| function setpassword($password) { | ||||
| 	$randlen = strlen($password); | ||||
| 	$key = getrandchars($randlen); | ||||
| 	$cryptext = xorcrypt($password,$key); | ||||
|  | ||||
| 	// Non-ascii characters, encode it in base64 | ||||
| 	$cryptext = base64_encode($cryptext); | ||||
| 	setcookie("xcatauthsecret",$cryptext,0,'/'); | ||||
| 	$GLOBALS["xcatauthsecret"] = $cryptext; | ||||
| 	$_SESSION["secretkey"] = $key; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Determine if a user/password session exists | ||||
|  * | ||||
|  * @param 	Nothing | ||||
|  * @return 	True 	If user has a session. | ||||
|  * 			False 	Otherwise | ||||
|  */ | ||||
| function is_logged() { | ||||
| 	if (isset($_SESSION["srv_username"]) and !is_bool(getpassword())) { | ||||
| 		return true; | ||||
| 	} else { | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Determine if a user is currently logged in successfully | ||||
|  *  | ||||
|  * @param 	Nothing | ||||
|  * @return 	True 	If the user is currently logged in successfully | ||||
|  * 			False 	Otherwise | ||||
|  */ | ||||
| function isAuthenticated() { | ||||
| 	if (is_logged()) { | ||||
| 		if ($_SESSION["srv_xcatpassvalid"] != 1) { | ||||
| 			$testcred = docmd("authcheck", "", NULL, NULL); | ||||
| 			if (isset($testcred->{'xcatresponse'}->{'data'})) { | ||||
| 				$result = "".$testcred->{'xcatresponse'}->{'data'}; | ||||
| 				if (is_numeric(strpos("Authenticated",$result))) { | ||||
| 					// Logged in successfully | ||||
| 					$_SESSION["srv_xcatpassvalid"] = 1; | ||||
| 				} else { | ||||
| 					// Not logged in | ||||
| 					$_SESSION["srv_xcatpassvalid"] = 0; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if (isset($_SESSION["srv_xcatpassvalid"]) and $_SESSION["srv_xcatpassvalid"]==1) { | ||||
| 		return true; | ||||
| 	} else { | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Log out of the current user session | ||||
|  *  | ||||
|  * @param 	Nothing | ||||
|  * @return 	Nothing | ||||
|  */ | ||||
| function logout() { | ||||
| 	// Clear the secret cookie from browser | ||||
| 	if (isset($_COOKIE["xcatauthsecret"])) { | ||||
| 		setcookie("xcatauthsecret",'',time()-86400*7,'/'); | ||||
| 	} | ||||
|  | ||||
| 	// Expire session cookie | ||||
| 	if (isset($_COOKIE[session_name()])) { | ||||
| 		setcookie(session_name(),"",time()-86400*7,"/"); | ||||
| 	} | ||||
|  | ||||
| 	// Clear server store of data | ||||
| 	$_SESSION=array(); | ||||
| 	session_destroy(); | ||||
| } | ||||
| ?> | ||||
							
								
								
									
										39
									
								
								xCAT-UI/lib/srv_log.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								xCAT-UI/lib/srv_log.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| <?php | ||||
| $TOPDIR = '..'; | ||||
| require_once "$TOPDIR/lib/srv_functions.php"; | ||||
| require_once "$TOPDIR/lib/jsonwrapper.php"; | ||||
|  | ||||
| header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); | ||||
| header("Cache-Control: no-store, no-cache, must-revalidate"); | ||||
| header("Cache-Control: post-check=0, pre-check=0", false); | ||||
| header("Pragma: no-cache"); | ||||
|  | ||||
| if (isset($_REQUEST["password"])) { | ||||
| 	// Clear data from session | ||||
| 	$_SESSION = array(); | ||||
|  | ||||
| 	// Zap existing session entirely | ||||
| 	session_regenerate_id(true); | ||||
| 	setpassword($_REQUEST["password"]); | ||||
|  | ||||
| 	// Invalid password | ||||
| 	$_SESSION["srv_xcatpassvalid"] = -1; | ||||
| } | ||||
|  | ||||
| if (isset($_REQUEST["username"])) { | ||||
| 	$_SESSION["srv_username"] = $_REQUEST["username"]; | ||||
|  | ||||
| 	// Invalid user name | ||||
| 	$_SESSION["srv_xcatpassvalid"]=-1; | ||||
| } | ||||
|  | ||||
| $jdata = array(); | ||||
| if (isAuthenticated()) { | ||||
| 	$jdata["authenticated"]="yes"; | ||||
| } else { | ||||
| 	$jdata["authenticated"]="no"; | ||||
| } | ||||
|  | ||||
| echo json_encode($jdata); | ||||
| ?> | ||||
|  | ||||
							
								
								
									
										10
									
								
								xCAT-UI/lib/srv_logout.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								xCAT-UI/lib/srv_logout.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Allow the user to log out and log back in | ||||
|  */ | ||||
| $TOPDIR = '..'; | ||||
| require_once "$TOPDIR/lib/functions.php"; | ||||
|  | ||||
| logout(); | ||||
| header("Location: ../service.php"); | ||||
| ?> | ||||
| @@ -5,21 +5,21 @@ | ||||
|  * @param 	Nothing | ||||
|  * @return 	Nothing | ||||
|  */ | ||||
| function loadPage(){ | ||||
| function loadPage() { | ||||
| 	// Include CSS and Javascripts | ||||
| 	echo | ||||
| 	'<html> | ||||
| 		<head> | ||||
| 			<title>xCAT Console</title> | ||||
| 			<link rel="shortcut icon" href="images/favicon.ico"> | ||||
| 			<link href="css/jquery-ui-1.8.12.start.css" rel=stylesheet type="text/css"> | ||||
| 			<link href="css/jquery-ui.css" rel=stylesheet type="text/css"> | ||||
| 			<link href="css/jquery.dataTables.css" rel=stylesheet type="text/css"> | ||||
| 			<link href="css/superfish.css" rel=stylesheet type="text/css"> | ||||
| 			<link href="css/jstree.css" rel=stylesheet type="text/css"> | ||||
| 			<link href="css/jquery.jqplot.css" rel=stylesheet type="text/css"> | ||||
| 			<link href="css/style.css" rel=stylesheet type="text/css"> | ||||
| 			<script type="text/javascript" src="js/jquery/jquery-1.5.1.min.js"></script> | ||||
| 			<script type="text/javascript" src="js/jquery/jquery-ui-1.8.12.start.min.js"></script> | ||||
| 			<script type="text/javascript" src="js/jquery/jquery.min.js"></script> | ||||
| 			<script type="text/javascript" src="js/jquery/jquery-ui.min.js"></script> | ||||
| 			<script type="text/javascript" src="js/ui.js"></script> | ||||
| 		</head>'; | ||||
|  | ||||
|   | ||||
							
								
								
									
										87
									
								
								xCAT-UI/service.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								xCAT-UI/service.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,87 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Main xCAT self-service page | ||||
|  */ | ||||
| require_once "lib/srv_functions.php"; | ||||
| require_once "lib/ui.php"; | ||||
| require_once "lib/jsonwrapper.php"; | ||||
|  | ||||
| /**  | ||||
|  * Load service page | ||||
|  */ | ||||
| // Include CSS and Javascripts | ||||
|  | ||||
| // TODO Rebuild xCAT-UI-deps where version numbers are removed from: | ||||
| // jquery-ui-default.css, jquery.min.js, jquery-ui.min.js | ||||
| echo | ||||
| '<html> | ||||
| 	<head> | ||||
| 		<title>xCAT Service Portal</title> | ||||
| 		<link rel="shortcut icon" href="images/favicon.ico"> | ||||
| 		<link href="css/jquery-ui-default.css" rel=stylesheet type="text/css"> | ||||
| 		<link href="css/jquery.dataTables.css" rel=stylesheet type="text/css"> | ||||
| 		<link href="css/jquery.jqplot.css" rel=stylesheet type="text/css"> | ||||
| 		<link href="css/superfish.css" rel=stylesheet type="text/css"> | ||||
| 		<link href="css/service.css" rel=stylesheet type="text/css"> | ||||
| 		<script type="text/javascript" src="js/jquery/jquery.min.js"></script> | ||||
| 		<script type="text/javascript" src="js/jquery/jquery-ui.min.js"></script> | ||||
| 		<script type="text/javascript" src="js/ui.js"></script> | ||||
| 		<script type="text/javascript" src="js/service/service.js"></script> | ||||
| 	</head>'; | ||||
|  | ||||
| // Create header menu | ||||
| echo | ||||
| '<body> | ||||
| 	<div id="header" class="ui-widget-header"> | ||||
| 		<img style="margin: 0px 20px; position: relative; float: left;" src="images/logo.gif" height="100%"/> | ||||
| 		<div style="margin: 10px 20px; position: relative; float: left; color: white; font: bold 14px sans-serif;">xCAT Service Portal</div>'; | ||||
| 		 | ||||
| // Create user name and log out section | ||||
| if (isset($_SESSION['srv_username'])){ | ||||
| 	echo  | ||||
| 		"<div> | ||||
| 			<span style='color: white;'>User: {$_SESSION['srv_username']}</span> | ||||
| 			<a href='lib/srv_logout.php'>Log out</a> | ||||
| 		</div>"; | ||||
| } | ||||
|  | ||||
| echo '</div>'; | ||||
|  | ||||
| // Create content area | ||||
| echo '<div class="content" id="content"></div>'; | ||||
|  | ||||
| // End of page | ||||
| echo | ||||
| 	'</body> | ||||
| </html>'; | ||||
|  | ||||
| // Login user | ||||
| if (!isAuthenticated()) { | ||||
| 	// xcatauth.js will open a dialog box asking for the user name and password | ||||
| 	echo | ||||
| 	'<script src="js/jquery/jquery.cookie.min.js" type="text/javascript"></script> | ||||
| 	<script src="js/srv_xcatauth.js" type="text/javascript"></script> | ||||
| 	<div id="logdialog"> | ||||
| 		<div id="loginput" class="ui-corner-all"> | ||||
| 			<table> | ||||
| 				<tr><td colspan=5></td></tr> | ||||
| 			    <tr><td align=right><img src="images/logo.png" width="50" height="30"></img></td><td colspan=4><p>eXtreme Cloud Administration Toolkit</p></td></tr> | ||||
| 			    <tr><td colspan=5></td></tr> | ||||
| 				<tr><td></td><td><label for=username>User name:</label></td><td colspan=2><input id=username type=text name=username></td><td></td></tr> | ||||
| 				<tr><td></td><td><label for=password>Password:</label></td><td colspan=2><input id=password type=password name=password></td><td></td></tr> | ||||
| 				<tr><td></td><td></td><td></td><td align=right><button>Login</button></td><td></td></tr> | ||||
| 				<tr><td></td><td colspan=5><span id=logstatus></span></td></tr> | ||||
| 			</table> | ||||
| 		</div> | ||||
| 		<div id="loginfo">Open Source. EPL License.</div> | ||||
| 	</div>'; | ||||
| } else { | ||||
| 	// Initialize page | ||||
| 	echo | ||||
| 	'<script language="JavaScript" type="text/javascript">  | ||||
| 		$(document).ready(function() { | ||||
| 			initServicePage(); | ||||
| 		});  | ||||
| 	</script>'; | ||||
| } | ||||
| ?> | ||||
		Reference in New Issue
	
	Block a user