2010-07-28 20:24:29 +00:00
|
|
|
/**
|
|
|
|
* Execute when the DOM is fully loaded
|
|
|
|
*/
|
|
|
|
$(document).ready(function() {
|
|
|
|
// Load utility scripts
|
2010-07-20 18:49:31 +00:00
|
|
|
});
|
|
|
|
|
2010-07-22 19:56:09 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
var ipmiPlugin = function() {
|
2010-07-28 20:24:29 +00:00
|
|
|
|
2010-07-22 19:56:09 +00:00
|
|
|
};
|
|
|
|
|
2010-07-20 18:49:31 +00:00
|
|
|
/**
|
|
|
|
* Load node inventory
|
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
* Data from HTTP request
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
ipmiPlugin.prototype.loadInventory = function(data) {
|
2010-10-07 14:15:56 +00:00
|
|
|
// Get arguments
|
|
|
|
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;
|
|
|
|
|
|
|
|
// Remove loader
|
2011-01-19 15:56:43 +00:00
|
|
|
$('#' + tabId).find('img').remove();
|
2010-10-07 14:15:56 +00:00
|
|
|
|
|
|
|
// Create division to hold inventory
|
|
|
|
var invDivId = tabId + 'Inventory';
|
|
|
|
var invDiv = $('<div class="inventory" id="' + invDivId + '"></div>');
|
|
|
|
var info = createInfoBar('Under construction');
|
|
|
|
invDiv.append(info);
|
|
|
|
|
|
|
|
// Append to inventory form
|
|
|
|
$('#' + tabId).append(invDiv);
|
2010-07-22 19:56:09 +00:00
|
|
|
};
|
2010-07-20 18:49:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load clone page
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* Source node to clone
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
ipmiPlugin.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);
|
|
|
|
}
|
|
|
|
|
|
|
|
tab.select(newTabId);
|
2010-07-22 19:56:09 +00:00
|
|
|
};
|
2010-07-20 18:49:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load provision page
|
|
|
|
*
|
|
|
|
* @param tabId
|
|
|
|
* The provision tab ID
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
ipmiPlugin.prototype.loadProvisionPage = function(tabId) {
|
2010-07-28 20:24:29 +00:00
|
|
|
// Get OS image names
|
2010-07-20 18:49:31 +00:00
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'tabdump',
|
|
|
|
tgt : '',
|
|
|
|
args : 'osimage',
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
|
|
|
|
success : setOSImageCookies
|
|
|
|
});
|
|
|
|
|
|
|
|
// Get groups
|
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'extnoderange',
|
|
|
|
tgt : '/.*',
|
|
|
|
args : 'subgroups',
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
|
|
|
|
success : setGroupsCookies
|
|
|
|
});
|
|
|
|
|
2010-07-28 20:24:29 +00:00
|
|
|
// Get provision tab instance
|
2010-07-20 18:49:31 +00:00
|
|
|
var inst = tabId.replace('ipmiProvisionTab', '');
|
|
|
|
|
|
|
|
// Create provision form
|
|
|
|
var provForm = $('<div class="form"></div>');
|
|
|
|
|
|
|
|
// Create status bar
|
2010-07-28 20:24:29 +00:00
|
|
|
var statBarId = 'ipmiProvisionStatBar' + inst;
|
2011-01-19 15:56:43 +00:00
|
|
|
var statBar = createStatusBar(statBarId).hide();
|
2010-07-20 18:49:31 +00:00
|
|
|
provForm.append(statBar);
|
|
|
|
|
|
|
|
// Create loader
|
2011-01-19 15:56:43 +00:00
|
|
|
var loader = createLoader('ipmiProvisionLoader' + inst).hide();
|
2011-04-27 20:28:00 +00:00
|
|
|
statBar.find('div').append(loader);
|
2010-07-20 18:49:31 +00:00
|
|
|
|
|
|
|
// Create info bar
|
2011-02-24 19:49:11 +00:00
|
|
|
var infoBar = createInfoBar('Provision a node on iDataPlex.');
|
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
|
|
|
|
var provType = $('<div></div>');
|
|
|
|
var typeLabel = $('<label>Provision:</label>');
|
|
|
|
var typeSelect = $('<select></select>');
|
|
|
|
var provNewNode = $('<option value="new">New node</option>');
|
|
|
|
var provExistNode = $('<option value="existing">Existing node</option>');
|
|
|
|
typeSelect.append(provNewNode);
|
|
|
|
typeSelect.append(provExistNode);
|
|
|
|
provType.append(typeLabel);
|
|
|
|
provType.append(typeSelect);
|
|
|
|
provForm.append(provType);
|
2010-07-20 18:49:31 +00:00
|
|
|
|
|
|
|
/**
|
2010-07-28 20:24:29 +00:00
|
|
|
* Create provision new node division
|
2010-07-20 18:49:31 +00:00
|
|
|
*/
|
2010-10-08 03:03:42 +00:00
|
|
|
// You should copy whatever is in this function, put it here, and customize it
|
2010-07-28 20:24:29 +00:00
|
|
|
var provNew = createProvisionNew('ipmi', inst);
|
|
|
|
provForm.append(provNew);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create provision existing node division
|
|
|
|
*/
|
2010-10-08 03:03:42 +00:00
|
|
|
// You should copy whatever is in this function, put it here, and customize it
|
2010-07-28 20:24:29 +00:00
|
|
|
var provExisting = createProvisionExisting('ipmi', inst);
|
|
|
|
provForm.append(provExisting);
|
|
|
|
|
|
|
|
// Toggle provision new/existing on select
|
|
|
|
typeSelect.change(function() {
|
|
|
|
var selected = $(this).val();
|
|
|
|
if (selected == 'new') {
|
|
|
|
provNew.toggle();
|
|
|
|
provExisting.toggle();
|
|
|
|
} else {
|
|
|
|
provNew.toggle();
|
|
|
|
provExisting.toggle();
|
|
|
|
}
|
2010-07-20 18:49:31 +00:00
|
|
|
});
|
2010-07-22 19:56:09 +00:00
|
|
|
};
|
2010-07-20 18:49:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load resources
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
ipmiPlugin.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 = 'ipmiResourceTab';
|
|
|
|
// Remove loader
|
|
|
|
$('#' + tabId).find('img').remove();
|
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-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
|
|
|
ipmiPlugin.prototype.addNode = function() {
|
2011-07-07 08:50:26 +00:00
|
|
|
var diaDiv = $('<div id="addIdpDiv" class="form" title="Add iDataPlex Node"></div>');
|
|
|
|
var showStr = '<div><label>Node Name: </label><input type="text"></div>' +
|
2011-07-20 21:13:09 +00:00
|
|
|
'<div><label>Node MAC:</label><input type="text"></div>' +
|
2011-07-07 08:50:26 +00:00
|
|
|
'<div><label>Node IP: </label><input type="text"></div>' +
|
|
|
|
'<div><label>Node Groups : </label><input type="text"></div>' +
|
|
|
|
'<div><label>BMC Name:</label><input type="text"></div>' +
|
|
|
|
'<div><label>BMC IP:</label><input type="text"></div>' +
|
2011-07-20 21:13:09 +00:00
|
|
|
'<div><label>BMC Groups:</label><input type="text"></div>';
|
2011-07-07 08:50:26 +00:00
|
|
|
|
|
|
|
diaDiv.append(showStr);
|
|
|
|
diaDiv.dialog({
|
|
|
|
modal: true,
|
|
|
|
width: 400,
|
|
|
|
close: function(){$(this).remove();},
|
|
|
|
buttons: {
|
|
|
|
"OK" : function(){addidataplexNode();},
|
|
|
|
"Cancel": function(){$(this).dialog('close');}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
function addidataplexNode(){
|
|
|
|
var tempArray = new Array();
|
|
|
|
var errormessage = '';
|
|
|
|
var attr = '';
|
|
|
|
var args = '';
|
|
|
|
|
|
|
|
//remove the warning bar
|
|
|
|
$('#addIdpDiv .ui-state-error').remove();
|
|
|
|
|
|
|
|
//get all inputs' value
|
|
|
|
$('#addIdpDiv input').each(function(){
|
|
|
|
attr = $(this).val();
|
|
|
|
if (attr){
|
|
|
|
tempArray.push($(this).val());
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
errormessage = "You are missing some input!";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if ('' != errormessage){
|
|
|
|
$('#addIdpDiv').prepend(createWarnBar(errormessage));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//add the loader
|
|
|
|
$('#addIdpDiv').append(createLoader());
|
|
|
|
|
|
|
|
//change the dialog button
|
|
|
|
$('#addIdpDiv').dialog('option', 'buttons', {'Close':function(){$('#addIdpDiv').dialog('close');}});
|
|
|
|
|
|
|
|
//compose all args into chdef for node
|
|
|
|
args = '-t;node;-o;' + tempArray[0] + ';mac=' + tempArray[1] + ';ip=' + tempArray[2] + ';groups=' +
|
2011-07-08 08:59:58 +00:00
|
|
|
tempArray[3] + ';mgt=ipmi;chain="runcmd=bmcsetup";netboot=xnba;nodetype=osi;profile=compute;' +
|
|
|
|
'bmc=' + tempArray[4];
|
2011-07-07 08:50:26 +00:00
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'chdef',
|
|
|
|
tgt : '',
|
|
|
|
args : args,
|
|
|
|
msg : ''
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
//compose all args into chdef for bmc
|
|
|
|
args = '-t;node;-o;' + tempArray[4] + ';ip=' + tempArray[5] + ';groups=' + tempArray[6];
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'chdef',
|
|
|
|
tgt : '',
|
|
|
|
args : args,
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
success: function(data){
|
|
|
|
$('#addIdpDiv img').remove();
|
|
|
|
var message = '';
|
|
|
|
for (var i in data.rsp){
|
|
|
|
message += data.rsp[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ('' != message){
|
|
|
|
$('#addIdpDiv').prepend(createInfoBar(message));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|