diff --git a/xCAT-UI/configure.php b/xCAT-UI/configure.php
index 0d754e90f..f518ad157 100644
--- a/xCAT-UI/configure.php
+++ b/xCAT-UI/configure.php
@@ -10,8 +10,8 @@ loadPage();
 
 /* Login user */
 if (!isAuthenticated()) {
-	login();
+    login();
 } else {
-	loadContent();
+    loadContent();
 }
 ?>
\ No newline at end of file
diff --git a/xCAT-UI/css/login.css b/xCAT-UI/css/login.css
index 1e8be9733..8aea60065 100644
--- a/xCAT-UI/css/login.css
+++ b/xCAT-UI/css/login.css
@@ -30,11 +30,11 @@ body {
 	padding: 5px;
 }
 
-#login label{
+#login label {
 	font: bold 12px sans-serif;
 }
 
-#login_status {
+#login-status {
 	font: bold 12px sans-serif;
 }
 
@@ -44,7 +44,7 @@ body {
 	float: right;
 }
 
-#login_form {
+#login-form {
 	background-color: #f5f5f5;
 	height: 280px;
 	-moz-border-radius: 3px;
@@ -52,9 +52,9 @@ body {
 	border-radius: 3px;
 }
 
-#loginfo {
+#log-info {
 	margin: 5px 0px;
 	text-align: right;
 	color: #f5f5f5;
-	font-weight:bold;
+	font-weight: bold;
 }
\ No newline at end of file
diff --git a/xCAT-UI/css/style.css b/xCAT-UI/css/style.css
index 066636d80..58f7b2828 100644
--- a/xCAT-UI/css/style.css
+++ b/xCAT-UI/css/style.css
@@ -1,11 +1,10 @@
-/*--------------- Dialogs ---------------*/
+/*--- Dialogs ---*/
 .ui-dialog input {
 	border: solid 1px #BDBDBD;
 	font: 12px sans-serif;
 }
 
-.ui-dialog label,.ui-dialog input,.ui-dialog p,.ui-dialog button,.ui-dialog td
-	{
+.ui-dialog label,.ui-dialog input,.ui-dialog p,.ui-dialog button,.ui-dialog td {
 	font: 12px sans-serif;
 }
 
@@ -13,12 +12,11 @@
 	font: 12px sans-serif;
 }
 
-.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button
-	{
+.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button {
 	font: 12px sans-serif;
 }
 
-/*--------------- Tooltip ---------------*/
+/*--- Tooltip ---*/
 .tooltip {
 	background-color: #000;
 	border: 1px solid #fff;
@@ -37,7 +35,7 @@
 	margin: 0px;
 }
 
-/*--------------- Header ---------------*/
+/*--- Header ---*/
 #header {
 	height: 39px;
 	width: 1000px;
@@ -90,15 +88,7 @@
 	color: #FF0000;
 }
 
