2010-06-16 18:21:58 +00:00
|
|
|
/**
|
|
|
|
* Global variables
|
|
|
|
*/
|
|
|
|
var provisionTabs; // Provision tabs
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the provision tab
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param obj Tab object
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
function setProvisionTab(obj) {
|
2012-05-04 00:54:58 +00:00
|
|
|
provisionTabs = obj;
|
2010-06-16 18:21:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the provision tab
|
|
|
|
*
|
|
|
|
* @param Nothing
|
|
|
|
* @return Tab object
|
|
|
|
*/
|
|
|
|
function getProvisionTab() {
|
2012-05-04 00:54:58 +00:00
|
|
|
return provisionTabs;
|
2010-06-16 18:21:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load provision page
|
|
|
|
*/
|
|
|
|
function loadProvisionPage() {
|
2012-05-04 00:54:58 +00:00
|
|
|
// If the page is loaded
|
|
|
|
if ($('#content').children().length) {
|
|
|
|
// Do not load again
|
|
|
|
return;
|
|
|
|
}
|
2010-06-16 18:21:58 +00:00
|
|
|
|
2012-05-04 00:54:58 +00:00
|
|
|
// Get OS image names
|
|
|
|
if (!$.cookie('imagenames')){
|
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'tabdump',
|
|
|
|
tgt : '',
|
|
|
|
args : 'osimage',
|
|
|
|
msg : ''
|
|
|
|
},
|
2011-02-23 08:34:23 +00:00
|
|
|
|
2012-05-04 00:54:58 +00:00
|
|
|
success : setOSImageCookies
|
|
|
|
});
|
|
|
|
}
|
2011-02-23 08:34:23 +00:00
|
|
|
|
2012-05-04 00:54:58 +00:00
|
|
|
// Get groups
|
|
|
|
if (!$.cookie('groups')){
|
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'extnoderange',
|
|
|
|
tgt : '/.*',
|
|
|
|
args : 'subgroups',
|
|
|
|
msg : ''
|
|
|
|
},
|
2011-02-23 08:34:23 +00:00
|
|
|
|
2012-05-04 00:54:58 +00:00
|
|
|
success : setGroupsCookies
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create info bar
|
|
|
|
var infoBar = createInfoBar('Select a platform to provision or re-provision a node on, then click Ok.');
|
|
|
|
|
|
|
|
// Create provision page
|
|
|
|
var provPg = $('<div class="form"></div>');
|
|
|
|
provPg.append(infoBar);
|
2010-06-16 18:21:58 +00:00
|
|
|
|
2012-05-04 00:54:58 +00:00
|
|
|
// Create provision tab
|
|
|
|
var tab = new Tab('provisionPageTabs');
|
|
|
|
setProvisionTab(tab);
|
|
|
|
tab.init();
|
|
|
|
$('#content').append(tab.object());
|
2010-06-16 18:21:58 +00:00
|
|
|
|
2012-05-04 00:54:58 +00:00
|
|
|
// Create radio buttons for platforms
|
|
|
|
var hwList = $('<ol>Platforms available:</ol>');
|
|
|
|
var esx = $('<li><input type="radio" name="hw" value="esx" checked/>ESX</li>');
|
|
|
|
var kvm = $('<li><input type="radio" name="hw" value="kvm"/>KVM</li>');
|
|
|
|
var zvm = $('<li><input type="radio" name="hw" value="zvm"/>z\/VM</li>');
|
|
|
|
var ipmi = $('<li><input type="radio" name="hw" value="ipmi"/>iDataPlex</li>');
|
|
|
|
var blade = $('<li><input type="radio" name="hw" value="blade"/>BladeCenter</li>');
|
|
|
|
var hmc = $('<li><input type="radio" name="hw" value="hmc"/>System p</li>');
|
|
|
|
|
|
|
|
hwList.append(esx);
|
|
|
|
hwList.append(kvm);
|
|
|
|
hwList.append(zvm);
|
|
|
|
hwList.append(blade);
|
|
|
|
hwList.append(ipmi);
|
|
|
|
hwList.append(hmc);
|
|
|
|
provPg.append(hwList);
|
2010-06-16 18:21:58 +00:00
|
|
|
|
2012-05-04 00:54:58 +00:00
|
|
|
/**
|
|
|
|
* Ok
|
|
|
|
*/
|
|
|
|
var okBtn = createButton('Ok');
|
|
|
|
okBtn.bind('click', function(event) {
|
|
|
|
// Get hardware that was selected
|
|
|
|
var hw = $(this).parent().find('input[name="hw"]:checked').val();
|
|
|
|
|
|
|
|
var inst = 0;
|
|
|
|
var newTabId = hw + 'ProvisionTab' + inst;
|
|
|
|
while ($('#' + newTabId).length) {
|
|
|
|
// If one already exists, generate another one
|
|
|
|
inst = inst + 1;
|
|
|
|
newTabId = hw + 'ProvisionTab' + inst;
|
|
|
|
}
|
|
|
|
|
2011-11-24 04:18:38 +00:00
|
|
|
// Create an instance of the plugin
|
2012-05-04 00:54:58 +00:00
|
|
|
var title = '';
|
2011-11-24 04:18:38 +00:00
|
|
|
var plugin;
|
|
|
|
switch (hw) {
|
2012-05-04 00:54:58 +00:00
|
|
|
case "kvm":
|
|
|
|
plugin = new kvmPlugin();
|
|
|
|
title = 'KVM';
|
|
|
|
break;
|
|
|
|
case "esx":
|
|
|
|
plugin = new esxPlugin();
|
|
|
|
title = 'ESX';
|
|
|
|
break;
|
|
|
|
case "blade":
|
|
|
|
plugin = new bladePlugin();
|
|
|
|
title = 'BladeCenter';
|
|
|
|
break;
|
|
|
|
case "hmc":
|
|
|
|
plugin = new hmcPlugin();
|
|
|
|
title = 'System p';
|
|
|
|
break;
|
|
|
|
case "ipmi":
|
|
|
|
plugin = new ipmiPlugin();
|
|
|
|
title = 'iDataPlex';
|
|
|
|
break;
|
|
|
|
case "zvm":
|
|
|
|
plugin = new zvmPlugin();
|
|
|
|
title = 'z/VM';
|
|
|
|
break;
|
2011-11-24 04:18:38 +00:00
|
|
|
}
|
2011-08-24 10:30:30 +00:00
|
|
|
|
2011-11-24 04:18:38 +00:00
|
|
|
// Select tab
|
|
|
|
tab.add(newTabId, title, '', true);
|
|
|
|
tab.select(newTabId);
|
|
|
|
plugin.loadProvisionPage(newTabId);
|
2012-05-04 00:54:58 +00:00
|
|
|
});
|
|
|
|
provPg.append(okBtn);
|
2010-06-16 18:21:58 +00:00
|
|
|
|
2012-05-04 00:54:58 +00:00
|
|
|
// Add provision tab
|
|
|
|
tab.add('provisionTab', 'Provision', provPg, false);
|
|
|
|
// Add image tab
|
|
|
|
tab.add('imagesTab', 'Images', '', false);
|
|
|
|
|
|
|
|
// Load tabs onselect
|
|
|
|
$('#provisionPageTabs').bind('tabsselect', function(event, ui){
|
|
|
|
// Load image page
|
|
|
|
if (!$('#imagesTab').children().length && ui.index == 1) {
|
|
|
|
$('#imagesTab').append($('<center></center>').append(createLoader('')));
|
|
|
|
loadImagesPage();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Open the quick provision tab
|
|
|
|
if (window.location.search) {
|
|
|
|
tab.add('quickProvisionTab', 'Quick Provision', '', true);
|
|
|
|
tab.select('quickProvisionTab');
|
|
|
|
|
|
|
|
var provForm = $('<div class="form"></div>');
|
|
|
|
$('#quickProvisionTab').append(provForm);
|
|
|
|
appendProvisionSection('quick', provForm);
|
|
|
|
}
|
2010-06-16 18:21:58 +00:00
|
|
|
}
|