2010-07-28 20:24:29 +00:00
|
|
|
/**
|
|
|
|
* Create nodes datatable for a given group
|
|
|
|
*
|
|
|
|
* @param group
|
|
|
|
* Group name
|
|
|
|
* @param outId
|
|
|
|
* Division ID to append datatable
|
|
|
|
* @return Nodes datatable
|
|
|
|
*/
|
|
|
|
function createNodesDatatable(group, outId) {
|
|
|
|
// Get group nodes
|
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'lsdef',
|
|
|
|
tgt : '',
|
|
|
|
args : group,
|
|
|
|
msg : outId
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create nodes datatable
|
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
* Data returned from HTTP request
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
success : function(data) {
|
|
|
|
// Data returned
|
|
|
|
var rsp = data.rsp;
|
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
// Get output ID
|
2010-07-28 20:24:29 +00:00
|
|
|
var outId = data.msg;
|
2010-10-08 03:03:42 +00:00
|
|
|
// Get datatable ID
|
2010-07-28 20:24:29 +00:00
|
|
|
var dTableId = outId.replace('DIV', '');
|
|
|
|
|
|
|
|
// Node attributes hash
|
|
|
|
var attrs = new Object();
|
|
|
|
// Node attributes
|
|
|
|
var headers = new Object();
|
|
|
|
|
|
|
|
// Clear nodes datatable division
|
2011-02-17 09:06:21 +00:00
|
|
|
$('#' + outId).empty();
|
2010-07-28 20:24:29 +00:00
|
|
|
|
|
|
|
// Create nodes datatable
|
|
|
|
var node, args;
|
|
|
|
for ( var i in rsp) {
|
|
|
|
// Get node
|
|
|
|
var pos = rsp[i].indexOf('Object name:');
|
|
|
|
if (pos > -1) {
|
|
|
|
var temp = rsp[i].split(': ');
|
|
|
|
node = jQuery.trim(temp[1]);
|
|
|
|
|
|
|
|
// Create a hash for the node attributes
|
|
|
|
attrs[node] = new Object();
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get key and value
|
|
|
|
args = rsp[i].split('=');
|
|
|
|
var key = jQuery.trim(args[0]);
|
|
|
|
var val = jQuery.trim(args[1]);
|
|
|
|
|
|
|
|
// Create hash table
|
|
|
|
attrs[node][key] = val;
|
|
|
|
headers[key] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sort headers
|
|
|
|
var sorted = new Array();
|
|
|
|
for ( var key in headers) {
|
|
|
|
sorted.push(key);
|
|
|
|
}
|
|
|
|
sorted.sort();
|
|
|
|
|
|
|
|
// Add column for check box and node
|
|
|
|
sorted.unshift('<input type="checkbox" onclick="selectAllCheckbox(event, $(this))">', 'node');
|
|
|
|
|
|
|
|
// Create nodes datatable
|
|
|
|
var dTable = new DataTable(dTableId);
|
|
|
|
dTable.init(sorted);
|
|
|
|
|
|
|
|
// Go through each node
|
|
|
|
for ( var node in attrs) {
|
|
|
|
// Create a row
|
|
|
|
var row = new Array();
|
|
|
|
// Create a check box
|
|
|
|
var checkBx = '<input type="checkbox" name="' + node + '"/>';
|
|
|
|
row.push(checkBx, node);
|
|
|
|
|
|
|
|
// Go through each header
|
|
|
|
for ( var i = 2; i < sorted.length; i++) {
|
|
|
|
// Add node attributes to the row
|
|
|
|
var key = sorted[i];
|
|
|
|
var val = attrs[node][key];
|
|
|
|
if (val) {
|
|
|
|
row.push(val);
|
|
|
|
} else {
|
|
|
|
row.push('');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add row to table
|
|
|
|
dTable.add(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#' + outId).append(dTable.object());
|
|
|
|
$('#' + dTableId).dataTable();
|
|
|
|
} // End of function(data)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create provision existing node division
|
|
|
|
*
|
|
|
|
* @param plugin
|
|
|
|
* Plugin name to create division for
|
|
|
|
* @param inst
|
|
|
|
* Provision tab instance
|
|
|
|
* @return Provision existing node division
|
|
|
|
*/
|
|
|
|
function createProvisionExisting(plugin, inst) {
|
|
|
|
// Create provision existing division and hide it
|
|
|
|
var provExisting = $('<div></div>').hide();
|
|
|
|
|
|
|
|
// Create group input
|
|
|
|
var group = $('<div></div>');
|
|
|
|
var groupLabel = $('<label for="provType">Group:</label>');
|
|
|
|
group.append(groupLabel);
|
|
|
|
|
|
|
|
// Turn on auto complete for group
|
|
|
|
var dTableDivId = plugin + 'NodesDatatableDIV' + inst; // Division ID where nodes datatable will be appended
|
2010-11-22 16:18:55 +00:00
|
|
|
var groupNames = $.cookie('groups');
|
2010-07-28 20:24:29 +00:00
|
|
|
if (groupNames) {
|
|
|
|
// Split group names into an array
|
|
|
|
var tmp = groupNames.split(',');
|
|
|
|
|
|
|
|
// Create drop down for groups
|
|
|
|
var groupSelect = $('<select></select>');
|
|
|
|
groupSelect.append('<option></option>');
|
|
|
|
for ( var i in tmp) {
|
|
|
|
// Add group into drop down
|
|
|
|
var opt = $('<option value="' + tmp[i] + '">' + tmp[i] + '</option>');
|
|
|
|
groupSelect.append(opt);
|
|
|
|
}
|
|
|
|
group.append(groupSelect);
|
|
|
|
|
|
|
|
// Create node datatable
|
|
|
|
groupSelect.change(function() {
|
|
|
|
// Get group selected
|
|
|
|
var thisGroup = $(this).val();
|
|
|
|
// If a valid group is selected
|
|
|
|
if (thisGroup) {
|
|
|
|
createNodesDatatable(thisGroup, dTableDivId);
|
|
|
|
} // End of if (thisGroup)
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// If no groups are cookied
|
|
|
|
var groupInput = $('<input type="text" name="group"/>');
|
|
|
|
group.append(groupInput);
|
|
|
|
}
|
|
|
|
provExisting.append(group);
|
|
|
|
|
|
|
|
// Create node input
|
|
|
|
var node = $('<div></div>');
|
|
|
|
var nodeLabel = $('<label for="nodeName">Nodes:</label>');
|
|
|
|
var nodeDatatable = $('<div class="indent" id="' + dTableDivId + '"><p>Select a group to view its nodes</p></div>');
|
|
|
|
node.append(nodeLabel);
|
|
|
|
node.append(nodeDatatable);
|
|
|
|
provExisting.append(node);
|
|
|
|
|
|
|
|
// Create boot method drop down
|
|
|
|
var method = $('<div></div>');
|
|
|
|
var methodLabel = $('<label for="method">Boot method:</label>');
|
|
|
|
var methodSelect = $('<select id="bootMethod" name="bootMethod"></select>');
|
2010-09-24 02:27:04 +00:00
|
|
|
methodSelect.append('<option value="boot">boot</option>'
|
|
|
|
+ '<option value="install">install</option>'
|
|
|
|
+ '<option value="iscsiboot">iscsiboot</option>'
|
|
|
|
+ '<option value="netboot">netboot</option>'
|
|
|
|
+ '<option value="statelite">statelite</option>'
|
|
|
|
);
|
2010-07-28 20:24:29 +00:00
|
|
|
method.append(methodLabel);
|
|
|
|
method.append(methodSelect);
|
|
|
|
provExisting.append(method);
|
|
|
|
|
|
|
|
// Create boot type drop down
|
|
|
|
var type = $('<div></div>');
|
|
|
|
var typeLabel = $('<label for="type">Boot type:</label>');
|
|
|
|
var typeSelect = $('<select id="bootType" name="bootType"></select>');
|
2010-09-24 02:27:04 +00:00
|
|
|
typeSelect.append('<option value="pxe">pxe</option>'
|
|
|
|
+ '<option value="iscsiboot">yaboot</option>'
|
|
|
|
+ '<option value="zvm">zvm</option>'
|
|
|
|
);
|
2010-07-28 20:24:29 +00:00
|
|
|
type.append(typeLabel);
|
|
|
|
type.append(typeSelect);
|
|
|
|
provExisting.append(type);
|
|
|
|
|
|
|
|
// Create operating system input
|
|
|
|
var os = $('<div></div>');
|
|
|
|
var osLabel = $('<label for="os">Operating system:</label>');
|
|
|
|
var osInput = $('<input type="text" name="os"/>');
|
|
|
|
osInput.one('focus', function() {
|
2010-11-22 16:18:55 +00:00
|
|
|
var tmp = $.cookie('osvers');
|
2010-07-28 20:24:29 +00:00
|
|
|
if (tmp) {
|
|
|
|
// Turn on auto complete
|
2011-01-14 15:16:44 +00:00
|
|
|
$(this).autocomplete({
|
|
|
|
source: tmp.split(',')
|
|
|
|
});
|
2010-07-28 20:24:29 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
os.append(osLabel);
|
|
|
|
os.append(osInput);
|
|
|
|
provExisting.append(os);
|
|
|
|
|
|
|
|
// Create architecture input
|
|
|
|
var arch = $('<div></div>');
|
|
|
|
var archLabel = $('<label for="arch">Architecture:</label>');
|
|
|
|
var archInput = $('<input type="text" name="arch"/>');
|
|
|
|
archInput.one('focus', function() {
|
2010-11-22 16:18:55 +00:00
|
|
|
var tmp = $.cookie('osarchs');
|
2010-07-28 20:24:29 +00:00
|
|
|
if (tmp) {
|
|
|
|
// Turn on auto complete
|
2011-01-14 15:16:44 +00:00
|
|
|
$(this).autocomplete({
|
|
|
|
source: tmp.split(',')
|
|
|
|
});
|
2010-07-28 20:24:29 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
arch.append(archLabel);
|
|
|
|
arch.append(archInput);
|
|
|
|
provExisting.append(arch);
|
|
|
|
|
|
|
|
// Create profile input
|
|
|
|
var profile = $('<div></div>');
|
|
|
|
var profileLabel = $('<label for="profile">Profile:</label>');
|
|
|
|
var profileInput = $('<input type="text" name="profile"/>');
|
|
|
|
profileInput.one('focus', function() {
|
2010-11-22 16:18:55 +00:00
|
|
|
var tmp = $.cookie('profiles');
|
2010-07-28 20:24:29 +00:00
|
|
|
if (tmp) {
|
|
|
|
// Turn on auto complete
|
2011-01-14 15:16:44 +00:00
|
|
|
$(this).autocomplete({
|
|
|
|
source: tmp.split(',')
|
|
|
|
});
|
2010-07-28 20:24:29 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
profile.append(profileLabel);
|
|
|
|
profile.append(profileInput);
|
|
|
|
provExisting.append(profile);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provision existing
|
|
|
|
*/
|
|
|
|
var provisionBtn = createButton('Provision');
|
|
|
|
provisionBtn.bind('click', function(event) {
|
|
|
|
// TODO Insert provision code here
|
2012-03-14 19:23:51 +00:00
|
|
|
openDialog('info', 'Not yet supported');
|
2010-07-28 20:24:29 +00:00
|
|
|
});
|
|
|
|
provExisting.append(provisionBtn);
|
|
|
|
|
|
|
|
return provExisting;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create provision new node division
|
|
|
|
*
|
|
|
|
* @param inst
|
|
|
|
* Provision tab instance
|
|
|
|
* @return Provision new node division
|
|
|
|
*/
|
|
|
|
function createProvisionNew(plugin, inst) {
|
|
|
|
// Create provision new node division
|
|
|
|
var provNew = $('<div></div>');
|
|
|
|
|
|
|
|
// Create node input
|
|
|
|
var nodeName = $('<div><label for="nodeName">Node:</label><input type="text" name="nodeName"/></div>');
|
|
|
|
provNew.append(nodeName);
|
|
|
|
|
|
|
|
// Create group input
|
|
|
|
var group = $('<div></div>');
|
|
|
|
var groupLabel = $('<label for="group">Group:</label>');
|
|
|
|
var groupInput = $('<input type="text" name="group"/>');
|
|
|
|
groupInput.one('focus', function() {
|
2010-11-22 16:18:55 +00:00
|
|
|
var groupNames = $.cookie('groups');
|
2010-07-28 20:24:29 +00:00
|
|
|
if (groupNames) {
|
|
|
|
// Turn on auto complete
|
2011-01-14 15:16:44 +00:00
|
|
|
$(this).autocomplete({
|
|
|
|
source: groupNames.split(',')
|
|
|
|
});
|
2010-07-28 20:24:29 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
group.append(groupLabel);
|
|
|
|
group.append(groupInput);
|
|
|
|
provNew.append(group);
|
|
|
|
|
|
|
|
// Create boot method drop down
|
|
|
|
var method = $('<div></div>');
|
|
|
|
var methodLabel = $('<label for="method">Boot method:</label>');
|
|
|
|
var methodSelect = $('<select id="bootMethod" name="bootMethod"></select>');
|
2010-09-24 02:27:04 +00:00
|
|
|
methodSelect.append('<option value="boot">boot</option>'
|
|
|
|
+ '<option value="install">install</option>'
|
|
|
|
+ '<option value="iscsiboot">iscsiboot</option>'
|
|
|
|
+ '<option value="netboot">netboot</option>'
|
|
|
|
+ '<option value="statelite">statelite</option>'
|
|
|
|
);
|
2010-07-28 20:24:29 +00:00
|
|
|
method.append(methodLabel);
|
|
|
|
method.append(methodSelect);
|
|
|
|
provNew.append(method);
|
|
|
|
|
|
|
|
// Create boot type drop down
|
|
|
|
var type = $('<div></div>');
|
|
|
|
var typeLabel = $('<label for="type">Boot type:</label>');
|
|
|
|
var typeSelect = $('<select id="bootType" name="bootType"></select>');
|
2010-09-24 02:27:04 +00:00
|
|
|
typeSelect.append('<option value="install">pxe</option>'
|
|
|
|
+ '<option value="iscsiboot">yaboot</option>'
|
|
|
|
+ '<option value="zvm">zvm</option>'
|
|
|
|
);
|
2010-07-28 20:24:29 +00:00
|
|
|
type.append(typeLabel);
|
|
|
|
type.append(typeSelect);
|
|
|
|
provNew.append(type);
|
|
|
|
|
|
|
|
// Create operating system input
|
|
|
|
var os = $('<div></div>');
|
|
|
|
var osLabel = $('<label for="os">Operating system:</label>');
|
|
|
|
var osInput = $('<input type="text" name="os"/>');
|
|
|
|
osInput.one('focus', function() {
|
2010-11-22 16:18:55 +00:00
|
|
|
var tmp = $.cookie('osvers');
|
2010-07-28 20:24:29 +00:00
|
|
|
if (tmp) {
|
|
|
|
// Turn on auto complete
|
2011-01-14 15:16:44 +00:00
|
|
|
$(this).autocomplete({
|
|
|
|
source: tmp.split(',')
|
|
|
|
});
|
2010-07-28 20:24:29 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
os.append(osLabel);
|
|
|
|
os.append(osInput);
|
|
|
|
provNew.append(os);
|
|
|
|
|
|
|
|
// Create architecture input
|
|
|
|
var arch = $('<div></div>');
|
|
|
|
var archLabel = $('<label for="arch">Architecture:</label>');
|
|
|
|
var archInput = $('<input type="text" name="arch"/>');
|
|
|
|
archInput.one('focus', function() {
|
2010-11-22 16:18:55 +00:00
|
|
|
var tmp = $.cookie('osarchs');
|
2010-07-28 20:24:29 +00:00
|
|
|
if (tmp) {
|
|
|
|
// Turn on auto complete
|
2011-01-14 15:16:44 +00:00
|
|
|
$(this).autocomplete({
|
|
|
|
source: tmp.split(',')
|
|
|
|
});
|
2010-07-28 20:24:29 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
arch.append(archLabel);
|
|
|
|
arch.append(archInput);
|
|
|
|
provNew.append(arch);
|
|
|
|
|
|
|
|
// Create profile input
|
|
|
|
var profile = $('<div></div>');
|
|
|
|
var profileLabel = $('<label for="profile">Profile:</label>');
|
|
|
|
var profileInput = $('<input type="text" name="profile"/>');
|
|
|
|
profileInput.one('focus', function() {
|
2010-11-22 16:18:55 +00:00
|
|
|
var tmp = $.cookie('profiles');
|
2010-07-28 20:24:29 +00:00
|
|
|
if (tmp) {
|
|
|
|
// Turn on auto complete
|
2011-01-14 15:16:44 +00:00
|
|
|
$(this).autocomplete({
|
|
|
|
source: tmp.split(',')
|
|
|
|
});
|
2010-07-28 20:24:29 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
profile.append(profileLabel);
|
|
|
|
profile.append(profileInput);
|
|
|
|
provNew.append(profile);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provision new node
|
|
|
|
*/
|
|
|
|
var provisionBtn = createButton('Provision');
|
|
|
|
provisionBtn.bind('click', function(event) {
|
|
|
|
// TODO Insert provision code here
|
2012-03-14 19:23:51 +00:00
|
|
|
openDialog('info', 'Not yet supported');
|
2010-07-28 20:24:29 +00:00
|
|
|
});
|
|
|
|
provNew.append(provisionBtn);
|
|
|
|
|
|
|
|
return provNew;
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
|
|
|
|
2011-09-12 19:47:26 +00:00
|
|
|
/**
|
2012-03-15 05:11:58 +00:00
|
|
|
* Create section to provision node
|
2011-09-12 19:47:26 +00:00
|
|
|
*
|
|
|
|
* @param plugin
|
2012-03-15 05:11:58 +00:00
|
|
|
* Plugin name
|
2011-09-12 19:47:26 +00:00
|
|
|
* @param container
|
2012-03-15 05:11:58 +00:00
|
|
|
* Container to hold provision section
|
2011-09-12 19:47:26 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-03-15 05:11:58 +00:00
|
|
|
function appendProvisionSection(plugin, container) {
|
|
|
|
// Get provision tab ID
|
|
|
|
var tabId = container.parents('.tab').attr('id');
|
|
|
|
|
|
|
|
if (plugin == 'quick')
|
|
|
|
appendProvision4Url(container); // For provisioning based on argmunents found in URL
|
|
|
|
else
|
|
|
|
appendProvision4NoUrl(plugin, container);
|
|
|
|
|
2011-09-12 19:47:26 +00:00
|
|
|
// Add provision button
|
2011-08-24 10:30:30 +00:00
|
|
|
var provisionBtn = createButton('Provision');
|
|
|
|
provisionBtn.bind('click', function(){
|
2012-03-15 05:11:58 +00:00
|
|
|
provisionNode(tabId);
|
2011-08-24 10:30:30 +00:00
|
|
|
});
|
|
|
|
container.append(provisionBtn);
|
|
|
|
|
2011-09-12 19:47:26 +00:00
|
|
|
// Bind image select to change event
|
2012-03-15 05:11:58 +00:00
|
|
|
container.find('select[name=image]').bind('change', function() {
|
|
|
|
createAdvancedOptions($(this).val(), tabId);
|
2011-08-24 10:30:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'lsdef',
|
|
|
|
tgt : '',
|
|
|
|
args : '-t;osimage',
|
2012-03-15 05:11:58 +00:00
|
|
|
msg : tabId
|
2011-08-24 10:30:30 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
success : function(data){
|
2012-03-15 05:11:58 +00:00
|
|
|
var tabId = data.msg;
|
2011-09-12 19:47:26 +00:00
|
|
|
var i = 0;
|
|
|
|
var imageName = 0;
|
2011-08-24 10:30:30 +00:00
|
|
|
var position = 0;
|
2011-09-12 19:47:26 +00:00
|
|
|
if (!data.rsp.length) {
|
2012-03-15 05:11:58 +00:00
|
|
|
$('#' + tabId).prepend(createWarnBar('Please run copycds and genimage in provision page before continuing!'));
|
2011-08-24 10:30:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-09-12 19:47:26 +00:00
|
|
|
for (i in data.rsp) {
|
|
|
|
imageName = data.rsp[i];
|
|
|
|
position = imageName.indexOf(' ');
|
|
|
|
imageName = imageName.substr(0, position);
|
2011-08-24 10:30:30 +00:00
|
|
|
|
2012-03-15 05:11:58 +00:00
|
|
|
$('#' + tabId + ' select[name=image]').append($('<option value="' + imageName + '">' + imageName + '</option>'));
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
2011-09-12 19:47:26 +00:00
|
|
|
|
|
|
|
// Trigger select change event
|
2012-03-15 05:11:58 +00:00
|
|
|
$('#' + tabId + ' select[name=image]').trigger('change');
|
2011-09-12 19:47:26 +00:00
|
|
|
// Show provision button
|
2012-03-15 05:11:58 +00:00
|
|
|
$('#' + tabId + ' button').show();
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-09-12 19:47:26 +00:00
|
|
|
/**
|
2012-03-15 05:11:58 +00:00
|
|
|
* Create provision node section using URL
|
2011-09-12 19:47:26 +00:00
|
|
|
*
|
2012-03-15 05:11:58 +00:00
|
|
|
* @param container
|
|
|
|
* Container to hold provision section
|
|
|
|
* @returns Nothing
|
2011-09-12 19:47:26 +00:00
|
|
|
*/
|
2012-03-15 05:11:58 +00:00
|
|
|
function appendProvision4Url(container){
|
2012-03-15 13:38:33 +00:00
|
|
|
// Get provision tab ID
|
|
|
|
var tabId = container.parents('.tab').attr('id');
|
|
|
|
|
|
|
|
// Create node fieldset
|
|
|
|
var nodeFS = $('<fieldset></fieldset>');
|
|
|
|
var nodeLegend = $('<legend>Node</legend>');
|
|
|
|
nodeFS.append(nodeLegend);
|
|
|
|
container.append(nodeFS);
|
|
|
|
|
|
|
|
var nodeAttr = $('<div style="display: inline-table; vertical-align: middle; width: 85%; margin-left: 10px;"></div>');
|
|
|
|
nodeFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/computer.png"></img></div>'));
|
|
|
|
nodeFS.append(nodeAttr);
|
|
|
|
|
|
|
|
// Create image fieldset
|
|
|
|
var imgFS = $('<fieldset></fieldset>');
|
|
|
|
var imgLegend = $('<legend>Image</legend>');
|
|
|
|
imgFS.append(imgLegend);
|
|
|
|
container.append(imgFS);
|
|
|
|
|
|
|
|
var imgAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
|
|
|
imgFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/operating_system.png"></img></div>'));
|
|
|
|
imgFS.append(imgAttr);
|
|
|
|
|
2012-03-15 05:11:58 +00:00
|
|
|
var query = window.location.search;
|
|
|
|
var args = query.substr(1).split('&');
|
|
|
|
var parms = new Object();
|
|
|
|
var tmp;
|
|
|
|
|
|
|
|
// Turn URL arguments into hash array
|
|
|
|
for (var i = 0; i < args.length; i++) {
|
|
|
|
tmp = args[i].split('=');
|
|
|
|
parms[tmp[0]] = tmp[1];
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
|
|
|
|
2012-03-15 05:11:58 +00:00
|
|
|
var master = '';
|
|
|
|
if (parms['master'])
|
|
|
|
master = parms['master'];
|
2011-09-02 07:48:30 +00:00
|
|
|
|
2012-03-15 05:11:58 +00:00
|
|
|
var nfsserver = '';
|
|
|
|
if (parms['nfsserver'])
|
|
|
|
nfsserver = parms['nfsserver'];
|
2011-09-12 19:47:26 +00:00
|
|
|
|
2012-03-15 05:11:58 +00:00
|
|
|
var tftpserver = '';
|
|
|
|
if (parms['tftpserver'])
|
|
|
|
tftpserver = parms['tftpserver'];
|
|
|
|
|
2012-03-15 13:38:33 +00:00
|
|
|
nodeAttr.append('<div><label>Node:</label><input type="text" disabled="disabled" name="node" value="' + parms['nodes'] + '"></div>');
|
|
|
|
|
|
|
|
imgAttr.append('<div><label>Architecture:</label><input type="text" disabled="disabled" name="arch" value="' + parms['arch'] + '"></div>');
|
|
|
|
imgAttr.append('<div><label>Image name:</label><select name="image"></select></div>');
|
|
|
|
imgAttr.append( '<div><label>Install NIC:</label><input type="text" name="installNic"/></div>');
|
|
|
|
imgAttr.append('<div><label>Primary NIC:</label><input type="text" name="primaryNic"/></div>');
|
|
|
|
imgAttr.append('<div><label>xCAT master:</label><input type="text" name="xcatMaster" value="' + master + '"></div>');
|
|
|
|
imgAttr.append('<div><label>TFTP server:</label><input type="text" name="tftpServer" value="' + tftpserver + '"></div>');
|
|
|
|
imgAttr.append('<div><label>NFS server:</label><input type="text" name="nfsServer" value="' + nfsserver + '"></div>');
|
2012-03-15 05:11:58 +00:00
|
|
|
|
|
|
|
return;
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
|
|
|
|
2011-09-12 19:47:26 +00:00
|
|
|
/**
|
2012-03-15 05:11:58 +00:00
|
|
|
* Create section to provision node using no URL
|
2011-09-12 19:47:26 +00:00
|
|
|
*
|
|
|
|
* @param plugin
|
2012-03-15 05:11:58 +00:00
|
|
|
* Create provision section for given plugin
|
|
|
|
* @param container
|
|
|
|
* Container to hold provision section
|
|
|
|
* @returns Nothing
|
2011-09-12 19:47:26 +00:00
|
|
|
*/
|
2012-03-15 05:11:58 +00:00
|
|
|
function appendProvision4NoUrl(plugin, container){
|
|
|
|
// Get provision tab ID
|
|
|
|
var tabId = container.parents('.tab').attr('id');
|
|
|
|
|
|
|
|
// Create node fieldset
|
|
|
|
var nodeFS = $('<fieldset></fieldset>');
|
|
|
|
var nodeLegend = $('<legend>Node</legend>');
|
|
|
|
nodeFS.append(nodeLegend);
|
|
|
|
container.append(nodeFS);
|
|
|
|
|
|
|
|
var nodeAttr = $('<div style="display: inline-table; vertical-align: middle; width: 85%; margin-left: 10px;"></div>');
|
|
|
|
nodeFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/computer.png"></img></div>'));
|
|
|
|
nodeFS.append(nodeAttr);
|
|
|
|
|
|
|
|
// Create image fieldset
|
|
|
|
var imgFS = $('<fieldset></fieldset>');
|
|
|
|
var imgLegend = $('<legend>Image</legend>');
|
|
|
|
imgFS.append(imgLegend);
|
|
|
|
container.append(imgFS);
|
|
|
|
|
|
|
|
var imgAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
|
|
|
imgFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/operating_system.png"></img></div>'));
|
|
|
|
imgFS.append(imgAttr);
|
|
|
|
|
|
|
|
// Select group name
|
|
|
|
var group = $('<div></div>').append('<label>Group:</label>');
|
|
|
|
var groupSelect = $('<select name="group"></select>');
|
|
|
|
group.append(groupSelect);
|
2011-08-24 10:30:30 +00:00
|
|
|
var groupNames = $.cookie('groups');
|
|
|
|
if (groupNames) {
|
2012-03-15 05:11:58 +00:00
|
|
|
var tmp = groupNames.split(',');
|
|
|
|
groupSelect.append('<option value=""></option>'); // Append empty group name
|
|
|
|
for (var i in tmp)
|
|
|
|
groupSelect.append('<option value="' + tmp[i] + '">' + tmp[i] + '</option>');
|
|
|
|
}
|
|
|
|
nodeAttr.append(group);
|
|
|
|
|
|
|
|
// Select node from table
|
|
|
|
var nodes = $('<div><label style="vertical-align: top;">Nodes:</label></div>');
|
|
|
|
var nodesTable = $('<div id="nodesTable" style="display: inline-block; max-width: 800px;"><p>Select a group to view its nodes</p></div>');
|
|
|
|
nodes.append(nodesTable);
|
|
|
|
nodeAttr.append(nodes);
|
|
|
|
|
2011-09-12 19:47:26 +00:00
|
|
|
// Select architecture
|
2012-03-15 05:11:58 +00:00
|
|
|
var arch = $('<div></div>').append('<label>Architecture:</label>');
|
2011-08-24 10:30:30 +00:00
|
|
|
var archName = $.cookie('osarchs');
|
2011-09-12 19:47:26 +00:00
|
|
|
if (archName) {
|
2012-03-15 05:11:58 +00:00
|
|
|
var archSelect = $('<select name="arch"></select>');
|
|
|
|
arch.append(archSelect);
|
|
|
|
|
|
|
|
var tmp = archName.split(',');
|
|
|
|
for (var i in tmp)
|
|
|
|
archSelect.append('<option value="' + tmp[i] + '">' + tmp[i] + '</option>');
|
2011-08-24 10:30:30 +00:00
|
|
|
} else {
|
2012-03-15 05:11:58 +00:00
|
|
|
arch.append('<input type="text" name="arch"/>');
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
2012-03-15 05:11:58 +00:00
|
|
|
imgAttr.append(arch);
|
|
|
|
|
|
|
|
imgAttr.append('<div><label>Image name:</label><select name="image"></select></div>');
|
|
|
|
imgAttr.append('<div><label>Install NIC:</label><input type="text" name="installNic"/></div>');
|
|
|
|
imgAttr.append('<div><label>Primary NIC:</label><input type="text" name="primaryNic"/></div>');
|
|
|
|
imgAttr.append('<div><label>xCAT master:</label><input type="text" name="xcatMaster"/></div>');
|
|
|
|
imgAttr.append('<div><label>TFTP server:</label><input type="text" name="tftpServer"/></div>');
|
|
|
|
imgAttr.append('<div><label>NFS server:</label><input type="text" name=nfsServer"/></div>');
|
|
|
|
|
|
|
|
// When a group is selected, show the nodes belonging to that group
|
|
|
|
groupSelect.bind('change', function() {
|
|
|
|
var nodesTableId = '#' + tabId + ' #nodesTable';
|
|
|
|
$(nodesTableId).append(createLoader());
|
|
|
|
createNodesTable($(this).val(), nodesTableId);
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-03-15 05:11:58 +00:00
|
|
|
* Provision node
|
2011-08-24 10:30:30 +00:00
|
|
|
*
|
2012-03-15 05:11:58 +00:00
|
|
|
* @param tabId
|
|
|
|
* Provision tab ID
|
2011-08-24 10:30:30 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-03-15 05:11:58 +00:00
|
|
|
function provisionNode(tabId) {
|
|
|
|
var plugin = tabId;
|
|
|
|
var errorMessage = "";
|
|
|
|
var args = new Array();
|
|
|
|
var node = "";
|
|
|
|
|
|
|
|
// Delete any existing warnings
|
|
|
|
$('#' + tabId + ' .ui-state-error').remove();
|
|
|
|
|
|
|
|
// Go through each input
|
|
|
|
$('#' + tabId + ' input[type!="checkbox"]').each(function() {
|
2011-09-12 19:47:26 +00:00
|
|
|
if (!$(this).val()) {
|
2011-12-01 04:10:40 +00:00
|
|
|
errorMessage = 'Please provide a value for each missing field!';
|
2011-08-24 10:30:30 +00:00
|
|
|
return false;
|
2011-09-12 19:47:26 +00:00
|
|
|
} else {
|
2012-03-15 05:11:58 +00:00
|
|
|
args.push($(this).val());
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-03-15 05:11:58 +00:00
|
|
|
// Do not continue if error was found
|
2011-09-12 19:47:26 +00:00
|
|
|
if (errorMessage) {
|
2012-03-15 05:11:58 +00:00
|
|
|
$('#' + tabId).prepend(createWarnBar(errorMessage));
|
2011-08-24 10:30:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-15 05:11:58 +00:00
|
|
|
// If jumped from nodes page, get node name
|
|
|
|
if (tabId == 'quick') {
|
|
|
|
node = args.shift();
|
|
|
|
} else {
|
|
|
|
// Select platform, get node names from table checkbox
|
|
|
|
args.unshift($('#' + tabId + ' input[name=arch]').val());
|
|
|
|
node = getCheckedByObj($('#' + tabId + ' #nodesTable'));
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
|
|
|
|
2012-03-15 05:11:58 +00:00
|
|
|
// Do not continue if a node is not given
|
|
|
|
if (!node) {
|
|
|
|
$('#' + tabId).prepend(createWarnBar('Please select a node!'));
|
2011-08-24 10:30:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-15 05:11:58 +00:00
|
|
|
var software = getCheckedByObj($('#' + tabId + ' #advanced'));
|
|
|
|
var imageName = $('#' + tabId + ' select[name=image]').val();
|
|
|
|
var provision = args.join(',');
|
|
|
|
|
|
|
|
var url = 'lib/cmd.php?cmd=webrun&tgt=&args=provision;' +
|
|
|
|
node + ';' + imageName + ';' + provision + ';' + software + '&msg=&opts=flush';
|
|
|
|
$('#' + tabId).prepend(createIFrame(url));
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
|
|
|
|
2011-09-12 19:47:26 +00:00
|
|
|
/**
|
2012-03-15 05:11:58 +00:00
|
|
|
* Create advance option
|
2011-09-12 19:47:26 +00:00
|
|
|
*
|
|
|
|
* @param imagename
|
|
|
|
* Image name
|
2012-03-15 05:11:58 +00:00
|
|
|
* @param outId
|
|
|
|
* Output area ID
|
2011-09-12 19:47:26 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-03-15 05:11:58 +00:00
|
|
|
function createAdvancedOptions(image, outId) {
|
2011-08-24 10:30:30 +00:00
|
|
|
$.ajax({
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'lsdef',
|
|
|
|
tgt : '',
|
2012-03-15 05:11:58 +00:00
|
|
|
args : '-t;osimage;' + image + ';-i;osname,provmethod',
|
|
|
|
msg : outId
|
2011-08-24 10:30:30 +00:00
|
|
|
},
|
|
|
|
|
2011-09-12 19:47:26 +00:00
|
|
|
success : function(data) {
|
2012-03-15 05:11:58 +00:00
|
|
|
var outId = data.msg;
|
2011-09-12 19:47:26 +00:00
|
|
|
var osName = '';
|
|
|
|
var provMethod = '';
|
2012-03-15 05:11:58 +00:00
|
|
|
var tmpStr = '';
|
2011-08-24 10:30:30 +00:00
|
|
|
var position = 0;
|
2012-03-15 05:11:58 +00:00
|
|
|
|
|
|
|
for (var i = 0; i < data.rsp.length; i++) {
|
|
|
|
tmpStr = data.rsp[i];
|
|
|
|
if (tmpStr.indexOf('osname') != -1) {
|
|
|
|
position = tmpStr.indexOf('=');
|
|
|
|
osName = tmpStr.substr(position + 1);
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
2011-09-12 19:47:26 +00:00
|
|
|
|
2012-03-15 05:11:58 +00:00
|
|
|
if (tmpStr.indexOf('provmethod') != -1) {
|
|
|
|
position = tmpStr.indexOf('=');
|
|
|
|
provMethod = tmpStr.substr(position + 1);
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-15 05:11:58 +00:00
|
|
|
$('#' + outId + ' #advanced').remove();
|
|
|
|
if (osName.toLowerCase() == 'aix')
|
2011-08-24 10:30:30 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-15 05:11:58 +00:00
|
|
|
if (provMethod == 'install') {
|
|
|
|
// Create advanced fieldset
|
|
|
|
var advancedFS = $('<fieldset id="advanced"></fieldset>').append($('<legend>Advanced</legend>'));
|
|
|
|
$('#' + outId + ' div.form fieldset:eq(1)').after(advancedFS);
|
|
|
|
|
|
|
|
advancedFS.append('<div><input type="checkbox" checked="checked" name="ganglia">Install Ganglia monitoring</div>');
|
|
|
|
}
|
|
|
|
}
|
2011-08-24 10:30:30 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-03-15 05:11:58 +00:00
|
|
|
* Create nodes table
|
2011-08-24 10:30:30 +00:00
|
|
|
*
|
2012-03-15 05:11:58 +00:00
|
|
|
* @param group
|
2011-09-12 19:47:26 +00:00
|
|
|
* Group name
|
2012-03-15 05:11:58 +00:00
|
|
|
* @param outId
|
|
|
|
* Output section ID
|
2011-08-24 10:30:30 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-03-15 05:11:58 +00:00
|
|
|
function createNodesTable(group, outId) {
|
2011-08-24 10:30:30 +00:00
|
|
|
// Get group nodes
|
|
|
|
$.ajax({
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'nodels',
|
2012-03-15 05:11:58 +00:00
|
|
|
tgt : group,
|
2011-08-24 10:30:30 +00:00
|
|
|
args : '',
|
2012-03-15 05:11:58 +00:00
|
|
|
msg : outId
|
2011-08-24 10:30:30 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
success : function(data) {
|
2012-03-15 05:11:58 +00:00
|
|
|
var outId = $(data.msg);
|
2011-08-24 10:30:30 +00:00
|
|
|
var nodes = data.rsp;
|
2012-03-15 05:11:58 +00:00
|
|
|
|
|
|
|
// Create table to hold nodes
|
|
|
|
var nTable = $('<table></table>');
|
2012-03-15 13:38:33 +00:00
|
|
|
var tHead = $('<thead class="ui-widget-header"> <th><input type="checkbox" onclick="selectAll4Table(event, $(this))"></th> <th>Node</th> </thead>');
|
2012-03-15 05:11:58 +00:00
|
|
|
nTable.append(tHead);
|
|
|
|
var tBody = $('<tbody></tbody>');
|
|
|
|
nTable.append(tBody);
|
|
|
|
|
|
|
|
for (var i in nodes) {
|
|
|
|
var node = nodes[i][0];
|
|
|
|
|
|
|
|
// Go to next node if there is nothing here
|
|
|
|
if (!node)
|
2011-08-24 10:30:30 +00:00
|
|
|
continue;
|
2012-03-15 05:11:58 +00:00
|
|
|
// Insert node into table
|
|
|
|
tBody.append('<tr><td><input type="checkbox" name="' + node + '"/></td><td>' + node + '</td></tr>');
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
2011-09-12 19:47:26 +00:00
|
|
|
|
2012-03-15 05:11:58 +00:00
|
|
|
outId.empty().append(nTable);
|
|
|
|
|
2012-03-15 13:38:33 +00:00
|
|
|
if (nodes.length > 10)
|
2012-03-15 05:11:58 +00:00
|
|
|
outId.css('height', '300px');
|
|
|
|
else
|
|
|
|
outId.css('height', 'auto');
|
|
|
|
}
|
2011-08-24 10:30:30 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-09-12 19:47:26 +00:00
|
|
|
* Get select element names
|
2011-08-24 10:30:30 +00:00
|
|
|
*
|
2011-09-12 19:47:26 +00:00
|
|
|
* @param obj
|
|
|
|
* Object to get selected element names
|
|
|
|
* @return Nodes name seperate by a comma
|
2011-08-24 10:30:30 +00:00
|
|
|
*/
|
|
|
|
function getCheckedByObj(obj) {
|
2011-09-12 19:47:26 +00:00
|
|
|
var str = '';
|
|
|
|
|
2011-08-24 10:30:30 +00:00
|
|
|
// Get nodes that were checked
|
|
|
|
obj.find('input:checked').each(function() {
|
|
|
|
if ($(this).attr('name')) {
|
2011-09-12 19:47:26 +00:00
|
|
|
str += $(this).attr('name') + ',';
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-09-12 19:47:26 +00:00
|
|
|
if (str) {
|
|
|
|
str = str.substr(0, str.length - 1);
|
2011-08-24 10:30:30 +00:00
|
|
|
}
|
|
|
|
|
2011-09-12 19:47:26 +00:00
|
|
|
return str;
|
2012-03-15 13:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Select all checkboxes in the table
|
|
|
|
*
|
|
|
|
* @param event
|
|
|
|
* Event on element
|
|
|
|
* @param obj
|
|
|
|
* Object triggering event
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function selectAll4Table(event, obj) {
|
|
|
|
// Get datatable ID
|
|
|
|
// This will ascend from <input> <td> <tr> <thead> <table>
|
|
|
|
var tableObj = obj.parents('table').find('tbody');
|
|
|
|
var status = obj.attr('checked');
|
|
|
|
tableObj.find(' :checkbox').attr('checked', status);
|
|
|
|
event.stopPropagation();
|
2010-07-28 20:24:29 +00:00
|
|
|
}
|