-#layoutselector {
-	padding: 2px 10px 0px 2px; /* Top right left bottom*/
-	text-align: right;
-	color: #FFC125;
-	text-decoration: none;
-	display: block;
-}
-
-/*--------------- Body and content ---------------*/
+/*--- Body and content ---*/
 body {
 	background: #1C1C1C;
 	font: 12px sans-serif;
@@ -124,7 +114,7 @@ pre {
 	font-size: 10px;
 }
 
-/*--------------- Groups ---------------*/
+/*--- Groups ---*/
 #groups {
 	width: 150px;
 	vertical-align: top;
@@ -178,7 +168,7 @@ pre {
 	border-top: thin solid #E7EBFF;
 }
 
-/*--------------- Nodes section ---------------*/
+/*--- Nodes section ---*/
 #nodes {
 	width: 790px;
 	min-height: 570px;
@@ -204,7 +194,7 @@ pre {
 	line-height: 1;
 }
 
-/*--------------- Info/warning bar ---------------*/
+/*--- Info and warning bar ---*/
 span.ui-icon-info {
 	float: left;
 	margin-right: 0.3em;
@@ -227,7 +217,7 @@ span.ui-icon-info {
 	text-align: center
 }
 
-/*--------------- jQuery tabs ---------------*/
+/*--- jQuery tabs ---*/
 .tab {
 	font: 12px sans-serif;
 	border-style: none;
@@ -248,7 +238,7 @@ span.ui-icon-info {
 	cursor: pointer;
 }
 
-/*--------------- Inventory and user entry ---------------*/
+/*--- Inventory and user entry ---*/
 .tab table {
 	border-width: 1px;
 	border-spacing: 0px;
@@ -326,7 +316,7 @@ legend {
 	height: 300px;
 }
 
-/*--------------- menu Div Actions bar ---------------*/
+/*--- menu Div Actions bar ---*/
 .menuDiv {
 	padding: 0.5em;
 	height: 30px;
@@ -373,7 +363,7 @@ legend {
 	margin: 0;
 }
 
-/*--------------- jQuery datatable ---------------*/
+/*--- jQuery datatable ---*/
 .dataTables_wrapper {
 	overflow: auto;
 	width: auto;
@@ -414,8 +404,7 @@ legend {
 }
 
 /*** < > buttons ***/
-.paginate_disabled_previous,.paginate_enabled_previous,.paginate_disabled_next,.paginate_enabled_next
-	{
+.paginate_disabled_previous,.paginate_enabled_previous,.paginate_disabled_next,.paginate_enabled_next {
 	height: 19px;
 	width: 19px;
 	margin-left: 2px;
@@ -472,7 +461,7 @@ legend {
 	color: #FF0000;
 }
 
-/*--------------- Editable column ---------------*/
+/*--- Editable column ---*/
 .tab .datatable textarea {
 	font: 12px sans-serif;
 	border: solid 1px #BDBDBD;
@@ -498,7 +487,7 @@ legend {
 	background: none;
 }
 
-/*--------------- jQuery context menu ---------------*/
+/*--- jQuery context menu ---*/
 .context-menu-theme-vista {
 	background: #FAFAFA url(../images/contextmenu/context-menu-bg.gif)
 		repeat-y left top;
@@ -536,8 +525,7 @@ legend {
 	background-image: none;
 }
 
-.context-menu-theme-vista .context-menu-item-hover .context-menu-item-inner
-	{
+.context-menu-theme-vista .context-menu-item-hover .context-menu-item-inner {
 	padding: 3px 15px 3px 35px;
 	margin-left: 0px;
 }
@@ -546,7 +534,7 @@ legend {
 	color: #A7A7A7;
 }
 
-/*--------------- Forms ---------------*/
+/*--- Forms ---*/
 .form label {
 	color: #424242;
 	line-height: 1.5;
@@ -613,7 +601,7 @@ table a:hover {
 	border: solid 1px #d4d4d4;
 }
 
-/*--------------- Provision disk table ---------------*/
+/*--- Provision disk table ---*/
 .provision table {
 	border-width: 1px;
 	border-spacing: 0px;
@@ -630,7 +618,7 @@ table a:hover {
 	width: 60px;
 }
 
-/*--------------- Provision and clone table ---------------*/
+/*--- Provision and clone table ---*/
 .special table {
 	border-width: 1px;
 	border-spacing: 0px;
@@ -646,52 +634,52 @@ table a:hover {
 	padding: 3px;
 }
 
-/*--------------- Provision and monitor forms ---------------*/
-.monitornormal {
+/*--- Provision and monitor forms ---*/
+.monitor-normal {
 	background: #66CD00;
 	cursor: pointer;
 }
 
-.mornitorwarning {
+.mornitor-warning {
 	background: #FFD700;
 	cursor: pointer;
 }
 
-.monitorerror {
+.monitor-error {
 	background: #FF3030;
 }
 
-.monitorunknown {
+.monitor-unknown {
 	background: #8B8B7A;
 }
 
-.monitornodeli {
+.monitor-node-li {
 	width: 10px;
 	height: 10px;
 	float: left;
 	border: 1px solid white;
 }
 
-.monitorsumdiv {
+.monitor-sum-div {
 	width: 300px;
 	height: 180px;
 	float: left;
 	margin: 0px 0px 10px 10px;
 }
 
-.monitorsumdiv td {
+.monitor-sum-div td {
 	padding: 0;
 	border-style: none;
 	font-size: 10px;
 }
 
-.monitornodediv {
+.monitor-node-div {
 	width: 240px;
 	height: 120px;
 	margin: 0px 0px 15px 0px;
 }
 
-.monitorzoomlink {
+.monitor-zoom-link {
 	cursor: pointer;
 	color: blue;
 }
@@ -710,7 +698,7 @@ table a:hover {
 	height: 150px;
 }
 
-/*--------------- Physical layout section ---------------*/
+/*--- Physical layout section ---*/
 .frameDiv {
 	width: 179px;
 	height: 500px;
@@ -768,7 +756,7 @@ table a:hover {
 	height: 11px;
 }
 
-.fspcheckbox {
+.fspCheckbox {
 	padding: 0px;
 	margin: 3px 3px 1px 3px;
 }
@@ -796,7 +784,7 @@ table a:hover {
 	background: url(../images/nodes/blade.jpg);
 }
 
-.xnodeDiv {
+.xNodeDiv {
 	font-size: 12px;
 	height: 21px;
 	line-height: 21px;
@@ -809,45 +797,7 @@ table a:hover {
 	display: inline-block;
 }
 
-/*--------------- Discovery section ---------------*/
-.discoverstep {
-	width: 960px;
-	vertical-align: top;
-	background-color: #A9D0F5;
-	padding: 0px 0px 0px 5px;
-	-moz-border-radius: .3em;
-	-webkit-border-radius: .3em;
-	border-radius: .3em;
-}
-
-.discovercurrentstep {
-	background-color: yellow;
-	font: normal bold 12px/35px sans-serif;
-	padding: 5px;
-}
-
-.discovercontent {
-	width: 960px;
-	display: inline-table;
-	padding: 0;
-}
-
-.discovercontent table {
-	border: none;
-}
-
-.discovercontent td {
-	border: none;
-	text-align: left;
-}
-
-.discovercontent th {
-	font: normal bold 15px sans-serif;
-	text-align: center;
-	border: none;
-}
-
-/*--------------- jqPlot Pie legend ---------------*/
+/*--- jqPlot Pie legend ---*/
 td.jqplot-table-legend {
 	border-width: 0px;
 }
diff --git a/xCAT-UI/ganglianode.php b/xCAT-UI/ganglianode.php
index 370fbefcf..3ee6b5d89 100644
--- a/xCAT-UI/ganglianode.php
+++ b/xCAT-UI/ganglianode.php
@@ -1,17 +1,18 @@
 <?php
 echo <<<EEE
 <html>
-	<head>
-	    <title>Node {$_GET['n']} Ganglia Report</title>
-	    <meta content="600" http-equiv="refresh">
-	    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
-	    <link href="css/style.css" rel=stylesheet type="text/css">
-	    <link href="css/jquery.jqplot.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>
+    <head>
+        <title>Node {$_GET['n']} Ganglia Report</title>
+        <meta content="600" http-equiv="refresh">
+        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
+        <link href="css/style.css" rel=stylesheet type="text/css">
+        <link href="css/jquery.jqplot.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>
 EEE;
 ?>
+
 <script type="text/javascript">
 window.onload=function() {
     var nodepath = $('#nodepath').val();
@@ -37,9 +38,9 @@ window.onload=function() {
 };
 
 function drawNodesummary(summaryString){
-	var nodename = $('#nodename').val();
-	var nodeData = new Object();
-	var metricArray = summaryString.split(';');
+    var nodename = $('#nodename').val();
+    var nodeData = new Object();
+    var metricArray = summaryString.split(';');
     var metricname = '';
     var valueArray = '';
     var position = 0;
@@ -64,27 +65,28 @@ function drawNodesummary(summaryString){
     drawNetworkFlot('ganglianodenetwork', nodename, nodeData['bytes_in'], nodeData['bytes_out']);
 }
 </script>
+
 <?php
 echo <<<EEE
-	</head>
-	<body>
-		<input id="nodename" type="hidden" value="{$_GET['n']}"></input>
-		<input id="nodepath" type="hidden" value="{$_GET['p']}"></input>
-		<div style="background-color:white;" class="tab">
-			<table style="border-style:none;">
-				<tr>
-					<td style="padding:0;border-style:none;"><div id="ganglianodeload" class="monitorsumdiv"></div></td>
-					<td style="padding:0;border-style:none;"><div id="ganglianodecpu" class="monitorsumdiv"></div></td>
-					<td style="padding:0;border-style: none;"><div id="ganglianodemem" class="monitorsumdiv"></div></td>
-				</tr>
-				<tr>
-					<td style="padding:0;border-style:none;"><div id="ganglianodedisk" class="monitorsumdiv"></div></td>
-					<td style="padding:0;border-style:none;"><div id="ganglianodenetwork" class="monitorsumdiv"></div></td>
-					<td style="padding:0;border-style:none;"></td>
-				</tr>
-			</table>
-		</div>
-	</body>
+    </head>
+    <body>
+        <input id="nodename" type="hidden" value="{$_GET['n']}"></input>
+        <input id="nodepath" type="hidden" value="{$_GET['p']}"></input>
+        <div style="background-color:white;" class="tab">
+            <table style="border-style:none;">
+                <tr>
+                    <td style="padding:0;border-style:none;"><div id="ganglianodeload" class="monitor-sum-div"></div></td>
+                    <td style="padding:0;border-style:none;"><div id="ganglianodecpu" class="monitor-sum-div"></div></td>
+                    <td style="padding:0;border-style: none;"><div id="ganglianodemem" class="monitor-sum-div"></div></td>
+                </tr>
+                <tr>
+                    <td style="padding:0;border-style:none;"><div id="ganglianodedisk" class="monitor-sum-div"></div></td>
+                    <td style="padding:0;border-style:none;"><div id="ganglianodenetwork" class="monitor-sum-div"></div></td>
+                    <td style="padding:0;border-style:none;"></td>
+                </tr>
+            </table>
+        </div>
+    </body>
 </html>
 EEE;
 ?>
\ No newline at end of file
diff --git a/xCAT-UI/help.php b/xCAT-UI/help.php
index d9d5b552c..95bf6e353 100644
--- a/xCAT-UI/help.php
+++ b/xCAT-UI/help.php
@@ -10,8 +10,8 @@ loadPage();
 
 /* Login user */
 if (!isAuthenticated()) {
-	login();
+    login();
 } else {
-	loadContent();
+    loadContent();
 }
 ?>
\ No newline at end of file
diff --git a/xCAT-UI/index.php b/xCAT-UI/index.php
index dadb7b817..b55a5842c 100644
--- a/xCAT-UI/index.php
+++ b/xCAT-UI/index.php
@@ -11,8 +11,8 @@ loadPage();
 
 /* Login user */
 if (!isAuthenticated()) {
-	login();
+    login();
 } else {
-	loadContent();
+    loadContent();
 }
 ?>
\ No newline at end of file
diff --git a/xCAT-UI/js/monitor/gangliamon.js b/xCAT-UI/js/monitor/gangliamon.js
index 2fd4c4ddd..664a6d6ff 100644
--- a/xCAT-UI/js/monitor/gangliamon.js
+++ b/xCAT-UI/js/monitor/gangliamon.js
@@ -476,11 +476,11 @@ function drawGridSummary() {
     }
     
     gridDrawArea.empty();
-    showStr = '<table style="border-style:none;"><tr><td style="padding:0;border-style:none;"><div id="gangliasummaryload" class="monitorsumdiv"></div></td>' + 
-              '<td style="padding:0;border-style:none;"><div id="gangliasummarycpu" class="monitorsumdiv"></div></td>' +
-              '<td style="padding:0;border-style:none;"><div id="gangliasummarymem" class="monitorsumdiv"></div></td></tr>' +
-              '<tr><td style="padding:0;border-style:none;"><div id="gangliasummarydisk" class="monitorsumdiv"></div></td>' +
-              '<td style="padding:0;border-style:none;"><div id="gangliasummarynetwork" class="monitorsumdiv"></div></td>' +
+    showStr = '<table style="border-style:none;"><tr><td style="padding:0;border-style:none;"><div id="gangliasummaryload" class="monitor-sum-div"></div></td>' + 
+              '<td style="padding:0;border-style:none;"><div id="gangliasummarycpu" class="monitor-sum-div"></div></td>' +
+              '<td style="padding:0;border-style:none;"><div id="gangliasummarymem" class="monitor-sum-div"></div></td></tr>' +
+              '<tr><td style="padding:0;border-style:none;"><div id="gangliasummarydisk" class="monitor-sum-div"></div></td>' +
+              '<td style="padding:0;border-style:none;"><div id="gangliasummarynetwork" class="monitor-sum-div"></div></td>' +
               '<td style="padding:0;border-style:none;"></td></tr></table>';
     gridDrawArea.append(showStr);
     drawLoadFlot('gangliasummaryload', 'Grid', gridData['load_one'], gridData['cpu_num']);
@@ -906,23 +906,23 @@ function drawGangliaNodesAreaPic(type, name) {
         nodename = temparray[index];
         switch (nodeStatus[nodename]) {
             case 'ERROR':
-                showStr = '<li class="monitorerror ui-corner-all monitornodeli" title="' + nodename + '"></li>';
+                showStr = '<li class="monitor-error ui-corner-all monitor-node-li" title="' + nodename + '"></li>';
                 break;
             case 'WARNING':
-                showStr = '<li class="mornitorwarning ui-corner-all monitornodeli" title="' + nodename + '"></li>';
+                showStr = '<li class="mornitor-warning ui-corner-all monitor-node-li" title="' + nodename + '"></li>';
                 break;
             case 'NORMAL':
-                showStr = '<li class="monitornormal ui-corner-all monitornodeli" title="' + nodename + '"></li>';
+                showStr = '<li class="monitor-normal ui-corner-all monitor-node-li" title="' + nodename + '"></li>';
                 break;
             default:
-            	showStr = '<li class="monitorunknown ui-corner-all monitornodeli" title="' + nodename + '"></li>';
+            	showStr = '<li class="monitor-unknown ui-corner-all monitor-node-li" title="' + nodename + '"></li>';
             	break;
         }
         $('#gangliaNodes ul').append(showStr);
     }
     
     // Bind all normal and warning nodes click event
-    $('.monitornormal,.monitorwarning').bind('click', function() {
+    $('.monitor-normal,.monitorwarning').bind('click', function() {
         var nodename = $(this).attr('title');
         window.open('ganglianode.php?n=' + nodename + '&p=' + nodePath[nodename],
                 'nodedetail','height=430,width=950,scrollbars=yes,status =no');
@@ -1077,7 +1077,7 @@ function updateZoom(obj) {
 	while ($('#zoomDiv span:last').attr('name') != type) {
 		$('#zoomDiv span:last').remove();
 	}
-	$(obj).removeClass('monitorzoomlinkli');
+	$(obj).removeClass('monitor-zoom-link');
 	$(obj).unbind('click');
 	
 	drawGangliaNodesArea();
@@ -1093,7 +1093,7 @@ function addZoomDiv(obj) {
 	var type = $(obj).attr('name');
 	
 	var lastzoomobj = $('#zoomDiv span:last');
-	lastzoomobj.addClass('monitorzoomlink');
+	lastzoomobj.addClass('monitor-zoom-link');
 	lastzoomobj.bind('click', function() {
 		updateZoom(this);
 	});
diff --git a/xCAT-UI/js/monitor/rmcmon.js b/xCAT-UI/js/monitor/rmcmon.js
index c2215a251..8eb011415 100644
--- a/xCAT-UI/js/monitor/rmcmon.js
+++ b/xCAT-UI/js/monitor/rmcmon.js
@@ -273,13 +273,13 @@ function showRmcSummary(returnData) {
             summaryTable.append(summaryRow);
         }
         summaryRow.append(tempTd);
-        attrDiv = $('<div id="monitorsumdiv' + attr + '" class="monitorsumdiv"></div>');
+        attrDiv = $('<div id="monitor-sum-div' + attr + '" class="monitor-sum-div"></div>');
         tempTd.append(attrDiv);
         for (var i in attrValues) {
             tempArray.push( [ globalTimeStamp[i], Number(attrValues[i]) ]);
         }
 
-        $.jqplot('monitorsumdiv' + attr, [ tempArray ], {
+        $.jqplot('monitor-sum-div' + attr, [ tempArray ], {
             series: [{
                 showMarker : false
             }],
@@ -348,13 +348,13 @@ function parseRmcData(returnData) {
 }
 
 function createUnkownNode(nodeName) {
-    var tempLi = '<li class="monitorunknown ui-corner-all monitornodeli" id="' + nodeName + '" ' + 
+    var tempLi = '<li class="monitor-unknown ui-corner-all monitor-node-li" id="' + nodeName + '" ' + 
                  'title="Name:' + nodeName + '<br/>Unknown"></li>';
     return tempLi;
 }
 
 function createErrorNode(nodeName) {
-    var tempLi = '<li class="monitorerror ui-corner-all monitornodeli id="' + nodeName + '" ' +
+    var tempLi = '<li class="monitor-error ui-corner-all monitor-node-li id="' + nodeName + '" ' +
                  'title="Name:' + nodeName + '<br/>Error"></li>';
 }
 
@@ -403,12 +403,12 @@ function showRmcNodes(data, nodename) {
     memAvg = parseInt(tempSum / index);
     
     if (cpuAvg >= 10 && memAvg <= 90){
-        classname = 'monitornormal';
+        classname = 'monitor-normal';
     } else {
-        classname = 'mornitorwarning';
+        classname = 'mornitor-warning';
     }
     
-    var normalLi = $('<li class="' + classname + ' ui-corner-all monitornodeli" id="' + nodename + '" title="' +
+    var normalLi = $('<li class="' + classname + ' ui-corner-all monitor-node-li" id="' + nodename + '" title="' +
          'Name:' + nodename + '<br/> CpuIdle: ' + cpuAvg + '%<br/> MemFree: ' + memAvg + '%"></li>');
     
     $('#rmcmonDetail ul').append(normalLi);
@@ -440,8 +440,8 @@ function showNode(nodeName) {
 
     for ( var attr in globalNodesDetail[nodeName]) {
         var tempTd = $('<td style="border:0px;padding:1px 1px;"></td>');
-        var attrChat = $('<div id="monitornodediv' + nodeName + attr
-                + '" class="monitornodediv"></div>');
+        var attrChat = $('<div id="monitor-node-div' + nodeName + attr
+                + '" class="monitor-node-div"></div>');
         if (0 == parseNum % 4) {
             nodeRow = $('<tr></tr>');
             nodeTable.append(nodeRow);
@@ -457,7 +457,7 @@ function showNode(nodeName) {
             tempArray.push( [ globalTimeStamp[i], Number(tempData[i]) ]);
         }
 
-        $.jqplot('monitornodediv' + nodeName + attr, [ tempArray ], {
+        $.jqplot('monitor-node-div' + nodeName + attr, [ tempArray ], {
             series : [{
                 showMarker : false
             }],
diff --git a/xCAT-UI/js/nodes/physical.js b/xCAT-UI/js/nodes/physical.js
index 498ffd35c..18066b328 100644
--- a/xCAT-UI/js/nodes/physical.js
+++ b/xCAT-UI/js/nodes/physical.js
@@ -312,7 +312,7 @@ function createSystempGraphical(bpa, fsp, area){
 		
 		var td = $('<td style="padding:0;border-color: transparent;"></td>');
 		var frameDiv = $('<div class="frameDiv"></div>');
-		frameDiv.append('<div style="height:27px;" title="' + bpaName + '"><input type="checkbox" class="fspcheckbox" name="check_'+ bpaName +'"></div>');
+		frameDiv.append('<div style="height:27px;" title="' + bpaName + '"><input type="checkbox" class="fspCheckbox" name="check_'+ bpaName +'"></div>');
 		
 		//for P7-IH, all the cecs are insert into the frame from down to up, so we had to show the cecs same as the
 		//physical layout.
@@ -445,7 +445,7 @@ function createSystempGraphical(bpa, fsp, area){
 		updateSelectNodeDiv();
 	});
 	
-	$('.fspcheckbox').bind('click', function(){
+	$('.fspCheckbox').bind('click', function(){
 		var itemName = $(this).attr('name');
 		name = itemName.substr(6);
 		
@@ -571,8 +571,8 @@ function createSystemxGraphical(xnodes, area){
 			}
 			xnodenum++;
 			var td = $('<td style="padding:0;border-color: transparent;"></td>');
-			var xnodeDiv = '<div id="' + xnodename + '" class="xnodeDiv" title="' + xnodename +'"></div>';
-			td.append(xnodeDiv);
+			var xNodeDiv = '<div id="' + xnodename + '" class="xNodeDiv" title="' + xnodename +'"></div>';
+			td.append(xNodeDiv);
 			row.append(td);
 		}
 	}
@@ -801,7 +801,7 @@ function createFspDiv(fspName, mtm, fsp){
 	}
 		
 	//create return value
-	var retHtml = '<input style="padding:0;" class="fspcheckbox" type="checkbox" name="check_' + fspName + '">';
+	var retHtml = '<input style="padding:0;" class="fspCheckbox" type="checkbox" name="check_' + fspName + '">';
 	retHtml += '<div value="' + fspName + '" class="' + divClass + '">';
 	retHtml += '<div class="lparDiv"><table><tbody><tr>' + lparStatusRow + '</tr></tbody></table></div></div>';
 	return retHtml;
diff --git a/xCAT-UI/js/srv_xcatauth.js b/xCAT-UI/js/srv_xcatauth.js
index a22fc56ad..e9c4ef89c 100644
--- a/xCAT-UI/js/srv_xcatauth.js
+++ b/xCAT-UI/js/srv_xcatauth.js
@@ -24,8 +24,8 @@ $(document).ready(function() {
     }).button();
     
 	if (document.location.protocol == 'http:') {
-		$('#login_status').html('You are using an unencrypted session!');
-		$('#login_status').css('color', 'red');
+		$('#login-status').html('You are using an unencrypted session!');
+		$('#login-status').css('color', 'red');
 	}
 	
 	if (!$("#login input[name='username']").val()) {
@@ -62,7 +62,7 @@ function onlogin(data, txtStatus) {
 	var usrName = $("#login input[name='username']").val();
 	$("#login input[name='password']").val('');
 	if (data.authenticated == 'yes') {
-		$('#login_status').text('Login successful');
+		$('#login-status').text('Login successful');
 		window.location = 'service.php';
 				
 		// Set user name cookie
@@ -70,8 +70,8 @@ function onlogin(data, txtStatus) {
 		exDate.setTime(exDate.getTime() + (240 * 60 * 1000));
 		$.cookie('xcat_username', usrName, { expires: exDate });
 	} else {
-		$('#login_status').text('Authentication failure');
-		$('#login_status').css('color', '#FF0000');
+		$('#login-status').text('Authentication failure');
+		$('#login-status').css('color', '#FF0000');
 	}
 }
 
@@ -79,8 +79,8 @@ function onlogin(data, txtStatus) {
  * Authenticate user for new session
  */
 function authenticate() {
-	$('#login_status').css('color', '#000000');
-	$('#login_status').html('Authenticating...');
+	$('#login-status').css('color', '#000000');
+	$('#login-status').html('Authenticating...');
 	
 	var passwd = $("#login input[name='password']").val();
 	$.post('lib/srv_log.php', {
diff --git a/xCAT-UI/js/xcatauth.js b/xCAT-UI/js/xcatauth.js
index 9d615b349..22fb185fc 100644
--- a/xCAT-UI/js/xcatauth.js
+++ b/xCAT-UI/js/xcatauth.js
@@ -26,8 +26,8 @@ $(document).ready(function() {
     $('#login button').button();
     
 	if (document.location.protocol == "http:") {
-		$("#login_status").html("You are using an unencrypted session!");
-		$("#login_status").css("color", "#ff0000");
+		$("#login-status").html("You are using an unencrypted session!");
+		$("#login-status").css("color", "#ff0000");
 	}
 	
 	if ($("#login input[name='username']").val() == "") {
@@ -64,7 +64,7 @@ function onlogin(data, txtStatus) {
 	// Clear password field regardless of what happens
 	$("#login input[name='password']").val("");
 	if (data.authenticated == "yes") {
-		$("#login_status").text("Login successful");
+		$("#login-status").text("Login successful");
 
 		// Not the first time to log
 		if ($.cookie('logonflag')){
@@ -87,7 +87,7 @@ function onlogin(data, txtStatus) {
 		});
 		
 	} else {
-		$("#login_status").text("Authentication failure").css("color", "#FF0000");
+		$("#login-status").text("Authentication failure").css("color", "#FF0000");
 	}
 }
 
@@ -97,8 +97,8 @@ function onlogin(data, txtStatus) {
  * @return Nothing
  */
 function authenticate() {
-	$("#login_status").css("color", "#000000");
-	$("#login_status").html('Authenticating...');
+	$("#login-status").css("color", "#000000");
+	$("#login-status").html('Authenticating...');
 	var passwd = $("#login input[name='password']").val();
 	$.post("lib/log.php", {
 		username : $("#login input[name='username']").val(),
diff --git a/xCAT-UI/lib/cmd.php b/xCAT-UI/lib/cmd.php
index d040fe499..d272b9d79 100644
--- a/xCAT-UI/lib/cmd.php
+++ b/xCAT-UI/lib/cmd.php
@@ -6,26 +6,26 @@ 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.
+ * 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
+ * @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"];
-	
+
 	// File contents in case of file write
 	if (isset($_GET["cont"])) {
 		$cont = $_GET["cont"];
 	}
-	
+
 	// Special messages put here
 	// This gets sent back to the AJAX request as is.
 	$msg = $_GET["msg"];
@@ -34,7 +34,7 @@ if (isset($_GET["cmd"])) {
 	if (!$tgt) {
 		$tgt = NULL;
 	}
-	
+
 	// If no $msg is given, set $msg to NULL
 	if (!$msg) {
 		$msg = NULL;
@@ -52,12 +52,12 @@ if (isset($_GET["cmd"])) {
 			$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
@@ -74,7 +74,7 @@ if (isset($_GET["cmd"])) {
 	if (in_array("flush", $opts_array)) {
 		return;
 	}
-	
+
 	$rsp = array();
 
 	// webrun pping and gangliastatus output needs special handling
@@ -90,7 +90,7 @@ if (isset($_GET["cmd"])) {
 	// This command gets the nodes and groups
 	else if(strncasecmp($cmd, "extnoderange", 12) == 0) {
 		$rsp = extractExtnoderange($xml);
-	}	
+	}
 	// Write contents to file
 	else if(strncasecmp($cmd, "write", 4) == 0) {
 		// Directory should be /var/opt/xcat/profiles
@@ -99,7 +99,7 @@ if (isset($_GET["cmd"])) {
 		$handle = fopen($file, 'w') or die("Cannot open $file");
 		fwrite($handle, $cont);
 		fclose($handle);
-		
+
 		$rsp = "Directory entry written to $file";
 	}
 	// Handle the typical output
@@ -108,20 +108,20 @@ if (isset($_GET["cmd"])) {
 			foreach ($child->children() as $data) {
 				if($data->name) {
 					$node = $data->name;
-					
+
 					if ($data->data->contents) {
 						$cont = $data->data->contents;
 					} else {
 						$cont = $data->data;
 					}
-					
+
 					if ($data->data->desc) {
 						$cont = $data->data->desc . ": " . $cont;
 					}
-					
+
 					$cont = str_replace(":|:", "\n", $cont);
 					array_push($rsp, "$node: $cont");
-				} else if(strlen("$data") > 2) {
+				} else if (strlen("$data") > 2) {
 					$data = str_replace(":|:", "\n", $data);
 					array_push($rsp, "$data");
 				}
@@ -137,8 +137,8 @@ if (isset($_GET["cmd"])) {
 /**
  * Extract the output for a webrun command
  *
- * @param	$xml 	The XML output from docmd()
- * @return 	An array containing the output
+ * @param    $xml    The XML output from docmd()
+ * @return An array containing the output
  */
 function extractWebrun($xml) {
 	$rsp = array();
@@ -149,7 +149,7 @@ function extractWebrun($xml) {
 		foreach($nodes->children() as $node){
 			// Get the node name
 			$name = $node->name;
-			
+
 			// Get the content
 			$status = $node->data;
 			$status = str_replace(":|:", "\n", $status);
@@ -166,8 +166,8 @@ function extractWebrun($xml) {
 /**
  * Extract the output for a nodels command
  *
- * @param	$xml 	The XML output from docmd()
- * @return 	An array containing the output
+ * @param    $xml    The XML output from docmd()
+ * @return An array containing the output
  */
 function extractNodels($xml) {
 	$rsp = array();
@@ -195,8 +195,8 @@ function extractNodels($xml) {
 /**
  * Extract the output for a extnoderange command
  *
- * @param 	$xml 	The XML output from docmd()
- * @return 	The nodes and groups
+ * @param    $xml    The XML output from docmd()
+ * @return The nodes and groups
  */
 function extractExtnoderange($xml) {
 	$rsp = array();
diff --git a/xCAT-UI/lib/functions.php b/xCAT-UI/lib/functions.php
index c1e23b5eb..52935d368 100644
--- a/xCAT-UI/lib/functions.php
+++ b/xCAT-UI/lib/functions.php
@@ -5,22 +5,21 @@
 
 // Retain session variables across page requests
 session_start();
-session_write_close();	// Do not block HTTP requests
+session_write_close();    // Do not block other HTTP requests
 
-// The settings below display error on the screen,
-// instead of giving blank pages.
+// 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
+ * @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,
@@ -34,7 +33,9 @@ function docmd($cmd, $nr, $args_array, $opts_array){
 	// 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($nr)) {
+		$request->addChild('noderange', $nr);
+	}
 	if (!empty($args_array)) {
 		foreach ($args_array as $a) {
 			$request->addChild('arg',$a);
@@ -53,9 +54,9 @@ function docmd($cmd, $nr, $args_array, $opts_array){
 /**
  * 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
+ * @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";
@@ -63,46 +64,46 @@ function submit_request($req, $skipVerify, $opts_array){
 	$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
+
+	// 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)){
+	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
-		
+		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	
+		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
@@ -117,50 +118,48 @@ function submit_request($req, $skipVerify, $opts_array){
 							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
+			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 = preg_replace($fullpattern,'', $response, -1, $count); // 1st try to remove the long pattern
+				if (!$count) {
+					$response = preg_replace($mixedpattern,'', $response) . '</xcatresponse>/';
+				}
 				$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) {
+		} else if(!$skipVerify) {
 			echo "<p>(Error) xCAT response ended prematurely: ", htmlentities($response), "</p>";
 			$rsp = FALSE;
 		}
@@ -170,10 +169,6 @@ function submit_request($req, $skipVerify, $opts_array){
 
 /**
  * Enable password storage to split between cookie and session variable
- *
- * @param 	$data
- * @param	$key
- * @return
  */
 function xorcrypt($data, $key) {
 	$datalen = strlen($data);
@@ -187,9 +182,6 @@ function xorcrypt($data, $key) {
 
 /**
  * Get password
- *
- * @param 	Nothing
- * @return
  */
 function getpassword() {
 	if (isset($GLOBALS['xcatauthsecret'])) {
@@ -204,13 +196,11 @@ function getpassword() {
 }
 
 /**
- * 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.
+ * 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
+ * @param $password    Password
  */
 function setpassword($password) {
 	$randlen = strlen($password);
@@ -227,8 +217,8 @@ function setpassword($password) {
 /**
  * Get RAND characters
  *
- * @param 	$length		Length of characters
- * @return 	RAND characters
+ * @param $length    Length of characters
+ * @return RAND characters
  */
 function getrandchars($length) {
 	$charset = '0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*';
@@ -246,9 +236,7 @@ function getrandchars($length) {
 /**
  * Determine if a user/password session exists
  *
- * @param 	Nothing
- * @return 	True 	If user has a session.
- * 			False 	Otherwise
+ * @return True if user has a session, false otherwise
  */
 function is_logged() {
 	if (isset($_SESSION["username"]) and !is_bool(getpassword())) {
@@ -260,10 +248,8 @@ function is_logged() {
 
 /**
  * Determine if a user is currently logged in successfully
- * 
- * @param 	Nothing
- * @return 	True 	If the user is currently logged in successfully
- * 			False 	Otherwise
+ *
+ * @return True if the user is currently logged in successfully, false otherwise
  */
 function isAuthenticated() {
 	if (is_logged()) {
@@ -290,12 +276,10 @@ function isAuthenticated() {
 }
 
 /**
-* Determine if a user has root access
-*
-* @param 	Nothing
-* @return 	True 	If the user has root access
-* 			False 	Otherwise
-*/
+ * Determine if a user has root access
+ *
+ * @return True if the user has root access, false otherwise
+ */
 function isRootAcess() {
 	if (is_logged() && $_SESSION["xcatpassvalid"]) {
 		$testacc = docmd('tabdump', '', array('policy', '-w', "name==" . $_SESSION["username"]), array());
@@ -304,7 +288,7 @@ function isRootAcess() {
 			$result = str_replace('"', '', $result);
 			$args = array();
 			$args = explode(",", $result);
-			
+
 			// Get the comments which contains the privilege
 			$comments = $args[8];
 			$args = explode(";", $comments);
@@ -319,13 +303,13 @@ function isRootAcess() {
 						$privilege = 'root';
 						$_SESSION["xcatpassvalid"] = 1;
 					}
-					
+
 					break;
-				}				
+				}
 			}
 		}
 	}
-	
+
 	if (strcmp($_SESSION["username"], 'root') == 0) {
 		$_SESSION["xcatpassvalid"] = 1;
 	}
@@ -338,10 +322,7 @@ function isRootAcess() {
 }
 
 /**
- * Log out of the current user session
- * 
- * @param 	Nothing
- * @return 	Nothing
+ * Log out of current user session
  */
 function logout() {
 	// Clear the secret cookie from browser
@@ -360,12 +341,9 @@ function logout() {
 
 /**
  * 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 
+	// Format a given string however you want it
 	echo $tmp . '<br/>';
 	flush();
 }
diff --git a/xCAT-UI/lib/rcons.php b/xCAT-UI/lib/rcons.php
index 5ddc2825a..d27960aa2 100644
--- a/xCAT-UI/lib/rcons.php
+++ b/xCAT-UI/lib/rcons.php
@@ -77,14 +77,14 @@ function rconsSynchronise($parameter) {
 		if (0 == strlen($line)) {
 			continue;
 		}
-		
+
 		if ('<' == substr($line, 0, 1)) {
 			$flag = true;
 			$return .= $line;
 			break;
 		}
 	}
-	
+
 	if ($flag) {
 		while (!feof($fp)) {
 			$return .= fgets($fp, 1024);
diff --git a/xCAT-UI/lib/srv_cmd.php b/xCAT-UI/lib/srv_cmd.php
index 3798fab27..ae3b4878b 100644
--- a/xCAT-UI/lib/srv_cmd.php
+++ b/xCAT-UI/lib/srv_cmd.php
@@ -5,22 +5,21 @@ 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.
+ * 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
+ * @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"];
@@ -29,7 +28,7 @@ if (isset($_GET["cmd"])) {
 	if (!$tgt) {
 		$tgt = NULL;
 	}
-	
+
 	// If no $msg is given, set $msg to NULL
 	if (!$msg) {
 		$msg = NULL;
@@ -47,12 +46,12 @@ if (isset($_GET["cmd"])) {
 			$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
@@ -69,7 +68,7 @@ if (isset($_GET["cmd"])) {
 	if (in_array("flush", $opts_array)) {
 		return;
 	}
-	
+
 	$rsp = array();
 
 	// webrun pping and gangliastatus output needs special handling
@@ -92,17 +91,16 @@ if (isset($_GET["cmd"])) {
 			foreach ($child->children() as $data) {
 				if($data->name) {
 					$node = $data->name;
-					
+
 					if($data->data->contents){
 						$cont = $data->data->contents;
-					}
-					else{
+					} else {
 						$cont = $data->data;
 					}
-					
+
 					$cont = str_replace(":|:", "\n", $cont);
 					array_push($rsp, "$node: $cont");
-				} else if(strlen("$data") > 2) {
+				} else if (strlen("$data") > 2) {
 					$data = str_replace(":|:", "\n", $data);
 					array_push($rsp, "$data");
 				}
@@ -118,8 +116,8 @@ if (isset($_GET["cmd"])) {
 /**
  * Extract the output for a webrun command
  *
- * @param	$xml 	The XML output from docmd()
- * @return 	An array containing the output
+ * @param $xml    The XML output from docmd()
+ * @return An array containing the output
  */
 function extractWebrun($xml) {
 	$rsp = array();
@@ -130,7 +128,7 @@ function extractWebrun($xml) {
 		foreach($nodes->children() as $node){
 			// Get the node name
 			$name = $node->name;
-			
+
 			// Get the content
 			$status = $node->data;
 			$status = str_replace(":|:", "\n", $status);
@@ -147,8 +145,8 @@ function extractWebrun($xml) {
 /**
  * Extract the output for a nodels command
  *
- * @param	$xml 	The XML output from docmd()
- * @return 	An array containing the output
+ * @param $xml    The XML output from docmd()
+ * @return An array containing the output
  */
 function extractNodels($xml) {
 	$rsp = array();
@@ -176,8 +174,8 @@ function extractNodels($xml) {
 /**
  * Extract the output for a extnoderange command
  *
- * @param 	$xml 	The XML output from docmd()
- * @return 	The nodes and groups
+ * @param $xml    The XML output from docmd()
+ * @return The nodes and groups
  */
 function extractExtnoderange($xml) {
 	$rsp = array();
diff --git a/xCAT-UI/lib/srv_functions.php b/xCAT-UI/lib/srv_functions.php
index 624db7687..c18a336fb 100644
--- a/xCAT-UI/lib/srv_functions.php
+++ b/xCAT-UI/lib/srv_functions.php
@@ -5,7 +5,7 @@
 
 // Retain session variables across page requests
 session_start();
-session_write_close();	// Do not block HTTP requests
+session_write_close();    // Do not block HTTP requests
 
 // The settings below display error on the screen,
 // instead of giving blank pages.
@@ -15,310 +15,286 @@ 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
+ * @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);
-	}
+    // 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);
-		}
-	}
+    // 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());
+    // 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;
+    $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
+ * @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);
+    $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 style="font-size: 10px;">' . $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();
+    // 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 style="font-size: 10px;">' . $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>/'; }
+                $response = "<xcat>$response</xcat>";
+                $response = preg_replace('/>\n\s*</', '><', $response);
+                $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;
+    // 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);
+        } else if (!$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]));
-	}
+    $datalen = strlen($data);
+    $keylen = strlen($key);
+    for ($i=0;$i<$datalen;$i++) {
+        $data[$i] = chr(ord($data[$i])^ord($key[$i]));
+    }
 
-	return $data;
+    return $data;
 }
 
 /**
  * Get RAND characters
  *
- * @param 	$length		Length of characters
- * @return 	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);
-	}
+    $charset = '0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*';
+    $charsize = strlen($charset);
+    srand();
+    $chars = '';
+    for ($i=0;$i<$length;$i++) {
+        $num=rand()%$charsize;
+        $chars=$chars.substr($charset,$num,1);
+    }
 
-	return $chars;
+    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();
+    // 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;
-	}
+    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));
+    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.
+ * 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
+ * @param $password    Password
  */
 function setpassword($password) {
-	$randlen = strlen($password);
-	$key = getrandchars($randlen);
-	$cryptext = xorcrypt($password,$key);
+    $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;
+    // 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
+ * @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;
-	}
+    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
+ *
+ * @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 (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;
-	}
+    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,'/');
-	}
+    // 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,"/");
-	}
+    // Expire session cookie
+    if (isset($_COOKIE[session_name()])) {
+        setcookie(session_name(),"",time()-86400*7,"/");
+    }
 
-	// Clear server store of data
-	$_SESSION=array();
+    // Clear server store of data
+    $_SESSION=array();
 }
 ?>
diff --git a/xCAT-UI/lib/srv_log.php b/xCAT-UI/lib/srv_log.php
index 5a9f3bccc..31106b9aa 100644
--- a/xCAT-UI/lib/srv_log.php
+++ b/xCAT-UI/lib/srv_log.php
@@ -11,29 +11,29 @@ header("Cache-Control: post-check=0, pre-check=0", false);
 header("Pragma: no-cache");
 
 if (isset($_REQUEST["password"])) {
-	// Clear data from session
-	$_SESSION = array();
+    // Clear data from session
+    $_SESSION = array();
 
-	// Zap existing session entirely
-	session_regenerate_id(true);
-	setpassword($_REQUEST["password"]);
+    // Zap existing session entirely
+    session_regenerate_id(true);
+    setpassword($_REQUEST["password"]);
 
-	// Invalid password
-	$_SESSION["srv_xcatpassvalid"] = -1;
+    // Invalid password
+    $_SESSION["srv_xcatpassvalid"] = -1;
 }
 
 if (isset($_REQUEST["username"])) {
-	$_SESSION["srv_username"] = $_REQUEST["username"];
+    $_SESSION["srv_username"] = $_REQUEST["username"];
 
-	// Invalid user name
-	$_SESSION["srv_xcatpassvalid"]=-1;
+    // Invalid user name
+    $_SESSION["srv_xcatpassvalid"]=-1;
 }
 
 $jdata = array();
 if (isAuthenticated()) {
-	$jdata["authenticated"]="yes";
+    $jdata["authenticated"]="yes";
 } else {
-	$jdata["authenticated"]="no";
+    $jdata["authenticated"]="no";
 }
 
 echo json_encode($jdata);
diff --git a/xCAT-UI/lib/systemcmd.php b/xCAT-UI/lib/systemcmd.php
index 469551789..7990aa035 100644
--- a/xCAT-UI/lib/systemcmd.php
+++ b/xCAT-UI/lib/systemcmd.php
@@ -7,30 +7,30 @@ require_once "$TOPDIR/lib/jsonwrapper.php";
 /**
  * This will handle system commands, e.g. rpm -qa xCAT
  *
- * @param 	$cmd	The system command
- * @return 	The system response.  Replies are in the form of JSON
+ * @param $cmd    The system command
+ * @return The system response.  Replies are in the form of JSON
  */
 if (!isAuthenticated()) {
-	echo ("<b>Please login before continuing!</b>");
-	exit;
+    echo ("<b>Please login before continuing!</b>");
+    exit;
 }
 
 if (isset($_GET["cmd"])) {
-	// HTTP GET requests
-	$cmd = $_GET["cmd"];
-	$msg = NULL;
-	$ret = "";
+    // HTTP GET requests
+    $cmd = $_GET["cmd"];
+    $msg = NULL;
+    $ret = "";
 
-	if (isset($_GET["msg"])) {
-		$msg = $_GET["msg"];
-	}
-	
-	if ($cmd == "ostype") {
-		$ret = strtolower(PHP_OS);
-	} else {
-		$ret = shell_exec($cmd);
-	}
+    if (isset($_GET["msg"])) {
+        $msg = $_GET["msg"];
+    }
+    
+    if ($cmd == "ostype") {
+        $ret = strtolower(PHP_OS);
+    } else {
+        $ret = shell_exec($cmd);
+    }
 
-	echo json_encode(array("rsp"=>$ret, "msg" => $msg));
+    echo json_encode(array("rsp"=>$ret, "msg" => $msg));
 }
 ?>
\ No newline at end of file
diff --git a/xCAT-UI/lib/tabRestore.php b/xCAT-UI/lib/tabRestore.php
index 79fafd6b8..4d3e960dc 100644
--- a/xCAT-UI/lib/tabRestore.php
+++ b/xCAT-UI/lib/tabRestore.php
@@ -7,8 +7,8 @@ require_once "$TOPDIR/lib/jsonwrapper.php";
 /**
  * Replace the contents of an xCAT table
  *
- * @param 	$tab	The xCAT table
- * @param	$cont	The xCAT table contents
+ * @param $tab     The xCAT table
+ * @param $cont    The xCAT table contents
  * @return The xCAT response.  Replies are in the form of JSON
  */
 if (isset($_POST["table"])) {
@@ -24,7 +24,7 @@ $request = simplexml_load_string('<xcatrequest></xcatrequest>');
 $request->addChild('command', 'tabrestore');
 
 // Setup authentication
-$usernode=$request->addChild('becomeuser');
+$usernode = $request->addChild('becomeuser');
 $usernode->addChild('username', $_SESSION["username"]);
 $usernode->addChild('password', getpassword());
 
@@ -43,7 +43,7 @@ foreach($cont as $line){
 	}
 
 	// Go through each column
-	foreach($line as &$col){
+	foreach ($line as &$col){
 		// If the column does begins and end with a quote
 		// Change quotes to &quot;
 		if(!empty($col) && !preg_match('/^".*"$/', $col)) {
@@ -55,9 +55,11 @@ foreach($cont as $line){
 	ksort($line, SORT_NUMERIC);
 	$keys = array_keys($line);
 	$max = count($line) - 1;
-	if($keys[$max] != $max){
+	if ($keys[$max] != $max){
 		for ($i = 0; $i <= $keys[$max]; $i++) {
-			if (!isset($line[$i])) {$line[$i]='';}
+			if (!isset($line[$i])) {
+				$line[$i]='';
+			}
 		}
 		ksort($line, SORT_NUMERIC);
 	}
diff --git a/xCAT-UI/lib/ui.php b/xCAT-UI/lib/ui.php
index 163785eb8..c45b83a26 100644
--- a/xCAT-UI/lib/ui.php
+++ b/xCAT-UI/lib/ui.php
@@ -1,96 +1,87 @@
 <?php
 /**
  * Load page
- *
- * @param 	Nothing
- * @return 	Nothing
  */
 function loadPage() {
-	// Include CSS and Javascripts
-	echo
-	'<html>
-		<head>
-			<title>xCAT</title>
-			<link rel="shortcut icon" href="images/favicon.ico">
-			<link href="css/login.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/jquery/jquery.cookie.min.js"></script>
-			<script type="text/javascript" src="js/ui.js"></script>			
-		</head>';
+    // Include CSS and Javascripts
+    echo
+    '<html>
+        <head>
+            <title>xCAT</title>
+            <link rel="shortcut icon" href="images/favicon.ico">
+            <link href="css/login.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/jquery/jquery.cookie.min.js"></script>
+            <script type="text/javascript" src="js/ui.js"></script>            
+        </head>';
 
-	// Header menu
-	echo
-	'<body>
-		<div id="header">
-			<ul>
-				<li><img src="images/logo.gif" height="39px" style="margin-right: 60px;"/></li>	
-				<li><a href="index.php" class="top_link">Nodes</a></li>		
-				<li><a href="configure.php" class="top_link">Configure</a></li>
-				<li><a href="provision.php" class="top_link">Provision</a></li>
-				<li><a href="monitor.php" class="top_link">Monitor</a></li>
-				<li><a href="help.php" class="top_link">Help</a></li>
-			</ul>';
-			
-	// User name and log out section
-	if (isset($_SESSION['username'])){
-		echo 
-			"<div>
-				<span id='login_user' style='padding: 0 6px; font-weight: bold;'>{$_SESSION['username']}</span> | <a id='xcat_settings'>Settings</a> | <a href='lib/logout.php'>Log out</a>
-			</div>";
-	}
+    // Header menu
+    echo
+    '<body>
+        <div id="header">
+            <ul>
+                <li><img src="images/logo.gif" height="39px" style="margin-right: 60px;"/></li>    
+                <li><a href="index.php" class="top_link">Nodes</a></li>        
+                <li><a href="configure.php" class="top_link">Configure</a></li>
+                <li><a href="provision.php" class="top_link">Provision</a></li>
+                <li><a href="monitor.php" class="top_link">Monitor</a></li>
+                <li><a href="help.php" class="top_link">Help</a></li>
+            </ul>';
+            
+    // User name and log out section
+    if (isset($_SESSION['username'])){
+        echo 
+            "<div>
+                <span id='login_user' style='padding: 0 6px; font-weight: bold;'>{$_SESSION['username']}</span> | <a id='xcat_settings'>Settings</a> | <a href='lib/logout.php'>Log out</a>
+            </div>";
+    }
 
-	echo '</div>';
-	// Content
-	echo '<div class="content" id="content"></div>';
+    echo '</div>';
+    // Content
+    echo '<div class="content" id="content"></div>';
 
-	// End of page
-	echo
-		'</body>
-	</html>';
+    // End of page
+    echo
+        '</body>
+    </html>';
 }
 
 /**
  * Load page content
- *
- * @param 	Nothing
- * @return 	Nothing
  */
 function loadContent() {
-	// Initialize page
-	echo
-	'<script language="JavaScript" type="text/javascript"> 
-		$(document).ready(function() {
-			initPage();
-		}); 
-	</script>';
+    // Initialize page
+    echo
+    '<script language="JavaScript" type="text/javascript"> 
+        $(document).ready(function() {
+            initPage();
+        }); 
+    </script>';
 }
 
 /**
  * Login user into a new session
- *
- * @param 	Nothing
- * @return 	Nothing
  */
 function login() {
-	// 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/xcatauth.js" type="text/javascript"></script>
-	<div id="login">
-		<div id="login_form">
-			<table>
-				<tr><td colspan=5></td></tr>
-			    <tr><td align=right><img src="images/logo.png" width="50" height="35"></img></td><td colspan=4 style="font-size: 18px;">eXtreme Cloud Administration Toolkit</td></tr>
-			    <tr><td colspan=5></td></tr>
-				<tr><td></td><td><label for=username>User name:</label></td><td colspan=2><input type=text name=username></td><td></td></tr>
-				<tr><td></td><td><label for=password>Password:</label></td><td colspan=2><input type=password name=password></td><td></td></tr>
-				<tr><td></td><td></td><td></td><td align=right><button style="padding: 5px;">Login</button></td><td></td></tr>
-				<tr><td></td><td colspan=4><span id=login_status></span></td></tr>
-			</table>
-		</div>
-		<div id="loginfo">Open Source. EPL License.</div>
-	</div>';
+    // 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/xcatauth.js" type="text/javascript"></script>
+    <div id="login">
+        <div id="login-form">
+            <table>
+                <tr><td colspan=5></td></tr>
+                <tr><td align=right><img src="images/logo.png" width="50" height="35"></img></td><td colspan=4 style="font-size: 18px;">eXtreme Cloud Administration Toolkit</td></tr>
+                <tr><td colspan=5></td></tr>
+                <tr><td></td><td><label for=username>User name:</label></td><td colspan=2><input type=text name=username></td><td></td></tr>
+                <tr><td></td><td><label for=password>Password:</label></td><td colspan=2><input type=password name=password></td><td></td></tr>
+                <tr><td></td><td></td><td></td><td align=right><button style="padding: 5px;">Login</button></td><td></td></tr>
+                <tr><td></td><td colspan=4><span id=login-status></span></td></tr>
+            </table>
+        </div>
+        <div id="log-info">Open Source. EPL License.</div>
+    </div>';
 }
 ?>
\ No newline at end of file
diff --git a/xCAT-UI/lib/upload.php b/xCAT-UI/lib/upload.php
index 2f33fc940..983fa30a1 100644
--- a/xCAT-UI/lib/upload.php
+++ b/xCAT-UI/lib/upload.php
@@ -4,26 +4,26 @@
  */
 $type = $_FILES["file"]["type"];
 if ($type == "text/plain" || $type == "application/octet-stream" || $type == "application/x-shellscript" || $type == "application/x-sh") {
-	$error = $_FILES["file"]["error"];
-	if ($error) {
-		echo "Return Code: " . $error;
-	} else {
-		$file = $_FILES["file"]["name"];
-		$path = "/var/tmp/" . $file;
-		move_uploaded_file($_FILES["file"]["tmp_name"], $path);
+    $error = $_FILES["file"]["error"];
+    if ($error) {
+        echo "Return Code: " . $error;
+    } else {
+        $file = $_FILES["file"]["name"];
+        $path = "/var/tmp/" . $file;
+        move_uploaded_file($_FILES["file"]["tmp_name"], $path);
 
-		// Open and read given file
-		$handler = fopen($path, "r");
-		$data = fread($handler, filesize($path));
-		fclose($handler);
+        // Open and read given file
+        $handler = fopen($path, "r");
+        $data = fread($handler, filesize($path));
+        fclose($handler);
 
-		// Print out file contents
-		echo $data;
+        // Print out file contents
+        echo $data;
 
-		// Remove this file
-		unlink($path);
-	}
+        // Remove this file
+        unlink($path);
+    }
 } else {
-	echo "(Error) File type $type not supported";
+    echo "(Error) File type $type not supported";
 }
 ?>
\ No newline at end of file
diff --git a/xCAT-UI/lib/zCmd.php b/xCAT-UI/lib/zCmd.php
index 24c6dcf32..706248268 100644
--- a/xCAT-UI/lib/zCmd.php
+++ b/xCAT-UI/lib/zCmd.php
@@ -7,9 +7,9 @@ require_once "$TOPDIR/lib/jsonwrapper.php";
 /**
  * Issue an xCAT command (only for z)
  *
- * @param 	$cmd	The xCAT command
- * @param	$tgt	The target node or group
- * @param	$args	The xCAT command arguments, separated by semicolons
+ * @param $cmd     The xCAT command
+ * @param $tgt     The target node or group
+ * @param $args    The xCAT command arguments, separated by semicolons
  * @return The xCAT response.  Replies are in the form of JSON
  */
 if (isset($_GET["cmd"])) {
@@ -56,7 +56,7 @@ if (isset($_GET["cmd"])) {
 	$rsp = array();
 
 	// Replace user entry
-	if(strncasecmp($cmd, "chvm", 4) == 0 && strncasecmp($arr[0], "--replacevs", 11) == 0) {
+	if (strncasecmp($cmd, "chvm", 4) == 0 && strncasecmp($arr[0], "--replacevs", 11) == 0) {
 		// Directory /var/tmp permissions = 777
 		// You can write anything to that directory
 		$userEntry = "/var/tmp/$tgt.txt";
@@ -77,7 +77,7 @@ if (isset($_GET["cmd"])) {
 	}
 
 	// Create virtual server
-	else if(strncasecmp($cmd, "mkvm", 4) == 0) {
+	else if (strncasecmp($cmd, "mkvm", 4) == 0) {
 		// Directory /var/tmp permissions = 777
 		// You can write anything to that directory
 		$userEntry = "/var/tmp/$tgt.txt";
diff --git a/xCAT-UI/monitor.php b/xCAT-UI/monitor.php
index db1637792..29010ad74 100644
--- a/xCAT-UI/monitor.php
+++ b/xCAT-UI/monitor.php
@@ -10,8 +10,8 @@ loadPage();
 
 /* Login user */
 if (!isAuthenticated()) {
-	login();
+    login();
 } else {
-	loadContent();
+    loadContent();
 }
 ?>
\ No newline at end of file
diff --git a/xCAT-UI/provision.php b/xCAT-UI/provision.php
index 8e12c5609..ef494bee5 100644
--- a/xCAT-UI/provision.php
+++ b/xCAT-UI/provision.php
@@ -10,8 +10,8 @@ loadPage();
 
 /* Login user */
 if (!isAuthenticated()) {
-	login();
+    login();
 } else {
-	loadContent();
+    loadContent();
 }
 ?>
\ No newline at end of file
diff --git a/xCAT-UI/rcons.php b/xCAT-UI/rcons.php
index 67877ba02..a18102ff4 100644
--- a/xCAT-UI/rcons.php
+++ b/xCAT-UI/rcons.php
@@ -1,21 +1,21 @@
 <?php
 echo <<<EEE
 <html>
-	<head>
-	    <title>{$_GET['rconsnd']}</title>
-	    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
-	    <link rel="stylesheet" type="text/css" href="css/ajaxterm.css"/>
-	    <script type="text/javascript" src="js/jquery/jquery.min.js"></script>
-	    <script type="text/javascript" src="js/rcons/rcons.js"></script>
-	    <script type="text/javascript">
-		    window.onload=function() {
-		        t=new rconsTerm("{$_GET['rconsnd']}", 80, 25);
-		    };
-	    </script>
-	</head>
-	<body>
-		<div id="term"></div>
-	</body>
+    <head>
+        <title>{$_GET['rconsnd']}</title>
+        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
+        <link rel="stylesheet" type="text/css" href="css/ajaxterm.css"/>
+        <script type="text/javascript" src="js/jquery/jquery.min.js"></script>
+        <script type="text/javascript" src="js/rcons/rcons.js"></script>
+        <script type="text/javascript">
+            window.onload=function() {
+                t=new rconsTerm("{$_GET['rconsnd']}", 80, 25);
+            };
+        </script>
+    </head>
+    <body>
+        <div id="term"></div>
+    </body>
 </html>
 EEE;
 ?>
diff --git a/xCAT-UI/service.php b/xCAT-UI/service.php
index 972ce6428..558d39f85 100644
--- a/xCAT-UI/service.php
+++ b/xCAT-UI/service.php
@@ -12,30 +12,30 @@ require_once "lib/jsonwrapper.php";
 // Include CSS and Javascripts
 echo
 '<html>
-	<head>
-		<title>xCAT Service Portal</title>
-		<link rel="shortcut icon" href="images/favicon.ico">
-		<link href="css/login.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/jquery/jquery.cookie.min.js"></script>
-		<script type="text/javascript" src="js/ui.js"></script>
-		<script type="text/javascript" src="js/service/service.js"></script>
-	</head>';
+    <head>
+        <title>xCAT Service Portal</title>
+        <link rel="shortcut icon" href="images/favicon.ico">
+        <link href="css/login.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/jquery/jquery.cookie.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>';
-		
+    <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='padding: 0 6px; color: white; font-weight: bold;'>{$_SESSION['srv_username']}</span> | <a id='xcat_settings'>Settings</a> | <a href='lib/srv_logout.php'>Log out</a>
-		</div>";
+    echo 
+        "<div>
+            <span style='padding: 0 6px; color: white; font-weight: bold;'>{$_SESSION['srv_username']}</span> | <a id='xcat_settings'>Settings</a> | <a href='lib/srv_logout.php'>Log out</a>
+        </div>";
 }
 
 echo '</div>';
@@ -45,35 +45,35 @@ echo '<div class="content" id="content"></div>';
 
 // End of page
 echo
-	'</body>
+    '</body>
 </html>';
 
 // Login user
 if (!isAuthenticated()) {
-	// xcatauth.js will open a dialog box asking for the user name and password
-	echo
-	'<script src="js/srv_xcatauth.js" type="text/javascript"></script>
-	<div id="login">
-		<div id="login_form">
-			<table>
-				<tr><td colspan=5></td></tr>
-			    <tr><td align=right><img src="images/logo.png" width="50" height="35"></img></td><td colspan=4 style="font-size: 18px;">eXtreme Cloud Administration Toolkit</td></tr>
-			    <tr><td colspan=5></td></tr>
-				<tr><td></td><td><label for=username>User name:</label></td><td colspan=2><input type=text name=username></td><td></td></tr>
-				<tr><td></td><td><label for=password>Password:</label></td><td colspan=2><input type=password name=password></td><td></td></tr>
-				<tr><td></td><td></td><td></td><td align=right><button style="padding: 5px;">Login</button></td><td></td></tr>
-				<tr><td></td><td colspan=4><span id=login_status></span></td></tr>
-			</table>
-		</div>
-		<div id="loginfo">Open Source. EPL License.</div>
-	</div>';
+    // xcatauth.js will open a dialog box asking for the user name and password
+    echo
+    '<script src="js/srv_xcatauth.js" type="text/javascript"></script>
+    <div id="login">
+        <div id="login-form">
+            <table>
+                <tr><td colspan=5></td></tr>
+                <tr><td align=right><img src="images/logo.png" width="50" height="35"></img></td><td colspan=4 style="font-size: 18px;">eXtreme Cloud Administration Toolkit</td></tr>
+                <tr><td colspan=5></td></tr>
+                <tr><td></td><td><label for=username>User name:</label></td><td colspan=2><input type=text name=username></td><td></td></tr>
+                <tr><td></td><td><label for=password>Password:</label></td><td colspan=2><input type=password name=password></td><td></td></tr>
+                <tr><td></td><td></td><td></td><td align=right><button style="padding: 5px;">Login</button></td><td></td></tr>
+                <tr><td></td><td colspan=4><span id=login-status></span></td></tr>
+            </table>
+        </div>
+        <div id="log-info">Open Source. EPL License.</div>
+    </div>';
 } else {
-	// Initialize page
-	echo
-	'<script language="JavaScript" type="text/javascript"> 
-		$(document).ready(function() {
-			initServicePage();
-		}); 
-	</script>';
+    // Initialize page
+    echo
+    '<script language="JavaScript" type="text/javascript"> 
+        $(document).ready(function() {
+            initServicePage();
+        }); 
+    </script>';
 }
 ?>
diff --git a/xCAT-UI/xCAT-UI.spec b/xCAT-UI/xCAT-UI.spec
index c36a82a3d..d16f9a1d4 100644
--- a/xCAT-UI/xCAT-UI.spec
+++ b/xCAT-UI/xCAT-UI.spec
@@ -120,7 +120,7 @@ ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/webportal
         echo "Installing xCAT-UI on AIX..."
     else
         echo ""
-        echo "Error! IBM HTTP Server is not installed or not installed in the default directory (/usr/IBM/HTTPServer/)."
+        echo "Error! IBM HTTP Server has not been installed or has not been installed in the default directory (/usr/IBM/HTTPServer/)."
         exit -1;
     fi
 %endif
diff --git a/xCAT-UI/xcat/plugins/web.pm b/xCAT-UI/xcat/plugins/web.pm
index 4c655f604..0d53789c8 100644
--- a/xCAT-UI/xcat/plugins/web.pm
+++ b/xCAT-UI/xcat/plugins/web.pm
@@ -21,1733 +21,1772 @@ use LWP::Simple;
 use xCAT::Table;
 use xCAT::NodeRange;
 require XML::Parser;
+
 sub handled_commands {
-	return { webrun => "web", };
+    return { webrun => "web" };
 }
 
 sub process_request {
-	my $request         = shift;
-	my $callback        = shift;
-	my $sub_req         = shift;
-	my %authorized_cmds = (
-		'update'        => \&web_update,
-		'lscondition'   => \&web_lscond,
-		'lsresponse'    => \&web_lsresp,
-		'lscondresp'    => \&web_lscondresp,
-		'mkcondresp'    => \&web_mkcondresp,
-		'startcondresp' => \&web_startcondresp,
-		'stopcondresp'  => \&web_stopcondresp,
-		'lsevent'       => \&web_lsevent,
-		'unlock'        => \&web_unlock,
-		'rmcstart'      => \&web_rmcmonStart,
-		'rmcshow'       => \&web_rmcmonShow,
-		'gangliaconf'   => \&web_gangliaconf,
-		'gangliastart'  => \&web_gangliastart,
-		'gangliastop'   => \&web_gangliastop,
-		'gangliastatus' => \&web_gangliastatus,
-		'gangliacheck'  => \&web_gangliacheck,
-		'installganglia'=> \&web_installganglia,
-		'mkcondition'   => \&web_mkcondition,
-		'monls'         => \&web_monls,
-		'dynamiciprange'=> \&web_dynamiciprange,
-		'discover'      => \&web_discover,
-		'updatevpd'     => \&web_updatevpd,
-		'writeconfigfile'=> \&web_writeconfigfile,
-		'createimage'   => \&web_createimage,
-        'provision'     => \&web_provision,
-        'summary'       => \&web_summary,
-	    'gangliashow'   => \&web_gangliaShow,
-	    'gangliacurrent' => \&web_gangliaLatest,
-	    'rinstall'	    => \&web_rinstall,
-        'addnode'      => \&web_addnode,
-		'graph'		    => \&web_graphinfo,
-		'getdefaultuserentry' => \&web_getdefaultuserentry,
-		'getzdiskinfo' => \&web_getzdiskinfo,
-		'passwd' => \&web_passwd,
-		'updateuser' => \&web_updateuser,
-		'deleteuser' => \&web_deleteuser,
-		'mkzprofile' => \&web_mkzprofile,
-		'rmzprofile' => \&web_rmzprofile,
-		'updateosimage' => \&web_updateosimage,
-		'rmosimage' => \&web_rmosimage,
-		'updategroup' => \&web_updategroup,
-		'rmgroup' => \&web_rmgroup
-	);
+    my $request         = shift;
+    my $callback        = shift;
+    my $sub_req         = shift;
+    my %authorized_cmds = (
+        'update'              => \&web_update,
+        'lscondition'         => \&web_lscond,
+        'lsresponse'          => \&web_lsresp,
+        'lscondresp'          => \&web_lscondresp,
+        'mkcondresp'          => \&web_mkcondresp,
+        'startcondresp'       => \&web_startcondresp,
+        'stopcondresp'        => \&web_stopcondresp,
+        'lsevent'             => \&web_lsevent,
+        'unlock'              => \&web_unlock,
+        'rmcstart'            => \&web_rmcmonStart,
+        'rmcshow'             => \&web_rmcmonShow,
+        'gangliaconf'         => \&web_gangliaconf,
+        'gangliastart'        => \&web_gangliastart,
+        'gangliastop'         => \&web_gangliastop,
+        'gangliastatus'       => \&web_gangliastatus,
+        'gangliacheck'        => \&web_gangliacheck,
+        'installganglia'      => \&web_installganglia,
+        'mkcondition'         => \&web_mkcondition,
+        'monls'               => \&web_monls,
+        'dynamiciprange'      => \&web_dynamiciprange,
+        'discover'            => \&web_discover,
+        'updatevpd'           => \&web_updatevpd,
+        'writeconfigfile'     => \&web_writeconfigfile,
+        'createimage'         => \&web_createimage,
+        'provision'           => \&web_provision,
+        'summary'             => \&web_summary,
+        'gangliashow'         => \&web_gangliaShow,
+        'gangliacurrent'      => \&web_gangliaLatest,
+        'rinstall'            => \&web_rinstall,
+        'addnode'             => \&web_addnode,
+        'graph'               => \&web_graphinfo,
+        'getdefaultuserentry' => \&web_getdefaultuserentry,
+        'getzdiskinfo'        => \&web_getzdiskinfo,
+        'passwd'              => \&web_passwd,
+        'updateuser'          => \&web_updateuser,
+        'deleteuser'          => \&web_deleteuser,
+        'mkzprofile'          => \&web_mkzprofile,
+        'rmzprofile'          => \&web_rmzprofile,
+        'updateosimage'       => \&web_updateosimage,
+        'rmosimage'           => \&web_rmosimage,
+        'updategroup'         => \&web_updategroup,
+        'rmgroup'             => \&web_rmgroup
+    );
 
-	#check whether the request is authorized or not
-	split ' ', $request->{arg}->[0];
-	my $cmd = $_[0];
-	if ( grep { $_ eq $cmd } keys %authorized_cmds ) {
-		my $func = $authorized_cmds{$cmd};
-		$func->( $request, $callback, $sub_req );
-	} else {
-		$callback->( { error => "$cmd is not authorized!\n", errorcode => [1] } );
-	}
+    # Check whether the request is authorized or not
+    split ' ', $request->{arg}->[0];
+    my $cmd = $_[0];
+    if ( grep { $_ eq $cmd } keys %authorized_cmds ) {
+        my $func = $authorized_cmds{$cmd};
+        $func->( $request, $callback, $sub_req );
+    }
+    else {
+        $callback->(
+            { error => "$cmd is not authorized!\n", errorcode => [1] } );
+    }
 }
 
 sub web_lsevent {
-	my ( $request, $callback, $sub_req ) = @_;
-	my @ret = `$request->{arg}->[0]`;
+    my ( $request, $callback, $sub_req ) = @_;
+    my @ret = `$request->{arg}->[0]`;
 
-	#please refer the manpage for the output format of "lsevent"
-	my $data   = [];
-	my $record = '';
-	my $i      = 0;
-	my $j      = 0;
+    # Please refer the manpage for the output format of lsevent
+    my $data   = [];
+    my $record = '';
+    my $i      = 0;
+    my $j      = 0;
 
-	foreach my $item (@ret) {
-		if ( $item ne "\n" ) {
-			chomp $item;
-			my ( $key, $value ) = split( "=", $item );
-			if ( $j < 2 ) {
-				$record .= $value . ';';
-			} else {
-				$record .= $value;
-			}
+    foreach my $item (@ret) {
+        if ( $item ne "\n" ) {
+            chomp $item;
+            my ( $key, $value ) = split( "=", $item );
+            if ( $j < 2 ) {
+                $record .= $value . ';';
+            }
+            else {
+                $record .= $value;
+            }
 
-			$j++;
-			if ( $j == 3 ) {
-				$i++;
-				$j = 0;
-				push( @$data, $record );
-				$record = '';
-			}
-		}
+            $j++;
+            if ( $j == 3 ) {
+                $i++;
+                $j = 0;
+                push( @$data, $record );
+                $record = '';
+            }
+        }
 
-	}
+    }
 
-	$callback->( { data => $data } );
+    $callback->( { data => $data } );
 }
 
 sub web_mkcondresp {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $conditionName = $request->{arg}->[1];
-	my $temp          = $request->{arg}->[2];
-	my $cmd           = '';
-	my @resp          = split( ':', $temp );
+    my ( $request, $callback, $sub_req ) = @_;
+    my $conditionName = $request->{arg}->[1];
+    my $temp          = $request->{arg}->[2];
+    my $cmd           = '';
+    my @resp          = split( ':', $temp );
 
-	#create new associations
-	if ( 1 < length( @resp[0] ) ) {
-		$cmd = substr( @resp[0], 1 );
-		$cmd =~ s/,/ /;
-		$cmd = 'mkcondresp ' . $conditionName . ' ' . $cmd;
-		my $retInfo = xCAT::Utils->runcmd( $cmd, -1, 1 );
-	}
+    # Create new associations
+    if ( 1 < length( @resp[0] ) ) {
+        $cmd = substr( @resp[0], 1 );
+        $cmd =~ s/,/ /;
+        $cmd = 'mkcondresp ' . $conditionName . ' ' . $cmd;
+        my $retInfo = xCAT::Utils->runcmd( $cmd, -1, 1 );
+    }
 
-	#delete old associations
-	if ( 1 < length( @resp[1] ) ) {
-		$cmd = substr( @resp[1], 1 );
-		$cmd =~ s/,/ /;
-		$cmd = 'rmcondresp ' . $conditionName . ' ' . $cmd;
-		my $retInfo = xCAT::Utils->runcmd( $cmd, -1, 1 );
-	}
+    # Delete old associations
+    if ( 1 < length( @resp[1] ) ) {
+        $cmd = substr( @resp[1], 1 );
+        $cmd =~ s/,/ /;
+        $cmd = 'rmcondresp ' . $conditionName . ' ' . $cmd;
+        my $retInfo = xCAT::Utils->runcmd( $cmd, -1, 1 );
+    }
 
-	#there's no output for "mkcondresp"
-	$cmd = 'startcondresp ' . $conditionName;
-	my $refInfo = xCAT::Utils->runcmd( $cmd, -1, 1 );
-	$callback->( { data => "Success." } );
+    # There is no output for mkcondresp
+    $cmd = 'startcondresp ' . $conditionName;
+    my $refInfo = xCAT::Utils->runcmd( $cmd, -1, 1 );
+    $callback->( { data => "Success." } );
 }
 
 sub web_startcondresp {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $conditionName = $request->{arg}->[1];
-	my $cmd           = 'startcondresp "' . $conditionName . '"';
-	my $retInfo       = xCAT::Utils->runcmd( $cmd, -1, 1 );
-	$callback->( { data => 'start monitor "' . $conditionName . '" Successful.' } );
+    my ( $request, $callback, $sub_req ) = @_;
+    my $conditionName = $request->{arg}->[1];
+    my $cmd           = 'startcondresp "' . $conditionName . '"';
+    my $retInfo       = xCAT::Utils->runcmd( $cmd, -1, 1 );
+    $callback->(
+        { data => 'start monitor "' . $conditionName . '" Successful.' } );
 }
 
 sub web_stopcondresp {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $conditionName = $request->{arg}->[1];
-	my $cmd           = 'stopcondresp "' . $conditionName . '"';
-	my $retInfo       = xCAT::Utils->runcmd( $cmd, -1, 1 );
-	$callback->( { data => 'stop monitor "' . $conditionName . '" Successful.' } );
+    my ( $request, $callback, $sub_req ) = @_;
+    my $conditionName = $request->{arg}->[1];
+    my $cmd           = 'stopcondresp "' . $conditionName . '"';
+    my $retInfo       = xCAT::Utils->runcmd( $cmd, -1, 1 );
+    $callback->(
+        { data => 'stop monitor "' . $conditionName . '" Successful.' } );
 }
 
 sub web_lscond {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $nodeRange = $request->{arg}->[1];
-	my $names     = '';
+    my ( $request, $callback, $sub_req ) = @_;
+    my $nodeRange = $request->{arg}->[1];
+    my $names     = '';
 
-	#list all the conditions on all lpars in this group
-	if ($nodeRange) {
-		my @nodes = xCAT::NodeRange::noderange($nodeRange);
-		my %tempHash;
-		my $nodeCount = @nodes;
+    # List all the conditions for all lpars in this group
+    if ($nodeRange) {
+        my @nodes = xCAT::NodeRange::noderange($nodeRange);
+        my %tempHash;
+        my $nodeCount = @nodes;
 
-		#no node in this group
-		if ( 1 > $nodeCount ) {
-			return;
-		}
+        # No node in this group
+        if ( 1 > $nodeCount ) {
+            return;
+        }
 
-		#no conditions return
-		my $tempCmd = 'lscondition -d :' . join( ',', @nodes );
-		my $retInfo = xCAT::Utils->runcmd( $tempCmd, -1, 1 );
-		if ( 1 > @$retInfo ) {
-			return;
-		}
+        # No conditions return
+        my $tempCmd = 'lscondition -d :' . join( ',', @nodes );
+        my $retInfo = xCAT::Utils->runcmd( $tempCmd, -1, 1 );
+        if ( 1 > @$retInfo ) {
+            return;
+        }
 
-		shift @$retInfo;
-		shift @$retInfo;
-		foreach my $line (@$retInfo) {
-			my @temp = split( ':', $line );
-			$tempHash{ @temp[0] }++;
-		}
+        shift @$retInfo;
+        shift @$retInfo;
+        foreach my $line (@$retInfo) {
+            my @temp = split( ':', $line );
+            $tempHash{ @temp[0] }++;
+        }
 
-		foreach my $name ( keys(%tempHash) ) {
-			if ( $nodeCount == $tempHash{$name} ) {
-				$names = $names . $name . ';';
-			}
-		}
-	}
+        foreach my $name ( keys(%tempHash) ) {
+            if ( $nodeCount == $tempHash{$name} ) {
+                $names = $names . $name . ';';
+            }
+        }
+    }
 
-	#only list the conditions on local.
-	else {
-		my $retInfo = xCAT::Utils->runcmd( 'lscondition -d', -1, 1 );
-		if ( 2 > @$retInfo ) {
-			return;
-		}
+    # Only list the conditions on local
+    else {
+        my $retInfo = xCAT::Utils->runcmd( 'lscondition -d', -1, 1 );
+        if ( 2 > @$retInfo ) {
+            return;
+        }
 
-		shift @$retInfo;
-		shift @$retInfo;
-		foreach my $line (@$retInfo) {
-			my @temp = split( ':', $line );
-			$names = $names . @temp[0] . ':' . substr( @temp[2], 1, 3 ) . ';';
-		}
-	}
+        shift @$retInfo;
+        shift @$retInfo;
+        foreach my $line (@$retInfo) {
+            my @temp = split( ':', $line );
+            $names = $names . @temp[0] . ':' . substr( @temp[2], 1, 3 ) . ';';
+        }
+    }
 
-	if ( '' eq $names ) {
-		return;
-	}
+    if ( '' eq $names ) {
+        return;
+    }
 
-	$names = substr( $names, 0, ( length($names) - 1 ) );
-	$callback->( { data => $names } );
+    $names = substr( $names, 0, ( length($names) - 1 ) );
+    $callback->( { data => $names } );
 }
 
 sub web_mkcondition {
-	my ( $request, $callback, $sub_req ) = @_;
+    my ( $request, $callback, $sub_req ) = @_;
 
-	if ( 'change' eq $request->{arg}->[1] ) {
-		my @nodes;
-		my $conditionName = $request->{arg}->[2];
-		my $groupName     = $request->{arg}->[3];
+    if ( 'change' eq $request->{arg}->[1] ) {
+        my @nodes;
+        my $conditionName = $request->{arg}->[2];
+        my $groupName     = $request->{arg}->[3];
 
-		my $retInfo = xCAT::Utils->runcmd( 'nodels ' . $groupName . " ppc.nodetype", -1, 1 );
-		foreach my $line (@$retInfo) {
-			my @temp = split( ':', $line );
-			if ( @temp[1] !~ /lpar/ ) {
-				$callback->( { data => 'Error : only the compute nodes\' group could select.' } );
-				return;
-			}
+        my $retInfo =
+          xCAT::Utils->runcmd( 'nodels ' . $groupName . " ppc.nodetype", -1,
+            1 );
+        foreach my $line (@$retInfo) {
+            my @temp = split( ':', $line );
+            if ( @temp[1] !~ /lpar/ ) {
+                $callback->(
+                    {
+                        data =>
+                          'Error : only the compute nodes\' group could select.'
+                    }
+                );
+                return;
+            }
 
-			push( @nodes, @temp[0] );
-		}
+            push( @nodes, @temp[0] );
+        }
 
-		xCAT::Utils->runcmd( 'chcondition -n ' + join( ',', @nodes ) + '-m m ' + $conditionName );
-		$callback->( { data => 'Change scope success.' } );
-	}
+        xCAT::Utils->runcmd( 'chcondition -n ' + join( ',', @nodes ) + '-m m ' +
+              $conditionName );
+        $callback->( { data => 'Change scope success.' } );
+    }
 
 }
 
 sub web_lsresp {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $names = '';
-	my @temp;
-	my $retInfo = xCAT::Utils->runcmd( 'lsresponse -d', -1, 1 );
+    my ( $request, $callback, $sub_req ) = @_;
+    my $names = '';
+    my @temp;
+    my $retInfo = xCAT::Utils->runcmd( 'lsresponse -d', -1, 1 );
 
-	shift @$retInfo;
-	shift @$retInfo;
-	foreach my $line (@$retInfo) {
-		@temp = split( ':', $line );
-		$names = $names . @temp[0] . ';';
-	}
+    shift @$retInfo;
+    shift @$retInfo;
+    foreach my $line (@$retInfo) {
+        @temp = split( ':', $line );
+        $names = $names . @temp[0] . ';';
+    }
 
-	$names = substr( $names, 0, ( length($names) - 1 ) );
-	$callback->( { data => $names } );
+    $names = substr( $names, 0, ( length($names) - 1 ) );
+    $callback->( { data => $names } );
 }
 
 sub web_lscondresp {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $names = '';
-	my @temp;
+    my ( $request, $callback, $sub_req ) = @_;
+    my $names = '';
+    my @temp;
 
-	#if there is condition name, then we only show the condition linked associations.
-	if ( $request->{arg}->[1] ) {
-		my $cmd = 'lscondresp -d ' . $request->{arg}->[1];
-		my $retInfo = xCAT::Utils->runcmd( $cmd, -1, 1 );
-		if ( 2 > @$retInfo ) {
-			$callback->( { data => '' } );
-			return;
-		}
+    # If there is a condition name, then we only show the condition linked associations
+    if ( $request->{arg}->[1] ) {
+        my $cmd = 'lscondresp -d ' . $request->{arg}->[1];
+        my $retInfo = xCAT::Utils->runcmd( $cmd, -1, 1 );
+        if ( 2 > @$retInfo ) {
+            $callback->( { data => '' } );
+            return;
+        }
 
-		shift @$retInfo;
-		shift @$retInfo;
-		for my $line (@$retInfo) {
-			@temp = split( ':', $line );
-			$names = $names . @temp[1] . ';';
-		}
-	}
+        shift @$retInfo;
+        shift @$retInfo;
+        for my $line (@$retInfo) {
+            @temp = split( ':', $line );
+            $names = $names . @temp[1] . ';';
+        }
+    }
 
-	$names = substr( $names, 0, ( length($names) - 1 ) );
-	$callback->( { data => $names } );
+    $names = substr( $names, 0, ( length($names) - 1 ) );
+    $callback->( { data => $names } );
 }
 
 sub web_update {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $os         = "unknow";
-	my $RpmNames   = $request->{arg}->[1];
-	my $repository = $request->{arg}->[2];
-	my $FileHandle;
-	my $cmd;
-	my $ReturnInfo;
-	my $WebpageContent    = undef;
-	my $RemoteRpmFilePath = undef;
-	my $LocalRpmFilePath  = undef;
+    my ( $request, $callback, $sub_req ) = @_;
+    my $os         = "unknown";
+    my $rpmNames   = $request->{arg}->[1];
+    my $repository = $request->{arg}->[2];
+    my $fileHandle;
+    my $cmd;
+    my $returnInfo;
+    my $webpageContent    = undef;
+    my $remoteRpmFilePath = undef;
+    my $localRpmFilePath  = undef;
 
-	if ( xCAT::Utils->isLinux() ) {
-		$os = xCAT::Utils->osver();
+    if ( xCAT::Utils->isLinux() ) {
+        $os = xCAT::Utils->osver();
 
-		#suse linux
-		if ( $os =~ /sles.*/ ) {
-			$RpmNames =~ s/,/ /g;
+        # SUSE Linux
+        if ( $os =~ /sles.*/ ) {
+            $rpmNames =~ s/,/ /g;
 
-			#create zypper command
-			$cmd = "zypper -n -p " . $repository . " update " . $RpmNames;
-		}
+            # Create zypper command
+            $cmd = "zypper -n -p " . $repository . " update " . $rpmNames;
+        }
 
-		#redhat
-		else {
+        # Red Hat
+        else {
 
-			#check the yum config file, and delect it if exist.
-			if ( -e "/tmp/xCAT_update.yum.conf" ) {
-				unlink("/tmp/xCAT_update.yum.conf");
-			}
+            # Check the yum config file, and detect if it exists
+            if ( -e "/tmp/xCAT_update.yum.conf" ) {
+                unlink("/tmp/xCAT_update.yum.conf");
+            }
 
-			#create file, return error if failed.
-			unless ( open( $FileHandle, '>>', "/tmp/xCAT_update.yum.conf" ) ) {
-				$callback->( { error => "Create temp file error!\n", errorcode => [1] } );
-				return;
-			}
+            # Create file, return error if failed
+            unless ( open( $fileHandle, '>>', "/tmp/xCAT_update.yum.conf" ) ) {
+                $callback->(
+                    { error => "Created temp file error!\n", errorcode => [1] }
+                );
+                return;
+            }
 
-			#write the rpm path into config file.
-			print $FileHandle "[xcat_temp_update]\n";
-			print $FileHandle "name=temp prepository\n";
-			$repository = "baseurl=" . $repository . "\n";
-			print $FileHandle $repository;
-			print $FileHandle "enabled=1\n";
-			print $FileHandle "gpgcheck=0\n";
-			close($FileHandle);
+            # Write the RPM path into config file
+            print $fileHandle "[xcat_temp_update]\n";
+            print $fileHandle "name=temp prepository\n";
+            $repository = "baseurl=" . $repository . "\n";
+            print $fileHandle $repository;
+            print $fileHandle "enabled=1\n";
+            print $fileHandle "gpgcheck=0\n";
+            close($fileHandle);
 
-			#use system to run the cmd "yum -y -c config-file update rpm-names"
-			$RpmNames =~ s/,/ /g;
-			$cmd = "yum -y -c /tmp/xCAT_update.yum.conf update " . $RpmNames . " 2>&1";
-		}
+            # Use system to run the command: yum -y -c config-file update rpm-names
+            $rpmNames =~ s/,/ /g;
+            $cmd = "yum -y -c /tmp/xCAT_update.yum.conf update " . $rpmNames . " 2>&1";
+        }
 
-		#run the command and return the result
-		$ReturnInfo = readpipe($cmd);
-		$callback->( { info => $ReturnInfo } );
-	}
+        # Run the command and return the result
+        $returnInfo = readpipe($cmd);
+        $callback->( { info => $returnInfo } );
+    }
 
-	#AIX
-	else {
+    # AIX
+    else {
 
-		#open the rpmpath(may be error), and read the page's content
-		$WebpageContent = LWP::Simple::get($repository);
-		unless ( defined($WebpageContent) ) {
-			$callback->( { error => "open $repository error, please check!!", errorcode => [1] } );
-			return;
-		}
+        # Open the RPM path and read the page's content
+        $webpageContent = LWP::Simple::get($repository);
+        unless ( defined($webpageContent) ) {
+            $callback->({
+                    error     => "open $repository error, please check!!",
+                    errorcode => [1]
+                });
+            return;
+        }
 
-		#must support for updating several rpms.
-		foreach ( split( /,/, $RpmNames ) ) {
+        # Must support updating several RPM
+        foreach ( split( /,/, $rpmNames ) ) {
 
-			#find out rpms' corresponding rpm href on the web page
-			$WebpageContent =~ m/href="($_-.*?[ppc64|noarch].rpm)/i;
-			unless ( defined($1) ) {
-				next;
-			}
-			$RemoteRpmFilePath = $repository . $1;
-			$LocalRpmFilePath  = '/tmp/' . $1;
+            # Find out RPMs corresponding RPM HREF on the web page
+            $webpageContent =~ m/href="($_-.*?[ppc64|noarch].rpm)/i;
+            unless ( defined($1) ) {
+                next;
+            }
+            $remoteRpmFilePath = $repository . $1;
+            $localRpmFilePath  = '/tmp/' . $1;
 
-			#download rpm package to temp
-			unless ( -e $LocalRpmFilePath ) {
-				$cmd = "wget -O " . $LocalRpmFilePath . " " . $RemoteRpmFilePath;
-				if ( 0 != system($cmd) ) {
-					$ReturnInfo =
-					  $ReturnInfo . "update " . $_ . " failed: can not download the rpm\n";
-					$callback->( { error => $ReturnInfo, errorcode => [1] } );
-					return;
-				}
-			}
+            # Download RPM package to temp
+            unless ( -e $localRpmFilePath ) {
+                $cmd = "wget -O " . $localRpmFilePath . " " . $remoteRpmFilePath;
+                if ( 0 != system($cmd) ) {
+                    $returnInfo = $returnInfo . "update " . $_ . " failed: cannot download the RPM\n";
+                    $callback->( { error => $returnInfo, errorcode => [1] } );
+                    return;
+                }
+            }
 
-			#update rpm by rpm packages.
-			$cmd        = "rpm -U " . $LocalRpmFilePath . " 2>&1";
-			$ReturnInfo = $ReturnInfo . readpipe($cmd);
-		}
+            # Update RPM by RPM packages
+            $cmd        = "rpm -U " . $localRpmFilePath . " 2>&1";
+            $returnInfo = $returnInfo . readpipe($cmd);
+        }
 
-		$callback->( { info => $ReturnInfo } );
-	}
+        $callback->( { info => $returnInfo } );
+    }
 }
 
 sub web_unlock {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $node     = $request->{arg}->[1];
-	my $password = $request->{arg}->[2];
+    my ( $request, $callback, $sub_req ) = @_;
+    my $node     = $request->{arg}->[1];
+    my $password = $request->{arg}->[2];
 
-	# Unlock a node by setting up the SSH keys
-	my $out = `DSH_REMOTE_PASSWORD=$password xdsh $node -K`;
+    # Unlock a node by setting up the SSH keys
+    my $out = `DSH_REMOTE_PASSWORD=$password xdsh $node -K`;
 
-	$callback->( { data => $out } );
+    $callback->( { data => $out } );
 }
 
 sub web_gangliastatus {
-	my ( $request, $callback, $sub_req ) = @_;
+    my ( $request, $callback, $sub_req ) = @_;
 
-	# Get node range
-	my $nr  = $request->{arg}->[1];
-	my $out = `xdsh $nr "service gmond status"`;
+    # Get node range
+    my $nr  = $request->{arg}->[1];
+    my $out = `xdsh $nr "service gmond status"`;
 
-	# Parse output, and use $callback to send back to the web interface
-	# Output looks like:
-	# 	node_1: Checking for gmond: ..running
-	# 	node_2: Checking for gmond: ..running
-	my @lines = split( '\n', $out );
-	my $line;
-	my $status;
-	foreach $line (@lines) {
-		if ( $line =~ m/running/i ) {
-			$status = 'on';
-		} else {
-			$status = 'off';
-		}
+    # Parse output, and use $callback to send back to the web interface
+    # Output looks like:
+    #     node_1: Checking for gmond: ..running
+    #     node_2: Checking for gmond: ..running
+    my @lines = split( '\n', $out );
+    my $line;
+    my $status;
+    foreach $line (@lines) {
+        if ( $line =~ m/running/i ) {
+            $status = 'on';
+        }
+        else {
+            $status = 'off';
+        }
 
-		split( ': ', $line );
-		$callback->(
-			{
-				node => [
-					{
-						name => [ $_[0] ],    # Node name
-						data => [$status]     # Output
-					}
-				]
-			}
-		);
-	}
+        split( ': ', $line );
+        $callback->({
+            node => [{
+                    name => [ $_[0] ],    # Node name
+                    data => [$status]     # Output
+                }]
+        });
+    }
 }
 
 sub web_gangliaconf() {
-	my ( $request, $callback, $sub_req ) = @_;
+    my ( $request, $callback, $sub_req ) = @_;
 
-	# Get node range
-	my $nr = $request->{arg}->[1];
-	
-	my $info;
-	my $output;
-	
-	# Add gangliamon to the monitoring table (if not already)
-	$output = `monadd gangliamon`;
-	
-	# Run the ganglia configuration script on node
-	if ($nr) {
-		$output = `moncfg gangliamon $nr -r`;
-	} else {
-		# If no node range is given, then assume all nodes
-			
-		# Handle localhost (this needs to be 1st)
-		$output = `moncfg gangliamon`;
-		# Handle remote nodes
-		$output .= `moncfg gangliamon -r`;
-	}
+    # Get node range
+    my $nr = $request->{arg}->[1];
 
-	my @lines = split( '\n', $output );
-	foreach (@lines) {
-		if ($_) {
-			$info .= ( $_ . "\n" );
-		}
-	}
+    my $info;
+    my $output;
 
-	$callback->( { info => $info } );
-	return;
+    # Add gangliamon to the monitoring table (if not already)
+    $output = `monadd gangliamon`;
+
+    # Run the ganglia configuration script on node
+    if ($nr) {
+        $output = `moncfg gangliamon $nr -r`;
+    }
+    else {
+
+        # If no node range is given, then assume all nodes
+
+        # Handle localhost (this needs to be 1st)
+        $output = `moncfg gangliamon`;
+
+        # Handle remote nodes
+        $output .= `moncfg gangliamon -r`;
+    }
+
+    my @lines = split( '\n', $output );
+    foreach (@lines) {
+        if ($_) {
+            $info .= ( $_ . "\n" );
+        }
+    }
+
+    $callback->( { info => $info } );
+    return;
 }
 
 sub web_gangliastart() {
-	my ( $request, $callback, $sub_req ) = @_;
+    my ( $request, $callback, $sub_req ) = @_;
 
-	# Get node range
-	my $nr = $request->{arg}->[1];
+    # Get node range
+    my $nr = $request->{arg}->[1];
 
-	my $info;
-	my $output;
-	
-	# Add gangliamon to the monitoring table (if not already)
-	$output = `monadd gangliamon`;
-	
-	# Start the gmond daemon on node
-	if ($nr) {
-		$output = `moncfg gangliamon $nr -r`;
-		$output .= `monstart gangliamon $nr -r`;	
-	} else {
-		# If no node range is given, then assume all nodes
-		
-		# Handle localhost (this needs to be 1st)
-		$output = `moncfg gangliamon`;
-		# Handle remote nodes
-		$output .= `moncfg gangliamon -r`;
-		
-		# Handle localhost (this needs to be 1st)
-		$output .= `monstart gangliamon`;
-		# Handle remote nodes
-		$output .= `monstart gangliamon -r`;
-	}
-				
-	my @lines = split( '\n', $output );
-	foreach (@lines) {
-		if ($_) {
-			$info .= ( $_ . "\n" );
-		}
-	}
+    my $info;
+    my $output;
 
-	$callback->( { info => $info } );
-	return;
+    # Add gangliamon to the monitoring table (if not already)
+    $output = `monadd gangliamon`;
+
+    # Start the gmond daemon on node
+    if ($nr) {
+        $output = `moncfg gangliamon $nr -r`;
+        $output .= `monstart gangliamon $nr -r`;
+    }
+    else {
+
+        # If no node range is given, then assume all nodes
+
+        # Handle localhost (this needs to be 1st)
+        $output = `moncfg gangliamon`;
+
+        # Handle remote nodes
+        $output .= `moncfg gangliamon -r`;
+
+        # Handle localhost (this needs to be 1st)
+        $output .= `monstart gangliamon`;
+
+        # Handle remote nodes
+        $output .= `monstart gangliamon -r`;
+    }
+
+    my @lines = split( '\n', $output );
+    foreach (@lines) {
+        if ($_) {
+            $info .= ( $_ . "\n" );
+        }
+    }
+
+    $callback->( { info => $info } );
+    return;
 }
 
 sub web_gangliastop() {
-	my ( $request, $callback, $sub_req ) = @_;
+    my ( $request, $callback, $sub_req ) = @_;
 
-	# Get node range
-	my $nr = $request->{arg}->[1];
-	
-	my $info;
-	my $output;
-	
-	# Stop the gmond daemon on node
-	if ($nr) {
-		$output = `monstop gangliamon $nr -r`;	
-	} else {
-		# If no node range is given, then assume all nodes
-		
-		# Handle localhost (this needs to be 1st)
-		$output = `monstop gangliamon`;
-		# Handle remote nodes
-		$output .= `monstop gangliamon -r`;
-	}
-		
-	my @lines = split( '\n', $output );
-	foreach (@lines) {
-		if ($_) {
-			$info .= ( $_ . "\n" );
-		}
-	}
+    # Get node range
+    my $nr = $request->{arg}->[1];
 
-	$callback->( { info => $info } );
-	return;
+    my $info;
+    my $output;
+
+    # Stop the gmond daemon on node
+    if ($nr) {
+        $output = `monstop gangliamon $nr -r`;
+    }
+    else {
+
+        # If no node range is given, then assume all nodes
+
+        # Handle localhost (this needs to be 1st)
+        $output = `monstop gangliamon`;
+
+        # Handle remote nodes
+        $output .= `monstop gangliamon -r`;
+    }
+
+    my @lines = split( '\n', $output );
+    foreach (@lines) {
+        if ($_) {
+            $info .= ( $_ . "\n" );
+        }
+    }
+
+    $callback->( { info => $info } );
+    return;
 }
 
 sub web_gangliacheck() {
-	my ( $request, $callback, $sub_req ) = @_;
+    my ( $request, $callback, $sub_req ) = @_;
 
-	# Get node range
-	my $nr = $request->{arg}->[1];
-	if ( !$nr ) {
-		$nr = '';
-	}
+    # Get node range
+    my $nr = $request->{arg}->[1];
+    if ( !$nr ) {
+        $nr = '';
+    }
 
-	# Check if ganglia RPMs are installed
-	my $info;
-	my $info = `xdsh $nr "rpm -q ganglia-gmond libganglia libconfuse"`;
-	$callback->( { info => $info } );
-	return;
+    # Check if ganglia RPMs are installed
+    my $info;
+    my $info = `xdsh $nr "rpm -q ganglia-gmond libganglia libconfuse"`;
+    $callback->( { info => $info } );
+    return;
 }
 
 sub web_installganglia() {
-	my ( $request, $callback, $sub_req ) = @_;
+    my ( $request, $callback, $sub_req ) = @_;
+
+    # Get node range
+    my $nr    = $request->{arg}->[1];
+    my @nodes = split( ',', $nr );
+
+    # Loop through each node
+    my $info;
+    my $tab;
+    my $attrs;
+    my $osType;
+    my $dir;
+    my $pkglist;
+    my $defaultDir;
+
+    foreach (@nodes) {
+
+        # Get os, arch, profile, and provmethod
+        $tab   = xCAT::Table->new('nodetype');
+        $attrs =
+          $tab->getNodeAttribs( $_, [ 'os', 'arch', 'profile', 'provmethod' ] );
+
+        # If any attributes are missing, skip
+        if ( !$attrs->{'os'}
+	            || !$attrs->{'arch'}
+	            || !$attrs->{'profile'}
+	            || !$attrs->{'provmethod'} ){
+            $callback->({ info => "$_: (Error) Missing attribute (os, arch, profile, or provmethod) in nodetype table" });
+            next;
+        }
+
+        # Get the right OS type
+        if ( $attrs->{'os'} =~ /fedora/ ) {
+            $osType = 'fedora';
+        } elsif ($attrs->{'os'} =~ /rh/
+	            || $attrs->{'os'} =~ /rhel/
+	            || $attrs->{'os'} =~ /rhels/ ) {
+            $osType = 'rh';
+        } elsif ( $attrs->{'os'} =~ /sles/ ) {
+            $osType = 'sles';
+        }
 
-	# Get node range
-	my $nr = $request->{arg}->[1];
-	my @nodes = split( ',', $nr );
-	
-	# Loop through each node
-	my $info;
-	my $tab;
-	my $attrs;
-	my $osType;
-	my $dir;
-	my $pkglist;
-	my $defaultDir;
-	foreach (@nodes) {
-		# Get os, arch, profile, and provmethod
-		$tab = xCAT::Table->new('nodetype');
-		$attrs = $tab->getNodeAttribs( $_, ['os', 'arch', 'profile', 'provmethod'] );
-		
-		# If any attributes are missing, skip
-		if (!$attrs->{'os'} || !$attrs->{'arch'} || !$attrs->{'profile'} || !$attrs->{'provmethod'}) {
-			$callback->( { info => "$_: (Error) Missing attribute (os, arch, profile, or provmethod) in nodetype table" } );
-			next;
-		}
-		
-		# Get the right OS type
-		if ($attrs->{'os'} =~ /fedora/) {
-			$osType = 'fedora';
-		} elsif ($attrs->{'os'} =~ /rh/ || $attrs->{'os'} =~ /rhel/ || $attrs->{'os'} =~ /rhels/) {
-			$osType = 'rh';
-		} elsif ($attrs->{'os'} =~ /sles/) {
-			$osType = 'sles';
-		}
-		
 		# Assume /install/post/otherpkgs/<os>/<arch>/ directory is created
 		# If Ganglia RPMs (ganglia-gmond-*, libconfuse-*, and libganglia-*) are not in directory
-		$dir = "/install/post/otherpkgs/$attrs->{'os'}/$attrs->{'arch'}/";
-		if (!(`test -e $dir/ganglia-gmond-* && echo 'File exists'` &&
-			`test -e $dir/libconfuse-* && echo 'File exists'` &&
-			`test -e $dir/libganglia-* && echo 'File exists'`)) {
-			# Skip
-			$callback->( { info => "$_: (Error) Missing Ganglia RPMs under $dir" } );
-			next;
-		}
-					
-		# Find pkglist directory
-		$dir = "/install/custom/$attrs->{'provmethod'}/$osType";
-		if (!(`test -d $dir && echo 'Directory exists'`)) {
-			# Create pkglist directory
-			`mkdir -p $dir`;
-		}
-		
+        $dir = "/install/post/otherpkgs/$attrs->{'os'}/$attrs->{'arch'}/";
+        if (!( `test -e $dir/ganglia-gmond-* && echo 'File exists'`
+                && `test -e $dir/libconfuse-* && echo 'File exists'`
+                && `test -e $dir/libganglia-* && echo 'File exists'`
+            )) {
+
+            # Skip
+            $callback->({ info => "$_: (Error) Missing Ganglia RPMs under $dir" });
+            next;
+        }
+
+        # Find pkglist directory
+        $dir = "/install/custom/$attrs->{'provmethod'}/$osType";
+        if ( !(`test -d $dir && echo 'Directory exists'`) ) {
+            # Create pkglist directory
+            `mkdir -p $dir`;
+        }
+
 		# Find pkglist file
 		# Ganglia RPM names should be added to /install/custom/<inst_type>/<ostype>/<profile>.<os>.<arch>.otherpkgs.pkglist
-		$pkglist = "$attrs->{'profile'}.$attrs->{'os'}.$attrs->{'arch'}.otherpkgs.pkglist";
-		if (!(`test -e $dir/$pkglist && echo 'File exists'`)) {
-			# Copy default otherpkgs.pkglist
-			$defaultDir = "/opt/xcat/share/xcat/$attrs->{'provmethod'}/$osType";
-			if (`test -e $defaultDir/$pkglist && echo 'File exists'`) {
-				# Copy default pkglist
-				`cp $defaultDir/$pkglist $dir/$pkglist`;
-			} else {
-				# Create pkglist
-				`touch $dir/$pkglist`;
-			}
-			
-			# Add Ganglia RPMs to pkglist
-			`echo ganglia-gmond >> $dir/$pkglist`;
-			`echo libconfuse >> $dir/$pkglist`;
-			`echo libganglia >> $dir/$pkglist`;
-		}
+        $pkglist = "$attrs->{'profile'}.$attrs->{'os'}.$attrs->{'arch'}.otherpkgs.pkglist";
+        if ( !(`test -e $dir/$pkglist && echo 'File exists'`) ) {
 
-		# Check if libapr1 is installed
-		$info = `xdsh $_ "rpm -qa libapr1"`;
-		if (!($info =~ /libapr1/)) {
-			$callback->( { info => "$_: (Error) libapr1 package not installed" } );
-			next;
-		}
-		
-		# Install Ganglia RPMs using updatenode
-		$callback->( { info => "$_: Installing Ganglia..." } );
-		$info = `updatenode $_ -S`;
-		$callback->( { info => "$info" } );
-	}
-	
-	return;
+            # Copy default otherpkgs.pkglist
+            $defaultDir = "/opt/xcat/share/xcat/$attrs->{'provmethod'}/$osType";
+            if (`test -e $defaultDir/$pkglist && echo 'File exists'`) {
+
+                # Copy default pkglist
+                `cp $defaultDir/$pkglist $dir/$pkglist`;
+            } else {
+
+                # Create pkglist
+                `touch $dir/$pkglist`;
+            }
+
+            # Add Ganglia RPMs to pkglist
+            `echo ganglia-gmond >> $dir/$pkglist`;
+            `echo libconfuse >> $dir/$pkglist`;
+            `echo libganglia >> $dir/$pkglist`;
+        }
+
+        # Check if libapr1 is installed
+        $info = `xdsh $_ "rpm -qa libapr1"`;
+        if ( !( $info =~ /libapr1/ ) ) {
+            $callback->(
+                { info => "$_: (Error) libapr1 package not installed" } );
+            next;
+        }
+
+        # Install Ganglia RPMs using updatenode
+        $callback->( { info => "$_: Installing Ganglia..." } );
+        $info = `updatenode $_ -S`;
+        $callback->( { info => "$info" } );
+    }
+
+    return;
 }
 
-#get ganglia data from rrd file. 
-#args : 
-#	nodeRange : the nodes' name which want to get
-#	time range : which period want to get, like last hour, last day, last week .....
-#	metric : which monitor attribute want to get, like load_one, bytes_in, bytes_out ......
-#
-#output: (till now there are 6 metic to get at one time at most)
-#   metric1:timestamp1,value1,timestamp2,value2,.....;metric2:timestamp1,value1,timestamp2,value2,.....;....
-sub web_gangliaShow{
-	my ( $request, $callback, $sub_req ) = @_;
-	my $nodename = $request->{arg}->[1];
-	my $timeRange = 'now-1h';
-	my $resolution = 60;
-	my $metric = $request->{arg}->[3];
-	my @nodes = ();
-	my $retStr = '';
-	my $runInfo;
-	my $cmd = '';
-	my $dirname = '/var/lib/ganglia/rrds/__SummaryInfo__/';
-	#get the summary for this grid(the meaning of grid is referenced from ganglia )
-	if ('_grid_' ne $nodename){
-		$dirname = '/var/lib/ganglia/rrds/' . $nodename . '/';
-	}
-
-	if ('hour' eq $request->{arg}->[2]){
-		$timeRange = 'now-1h';
-		$resolution = 60;
-	}
-	elsif('day' eq $request->{arg}->[2]){
-		$timeRange = 'now-1d';
-		$resolution = 1800;
-	}
+sub web_gangliaShow {
+	# Get ganglia data from RRD file
 	
-	if ('_summary_' eq $metric){
-		my @metricArray = ('load_one', 'cpu_num', 'cpu_idle', 'mem_free', 'mem_total', 'disk_total', 'disk_free', 'bytes_in', 'bytes_out');
-		my $filename = '';
-		my $step = 1;
-		my $index = 0;
-		my $size = 0;
-		foreach my $tempmetric (@metricArray){
-			my $temp = '';
-			my $line = '';
-			$retStr .= $tempmetric . ':';
-			$filename = $dirname . $tempmetric . '.rrd';
-			$cmd = "rrdtool fetch $filename -s $timeRange -r $resolution AVERAGE";
-			$runInfo = xCAT::Utils->runcmd($cmd, -1, 1);
-			if (scalar(@$runInfo) < 3){
-				$callback->({data=>'error.'});
-				return;
-			}
-			#delete the first 2 lindes
-			shift(@$runInfo);
-			shift(@$runInfo);
+    my ( $request, $callback, $sub_req ) = @_;
+    my $nodename   = $request->{arg}->[1];
+    my $timeRange  = 'now-1h';
+    my $resolution = 60;
+    my $metric     = $request->{arg}->[3];
+    my @nodes      = ();
+    my $retStr     = '';
+    my $runInfo;
+    my $cmd     = '';
+    my $dirname = '/var/lib/ganglia/rrds/__SummaryInfo__/';
 
-			#we only support 60 lines for one metric, in order to reduce the data load for web gui
-			$size = scalar(@$runInfo);
-			if ($size > 60){
-				$step = int($size / 60) + 1;
-			}
-			
-			if (($tempmetric eq 'cpu_idle') && ('_grid_' eq $nodename)){
-				my $cpuidle = 0;
-				my $cpunum = 0;
-				for($index = 0; $index < $size; $index += $step){
-					if ($runInfo->[$index] =~ /^(\S+): (\S+) (\S+)/){
-						my $timestamp = $1;
-                        my $value = $2;
-                        my $valuenum = $3;
-						if ((lc($value) =~ /nanq/) || (lc($value) =~ /nan/)){
-							#the rrdtool fetch last outline line always nan, so no need to add into return string
-							if ($index == ($size - 1)){
-								next;
-							}
-							$temp .= $timestamp . ',0,';
-						}
-						else{
-							$cpuidle = sprintf "%.2f", $value;
-							$cpunum = sprintf "%.2f", $valuenum;
-							$temp .= $timestamp . ',' . (sprintf "%.2f", $cpuidle/$cpunum) . ',';
-						}
-					}
-				}
-			}
-			else{
-				for($index = 0; $index < $size; $index += $step){
-					if ($runInfo->[$index] =~ /^(\S+): (\S+).*/){
-						my $timestamp = $1;
-						my $value = $2;
-						if ((lc($value) =~ /nanq/) || (lc($value) =~ /nan/)){
-							#the rrdtool fetch last outline line always nan, so no need to add into return string
-							if ($index == ($size - 1)){
-								next;
-							}
-							$temp .= $timestamp . ',0,';
-						}
-						else{
-							$temp .= $timestamp . ',' . (sprintf "%.2f", $2) . ',';
-						}
-					}
-				}
-			}
-			$retStr .= substr($temp, 0, -1) . ';';
-		}
-		$retStr = substr($retStr, 0, -1);
-		$callback->({data=>$retStr});
-		return;
-	}
+    # Get the summary for this grid (the meaning of grid is referenced from Ganglia)
+    if ( '_grid_' ne $nodename ) {
+        $dirname = '/var/lib/ganglia/rrds/' . $nodename . '/';
+    }
+
+    if ( 'hour' eq $request->{arg}->[2] ) {
+        $timeRange  = 'now-1h';
+        $resolution = 60;
+    } elsif ( 'day' eq $request->{arg}->[2] ) {
+        $timeRange  = 'now-1d';
+        $resolution = 1800;
+    }
+
+    if ( '_summary_' eq $metric ) {
+        my @metricArray = (
+            'load_one',  'cpu_num',    'cpu_idle',  'mem_free',
+            'mem_total', 'disk_total', 'disk_free', 'bytes_in',
+            'bytes_out'
+        );
+        
+        my $filename = '';
+        my $step     = 1;
+        my $index    = 0;
+        my $size     = 0;
+        foreach my $tempmetric (@metricArray) {
+            my $temp = '';
+            my $line = '';
+            $retStr .= $tempmetric . ':';
+            $filename = $dirname . $tempmetric . '.rrd';
+            $cmd      = "rrdtool fetch $filename -s $timeRange -r $resolution AVERAGE";
+            $runInfo = xCAT::Utils->runcmd( $cmd, -1, 1 );
+            if ( scalar(@$runInfo) < 3 ) {
+                $callback->( { data => 'error.' } );
+                return;
+            }
+
+            # Delete the first 2 lines
+            shift(@$runInfo);
+            shift(@$runInfo);
+
+            # We only support 60 lines for one metric, in order to reduce the data load for web GUI
+            $size = scalar(@$runInfo);
+            if ( $size > 60 ) {
+                $step = int( $size / 60 ) + 1;
+            }
+
+            if ( ( $tempmetric eq 'cpu_idle' ) && ( '_grid_' eq $nodename ) ) {
+                my $cpuidle = 0;
+                my $cpunum  = 0;
+                for ( $index = 0 ; $index < $size ; $index += $step ) {
+                    if ( $runInfo->[$index] =~ /^(\S+): (\S+) (\S+)/ ) {
+                        my $timestamp = $1;
+                        my $value     = $2;
+                        my $valuenum  = $3;
+                        if (( lc($value) =~ /nanq/ ) || ( lc($value) =~ /nan/ )) {
+                            # The rrdtool fetch last line is always NaN, so no need to add into the return string
+                            if ( $index == ( $size - 1 ) ) {
+                                next;
+                            }
+                            
+                            $temp .= $timestamp . ',0,';
+                        } else {
+                            $cpuidle = sprintf "%.2f", $value;
+                            $cpunum  = sprintf "%.2f", $valuenum;
+                            $temp .= $timestamp . ',' . ( sprintf "%.2f", $cpuidle / $cpunum ) . ',';
+                        }
+                    }
+                }
+            } else {
+                for ( $index = 0 ; $index < $size ; $index += $step ) {
+                    if ( $runInfo->[$index] =~ /^(\S+): (\S+).*/ ) {
+                        my $timestamp = $1;
+                        my $value     = $2;
+                        if (( lc($value) =~ /nanq/ ) || ( lc($value) =~ /nan/ )) {
+                            # The rrdtool fetch last line is always NaN, so no need to add into the return string
+                            if ( $index == ( $size - 1 ) ) {
+                                next;
+                            }
+                            
+                            $temp .= $timestamp . ',0,';
+                        } else {
+                            $temp .= $timestamp . ',' . ( sprintf "%.2f", $2 ) . ',';
+                        }
+                    }
+                }
+            }
+            
+            $retStr .= substr( $temp, 0, -1 ) . ';';
+        }
+        
+        $retStr = substr( $retStr, 0, -1 );
+        $callback->( { data => $retStr } );
+        return;
+    }
 }
 
 my $ganglia_return_flag = 0;
 my %gangliaHash;
 my $gangliaclustername;
 my $ganglianodename;
-#use socket to connect ganglia port to get the latest value/status
-sub web_gangliaLatest{
-	my ( $request, $callback, $sub_req ) = @_;
-	my $type = $request->{arg}->[1];
-	my $groupname = '';
-	my $xmlparser;
-	my $telnetcmd = '';
-	my $connect;
-	my $xmloutput = '';
-	my $tmpFilename = '/tmp/gangliadata';
 
-	$ganglia_return_flag = 0;
-	$gangliaclustername = '';
-	$ganglianodename = '';
-	undef(%gangliaHash);
+sub web_gangliaLatest {
+	# Use socket to connect ganglia port to get the latest value/status
+	
+    my ( $request, $callback, $sub_req ) = @_;
+    my $type      = $request->{arg}->[1];
+    my $groupname = '';
+    my $xmlparser;
+    my $telnetcmd = '';
+    my $connect;
+    my $xmloutput   = '';
+    my $tmpFilename = '/tmp/gangliadata';
 
-	if($request->{arg}->[2]){
-		$groupname = $request->{arg}->[2];
-	}
-	if ('grid' eq $type){
-		$xmlparser = XML::Parser->new(Handlers=>{Start=>\&web_gangliaGridXmlStart, End=>\&web_gangliaXmlEnd});
-		$telnetcmd = "/?filter=summary\n";
-		$tmpFilename = '/tmp/gangliagriddata';
-	}
-	elsif('node' eq $type){
-		$xmlparser = XML::Parser->new(Handlers=>{Start=>\&web_gangliaNodeXmlStart, End=>\&web_gangliaXmlEnd});
-		$telnetcmd = "/\n";
-		$tmpFilename = '/tmp/ganglianodedata';
-	}
+    $ganglia_return_flag = 0;
+    $gangliaclustername  = '';
+    $ganglianodename     = '';
+    undef(%gangliaHash);
 
-	#use socket to telnet 127.0.0.1 8652(ganglia's interactive port)
-	$connect = IO::Socket::INET->new('127.0.0.1:8652');
-	unless($connect){
-		$callback->({'data'=>'error: connect local port failed.'});
-		return;
-	}
+    if ( $request->{arg}->[2] ) {
+        $groupname = $request->{arg}->[2];
+    }
+    if ( 'grid' eq $type ) {
+        $xmlparser = XML::Parser->new(
+            Handlers => {
+                Start => \&web_gangliaGridXmlStart,
+                End   => \&web_gangliaXmlEnd
+            });
+        $telnetcmd   = "/?filter=summary\n";
+        $tmpFilename = '/tmp/gangliagriddata';
+    } elsif ( 'node' eq $type ) {
+        $xmlparser = XML::Parser->new(
+            Handlers => {
+                Start => \&web_gangliaNodeXmlStart,
+                End   => \&web_gangliaXmlEnd
+            });
+        $telnetcmd   = "/\n";
+        $tmpFilename = '/tmp/ganglianodedata';
+    }
 
-	print $connect $telnetcmd;
-	open(TEMPFILE, '>' . $tmpFilename);
-	while(<$connect>){
-		print TEMPFILE $_;
-	}
-	close($connect);
-	close(TEMPFILE);
+    # Use socket to telnet 127.0.0.1:8652 (Ganglia's interactive port)
+    $connect = IO::Socket::INET->new('127.0.0.1:8652');
+    unless ($connect) {
+        $callback->( { 'data' => 'error: connect local port failed.' } );
+        return;
+    }
 
-	$xmlparser->parsefile($tmpFilename);
+    print $connect $telnetcmd;
+    open( TEMPFILE, '>' . $tmpFilename );
+    while (<$connect>) {
+        print TEMPFILE $_;
+    }
+    
+    close($connect);
+    close(TEMPFILE);
 
-	if ('grid' eq $type){
-		web_gangliaGridLatest($callback);
-	}
-	elsif('node' eq $type){
-		web_gangliaNodeLatest($callback, $groupname);
-	}
-	return;
+    $xmlparser->parsefile($tmpFilename);
+
+    if ( 'grid' eq $type ) {
+        web_gangliaGridLatest($callback);
+    } elsif ( 'node' eq $type ) {
+        web_gangliaNodeLatest( $callback, $groupname );
+    }
+    return;
 }
 
-#create return data for grid current status
-sub web_gangliaGridLatest{
-	my $callback = shift;
-	my $retStr = '';
-	my $timestamp = time();
-	my $metricname = '';
-	my @metricArray = ('load_one', 'cpu_num', 'mem_total', 'mem_free', 'disk_total', 'disk_free', 'bytes_in', 'bytes_out');
+sub web_gangliaGridLatest {
+	# Create return data for grid current status
+	
+    my $callback    = shift;
+    my $retStr      = '';
+    my $timestamp   = time();
+    my $metricname  = '';
+    my @metricArray = (
+        'load_one',   'cpu_num',   'mem_total', 'mem_free',
+        'disk_total', 'disk_free', 'bytes_in',  'bytes_out'
+    );
 
-	if ($gangliaHash{'cpu_idle'}){
-		my $sum = $gangliaHash{'cpu_idle'}->{'SUM'};
-		my $num = $gangliaHash{'cpu_idle'}->{'NUM'};
-		$retStr .= 'cpu_idle:' . $timestamp . ',' . (sprintf("%.2f", $sum/$num )) . ';';
-	}
-	foreach $metricname (@metricArray){
-		if ($gangliaHash{$metricname}){
-			$retStr .= $metricname . ':' . $timestamp . ',' . $gangliaHash{$metricname}->{'SUM'} . ';';
-		}
-	}
-	$retStr = substr($retStr, 0, -1);
-	$callback->({data=>$retStr});
+    if ( $gangliaHash{'cpu_idle'} ) {
+        my $sum = $gangliaHash{'cpu_idle'}->{'SUM'};
+        my $num = $gangliaHash{'cpu_idle'}->{'NUM'};
+        $retStr .= 'cpu_idle:'
+          . $timestamp . ','
+          . ( sprintf( "%.2f", $sum / $num ) ) . ';';
+    }
+    
+    foreach $metricname (@metricArray) {
+        if ( $gangliaHash{$metricname} ) {
+            $retStr .=
+                $metricname . ':'
+              . $timestamp . ','
+              . $gangliaHash{$metricname}->{'SUM'} . ';';
+        }
+    }
+    
+    $retStr = substr( $retStr, 0, -1 );
+    $callback->( { data => $retStr } );
 }
 
-#create return data for node current status
-sub web_gangliaNodeLatest{
-	my ($callback, $groupname) = @_;
-	my $node = '';
-	my $retStr = '';
-	my $timestamp = time() - 180;
-	my @nodes;
-	#get all nodes by group
-	if ($groupname){
-		@nodes = xCAT::NodeRange::noderange($groupname, 1);
-	}
-	else{
-		@nodes = xCAT::DBobjUtils->getObjectsOfType('node');
-	}
-	foreach $node(@nodes){
-		#if the node install the ganglia
-		if ($gangliaHash{$node}){
-			my $lastupdate = $gangliaHash{$node}->{'timestamp'};
-			#can not get the monitor data for too long time
-			if ($lastupdate < $timestamp){
-				$retStr .= $node . ':ERROR,Can not get monitor data more than 3 minutes!;';
-				next;
-			}
-			
-			if ($gangliaHash{$node}->{'load_one'} > $gangliaHash{$node}->{'cpu_num'}){
-				$retStr .= $node . ':WARNING,';
-			}
-			else{
-				$retStr .= $node . ':NORMAL,';
-			}
-			$retStr .= $gangliaHash{$node}->{'path'} . ';'
-		}
-		else{
-			$retStr .= $node . ':UNKNOWN,;' ;
-		}
-	}
+sub web_gangliaNodeLatest {
+	# Create return data for node current status
+	
+    my ( $callback, $groupname ) = @_;
+    my $node      = '';
+    my $retStr    = '';
+    my $timestamp = time() - 180;
+    my @nodes;
 
-	$retStr = substr($retStr, 0, -1);
-	$callback->({data=>$retStr});
-}
-#xml parser end function, do noting here
-sub web_gangliaXmlEnd{
+    # Get all nodes by group
+    if ($groupname) {
+        @nodes = xCAT::NodeRange::noderange( $groupname, 1 );
+    } else {
+        @nodes = xCAT::DBobjUtils->getObjectsOfType('node');
+    }
+    
+    foreach $node (@nodes) {
+        # If the node has Ganglia
+        if ( $gangliaHash{$node} ) {
+            my $lastupdate = $gangliaHash{$node}->{'timestamp'};
+
+            # Cannot get monitor data for too long
+            if ( $lastupdate < $timestamp ) {
+                $retStr .= $node . ':ERROR,Can not get monitor data more than 3 minutes!;';
+                next;
+            }
+
+            if ( $gangliaHash{$node}->{'load_one'} >
+                $gangliaHash{$node}->{'cpu_num'} ) {
+                $retStr .= $node . ':WARNING,';
+            } else {
+                $retStr .= $node . ':NORMAL,';
+            }
+            
+            $retStr .= $gangliaHash{$node}->{'path'} . ';';
+        } else {
+            $retStr .= $node . ':UNKNOWN,;';
+        }
+    }
+
+    $retStr = substr( $retStr, 0, -1 );
+    $callback->( { data => $retStr } );
 }
 
-#xml parser start function for grid latest value
-sub web_gangliaGridXmlStart{
-	my( $parseinst, $elementname, %attrs ) = @_;
-	my $metricname = '';
-
-	#only parser grid infomation
-	if ($ganglia_return_flag){
-		return;
-	}
-	if ('METRICS' eq $elementname){
-		$metricname = $attrs{'NAME'};
-		$gangliaHash{$metricname}->{'SUM'} = $attrs{'SUM'};
-		$gangliaHash{$metricname}->{'NUM'} = $attrs{'NUM'};
-	}
-	elsif ('CLUSTER' eq $elementname){
-		$ganglia_return_flag = 1;
-		return;
-	}
-	else{
-		return;
-	}
-	#only need the grid summary info, if receive cluster return directly
+sub web_gangliaXmlEnd {
+	# XML parser end function, do noting here
 }
 
-#xml parser start function for node current status
-sub web_gangliaNodeXmlStart{
-	my( $parseinst, $elementname, %attrs ) = @_;
-	my $metricname = '';
-	#save the cluster name
-	if('CLUSTER' eq $elementname){
-		$gangliaclustername = $attrs{'NAME'};
-		return;
-	}
-	elsif('HOST' eq $elementname){
-		if ($attrs{'NAME'} =~ /(\S+?)\.(.*)/){
-			$ganglianodename = $1;
-		}
-		else{
-			$ganglianodename = $attrs{'NAME'};
-		}
-		$gangliaHash{$ganglianodename}->{'path'} = $gangliaclustername . '/' . $attrs{'NAME'};
-		$gangliaHash{$ganglianodename}->{'timestamp'} = $attrs{'REPORTED'};
-	}
-	elsif('METRIC' eq $elementname){
-		$metricname = $attrs{'NAME'};
-		if (('load_one' eq $metricname) || ('cpu_num' eq $metricname)){
-			$gangliaHash{$ganglianodename}->{$metricname} = $attrs{'VAL'};
-		}
-	}
+sub web_gangliaGridXmlStart {
+	# XML parser start function
+	
+    my ( $parseinst, $elementname, %attrs ) = @_;
+    my $metricname = '';
+
+    # Only parse grid information
+    if ($ganglia_return_flag) {
+        return;
+    }
+    
+    if ( 'METRICS' eq $elementname ) {
+        $metricname                        = $attrs{'NAME'};
+        $gangliaHash{$metricname}->{'SUM'} = $attrs{'SUM'};
+        $gangliaHash{$metricname}->{'NUM'} = $attrs{'NUM'};
+    } elsif ( 'CLUSTER' eq $elementname ) {
+        $ganglia_return_flag = 1;
+        return;
+    } else {
+        return;
+    }
+}
+
+sub web_gangliaNodeXmlStart {
+    # XML parser start function for node current status
+    
+    my ( $parseinst, $elementname, %attrs ) = @_;
+    my $metricname = '';
+
+    # Save cluster name
+    if ( 'CLUSTER' eq $elementname ) {
+        $gangliaclustername = $attrs{'NAME'};
+        return;
+    } elsif ( 'HOST' eq $elementname ) {
+        if ( $attrs{'NAME'} =~ /(\S+?)\.(.*)/ ) {
+            $ganglianodename = $1;
+        } else {
+            $ganglianodename = $attrs{'NAME'};
+        }
+        
+        $gangliaHash{$ganglianodename}->{'path'} =
+          $gangliaclustername . '/' . $attrs{'NAME'};
+        $gangliaHash{$ganglianodename}->{'timestamp'} = $attrs{'REPORTED'};
+    } elsif ( 'METRIC' eq $elementname ) {
+        $metricname = $attrs{'NAME'};
+        if ( ( 'load_one' eq $metricname ) || ( 'cpu_num' eq $metricname ) ) {
+            $gangliaHash{$ganglianodename}->{$metricname} = $attrs{'VAL'};
+        }
+    }
 }
 
 sub web_rmcmonStart {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $nodeRange = $request->{arg}->[1];
-	my $table;
-	my $retData = "";
-	my $output;
-
-	#check the running status
-	$table = xCAT::Table->new('monitoring');
-	my $rmcWorkingStatus = $table->getAttribs( { name => 'rmcmon' }, 'disable' );
-	$table . close();
-
-	#the rmc monitoring is running so return directly
-	if ($rmcWorkingStatus) {
-		if ( $rmcWorkingStatus->{disable} =~ /0|No|no|NO|N|n/ ) {
-			$callback->( { info => 'RMC Monitoring is running now.' } );
-			return;
-		}
-	}
-
-	$retData .= "RMC is not running, start it now.\n";
-
-	#check the monsetting table rmc's montype contains "performance"
-	$table = xCAT::Table->new('monsetting');
-	my $rmcmonType = $table->getAttribs( { name => 'rmcmon', key => 'montype' }, 'value' );
-	$table . close();
-
-	#the rmc monitoring is not configure right we should configure it again
-	#there is no rmcmon in monsetting table
-	if ( !$rmcmonType ) {
-		$output = xCAT::Utils->runcmd( 'monadd rmcmon -s [montype=perf]', -1, 1 );
-		foreach (@$output) {
-			$retData .= ( $_ . "\n" );
-		}
-		$retData .= "Add the rmcmon to monsetting table complete.\n";
-	}
-
-	#configure before but there is not performance monitoring, so change the table
-	else {
-		if ( !( $rmcmonType->{value} =~ /perf/ ) ) {
-			$output =
-			  xCAT::Utils->runcmd( 'chtab name=rmcmon,key=montype monsetting.value=perf', -1, 1 );
-			foreach (@$output) {
-				$retData .= ( $_ . "\n" );
-			}
-			$retData .= "Change the rmcmon configure in monsetting table finish.\n";
-		}
-	}
-
-	#run the rmccfg command to add all nodes into local RMC configuration
-	$output = xCAT::Utils->runcmd( "moncfg rmcmon $nodeRange", -1, 1 );
-	foreach (@$output) {
-		$retData .= ( $_ . "\n" );
-	}
-
-	#run the rmccfg command to add all nodes into remote RMC configuration
-	$output = xCAT::Utils->runcmd( "moncfg rmcmon $nodeRange -r", -1, 1 );
-	foreach (@$output) {
-		$retData .= ( $_ . "\n" );
-	}
-
-#check the monfiguration
-#use lsrsrc -a IBM.Host Name. compare the command's return and the noderange, then decide witch node should be refrsrc
-
-	#start the rmc monitor
-	$output = xCAT::Utils->runcmd( "monstart rmcmon", -1, 1 );
-	foreach (@$output) {
-		$retData .= ( $_ . "\n" );
-	}
-
-	$callback->( { info => $retData } );
-	return;
-}
-
-sub web_rmcmonShow() {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $nodeRange = $request->{arg}->[1];
-	my $attr      = $request->{arg}->[2];
-	my @nodes;
-	my $retInfo;
-	my $retHash = {};
-	my $output;
-	my $temp = "";
-
-	#only get the system rmc info
-	#like this PctTotalTimeIdle=>"10.0000, 20.0000, 12.0000, 30.0000"
-	if ( 'summary' eq $nodeRange ) {
-		$output = xCAT::Utils->runcmd( "monshow rmcmon -s -t 60 -o p -a " . $attr, -1, 1 );
-		foreach $temp (@$output) {
-
-			#the attribute name
-			if ( $temp =~ /Pct/ ) {
-				$temp =~ s/ //g;
-
-				#the first one
-				if ( "" eq $retInfo ) {
-					$retInfo .= ( $temp . ':' );
-				} else {
-					$retInfo =~ s/,$/;/;
-					$retInfo .= ( $temp . ':' );
-				}
-				next;
-			}
-
-			#the content of the attribute
-			$temp =~ m/\s+(\d+\.\d{4})/;
-			if ( defined($1) ) {
-				$retInfo .= ( $1 . ',' );
-			}
-		}
-
-		#return the rmc info
-		$retInfo =~ s/,$//;
-		$callback->( { info => $retInfo } );
-		return;
-	}
-
-	if ( 'compute' eq $nodeRange ) {
-		my $node;
-		#get nodes detail containt
-		@nodes = xCAT::NodeRange::noderange($nodeRange);
-		for $node (@nodes){
-			if (-e "/var/rrd/$node"){
-				push( @{ $retHash->{node} }, { name => $node, data => 'OK' } );
-			}
-			else{
-				push( @{ $retHash->{node} }, { name => $node, data => 'UNKNOWN' } );
-			}
-		}
-
-		$callback->($retHash);
-		return;
-	}
-
-    my $attrName  = "";
-    my @attrs = split(/,/, $attr);
-    for $attrName (@attrs){
-        my @attrValue = ();
-        $output = xCAT::Utils->runcmd( "rrdtool fetch /var/rrd/${nodeRange}/${attrName}.rrd -r 60 -s e-1h AVERAGE", -1, 1 );
-        foreach(@$output){
-            $temp = $_;
-            if ($temp eq ''){
-                next;
-            }
-            
-            if (lc($temp) =~ /[nanq|nan]/){
-                next;
-            }
-            
-            if ($temp =~ /^(\d+): (\S+) (\S+)/){
-                push( @attrValue, (sprintf "%.2f", $2));
-            }
-        }
-        
-        if(scalar(@attrValue) > 1){
-            push(@{$retHash->{node}}, { name => $attrName, data => join( ',', @attrValue )});
-        }
-        else{
-        	$retHash->{node}= { name => $attrName, data => ''};
-        	last;
-        }
-    }
-    $callback->($retHash);
-}
-
-sub web_monls() {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $retInfo = xCAT::Utils->runcmd( "monls", -1, 1 );
-	my $ret = '';
-	foreach my $line (@$retInfo) {
-		my @temp = split( /\s+/, $line );
-		$ret .= @temp[0];
-		if ( 'not-monitored' eq @temp[1] ) {
-			$ret .= ':Off;';
-		} else {
-			$ret .= ':On;';
-		}
-	}
-	if ( '' eq $ret ) {
-		return;
-	}
-
-	$ret = substr( $ret, 0, length($ret) - 1 );
-	$callback->( { data => $ret } );
-}
-
-sub web_dynamiciprange{
-	my ($request, $callback, $sub_req ) = @_;
-	my $iprange = $request->{arg}->[1];
-
-	open(TEMPFILE, '>/tmp/iprange.conf');
-	print TEMPFILE "xcat-service-lan:\n";
-	print TEMPFILE "dhcp-dynamic-range = " . $iprange . "\n";
-	close(TEMPFILE);
-
-	#run xcatsetup command to change the dynamic ip range
-	xCAT::Utils->runcmd("xcatsetup /tmp/iprange.conf", -1, 1);
-	unlink('/tmp/iprange.conf');
-	xCAT::Utils->runcmd("makedhcp -n", -1, 1);
-	#restart the dhcp server
-	if (xCAT::Utils->isLinux()){
-	#	xCAT::Utils->runcmd("service dhcpd restart", -1, 1);
-	}
-	else{
-	#	xCAT::Utils->runcmd("startsrc -s dhcpsd", -1, 1);
-	}
-}
-
-sub web_discover {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $type = uc( $request->{arg}->[1] );
-
-	my $retStr  = '';
-	my $retInfo =
-	  xCAT::Utils->runcmd( "lsslp -m -s $type 2>/dev/null | grep $type | awk '{print \$1\":\" \$2\"-\"\$3}'",
-		-1, 1 );
-	if ( scalar(@$retInfo) < 1 ) {
-		$retStr = 'Error: Can not discover frames in cluster!';
-	} else {
-		foreach my $line (@$retInfo) {
-			$retStr .= $line . ';';
-		}
-		$retStr = substr( $retStr, 0, -1 );
-	}
-	$callback->( { data => $retStr } );
-}
-
-sub web_updatevpd {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $harwareMtmsPair = $request->{arg}->[1];
-	my @hardware        = split( /:/, $harwareMtmsPair );
-
-	my $vpdtab = xCAT::Table->new('vpd');
-	unless ($vpdtab) {
-		return;
-	}
-	foreach my $hard (@hardware) {
-
-		#the sequence must be object name, mtm, serial
-		my @temp = split( /,/, $hard );
-		$vpdtab->setAttribs( { 'node' => @temp[0] }, { 'serial' => @temp[2], 'mtm' => @temp[1] } );
-	}
-
-	$vpdtab->close();
-}
-
-sub web_writeconfigfile{
-	my ( $request, $callback, $sub_req ) = @_;
-	my $filename = $request->{arg}->[1];
-	my $content = $request->{arg}->[2];
-
-	open(TEMPFILE, '>'.$filename);
-	print TEMPFILE $content;
-	
-	close(TEMPFILE);
-	return;
-}
-
-sub web_createimage {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $ostype    = $request->{arg}->[1];
-	my $osarch    = lc( $request->{arg}->[2] );
-	my $profile   = $request->{arg}->[3];
-	my $bootif    = $request->{arg}->[4];
-	my $imagetype = lc( $request->{arg}->[5] );
-	my @softArray;
-	my $netdriver  = '';
-	my $installdir = xCAT::Utils->getInstallDir();
-	my $tempos     = $ostype;
-	$tempos =~ s/[0-9\.]//g;
-	my $CONFILE;
-	my $archFlag = 0;
-	my $ret      = '';
-	my $cmdPath  = '';
-
-	if ( $request->{arg}->[6] ) {
-		@softArray = split( ',', $request->{arg}->[6] );
-
-		#check the custom package, if the path is not exist, must create the dir first
-		if ( -e "$installdir/custom/netboot/$ostype/" ) {
-
-			#the path is exist, so archive all file under this path.
-			opendir( TEMPDIR, "$installdir/custom/netboot/$ostype/" );
-			my @fileArray = readdir(TEMPDIR);
-			closedir(TEMPDIR);
-			if ( 2 < scalar(@fileArray) ) {
-				$archFlag = 1;
-				unless ( -e "/tmp/webImageArch/" ) {
-					system("mkdir -p /tmp/webImageArch/");
-				}
-				system("mv $installdir/custom/netboot/$ostype/*.* /tmp/webImageArch/");
-			} else {
-				$archFlag = 0;
-			}
-		} else {
-
-			#do not need to archive
-			$archFlag = 0;
-			system("mkdir -p $installdir/custom/netboot/$ostype/");
-		}
-
-		#write pkglist
-		open( $CONFILE, ">$installdir/custom/netboot/$ostype/$profile.pkglist" );
-		print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/IBMhpc.$ostype.ppc64.pkglist# \n";
-		close($CONFILE);
-
-		#write otherpkglist
-		open( $CONFILE, ">$installdir/custom/netboot/$ostype/$profile.otherpkgs.pkglist" );
-		print $CONFILE "\n";
-		close($CONFILE);
-
-		#write exlist for stateless
-		open( $CONFILE, ">$installdir/custom/netboot/$ostype/$profile.exlist" );
-		print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/IBMhpc.$ostype.$osarch.exlist#\n";
-		close($CONFILE);
-
-		#write postinstall
-		open( $CONFILE, ">$installdir/custom/netboot/$ostype/$profile.postinstall" );
-		print $CONFILE
-		  "/opt/xcat/share/xcat/IBMhpc/IBMhpc.$tempos.postinstall \$1 \$2 \$3 \$4 \$5 \n";
-		close($CONFILE);
-
-		for my $soft (@softArray) {
-			$soft = lc($soft);
-			if ( 'gpfs' eq $soft ) {
-				web_gpfsConfigure( $ostype, $profile, $osarch, $installdir );
-			} elsif ( 'rsct' eq $soft ) {
-				web_rsctConfigure( $ostype, $profile, $osarch, $installdir );
-			} elsif ( 'pe' eq $soft ) {
-				web_peConfigure( $ostype, $profile, $osarch, $installdir );
-			} elsif ( 'essl' eq $soft ) {
-				web_esslConfigure( $ostype, $profile, $osarch, $installdir );
-			} elsif ( 'ganglia' eq $soft) {
-				web_gangliaConfig( $ostype, $profile, $osarch, 'netboot', $installdir);
-			}
-		}
-
-		#chmod
-		system("chmod 755 $installdir/custom/netboot/$ostype/*.*");
-	}
-
-	if ( $bootif =~ /hf/i ) {
-		$netdriver = 'hf_if';
-	} else {
-		$netdriver = 'ibmveth';
-	}
-
-	if ( $tempos =~ /rh/i ) {
-		$cmdPath = "/opt/xcat/share/xcat/netboot/rh";
-	} else {
-		$cmdPath = "/opt/xcat/share/xcat/netboot/sles";
-	}
-
-	#for stateless only run packimage is ok
-	if ( 'stateless' eq $imagetype ) {
-		my $retInfo =
-		  xCAT::Utils->runcmd(
-			"${cmdPath}/genimage -i $bootif -n $netdriver -o $ostype -p $profile",
-			-1, 1 );
-		$ret = join( "\n", @$retInfo );
-
-		if ($::RUNCMD_RC) {
-			web_restoreChange( $request->{arg}->[6], $archFlag, $imagetype, $ostype, $installdir );
-			$callback->( { data => $ret } );
-			return;
-		}
-
-		$ret .= "\n";
-		my $retInfo = xCAT::Utils->runcmd( "packimage -o $ostype -p $profile -a $osarch", -1, 1 );
-		$ret .= join( "\n", @$retInfo );
-	} else {
-
-		#for statelist we should check the litefile table
-		#step1 save the old litefile table content into litefilearchive.csv
-		system('tabdump litefile > /tmp/litefilearchive.csv');
-
-		#step2 write the new litefile.csv for this lite image
-		open( $CONFILE, ">/tmp/litefile.csv" );
-		print $CONFILE "#image,file,options,comments,disable\n";
-		print $CONFILE '"ALL","/etc/lvm/","tmpfs",,' . "\n";
-		print $CONFILE '"ALL","/etc/ntp.conf","tmpfs",,' . "\n";
-		print $CONFILE '"ALL","/etc/resolv.conf","tmpfs",,' . "\n";
-		print $CONFILE '"ALL","/etc/sysconfig/","tmpfs",,' . "\n";
-		print $CONFILE '"ALL","/etc/yp.conf","tmpfs",,' . "\n";
-		print $CONFILE '"ALL","/etc/ssh/","tmpfs",,' . "\n";
-		print $CONFILE '"ALL","/var/","tmpfs",,' . "\n";
-		print $CONFILE '"ALL","/tmp/","tmpfs",,' . "\n";
-		print $CONFILE '"ALL","/root/.ssh/","tmpfs",,' . "\n";
-		print $CONFILE '"ALL","/opt/xcat/","tmpfs",,' . "\n";
-		print $CONFILE '"ALL","/xcatpost/","tmpfs",,' . "\n";
-
-		if ( 'rhels' eq $tempos ) {
-			print $CONFILE '"ALL","/etc/adjtime","tmpfs",,' . "\n";
-			print $CONFILE '"ALL","/etc/securetty","tmpfs",,' . "\n";
-			print $CONFILE '"ALL","/etc/rsyslog.conf","tmpfs",,' . "\n";
-			print $CONFILE '"ALL","/etc/rsyslog.conf.XCATORIG","tmpfs",,' . "\n";
-			print $CONFILE '"ALL","/etc/udev/","tmpfs",,' . "\n";
-			print $CONFILE '"ALL","/etc/ntp.conf.predhclient","tmpfs",,' . "\n";
-			print $CONFILE '"ALL","/etc/resolv.conf.predhclient","tmpfs",,' . "\n";
-		} else {
-			print $CONFILE '"ALL","/etc/ntp.conf.org","tmpfs",,' . "\n";
-			print $CONFILE '"ALL","/etc/syslog-ng/","tmpfs",,' . "\n";
-			print $CONFILE '"ALL","/etc/fstab","tmpfs",,' . "\n";
-		}
-		close($CONFILE);
-
-		#write the hpc software litefile into temp litefile.csv
-		for my $soft (@softArray) {
-			$soft = lc($soft);
-			if ( -e "/opt/xcat/share/xcat/IBMhpc/$soft/litefile.csv" ) {
-				system(
-"grep '^[^#]' /opt/xcat/share/xcat/IBMhpc/$soft/litefile.csv >> /tmp/litefile.csv"
-				);
-			}
-		}
-
-		system("tabrestore /tmp/litefile.csv");
-
-		#create the image
-		my $retInfo =
-		  xCAT::Utils->runcmd(
-			"${cmdPath}/genimage -i $bootif -n $netdriver -o $ostype -p $profile",
-			-1, 1 );
-		$ret = join( "\n", @$retInfo );
-		if ($::RUNCMD_RC) {
-			web_restoreChange( $request->{arg}->[6], $archFlag, $imagetype, $ostype, $installdir );
-			$callback->( { data => $ret } );
-			return;
-		}
-		$ret .= "\n";
-		my $retInfo = xCAT::Utils->runcmd( "liteimg -o $ostype -p $profile -a $osarch", -1, 1 );
-		$ret .= join( "\n", @$retInfo );
-	}
-
-	web_restoreChange( $request->{arg}->[6], $archFlag, $imagetype, $ostype, $installdir );
-	$callback->( { data => $ret } );
-	return;
-}
-
-sub web_gpfsConfigure {
-	my ( $ostype, $profile, $osarch, $installdir ) = @_;
-	my $CONFILE;
-
-	#createrepo
-	system("createrepo $installdir/post/otherpkgs/$ostype/$osarch/gpfs");
-
-	#other pakgs
-	open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.otherpkgs.pkglist" );
-	print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/gpfs/gpfs.otherpkgs.pkglist#\n";
-	close($CONFILE);
-
-	#exlist
-	open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.exlist" );
-	print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/gpfs/gpfs.exlist#\n";
-	close($CONFILE);
-
-	#postinstall
-	system('cp /opt/xcat/share/xcat/IBMhpc/gpfs/gpfs_mmsdrfs $installdir/postscripts/gpfs_mmsdrfs');
-	open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.postinstall" );
-	print $CONFILE
-	  "NODESETSTATE=genimage installroot=\$1 /opt/xcat/share/xcat/IBMhpc/gpfs/gpfs_updates\n";
-	print $CONFILE "installroot=\$1 $installdir/postscripts/gpfs_mmsdrfs\n";
-	close($CONFILE);
-}
-
-sub web_rsctConfigure {
-	my ( $ostype, $profile, $osarch, $installdir ) = @_;
-	my $CONFILE;
-
-	#createrepo
-	system("createrepo $installdir/post/otherpkgs/$ostype/$osarch/rsct");
-
-	#packagelist for sles11
-	if ( $ostype =~ /sles/i ) {
-		open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.pkglist" );
-		print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/rsct/rsct.pkglist# \n";
-		close($CONFILE);
-	}
-
-	#exlist
-	open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.exlist" );
-	print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/rsct/rsct.exlist#\n";
-	close($CONFILE);
-
-	#postinstall
-	open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.postinstall" );
-	print $CONFILE
-"installroot=\$1 rsctdir=$installdir/post/otherpkgs/rhels6/ppc64/rsct NODESETSTATE=genimage   /opt/xcat/share/xcat/IBMhpc/rsct/rsct_install\n";
-	close($CONFILE);
-}
-
-sub web_peConfigure {
-	my ( $ostype, $profile, $osarch, $installdir ) = @_;
-	my $CONFILE;
-
-	#createrepo
-	system("createrepo $installdir/post/otherpkgs/$ostype/$osarch/pe");
-	system("createrepo $installdir/post/otherpkgs/$ostype/$osarch/compilers");
-
-	#pkglist
-	open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.pkglist" );
-	if ( $ostype =~ /rh/i ) {
-		print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/pe/pe.$ostype.pkglist#\n";
-	} else {
-		print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/compilers/compilers.pkglist#\n";
-		print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/pe/pe.pkglist#\n";
-	}
-	close($CONFILE);
-
-	#otherpaglist
-	open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.otherpkgs.pkglist" );
-	print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/pe/pe.otherpkgs.pkglist#\n";
-	close($CONFILE);
-
-	#exlist
-	open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.exlist" );
-	print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/compilers/compilers.exlist#\n";
-	print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/pe/pe.exlist#\n";
-	close($CONFILE);
-
-	#postinstall
-	open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.postinstall" );
-	print $CONFILE
-"installroot=\$1 NODESETSTATE=genimage   /opt/xcat/share/xcat/IBMhpc/compilers/compilers_license";
-	print $CONFILE
-"installroot=\$1 pedir=$installdir/post/otherpkgs/rhels6/ppc64/pe NODESETSTATE=genimage   /opt/xcat/share/xcat/IBMhpc/pe/pe_install";
-	close($CONFILE);
-}
-
-sub web_esslConfigure {
-	my ( $ostype, $profile, $osarch, $installdir ) = @_;
-	my $CONFILE;
-
-	#createrepo
-	system("createrepo $installdir/post/otherpkgs/$ostype/$osarch/essl");
-
-	#pkglist
-	open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.pkglist" );
-	if ( $ostype =~ /rh/i ) {
-		print $CONFILE
-		  "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/compilers/compilers.rhels6.pkglist#\n";
-	} else {
-		print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/essl/essl.pkglist#\n";
-	}
-
-	#otherpkgs
-	open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.otherpkgs.pkglist" );
-	print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/essl/essl.otherpkgs.pkglist#\n";
-	close($CONFILE);
-
-	#exlist
-	open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.exlist" );
-	print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/essl/essl.exlist#\n";
-	close($CONFILE);
-
-	#postinstall
-	open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.postinstall" );
-	print $CONFILE,
-"installroot=\$1 essldir=$installdir/post/otherpkgs/rhels6/ppc64/essl NODESETSTATE=genimage   /opt/xcat/share/xcat/IBMhpc/essl/essl_install";
-	close($CONFILE);
-}
-
-sub web_gangliaConfig{
-	my ( $ostype, $profile, $osarch, $provtype, $installdir ) = @_;
-	my $CONFILE;
-	#createrepo
-	system("createrepo $installdir/post/otherpkgs/$ostype/$osarch/ganglia");
-
-	#pkglist
-	open ( $CONFILE, ">>$installdir/custom/$provtype/$ostype/$profile.otherpkgs.pkglist" );
-	print $CONFILE "#created by xCAT Web Gui.\n";
-	print $CONFILE "ganglia/ganglia\n";
-	print $CONFILE "ganglia/ganglia-gmond\n";
-	print $CONFILE "ganglia/ganglia-gmetad\n";
-	print $CONFILE "ganglia/rrdtool\n";
-	close($CONFILE);
-}
-#check ganglia install needed rpm are put in the right directory
-sub web_gangliaRpmCheck{
-	my ( $ostype, $profile, $osarch, $installdir ) = @_;
-	my @rpmnames = ("rrdtool", "ganglia", "ganglia-gmond", "ganglia-gmetad");
-	my %temphash;
-	my $rpmdir = "$installdir/post/otherpkgs/$ostype/$osarch/ganglia";
-	my $errorstr = '';
-	unless (-e $rpmdir){
-		return "Put rrdtool,ganglia,ganglia-gmond,ganglia-gmetad rpms into $rpmdir.";
-	}
-
-	opendir(DIRHANDLE, $rpmdir);
-	foreach my $filename (readdir(DIRHANDLE)){
-		if ($filename =~ /(\D+)-(\d+)\..*\.rpm$/){
-			$temphash{$1} = 1;
-		}
-	}
-	closedir(DIRHANDLE);
-	
-	#check if all rpm are in the array
-	foreach (@rpmnames){
-		unless ($temphash{$_}){
-			$errorstr .= $_ . ',';
-		}
-	}
-
-	if ($errorstr){
-		$errorstr = substr($errorstr, 0, -1);
-		return "Put $errorstr rpms into $rpmdir.";
-	}
-	else{
-		return "";
-	}
-}
-
-sub web_restoreChange {
-	my ( $software, $archFlag, $imagetype, $ostype, $installdir ) = @_;
-
-	#recover all file in the $installdir/custom/netboot/$ostype/
-	if ($software) {
-		system("rm -f $installdir/custom/netboot/$ostype/*.*");
-	}
-
-	if ($archFlag) {
-		system("mv /tmp/webImageArch/*.* $installdir/custom/netboot/$ostype/");
-	}
-
-	#recover the litefile table for statelite image
-	if ( 'statelite' == $imagetype ) {
-		system(
-"rm -r /tmp/litefile.csv ; mv /tmp/litefilearchive.csv /tmp/litefile.csv ; tabrestore /tmp/litefile.csv"
-		);
-	}
-}
-
-sub web_provision_preinstall{
-	my ($ostype, $profile, $arch, $installdir, $softwarenames) = @_;
-	my $checkresult = '';
-	my $errorstr = '';
-	my @software = split(',', $softwarenames);
-	my $softwarenum = scalar(@software);
-  
-    if (-e "$installdir/custom/install/$ostype/"){
-        opendir(DIRHANDLE, "$installdir/custom/install/$ostype/");
-        foreach my $filename (readdir(DIRHANDLE)){
-            if ('.' eq $filename || '..' eq $filename){
-                next;
-            }
-            $filename = "$installdir/custom/install/$ostype/" . $filename;
-            if ($filename =~ /(.*)\.guibak$/){
-                #no software recover the file, else do nothing
-                if ($softwarenum < 1){
-                    system("mv $filename $1");
-                }
-                next;
-            }
-            `/bin/grep 'xCAT Web Gui' $filename`;
-            if ($?){
-                #backup the origional config file
-                if ($softwarenum > 0){
-                    system("mv $filename ${filename}.guibak");
-                }
-            }
-            else{
-                unlink($filename);
-            }
-        }
-        closedir(DIRHANDLE);
-    }
-    else{
-        `mkdir -p $installdir/custom/install/$ostype -m 0755`;
-    }
-
-	if ($softwarenum < 1){
-		return '';
-	}
-
-	foreach (@software){
-		if ('ganglia' eq $_){
-            $checkresult = web_gangliaRpmCheck($ostype, $profile, $arch, $installdir);
-        }
-        if ($checkresult){
-            $errorstr .= $checkresult . "\n";
-        }
-	}
-	
-	if ($errorstr){
-		return $errorstr;
-	}
-
-	foreach(@software){
-		if ('ganglia' eq $_){
-			web_gangliaConfig($ostype, $profile, $arch, 'install', $installdir);
-		}
-	}
-	return '';
-}
-
-sub web_provision{
     my ( $request, $callback, $sub_req ) = @_;
-    my $nodes = $request->{arg}->[1];
-    my $imageName = $request->{arg}->[2];
-    my ($arch, $inic, $pnic, $master, $tftp, $nfs) = split(/,/, $request->{arg}->[3]);
-    my $line = '';
-    my %imageattr;
-    my $retinfo = xCAT::Utils->runcmd("lsdef -t osimage -l $imageName", -1, 1);
-	my $installdir = xCAT::Utils->getInstallDir();
-    #parse output, get the os name, type
-    foreach $line(@$retinfo){
-        if ($line =~ /(\w+)=(\S*)/){
-            $imageattr{$1} = $2;
-        }
-    }
-	#check the output
-    unless($imageattr{'osname'}){
-        web_infomsg("Image infomation error. Check the image first.\nprovision stop.", $callback);
-        return;
-    }
+    my $nodeRange = $request->{arg}->[1];
+    my $table;
+    my $retData = "";
+    my $output;
 
-	if ('install' eq $imageattr{'provmethod'}){
-		my $prepareinfo = web_provision_preinstall($imageattr{'osvers'}, $imageattr{'profile'}, $arch, $installdir, $request->{arg}->[4]);
-		if ($prepareinfo){
-			web_infomsg("$prepareinfo \nprovision stop.", $callback);
-			return;
-		}
-	}
-    
-    if($imageattr{'osname'} =~ /aix/i){
-        web_provisionaix($nodes, $imageName, $imageattr{'nimtype'}, $inic, $pnic, $master, $tftp, $nfs, $callback);
-    }
-    else{
-        web_provisionlinux($nodes, $arch, $imageattr{'osvers'}, $imageattr{'provmethod'}, $imageattr{'profile'}, $inic, $pnic, $master, $tftp, $nfs, $callback);
-    }
-}
+    # Check running status
+    $table = xCAT::Table->new('monitoring');
+    my $rmcWorkingStatus = $table->getAttribs( { name => 'rmcmon' }, 'disable' );
+    $table . close();
 
-sub web_provisionlinux{
-    my ($nodes, $arch, $os, $provmethod, $profile, $inic, $pnic, $master, $tftp, $nfs, $callback) = @_;
-    my $outputMessage = '';
-    my $retvalue = 0;
-    my $netboot = '';
-    if ($arch =~ /ppc/i){
-        $netboot = 'yaboot';
-    }
-    elsif($arch =~ /x.*86/i){
-        $netboot = 'xnba';
-    }
-    $outputMessage = "Do provison : $nodes \n".
-          " Arch:$arch\n OS:$os\n Provision:$provmethod\n Profile:$profile\n Install NIC:$inic\n Primary NIC:$pnic\n" .
-          " xCAT Master:$master\n TFTP Server:$tftp\n NFS Server:$nfs\n Netboot:$netboot\n";
-
-    web_infomsg($outputMessage, $callback);
-
-    #change the nodes attribute
-    my $cmd = "chdef -t node -o $nodes arch=$arch os=$os provmethod=$provmethod profile=$profile installnic=$inic tftpserver=$tftp nfsserver=$nfs netboot=$netboot" .
-              " xcatmaster=$master primarynic=$pnic";
-    web_runcmd($cmd, $callback);
-    #error return
-    if ($::RUNCMD_RC){
-        web_infomsg("Configure nodes' attributes error.\nprovision stop.", $callback);
-        return;
-    }
-
-    #dhcp
-    $cmd = "makedhcp $nodes";
-    web_runcmd($cmd, $callback);
-    if ($::RUNCMD_RC){
-        web_infomsg("Make DHCP error.\nprovision stop.", $callback);
-        return;
-    }
-    #restart dhcp
-    $cmd = "service dhcpd restart";
-    web_runcmd($cmd, $callback);
-    #conserver
-    $cmd = "makeconservercf $nodes";
-    web_runcmd($cmd, $callback);
-    if ($::RUNCMD_RC){
-        web_infomsg("Configure conserver error.\nprovision stop.", $callback);
-        return;
-    }
-
-    #for system x, should configure boot sequence first.
-    if ($arch =~ /x.*86/i){
-        $cmd = "rbootseq $nodes net,hd";
-        web_runcmd($cmd, $callback);
-        if($::RUNCMD_RC){
-            web_infomsg("Set boot sequence error.\nprovision stop.", $callback);
+    # RMC monitoring is running so return
+    if ($rmcWorkingStatus) {
+        if ( $rmcWorkingStatus->{disable} =~ /0|No|no|NO|N|n/ ) {
+            $callback->( { info => 'RMC Monitoring is running now.' } );
             return;
         }
     }
 
-    #nodeset
-    $cmd = "nodeset $nodes $provmethod";
-    web_runcmd($cmd, $callback);
-    if ($::RUNCMD_RC){
-        web_infomsg("Set nodes provision method error.\nprovision stop.", $callback);
+    $retData .= "RMC is not running, start it now.\n";
+
+    # Check monsetting table to see if rmc's montype contains performance
+    $table = xCAT::Table->new('monsetting');
+    my $rmcmonType =
+      $table->getAttribs( { name => 'rmcmon', key => 'montype' }, 'value' );
+    $table . close();
+
+    # RMC monitoring is not configured right, we should configure it again
+    # There is no rmcmon in monsetting table
+    if ( !$rmcmonType ) {
+        $output = xCAT::Utils->runcmd( 'monadd rmcmon -s [montype=perf]', -1, 1 );
+        foreach (@$output) {
+            $retData .= ( $_ . "\n" );
+        }
+        
+        $retData .= "Adding rmcmon to the monsetting table complete.\n";
+    }
+
+    # Configure before but there is no performance monitoring, so change the table
+    else {
+        if ( !( $rmcmonType->{value} =~ /perf/ ) ) {
+            $output = xCAT::Utils->runcmd('chtab name=rmcmon,key=montype monsetting.value=perf', -1, 1 );
+            foreach (@$output) {
+                $retData .= ( $_ . "\n" );
+            }
+            
+            $retData .= "Change the rmcmon configure in monsetting table finish.\n";
+        }
+    }
+
+    # Run the rmccfg command to add all nodes into local RMC configuration
+    $output = xCAT::Utils->runcmd("moncfg rmcmon $nodeRange", -1, 1);
+    foreach (@$output) {
+        $retData .= ( $_ . "\n" );
+    }
+
+    # Run the rmccfg command to add all nodes into remote RMC configuration
+    $output = xCAT::Utils->runcmd( "moncfg rmcmon $nodeRange -r", -1, 1 );
+    foreach (@$output) {
+        $retData .= ( $_ . "\n" );
+    }
+
+    # Start the RMC monitor
+    $output = xCAT::Utils->runcmd( "monstart rmcmon", -1, 1 );
+    foreach (@$output) {
+        $retData .= ( $_ . "\n" );
+    }
+
+    $callback->( { info => $retData } );
+    return;
+}
+
+sub web_rmcmonShow() {
+    my ( $request, $callback, $sub_req ) = @_;
+    my $nodeRange = $request->{arg}->[1];
+    my $attr      = $request->{arg}->[2];
+    my @nodes;
+    my $retInfo;
+    my $retHash = {};
+    my $output;
+    my $temp = "";
+
+    # Only get the system RMC info
+    if ( 'summary' eq $nodeRange ) {
+        $output = xCAT::Utils->runcmd( "monshow rmcmon -s -t 60 -o p -a " . $attr, -1, 1 );
+        foreach $temp (@$output) {
+            # The attribute name
+            if ( $temp =~ /Pct/ ) {
+                $temp =~ s/ //g;
+
+                # The first one
+                if ( "" eq $retInfo ) {
+                    $retInfo .= ( $temp . ':' );
+                } else {
+                    $retInfo =~ s/,$/;/;
+                    $retInfo .= ( $temp . ':' );
+                }
+                
+                next;
+            }
+
+            # The content of the attribute
+            $temp =~ m/\s+(\d+\.\d{4})/;
+            if ( defined($1) ) {
+                $retInfo .= ( $1 . ',' );
+            }
+        }
+
+        # Return the RMC info
+        $retInfo =~ s/,$//;
+        $callback->( { info => $retInfo } );
+        return;
+    }
+
+    if ('compute' eq $nodeRange) {
+        my $node;
+
+        @nodes = xCAT::NodeRange::noderange($nodeRange);
+        for $node (@nodes) {
+            if ( -e "/var/rrd/$node" ) {
+                push( @{ $retHash->{node} }, { name => $node, data => 'OK' } );
+            } else {
+                push( @{ $retHash->{node} }, { name => $node, data => 'UNKNOWN' } );
+            }
+        }
+
+        $callback->($retHash);
+        return;
+    }
+
+    my $attrName = "";
+    my @attrs = split( /,/, $attr );
+    for $attrName (@attrs) {
+        my @attrValue = ();
+        $output = xCAT::Utils->runcmd( "rrdtool fetch /var/rrd/${nodeRange}/${attrName}.rrd -r 60 -s e-1h AVERAGE", -1, 1 );
+        foreach (@$output) {
+            $temp = $_;
+            if ( $temp eq '' ) {
+                next;
+            }
+
+            if ( lc($temp) =~ /[nanq|nan]/ ) {
+                next;
+            }
+
+            if ( $temp =~ /^(\d+): (\S+) (\S+)/ ) {
+                push( @attrValue, ( sprintf "%.2f", $2 ) );
+            }
+        }
+
+        if ( scalar(@attrValue) > 1 ) {
+            push( @{ $retHash->{node} }, { name => $attrName, data => join( ',', @attrValue ) } );
+        } else {
+            $retHash->{node} = { name => $attrName, data => '' };
+            last;
+        }
+    }
+    
+    $callback->($retHash);
+}
+
+sub web_monls() {
+    my ( $request, $callback, $sub_req ) = @_;
+    my $retInfo = xCAT::Utils->runcmd( "monls", -1, 1 );
+    my $ret = '';
+    foreach my $line (@$retInfo) {
+        my @temp = split( /\s+/, $line );
+        $ret .= @temp[0];
+        if ( 'not-monitored' eq @temp[1] ) {
+            $ret .= ':Off;';
+        } else {
+            $ret .= ':On;';
+        }
+    }
+    
+    if ( '' eq $ret ) {
+        return;
+    }
+
+    $ret = substr( $ret, 0, length($ret) - 1 );
+    $callback->( { data => $ret } );
+}
+
+sub web_dynamiciprange {
+    my ( $request, $callback, $sub_req ) = @_;
+    my $iprange = $request->{arg}->[1];
+
+    open( TEMPFILE, '>/tmp/iprange.conf' );
+    print TEMPFILE "xcat-service-lan:\n";
+    print TEMPFILE "dhcp-dynamic-range = " . $iprange . "\n";
+    close(TEMPFILE);
+
+    # Run xcatsetup command to change the dynamic IP range
+    xCAT::Utils->runcmd( "xcatsetup /tmp/iprange.conf", -1, 1 );
+    unlink('/tmp/iprange.conf');
+    xCAT::Utils->runcmd( "makedhcp -n", -1, 1 );
+
+    # Restart the DHCP server
+    if ( xCAT::Utils->isLinux() ) {
+        # xCAT::Utils->runcmd("service dhcpd restart", -1, 1);
+    } else {
+        # xCAT::Utils->runcmd("startsrc -s dhcpsd", -1, 1);
+    }
+}
+
+sub web_discover {
+    my ( $request, $callback, $sub_req ) = @_;
+    my $type = uc( $request->{arg}->[1] );
+
+    my $retStr  = '';
+    my $retInfo = xCAT::Utils->runcmd( "lsslp -m -s $type 2>/dev/null | grep $type | awk '{print \$1\":\" \$2\"-\"\$3}'", -1, 1 );
+    if ( scalar(@$retInfo) < 1 ) {
+        $retStr = 'Error: Can not discover frames in cluster!';
+    } else {
+        foreach my $line (@$retInfo) {
+            $retStr .= $line . ';';
+        }
+        
+        $retStr = substr( $retStr, 0, -1 );
+    }
+    
+    $callback->( { data => $retStr } );
+}
+
+sub web_updatevpd {
+    my ( $request, $callback, $sub_req ) = @_;
+    my $harwareMtmsPair = $request->{arg}->[1];
+    my @hardware        = split( /:/, $harwareMtmsPair );
+
+    my $vpdtab = xCAT::Table->new('vpd');
+    unless ($vpdtab) {
         return;
     }
     
-    #reboot the node fro provision
-    if($arch =~ /ppc/i){
-        $cmd = "rnetboot $nodes";
+    foreach my $hard (@hardware) {
+        # The sequence must be object name, mtm, serial
+        my @temp = split( /,/, $hard );
+        $vpdtab->setAttribs( { 'node' => @temp[0] }, { 'serial' => @temp[2], 'mtm' => @temp[1] } );
     }
-    else{
-        $cmd = "rpower $nodes boot";
+
+    $vpdtab->close();
+}
+
+sub web_writeconfigfile {
+    my ( $request, $callback, $sub_req ) = @_;
+    my $filename = $request->{arg}->[1];
+    my $content  = $request->{arg}->[2];
+
+    open( TEMPFILE, '>' . $filename );
+    print TEMPFILE $content;
+
+    close(TEMPFILE);
+    return;
+}
+
+sub web_createimage {
+    my ( $request, $callback, $sub_req ) = @_;
+    my $ostype    = $request->{arg}->[1];
+    my $osarch    = lc( $request->{arg}->[2] );
+    my $profile   = $request->{arg}->[3];
+    my $bootif    = $request->{arg}->[4];
+    my $imagetype = lc( $request->{arg}->[5] );
+    my @softArray;
+    my $netdriver  = '';
+    my $installdir = xCAT::Utils->getInstallDir();
+    my $tempos     = $ostype;
+    $tempos =~ s/[0-9\.]//g;
+    my $CONFILE;
+    my $archFlag = 0;
+    my $ret      = '';
+    my $cmdPath  = '';
+
+    if ( $request->{arg}->[6] ) {
+        @softArray = split( ',', $request->{arg}->[6] );
+
+        # Check the custom package, if the directory does not exist, create the directory first
+        if ( -e "$installdir/custom/netboot/$ostype/" ) {
+            # The path exist, so archive all file under this path
+            opendir( TEMPDIR, "$installdir/custom/netboot/$ostype/" );
+            my @fileArray = readdir(TEMPDIR);
+            closedir(TEMPDIR);
+            if ( 2 < scalar(@fileArray) ) {
+                $archFlag = 1;
+                unless ( -e "/tmp/webImageArch/" ) {
+                    system("mkdir -p /tmp/webImageArch/");
+                }
+                
+                system("mv $installdir/custom/netboot/$ostype/*.* /tmp/webImageArch/");
+            } else {
+                $archFlag = 0;
+            }
+        } else {
+            # No need to archive
+            $archFlag = 0;
+            system("mkdir -p $installdir/custom/netboot/$ostype/");
+        }
+
+        # Write pkglist
+        open( $CONFILE, ">$installdir/custom/netboot/$ostype/$profile.pkglist" );
+        print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/IBMhpc.$ostype.ppc64.pkglist# \n";
+        close($CONFILE);
+
+        # Write otherpkglist
+        open( $CONFILE, ">$installdir/custom/netboot/$ostype/$profile.otherpkgs.pkglist" );
+        print $CONFILE "\n";
+        close($CONFILE);
+
+        # Write exlist for stateless
+        open( $CONFILE, ">$installdir/custom/netboot/$ostype/$profile.exlist" );
+        print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/IBMhpc.$ostype.$osarch.exlist#\n";
+        close($CONFILE);
+
+        # Write postinstall
+        open( $CONFILE, ">$installdir/custom/netboot/$ostype/$profile.postinstall" );
+        print $CONFILE "/opt/xcat/share/xcat/IBMhpc/IBMhpc.$tempos.postinstall \$1 \$2 \$3 \$4 \$5 \n";
+        close($CONFILE);
+
+        for my $soft (@softArray) {
+            $soft = lc($soft);
+            if ( 'gpfs' eq $soft ) {
+                web_gpfsConfigure( $ostype, $profile, $osarch, $installdir );
+            } elsif ( 'rsct' eq $soft ) {
+                web_rsctConfigure( $ostype, $profile, $osarch, $installdir );
+            } elsif ( 'pe' eq $soft ) {
+                web_peConfigure( $ostype, $profile, $osarch, $installdir );
+            } elsif ( 'essl' eq $soft ) {
+                web_esslConfigure( $ostype, $profile, $osarch, $installdir );
+            } elsif ( 'ganglia' eq $soft ) {
+                web_gangliaConfig( $ostype, $profile, $osarch, 'netboot', $installdir );
+            }
+        }
+
+        system("chmod 755 $installdir/custom/netboot/$ostype/*.*");
     }
-    web_runcmd($cmd, $callback);
-    if ($::RUNCMD_RC){
-        web_infomsg("Boot nodes error.\nprovision stop.", $callback);
+
+    if ( $bootif =~ /hf/i ) {
+        $netdriver = 'hf_if';
+    } else {
+        $netdriver = 'ibmveth';
+    }
+
+    if ( $tempos =~ /rh/i ) {
+        $cmdPath = "/opt/xcat/share/xcat/netboot/rh";
+    } else {
+        $cmdPath = "/opt/xcat/share/xcat/netboot/sles";
+    }
+
+    # For stateless only run packimage
+    if ( 'stateless' eq $imagetype ) {
+        my $retInfo = xCAT::Utils->runcmd( "${cmdPath}/genimage -i $bootif -n $netdriver -o $ostype -p $profile", -1, 1 );
+        $ret = join( "\n", @$retInfo );
+
+        if ($::RUNCMD_RC) {
+            web_restoreChange( $request->{arg}->[6], $archFlag, $imagetype, $ostype, $installdir );
+            $callback->( { data => $ret } );
+            return;
+        }
+
+        $ret .= "\n";
+        my $retInfo = xCAT::Utils->runcmd( "packimage -o $ostype -p $profile -a $osarch", -1, 1 );
+        $ret .= join( "\n", @$retInfo );
+    } else {
+        # For statelist we should check the litefile table
+        # Step 1: Save the old litefile table content into litefilearchive.csv
+        system('tabdump litefile > /tmp/litefilearchive.csv');
+
+        # Step 2: Write the new litefile.csv for this lite image
+        open( $CONFILE, ">/tmp/litefile.csv" );
+        print $CONFILE "#image,file,options,comments,disable\n";
+        print $CONFILE '"ALL","/etc/lvm/","tmpfs",,' . "\n";
+        print $CONFILE '"ALL","/etc/ntp.conf","tmpfs",,' . "\n";
+        print $CONFILE '"ALL","/etc/resolv.conf","tmpfs",,' . "\n";
+        print $CONFILE '"ALL","/etc/sysconfig/","tmpfs",,' . "\n";
+        print $CONFILE '"ALL","/etc/yp.conf","tmpfs",,' . "\n";
+        print $CONFILE '"ALL","/etc/ssh/","tmpfs",,' . "\n";
+        print $CONFILE '"ALL","/var/","tmpfs",,' . "\n";
+        print $CONFILE '"ALL","/tmp/","tmpfs",,' . "\n";
+        print $CONFILE '"ALL","/root/.ssh/","tmpfs",,' . "\n";
+        print $CONFILE '"ALL","/opt/xcat/","tmpfs",,' . "\n";
+        print $CONFILE '"ALL","/xcatpost/","tmpfs",,' . "\n";
+
+        if ( 'rhels' eq $tempos ) {
+            print $CONFILE '"ALL","/etc/adjtime","tmpfs",,' . "\n";
+            print $CONFILE '"ALL","/etc/securetty","tmpfs",,' . "\n";
+            print $CONFILE '"ALL","/etc/rsyslog.conf","tmpfs",,' . "\n";
+            print $CONFILE '"ALL","/etc/rsyslog.conf.XCATORIG","tmpfs",,'
+              . "\n";
+            print $CONFILE '"ALL","/etc/udev/","tmpfs",,' . "\n";
+            print $CONFILE '"ALL","/etc/ntp.conf.predhclient","tmpfs",,' . "\n";
+            print $CONFILE '"ALL","/etc/resolv.conf.predhclient","tmpfs",,'
+              . "\n";
+        } else {
+            print $CONFILE '"ALL","/etc/ntp.conf.org","tmpfs",,' . "\n";
+            print $CONFILE '"ALL","/etc/syslog-ng/","tmpfs",,' . "\n";
+            print $CONFILE '"ALL","/etc/fstab","tmpfs",,' . "\n";
+        }
+        close($CONFILE);
+
+        # Write the HPC software litefile into temp litefile.csv
+        for my $soft (@softArray) {
+            $soft = lc($soft);
+            if ( -e "/opt/xcat/share/xcat/IBMhpc/$soft/litefile.csv" ) {
+                system("grep '^[^#]' /opt/xcat/share/xcat/IBMhpc/$soft/litefile.csv >> /tmp/litefile.csv");
+            }
+        }
+
+        system("tabrestore /tmp/litefile.csv");
+
+        # Create the image
+        my $retInfo = xCAT::Utils->runcmd("${cmdPath}/genimage -i $bootif -n $netdriver -o $ostype -p $profile", -1, 1);
+        $ret = join( "\n", @$retInfo );
+        if ($::RUNCMD_RC) {
+            web_restoreChange( $request->{arg}->[6], $archFlag, $imagetype, $ostype, $installdir );
+            $callback->( { data => $ret } );
+            return;
+        }
+        
+        $ret .= "\n";
+        my $retInfo = xCAT::Utils->runcmd( "liteimg -o $ostype -p $profile -a $osarch", -1, 1 );
+        $ret .= join( "\n", @$retInfo );
+    }
+
+    web_restoreChange( $request->{arg}->[6], $archFlag, $imagetype, $ostype, $installdir );
+    $callback->( { data => $ret } );
+    return;
+}
+
+sub web_gpfsConfigure {
+    my ( $ostype, $profile, $osarch, $installdir ) = @_;
+    my $CONFILE;
+
+    system("createrepo $installdir/post/otherpkgs/$ostype/$osarch/gpfs");
+
+    open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.otherpkgs.pkglist" );
+    print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/gpfs/gpfs.otherpkgs.pkglist#\n";
+    close($CONFILE);
+
+    open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.exlist" );
+    print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/gpfs/gpfs.exlist#\n";
+    close($CONFILE);
+
+    system('cp /opt/xcat/share/xcat/IBMhpc/gpfs/gpfs_mmsdrfs $installdir/postscripts/gpfs_mmsdrfs');
+    open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.postinstall" );
+    print $CONFILE "NODESETSTATE=genimage installroot=\$1 /opt/xcat/share/xcat/IBMhpc/gpfs/gpfs_updates\n";
+    print $CONFILE "installroot=\$1 $installdir/postscripts/gpfs_mmsdrfs\n";
+    close($CONFILE);
+}
+
+sub web_rsctConfigure {
+    my ( $ostype, $profile, $osarch, $installdir ) = @_;
+    my $CONFILE;
+
+    system("createrepo $installdir/post/otherpkgs/$ostype/$osarch/rsct");
+
+    if ( $ostype =~ /sles/i ) {
+        open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.pkglist" );
+        print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/rsct/rsct.pkglist# \n";
+        close($CONFILE);
+    }
+
+    open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.exlist" );
+    print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/rsct/rsct.exlist#\n";
+    close($CONFILE);
+
+    open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.postinstall" );
+    print $CONFILE "installroot=\$1 rsctdir=$installdir/post/otherpkgs/rhels6/ppc64/rsct NODESETSTATE=genimage   /opt/xcat/share/xcat/IBMhpc/rsct/rsct_install\n";
+    close($CONFILE);
+}
+
+sub web_peConfigure {
+    my ( $ostype, $profile, $osarch, $installdir ) = @_;
+    my $CONFILE;
+
+    system("createrepo $installdir/post/otherpkgs/$ostype/$osarch/pe");
+    system("createrepo $installdir/post/otherpkgs/$ostype/$osarch/compilers");
+
+    open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.pkglist" );
+    if ( $ostype =~ /rh/i ) {
+        print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/pe/pe.$ostype.pkglist#\n";
+    } else {
+        print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/compilers/compilers.pkglist#\n";
+        print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/pe/pe.pkglist#\n";
+    }
+    
+    close($CONFILE);
+
+    open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.otherpkgs.pkglist" );
+    print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/pe/pe.otherpkgs.pkglist#\n";
+    close($CONFILE);
+
+    open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.exlist" );
+    print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/compilers/compilers.exlist#\n";
+    print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/pe/pe.exlist#\n";
+    close($CONFILE);
+
+    open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.postinstall" );
+    print $CONFILE "installroot=\$1 NODESETSTATE=genimage   /opt/xcat/share/xcat/IBMhpc/compilers/compilers_license";
+    print $CONFILE "installroot=\$1 pedir=$installdir/post/otherpkgs/rhels6/ppc64/pe NODESETSTATE=genimage   /opt/xcat/share/xcat/IBMhpc/pe/pe_install";
+    close($CONFILE);
+}
+
+sub web_esslConfigure {
+    my ( $ostype, $profile, $osarch, $installdir ) = @_;
+    my $CONFILE;
+
+    system("createrepo $installdir/post/otherpkgs/$ostype/$osarch/essl");
+
+    open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.pkglist" );
+    if ( $ostype =~ /rh/i ) {
+        print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/compilers/compilers.rhels6.pkglist#\n";
+    } else {
+        print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/essl/essl.pkglist#\n";
+    }
+
+    open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.otherpkgs.pkglist" );
+    print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/essl/essl.otherpkgs.pkglist#\n";
+    close($CONFILE);
+
+    open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.exlist" );
+    print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/essl/essl.exlist#\n";
+    close($CONFILE);
+
+    open( $CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.postinstall" );
+    print $CONFILE, "installroot=\$1 essldir=$installdir/post/otherpkgs/rhels6/ppc64/essl NODESETSTATE=genimage   /opt/xcat/share/xcat/IBMhpc/essl/essl_install";
+    close($CONFILE);
+}
+
+sub web_gangliaConfig {
+    my ( $ostype, $profile, $osarch, $provtype, $installdir ) = @_;
+    my $CONFILE;
+
+    system("createrepo $installdir/post/otherpkgs/$ostype/$osarch/ganglia");
+
+    open( $CONFILE, ">>$installdir/custom/$provtype/$ostype/$profile.otherpkgs.pkglist" );
+    print $CONFILE "#created by xCAT Web Gui.\n";
+    print $CONFILE "ganglia/ganglia\n";
+    print $CONFILE "ganglia/ganglia-gmond\n";
+    print $CONFILE "ganglia/ganglia-gmetad\n";
+    print $CONFILE "ganglia/rrdtool\n";
+    close($CONFILE);
+}
+
+sub web_gangliaRpmCheck {
+    my ( $ostype, $profile, $osarch, $installdir ) = @_;
+    my @rpmnames = ( "rrdtool", "ganglia", "ganglia-gmond", "ganglia-gmetad" );
+    my %temphash;
+    my $rpmdir   = "$installdir/post/otherpkgs/$ostype/$osarch/ganglia";
+    my $errorstr = '';
+    unless ( -e $rpmdir ) {
+        return "Put rrdtool,ganglia,ganglia-gmond,ganglia-gmetad rpms into $rpmdir.";
+    }
+
+    opendir( DIRHANDLE, $rpmdir );
+    foreach my $filename ( readdir(DIRHANDLE) ) {
+        if ( $filename =~ /(\D+)-(\d+)\..*\.rpm$/ ) {
+            $temphash{$1} = 1;
+        }
+    }
+    closedir(DIRHANDLE);
+
+    # Check if all RPMs are in the array
+    foreach (@rpmnames) {
+        unless ( $temphash{$_} ) {
+            $errorstr .= $_ . ',';
+        }
+    }
+
+    if ($errorstr) {
+        $errorstr = substr( $errorstr, 0, -1 );
+        return "Put $errorstr rpms into $rpmdir.";
+    } else {
+        return "";
+    }
+}
+
+sub web_restoreChange {
+    my ( $software, $archFlag, $imagetype, $ostype, $installdir ) = @_;
+
+    # Recover all file in the $installdir/custom/netboot/$ostype/
+    if ($software) {
+        system("rm -f $installdir/custom/netboot/$ostype/*.*");
+    }
+
+    if ($archFlag) {
+        system("mv /tmp/webImageArch/*.* $installdir/custom/netboot/$ostype/");
+    }
+
+    # Recover the litefile table for statelite image
+    if ( 'statelite' == $imagetype ) {
+        system("rm -r /tmp/litefile.csv ; mv /tmp/litefilearchive.csv /tmp/litefile.csv ; tabrestore /tmp/litefile.csv");
+    }
+}
+
+sub web_provision_preinstall {
+    my ( $ostype, $profile, $arch, $installdir, $softwarenames ) = @_;
+    my $checkresult = '';
+    my $errorstr    = '';
+    my @software    = split( ',', $softwarenames );
+    my $softwarenum = scalar(@software);
+
+    if ( -e "$installdir/custom/install/$ostype/" ) {
+        opendir( DIRHANDLE, "$installdir/custom/install/$ostype/" );
+        foreach my $filename ( readdir(DIRHANDLE) ) {
+            if ( '.' eq $filename || '..' eq $filename ) {
+                next;
+            }
+            
+            $filename = "$installdir/custom/install/$ostype/" . $filename;
+            if ( $filename =~ /(.*)\.guibak$/ ) {
+                if ( $softwarenum < 1 ) {
+                    system("mv $filename $1");
+                }
+                next;
+            }
+            
+            `/bin/grep 'xCAT Web Gui' $filename`;
+            if ($?) {
+                # Backup the original config file
+                if ( $softwarenum > 0 ) {
+                    system("mv $filename ${filename}.guibak");
+                }
+            } else {
+                unlink($filename);
+            }
+        }
+        
+        closedir(DIRHANDLE);
+    } else {
+        `mkdir -p $installdir/custom/install/$ostype -m 0755`;
+    }
+
+    if ( $softwarenum < 1 ) {
+        return '';
+    }
+
+    foreach (@software) {
+        if ( 'ganglia' eq $_ ) {
+            $checkresult = web_gangliaRpmCheck( $ostype, $profile, $arch, $installdir );
+        }
+        
+        if ($checkresult) {
+            $errorstr .= $checkresult . "\n";
+        }
+    }
+
+    if ($errorstr) {
+        return $errorstr;
+    }
+
+    foreach (@software) {
+        if ( 'ganglia' eq $_ ) {
+            web_gangliaConfig( $ostype, $profile, $arch, 'install', $installdir );
+        }
+    }
+    return '';
+}
+
+sub web_provision {
+    my ( $request, $callback, $sub_req ) = @_;
+    my $nodes     = $request->{arg}->[1];
+    my $imageName = $request->{arg}->[2];
+    my ( $arch, $inic, $pnic, $master, $tftp, $nfs ) = split( /,/, $request->{arg}->[3] );
+    my $line = '';
+    my %imageattr;
+    my $retinfo = xCAT::Utils->runcmd( "lsdef -t osimage -l $imageName", -1, 1 );
+    my $installdir = xCAT::Utils->getInstallDir();
+
+    # Parse output, get the OS name and type
+    foreach $line (@$retinfo) {
+        if ( $line =~ /(\w+)=(\S*)/ ) {
+            $imageattr{$1} = $2;
+        }
+    }
+
+    # Check the output
+    unless ( $imageattr{'osname'} ) {
+        web_infomsg( "Image infomation error. Check the image first.\nprovision stop.", $callback );
         return;
     }
 
-    #provision complete
-    web_infomsg("Provision on $nodes success.\nprovision stop.");
+    if ( 'install' eq $imageattr{'provmethod'} ) {
+        my $prepareinfo = web_provision_preinstall( $imageattr{'osvers'}, $imageattr{'profile'}, $arch, $installdir, $request->{arg}->[4] );
+        if ($prepareinfo) {
+            web_infomsg( "$prepareinfo \nprovision stop.", $callback );
+            return;
+        }
+    }
+
+    if ( $imageattr{'osname'} =~ /aix/i ) {
+        web_provisionaix( $nodes, $imageName, $imageattr{'nimtype'}, $inic, $pnic, $master, $tftp, $nfs, $callback );
+    } else {
+        web_provisionlinux(
+            $nodes,                $arch,
+            $imageattr{'osvers'},  $imageattr{'provmethod'},
+            $imageattr{'profile'}, $inic,
+            $pnic,                 $master,
+            $tftp,                 $nfs,
+            $callback
+        );
+    }
 }
 
-sub web_provisionaix{
-    my ($nodes, $imagename, $nimtype, $inic, $pnic, $master, $tftp, $nfs, $callback) = @_;
+sub web_provisionlinux {
+    my ($nodes, $arch, $os, $provmethod, $profile, $inic, $pnic, $master, $tftp, $nfs, $callback) = @_;
+    my $outputMessage = '';
+    my $retvalue      = 0;
+    my $netboot       = '';
+    
+    if ( $arch =~ /ppc/i ) {
+        $netboot = 'yaboot';
+    } elsif ( $arch =~ /x.*86/i ) {
+        $netboot = 'xnba';
+    }
+    
+    $outputMessage =
+        "Do provison : $nodes \n"
+      . " Arch:$arch\n OS:$os\n Provision:$provmethod\n Profile:$profile\n Install NIC:$inic\n Primary NIC:$pnic\n"
+      . " xCAT Master:$master\n TFTP Server:$tftp\n NFS Server:$nfs\n Netboot:$netboot\n";
+
+    web_infomsg( $outputMessage, $callback );
+
+    # Change the node attribute
+    my $cmd = "chdef -t node -o $nodes arch=$arch os=$os provmethod=$provmethod profile=$profile installnic=$inic tftpserver=$tftp nfsserver=$nfs netboot=$netboot" . " xcatmaster=$master primarynic=$pnic";
+    web_runcmd( $cmd, $callback );
+    if ($::RUNCMD_RC) {
+        web_infomsg( "Configure nodes' attributes error.\nProvision stop.", $callback );
+        return;
+    }
+
+    $cmd = "makedhcp $nodes";
+    web_runcmd( $cmd, $callback );
+    if ($::RUNCMD_RC) {
+        web_infomsg( "Make DHCP error.\nProvision stop.", $callback );
+        return;
+    }
+
+    # Restart DHCP
+    $cmd = "service dhcpd restart";
+    web_runcmd( $cmd, $callback );
+
+    # Conserver
+    $cmd = "makeconservercf $nodes";
+    web_runcmd( $cmd, $callback );
+    if ($::RUNCMD_RC) {
+        web_infomsg( "Configure conserver error.\nProvision stop.", $callback );
+        return;
+    }
+
+    # For system x, should configure boot sequence first
+    if ( $arch =~ /x.*86/i ) {
+        $cmd = "rbootseq $nodes net,hd";
+        web_runcmd( $cmd, $callback );
+        if ($::RUNCMD_RC) {
+            web_infomsg( "Set boot sequence error.\nProvision stop.",
+                $callback );
+            return;
+        }
+    }
+
+    # Nodeset
+    $cmd = "nodeset $nodes $provmethod";
+    web_runcmd( $cmd, $callback );
+    if ($::RUNCMD_RC) { web_infomsg( "Set nodes provision method error.\nprovision stop.", $callback );
+        return;
+    }
+
+    # Reboot the node fro provision
+    if ( $arch =~ /ppc/i ) {
+        $cmd = "rnetboot $nodes";
+    } else {
+        $cmd = "rpower $nodes boot";
+    }
+    
+    web_runcmd( $cmd, $callback );
+    if ($::RUNCMD_RC) {
+        web_infomsg( "Boot nodes error.\nProvision stop.", $callback );
+        return;
+    }
+
+    # Provision complete
+    web_infomsg("Provision on $nodes success.\nProvision stop.");
+}
+
+sub web_provisionaix {
+    my (
+        $nodes,  $imagename, $nimtype, $inic, $pnic,
+        $master, $tftp,      $nfs,     $callback
+      ) = @_;
     my $outputMessage = '';
     my $retinfo;
     my %nimhash;
@@ -1755,674 +1794,679 @@ sub web_provisionaix{
     my @updatenodes;
     my @addnodes;
     my $cmd = '';
-    #set attibutes
+
+    # Set attributes
     $cmd = "chdef -t node -o $nodes installnic=$inic tftpserver=$tftp nfsserver=$nfs xcatmaster=$master primarynic=$pnic";
-    web_runcmd($cmd, $callback);
-    if ($::RUNCMD_RC){
-        web_infomsg("Change nodes' attributes error.\nprovision stop.", $callback);
+    web_runcmd( $cmd, $callback );
+    if ($::RUNCMD_RC) {
+        web_infomsg( "Change nodes' attributes error.\nprovision stop.", $callback );
         return;
     }
-    #get all nim resource to filter nodes
-    $retinfo = xCAT::Utils->runcmd("lsnim -c machines", -1, 1);
-    foreach $line (@$retinfo){
-        if($line =~ /(\S+)\s+\S+/){
+
+    # Get all NIM resource to filter nodes
+    $retinfo = xCAT::Utils->runcmd( "lsnim -c machines", -1, 1 );
+    foreach $line (@$retinfo) {
+        if ( $line =~ /(\S+)\s+\S+/ ) {
             $nimhash{$1} = 1;
         }
     }
 
-    foreach my $node(split(/,/, $nodes)){
-        if ($nimhash{$node}){
-            push(@updatenodes, $node);
-        }
-        else{
-            push(@addnodes, $node);
+    foreach my $node ( split( /,/, $nodes ) ) {
+        if ( $nimhash{$node} ) {
+            push( @updatenodes, $node );
+        } else {
+            push( @addnodes, $node );
         }
     }
 
-    #xcat2nim
-    if(0 < scalar(@addnodes)){
-        $cmd = "xcat2nim -t node -o " . join(",", @addnodes);
-        web_runcmd($cmd, $callback);
-        if ($::RUNCMD_RC){
-            web_infomsg("xcat2nim command error.\nprovision stop.", $callback);
+    if ( 0 < scalar(@addnodes) ) {
+        $cmd = "xcat2nim -t node -o " . join( ",", @addnodes );
+        web_runcmd( $cmd, $callback );
+        if ($::RUNCMD_RC) {
+            web_infomsg( "xcat2nim command error.\nprovision stop.", $callback );
             return;
         }
     }
 
-    #update nimnode
-    if(0 < scalar(@updatenodes)){
-        $cmd = "xcat2nim -u -t node -o " . join(",", @updatenodes);
-        web_runcmd($cmd, $callback);
-        if ($::RUNCMD_RC){
-            web_infomsg("xcat2nim command error.\nprovision stop.", $callback);
+    if ( 0 < scalar(@updatenodes) ) {
+        $cmd = "xcat2nim -u -t node -o " . join( ",", @updatenodes );
+        web_runcmd( $cmd, $callback );
+        if ($::RUNCMD_RC) {
+            web_infomsg( "xcat2nim command error.\nprovision stop.", $callback );
             return;
         }
     }
 
-    #make con server
     $cmd = "makeconservercf $nodes";
-    web_runcmd($cmd, $callback);
-    if ($::RUNCMD_RC){
-        web_infomsg("Configure conserver error.\nprovision stop.", $callback);
+    web_runcmd( $cmd, $callback );
+    if ($::RUNCMD_RC) {
+        web_infomsg( "Configure conserver error.\nprovision stop.", $callback );
         return;
     }
 
-    #nodeset
-    if ($nimtype =~ /diskless/){
+    if ( $nimtype =~ /diskless/ ) {
         $cmd = "mkdsklsnode -i $imagename $nodes";
-    }
-    else{
+    } else {
         $cmd = "nimnodeset -i $imagename $nodes";
     }
-    web_runcmd($cmd, $callback);
-    if ($::RUNCMD_RC){
-        web_infomsg("Set node install method error.\nprovision stop.", $callback);
+    
+    web_runcmd( $cmd, $callback );
+    if ($::RUNCMD_RC) {
+        web_infomsg( "Set node install method error.\nprovision stop.", $callback );
         return;
     }
 
-    #reboot nodes
     $cmd = "rnetboot $nodes";
-    web_runcmd($cmd, $callback);
-    if ($::RUNCMD_RC){
-        web_infomsg("Reboot nodes error.\nprovision stop.", $callback);
+    web_runcmd( $cmd, $callback );
+    if ($::RUNCMD_RC) {
+        web_infomsg( "Reboot nodes error.\nprovision stop.", $callback );
         return;
     }
 
     web_infomsg("Provision on $nodes success.\nprovision stop.");
 }
 
-#run the cmd by xCAT::Utils->runcmd and show information.
-sub web_runcmd{
-    my $cmd = shift;
+sub web_runcmd {
+    my $cmd      = shift;
     my $callback = shift;
-    my $showstr = "\n" . $cmd . "\n";
-    web_infomsg($showstr, $callback);
-    my $retvalue = xCAT::Utils->runcmd($cmd, -1, 1);
-    $showstr = join("\n", @$retvalue);
+    my $showstr  = "\n" . $cmd . "\n";
+    
+    web_infomsg( $showstr, $callback );
+    
+    my $retvalue = xCAT::Utils->runcmd( $cmd, -1, 1 );
+    $showstr = join( "\n", @$retvalue );
     $showstr .= "\n";
-    web_infomsg($showstr, $callback);
+    
+    web_infomsg( $showstr, $callback );
 }
 
 sub web_infomsg {
-    my $msg = shift;
+    my $msg      = shift;
     my $callback = shift;
     my %rsp;
-    push @{$rsp{info}}, $msg;
-    xCAT::MsgUtils->message('I', \%rsp, $callback);
+    
+    push @{ $rsp{info} }, $msg;
+    xCAT::MsgUtils->message( 'I', \%rsp, $callback );
     return;
 }
 
-sub web_summary{
+sub web_summary {
     my ( $request, $callback, $sub_req ) = @_;
     my $groupName = $request->{arg}->[1];
     my @nodes;
     my $nodetypeTab;
-	my $nodelistTab;
+    my $nodelistTab;
     my $attrs;
     my %oshash;
     my %archhash;
     my %provhash;
     my %typehash;
-	my %statushash;
+    my %statushash;
     my $retHash = {};
     my $temp;
-    #$groupName is undefined, use all nodes
-    if (defined($groupName)){
+
+    if ( defined($groupName) ) {
         @nodes = xCAT::NodeRange::noderange($groupName);
-    }
-    #groupName if definded, use the defined group name
-    else{
+    } else {
         @nodes = xCAT::DBobjUtils->getObjectsOfType('node');
     }
 
     $nodetypeTab = xCAT::Table->new('nodetype');
-    unless($nodetypeTab){
+    unless ($nodetypeTab) {
         return;
     }
 
-	$nodelistTab = xCAT::Table->new('nodelist');
-	unless($nodelistTab){
-		return;
-	}
-
-    $attrs = $nodetypeTab->getNodesAttribs(\@nodes, ['os','arch','provmethod','nodetype']);
-    unless($attrs){
+    $nodelistTab = xCAT::Table->new('nodelist');
+    unless ($nodelistTab) {
         return;
     }
 
-    while( my ($key, $value) = each(%{$attrs})){
-        web_attrcount($value->[0]->{'os'}, \%oshash);
-        web_attrcount($value->[0]->{'arch'}, \%archhash);
-        web_attrcount($value->[0]->{'provmethod'},, \%provhash);
-        web_attrcount($value->[0]->{'nodetype'},, \%typehash);
+    $attrs = $nodetypeTab->getNodesAttribs( \@nodes, [ 'os', 'arch', 'provmethod', 'nodetype' ] );
+    unless ($attrs) {
+        return;
     }
-    
-	$attrs = $nodelistTab->getNodesAttribs(\@nodes, ['status']);
-	while(my ($key, $value) = each(%{$attrs})){
-		web_attrcount($value->[0]->{'status'}, \%statushash);
-	}
 
-    #status
-	$temp = '';
-	while(my ($key, $value) = each(%statushash)){
-		$temp .= ($key . ':' . $value . ';');
-	}
-	$temp = substr($temp, 0, -1);
-	push(@{$retHash->{'data'}}, 'Status=' . $temp);
-	#os
+    while ( my ( $key, $value ) = each( %{$attrs} ) ) {
+        web_attrcount( $value->[0]->{'os'},          \%oshash );
+        web_attrcount( $value->[0]->{'arch'},        \%archhash );
+        web_attrcount( $value->[0]->{'provmethod'},, \%provhash );
+        web_attrcount( $value->[0]->{'nodetype'},,   \%typehash );
+    }
+
+    $attrs = $nodelistTab->getNodesAttribs( \@nodes, ['status'] );
+    while ( my ( $key, $value ) = each( %{$attrs} ) ) {
+        web_attrcount( $value->[0]->{'status'}, \%statushash );
+    }
+
+    # Status
     $temp = '';
-    while(my ($key, $value) = each(%oshash)){
-        $temp .= ($key . ':' . $value . ';');
+    while ( my ( $key, $value ) = each(%statushash) ) {
+        $temp .= ( $key . ':' . $value . ';' );
     }
-    $temp = substr($temp, 0, -1);
-    push(@{$retHash->{'data'}}, 'Operating System=' . $temp);
+    $temp = substr( $temp, 0, -1 );
+    push( @{ $retHash->{'data'} }, 'Status=' . $temp );
 
-    #arch
+    # OS
     $temp = '';
-    while(my ($key, $value) = each(%archhash)){
-        $temp .= ($key . ':' . $value . ';');
+    while ( my ( $key, $value ) = each(%oshash) ) {
+        $temp .= ( $key . ':' . $value . ';' );
     }
-    $temp = substr($temp, 0, -1);
-    push(@{$retHash->{'data'}}, 'Architecture=' . $temp);
+    $temp = substr( $temp, 0, -1 );
+    push( @{ $retHash->{'data'} }, 'Operating System=' . $temp );
 
-    #provmethod
+    # Architecture
     $temp = '';
-    while(my ($key, $value) = each(%provhash)){
-        $temp .= ($key . ':' . $value . ';');
+    while ( my ( $key, $value ) = each(%archhash) ) {
+        $temp .= ( $key . ':' . $value . ';' );
     }
-    $temp = substr($temp, 0, -1);
-    push(@{$retHash->{'data'}}, 'Provision Method=' . $temp);
+    $temp = substr( $temp, 0, -1 );
+    push( @{ $retHash->{'data'} }, 'Architecture=' . $temp );
 
-    #nodetype
+    # Provision method
     $temp = '';
-    while(my ($key, $value) = each(%typehash)){
-        $temp .= ($key . ':' . $value . ';');
+    while ( my ( $key, $value ) = each(%provhash) ) {
+        $temp .= ( $key . ':' . $value . ';' );
     }
-    $temp = substr($temp, 0, -1);
-    push(@{$retHash->{'data'}}, 'Node Type=' . $temp);
+    $temp = substr( $temp, 0, -1 );
+    push( @{ $retHash->{'data'} }, 'Provision Method=' . $temp );
 
-    #return data
+    # Nodetype
+    $temp = '';
+    while ( my ( $key, $value ) = each(%typehash) ) {
+        $temp .= ( $key . ':' . $value . ';' );
+    }
+    $temp = substr( $temp, 0, -1 );
+    push( @{ $retHash->{'data'} }, 'Node Type=' . $temp );
+
+    # Return data
     $callback->($retHash);
 }
 
-#called by web_summay, count all attr numbers
-sub web_attrcount{
-    my ($key, $container) = @_;
-    unless(defined($key)){
+sub web_attrcount {
+    my ( $key, $container ) = @_;
+    unless ( defined($key) ) {
         $key = 'unknown';
     }
 
-    if ($container->{$key}){
+    if ( $container->{$key} ) {
         $container->{$key}++;
-    }
-    else{
+    } else {
         $container->{$key} = 1;
     }
 }
 
 sub web_rinstall {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $os = $request->{arg}->[1];
-	my $profile = $request->{arg}->[2];
-	my $arch = $request->{arg}->[3];
-	my $node = $request->{arg}->[4];
+    my ( $request, $callback, $sub_req ) = @_;
+    my $os      = $request->{arg}->[1];
+    my $profile = $request->{arg}->[2];
+    my $arch    = $request->{arg}->[3];
+    my $node    = $request->{arg}->[4];
 
-	# Begin installation
-	my $out = `rinstall -o $os -p $profile -a $arch $node`;
+    # Begin installation
+    my $out = `rinstall -o $os -p $profile -a $arch $node`;
 
-	$callback->( { data => $out } );
+    $callback->( { data => $out } );
 }
 
-sub web_addnode{
-	my ( $request, $callback, $sub_req ) = @_;
-	my $nodetype = $request->{arg}->[1];
-	my @tempArray = split(',', $request->{arg}->[2]);
+sub web_addnode {
+    my ( $request, $callback, $sub_req ) = @_;
+    my $nodetype  = $request->{arg}->[1];
+    my @tempArray = split( ',', $request->{arg}->[2] );
 
-	my $hcpname = shift(@tempArray);
-	if ('node' ne $nodetype){
-		my $username = $tempArray[0];
-		my $passwd = $tempArray[1];
-		my $ip = $tempArray[2];
-		`/bin/grep '$hcpname' /etc/hosts`;
-		if ($?){
-			open(OUTPUTFILE, '>>/etc/hosts');
-			print OUTPUTFILE "$ip $hcpname\n";
-			close(OUTPUTFILE);
-		}
-		if ('hmc' eq $nodetype) {
-			`chdef -t node -o $hcpname username=$username password=$passwd mgt=hmc nodetype=$nodetype ip=$ip groups=all`
-		} else {
-			`chdef -t node -o $hcpname username=$username password=$passwd mgt=blade mpa=$hcpname nodetype=$nodetype id=0 groups=mm,all`
-		}
-		return;
-	}
-
-	my %temphash;
-	my $writeflag = 0;
-	my $line = '';
-	#save all node into a hash
-	foreach(@tempArray) {
-		$temphash{$_} = 1;
-	}
-	for (my $i = 0; $i < scalar(@tempArray); $i = $i + 2){
-		$temphash{$tempArray[$i]} = $tempArray[$i + 1];
-	}
-	`rscan $hcpname -z > /tmp/rscanall.tmp`;
-	#if can not create the rscan result file, error
-	unless(-e '/tmp/rscanall.tmp'){
-		return;
-	}
-
-	open(INPUTFILE, '/tmp/rscanall.tmp');
-	open(OUTPUTFILE, '>/tmp/webrscan.tmp');
-	while($line=<INPUTFILE>){
-		if ($line =~ /(\S+):$/){
-			if ($temphash{$1}){
-				$writeflag = 1;
-				print OUTPUTFILE $temphash{$1} . ":\n";
-			}
-			else{
-				$writeflag = 0;
-			}
-		}
-		else{
-			if ($writeflag){
-				print OUTPUTFILE $line;
-			}
-		}
-	}
-
-	close(INPUTFILE);
-	close(OUTPUTFILE);
-	unlink('/tmp/rscanall.tmp');
-
-	`cat /tmp/webrscan.tmp | chdef -z`;
-	unlink('/tmp/webrscan.tmp');
-}
-
-sub web_graphinfo{
-	my ( $request, $callback, $sub_req ) = @_;
-	my $nodetypeTab;
-	my @nodes;
-	my @parray;
-	my @bladearray;
-	my @xarray;
-	my %phash;
-	my %bladehash;
-	my %xhash;
-	my @unsupportarray;
-	my @missinfoarray;
-	my $result;
-	my $pretstr = '';
-	my $bladeretstr = '';
-	my $xretstr = '';
-	my $unsupretstr = '';
-	my $missretstr = '';
-
-	@nodes = xCAT::DBobjUtils->getObjectsOfType('node');
-
-	$nodetypeTab = xCAT::Table->new('nodetype');
-    unless($nodetypeTab){
+    my $hcpname = shift(@tempArray);
+    if ( 'node' ne $nodetype ) {
+        my $username = $tempArray[0];
+        my $passwd   = $tempArray[1];
+        my $ip       = $tempArray[2];
+        `/bin/grep '$hcpname' /etc/hosts`;
+        if ($?) {
+            open( OUTPUTFILE, '>>/etc/hosts' );
+            print OUTPUTFILE "$ip $hcpname\n";
+            close(OUTPUTFILE);
+        }
+        
+        if ( 'hmc' eq $nodetype ) {
+            `chdef -t node -o $hcpname username=$username password=$passwd mgt=hmc nodetype=$nodetype ip=$ip groups=all`;
+        } else {
+            `chdef -t node -o $hcpname username=$username password=$passwd mgt=blade mpa=$hcpname nodetype=$nodetype id=0 groups=mm,all`;
+        }
         return;
     }
 
-	#get all nodes type to seperate nodes into different group
-	$result = $nodetypeTab->getNodesAttribs(\@nodes,['nodetype']);
-	while(my ($key, $value) = each(%$result)){
-		my $temptype = $value->[0]->{'nodetype'};
-		if ($temptype =~ /(ppc|lpar|cec|frame)/i){
-			push(@parray, $key);
-		}
-		elsif ($temptype =~ /blade/i){
-			push(@bladearray, $key);
-		}
-		elsif ($temptype =~ /osi/i){
-			push(@xarray, $key);
-		}
-		else{
-			push(@unsupportarray, $key);
-		}
-	}
-	$nodetypeTab->close();
+    my %temphash;
+    my $writeflag = 0;
+    my $line      = '';
 
-	#get all infomations for system p node
-	if (scalar(@parray) > 0){
-		my $ppctab = xCAT::Table->new('ppc');
-		#nodetype, parent
-		$result = $ppctab->getNodesAttribs(\@parray, ['parent']);
-                my $typehash = xCAT::DBobjUtils->getnodetype(\@parray);
-		foreach(@parray){
-			my $value = $result->{$_};
-			if ($value->[0]){
-				$phash{$_} = $$typehash{$_} . ':' . $value->[0]->{'parent'} . ':';
-			}
-			else{
-				push(@missinfoarray, $_);
-			}
-		}
-		$ppctab->close();
+    # Save all nodes into a hash
+    foreach (@tempArray) {
+        $temphash{$_} = 1;
+    }
+    
+    for ( my $i = 0 ; $i < scalar(@tempArray) ; $i = $i + 2 ) {
+        $temphash{ $tempArray[$i] } = $tempArray[ $i + 1 ];
+    }
+    
+    `rscan $hcpname -z > /tmp/rscanall.tmp`;
 
-		undef @parray;
-		@parray = keys %phash;
-	}
-	if (scalar(@parray) > 0){
-		#mtm
-		my $vpdtab = xCAT::Table->new('vpd');
-		$result = $vpdtab->getNodesAttribs(\@parray, ['mtm']);
-		foreach(@parray){
-			my $value = $result->{$_};
-			$phash{$_} = $phash{$_} . $value->[0]->{'mtm'} . ':';
-		}
-		$vpdtab->close();
-		
-		#status
-		my $nodelisttab = xCAT::Table->new('nodelist');
-		$result = $nodelisttab->getNodesAttribs(\@parray, ['status']);
-		foreach(@parray){
-			my $value = $result->{$_};
-			$phash{$_} = $phash{$_} . $value->[0]->{'status'};
-		}
-		$nodelisttab->close();
+    unless ( -e '/tmp/rscanall.tmp' ) {
+        return;
+    }
 
-		while(my ($key, $value) = each(%phash)){
-			$pretstr = $pretstr . $key . ':' . $value . ';';
-		}
-	}
+    open( INPUTFILE,  '/tmp/rscanall.tmp' );
+    open( OUTPUTFILE, '>/tmp/webrscan.tmp' );
+    while ( $line = <INPUTFILE> ) {
+        if ( $line =~ /(\S+):$/ ) {
+            if ( $temphash{$1} ) {
+                $writeflag = 1;
+                print OUTPUTFILE $temphash{$1} . ":\n";
+            } else {
+                $writeflag = 0;
+            }
+        } else {
+            if ($writeflag) {
+                print OUTPUTFILE $line;
+            }
+        }
+    }
 
-	#get all information for blade node
-	if (scalar(@bladearray) > 0){
-		#mpa, id
-		my $mptab = xCAT::Table->new('mp');
-		$result = $mptab->getNodesAttribs(\@bladearray, ['mpa', 'id']);
-		foreach(@bladearray){
-			my $value = $result->{$_};
-			if ($value->[0]->{'mpa'}){
-				$bladehash{$_} = 'blade:' . $value->[0]->{'mpa'} . ':' . $value->[0]->{'id'} . ':';
-			}
-			else{
-				push(@missinfoarray, $_);
-			}
-		}
-		$mptab->close();
+    close(INPUTFILE);
+    close(OUTPUTFILE);
+    unlink('/tmp/rscanall.tmp');
 
-		undef @bladearray;
-		@bladearray = keys %bladehash;
-	}
-	if (scalar(@bladearray) > 0){
-		#status
-		my $nodelisttab = xCAT::Table->new('nodelist');
-		$result = $nodelisttab->getNodesAttribs(\@bladearray, ['status']);
-		foreach(@bladearray){
-			my $value = $result->{$_};
-			$bladehash{$_} = $bladehash{$_} . $value->[0]->{'status'};
-		}
-		$nodelisttab->close();
-		while(my ($key, $value) = each(%bladehash)){
-			$bladeretstr = $bladeretstr . $key . ':' . $value . ';';
-		}
-	}
+    `cat /tmp/webrscan.tmp | chdef -z`;
+    unlink('/tmp/webrscan.tmp');
+}
 
-	#get all information for system x node
-	if (scalar(@xarray) > 0){
-		#rack, unit
-		my $nodepostab = xCAT::Table->new('nodepos');
-		$result = $nodepostab->getNodesAttribs(\@xarray, ['rack', 'u']);
-		foreach(@xarray){
-			my $value = $result->{$_};
-			if ($value->[0]->{'rack'}){
-				$xhash{$_} = 'systemx:' . $value->[0]->{'rack'} . ':' . $value->[0]->{'u'} . ':';
-			}
-			else{
-				push(@missinfoarray, $_);
-			}
-		}
-		$nodepostab->close();
+sub web_graphinfo {
+    my ( $request, $callback, $sub_req ) = @_;
+    my $nodetypeTab;
+    my @nodes;
+    my @parray;
+    my @bladearray;
+    my @xarray;
+    my %phash;
+    my %bladehash;
+    my %xhash;
+    my @unsupportarray;
+    my @missinfoarray;
+    my $result;
+    my $pretstr     = '';
+    my $bladeretstr = '';
+    my $xretstr     = '';
+    my $unsupretstr = '';
+    my $missretstr  = '';
 
-		undef @xarray;
-		@xarray = keys %xhash;
-	}
-	if (scalar(@xarray) > 0){
-		#mtm
-		my $vpdtab = xCAT::Table->new('vpd');
-		$result = $vpdtab->getNodesAttribs(\@xarray, ['mtm']);
-		foreach(@xarray){
-			my $value = $result->{$_};
-			$xhash{$_} = $xhash{$_} . $value->[0]->{'mtm'} . ':';
-		}
-		$vpdtab->close();
+    @nodes = xCAT::DBobjUtils->getObjectsOfType('node');
 
-		#status
-		my $nodelisttab = xCAT::Table->new('nodelist');
-		$result = $nodelisttab->getNodesAttribs(\@xarray, ['status']);
-		foreach(@xarray){
-			my $value = $result->{$_};
-			$xhash{$_} = $xhash{$_} . $value->[0]->{'status'};
-		}
-		while(my ($key, $value) = each(%xhash)){
-			$xretstr = $xretstr . $key . ':' . $value . ';';
-		}
-	}
+    $nodetypeTab = xCAT::Table->new('nodetype');
+    unless ($nodetypeTab) {
+        return;
+    }
 
-	foreach(@missinfoarray){
-		$missretstr = $missretstr . $_ . ':linux:other;'; 
-	}
+    # Get all nodetype and seperate nodes into different group
+    $result = $nodetypeTab->getNodesAttribs( \@nodes, ['nodetype'] );
+    while ( my ( $key, $value ) = each(%$result) ) {
+        my $temptype = $value->[0]->{'nodetype'};
+        if ( $temptype =~ /(ppc|lpar|cec|frame)/i ) {
+            push( @parray, $key );
+        } elsif ( $temptype =~ /blade/i ) {
+            push( @bladearray, $key );
+        } elsif ( $temptype =~ /osi/i ) {
+            push( @xarray, $key );
+        } else {
+            push( @unsupportarray, $key );
+        }
+    }
+    $nodetypeTab->close();
 
-	#combine all information into a string
-	my $retstr = $pretstr . $bladeretstr . $xretstr . $missretstr;
-	if ($retstr){
-		$retstr = substr($retstr, 0, -1);
-	}
+    # Get all information for System p node
+    if ( scalar(@parray) > 0 ) {
+        my $ppctab = xCAT::Table->new('ppc');
 
-	$callback->({data => $retstr});
+        $result = $ppctab->getNodesAttribs( \@parray, ['parent'] );
+        my $typehash = xCAT::DBobjUtils->getnodetype( \@parray );
+        foreach (@parray) {
+            my $value = $result->{$_};
+            if ( $value->[0] ) {
+                $phash{$_} = $$typehash{$_} . ':' . $value->[0]->{'parent'} . ':';
+            } else {
+                push( @missinfoarray, $_ );
+            }
+        }
+        $ppctab->close();
+
+        undef @parray;
+        @parray = keys %phash;
+    }
+    if ( scalar(@parray) > 0 ) {
+        # mtm
+        my $vpdtab = xCAT::Table->new('vpd');
+        $result = $vpdtab->getNodesAttribs( \@parray, ['mtm'] );
+        foreach (@parray) {
+            my $value = $result->{$_};
+            $phash{$_} = $phash{$_} . $value->[0]->{'mtm'} . ':';
+        }
+        $vpdtab->close();
+
+        # Status
+        my $nodelisttab = xCAT::Table->new('nodelist');
+        $result = $nodelisttab->getNodesAttribs( \@parray, ['status'] );
+        foreach (@parray) {
+            my $value = $result->{$_};
+            $phash{$_} = $phash{$_} . $value->[0]->{'status'};
+        }
+        $nodelisttab->close();
+
+        while ( my ( $key, $value ) = each(%phash) ) {
+            $pretstr = $pretstr . $key . ':' . $value . ';';
+        }
+    }
+
+    # Get all information for blade node
+    if ( scalar(@bladearray) > 0 ) {
+        my $mptab = xCAT::Table->new('mp');
+        $result = $mptab->getNodesAttribs( \@bladearray, [ 'mpa', 'id' ] );
+        foreach (@bladearray) {
+            my $value = $result->{$_};
+            if ( $value->[0]->{'mpa'} ) {
+                $bladehash{$_} = 'blade:' . $value->[0]->{'mpa'} . ':' . $value->[0]->{'id'} . ':';
+            } else {
+                push( @missinfoarray, $_ );
+            }
+        }
+        
+        $mptab->close();
+
+        undef @bladearray;
+        @bladearray = keys %bladehash;
+    }
+    
+    if ( scalar(@bladearray) > 0 ) {
+        # Status
+        my $nodelisttab = xCAT::Table->new('nodelist');
+        $result = $nodelisttab->getNodesAttribs( \@bladearray, ['status'] );
+        foreach (@bladearray) {
+            my $value = $result->{$_};
+            $bladehash{$_} = $bladehash{$_} . $value->[0]->{'status'};
+        }
+        $nodelisttab->close();
+        while ( my ( $key, $value ) = each(%bladehash) ) {
+            $bladeretstr = $bladeretstr . $key . ':' . $value . ';';
+        }
+    }
+
+    # Get all information for System x node
+    if ( scalar(@xarray) > 0 ) {
+        # Rack and unit
+        my $nodepostab = xCAT::Table->new('nodepos');
+        $result = $nodepostab->getNodesAttribs( \@xarray, [ 'rack', 'u' ] );
+        foreach (@xarray) {
+            my $value = $result->{$_};
+            if ( $value->[0]->{'rack'} ) {
+                $xhash{$_} = 'systemx:' . $value->[0]->{'rack'} . ':' . $value->[0]->{'u'} . ':';
+            } else {
+                push( @missinfoarray, $_ );
+            }
+        }
+        
+        $nodepostab->close();
+
+        undef @xarray;
+        @xarray = keys %xhash;
+    }
+    
+    if ( scalar(@xarray) > 0 ) {
+        # mtm
+        my $vpdtab = xCAT::Table->new('vpd');
+        $result = $vpdtab->getNodesAttribs( \@xarray, ['mtm'] );
+        foreach (@xarray) {
+            my $value = $result->{$_};
+            $xhash{$_} = $xhash{$_} . $value->[0]->{'mtm'} . ':';
+        }
+        $vpdtab->close();
+
+        # Status
+        my $nodelisttab = xCAT::Table->new('nodelist');
+        $result = $nodelisttab->getNodesAttribs( \@xarray, ['status'] );
+        foreach (@xarray) {
+            my $value = $result->{$_};
+            $xhash{$_} = $xhash{$_} . $value->[0]->{'status'};
+        }
+        
+        while ( my ( $key, $value ) = each(%xhash) ) {
+            $xretstr = $xretstr . $key . ':' . $value . ';';
+        }
+    }
+
+    foreach (@missinfoarray) {
+        $missretstr = $missretstr . $_ . ':linux:other;';
+    }
+
+    # Combine all information into a string
+    my $retstr = $pretstr . $bladeretstr . $xretstr . $missretstr;
+    if ($retstr) {
+        $retstr = substr( $retstr, 0, -1 );
+    }
+
+    $callback->( { data => $retstr } );
 }
 
 sub web_getdefaultuserentry {
-	# Get default user entry
-	my ( $request, $callback, $sub_req ) = @_;
-	
-	# Get profile
-	my $profile = $request->{arg}->[1];
-	
-	if (!$profile) {
-		$profile = 'default';
-	}
-	
-	my $entry;
-	if (!(`test -e /var/opt/xcat/profiles/$profile.direct && echo 'File exists'`)) {
-		$entry = `cat /var/opt/xcat/profiles/default.direct`;
-	} else {
-		$entry = `cat /var/opt/xcat/profiles/$profile.direct`;	
-	}
-	
-	$callback->( { data => $entry } );
+
+    # Get default user entry
+    my ( $request, $callback, $sub_req ) = @_;
+
+    # Get profile
+    my $profile = $request->{arg}->[1];
+
+    if ( !$profile ) {
+        $profile = 'default';
+    }
+
+    my $entry;
+    if ( !(`test -e /var/opt/xcat/profiles/$profile.direct && echo 'File exists'`) ) {
+        $entry = `cat /var/opt/xcat/profiles/default.direct`;
+    } else {
+        $entry = `cat /var/opt/xcat/profiles/$profile.direct`;
+    }
+
+    $callback->( { data => $entry } );
 }
 
 sub web_passwd() {
-	my ( $request, $callback, $sub_req ) = @_;
+    my ( $request, $callback, $sub_req ) = @_;
 
-	# Get current and new passwords
-	my $user = $request->{arg}->[1];
-	my $newPassword = $request->{arg}->[2];
-	
-	# Generate encrypted password
-	my $random = rand(10000000);
-	my $encrypted = `perl -e "print crypt($newPassword, $random)"`;
-	# Save in xCAT passwd table
-	`chtab username=$user passwd.key=xcat passwd.password=$encrypted`;
-	
-	my $info = "Password successfully changed";
-	$callback->( { info => $info } );
-	return;
+    # Get current and new passwords
+    my $user        = $request->{arg}->[1];
+    my $newPassword = $request->{arg}->[2];
+
+    # Generate encrypted password
+    my $random    = rand(10000000);
+    my $encrypted = `perl -e "print crypt($newPassword, $random)"`;
+
+    # Save in xCAT passwd table
+    `chtab username=$user passwd.key=xcat passwd.password=$encrypted`;
+
+    my $info = "Password successfully changed";
+    $callback->( { info => $info } );
+    return;
 }
 
 sub web_updateuser() {
-	my ( $request, $callback, $sub_req ) = @_;
+    my ( $request, $callback, $sub_req ) = @_;
 
-	# Get user attributes
-	my $priority = $request->{arg}->[1];
-	my $user = $request->{arg}->[2];
-	my $password = $request->{arg}->[3];
-	my $maxVM = $request->{arg}->[4];
-	
-	# Save in xCAT passwd and policy tables
-	`chtab username=$user passwd.key=xcat passwd.password=$password`;
-	`chtab name=$user policy.priority=$priority policy.rule=allow policy.comments="max-vm:$maxVM"`;
-	
-	my $info = "User successfully updated";
-	$callback->( { info => $info } );
-	return;
+    # Get user attributes
+    my $priority = $request->{arg}->[1];
+    my $user     = $request->{arg}->[2];
+    my $password = $request->{arg}->[3];
+    my $maxVM    = $request->{arg}->[4];
+
+    # Save in xCAT passwd and policy tables
+    `chtab username=$user passwd.key=xcat passwd.password=$password`;
+`chtab name=$user policy.priority=$priority policy.rule=allow policy.comments="max-vm:$maxVM"`;
+
+    my $info = "User successfully updated";
+    $callback->( { info => $info } );
+    return;
 }
 
 sub web_deleteuser() {
-	my ( $request, $callback, $sub_req ) = @_;
+    my ( $request, $callback, $sub_req ) = @_;
 
-	# Get user attributes
-	my $user = $request->{arg}->[1];
-	my @users = split( ',', $user );
-		
-	# Delete user from xCAT passwd and policy tables
-	foreach(@users) {
-		`chtab -d username=$_ passwd`;
-		`chtab -d name=$_ policy`;
-	}
+    # Get user attributes
+    my $user  = $request->{arg}->[1];
+    my @users = split( ',', $user );
 
-	my $info = "User successfully deleted";
-	$callback->( { info => $info } );
-	return;
+    # Delete user from xCAT passwd and policy tables
+    foreach (@users) {
+        `chtab -d username=$_ passwd`;
+        `chtab -d name=$_ policy`;
+    }
+
+    my $info = "User successfully deleted";
+    $callback->( { info => $info } );
+    return;
 }
 
 sub web_getzdiskinfo() {
-	# Get default disk info
-	my ( $request, $callback, $sub_req ) = @_;
-	
-	# Get profile
-	my $profile = $request->{arg}->[1];
-	
-	if (!$profile) {
-		$profile = 'default';
-	}
-	
-	my $info;
-	if (!(`test -e /var/opt/xcat/profiles/$profile.conf && echo 'File exists'`)) {
-		$info = `cat /var/opt/xcat/profiles/default.conf`;
-	} else {
-		$info = `cat /var/opt/xcat/profiles/$profile.conf`;	
-	}
-	
-	$callback->( { info => $info } );
+
+    # Get default disk info
+    my ( $request, $callback, $sub_req ) = @_;
+
+    # Get profile
+    my $profile = $request->{arg}->[1];
+
+    if ( !$profile ) {
+        $profile = 'default';
+    }
+
+    my $info;
+    if ( !(`test -e /var/opt/xcat/profiles/$profile.conf && echo 'File exists'`)) {
+        $info = `cat /var/opt/xcat/profiles/default.conf`;
+    } else {
+        $info = `cat /var/opt/xcat/profiles/$profile.conf`;
+    }
+
+    $callback->( { info => $info } );
 }
 
 sub web_mkzprofile() {
-	# Create default profile
-	my ( $request, $callback, $sub_req ) = @_;
-	
-	# Get profile
-	my $profile = $request->{arg}->[1];
-	my $pool = $request->{arg}->[2];
-	my $size = $request->{arg}->[3];
-		
-	# Create profile under /var/opt/xcat/profiles
-	my $var = "";
-	`echo "# Configuration for virtual machines" > /var/opt/xcat/profiles/$profile.conf`;
-	$var = $profile . "_diskpool";
-	`echo "$var=$pool" >> /var/opt/xcat/profiles/$profile.conf`;
-	$var = $profile . "_eckd_size";
-	`echo "$var=$size" >> /var/opt/xcat/profiles/$profile.conf`;
-	
-	# Move directory entry into /var/opt/xcat/profiles from /var/tmp
-	`mv /var/tmp/$profile.direct /var/opt/xcat/profiles`;
 
-	my $info = "Profile successfully created/updated";
-	$callback->( { info => $info } );
+    # Create default profile
+    my ( $request, $callback, $sub_req ) = @_;
+
+    # Get profile
+    my $profile = $request->{arg}->[1];
+    my $pool    = $request->{arg}->[2];
+    my $size    = $request->{arg}->[3];
+
+    # Create profile under /var/opt/xcat/profiles
+    my $var = "";
+`echo "# Configuration for virtual machines" > /var/opt/xcat/profiles/$profile.conf`;
+    $var = $profile . "_diskpool";
+    `echo "$var=$pool" >> /var/opt/xcat/profiles/$profile.conf`;
+    $var = $profile . "_eckd_size";
+    `echo "$var=$size" >> /var/opt/xcat/profiles/$profile.conf`;
+
+    # Move directory entry into /var/opt/xcat/profiles from /var/tmp
+    `mv /var/tmp/$profile.direct /var/opt/xcat/profiles`;
+
+    my $info = "Profile successfully created/updated";
+    $callback->( { info => $info } );
 }
 
 sub web_rmzprofile() {
-	# Delete default profile
-	my ( $request, $callback, $sub_req ) = @_;
-	
-	# Get profile
-	my $profile = $request->{arg}->[1];
-	my @profiles = split( ',', $profile );
-		
-	# Delete profile under /var/opt/xcat/profiles
-	foreach(@profiles) {
-		`rm /var/opt/xcat/profiles/$_.conf`;
-		`rm /var/opt/xcat/profiles/$_.direct`;
-	}
 
-	my $info = "Profile successfully deleted";
-	$callback->( { info => $info } );
+    # Delete default profile
+    my ( $request, $callback, $sub_req ) = @_;
+
+    # Get profile
+    my $profile  = $request->{arg}->[1];
+    my @profiles = split( ',', $profile );
+
+    # Delete profile under /var/opt/xcat/profiles
+    foreach (@profiles) {
+        `rm /var/opt/xcat/profiles/$_.conf`;
+        `rm /var/opt/xcat/profiles/$_.direct`;
+    }
+
+    my $info = "Profile successfully deleted";
+    $callback->( { info => $info } );
 }
 
 sub web_updateosimage() {
-	# Add OS image to xCAT table
-	my ( $request, $callback, $sub_req ) = @_;
-		
-	my $name = $request->{arg}->[1];
-	my $type = $request->{arg}->[2];
-	my $arch = $request->{arg}->[3];
-	my $osName = $request->{arg}->[4];
-	my $osVersion = $request->{arg}->[5];
-	my $profile = $request->{arg}->[6];
-	my $provMethod = $request->{arg}->[7];
-	my $comments = $request->{arg}->[8];
-	
-	`chtab -d imagename=$name osimage`;
-	`chtab osimage.imagename=$name osimage.imagetype=$type osimage.osarch=$arch osimage.osname=$osName osimage.osvers=$osVersion osimage.profile=$profile osimage.provmethod=$provMethod osimage.comments=$comments`;
-	my $info = "Image successfully updated";
-	$callback->( { info => $info } );
+
+    # Add OS image to xCAT table
+    my ( $request, $callback, $sub_req ) = @_;
+
+    my $name       = $request->{arg}->[1];
+    my $type       = $request->{arg}->[2];
+    my $arch       = $request->{arg}->[3];
+    my $osName     = $request->{arg}->[4];
+    my $osVersion  = $request->{arg}->[5];
+    my $profile    = $request->{arg}->[6];
+    my $provMethod = $request->{arg}->[7];
+    my $comments   = $request->{arg}->[8];
+
+    `chtab -d imagename=$name osimage`;
+    `chtab osimage.imagename=$name osimage.imagetype=$type osimage.osarch=$arch osimage.osname=$osName osimage.osvers=$osVersion osimage.profile=$profile osimage.provmethod=$provMethod osimage.comments=$comments`;
+    my $info = "Image successfully updated";
+    $callback->( { info => $info } );
 }
 
 sub web_rmosimage() {
-	# Delete OS image from xCAT table
-	my ( $request, $callback, $sub_req ) = @_;
-		
-	my $name = $request->{arg}->[1];
-	my @names = split( ',', $name );
-		
-	# Delete user from xCAT passwd and policy tables
-	foreach(@names) {		
-		`chtab -d imagename=$_ osimage`;
-	}
-	
-	my $info = "Image successfully deleted";
-	$callback->( { info => $info } );
+
+    # Delete OS image from xCAT table
+    my ( $request, $callback, $sub_req ) = @_;
+
+    my $name  = $request->{arg}->[1];
+    my @names = split( ',', $name );
+
+    # Delete user from xCAT passwd and policy tables
+    foreach (@names) {
+        `chtab -d imagename=$_ osimage`;
+    }
+
+    my $info = "Image successfully deleted";
+    $callback->( { info => $info } );
 }
 
 sub web_updategroup() {
-	# Add group to xCAT table
-	my ( $request, $callback, $sub_req ) = @_;
-		
-	my $name = $request->{arg}->[1];
-	my $ip = $request->{arg}->[2];
-	$ip =~ s/'//g;
-	
-	my $hostnames = $request->{arg}->[3];
-	$hostnames =~ s/'//g;
-	
-	my $comments = $request->{arg}->[4];
-	$comments =~ s/'//g;
-	
-	`chtab -d node=$name hosts`;
-	`chtab node=$name hosts.ip="$ip" hosts.hostnames="$hostnames" hosts.comments="$comments"`;
-	
-	my $info = "Group successfully updated";
-	$callback->( { info => $info } );
+
+    # Add group to xCAT table
+    my ( $request, $callback, $sub_req ) = @_;
+
+    my $name = $request->{arg}->[1];
+    my $ip   = $request->{arg}->[2];
+    $ip =~ s/'//g;
+
+    my $hostnames = $request->{arg}->[3];
+    $hostnames =~ s/'//g;
+
+    my $comments = $request->{arg}->[4];
+    $comments =~ s/'//g;
+
+    `chtab -d node=$name hosts`;
+`chtab node=$name hosts.ip="$ip" hosts.hostnames="$hostnames" hosts.comments="$comments"`;
+
+    my $info = "Group successfully updated";
+    $callback->( { info => $info } );
 }
 
 sub web_rmgroup() {
-	# Delete group from xCAT table
-	my ( $request, $callback, $sub_req ) = @_;
-		
-	my $name = $request->{arg}->[1];
-	my @names = split( ',', $name );
-		
-	# Delete user from xCAT passwd and policy tables
-	foreach(@names) {		
-		`chtab -d node=$_ hosts`;
-	}
-	
-	my $info = "Group successfully deleted";
-	$callback->( { info => $info } );
+
+    # Delete group from xCAT table
+    my ( $request, $callback, $sub_req ) = @_;
+
+    my $name  = $request->{arg}->[1];
+    my @names = split( ',', $name );
+
+    # Delete user from xCAT passwd and policy tables
+    foreach (@names) {
+        `chtab -d node=$_ hosts`;
+    }
+
+    my $info = "Group successfully deleted";
+    $callback->( { info => $info } );
 }
 1;
diff --git a/xCAT-UI/xcat/plugins/webportal.pm b/xCAT-UI/xcat/plugins/webportal.pm
index 4f6fd2387..89247941f 100644
--- a/xCAT-UI/xcat/plugins/webportal.pm
+++ b/xCAT-UI/xcat/plugins/webportal.pm
@@ -26,763 +26,763 @@ sub handled_commands {
 
 # In order for this to work, you need to run: ln -s /opt/xcat/bin/xcatclientnnr /opt/xcat/bin/webportal
 # xcatclientnnr allows command to run without a node range
-	return { webportal => "webportal" };
+    return { webportal => "webportal" };
 }
 
 sub process_request {
-	my $request         = shift;
-	my $callback        = shift;
-	my $sub_req         = shift;
-	my %authorized_cmds = (
-		'lszvm'       => \&lszvm,
-		'provzlinux'  => \&provzlinux,
-		'clonezlinux' => \&clonezlinux,
-		'genhostip'   => \&genhostip,
-		'getmaxvm'    => \&getmaxvm,
-		'getuserprivilege' => \&getuserprivilege
-	);
+    my $request         = shift;
+    my $callback        = shift;
+    my $sub_req         = shift;
+    my %authorized_cmds = (
+        'lszvm'       => \&lszvm,
+        'provzlinux'  => \&provzlinux,
+        'clonezlinux' => \&clonezlinux,
+        'genhostip'   => \&genhostip,
+        'getmaxvm'    => \&getmaxvm,
+        'getuserprivilege' => \&getuserprivilege
+    );
 
-	# Check if the request is authorized
-	split ' ', $request->{arg}->[0];
-	my $cmd = $_[0];
-	if ( grep { $_ eq $cmd } keys %authorized_cmds ) {
-		my $func = $authorized_cmds{$cmd};
-		$func->( $request, $callback, $sub_req );
-	}
-	else {
-		$callback->(
-			{ error => "$cmd is not authorized!\n", errorcode => [1] } );
-	}
+    # Check if the request is authorized
+    split ' ', $request->{arg}->[0];
+    my $cmd = $_[0];
+    if ( grep { $_ eq $cmd } keys %authorized_cmds ) {
+        my $func = $authorized_cmds{$cmd};
+        $func->( $request, $callback, $sub_req );
+    }
+    else {
+        $callback->(
+            { error => "$cmd is not authorized!\n", errorcode => [1] } );
+    }
 }
 
 sub println {
-	my $callback = shift;
-	my $msg      = shift;
-	my %rsp;
-	push @{ $rsp{info} }, $msg;
-	xCAT::MsgUtils->message( 'I', \%rsp, $callback );
-	return;
+    my $callback = shift;
+    my $msg      = shift;
+    my %rsp;
+    push @{ $rsp{info} }, $msg;
+    xCAT::MsgUtils->message( 'I', \%rsp, $callback );
+    return;
 }
 
 sub lszvm {
-	my ( $request, $callback, $sub_req ) = @_;
+    my ( $request, $callback, $sub_req ) = @_;
 
-	# List the zVM and their respective HCP
-	my $out = "";
-	my %pair;
+    # List the zVM and their respective HCP
+    my $out = "";
+    my %pair;
 
-	# Look in 'zvm' table
-	my $tab = xCAT::Table->new( 'zvm', -create => 1, -autocommit => 0 );
-	my @results = $tab->getAllAttribsWhere( "nodetype='vm'", 'hcp', 'parent' );
-	foreach (@results) {
-		if ( $_->{'hcp'} && $_->{'parent'} && !$pair{ $_->{'hcp'} } ) {
+    # Look in 'zvm' table
+    my $tab = xCAT::Table->new( 'zvm', -create => 1, -autocommit => 0 );
+    my @results = $tab->getAllAttribsWhere( "nodetype='vm'", 'hcp', 'parent' );
+    foreach (@results) {
+        if ( $_->{'hcp'} && $_->{'parent'} && !$pair{ $_->{'hcp'} } ) {
 
-			# Save zVM:HCP pairing
-			$pair{ $_->{'hcp'} } = $_->{'parent'};
+            # Save zVM:HCP pairing
+            $pair{ $_->{'hcp'} } = $_->{'parent'};
 
-			# Print out zVM:HCP
-			$out .= $_->{'parent'} . ":" . $_->{'hcp'} . "\n";
-		}
-	}
+            # Print out zVM:HCP
+            $out .= $_->{'parent'} . ":" . $_->{'hcp'} . "\n";
+        }
+    }
 
-	$callback->( { data => $out } );
+    $callback->( { data => $out } );
 }
 
 sub provzlinux {
-	my ( $request, $callback, $sub_req ) = @_;
+    my ( $request, $callback, $sub_req ) = @_;
 
-	my $group = $request->{arg}->[1];
-	my $hcp   = $request->{arg}->[2];
-	my $img   = $request->{arg}->[3];
-	my $owner = $request->{arg}->[4];
-	
-	# Exit if missing inputs
-	if ( !$group || !$hcp || !$img || !$owner ) {
-		println( $callback, '(Error) Missing group, HCP, image, or owner' );
-		return;
-	}
-	
-	# Check the max # of virtual machines allowed
-	my $out = `tabdump nodetype -w nodetype.comments=~"owner:$owner"`;
-	my @tmp = split( /\n/, $out );
-	my $usrVM = scalar(@tmp) - 1;
-	
-	$out = `webportal getmaxvm $owner`;
-	$out =~ s/Max allowed: //g;
-	my $maxVM = int($out);
-	
-	# Do not continue if the max # is reached
-	if ($usrVM >= $maxVM) {
-		println( $callback, "You have reached the maximum number of virtual machines allowed ($maxVM). Delete unused virtual machines or contact your system administrator request more virtual machines.");
-		return;
-	}
+    my $group = $request->{arg}->[1];
+    my $hcp   = $request->{arg}->[2];
+    my $img   = $request->{arg}->[3];
+    my $owner = $request->{arg}->[4];
+    
+    # Exit if missing inputs
+    if ( !$group || !$hcp || !$img || !$owner ) {
+        println( $callback, '(Error) Missing group, HCP, image, or owner' );
+        return;
+    }
+    
+    # Check the max # of virtual machines allowed
+    my $out = `tabdump nodetype -w nodetype.comments=~"owner:$owner"`;
+    my @tmp = split( /\n/, $out );
+    my $usrVM = scalar(@tmp) - 1;
+    
+    $out = `webportal getmaxvm $owner`;
+    $out =~ s/Max allowed: //g;
+    my $maxVM = int($out);
+    
+    # Do not continue if the max # is reached
+    if ($usrVM >= $maxVM) {
+        println( $callback, "You have reached the maximum number of virtual machines allowed ($maxVM). Delete unused virtual machines or contact your system administrator request more virtual machines.");
+        return;
+    }
 
-	# Get node OS base
-	my $profile;
-	my $arch;
-	my $os;
-	( $profile, $arch, $os ) = getosimagedef( $callback, $img );
-	if ( $os =~ m/sp/i ) {
-		@tmp = split( /sp/, $os );
-	} else {
-		@tmp = split( /\./, $os );
-	}
-	my $os_base = $tmp[0];
-	
-	# Read in default disk pool and disk size /opt/zhcp/conf/default.conf on zHCP
-	#	pool = POOL3
-	#	eckd_size = 10016
-	my $disk_pool;
-	my $eckd_size;
-	my $fba_size;
-	my $default_conf   = "/var/opt/xcat/profiles/$profile.conf";
-	my $default_direct = "/var/opt/xcat/profiles/$profile.direct";
+    # Get node OS base
+    my $profile;
+    my $arch;
+    my $os;
+    ( $profile, $arch, $os ) = getosimagedef( $callback, $img );
+    if ( $os =~ m/sp/i ) {
+        @tmp = split( /sp/, $os );
+    } else {
+        @tmp = split( /\./, $os );
+    }
+    my $os_base = $tmp[0];
+    
+    # Read in default disk pool and disk size /opt/zhcp/conf/default.conf on zHCP
+    #    pool = POOL3
+    #    eckd_size = 10016
+    my $disk_pool;
+    my $eckd_size;
+    my $fba_size;
+    my $default_conf   = "/var/opt/xcat/profiles/$profile.conf";
+    my $default_direct = "/var/opt/xcat/profiles/$profile.direct";
 
-	# Check if a group based directory entry exists, else use default one
-	if ( !(`test -e /var/opt/xcat/profiles/$profile.direct && echo Exists`) ) {
-		println( $callback, "$profile.direct does not exist.  Using default.direct to generate directory entry." );
-		
-		# Exit if default.direct does not exist
-		$default_direct = '/var/opt/xcat/profiles/default.direct';	
-		if ( !(`test -e /var/opt/xcat/profiles/default.direct && echo Exists`) ) {
-			println( $callback, '(Error) $default_direct does not exists' );
-			return;
-		}
-	}
+    # Check if a group based directory entry exists, else use default one
+    if ( !(`test -e /var/opt/xcat/profiles/$profile.direct && echo Exists`) ) {
+        println( $callback, "$profile.direct does not exist.  Using default.direct to generate directory entry." );
+        
+        # Exit if default.direct does not exist
+        $default_direct = '/var/opt/xcat/profiles/default.direct';    
+        if ( !(`test -e /var/opt/xcat/profiles/default.direct && echo Exists`) ) {
+            println( $callback, '(Error) $default_direct does not exists' );
+            return;
+        }
+    }
 
-	# Exit if default.conf does not exist
-	if ( !(`test -e $default_conf && echo Exists`) ) {
-		println( $callback, '(Error) $default_conf does not exists' );
-		return;
-	}
+    # Exit if default.conf does not exist
+    if ( !(`test -e $default_conf && echo Exists`) ) {
+        println( $callback, '(Error) $default_conf does not exists' );
+        return;
+    }
 
-	# Exit if default.direct does not exist
-	if ( !(`test -e $default_direct && echo Exists`) ) {
-		println( $callback, '(Error) $default_direct does not exists' );
-		return;
-	}
+    # Exit if default.direct does not exist
+    if ( !(`test -e $default_direct && echo Exists`) ) {
+        println( $callback, '(Error) $default_direct does not exists' );
+        return;
+    }
 
-	$out = `cat $default_conf`;
-	@tmp = split( /\n/, $out );
-	# default.conf should contain:
-	
-	# Configuration for virtual machines
-	#	default_diskpool=POOL3
-	#	default_eckd_size=10016
-	my $profile_diskpool_parm = $profile . "_diskpool";
-	my $profile_eckd_size_parm = $profile . "_eckd_size";
-	my $profile_fba_size_parm = $profile . "_fba_size";
-	my $default_disk_pool;
-	my $default_eckd_size;
-	my $default_fba_size;
-	foreach (@tmp) {		
-		# Get profile disk pool (default)
-		if ( $_ =~ m/$profile_diskpool_parm=/i ) {
-			$disk_pool = $_;
-			$disk_pool =~ s/$profile_diskpool_parm=//g;
-		}
-		# Get profile disk size (default)
-		elsif ( $_ =~ m/$profile_eckd_size_parm=/i ) {
-			$eckd_size = $_;
-			$eckd_size =~ s/$profile_eckd_size_parm=//g;
-		}
-		elsif ( $_ =~ m/$profile_fba_size_parm=/i ) {
-			$fba_size = $_;
-			$fba_size =~ s/$profile_fba_size_parm=//g;
-		}
-	}
-	
-	# Use default configuration if profile configuration does not exist
-	if (!$disk_pool && (!$eckd_size || !$fba_size)) {
-		println( $callback, "(Error) $profile configuration for disk pool and size does not exist" );
-		return;
-	}
+    $out = `cat $default_conf`;
+    @tmp = split( /\n/, $out );
+    # default.conf should contain:
+    
+    # Configuration for virtual machines
+    #    default_diskpool=POOL3
+    #    default_eckd_size=10016
+    my $profile_diskpool_parm = $profile . "_diskpool";
+    my $profile_eckd_size_parm = $profile . "_eckd_size";
+    my $profile_fba_size_parm = $profile . "_fba_size";
+    my $default_disk_pool;
+    my $default_eckd_size;
+    my $default_fba_size;
+    foreach (@tmp) {        
+        # Get profile disk pool (default)
+        if ( $_ =~ m/$profile_diskpool_parm=/i ) {
+            $disk_pool = $_;
+            $disk_pool =~ s/$profile_diskpool_parm=//g;
+        }
+        # Get profile disk size (default)
+        elsif ( $_ =~ m/$profile_eckd_size_parm=/i ) {
+            $eckd_size = $_;
+            $eckd_size =~ s/$profile_eckd_size_parm=//g;
+        }
+        elsif ( $_ =~ m/$profile_fba_size_parm=/i ) {
+            $fba_size = $_;
+            $fba_size =~ s/$profile_fba_size_parm=//g;
+        }
+    }
+    
+    # Use default configuration if profile configuration does not exist
+    if (!$disk_pool && (!$eckd_size || !$fba_size)) {
+        println( $callback, "(Error) $profile configuration for disk pool and size does not exist" );
+        return;
+    }
 
-	my $site_tab    = xCAT::Table->new('site');
-	my $hash        = $site_tab->getAttribs( { key => "installdir" }, 'value' );
-	my $install_dir = $hash->{'value'};
+    my $site_tab    = xCAT::Table->new('site');
+    my $hash        = $site_tab->getAttribs( { key => "installdir" }, 'value' );
+    my $install_dir = $hash->{'value'};
 
-	# Get autoyast/kickstart template
-	# Count the number of disks needed
-	my $tmpl;
-	if ( $os =~ m/sles/i ) {
-		$tmpl = "$install_dir/custom/install/sles/$profile.$os_base.$arch.tmpl";
-	} elsif ( $os =~ m/rhel/i ) {
-		$tmpl = "$install_dir/custom/install/rh/$profile.$os_base.$arch.tmpl";
-	}
+    # Get autoyast/kickstart template
+    # Count the number of disks needed
+    my $tmpl;
+    if ( $os =~ m/sles/i ) {
+        $tmpl = "$install_dir/custom/install/sles/$profile.$os_base.$arch.tmpl";
+    } elsif ( $os =~ m/rhel/i ) {
+        $tmpl = "$install_dir/custom/install/rh/$profile.$os_base.$arch.tmpl";
+    }
 
-	# Create VM
-	# e.g. webportal provzlinux [group] [hcp] [image]
-	my ($node, $ip, $base_digit) = gennodename( $callback, $group );
-	if (!$base_digit) {
-		println( $callback, "(Error) Failed to generate node name" );
-		return;
-	}
-	
-	my $userid = $node;
+    # Create VM
+    # e.g. webportal provzlinux [group] [hcp] [image]
+    my ($node, $ip, $base_digit) = gennodename( $callback, $group );
+    if (!$base_digit) {
+        println( $callback, "(Error) Failed to generate node name" );
+        return;
+    }
+    
+    my $userid = $node;
 
-	# Set node definitions
-	# Also put node into all group
-	if ($group eq 'all') {
-		$out = `mkdef -t node -o $node userid=$userid hcp=$hcp mgt=zvm groups=$group`;
-	} else {
-		# Put node in all group
-		$out = `mkdef -t node -o $node userid=$userid hcp=$hcp mgt=zvm groups=$group,all`;
-	}	
-	println( $callback, "$out" );
+    # Set node definitions
+    # Also put node into all group
+    if ($group eq 'all') {
+        $out = `mkdef -t node -o $node userid=$userid hcp=$hcp mgt=zvm groups=$group`;
+    } else {
+        # Put node in all group
+        $out = `mkdef -t node -o $node userid=$userid hcp=$hcp mgt=zvm groups=$group,all`;
+    }    
+    println( $callback, "$out" );
 
-	# Set nodetype definitions
-	$out = `chtab node=$node noderes.netboot=zvm nodetype.nodetype=osi nodetype.provmethod=install nodetype.os=$os nodetype.arch=$arch nodetype.profile=$profile nodetype.comments="owner:$owner"`;
+    # Set nodetype definitions
+    $out = `chtab node=$node noderes.netboot=zvm nodetype.nodetype=osi nodetype.provmethod=install nodetype.os=$os nodetype.arch=$arch nodetype.profile=$profile nodetype.comments="owner:$owner"`;
 
-	# Update hosts table and DNS
-	`makehosts`;
-	`makedns`;
+    # Update hosts table and DNS
+    `makehosts`;
+    `makedns`;
 
-	# Create user directory entry replacing LXUSR with user ID
-	# Use /opt/zhcp/conf/default.direct on zHCP as the template
-	#	USER LXUSR PSWD 512M 1G G
-	#	INCLUDE LNXDFLT
-	#	COMMAND SET VSWITCH VSW2 GRANT LXUSR
-	$out = `sed $default_direct -e s/LXUSR/$userid/g > /tmp/$node-direct.txt`;
-	$out = `mkvm $node /tmp/$node-direct.txt`;
-	`rm -rf /tmp/$node-direct.txt`;
-	println( $callback, "$out" );
-	if ( $out =~ m/Error/i ) {
-		return;
-	}
+    # Create user directory entry replacing LXUSR with user ID
+    # Use /opt/zhcp/conf/default.direct on zHCP as the template
+    #    USER LXUSR PSWD 512M 1G G
+    #    INCLUDE LNXDFLT
+    #    COMMAND SET VSWITCH VSW2 GRANT LXUSR
+    $out = `sed $default_direct -e s/LXUSR/$userid/g > /tmp/$node-direct.txt`;
+    $out = `mkvm $node /tmp/$node-direct.txt`;
+    `rm -rf /tmp/$node-direct.txt`;
+    println( $callback, "$out" );
+    if ( $out =~ m/Error/i ) {
+        return;
+    }
 
-	# Add MDISKs to user directory entry
-	# Use /opt/zhcp/conf/default.conf on zHCP to determine disk pool and disk size
-	#	pool = POOL3
-	#	eckd_size = 10016
+    # Add MDISKs to user directory entry
+    # Use /opt/zhcp/conf/default.conf on zHCP to determine disk pool and disk size
+    #    pool = POOL3
+    #    eckd_size = 10016
 
-	my $type;
-	my $virt_addr;
-	if ( $os =~ m/sles/i ) {
-		# Create XML object
-		my $xml = new XML::Simple;
-	
-		# Read XML file
-		my $data = $xml->XMLin($tmpl);
-		
-		my $devices = $data->{'dasd'}->{'devices'}->{'listentry'};
-		foreach (@$devices) {
-	
-			# Get disk virtual address and disk type
-			$type = $_->{'drivers'}->{'listentry'}->{'modules'}->{'module_entry'}->{'listentry'};
-			$virt_addr = $_->{'sysfs_bus_id'};
-			$virt_addr =~ s/0\.0\.//g;
-			foreach (@$type) {
-				# Add ECKD disk
-				if ( $_ =~ m/dasd_eckd_mod/i ) {
-					$out = `chvm $node --add3390 $disk_pool $virt_addr $eckd_size MR`;
-					println( $callback, "$out" );
-					if ( $out =~ m/Error/i ) {
-						return;
-					}
-				}
-	
-				# Add FBA disk
-				elsif ( $_ =~ m/dasd_fba_mod/i ) {
-					# To be continued
-					# $out = `chvm $node --add9336 $disk_pool $virt_addr $fba_size MR`;
-				}
-			}
-		}    # End of foreach
-	} elsif ( $os =~ m/rhel/i ) {
-		my %devices;
-		my $dev;
-		$virt_addr = 100;
-		
-		# Read in kickstart file
-		$out = `cat $tmpl | egrep "part /"`;
-		@tmp = split( /\n/, $out );
-		foreach (@tmp) {
-			$out = substr( $out, index( $out, '--ondisk=' )+9 );	
-			$out =~ s/\s*$//;	# Trim right
-			$out =~ s/^\s*//;	# Trim left
-			$devices{$out} = 1;
-		}
-		
-		# Add ECKD disk for each device found
-		for $dev ( keys %devices ) {
-			$out = `chvm $node --add3390 $disk_pool $virt_addr $eckd_size MR`;
-			println( $callback, "$out" );
-			if ( $out =~ m/Error/i ) {
-				return;
-			}
-			
-			# Increment virtual address
-			$virt_addr = $virt_addr + 1;
-		}
-	}
+    my $type;
+    my $virt_addr;
+    if ( $os =~ m/sles/i ) {
+        # Create XML object
+        my $xml = new XML::Simple;
+    
+        # Read XML file
+        my $data = $xml->XMLin($tmpl);
+        
+        my $devices = $data->{'dasd'}->{'devices'}->{'listentry'};
+        foreach (@$devices) {
+    
+            # Get disk virtual address and disk type
+            $type = $_->{'drivers'}->{'listentry'}->{'modules'}->{'module_entry'}->{'listentry'};
+            $virt_addr = $_->{'sysfs_bus_id'};
+            $virt_addr =~ s/0\.0\.//g;
+            foreach (@$type) {
+                # Add ECKD disk
+                if ( $_ =~ m/dasd_eckd_mod/i ) {
+                    $out = `chvm $node --add3390 $disk_pool $virt_addr $eckd_size MR`;
+                    println( $callback, "$out" );
+                    if ( $out =~ m/Error/i ) {
+                        return;
+                    }
+                }
+    
+                # Add FBA disk
+                elsif ( $_ =~ m/dasd_fba_mod/i ) {
+                    # To be continued
+                    # $out = `chvm $node --add9336 $disk_pool $virt_addr $fba_size MR`;
+                }
+            }
+        }    # End of foreach
+    } elsif ( $os =~ m/rhel/i ) {
+        my %devices;
+        my $dev;
+        $virt_addr = 100;
+        
+        # Read in kickstart file
+        $out = `cat $tmpl | egrep "part /"`;
+        @tmp = split( /\n/, $out );
+        foreach (@tmp) {
+            $out = substr( $out, index( $out, '--ondisk=' )+9 );    
+            $out =~ s/\s*$//;    # Trim right
+            $out =~ s/^\s*//;    # Trim left
+            $devices{$out} = 1;
+        }
+        
+        # Add ECKD disk for each device found
+        for $dev ( keys %devices ) {
+            $out = `chvm $node --add3390 $disk_pool $virt_addr $eckd_size MR`;
+            println( $callback, "$out" );
+            if ( $out =~ m/Error/i ) {
+                return;
+            }
+            
+            # Increment virtual address
+            $virt_addr = $virt_addr + 1;
+        }
+    }
 
-	# Update DHCP
-	`makedhcp -a`;
+    # Update DHCP
+    `makedhcp -a`;
 
-	# Toggle node power so COMMAND SET will get executed
-	`rpower $node on`;
-	`rpower $node off`;
+    # Toggle node power so COMMAND SET will get executed
+    `rpower $node on`;
+    `rpower $node off`;
 
-	# Punch kernel, initrd, and ramdisk to node reader
-	$out = `nodeset $node install`;
-	println( $callback, "$out" );
-	if ( $out =~ m/Error/i ) {
-		return;
-	}
+    # Punch kernel, initrd, and ramdisk to node reader
+    $out = `nodeset $node install`;
+    println( $callback, "$out" );
+    if ( $out =~ m/Error/i ) {
+        return;
+    }
 
-	# IPL reader and begin installation
-	$out = `rnetboot $node ipl=00C`;
-	println( $callback, "$out" );
-	if ( $out =~ m/Error/i ) {
-		return;
-	}
-	
-	# Configure Ganglia monitoring
-	$out = `moncfg gangliamon $node -r`;
-	
-	# Show node information, e.g. IP, hostname, and root password
-	$out = `lsdef $node -i ip,hostnames | egrep "ip=|hostnames="`;
-	my $rootpw = getsysrootpw();
-	println( $callback, "Your virtual machine is ready. It may take a few minutes before you can logon using VNC ($node:1). Below is your VM attributes." );
-	println( $callback, "$out" );
-	println( $callback, "    rootpw = $rootpw" );
+    # IPL reader and begin installation
+    $out = `rnetboot $node ipl=00C`;
+    println( $callback, "$out" );
+    if ( $out =~ m/Error/i ) {
+        return;
+    }
+    
+    # Configure Ganglia monitoring
+    $out = `moncfg gangliamon $node -r`;
+    
+    # Show node information, e.g. IP, hostname, and root password
+    $out = `lsdef $node -i ip,hostnames | egrep "ip=|hostnames="`;
+    my $rootpw = getsysrootpw();
+    println( $callback, "Your virtual machine is ready. It may take a few minutes before you can logon using VNC ($node:1). Below is your VM attributes." );
+    println( $callback, "$out" );
+    println( $callback, "    rootpw = $rootpw" );
 }
 
 sub getsysrootpw {
-	# Get the default root password for all xCAT provisioned VM
-	my ( $callback ) = @_;
-	
-	my $tab    = xCAT::Table->new('passwd');
-	my $hash   = $tab->getAttribs( { key => "system" }, 'password' );
-	my $passwd = $hash->{'password'};
-	
-	return $passwd;
+    # Get the default root password for all xCAT provisioned VM
+    my ( $callback ) = @_;
+    
+    my $tab    = xCAT::Table->new('passwd');
+    my $hash   = $tab->getAttribs( { key => "system" }, 'password' );
+    my $passwd = $hash->{'password'};
+    
+    return $passwd;
 }
 
 sub getosimagedef {
 
-	# Get osimage definitions based on image name
-	my ( $callback, $img_name ) = @_;
+    # Get osimage definitions based on image name
+    my ( $callback, $img_name ) = @_;
 
-	my $profile;
-	my $arch;
-	my $os;
+    my $profile;
+    my $arch;
+    my $os;
 
-	# Get profile, osarch, and osver in 'osimage' table based on imagename
-	my $tab = xCAT::Table->new( 'osimage', -create => 1, -autocommit => 0 );
-	my @results = $tab->getAllAttribsWhere( "imagename='" . $img_name . "'",
-		'profile', 'osarch', 'osvers' );
-	foreach (@results) {
+    # Get profile, osarch, and osver in 'osimage' table based on imagename
+    my $tab = xCAT::Table->new( 'osimage', -create => 1, -autocommit => 0 );
+    my @results = $tab->getAllAttribsWhere( "imagename='" . $img_name . "'",
+        'profile', 'osarch', 'osvers' );
+    foreach (@results) {
 
-		# It should return: |gpok(\d+)|10.1.100.($1+0)|
-		$profile = $_->{'profile'};
-		$arch    = $_->{'osarch'};
-		$os      = $_->{'osvers'};
-	}
+        # It should return: |gpok(\d+)|10.1.100.($1+0)|
+        $profile = $_->{'profile'};
+        $arch    = $_->{'osarch'};
+        $os      = $_->{'osvers'};
+    }
 
-	return ( $profile, $arch, $os );
+    return ( $profile, $arch, $os );
 }
 
 sub gennodename {
 
-	# Generate node name based on given group
-	my ( $callback, $group ) = @_;
+    # Generate node name based on given group
+    my ( $callback, $group ) = @_;
 
-	# Only use the 1st group
-	if ($group =~ m/,/) {
-		my @groups = split(',', $group);
-		$group = @groups[0];
-	}	
-	
-	# Hostname and IP address regular expressions
-	my $hostname_regex;
-	my $ipaddr_regex;
-	
-	my @comments;
-	my $base_digit = 0;
-	my $base_hostname;
-	my $base_ipaddr;
-	
-	# Network, submask, submask prefix, and host ranges
-	my $network = "";
-	my $mask;
-	my $prefix;
-	my $hosts_count;
-	my $range_low = 1;
-	my $range_high = 254;
-	
-	 # Hostname and IP address generated
-	my $hostname;
-	my $ipaddr;
-	my $tmp;
-	
-	my @args;
+    # Only use the 1st group
+    if ($group =~ m/,/) {
+        my @groups = split(',', $group);
+        $group = @groups[0];
+    }    
+    
+    # Hostname and IP address regular expressions
+    my $hostname_regex;
+    my $ipaddr_regex;
+    
+    my @comments;
+    my $base_digit = 0;
+    my $base_hostname;
+    my $base_ipaddr;
+    
+    # Network, submask, submask prefix, and host ranges
+    my $network = "";
+    my $mask;
+    my $prefix;
+    my $hosts_count;
+    my $range_low = 1;
+    my $range_high = 254;
+    
+     # Hostname and IP address generated
+    my $hostname;
+    my $ipaddr;
+    my $tmp;
+    
+    my @args;
 
-	# Get regular expression for hostname in 'hosts' table
-	my $tab = xCAT::Table->new( 'hosts', -create => 1, -autocommit => 0 );
-	my @results = $tab->getAllAttribsWhere( "node='" . $group . "'", 'ip', 'comments' );
-	foreach (@results) {
+    # Get regular expression for hostname in 'hosts' table
+    my $tab = xCAT::Table->new( 'hosts', -create => 1, -autocommit => 0 );
+    my @results = $tab->getAllAttribsWhere( "node='" . $group . "'", 'ip', 'comments' );
+    foreach (@results) {
 
-		# It should return: |gpok(\d+)|10.1.100.($1+0)|		
-		@args = split( /\|/, $_->{'ip'} );
-		$hostname_regex = $args[1];
-		$ipaddr_regex = $args[2];
-		
-		$base_hostname = $args[1];		
-		$base_hostname =~ s/\(\S*\)/#/g;
-		
-		# Get the 10.1.100.
-		$base_ipaddr = $args[2];
-		$base_ipaddr =~ s/\(\S*\)//g;
-		
-		# Get the ($1+0)
-		$ipaddr_regex =~ s/$base_ipaddr//g;
-		
-		# Get the network within comments
-		# It should return: "description: All machines; network: 10.1.100.0/24;"
-		# This will help determine the 1st node in the group if none exists
-		@comments = split( /|/, $_->{'comments'} );
-		foreach (@comments) {
-			if ($_ =~ m/network:/i) {
-				$network = $_;
-				
-				# Remove network header
-				$network =~ s/network://g;
-				
-				# Trim network section
-				$network =~ s/\s*$//;
-				$network =~ s/^\s*//;
+        # It should return: |gpok(\d+)|10.1.100.($1+0)|        
+        @args = split( /\|/, $_->{'ip'} );
+        $hostname_regex = $args[1];
+        $ipaddr_regex = $args[2];
+        
+        $base_hostname = $args[1];        
+        $base_hostname =~ s/\(\S*\)/#/g;
+        
+        # Get the 10.1.100.
+        $base_ipaddr = $args[2];
+        $base_ipaddr =~ s/\(\S*\)//g;
+        
+        # Get the ($1+0)
+        $ipaddr_regex =~ s/$base_ipaddr//g;
+        
+        # Get the network within comments
+        # It should return: "description: All machines; network: 10.1.100.0/24;"
+        # This will help determine the 1st node in the group if none exists
+        @comments = split( /|/, $_->{'comments'} );
+        foreach (@comments) {
+            if ($_ =~ m/network:/i) {
+                $network = $_;
+                
+                # Remove network header
+                $network =~ s/network://g;
+                
+                # Trim network section
+                $network =~ s/\s*$//;
+                $network =~ s/^\s*//;
 
-				# Extract network
-				$tmp = rindex($network, '/');
-				if ($tmp > -1) {
-					# Get submask prefix
-					$prefix = substr($network, $tmp);
-					$prefix =~ s|/||g;
-					
-					# Get the number of hosts possible using submask
-					$hosts_count = 32 - int($prefix);
-					# Minus network and broadcast addresses
-					$hosts_count = 2 ** $hosts_count - 2;
-					
-					# Get network
-					$network = substr($network, 0, $tmp);
-				}
-				
-				# Extract base digit, which depends on the netmask used
-				$base_digit = substr($network, rindex($network, '.') + 1);
-				# 1st number in range is network
-				$range_low = $base_digit + 1;
-				
-				# Get hosts range
-				if ($tmp > -1) {
-					$range_high = $base_digit + $hosts_count;
-				}
-			}
-		} # End of foreach
-	} # End of foreach
-					
-	# Are there nodes in this group already?
-	# If so, use the existing nodes as a base
-	my $out = `nodels $group`;
-	@args = split( /\n/, $out );
-	foreach (@args) {
-		$_ =~ s/$hostname_regex/$1/g;
+                # Extract network
+                $tmp = rindex($network, '/');
+                if ($tmp > -1) {
+                    # Get submask prefix
+                    $prefix = substr($network, $tmp);
+                    $prefix =~ s|/||g;
+                    
+                    # Get the number of hosts possible using submask
+                    $hosts_count = 32 - int($prefix);
+                    # Minus network and broadcast addresses
+                    $hosts_count = 2 ** $hosts_count - 2;
+                    
+                    # Get network
+                    $network = substr($network, 0, $tmp);
+                }
+                
+                # Extract base digit, which depends on the netmask used
+                $base_digit = substr($network, rindex($network, '.') + 1);
+                # 1st number in range is network
+                $range_low = $base_digit + 1;
+                
+                # Get hosts range
+                if ($tmp > -1) {
+                    $range_high = $base_digit + $hosts_count;
+                }
+            }
+        } # End of foreach
+    } # End of foreach
+                    
+    # Are there nodes in this group already?
+    # If so, use the existing nodes as a base
+    my $out = `nodels $group`;
+    @args = split( /\n/, $out );
+    foreach (@args) {
+        $_ =~ s/$hostname_regex/$1/g;
 
-		# Take the greatest digit
-		if ( int($_) > $base_digit ) {
-			$base_digit = int($_);
-		}
-	}
+        # Take the greatest digit
+        if ( int($_) > $base_digit ) {
+            $base_digit = int($_);
+        }
+    }
 
-	# +1 to base digit to obtain next hostname
-	$base_digit = $base_digit + 1;
-	
-	# Generate hostname
-	$hostname = $base_hostname;
-	$hostname =~ s/#/$base_digit/g;
-	
-	# Generate IP address
-	$ipaddr = $hostname;
-	$ipaddr =~ s/$hostname_regex/$ipaddr_regex/gee;
-	$ipaddr = $base_ipaddr . $ipaddr;
-	
-	# Get networks in 'networks' table
-	$tab = xCAT::Table->new( 'networks', -create => 1, -autocommit => 0 );
-	my $entries = $tab->getAllEntries();
+    # +1 to base digit to obtain next hostname
+    $base_digit = $base_digit + 1;
+    
+    # Generate hostname
+    $hostname = $base_hostname;
+    $hostname =~ s/#/$base_digit/g;
+    
+    # Generate IP address
+    $ipaddr = $hostname;
+    $ipaddr =~ s/$hostname_regex/$ipaddr_regex/gee;
+    $ipaddr = $base_ipaddr . $ipaddr;
+    
+    # Get networks in 'networks' table
+    $tab = xCAT::Table->new( 'networks', -create => 1, -autocommit => 0 );
+    my $entries = $tab->getAllEntries();
 
-	# Go through each network
-	my $iprange;
-	foreach (@$entries) {
+    # Go through each network
+    my $iprange;
+    foreach (@$entries) {
 
-		# Get network, mask, and range
-		$network = $_->{'net'};
-		$mask = $_->{'mask'};
-		$iprange = $_->{'dynamicrange'};
-			
-		# If the host IP address is in this subnet, return
-		if (xCAT::NetworkUtils->ishostinsubnet($ipaddr, $mask, $network)) {
+        # Get network, mask, and range
+        $network = $_->{'net'};
+        $mask = $_->{'mask'};
+        $iprange = $_->{'dynamicrange'};
+            
+        # If the host IP address is in this subnet, return
+        if (xCAT::NetworkUtils->ishostinsubnet($ipaddr, $mask, $network)) {
 
-			# Exit loop
-			last;
-		} else {
-			$network = "";
-		}
-	}
-	
-	# Exit if no network exist for group
-	if (!$network) {
-		return;
-	}
-	
-	# Find the network range for this group based on networks table
-	my @ranges;
-	if ($iprange) {
-		@args = split( /;/, $iprange );
-		foreach (@args) {
-			# If a network range exists
-			if ($_ =~ m/-/) {
-				@ranges = split( /-/, $_ );
-				$range_low = $ranges[0];				
-				$range_high = $ranges[1];
-				
-				# Get the low and high ends digit
-				$range_low =~ s/$base_ipaddr//g;
-				$range_high =~ s/$base_ipaddr//g;
-			}
-		}
-	} # End of if ($iprange)
-	
-	# If no nodes exist in group
-	# Set the base digit to the low end of the network range
-	if ($range_low && $base_digit == 1) {
-		$base_digit = $range_low;
-		
-		# Generate hostname
-		$hostname = $base_hostname;
-		$hostname =~ s/#/$base_digit/g;
-		
-		# Generate IP address
-		$ipaddr = $hostname;
-		$ipaddr =~ s/$hostname_regex/$ipaddr_regex/gee;
-		$ipaddr = $base_ipaddr . $ipaddr;
-	}
-				
-	# Check xCAT tables, /etc/hosts, and ping to see if hostname is already used
-	while (`nodels $hostname` || `cat /etc/hosts | grep "$ipaddr "` || !(`ping -c 4 $ipaddr` =~ m/100% packet loss/)) {		
-		# Base digit invalid if over 254
-		if ($base_digit > $range_high) {
-			last;
-		}
-		
-		# +1 to base digit to obtain next hostname
-		$base_digit = $base_digit + 1;
-		
-		$hostname = $base_hostname;
-		$hostname =~ s/#/$base_digit/g;
-		
-		$ipaddr = $hostname;
-		$ipaddr =~ s/$hostname_regex/$ipaddr_regex/gee;
-		$ipaddr = $base_ipaddr . $ipaddr;
-	}
-		
-	# Range must be within network range
-	if ($base_digit > $range_high) {
-		return;
-	} else {
-		return ($hostname, $ipaddr, $base_digit);
-	}
+            # Exit loop
+            last;
+        } else {
+            $network = "";
+        }
+    }
+    
+    # Exit if no network exist for group
+    if (!$network) {
+        return;
+    }
+    
+    # Find the network range for this group based on networks table
+    my @ranges;
+    if ($iprange) {
+        @args = split( /;/, $iprange );
+        foreach (@args) {
+            # If a network range exists
+            if ($_ =~ m/-/) {
+                @ranges = split( /-/, $_ );
+                $range_low = $ranges[0];                
+                $range_high = $ranges[1];
+                
+                # Get the low and high ends digit
+                $range_low =~ s/$base_ipaddr//g;
+                $range_high =~ s/$base_ipaddr//g;
+            }
+        }
+    } # End of if ($iprange)
+    
+    # If no nodes exist in group
+    # Set the base digit to the low end of the network range
+    if ($range_low && $base_digit == 1) {
+        $base_digit = $range_low;
+        
+        # Generate hostname
+        $hostname = $base_hostname;
+        $hostname =~ s/#/$base_digit/g;
+        
+        # Generate IP address
+        $ipaddr = $hostname;
+        $ipaddr =~ s/$hostname_regex/$ipaddr_regex/gee;
+        $ipaddr = $base_ipaddr . $ipaddr;
+    }
+                
+    # Check xCAT tables, /etc/hosts, and ping to see if hostname is already used
+    while (`nodels $hostname` || `cat /etc/hosts | grep "$ipaddr "` || !(`ping -c 4 $ipaddr` =~ m/100% packet loss/)) {        
+        # Base digit invalid if over 254
+        if ($base_digit > $range_high) {
+            last;
+        }
+        
+        # +1 to base digit to obtain next hostname
+        $base_digit = $base_digit + 1;
+        
+        $hostname = $base_hostname;
+        $hostname =~ s/#/$base_digit/g;
+        
+        $ipaddr = $hostname;
+        $ipaddr =~ s/$hostname_regex/$ipaddr_regex/gee;
+        $ipaddr = $base_ipaddr . $ipaddr;
+    }
+        
+    # Range must be within network range
+    if ($base_digit > $range_high) {
+        return;
+    } else {
+        return ($hostname, $ipaddr, $base_digit);
+    }
 }
 
 sub clonezlinux {
-	my ( $request, $callback, $sub_req ) = @_;
+    my ( $request, $callback, $sub_req ) = @_;
 
-	# webportal clonezlinux [src node] [group] [owner]
-	my $src_node = $request->{arg}->[1];
-	my $group = $request->{arg}->[2];
-	my $owner = $request->{arg}->[3];
-	
-	# Check the max # of virtual machines allowed
-	my $out = `tabdump nodetype -w nodetype.comments=~"owner:$owner"`;
-	my @tmp = split( /\n/, $out );
-	my $usrVM = scalar(@tmp) - 1;
-	
-	$out = `webportal getmaxvm $owner`;
-	$out =~ s/Max allowed: //g;
-	my $maxVM = int($out);
-	
-	# Do not continue if the max # is reached
-	if ($usrVM >= $maxVM) {
-		println( $callback, "You have reached the maximum number of virtual machines allowed ($maxVM). Delete unused virtual machines or contact your system administrator request more virtual machines.");
-		return;
-	}
+    # webportal clonezlinux [src node] [group] [owner]
+    my $src_node = $request->{arg}->[1];
+    my $group = $request->{arg}->[2];
+    my $owner = $request->{arg}->[3];
+    
+    # Check the max # of virtual machines allowed
+    my $out = `tabdump nodetype -w nodetype.comments=~"owner:$owner"`;
+    my @tmp = split( /\n/, $out );
+    my $usrVM = scalar(@tmp) - 1;
+    
+    $out = `webportal getmaxvm $owner`;
+    $out =~ s/Max allowed: //g;
+    my $maxVM = int($out);
+    
+    # Do not continue if the max # is reached
+    if ($usrVM >= $maxVM) {
+        println( $callback, "You have reached the maximum number of virtual machines allowed ($maxVM). Delete unused virtual machines or contact your system administrator request more virtual machines.");
+        return;
+    }
 
-	# Get source node's HCP
-	my $props = xCAT::zvmUtils->getNodeProps( 'zvm', $src_node, ('hcp') );
-	my $hcp = $props->{'hcp'};
-	
-	# Get source node's nodetype
-	$props = xCAT::zvmUtils->getNodeProps( 'nodetype', $src_node, ('os', 'arch', 'profile') );
-	my $os = $props->{'os'};
-	my $arch = $props->{'arch'};
-	my $profile = $props->{'profile'};
+    # Get source node's HCP
+    my $props = xCAT::zvmUtils->getNodeProps( 'zvm', $src_node, ('hcp') );
+    my $hcp = $props->{'hcp'};
+    
+    # Get source node's nodetype
+    $props = xCAT::zvmUtils->getNodeProps( 'nodetype', $src_node, ('os', 'arch', 'profile') );
+    my $os = $props->{'os'};
+    my $arch = $props->{'arch'};
+    my $profile = $props->{'profile'};
 
-	# Read in default disk pool from /var/opt/xcat/profiles/default.conf on xCAT MN
-	#	pool = POOL3
-	#	eckd_size = 10016
-	my $disk_pool;
-	my $default_conf   = '/var/opt/xcat/profiles/default.conf';
-	my $default_direct = '/var/opt/xcat/profiles/default.direct';
+    # Read in default disk pool from /var/opt/xcat/profiles/default.conf on xCAT MN
+    #    pool = POOL3
+    #    eckd_size = 10016
+    my $disk_pool;
+    my $default_conf   = '/var/opt/xcat/profiles/default.conf';
+    my $default_direct = '/var/opt/xcat/profiles/default.direct';
 
-	# Exit if default.conf does not exist
-	if ( !(`test -e $default_conf && echo Exists`) ) {
-		println( $callback, '(Error) $default_conf does not exists' );
-		return;
-	}
+    # Exit if default.conf does not exist
+    if ( !(`test -e $default_conf && echo Exists`) ) {
+        println( $callback, '(Error) $default_conf does not exists' );
+        return;
+    }
 
-	# Exit if default.direct does not exist
-	if ( !(`test -e $default_direct && echo Exists`) ) {
-		println( $callback, '(Error) $default_direct does not exists' );
-		return;
-	}
+    # Exit if default.direct does not exist
+    if ( !(`test -e $default_direct && echo Exists`) ) {
+        println( $callback, '(Error) $default_direct does not exists' );
+        return;
+    }
 
-	$out = `cat $default_conf`;
-	@tmp = split( /\n/, $out );
-	# default.conf should contain:
-	
-	# Default configuration for virtual machines handled by this zHCP
-	#	default_diskpool=POOL3
-	#	compute_diskpool=POOL3
-	my $profile_diskpool_parm = '';
-	if ($profile) {
-		$profile_diskpool_parm = $profile . "_diskpool";
-	}
-	
-	foreach (@tmp) {
-		# Get disk pool (default)
-		if ( $_ =~ m/default_diskpool=/i ) {
-			$disk_pool = $_;
-			$disk_pool =~ s/default_diskpool=//g;
-		}
-		
-		# Get profile disk pool (default)
-		elsif ( $_ =~ m/$profile_diskpool_parm=/i && $profile_diskpool_parm) {
-			$disk_pool = $_;
-			$disk_pool =~ s/$profile_diskpool_parm=//g;
-		}
-	}
-	
-	# Trim disk pool of white space
-	$disk_pool =~ s/\s*$//;	# Trim right
-	$disk_pool =~ s/^\s*//;	# Trim left
-		
-	# Create VM
-	# e.g. webportal provzlinux [group] [hcp] [image]
-	my ($node, $ip, $base_digit) = gennodename( $callback, $group );
-	my $userid = $node;
-		
-	# Set node definitions
-	$out = `mkdef -t node -o $node userid=$userid hcp=$hcp mgt=zvm groups=$group`;
-	println( $callback, "$out" );
+    $out = `cat $default_conf`;
+    @tmp = split( /\n/, $out );
+    # default.conf should contain:
+    
+    # Default configuration for virtual machines handled by this zHCP
+    #    default_diskpool=POOL3
+    #    compute_diskpool=POOL3
+    my $profile_diskpool_parm = '';
+    if ($profile) {
+        $profile_diskpool_parm = $profile . "_diskpool";
+    }
+    
+    foreach (@tmp) {
+        # Get disk pool (default)
+        if ( $_ =~ m/default_diskpool=/i ) {
+            $disk_pool = $_;
+            $disk_pool =~ s/default_diskpool=//g;
+        }
+        
+        # Get profile disk pool (default)
+        elsif ( $_ =~ m/$profile_diskpool_parm=/i && $profile_diskpool_parm) {
+            $disk_pool = $_;
+            $disk_pool =~ s/$profile_diskpool_parm=//g;
+        }
+    }
+    
+    # Trim disk pool of white space
+    $disk_pool =~ s/\s*$//;    # Trim right
+    $disk_pool =~ s/^\s*//;    # Trim left
+        
+    # Create VM
+    # e.g. webportal provzlinux [group] [hcp] [image]
+    my ($node, $ip, $base_digit) = gennodename( $callback, $group );
+    my $userid = $node;
+        
+    # Set node definitions
+    $out = `mkdef -t node -o $node userid=$userid hcp=$hcp mgt=zvm groups=$group`;
+    println( $callback, "$out" );
 
-	# Set nodetype definitions
-	$out = `chtab node=$node noderes.netboot=zvm nodetype.nodetype=osi nodetype.provmethod=install nodetype.os=$os nodetype.arch=$arch nodetype.profile=$profile nodetype.comments="owner:$owner"`;
+    # Set nodetype definitions
+    $out = `chtab node=$node noderes.netboot=zvm nodetype.nodetype=osi nodetype.provmethod=install nodetype.os=$os nodetype.arch=$arch nodetype.profile=$profile nodetype.comments="owner:$owner"`;
 
-	# Update hosts table and DNS
-	`makehosts`;
-	`makedns`;
+    # Update hosts table and DNS
+    `makehosts`;
+    `makedns`;
 
-	# Update DHCP
-	`makedhcp -a`;
-	println( $callback, "hosts table, DHCP, and DNS updated" );
+    # Update DHCP
+    `makedhcp -a`;
+    println( $callback, "hosts table, DHCP, and DNS updated" );
 
-	# Clone virtual machine	
-	$out = `mkvm $node $src_node pool=$disk_pool`;
-	println( $callback, "$out" );
-	if ( $out =~ m/Error/i || $out =~ m/Failed/i ) {
-		return;
-	}
-	
-	# Configure Ganglia monitoring
-	$out = `moncfg gangliamon $node -r`;
-	
-	# Show node information, e.g. IP, hostname, and root password
-	$out = `lsdef $node | egrep "ip=|hostnames="`;
-	my $rootpw = getsysrootpw();
-	println( $callback, "Your virtual machine is ready. It may take a few minutes before you can logon. Below is your VM attributes." );
-	println( $callback, "$out" );
-	println( $callback, "    rootpw = Same as source node" );
+    # Clone virtual machine    
+    $out = `mkvm $node $src_node pool=$disk_pool`;
+    println( $callback, "$out" );
+    if ( $out =~ m/Error/i || $out =~ m/Failed/i ) {
+        return;
+    }
+    
+    # Configure Ganglia monitoring
+    $out = `moncfg gangliamon $node -r`;
+    
+    # Show node information, e.g. IP, hostname, and root password
+    $out = `lsdef $node | egrep "ip=|hostnames="`;
+    my $rootpw = getsysrootpw();
+    println( $callback, "Your virtual machine is ready. It may take a few minutes before you can logon. Below is your VM attributes." );
+    println( $callback, "$out" );
+    println( $callback, "    rootpw = Same as source node" );
 }
 
 sub genhostip {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $group = $request->{arg}->[1];
-	
-	my ($node, $ip, $base_digit) = gennodename( $callback, $group );
-	println( $callback, "$node: $ip" );
+    my ( $request, $callback, $sub_req ) = @_;
+    my $group = $request->{arg}->[1];
+    
+    my ($node, $ip, $base_digit) = gennodename( $callback, $group );
+    println( $callback, "$node: $ip" );
 }
 
 sub getmaxvm {
-	my ( $request, $callback, $sub_req ) = @_;
-	my $user = $request->{arg}->[1];
-	
-	my @args;
-	my $max;
-	
-	# Look in 'policy' table
-	my $tab = xCAT::Table->new( 'policy', -create => 1, -autocommit => 0 );
-	my @results = $tab->getAllAttribsWhere( "name='" . $user . "'", 'comments' );
-	foreach (@results) {
-		if ( $_->{'comments'} ) {
-			@args = split( ';', $_->{'comments'} );
-			
-			# Extract max VM
-			foreach (@args) {
-				if ($_ =~ m/max-vm:/i) {
-					$_ =~ s/max-vm://g;
-					$max = $_;
-					last;
-				}
-			}
-		}
-	}
-	
-	$callback->( { data => "Max allowed: $max" } );
+    my ( $request, $callback, $sub_req ) = @_;
+    my $user = $request->{arg}->[1];
+    
+    my @args;
+    my $max;
+    
+    # Look in 'policy' table
+    my $tab = xCAT::Table->new( 'policy', -create => 1, -autocommit => 0 );
+    my @results = $tab->getAllAttribsWhere( "name='" . $user . "'", 'comments' );
+    foreach (@results) {
+        if ( $_->{'comments'} ) {
+            @args = split( ';', $_->{'comments'} );
+            
+            # Extract max VM
+            foreach (@args) {
+                if ($_ =~ m/max-vm:/i) {
+                    $_ =~ s/max-vm://g;
+                    $max = $_;
+                    last;
+                }
+            }
+        }
+    }
+    
+    $callback->( { data => "Max allowed: $max" } );
 }
 
 sub getuserprivilege {
-	# Get the user privilege
-	my ( $request, $callback, $sub_req ) = @_;
-	my $user = $request->{arg}->[1];
-	if (!$user) {
-		$callback->( { data => "(Error) No user name is specified" } );
-		return;
-	}
-	
-	my @args;
-	my $privilege = "user";
-	
-	# Look in 'policy' table
-	my $tab = xCAT::Table->new( 'policy', -create => 1, -autocommit => 0 );
-	my @results = $tab->getAllAttribsWhere( "name='" . $user . "'", 'comments' );
-	foreach (@results) {
-		if ( $_->{'comments'} ) {
-			@args = split( ';', $_->{'comments'} );
-			
-			# Extract user privilege
-			foreach (@args) {
-				if ($_ =~ m/privilege:/i) {
-					$_ =~ s/privilege://g;
-					$privilege = $_;					
-					$privilege =~ s/\s*$//;	# Trim right
-					$privilege =~ s/^\s*//;	# Trim left
-					last;
-				}
-			}
-		}
-	}
-	
-	$callback->( { data => "Privilege: $privilege" } );
+    # Get the user privilege
+    my ( $request, $callback, $sub_req ) = @_;
+    my $user = $request->{arg}->[1];
+    if (!$user) {
+        $callback->( { data => "(Error) No user name is specified" } );
+        return;
+    }
+    
+    my @args;
+    my $privilege = "user";
+    
+    # Look in 'policy' table
+    my $tab = xCAT::Table->new( 'policy', -create => 1, -autocommit => 0 );
+    my @results = $tab->getAllAttribsWhere( "name='" . $user . "'", 'comments' );
+    foreach (@results) {
+        if ( $_->{'comments'} ) {
+            @args = split( ';', $_->{'comments'} );
+            
+            # Extract user privilege
+            foreach (@args) {
+                if ($_ =~ m/privilege:/i) {
+                    $_ =~ s/privilege://g;
+                    $privilege = $_;                    
+                    $privilege =~ s/\s*$//;    # Trim right
+                    $privilege =~ s/^\s*//;    # Trim left
+                    last;
+                }
+            }
+        }
+    }
+    
+    $callback->( { data => "Privilege: $privilege" } );
 }
 1;
\ No newline at end of file