2010-07-28 20:24:29 +00:00
|
|
|
/**
|
|
|
|
* Execute when the DOM is fully loaded
|
|
|
|
*/
|
|
|
|
$(document).ready(function() {
|
|
|
|
// Load utility scripts
|
2010-07-15 22:57:48 +00:00
|
|
|
});
|
|
|
|
|
2010-07-22 19:56:09 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
var hmcPlugin = function() {
|
2010-07-28 20:24:29 +00:00
|
|
|
|
2010-07-22 19:56:09 +00:00
|
|
|
};
|
|
|
|
|
2010-07-15 22:57:48 +00:00
|
|
|
/**
|
|
|
|
* Load node inventory
|
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
* Data from HTTP request
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
hmcPlugin.prototype.loadInventory = function(data) {
|
2010-07-26 18:34:29 +00:00
|
|
|
// Get arguments
|
2010-07-22 19:56:09 +00:00
|
|
|
var args = data.msg.split(',');
|
|
|
|
// Get tab ID
|
|
|
|
var tabId = args[0].replace('out=', '');
|
|
|
|
// Get node
|
|
|
|
var node = args[1].replace('node=', '');
|
|
|
|
// Get node inventory
|
|
|
|
var inv = data.rsp;
|
2010-07-28 20:24:29 +00:00
|
|
|
|
2010-07-22 19:56:09 +00:00
|
|
|
// Remove loader
|
2011-01-19 15:56:43 +00:00
|
|
|
$('#' + tabId).find('img').remove();
|
2010-07-28 20:24:29 +00:00
|
|
|
|
2010-07-22 19:56:09 +00:00
|
|
|
// Create division to hold inventory
|
2010-07-26 18:34:29 +00:00
|
|
|
var invDivId = tabId + 'Inventory';
|
2010-07-22 19:56:09 +00:00
|
|
|
var invDiv = $('<div class="inventory" id="' + invDivId + '"></div>');
|
2010-07-28 20:24:29 +00:00
|
|
|
|
2010-07-26 18:34:29 +00:00
|
|
|
// Loop through each line
|
2010-07-28 20:24:29 +00:00
|
|
|
var fieldSet, legend, oList, item;
|
2011-04-16 14:40:15 +00:00
|
|
|
for (var k = 0; k < inv.length; k++) {
|
2010-07-28 20:24:29 +00:00
|
|
|
// Remove node name in front
|
2010-07-26 18:34:29 +00:00
|
|
|
var str = inv[k].replace(node + ': ', '');
|
2010-07-29 20:22:09 +00:00
|
|
|
str = jQuery.trim(str);
|
2010-07-28 20:24:29 +00:00
|
|
|
|
|
|
|
// If string is a header
|
|
|
|
if (str.indexOf('I/O Bus Information') > -1 || str.indexOf('Machine Configuration Info') > -1) {
|
2010-07-26 18:34:29 +00:00
|
|
|
// Create a fieldset
|
|
|
|
fieldSet = $('<fieldset></fieldset>');
|
|
|
|
legend = $('<legend>' + str + '</legend>');
|
|
|
|
fieldSet.append(legend);
|
|
|
|
oList = $('<ol></ol>');
|
|
|
|
fieldSet.append(oList);
|
|
|
|
invDiv.append(fieldSet);
|
|
|
|
} else {
|
|
|
|
// If no fieldset is defined
|
|
|
|
if (!fieldSet) {
|
2010-07-28 20:24:29 +00:00
|
|
|
// Define general fieldset
|
2010-07-26 18:34:29 +00:00
|
|
|
fieldSet = $('<fieldset></fieldset>');
|
|
|
|
legend = $('<legend>General</legend>');
|
|
|
|
fieldSet.append(legend);
|
|
|
|
oList = $('<ol></ol>');
|
|
|
|
fieldSet.append(oList);
|
|
|
|
invDiv.append(fieldSet);
|
|
|
|
}
|
2010-07-28 20:24:29 +00:00
|
|
|
|
2010-07-26 18:34:29 +00:00
|
|
|
// Append the string to a list
|
|
|
|
item = $('<li></li>');
|
2010-07-28 20:24:29 +00:00
|
|
|
item.append(str);
|
|
|
|
oList.append(item);
|
2010-07-26 18:34:29 +00:00
|
|
|
}
|
2010-07-22 19:56:09 +00:00
|
|
|
}
|
2010-07-28 20:24:29 +00:00
|
|
|
|
2010-07-22 19:56:09 +00:00
|
|
|
// Append to inventory form
|
|
|
|
$('#' + tabId).append(invDiv);
|
|
|
|
};
|
2010-07-15 22:57:48 +00:00
|
|
|
|
|
|
|
/**
|
2010-07-19 18:28:31 +00:00
|
|
|
* Load clone page
|
2010-07-15 22:57:48 +00:00
|
|
|
*
|
|
|
|
* @param node
|
2010-07-19 18:28:31 +00:00
|
|
|
* Source node to clone
|
2010-07-15 22:57:48 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
hmcPlugin.prototype.loadClonePage = function(node) {
|
2010-10-07 14:15:56 +00:00
|
|
|
// Get nodes tab
|
|
|
|
var tab = getNodesTab();
|
|
|
|
var newTabId = node + 'CloneTab';
|
|
|
|
|
|
|
|
// If there is no existing clone tab
|
|
|
|
if (!$('#' + newTabId).length) {
|
|
|
|
// Create status bar and hide it
|
|
|
|
var statBarId = node + 'CloneStatusBar';
|
2010-10-08 03:03:42 +00:00
|
|
|
var statBar = $('<div class="statusBar" id="' + statBarId + '"></div>').hide();
|
2010-10-07 14:15:56 +00:00
|
|
|
|
|
|
|
// Create info bar
|
|
|
|
var infoBar = createInfoBar('Under construction');
|
|
|
|
|
|
|
|
// Create clone form
|
|
|
|
var cloneForm = $('<div class="form"></div>');
|
|
|
|
cloneForm.append(statBar);
|
|
|
|
cloneForm.append(infoBar);
|
|
|
|
|
|
|
|
// Add clone tab
|
|
|
|
tab.add(newTabId, 'Clone', cloneForm, true);
|
|
|
|
}
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2010-10-07 14:15:56 +00:00
|
|
|
tab.select(newTabId);
|
2010-07-22 19:56:09 +00:00
|
|
|
};
|
2010-07-15 22:57:48 +00:00
|
|
|
|
|
|
|
/**
|
2010-07-19 18:28:31 +00:00
|
|
|
* Load provision page
|
2010-07-15 22:57:48 +00:00
|
|
|
*
|
|
|
|
* @param tabId
|
|
|
|
* The provision tab ID
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
hmcPlugin.prototype.loadProvisionPage = function(tabId) {
|
2010-07-28 20:24:29 +00:00
|
|
|
// Get OS image names
|
2011-04-16 14:40:15 +00:00
|
|
|
if (!$.cookie('imagenames')) {
|
|
|
|
$.ajax({
|
2011-02-17 09:06:21 +00:00
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'tabdump',
|
|
|
|
tgt : '',
|
|
|
|
args : 'osimage',
|
|
|
|
msg : ''
|
|
|
|
},
|
2010-07-20 18:49:31 +00:00
|
|
|
|
2011-02-17 09:06:21 +00:00
|
|
|
success : setOSImageCookies
|
|
|
|
});
|
|
|
|
}
|
2010-07-20 18:49:31 +00:00
|
|
|
|
|
|
|
// Get groups
|
2011-04-16 14:40:15 +00:00
|
|
|
if (!$.cookie('groups')) {
|
2011-02-17 09:06:21 +00:00
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'extnoderange',
|
|
|
|
tgt : '/.*',
|
|
|
|
args : 'subgroups',
|
|
|
|
msg : ''
|
|
|
|
},
|
2010-07-20 18:49:31 +00:00
|
|
|
|
2011-02-17 09:06:21 +00:00
|
|
|
success : setGroupsCookies
|
|
|
|
});
|
|
|
|
}
|
2010-07-20 18:49:31 +00:00
|
|
|
|
2010-07-28 20:24:29 +00:00
|
|
|
// Get provision tab instance
|
2010-07-20 18:49:31 +00:00
|
|
|
var inst = tabId.replace('hmcProvisionTab', '');
|
|
|
|
|
|
|
|
// Create provision form
|
|
|
|
var provForm = $('<div class="form"></div>');
|
|
|
|
|
|
|
|
// Create status bar
|
2011-02-23 08:34:23 +00:00
|
|
|
var statBar = createStatusBar('statBar').hide();
|
2010-07-20 18:49:31 +00:00
|
|
|
provForm.append(statBar);
|
|
|
|
|
|
|
|
// Create loader
|
2011-02-23 08:34:23 +00:00
|
|
|
var loader = createLoader('loader').hide();
|
2010-07-20 18:49:31 +00:00
|
|
|
statBar.append(loader);
|
|
|
|
|
|
|
|
// Create info bar
|
2011-02-24 19:49:11 +00:00
|
|
|
var infoBar = createInfoBar('Provision a node on System p.');
|
2010-07-20 18:49:31 +00:00
|
|
|
provForm.append(infoBar);
|
|
|
|
|
|
|
|
// Append to provision tab
|
|
|
|
$('#' + tabId).append(provForm);
|
|
|
|
|
2010-07-28 20:24:29 +00:00
|
|
|
// Create provision type drop down
|
2011-02-17 09:06:21 +00:00
|
|
|
provForm.append('<div><label>Provision:</label><select><option value="existing">Existing node</option></select></div>');
|
2010-07-20 18:49:31 +00:00
|
|
|
|
|
|
|
/**
|
2010-07-28 20:24:29 +00:00
|
|
|
* Create provision existing node division
|
2010-07-20 18:49:31 +00:00
|
|
|
*/
|
2011-02-17 09:06:21 +00:00
|
|
|
provForm.append(createHmcProvisionExisting(inst));
|
2010-07-28 20:24:29 +00:00
|
|
|
|
2011-02-17 09:06:21 +00:00
|
|
|
var hmcProvisionBtn = createButton('Provision');
|
|
|
|
hmcProvisionBtn.bind('click', function(event) {
|
2011-02-23 08:34:23 +00:00
|
|
|
// Remove any warning messages
|
|
|
|
var tempTab = $(this).parent().parent();
|
|
|
|
tempTab.find('.ui-state-error').remove();
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-02-23 08:34:23 +00:00
|
|
|
var ready = true;
|
|
|
|
var errMsg = '';
|
|
|
|
var tempNodes = '';
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-02-23 08:34:23 +00:00
|
|
|
// Get nodes that were checked
|
|
|
|
tempNodes = getCheckedByObj(tempTab.find('table'));
|
2011-04-16 14:40:15 +00:00
|
|
|
if ('' == tempNodes) {
|
2011-02-23 08:34:23 +00:00
|
|
|
errMsg += 'You need to select a node.<br>';
|
|
|
|
ready = false;
|
2011-04-16 14:40:15 +00:00
|
|
|
} else {
|
2011-02-23 08:34:23 +00:00
|
|
|
tempNodes = tempNodes.substr(0, tempNodes.length - 1);
|
|
|
|
}
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-02-23 08:34:23 +00:00
|
|
|
// If all inputs are valid, ready to provision
|
2011-04-16 14:40:15 +00:00
|
|
|
if (ready) {
|
2011-02-23 08:34:23 +00:00
|
|
|
// Disable provision button
|
|
|
|
$(this).attr('disabled', 'true');
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-02-23 08:34:23 +00:00
|
|
|
// Show loader
|
|
|
|
tempTab.find('#statBar').show();
|
|
|
|
tempTab.find('#loader').show();
|
|
|
|
|
|
|
|
// Disable all selects, input and checkbox
|
|
|
|
tempTab.find('input').attr('disabled', 'disabled');
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-02-23 08:34:23 +00:00
|
|
|
// Get operating system image
|
|
|
|
var os = tempTab.find('#osname').val();
|
|
|
|
var arch = tempTab.find('#arch').val();
|
|
|
|
var profile = tempTab.find('#pro').val();
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-02-23 08:34:23 +00:00
|
|
|
/**
|
|
|
|
* (1) Set operating system
|
|
|
|
*/
|
2011-04-16 14:40:15 +00:00
|
|
|
$.ajax({
|
2011-02-23 08:34:23 +00:00
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'nodeadd',
|
|
|
|
tgt : '',
|
2011-04-16 14:40:15 +00:00
|
|
|
args : tempNodes + ';noderes.netboot=yaboot;nodetype.os=' + os
|
|
|
|
+ ';nodetype.arch=' + arch + ';nodetype.profile=' + profile,
|
2011-02-23 08:34:23 +00:00
|
|
|
msg : 'cmd=nodeadd;out=' + tempTab.attr('id')
|
|
|
|
},
|
|
|
|
|
|
|
|
success : pProvisionExisting
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// Show warning message
|
|
|
|
var warn = createWarnBar(errMsg);
|
|
|
|
warn.prependTo(tempTab);
|
|
|
|
}
|
2011-02-17 09:06:21 +00:00
|
|
|
});
|
|
|
|
provForm.append(hmcProvisionBtn);
|
2011-04-16 14:40:15 +00:00
|
|
|
|
|
|
|
// Update the node table on group select
|
|
|
|
provForm.find('#groupname').bind('change', function() {
|
2011-02-17 09:06:21 +00:00
|
|
|
var groupName = $(this).val();
|
|
|
|
var nodeArea = $('#hmcSelectNodesTable' + inst);
|
|
|
|
nodeArea.empty();
|
2011-04-16 14:40:15 +00:00
|
|
|
if (!groupName) {
|
2011-02-17 09:06:21 +00:00
|
|
|
nodeArea.html('Select a group to view its nodes');
|
|
|
|
return;
|
2010-07-28 20:24:29 +00:00
|
|
|
}
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-02-17 09:06:21 +00:00
|
|
|
nodeArea.append(createLoader());
|
2011-04-16 14:40:15 +00:00
|
|
|
createNodesArea(groupName, 'hmcSelectNodesTable' + inst);
|
2010-07-20 18:49:31 +00:00
|
|
|
});
|
2010-07-22 19:56:09 +00:00
|
|
|
};
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2010-07-19 18:28:31 +00:00
|
|
|
/**
|
|
|
|
* Load resources
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
hmcPlugin.prototype.loadResources = function() {
|
2010-10-08 03:03:42 +00:00
|
|
|
// Get resource tab ID
|
2011-01-19 15:56:43 +00:00
|
|
|
var tabId = 'hmcResourceTab';
|
|
|
|
// Remove loader
|
|
|
|
$('#' + tabId).find('img').remove();
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2010-10-07 17:40:24 +00:00
|
|
|
// Create info bar
|
|
|
|
var infoBar = createInfoBar('Under construction');
|
2010-07-28 20:24:29 +00:00
|
|
|
|
2010-10-07 17:40:24 +00:00
|
|
|
// Create resource form
|
|
|
|
var resrcForm = $('<div class="form"></div>');
|
|
|
|
resrcForm.append(infoBar);
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-01-19 15:56:43 +00:00
|
|
|
$('#' + tabId).append(resrcForm);
|
2010-09-22 16:52:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2010-09-24 02:27:04 +00:00
|
|
|
* Add node range
|
2010-09-22 16:52:41 +00:00
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-09-23 20:43:10 +00:00
|
|
|
hmcPlugin.prototype.addNode = function() {
|
2010-10-07 14:15:56 +00:00
|
|
|
openDialog('info', 'Under construction');
|
2011-02-17 09:06:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create hmc provision existing form
|
|
|
|
*
|
2011-04-16 14:40:15 +00:00
|
|
|
* @return: Form content
|
2011-02-17 09:06:21 +00:00
|
|
|
*/
|
2011-04-16 14:40:15 +00:00
|
|
|
function createHmcProvisionExisting(inst) {
|
|
|
|
// Create the group area
|
2011-02-17 09:06:21 +00:00
|
|
|
var strGroup = '<div><label>Group:</label>';
|
|
|
|
var groupNames = $.cookie('groups');
|
2011-04-16 14:40:15 +00:00
|
|
|
if (groupNames) {
|
2011-02-17 09:06:21 +00:00
|
|
|
strGroup += '<select id="groupname"><option></option>';
|
|
|
|
var temp = groupNames.split(',');
|
2011-04-16 14:40:15 +00:00
|
|
|
for (var i in temp) {
|
2011-02-17 09:06:21 +00:00
|
|
|
strGroup += '<option value="' + temp[i] + '">' + temp[i] + '</option>';
|
|
|
|
}
|
|
|
|
strGroup += '</select>';
|
2011-04-16 14:40:15 +00:00
|
|
|
} else {
|
2011-02-17 09:06:21 +00:00
|
|
|
strGroup += '<input type="text" id="groupname">';
|
|
|
|
}
|
|
|
|
strGroup += '</div>';
|
2011-04-16 14:40:15 +00:00
|
|
|
|
|
|
|
// Create nodes area
|
|
|
|
var strNodes = '<div><label>Nodes:</label><div id="hmcSelectNodesTable'
|
|
|
|
+ inst
|
|
|
|
+ '" style="display:inline-block;width:700px;overflow-y:auto;">Select a group to view its nodes</div></div>';
|
|
|
|
|
|
|
|
// Create boot method
|
|
|
|
var strBoot = '<div><label>Boot Method:</label><select id="boot">'
|
|
|
|
+ '<option value="install">install</option>'
|
|
|
|
+ '<option value="netboot">netboot</option>'
|
|
|
|
+ '<option value="statelite">statelite</option></select></div>';
|
|
|
|
|
2011-02-17 09:06:21 +00:00
|
|
|
// Create operating system
|
|
|
|
var strOs = '<div><label>Operating system:</label>';
|
|
|
|
var osName = $.cookie('osvers');
|
2011-04-16 14:40:15 +00:00
|
|
|
if (osName) {
|
2011-02-17 09:06:21 +00:00
|
|
|
strOs += '<select id="osname">';
|
|
|
|
var temp = osName.split(',');
|
2011-04-16 14:40:15 +00:00
|
|
|
for (var i in temp) {
|
2011-02-17 09:06:21 +00:00
|
|
|
strOs += '<option value="' + temp[i] + '">' + temp[i] + '</option>';
|
|
|
|
}
|
|
|
|
strOs += '</select>';
|
2011-04-16 14:40:15 +00:00
|
|
|
} else {
|
2011-02-17 09:06:21 +00:00
|
|
|
strOs += '<input type="text" id="osname">';
|
|
|
|
}
|
|
|
|
strOs += '</div>';
|
2011-04-16 14:40:15 +00:00
|
|
|
|
|
|
|
// Create architecture
|
2011-02-17 09:06:21 +00:00
|
|
|
var strArch = '<div><label>Architecture:</label>';
|
|
|
|
var archName = $.cookie('osarchs');
|
2011-04-16 14:40:15 +00:00
|
|
|
if ('' != archName) {
|
2011-02-17 09:06:21 +00:00
|
|
|
strArch += '<select id="arch">';
|
|
|
|
var temp = archName.split(',');
|
2011-04-16 14:40:15 +00:00
|
|
|
for (var i in temp) {
|
2011-02-17 09:06:21 +00:00
|
|
|
strArch += '<option value="' + temp[i] + '">' + temp[i] + '</option>';
|
|
|
|
}
|
|
|
|
strArch += '</select>';
|
2011-04-16 14:40:15 +00:00
|
|
|
} else {
|
2011-02-17 09:06:21 +00:00
|
|
|
strArch += '<input type="text" id="arch">';
|
|
|
|
}
|
|
|
|
strArch += '</div>';
|
2011-04-16 14:40:15 +00:00
|
|
|
|
|
|
|
// Create profile
|
2011-02-17 09:06:21 +00:00
|
|
|
var strPro = '<div><label>Profile:</label>';
|
|
|
|
var proName = $.cookie('profiles');
|
2011-04-16 14:40:15 +00:00
|
|
|
if ('' != proName) {
|
2011-02-17 09:06:21 +00:00
|
|
|
strPro += '<select id="pro">';
|
|
|
|
var temp = proName.split(',');
|
2011-04-16 14:40:15 +00:00
|
|
|
for (var i in temp) {
|
2011-02-17 09:06:21 +00:00
|
|
|
strPro += '<option value="' + temp[i] + '">' + temp[i] + '</option>';
|
|
|
|
}
|
|
|
|
strPro += '</select>';
|
2011-04-16 14:40:15 +00:00
|
|
|
} else {
|
2011-02-17 09:06:21 +00:00
|
|
|
strPro += '<input type="text" id="pro">';
|
|
|
|
}
|
|
|
|
strPro += '</div>';
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-02-17 09:06:21 +00:00
|
|
|
var strRet = strGroup + strNodes + strBoot + strOs + strArch + strPro;
|
|
|
|
return strRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-16 14:40:15 +00:00
|
|
|
* Refresh the nodes area base on group selected
|
2011-02-17 09:06:21 +00:00
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2011-04-16 14:40:15 +00:00
|
|
|
function createNodesArea(groupName, areaId) {
|
2011-02-17 09:06:21 +00:00
|
|
|
// Get group nodes
|
2011-04-16 14:40:15 +00:00
|
|
|
$.ajax({
|
2011-02-17 09:06:21 +00:00
|
|
|
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 = '<table><thead><tr><th><input type="checkbox" onclick="selectAllCheckbox(event, $(this))"></th>';
|
|
|
|
showStr += '<th>Node</th></tr></thead><tbody>';
|
2011-04-16 14:40:15 +00:00
|
|
|
for (index in nodes) {
|
2011-02-17 09:06:21 +00:00
|
|
|
var node = nodes[index][0];
|
2011-04-16 14:40:15 +00:00
|
|
|
if ('' == node) {
|
2011-02-17 09:06:21 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-04-16 14:40:15 +00:00
|
|
|
showStr += '<tr><td><input type="checkbox" name="' + node + '"/></td><td>'
|
|
|
|
+ node + '</td></tr>';
|
2011-02-17 09:06:21 +00:00
|
|
|
}
|
|
|
|
showStr += '</tbody></table>';
|
|
|
|
areaObj.empty().append(showStr);
|
2011-04-16 14:40:15 +00:00
|
|
|
if (index > 10) {
|
2011-02-17 09:06:21 +00:00
|
|
|
areaObj.css('height', '300px');
|
2011-04-16 14:40:15 +00:00
|
|
|
} else {
|
2011-02-17 09:06:21 +00:00
|
|
|
areaObj.css('height', 'auto');
|
|
|
|
}
|
|
|
|
} // End of function(data)
|
|
|
|
});
|
2011-02-23 08:34:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-16 14:40:15 +00:00
|
|
|
* Provision for existing system p node
|
2011-02-23 08:34:23 +00:00
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2011-04-16 14:40:15 +00:00
|
|
|
function pProvisionExisting(data) {
|
2011-02-23 08:34:23 +00:00
|
|
|
// 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=', '');
|
2011-04-16 14:40:15 +00:00
|
|
|
|
|
|
|
// Get tab obj
|
2011-02-23 08:34:23 +00:00
|
|
|
var tempTab = $('#' + tabId);
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-02-23 08:34:23 +00:00
|
|
|
/**
|
|
|
|
* (2) Prepare node for boot
|
|
|
|
*/
|
|
|
|
if (cmd == 'nodeadd') {
|
|
|
|
// Get operating system
|
|
|
|
var bootMethod = tempTab.find('#boot').val();
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-02-23 08:34:23 +00:00
|
|
|
// Get nodes that were checked
|
|
|
|
var tgts = getCheckedByObj(tempTab.find('table'));
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-02-23 08:34:23 +00:00
|
|
|
// Prepare node for boot
|
2011-04-16 14:40:15 +00:00
|
|
|
$.ajax({
|
2011-02-23 08:34:23 +00:00
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'nodeset',
|
|
|
|
tgt : tgts,
|
|
|
|
args : bootMethod,
|
|
|
|
msg : 'cmd=nodeset;out=' + tabId
|
|
|
|
},
|
|
|
|
|
|
|
|
success : pProvisionExisting
|
|
|
|
});
|
2011-04-16 14:40:15 +00:00
|
|
|
}
|
|
|
|
|
2011-02-23 08:34:23 +00:00
|
|
|
/**
|
|
|
|
* (3) Boot node from network
|
|
|
|
*/
|
|
|
|
else if (cmd == 'nodeset') {
|
|
|
|
// Write ajax response to status bar
|
2011-04-16 14:40:15 +00:00
|
|
|
var prg = writeRsp(rsp, '');
|
2011-02-23 08:34:23 +00:00
|
|
|
tempTab.find('#statBar').append(prg);
|
|
|
|
|
|
|
|
// If there was an error, do not continue
|
|
|
|
if (prg.html().indexOf('Error') > -1) {
|
|
|
|
tempTab.find('#loader').remove();
|
|
|
|
return;
|
|
|
|
}
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-02-23 08:34:23 +00:00
|
|
|
// Get nodes that were checked
|
|
|
|
var tgts = getCheckedByObj(tempTab.find('table'));
|
2011-04-16 14:40:15 +00:00
|
|
|
|
2011-02-23 08:34:23 +00:00
|
|
|
// Boot node from network
|
2011-04-16 14:40:15 +00:00
|
|
|
$.ajax({
|
2011-02-23 08:34:23 +00:00
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'rnetboot',
|
|
|
|
tgt : tgts,
|
|
|
|
args : '',
|
|
|
|
msg : 'cmd=rnetboot;out=' + tabId
|
|
|
|
},
|
|
|
|
|
|
|
|
success : pProvisionExisting
|
|
|
|
});
|
2011-04-16 14:40:15 +00:00
|
|
|
}
|
|
|
|
|
2011-02-23 08:34:23 +00:00
|
|
|
/**
|
|
|
|
* (4) Done
|
|
|
|
*/
|
|
|
|
else if (cmd == 'rnetboot') {
|
|
|
|
// Write ajax response to status bar
|
2011-04-16 14:40:15 +00:00
|
|
|
var prg = writeRsp(rsp, '');
|
2011-02-23 08:34:23 +00:00
|
|
|
tempTab.find('#statBar').append(prg);
|
|
|
|
tempTab.find('#loader').remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-16 14:40:15 +00:00
|
|
|
* Get all select elements' name in the obj
|
2011-02-23 08:34:23 +00:00
|
|
|
*
|
2011-04-16 14:40:15 +00:00
|
|
|
* @return All nodes name, seperate by ','
|
2011-02-23 08:34:23 +00:00
|
|
|
*/
|
2011-04-16 14:40:15 +00:00
|
|
|
function getCheckedByObj(obj) {
|
2011-02-23 08:34:23 +00:00
|
|
|
var tempStr = '';
|
|
|
|
// Get nodes that were checked
|
2011-04-16 14:40:15 +00:00
|
|
|
obj.find('input:checked').each(function() {
|
|
|
|
if ($(this).attr('name')) {
|
2011-02-23 08:34:23 +00:00
|
|
|
tempStr += $(this).attr('name') + ',';
|
|
|
|
}
|
|
|
|
});
|
2011-04-16 14:40:15 +00:00
|
|
|
|
|
|
|
if ('' != tempStr) {
|
2011-02-23 08:34:23 +00:00
|
|
|
tempStr = tempStr.substr(0, tempStr.length - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return tempStr;
|
2011-02-17 09:06:21 +00:00
|
|
|
}
|