';
var strRet = strGroup + strNodes + strBoot + strOs + strArch + strPro;
return strRet;
}
/**
* Refresh the nodes area base on group selected
*
* @return Nothing
*/
function createNodesArea(groupName, areaId) {
// Get group nodes
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'nodels',
tgt : groupName,
args : '',
msg : areaId
},
/**
* Create nodes datatable
*
* @param data
* Data returned from HTTP request
* @return Nothing
*/
success : function(data) {
var areaObj = $('#' + data.msg);
var nodes = data.rsp;
var index;
var showStr = '
';
showStr += '
Node
';
for (index in nodes) {
var node = nodes[index][0];
if ('' == node) {
continue;
}
showStr += '
'
+ node + '
';
}
showStr += '
';
areaObj.empty().append(showStr);
if (index > 10) {
areaObj.css('height', '300px');
} else {
areaObj.css('height', 'auto');
}
} // End of function(data)
});
}
/**
* Provision for existing system p node
*
* @return Nothing
*/
function pProvisionExisting(data) {
// Get ajax response
var rsp = data.rsp;
var args = data.msg.split(';');
// Get command invoked
var cmd = args[0].replace('cmd=', '');
// Get provision tab instance
var tabId = args[1].replace('out=', '');
// Get tab obj
var tempTab = $('#' + tabId);
/**
* (2) Prepare node for boot
*/
if (cmd == 'nodeadd') {
// Get operating system
var bootMethod = tempTab.find('#boot').val();
// Get nodes that were checked
var tgts = getCheckedByObj(tempTab.find('table'));
// Prepare node for boot
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'nodeset',
tgt : tgts,
args : bootMethod,
msg : 'cmd=nodeset;out=' + tabId
},
success : pProvisionExisting
});
}
/**
* (3) Boot node from network
*/
else if (cmd == 'nodeset') {
// Write ajax response to status bar
var prg = writeRsp(rsp, '');
tempTab.find('#statBar').append(prg);
// If there was an error, do not continue
if (prg.html().indexOf('Error') > -1) {
tempTab.find('#loader').remove();
return;
}
// Get nodes that were checked
var tgts = getCheckedByObj(tempTab.find('table'));
// Boot node from network
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'rnetboot',
tgt : tgts,
args : '',
msg : 'cmd=rnetboot;out=' + tabId
},
success : pProvisionExisting
});
}
/**
* (4) Done
*/
else if (cmd == 'rnetboot') {
// Write ajax response to status bar
var prg = writeRsp(rsp, '');
tempTab.find('#statBar').append(prg);
tempTab.find('#loader').remove();
}
}
/**
* Get all select elements' name in the obj
*
* @return All nodes name, seperate by ','
*/
function getCheckedByObj(obj) {
var tempStr = '';
// Get nodes that were checked
obj.find('input:checked').each(function() {
if ($(this).attr('name')) {
tempStr += $(this).attr('name') + ',';
}
});
if ('' != tempStr) {
tempStr = tempStr.substr(0, tempStr.length - 1);
}
return tempStr;
}