diff --git a/xCAT-UI/js/custom/blade.js b/xCAT-UI/js/custom/blade.js
index 2ea3b5bef..e4d42aa93 100644
--- a/xCAT-UI/js/custom/blade.js
+++ b/xCAT-UI/js/custom/blade.js
@@ -170,91 +170,96 @@ bladePlugin.prototype.loadResources = function() {
* @return Nothing
*/
bladePlugin.prototype.addNode = function() {
- var nodeTypeSelectDia = $('
' +
- '
Blade Name: ' +
- '
Blade Group: ' +
- '
Blade ID: ' +
- '
Blade Series: JS
LS
' +
- '
Blade MPA: ';
- nodeTypeSelectDia.append(mmStr);
- nodeTypeSelectDia.append(bladeStr);
+ // Blade section
+ var blade = $('
').hide();
+ blade.append($('
Blade name:
'));
+ blade.append($('
Blade group:
'));
+ blade.append($('
Blade ID:
'));
+ blade.append($('
Blade series: JS LS
'));
+ blade.append($('
Blade MPA:
'));
+ diag.append(blade);
- nodeTypeSelectDia.find('#nodeTypeSelect').bind('change', function(){
- $('#nodeTypeSelectDia .ui-state-error').remove();
- $('#mmNode').toggle();
- $('#bladeNode').toggle();
- if ('mm' == $(this).val()){
- return;
- }
+ diag.find('select[name="nodeType"]').bind('change', function(){
+ diag.find('.ui-state-error').remove();
+ $('#amm').toggle();
+ $('#blade').toggle();
+
+ if ($(this).val() == 'mm') {
+ return;
+ }
+
+ $('#blade select').empty();
+ $('#blade select').parent().append(createLoader());
- //get all mm nodes from the server side
- $('#bladeNode select').empty();
- $('#bladeNode').append(createLoader());
-
- $.ajax({
- url : 'lib/cmd.php',
- dataType : 'json',
- data : {
- cmd : 'lsdef',
- tgt : '',
- args : '-t;node;-w;mgt==blade;-w;id==0',
- msg : ''
- },
- success : function(data){
- var position = 0;
- var tempStr = '';
- var options = '';
- //remove the loading image
- $('#bladeNode img').remove();
+ // Get AMMs
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'lsdef',
+ tgt : '',
+ args : '-t;node;-w;mgt==blade;-w;id==0',
+ msg : ''
+ },
+ success : function(data) {
+ var position = 0;
+ var temp = '';
+ var options = '';
+
+ // Remove loader
+ $('#blade img').remove();
- //check return result
- if (1 > data.rsp.length){
- $('#nodeTypeSelectDia').prepend(createWarnBar('Please define MM node first!'));
- return;
- }
+ // Check output
+ if (!data.rsp.length){
+ $('#addBC').prepend(createWarnBar('Please define the AMM node first!'));
+ return;
+ }
- //add all mm nodes to select
- for (var i in data.rsp){
- tempStr = data.rsp[i];
- position = tempStr.indexOf(' ');
- tempStr = tempStr.substring(0, position);
- options += '
' + tempStr + ' ';
- }
+ // Add AMMs to select
+ for (var i in data.rsp){
+ temp = data.rsp[i];
+ position = temp.indexOf(' ');
+ temp = temp.substring(0, position);
+ options += '
' + temp + ' ';
+ }
- $('#bladeNode select').append(options);
- }
- });
- });
+ $('#blade select').append(options);
+ }
+ });
+ });
- nodeTypeSelectDia.dialog( {
+ diag.dialog({
modal : true,
width : 400,
title : 'Select Node Type',
open : function(event, ui) {
- $(".ui-dialog-titlebar-close").hide();
+ $('.ui-dialog-titlebar-close').hide();
},
buttons : {
'Ok' : function() {
- //remove all error bar
- $('#nodeTypeSelectDia .ui-state-error').remove();
+ // Remove existing warnings
+ $(this).find('.ui-state-error').remove();
- if ($('#nodeTypeSelect').attr('value') == "mm") {
+ if ($(this).find('select[name="nodeType"]').attr('value') == "mm") {
addMmNode();
- }
- else {
+ } else {
addBladeNode();
}
},
@@ -265,67 +270,80 @@ bladePlugin.prototype.addNode = function() {
});
};
+
+/**
+ * Add AMM node
+ *
+ * @return Nothing
+ */
function addMmNode(){
- var name = $('#ammName').val();
- var ip = $('#ammIp').val();
+ var name = $('#addBC input[name="ammName"]').val();
+ var ip = $('#addBC input[name="ammIp"]').val();
- if ((!name) || (!ip)){
- $('#nodeTypeSelectDia').prepend(createWarnBar("You are missing some inputs!"));
+ if (!name || !ip){
+ $('#addBC').prepend(createWarnBar('You are missing some inputs!'));
return;
}
- //add the loader
- $('#nodeTypeSelectDia').prepend(createLoader());
+ // Add loader
+ $('#addBC').prepend(createLoader());
$('.ui-dialog-buttonpane .ui-button').attr('disabled', true);
- var argsTmp = '-t;node;-o;' + name +
- ';id=0;nodetype=mm;groups=mm;mgt=blade;mpa=' + name + ';ip=' + ip;
+
+ var args = '-t;node;-o;' + name + ';id=0;nodetype=mm;groups=mm;mgt=blade;mpa=' + name + ';ip=' + ip;
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chdef',
tgt : '',
- args : argsTmp,
+ args : args,
msg : ''
},
success : function(data) {
- $('#nodeTypeSelectDia').find('img').remove();
- var messages = data.rsp;
- var notes = "";
- for ( var i = 0; i < messages.length; i++) {
- notes += messages[i];
+ // Remove loader
+ $('#addBC').find('img').remove();
+
+ var rsp = data.rsp;
+ var messages = '';
+ for (var i = 0; i < rsp.length; i++) {
+ messages += rsp[i] + ' ';
}
- var info = createInfoBar(notes);
- $('#nodeTypeSelectDia').prepend(info);
- $('#nodeTypeSelectDia').dialog("option", "buttons", {
- "close" : function() {
- $('#nodeTypeSelectDia').remove();
+
+ $('#addBC').prepend(createInfoBar(messages));
+ $('#addBC').dialog('option', 'buttons', {
+ 'Close' : function() {
+ $('#addBC').remove();
}
});
}
});
}
+/**
+ * Add blade node
+ *
+ * @return Nothing
+ */
function addBladeNode(){
- var name = $('#bladeName').val();
- var group = $('#bladeGroup').val();
- var id = $('#bladeId').val();
- var series = $("#bladeNode :checked").val();
- var mpa = $('#mpaSelect').val();
+ var name = $('#addBC input[name="bladeName"]').val();
+ var group = $('#addBC input[name="bladeGroup"]').val();
+ var id = $('#addBC input[name="bladeId"]').val();
+ var series = $('#addBC input[name="bladeNode"]:checked').val();
+ var mpa = $('#addBC select[name="mpa"]').val();
- var argsTmp = '-t;node;-o;' + name + ';id=' + id +
- ';nodetype=osi;groups=' + group + ';mgt=blade;mpa=' + mpa + ';serialflow=hard';
+ var args = '-t;node;-o;' + name + ';id=' + id + ';nodetype=osi;groups=' + group + ';mgt=blade;mpa=' + mpa + ';serialflow=hard';
if (series != 'js') {
- argsTmp += ';serialspeed=19200;serialport=1';
+ args += ';serialspeed=19200;serialport=1';
}
- if ((!name) || (!group) || (!id) || (!mpa)){
- $('#nodeTypeSelectDia').prepend(createWarnBar("You miss some inputs."));
+ // Check blade properties
+ if (!name || !group || !id || !mpa){
+ $('#addBC').prepend(createWarnBar('You are missing some inputs!'));
return;
}
- //add loader and disable buttons
- $('#nodeTypeSelectDia').prepend(createLoader());
+ // Add loader and disable buttons
+ $('#addBC').prepend(createLoader());
$('.ui-dialog-buttonpane .ui-button').attr('disabled', true);
$.ajax( {
url : 'lib/cmd.php',
@@ -333,21 +351,21 @@ function addBladeNode(){
data : {
cmd : 'chdef',
tgt : '',
- args : argsTmp,
+ args : args,
msg : ''
},
success : function(data) {
- $('#nodeTypeSelectDia').find('img').remove();
- var messages = data.rsp;
- var notes = "";
- for ( var i = 0; i < messages.length; i++) {
- notes += messages[i];
+ $('#addBC').find('img').remove();
+ var rsp = data.rsp;
+ var messages = '';
+ for (var i = 0; i < rsp.length; i++) {
+ messages += rsp[i] + ' ';
}
-
- $('#nodeTypeSelectDia').prepend(createInfoBar(notes));
- $('#nodeTypeSelectDia').dialog("option", "buttons", {
- "close" : function() {
- $('#nodeTypeSelectDia').remove();
+ $('#addBC').prepend(createInfoBar(messages));
+
+ $('#addBC').dialog('option', 'buttons', {
+ 'Close' : function() {
+ $('#addBC').remove();
}
});
}
diff --git a/xCAT-UI/js/custom/customUtils.js b/xCAT-UI/js/custom/customUtils.js
index fc709a452..efde5405d 100644
--- a/xCAT-UI/js/custom/customUtils.js
+++ b/xCAT-UI/js/custom/customUtils.js
@@ -1,3 +1,5 @@
+var provisionClock;
+
/**
* Create nodes datatable for a given group
*
@@ -7,9 +9,6 @@
* Division ID to append datatable
* @return Nodes datatable
*/
-
-var provisionClock;
-
function createNodesDatatable(group, outId) {
// Get group nodes
$.ajax( {
@@ -385,26 +384,32 @@ function createProvisionNew(plugin, inst) {
return provNew;
}
+/**
+ * Create provision node division
+ *
+ * @param plugin
+ * Plugin name to create division for
+ * @param container
+ * Container to hold provisioning form
+ * @return Nothing
+ */
function createProvision(plugin, container){
- var showStr = '';
-
- //group, nodes, arch
- if ('quick' == plugin){
+ // Group, nodes, arch
+ if ('quick' == plugin) {
container.append(createProvWithUrl());
- }
- else{
- container.append(createProvNonurl(plugin));
- container.find('#' + plugin + 'group').bind('change', function(){
- var pluginname = $(this).attr('id').replace('group', '');
- $('#' + pluginname + 'SelectNodesTable').html('
');
- createNodesArea($(this).val(), pluginname + 'SelectNodesTable');
+ } else {
+ container.append(createProvNoUrl(plugin));
+ container.find('#' + plugin + 'group').bind('change', function() {
+ var pluginName = $(this).attr('id').replace('group', '');
+ $('#' + pluginName + 'SelectNodesTable').html('
');
+ createNodesArea($(this).val(), pluginName + 'SelectNodesTable');
});
}
- //option
+ // Advanced options
container.append('
');
- //add the provision button
+ // Add provision button
var provisionBtn = createButton('Provision');
provisionBtn.bind('click', function(){
var plugin = $(this).parent().parent().attr('id').replace('ProvisionTab', '');
@@ -413,7 +418,7 @@ function createProvision(plugin, container){
provisionBtn.hide();
container.append(provisionBtn);
- //bind the image select change event
+ // Bind image select to change event
container.find('#' + plugin + 'image').bind('change', function(){
var temp = $(this).attr('id');
temp = temp.replace('image', '');
@@ -432,124 +437,138 @@ function createProvision(plugin, container){
},
success : function(data){
- var containerid = data.msg + 'ProvisionTab';
- var index = 0;
- var imagename = 0;
+ var containerId = data.msg + 'ProvisionTab';
+ var i = 0;
+ var imageName = 0;
var position = 0;
- var imageselect = $('#' + containerid + ' #' + data.msg + 'image');
- $('#' + containerid + ' img').remove();
- if (data.rsp.lenght < 1){
- $('#' + containerid).prepend(createWarnBar('Please copycds and genimage in provision page first!'));
+ var imageSelect = $('#' + containerId + ' #' + data.msg + 'image');
+ $('#' + containerId + ' img').remove();
+ if (!data.rsp.length) {
+ $('#' + containerId).prepend(createWarnBar('Please run copycds and genimage in provision page before continuing!'));
return;
}
- for (index in data.rsp){
- imagename = data.rsp[index];
- position = imagename.indexOf(' ');
- imagename = imagename.substr(0, position);
+ for (i in data.rsp) {
+ imageName = data.rsp[i];
+ position = imageName.indexOf(' ');
+ imageName = imageName.substr(0, position);
- imageselect.append('
' + imagename + ' ');
+ imageSelect.append($('
' + imageName + ' '));
}
- //trigger the select change event
- imageselect.trigger('change');
- //show provision button
- $('#' + containerid + ' button').show();
+
+ // Trigger select change event
+ imageSelect.trigger('change');
+ // Show provision button
+ $('#' + containerId + ' button').show();
}
});
}
+/**
+ * Create provision node division using URL
+ *
+ * @returns Provisiong node division
+ */
function createProvWithUrl(){
- var querystr = window.location.search;
- var argarray = querystr.substr(1).split('&');
- var temphash = new Object();
- var index = 0;
- var temparray;
- var showstr = '';
+ var queryStr = window.location.search;
+ var argArray = queryStr.substr(1).split('&');
+ var tempHash = new Object();
+ var i = 0;
+ var tempArray;
+
+ var provHtml = '';
+
var master = '';
var tftpserver = '';
- var nfsserver = '';
- for (index = 0; index < argarray.length; index++){
- temparray = argarray[index].split('=');
- temphash[temparray[0]] = temparray[1];
+ var nfsserver = '';
+ for (i = 0; i < argArray.length; i++) {
+ tempArray = argArray[i].split('=');
+ tempHash[tempArray[0]] = tempArray[1];
}
- showstr += '
Nodes:
';
- showstr += '
Architecture:
';
+ provHtml += '
Nodes:
';
+ provHtml += '
Architecture:
';
+ provHtml += '
Image: ' +
+ '
Install NIC:
' +
+ '
Primary NIC:
' ;
- showstr += '
Image: ' +
- '
Install NIC:
' +
- '
Primary NIC:
' ;
-
- if (temphash['master']){
- master = temphash['master'];
+ if (tempHash['master']) {
+ master = tempHash['master'];
}
- if (temphash['nfsserver']){
- nfsserver = temphash['nfsserver'];
+ if (tempHash['nfsserver']) {
+ nfsserver = tempHash['nfsserver'];
}
- if (temphash['tftpserver']){
- tftpserver = temphash['tftpserver'];
+ if (tempHash['tftpserver']) {
+ tftpserver = tempHash['tftpserver'];
}
- showstr += '
xCAT Master:
';
- showstr += '
TFTP Server:
';
- showstr += '
NFS Server:
';
- return showstr;
-}
-
-function createProvNonurl(plugin){
- // Create the group area
- var strGroup = '
Group: ';
- var groupNames = $.cookie('groups');
- if (groupNames) {
- strGroup += ' ';
- var temp = groupNames.split(',');
- for (var i in temp) {
- strGroup += '' + temp[i] + ' ';
- }
- strGroup += ' ';
- }
- strGroup += '
';
-
- // Create nodes area
- var strNodes = '
Nodes: Select a group to view its nodes
';
-
- // Create architecture
- var strArch = '
Architecture: ';
- var archName = $.cookie('osarchs');
- if ('' != archName) {
- strArch += '';
- var temp = archName.split(',');
- for (var i in temp) {
- strArch += '' + temp[i] + ' ';
- }
- strArch += ' ';
- } else {
- strArch += ' ';
- }
- strArch += '
';
-
- //add the static input part
- strSta = '
Image: ' +
- '
Install NIC:
' +
- '
Primary NIC:
' +
- '
xCAT Master:
' +
- '
TFTP Server:
' +
- '
NFS Server:
';
- return strGroup + strNodes + strArch + strSta;
+ provHtml += '
xCAT master:
';
+ provHtml += '
TFTP server:
';
+ provHtml += '
NFS server:
';
+
+ return provHtml;
}
/**
- * get all needed field for provsion and send the command to server
+ * Create provision node division without using URL
*
+ * @param plugin
+ * Plugin name to create division for
+ * @returns {String}
+ */
+function createProvNoUrl(plugin){
+ // Select group
+ var groupHtml = '
Group: ';
+ var groupNames = $.cookie('groups');
+ if (groupNames) {
+ groupHtml += ' ';
+ var temp = groupNames.split(',');
+ for (var i in temp) {
+ groupHtml += '' + temp[i] + ' ';
+ }
+ groupHtml += ' ';
+ }
+ groupHtml += '
';
+
+ // Select nodes
+ var nodesHtml = '
Nodes: Select a group to view its nodes
';
+
+ // Select architecture
+ var archHtml = '
Architecture: ';
+ var archName = $.cookie('osarchs');
+ if (archName) {
+ archHtml += '';
+ var temp = archName.split(',');
+ for (var i in temp) {
+ archHtml += '' + temp[i] + ' ';
+ }
+ archHtml += ' ';
+ } else {
+ archHtml += ' ';
+ }
+ archHtml += '
';
+
+ // Add static input part
+ var staticHtml = '
Image: ' +
+ '
Install NIC:
' +
+ '
Primary NIC:
' +
+ '
xCAT Master:
' +
+ '
TFTP Server:
' +
+ '
NFS Server:
';
+ return groupHtml + nodesHtml + archHtml + staticHtml;
+}
+
+/**
+ * Get needed fields for provsioning and send command to server
+ *
+ * @param plugin
+ * Plugin name of platform to provision
* @return Nothing
*/
function quickProvision(plugin){
- var errormessage = '';
+ var errorMessage = '';
var argsArray = new Array();
var nodesName = '';
var provisionArg = '';
@@ -557,47 +576,47 @@ function quickProvision(plugin){
var imageName = '';
var url = '';
var softwareArg = '';
- var containerid = plugin + 'ProvisionTab';
- $('#' + containerid + ' .ui-state-error').remove();
+ var containerId = plugin + 'ProvisionTab';
+ $('#' + containerId + ' .ui-state-error').remove();
- $('#' + containerid + ' input[type!="checkbox"]').each(function(){
- if ('' == $(this).val()){
- errormessage = 'You are missing input!';
+ $('#' + containerId + ' input[type!="checkbox"]').each(function() {
+ if (!$(this).val()) {
+ errorMessage = 'You are missing some inputs!';
return false;
- }
- else{
+ } else {
argsArray.push($(this).val());
}
});
- if ('' != errormessage){
- $('#' + containerid).prepend('
' + errormessage + '
');
+ if (errorMessage) {
+ $('#' + containerId).prepend('
' + errorMessage + '
');
return;
}
- //if jumped from nodes page, get nodes name from input
- if ('quick' == plugin){
+ // If jumped from nodes page, get node names
+ if ('quick' == plugin) {
nodesName = argsArray.shift();
}
- //select the different platform, get nodes name from table checkbox
- else{
- //should unshift the arch type
- argsArray.unshift($('#' + containerid + ' #arch').val());
- nodesName = getCheckedByObj($('#' + containerid + ' #' + plugin + 'SelectNodesTable'));
+ // Select platform, get node names from table checkbox
+ else {
+ // Should unshift the arch type
+ argsArray.unshift($('#' + containerId + ' #arch').val());
+ nodesName = getCheckedByObj($('#' + containerId + ' #' + plugin + 'SelectNodesTable'));
}
- if ('' == nodesName){
- $('#' + containerid).prepend('
Please select nodes first.
');
+ if (!nodesName) {
+ $('#' + containerId).prepend('
Please select a node
');
return;
}
- softwareArg = getCheckedByObj($('#' + containerid + ' #advoption'));
- imageName = $('#' + containerid + ' #' + plugin + 'image').val();
+ softwareArg = getCheckedByObj($('#' + containerId + ' #advoption'));
+ imageName = $('#' + containerId + ' #' + plugin + 'image').val();
provisionArg = argsArray.join(',');
+
url = 'lib/cmd.php?cmd=webrun&tgt=&args=provision;' + nodesName + ';' + imageName + ';' +
provisionArg + ';' + softwareArg + '&msg=&opts=flush';
- // show the result
+ // Show output
var deployDia = $('
');
deployDia.append(createLoader()).append('
');
deployDia.append('
');
@@ -605,7 +624,7 @@ function quickProvision(plugin){
modal: true,
width: 600,
height: 480,
- title:'Provision on Nodes',
+ title:'Provision return',
close: function(){$(this).remove();},
buttons: {
Close : function(){$(this).dialog('close');}
@@ -615,7 +634,16 @@ function quickProvision(plugin){
provisionStopCheck();
}
-function provAdvOption(imagename, plugin){
+/**
+ * Create provisioning advance option
+ *
+ * @param imagename
+ * Image name
+ * @param plugin
+ * Plugin name of platform to provision
+ * @return Nothing
+ */
+function provAdvOption(imagename, plugin) {
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
@@ -626,40 +654,45 @@ function provAdvOption(imagename, plugin){
msg : plugin
},
- success : function(data){
- var containerid = data.msg + 'ProvisionTab';
- var index = 0;
- var osname = '';
- var provmethod = '';
- var tempstr = '';
+ success : function(data) {
+ var containerId = data.msg + 'ProvisionTab';
+ var i = 0;
+ var osName = '';
+ var provMethod = '';
+ var tempStr = '';
var position = 0;
- for (index = 0; index < data.rsp.length; index++){
- tempstr = data.rsp[index];
- if (-1 != tempstr.indexOf('osname')){
- position = tempstr.indexOf('=');
- osname = tempstr.substr(position + 1);
+ for (i = 0; i < data.rsp.length; i++) {
+ tempStr = data.rsp[i];
+ if (tempStr.indexOf('osname') != -1) {
+ position = tempStr.indexOf('=');
+ osName = tempStr.substr(position + 1);
}
- if (-1 != tempstr.indexOf('provmethod')){
- position = tempstr.indexOf('=');
- provmethod = tempstr.substr(position + 1);
+
+ if (tempStr.indexOf('provmethod') != -1) {
+ position = tempStr.indexOf('=');
+ provMethod = tempStr.substr(position + 1);
}
}
- $('#' + containerid + ' #advoption').empty();
- if ('aix' == osname.toLowerCase()){
+ $('#' + containerId + ' #advoption').empty();
+ if ('aix' == osName.toLowerCase()) {
return;
}
- if ('install' == provmethod){
- $('#' + containerid + ' #advoption').html('
Install Ganglia.');
+ if ('install' == provMethod){
+ $('#' + containerId + ' #advoption').html('
Install Ganglia.');
}
}
});
}
/**
- * Refresh the nodes area base on group selected
+ * Refresh nodes area base on group selected
*
+ * @param groupName
+ * Group name
+ * @param areaId
+ * Area ID to refresh
* @return Nothing
*/
function createNodesArea(groupName, areaId) {
@@ -678,18 +711,18 @@ function createNodesArea(groupName, areaId) {
var areaObj = $('#' + data.msg);
var nodes = data.rsp;
var index;
- var showStr = '
';
+
+ areaObj.empty().append(nodesHtml);
if (index > 10) {
areaObj.css('height', '300px');
} else {
@@ -701,32 +734,34 @@ function createNodesArea(groupName, areaId) {
function provisionStopCheck(){
var content = $('#provisionFrame').contents().find('body').text();
- if (-1 != content.indexOf('provision stop')){
+ if (content.indexOf('provision stop') != -1) {
$('#deployDia img').remove();
clearTimeout(provisionClock);
- }
- else{
+ } else {
provisionClock = setTimeout('provisionStopCheck()', 5000);
}
}
/**
- * Get all select elements' name in the obj
+ * Get select element names
*
- * @return All nodes name, seperate by ','
+ * @param obj
+ * Object to get selected element names
+ * @return Nodes name seperate by a comma
*/
function getCheckedByObj(obj) {
- var tempStr = '';
+ var str = '';
+
// Get nodes that were checked
obj.find('input:checked').each(function() {
if ($(this).attr('name')) {
- tempStr += $(this).attr('name') + ',';
+ str += $(this).attr('name') + ',';
}
});
- if ('' != tempStr) {
- tempStr = tempStr.substr(0, tempStr.length - 1);
+ if (str) {
+ str = str.substr(0, str.length - 1);
}
- return tempStr;
+ return str;
}
\ No newline at end of file
diff --git a/xCAT-UI/js/custom/hmc.js b/xCAT-UI/js/custom/hmc.js
index 56651b238..ad5afbd3c 100644
--- a/xCAT-UI/js/custom/hmc.js
+++ b/xCAT-UI/js/custom/hmc.js
@@ -166,27 +166,26 @@ hmcPlugin.prototype.addNode = function() {
diaDiv.append('
Type: HMC Scan Node
');
diaDiv.append('
');
- //show the dialog
- diaDiv.dialog( {
+ // Show the dialog
+ diaDiv.dialog({
modal : true,
width : 400,
- title : 'Add System P Node',
+ title : 'Add System p Node',
close : function(){$('#addpnodeDiv').remove();}
});
- //bind the select change event
- $('#pnodetype').bind('change', function(){
+ // Bind the select change event
+ $('#pnodetype').bind('change', function() {
$('#pnodeeditarea').empty();
- if ('HMC' == $(this).val()){
+ if ('HMC' == $(this).val()) {
$('#addpnodeDiv').dialog('option', 'width', '400');
$('#pnodeeditarea').append('
Name: Username: ' +
'
Password: IP Adress: ');
$('#addpnodeDiv').dialog('option', 'buttons',
{'Add': function(){addHmcNode();},
- 'Cancle': function(){$('#addpnodeDiv').dialog('close');}});
- }
- else{
+ 'Cancel': function(){$('#addpnodeDiv').dialog('close');}});
+ } else {
//add loader image and delete buttons
$('#pnodeeditarea').append(createLoader());
$('#addpnodeDiv').dialog('option', 'buttons', {'Cancel': function(){$('#addpnodeDiv').dialog('close');}});
@@ -200,7 +199,7 @@ hmcPlugin.prototype.addNode = function() {
args : 'ppc.nodetype==hmc',
msg : ''
},
- success : function(data){
+ success : function(data) {
$('#pnodeeditarea img').remove();
drawHmcSelector(data.rsp);
}
@@ -208,32 +207,34 @@ hmcPlugin.prototype.addNode = function() {
}
});
- //trigger the selector change event
+ // Trigger the select change event
$('#pnodetype').trigger('change');
};
/**
- * add all hmcs into the dialog
+ * Add HMCs into the dialog
*
+ * @param hmc
+ * HMCs
* @return Nothing
*/
function drawHmcSelector(hmcs){
- if (1 > hmcs.length){
+ if (1 > hmcs.length) {
$('#pnodeeditarea').append(createWarnBar('Please define HMC node first.'));
return;
}
- //add all hmcs into a selecter, add a scan button
+ // Add HMCs into a selector and add a scan button
var hmcoption = '';
var scanbutton = createButton('Scan');
- for (var i in hmcs){
+ for (var i in hmcs) {
hmcoption += '
' + hmcs[i][0] + ' ';
}
$('#pnodeeditarea').append('
HMC: ' + hmcoption + ' ');
$('#pnodeeditarea').append(scanbutton);
- scanbutton.bind('click', function(){
+ scanbutton.bind('click', function() {
var hmcname = $('#pnodeeditarea select').val();
$('#pnodeeditarea').append(createLoader());
$.ajax({
@@ -245,16 +246,16 @@ function drawHmcSelector(hmcs){
args : '',
msg : ''
},
- success : function(data){
+ success : function(data) {
$('#pnodeeditarea img').remove();
- //draw a table with checkbox
+ // Draw a table with checkbox
drawRscanResult(data.rsp[0]);
- //add the add button
+ // Add the add button
$('#addpnodeDiv').dialog('option', 'buttons',
{'Add': function(){addPNode();},
- 'Cancle': function(){$('#addpnodeDiv').dialog('close');}});
+ 'Cancel': function(){$('#addpnodeDiv').dialog('close');}});
}
});
});
@@ -271,44 +272,45 @@ function drawRscanResult(rscanresult){
var fields = 0;
$('#pnodeeditarea div').remove();
- if (!rscanresult){
+ if (!rscanresult) {
return;
}
var rows = rscanresult.split("\n");
- if (rows.length < 2){
+ if (rows.length < 2) {
return;
}
- //add the table header
+ // Add the table header
fields = rows[0].match(tempreg);
colnum = fields.length;
temprow = '
';
- for(var i in fields){
+ for(var i in fields) {
temprow += '' + fields[i] + ' ';
}
rscantable.append(temprow);
- //add the tbody
- for (var i = 1; i < rows.length; i++){
+ // Add the tbody
+ for (var i = 1; i < rows.length; i++) {
line = rows[i];
- if (!line){
- continue;
- }
- var fields = line.match(tempreg);
- if ('hmc' == fields[0]){
+ if (!line) {
continue;
}
- //may be the 3rd field(id) is empty, so we should add the new
+ var fields = line.match(tempreg);
+ if ('hmc' == fields[0]) {
+ continue;
+ }
+
+ // May be the 3rd field(id) is empty, so we should add the new
if (!idpreg.test(fields[2])){
fields = [fields[0], fields[1], ''].concat(fields.slice(2));
}
temprow = ' ';
- for(var j = 0; j < colnum; j++){
+ for(var j = 0; j < colnum; j++) {
temprow += '';
- if (fields[j]){
+ if (fields[j]) {
temprow += fields[j];
}
temprow += ' ';
@@ -320,6 +322,7 @@ function drawRscanResult(rscanresult){
resultDiv.append(rscantable);
$('#pnodeeditarea').append(resultDiv);
}
+
/**
* Add hmc node
*
@@ -330,24 +333,24 @@ function addHmcNode(){
var args = '';
$('#pnodeeditarea input').each(function(){
if (!$(this).val()){
- errorinfo = 'You are missing input.';
+ errorinfo = 'You are missing some inputs!';
}
args += $(this).val() + ',';
});
if (errorinfo){
- //add warning message
+ // Add warning message
alert(errorinfo);
return;
}
- //disabled the button
+ // Disabled the button
$('.ui-dialog-buttonpane button').attr('disabled', 'disabled');
args = args.substr(0, args.length - 1);
$('#pnodeeditarea').append(createLoader());
- //send the save hmc request
+ // Send the save HMC request
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
@@ -358,7 +361,7 @@ function addHmcNode(){
msg : ''
},
success : function(data){
- //refresh the area on the right side
+ // Refresh the area on the right side
$('#addpnodeDiv').dialog('close');
$('.selectgroup').trigger('click');
}
@@ -371,26 +374,27 @@ function addHmcNode(){
* @return Nothing
*/
function addPNode(){
- //get the hmc name
+ // Get the HMC name
var hmcname = $('#pnodeeditarea select').val();
var nodename = '';
- //get all need added node
- $('#pnodeeditarea :checked').each(function(){
- if ($(this).attr('name')){
+ // Get checked nodes
+ $('#pnodeeditarea :checked').each(function() {
+ if ($(this).attr('name')) {
nodename += $(this).attr('name') + ',';
}
});
- if (!nodename){
+ if (!nodename) {
alert('You should select nodes first!');
return;
}
- //disabled the button
+
+ // Disabled the button
$('.ui-dialog-buttonpane button').attr('disabled', 'disabled');
nodename = nodename.substr(0, nodename.length - 1);
$('#pnodeeditarea').append(createLoader());
- //send the add request
+ // Send the add request
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
@@ -400,8 +404,8 @@ function addPNode(){
args : 'addpnode;node;' + hmcname + ',' + nodename,
msg : ''
},
- success : function(data){
- //refresh the area on the right side
+ success : function(data) {
+ // Refresh the area on the right side
$('#addpnodeDiv').dialog('close');
$('.selectgroup').trigger('click');
}
@@ -409,7 +413,7 @@ function addPNode(){
}
/**
- * select all checkbox in a table
+ * Select all checkbox in a table
*
* @return Nothing
*/
diff --git a/xCAT-UI/js/custom/ipmi.js b/xCAT-UI/js/custom/ipmi.js
index b16f71ae4..2bdd85c54 100644
--- a/xCAT-UI/js/custom/ipmi.js
+++ b/xCAT-UI/js/custom/ipmi.js
@@ -171,7 +171,7 @@ ipmiPlugin.prototype.loadResources = function() {
* @return Nothing
*/
ipmiPlugin.prototype.addNode = function() {
- var diag = $('
');
+ var diag = $('
');
var info = createInfoBar('Add a node range');
diag.append(info);
@@ -216,37 +216,40 @@ ipmiPlugin.prototype.addNode = function() {
*/
function addIdataplex(){
var tempArray = new Array();
- var errormessage = '';
+ var errorMessage = '';
var attr = '';
var args = '';
- //remove the warning bar
- $('#addIdpDiv .ui-state-error').remove();
+ // Remove existing warnings
+ $('#addIdplx .ui-state-error').remove();
- //get all inputs' value
- $('#addIdpDiv input').each(function(){
+ // Get input values
+ $('#addIdplx input').each(function(){
attr = $(this).val();
- if (attr){
+ if (attr) {
tempArray.push($(this).val());
- }
- else{
- errormessage = "You are missing some inputs!";
+ } else {
+ errorMessage = "You are missing some inputs!";
return false;
}
});
- if ('' != errormessage){
- $('#addIdpDiv').prepend(createWarnBar(errormessage));
+ if (errorMessage) {
+ $('#addIdplx').prepend(createWarnBar(errorMessage));
return;
}
- //add the loader
- $('#addIdpDiv').append(createLoader());
+ // Create loader
+ $('#addIdplx').append(createLoader());
- //change the dialog button
- $('#addIdpDiv').dialog('option', 'buttons', {'Close':function(){$('#addIdpDiv').dialog('close');}});
+ // Change dialog buttons
+ $('#addIdplx').dialog('option', 'buttons', {
+ 'Close':function(){
+ $('#addIdplx').dialog('close');
+ }
+ });
- //compose all args into chdef for node
+ // Generate chdef arguments
args = '-t;node;-o;' + tempArray[0] + ';mac=' + tempArray[1] + ';ip=' + tempArray[2] + ';groups=' +
tempArray[3] + ';mgt=ipmi;chain="runcmd=bmcsetup";netboot=xnba;nodetype=osi;profile=compute;' +
'bmc=' + tempArray[4];
@@ -260,8 +263,8 @@ function addIdataplex(){
msg : ''
}
});
-
- //compose all args into chdef for bmc
+
+ // Generate chdef arguments for BMC
args = '-t;node;-o;' + tempArray[4] + ';ip=' + tempArray[5] + ';groups=' + tempArray[6];
$.ajax({
url : 'lib/cmd.php',
@@ -272,15 +275,15 @@ function addIdataplex(){
args : args,
msg : ''
},
- success: function(data){
- $('#addIdpDiv img').remove();
+ success: function(data) {
+ $('#addIdplx img').remove();
var message = '';
- for (var i in data.rsp){
+ for (var i in data.rsp) {
message += data.rsp[i];
}
- if ('' != message){
- $('#addIdpDiv').prepend(createInfoBar(message));
+ if (message) {
+ $('#addIdplx').prepend(createInfoBar(message));
}
}
});
diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js
index 19894c437..ef1e1ada4 100644
--- a/xCAT-UI/js/nodes/nodes.js
+++ b/xCAT-UI/js/nodes/nodes.js
@@ -3262,7 +3262,7 @@ function jump2Provision(tgtNodes){
// Skip if node does not have arch
if (!origAttrs[nodeName]['arch']){
- errorMsg = 'Nodes should have arch defined!';
+ errorMsg = 'Nodes should have arch defined! ';
break;
}
diff --git a/xCAT-UI/js/ui.js b/xCAT-UI/js/ui.js
index cc2af7e35..3f9381f96 100644
--- a/xCAT-UI/js/ui.js
+++ b/xCAT-UI/js/ui.js
@@ -87,9 +87,9 @@ Tab.prototype.add = function(tabId, tabName, tabCont, closeable) {
var tabIndex = ($('li', tabs).index(thisTab));
// Do not remove first tab
- if (tabIndex != 0) {
- tabs.tabs('remove', tabIndex);
+ if (tabIndex != 0) {
tabs.tabs('select', 0);
+ tabs.tabs('remove', tabIndex);
}
});
}