Fixed add node dialogs. Added change password option under Settings. Cleaned up code.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11844 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
phamt 2012-03-14 04:32:06 +00:00
parent 8805c4c1f1
commit 9df72493d4
13 changed files with 829 additions and 635 deletions

View File

@ -544,7 +544,7 @@ legend {
.form label {
color: #424242;
line-height: 1.5;
vertical-align: top;
vertical-align: middle;
width: 120px;
padding: 0px 0px 0px 20px;
display: inline-block;

View File

@ -2,7 +2,7 @@
* Execute when the DOM is fully loaded
*/
$(document).ready(function() {
// Load utility scripts
// Load utility scripts (if any)
});
/**
@ -66,7 +66,6 @@ bladePlugin.prototype.loadInventory = function(data) {
$('#' + tabId).find('img').remove();
// Create division to hold inventory
var invDivId = tabId + 'Inventory';
var invDiv = $('<div></div>');
// Create a fieldset
@ -199,8 +198,6 @@ bladePlugin.prototype.loadResources = function() {
/**
* Add node range
*
* @return Nothing
*/
bladePlugin.prototype.addNode = function() {
var addNodeForm = $('<div id="addBladeCenter" class="form"></div>');
@ -212,60 +209,61 @@ bladePlugin.prototype.addNode = function() {
typeFS.append(typeLegend);
addNodeForm.append(typeFS);
var nodeFS = $('<fieldset id="nodeAttrs"></fieldset>');
var nodeLegend = $('<legend>Node</legend>');
nodeFS.append(nodeLegend);
addNodeForm.append(nodeFS);
var settingsFS = $('<fieldset id="bcSettings"></fieldset>');
var nodeLegend = $('<legend>Settings</legend>');
settingsFS.append(nodeLegend);
addNodeForm.append(settingsFS);
typeFS.append('<div>' +
'<label>Node type:</label>' +
'<select id="typeSelect">' +
'<option value="mm">AMM</option>' +
'<option value="amm">AMM</option>' +
'<option value="blade">Blade</option>' +
'<option value="scanmm">Blade by scan</option>' +
'<option value="scan">Blade by scan</option>' +
'</select>' +
'</div>');
// Change dialog width
$('#addBladeCenter').dialog('option', 'width', '400');
typeFS.find('#typeSelect').bind('change', function(){
// Remove any existing warnings
$('#addBladeCenter .ui-state-error').remove();
nodeFS.find('div').remove();
settingsFS.find('div').remove();
var addMethod = $(this).val();
switch(addMethod){
case 'mm':
nodeFS.append('<div><label>AMM name: </label><input id="ammName" type="text"/></div>');
nodeFS.append('<div><label>Username: </label><input type="text"></div>');
nodeFS.append('<div><label>Password: </label><input type="text"></div>');
nodeFS.append('<div><label>AMM IP: </label><input id="ammIp" type="text"/></div>');
// Change dialog width
$('#addBladeCenter').dialog('option', 'width', '400');
var nodeType = $(this).val();
switch (nodeType) {
case 'amm':
settingsFS.append('<div><label>AMM name:</label><input name="ammName" type="text"/></div>');
settingsFS.append('<div><label>User name:</label><input name="ammUser" type="text"></div>');
settingsFS.append('<div><label>Password:</label><input name="ammPassword" type="password"></div>');
settingsFS.append('<div><label>IP address:</label><input id="ammIp" type="text"/></div>');
break;
case 'blade':
nodeFS.append('<div><label>Blade name: </label><input id="bladeName" type="text"/></input></div>');
nodeFS.append('<div><label>Blade group: </label><input id="bladeGroup" type="text"/></input></div>');
nodeFS.append('<div><label>Blade ID: </label><input id="bladeId" type="text"/t></div>');
nodeFS.append('<div><label>Blade series: </label>JS <input type="radio" name="series" value="js"/> LS<input type="radio" name="series" value="ls"/></div>');
nodeFS.append('<div><label style="vertical-align: middle;">Blade MPA: </label><select id="mpaSelect"></select><div>');
settingsFS.append('<div><label>Blade name:</label><input name="bladeName" type="text"/></input></div>');
settingsFS.append('<div><label>Blade group:</label><input name="bladeGroup" type="text"/></input></div>');
settingsFS.append('<div><label>Blade ID:</label><input name="bladeId" type="text"/t></div>');
settingsFS.append('<div><label>Blade series:</label>JS <input type="radio" name="bladeSeries" value="js"/> LS<input type="radio" name="bladeSeries" value="ls"/></div>');
settingsFS.append('<div><label style="vertical-align: middle;">Blade MPA:</label><select name="bladeMpa"></select><div>');
break;
case 'scanmm':
nodeFS.append('<div><label style="vertical-align: middle;">Blade MPA: </label><select id="mpaSelect"></select></div>');
case 'scan':
settingsFS.append('<div><label style="vertical-align: middle;">Blade MPA:</label><select id="bladeMpa"></select></div>');
// Change dialog width
$('#addBladeCenter').dialog('option', 'width', '650');
break;
}
// Change dialog width
if ($(this).val() == 'scanmm'){
$('#addBladeCenter').dialog('option', 'width', '650');
}else{
$('#addBladeCenter').dialog('option', 'width', '400');
}
// If MM node, return directly
if ($(this).val() == 'mm'){
// Do not continue if node type is AMM
if ($(this).val() == 'amm') {
return;
}
// Get all MM nodes from server side
nodeFS.find('select:eq(0)').after(createLoader());
// Gather AMM nodes
settingsFS.find('select:eq(0)').after(createLoader());
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
@ -273,64 +271,70 @@ bladePlugin.prototype.addNode = function() {
cmd : 'lsdef',
tgt : '',
args : '-t;node;-w;mgt==blade;-w;id==0',
msg : addMethod
msg : nodeType
},
success : function(data){
success : function(data) {
var position = 0;
var tempStr = '';
var tmp = '';
var options = '';
// Remove the loading image
nodeFS.find('img').remove();
settingsFS.find('img').remove();
// Check return result
// Do not continue if no AMM nodes are found
if (data.rsp.length < 1) {
$('#addBladeCenter').prepend(createWarnBar('Please define MM node first!'));
$('#addBladeCenter').prepend(createWarnBar('Please define an AMM node before continuing'));
return;
}
// Add all MM nodes to select
// Create options for AMM nodes
for (var i in data.rsp){
tempStr = data.rsp[i];
position = tempStr.indexOf(' ');
tempStr = tempStr.substring(0, position);
options += '<option value="' + tempStr + '">' + tempStr + '</option>';
tmp = data.rsp[i];
position = tmp.indexOf(' ');
tmp = tmp.substring(0, position);
options += '<option value="' + tmp + '">' + tmp + '</option>';
}
nodeFS.find('select:eq(0)').append(options);
// If adding node by rscan, we should add the scan button
if (data.msg != 'scanmm') {
// Select the first AMM node
settingsFS.find('select:eq(0)').append(options);
if (data.msg != 'scan') {
return;
}
// Create Scan button
var scan = createButton('Scan');
scan.bind('click', function(){
var mmName = nodeFS.find('select:eq(0)').val();
nodeFS.prepend(createLoader());
$('#nodeAttrs button').attr('disabled', 'disabled');
var ammName = settingsFS.find('select:eq(0)').val();
settingsFS.prepend(createLoader());
$('#bcSettings button').attr('disabled', 'disabled');
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'rscan',
tgt : mmName,
tgt : ammName,
args : '',
msg : ''
},
/**
* Show scanned results for AMM
*
* @param data Data returned from HTTP request
*/
success: function(data){
showScanMmResult(data.rsp[0]);
showScanAmmResult(data.rsp[0]);
}
});
});
nodeFS.find('select:eq(0)').after(scan);
settingsFS.find('select:eq(0)').after(scan);
}
});
});
addNodeForm.dialog( {
// Create dialog for BladeCenter
addNodeForm.dialog({
modal : true,
width : 400,
title : 'Add node',
@ -346,8 +350,8 @@ bladePlugin.prototype.addNode = function() {
$('#addBladeCenter .ui-state-error').remove();
var addMethod = $('#typeSelect').val();
if (addMethod == "mm") {
addMmNode();
if (addMethod == "amm") {
addAmmNode();
} else if(addMethod == "blade") {
addBladeNode();
} else{
@ -366,31 +370,30 @@ bladePlugin.prototype.addNode = function() {
/**
* Add AMM node
*
* @return Nothing
*/
function addMmNode(){
var argsTmp = '';
function addAmmNode(){
var args = '';
var errorMsg = '';
// Check for missing inputs
$('#addBladeCenter input').each(function(){
if (!$(this).val()) {
errorMsg = 'Please provide a value for each missing field.';
errorMsg = 'Please provide a value for each missing field!';
}
argsTmp += $(this).val() + ',';
args += $(this).val() + ',';
});
// Do not continue if error was found
if (errorMsg) {
// Add warning message
$('#addBladeCenter').prepend(createWarnBar(errorMsg));
return;
}
argsTmp = argsTmp.substring(0, argsTmp.length - 1);
args = args.substring(0, args.length - 1);
// Add the loader
$('#addBladeCenter').prepend(createLoader());
$('#addBladeCenter').append(createLoader());
$('.ui-dialog-buttonpane .ui-button').attr('disabled', true);
$.ajax( {
url : 'lib/cmd.php',
@ -398,17 +401,16 @@ function addMmNode(){
data : {
cmd : 'webrun',
tgt : '',
args : 'addnode;mm;' + argsTmp,
args : 'addnode;mm;' + args,
msg : ''
},
success : function(data) {
// Remove loader
$('#addBladeCenter').find('img').remove();
var info = createInfoBar('Successfully added MM node.');
$('#addBladeCenter').prepend(info);
$('#addBladeCenter').prepend(createInfoBar('AMM node was successfully added'));
$('#addBladeCenter').dialog("option", "buttons", {
"Close" : function() {
$('#addBladeCenter').dialog('close');
$('.selectgroup').trigger('click');
}
});
}
@ -417,24 +419,29 @@ function addMmNode(){
/**
* Add blade node
*
* @return Nothing
*/
function addBladeNode(){
var name = $('#addBladeCenter #bladeName').val();
var group = $('#addBladeCenter #bladeGroup').val();
var id = $('#addBladeCenter #bladeId').val();
var series = $("#addBladeCenter #bladeNode :checked").val();
var mpa = $('#addBladeCenter #mpaSelect').val();
// Get blade node attributes
var name = $('#bcSettings input[name="bladeName"]').val();
var group = $('#bcSettings input[name="bladeGroup"]').val();
var id = $('#bcSettings input[name="bladeId"]').val();
var series = $('#bcSettings input[name="bladeSeries"]:selected').val();
var mpa = $('#bcSettings select[name="bladeMpa"]').val();
var argsTmp = '-t;node;-o;' + name + ';id=' + id +
';nodetype=osi;groups=' + group + ';mgt=blade;mpa=' + mpa + ';serialflow=hard';
var args = '-t;node;-o;' + name
+ ';id=' + id
+ ';nodetype=osi;groups=' + group
+ ';mgt=blade;mpa=' + mpa
+ ';serialflow=hard';
// Set the serial speed and port for LS series blade
if (series != 'js') {
argsTmp += ';serialspeed=19200;serialport=1';
args += ';serialspeed=19200;serialport=1';
}
if ((!name) || (!group) || (!id) || (!mpa)){
$('#addBladeCenter').prepend(createWarnBar("Please provide a value for each missing field."));
// Check for missing inputs
if (!name || !group || !id || !mpa) {
$('#addBladeCenter').prepend(createWarnBar("Please provide a value for each missing field!"));
return;
}
@ -447,18 +454,24 @@ function addBladeNode(){
data : {
cmd : 'chdef',
tgt : '',
args : argsTmp,
args : args,
msg : ''
},
success : function(data) {
// Remove loader
$('#addBladeCenter').find('img').remove();
var messages = data.rsp;
var notes = "";
for (var i = 0; i < messages.length; i++) {
notes += messages[i] + " ";
// Gather response and display it
var rsp = data.rsp;
var rspMessage = '';
for (var i = 0; i < rsp.length; i++) {
rspMessage += rsp[i] + '<br/>';
}
$('#addBladeCenter').prepend(createInfoBar(notes));
// Append response message to dialog
$('#addBladeCenter').prepend(createInfoBar(rspMessage));
// Change dialog button
$('#addBladeCenter').dialog("option", "buttons", {
"Close" : function() {
$('#addBladeCenter').remove();
@ -471,81 +484,86 @@ function addBladeNode(){
/**
* Show rscan results
*
* @param rscanResults
* @param results
* Results from rscan of blade MPA
* @return Nothing
*/
function showScanMmResult(rscanResults){
var results = $('<div style="height: 300px; overflow: auto;" id="scan_results"></div>');
var rscanTable = $('<table></table>');
var regex = /\S+/g;
var line = '';
var column = 0;
function showScanAmmResult(results){
var rSection = $('<div style="height: 300px; overflow: auto;" id="scanResults"></div>');
$('#nodeAttrs #scan_results').remove();
$('#nodeAttrs img').remove();
$('#nodeAttrs button').attr('disabled', '');
if (!rscanResults){
// Create table to hold results
var rTable = $('<table></table>');
// Reset scan results area
$('#addBladeCenter #scanResults').remove();
$('#bcSettings img').remove();
$('#bcSettings button').attr('disabled', '');
if (!results)
return;
}
var rows = rscanResults.split("\n");
// Do not continue if there are no results
var rows = results.split("\n");
if (rows.length < 2){
results.append(createWarnBar(rows[0]));
$('#nodeAttrs').append(results);
$('#bcSettings').prepend(createWarnBar(rows[0]));
return;
}
// Add the table header
var fields = rows[0].match(regex);
column = fields.length;
row = '<tr><td><input type="checkbox" onclick="selectAllRscanNode(this)"></td>';
var fields = rows[0].match(/\S+/g);
var column = fields.length;
var row = $('<tr></tr>');
row.append('<td><input type="checkbox" onclick="selectAllRscanNode(this)"></td>');
for(var i in fields){
row += '<td>' + fields[i] + '</td>';
row.append('<td>' + fields[i] + '</td>');
}
rscanTable.append(row);
rTable.append(row);
// Add the tbody
for (var i=1; i<rows.length; i++) {
// Add table body
var line;
for (var i = 1; i < rows.length; i++) {
line = rows[i];
if (!line) {
if (!line)
continue;
}
var fields = line.match(regex);
if ('mm' == fields[0]){
var fields = line.match(/\S+/g);
if (fields[0] == 'mm')
continue;
}
row = '<tr><td><input type="checkbox" name="' + fields[1] + '"></td>';
// Create a row for each result
var row = $('<tr></tr>');
row.append('<td><input type="checkbox" name="' + fields[1] + '"></td>');
for (var j=0; j<column; j++){
row += '<td>';
// Add column for each field
for (var j = 0; j < column; j++){
if (fields[j]) {
if (j == 1) {
row += '<input value="' + fields[j] + '">';
row.append('<td><input value="' + fields[j] + '"></td>');
} else {
row += fields[j];
row.append('<td>' + fields[j] + '</td>');
}
} else {
row.append('<td></td>');
}
row += '</td>';
}
row += '</tr>';
rscanTable.append(row);
// Append row to table
rTable.append(row);
}
results.append(rscanTable);
$('#nodeAttrs').prepend(results);
rSection.append(rTable);
$('#bcSettings').prepend(rSection);
}
/**
* Add AMM scanned node
*/
function addMmScanNode(){
// Get the MM name
var mmName = $('#nodeAttrs select').val();
// Get the AMM name
var ammName = $('#bcSettings select').val();
var nodeName = '';
$('#nodeAttrs :checked').each(function() {
$('#bcSettings :checked').each(function() {
if ($(this).attr('name')) {
nodeName += $(this).attr('name') + ',';
nodeName += $(this).parents('tr').find('input').eq(1).val() + ',';
@ -553,30 +571,28 @@ function addMmScanNode(){
});
if (!nodeName) {
alert('You should select nodes first!');
$('#addBladeCenter').prepend(createWarnBar('Please select a node!'));
return;
}
// Disabled the button
// Disabled button
$('.ui-dialog-buttonpane button').attr('disabled', 'disabled');
nodeName = nodeName.substr(0, nodeName.length - 1);
$('#nodeAttrs').append(createLoader());
// Send the add request
// Send add request
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'webrun',
tgt : '',
args : 'addnode;node;' + mmName + ',' + nodeName,
args : 'addnode;node;' + ammName + ',' + nodeName,
msg : ''
},
success : function(data){
// Refresh the area on the right side
$('#addBladeCenter').dialog('close');
$('.selectgroup').trigger('click');
}
});
}

View File

@ -110,7 +110,7 @@ esxPlugin.prototype.loadClonePage = function(node) {
// If there is no existing clone tab
if (!$('#' + newTabId).length) {
// Create info bar
var infoBar = createInfoBar('Not supported');
var infoBar = createInfoBar('Not yet supported');
// Create clone form
var cloneForm = $('<div class="form"></div>');
@ -163,7 +163,7 @@ esxPlugin.prototype.loadProvisionPage = function(tabId) {
var provForm = $('<div class="form"></div>');
// Create info bar
var infoBar = createInfoBar('Provision an KVM virtual machine.');
var infoBar = createInfoBar('Provision an ESX virtual machine.');
provForm.append(infoBar);
// Append to provision tab
@ -477,106 +477,74 @@ esxPlugin.prototype.loadResources = function() {
/**
* Add node range
*
* @return Nothing
*/
esxPlugin.prototype.addNode = function() {
var diag = $('<div id="addIdplx" class="form"></div>');
var info = createInfoBar('Add a node range');
diag.append(info);
var dialog = $('<div id="addEsx" class="form"></div>');
var info = createInfoBar('Add a ESX node');
dialog.append(info);
// Create node inputs
var nodeFieldSet = $('<fieldset></fieldset>');
var legend = $('<legend>Node</legend>');
nodeFieldSet.append(legend);
diag.append(nodeFieldSet);
var nodeInputs = '<div><label>Node: </label><input type="text"></div>' +
'<div><label>MAC:</label><input type="text"></div>' +
'<div><label>IP: </label><input type="text"></div>' +
'<div><label>Groups: </label><input type="text"></div>';
nodeFieldSet.append(nodeInputs);
dialog.append($('<div><label>Node:</label><input name="node" type="text"></div>'));
dialog.append($('<div><label>VM host:</label><input name="vmhost" type="text"></div>'));
dialog.append($('<div><label>IP address:</label><input name="ip" type="text"></div>'));
dialog.append($('<div><label>Groups:</label><input name="groups" type="text"></div>'));
var bmcFieldSet = $('<fieldset></fieldset>');
var legend = $('<legend>BMC</legend>');
bmcFieldSet.append(legend);
diag.append(bmcFieldSet);
// Create BMC inputs
var bmcInputs = '<div><label>BMC:</label><input type="text"></div>' +
'<div><label>IP:</label><input type="text"></div>' +
'<div><label>Groups:</label><input type="text"></div>';
bmcFieldSet.append(bmcInputs);
diag.dialog({
dialog.dialog({
title: 'Add node',
modal: true,
width: 400,
close: function(){$(this).remove();},
buttons: {
"OK" : function(){addIdataplex();},
"OK" : function(){addEsxNode();},
"Cancel": function(){$(this).dialog('close');}
}
});
};
/**
* Add iDataPlex node range
*
* @return Nothing
* Add ESX node
*/
function addIdataplex(){
var tempArray = new Array();
function addEsxNode(){
var attr, args;
var errorMessage = '';
var attr = '';
var args = '';
// Remove existing warnings
$('#addIdplx .ui-state-error').remove();
$('#addEsx .ui-state-error').remove();
// Get input values
$('#addIdplx input').each(function(){
// Return input border colors to normal
$('#addEsx input').css('border', 'solid #BDBDBD 1px');
// Check node attributes
$('#addEsx input').each(function(){
attr = $(this).val();
if (attr) {
tempArray.push($(this).val());
} else {
if (!attr) {
errorMessage = "Please provide a value for each missing field!";
return false;
$(this).css('border', 'solid #FF0000 1px');
}
});
// Show error message (if any)
if (errorMessage) {
$('#addIdplx').prepend(createWarnBar(errorMessage));
$('#addEsx').prepend(createWarnBar(errorMessage));
return;
}
// Create loader
$('#addIdplx').append(createLoader());
$('#addEsx').append(createLoader());
// Change dialog buttons
$('#addIdplx').dialog('option', 'buttons', {
$('#addEsx').dialog('option', 'buttons', {
'Close':function(){
$('#addIdplx').dialog('close');
$('#addEsx').dialog('close');
}
});
// Generate chdef arguments
args = '-t;node;-o;' + tempArray[0] + ';mac=' + tempArray[1] + ';ip=' + tempArray[2] + ';groups=' +
tempArray[3] + ';mgt=esx;chain="runcmd=bmcsetup";netboot=xnba;nodetype=osi;profile=compute;' +
'bmc=' + tempArray[4];
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chdef',
tgt : '',
args : args,
msg : ''
}
});
// Generate chdef arguments for BMC
args = '-t;node;-o;' + tempArray[4] + ';ip=' + tempArray[5] + ';groups=' + tempArray[6];
args = '-t;node;-o;' + $('#addEsx input[name="node"]').val()
+ ';ip=' + $('#addEsx input[name="ip"]').val()
+ ';groups=' + $('#addEsx input[name="groups"]').val()
+ ';vmhost=' + $('#addEsx input[name="vmhost"]').val()
+ ';mgt=esx;netboot=xnba;nodetype=osi;profile=compute';
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
@ -587,15 +555,30 @@ function addIdataplex(){
msg : ''
},
success: function(data) {
$('#addIdplx img').remove();
// Update /etc/hosts
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'makehosts',
tgt : '',
args : '',
msg : ''
},
});
// Remove loader
$('#addEsx img').remove();
// Get return message
var message = '';
for (var i in data.rsp) {
message += data.rsp[i];
message += data.rsp[i] + '<br/>';
}
if (message) {
$('#addIdplx').prepend(createInfoBar(message));
}
// Show return message
if (message)
$('#addEsx').prepend(createInfoBar(message));
}
});
}

View File

@ -14,6 +14,44 @@ var hmcPlugin = function() {
};
/**
* Steps for hardware discovery wizard
*
* @return Discovery steps
*/
hmcPlugin.prototype.getStep = function(){
return ['Basic patterns',
'Supernode',
'More patterns',
'Power on hardware',
'Discover frames',
'Management node',
'Update definitions',
'Create LPARs'];
};
hmcPlugin.prototype.getInitFunction = function(){
return [powerInitBasicPattern,
powerInitSupernode,
powerInitSiteTable,
powerInitPoweronHardware,
powerInitDiscoverFrames,
powerInitConfig,
powerInitUpdateDefinition,
powerInitCreateLpar];
};
hmcPlugin.prototype.getNextFunction = function(){
return [checkBasicPattern,
checkSupernode,
checkSiteTable,
undefined,
checkFrameMtms,
undefined,
undefined,
collectInputValue];
};
/**
* Clone node (service page)
*
@ -191,237 +229,108 @@ hmcPlugin.prototype.loadResources = function() {
/**
* Add node range
*
* @return Nothing
*/
hmcPlugin.prototype.addNode = function() {
var diaDiv = $('<div id="addpnodeDiv" class="form"></div>');
diaDiv.append(createInfoBar('Add a node range'));
diaDiv.append('<div><label>Type:</label><select id="pnodetype"><option>HMC</option><option>Scan Node</option></select></div>');
diaDiv.append('<div id="pnodeeditarea" ></div>');
var dialog = $('<div id="addHmc" class="form"></div>');
dialog.append(createInfoBar('Add a System p node range'));
// Show the dialog
diaDiv.dialog({
// Create option to select node type
dialog.append('<div><label>Node type:</label>' +
'<select id="nodeType"><option>HMC</option>' +
'<option>Scan node</option>' +
'</select></div>');
dialog.append('<div id="nodeSettings"></div>');
// Show dialog
dialog.dialog({
modal : true,
width : 400,
title : 'Add node',
close : function(){$('#addpnodeDiv').remove();}
close : function(){$('#addHmc').remove();}
});
// Bind the select change event
$('#pnodetype').bind('change', function() {
$('#pnodeeditarea').empty();
if ('HMC' == $(this).val()) {
$('#addpnodeDiv').dialog('option', 'width', '400');
$('#pnodeeditarea').append('<label>Name:</label><input><br/><label>Username:</label><input><br/>' +
'<label>Password:</label><input><br/><label>IP Adress:</label><input>');
// Bind to select change event
$('#nodeType').bind('change', function() {
// Remove existing warnings
$('#addHmc .ui-state-error').remove();
// Clear settings section
$('#nodeSettings').empty();
if ($(this).val() == 'HMC') {
$('#addHmc').dialog('option', 'width', '400');
$('#nodeSettings').append('<div><label>Node:</label><input type="text" name="node"/></div>');
$('#nodeSettings').append('<div><label>User name:</label><input type="text" name="username"/></div>');
$('#nodeSettings').append('<div><label>Password:</label><input type="password" name="password"/></div>');
$('#nodeSettings').append('<div><label>IP adress:</label><input type="text" name="ip"/></div>');
$('#addpnodeDiv').dialog('option', 'buttons',
{'Add': function(){addHmcNode();},
'Cancel': function(){$('#addpnodeDiv').dialog('close');}});
// Change dialog buttons
$('#addHmc').dialog('option', 'buttons', {
'Add': function() {addHmcNode();},
'Cancel': function() {$('#addHmc').dialog('close');}
});
} else {
//add loader image and delete buttons
$('#pnodeeditarea').append(createLoader());
$('#addpnodeDiv').dialog('option', 'buttons', {'Cancel': function(){$('#addpnodeDiv').dialog('close');}});
$('#addpnodeDiv').dialog('option', 'width', '650');
// Add loader
$('#nodeSettings').append(createLoader());
// Change dialog buttons
$('#addHmc').dialog('option', 'buttons', {
'Cancel': function() {$('#addHmc').dialog('close');}
});
// Set to longer dialog width
$('#addHmc').dialog('option', 'width', '650');
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'nodels',
tgt : 'all',
args : 'ppc.nodetype==hmc',
args : 'nodetype.nodetype==hmc',
msg : ''
},
success : function(data) {
$('#pnodeeditarea img').remove();
// Remove loader
$('#nodeSettings img').remove();
drawHmcSelector(data.rsp);
}
});
}
});
// Trigger the select change event
$('#pnodetype').trigger('change');
// Trigger select event change
$('#nodeType').trigger('change');
};
hmcPlugin.prototype.getStep = function(){
return ['Basic Patterns',
'Supernode',
'More patterns',
'Power on hardware',
'Discover frames',
'Management node',
'Update definitions',
'Create LPARs'];
};
hmcPlugin.prototype.getInitFunction = function(){
return [powerInitBasicPattern,
powerInitSupernode,
powerInitSiteTable,
powerInitPoweronHardware,
powerInitDiscoverFrames,
powerInitConfig,
powerInitUpdateDefinition,
powerInitCreateLpar];
};
hmcPlugin.prototype.getNextFunction = function(){
return [checkBasicPattern,
checkSupernode,
checkSiteTable,
undefined,
checkFrameMtms,
undefined,
undefined,
collectInputValue];
};
/**
* Add HMCs into the dialog
*
* @param hmc
* HMCs
* @return Nothing
*/
function drawHmcSelector(hmcs){
if (1 > hmcs.length) {
$('#pnodeeditarea').append(createWarnBar('Please define HMC node first.'));
return;
}
// Add HMCs into a selector and add a scan button
var hmcoption = '';
var scanbutton = createButton('Scan');
for (var i in hmcs) {
hmcoption += '<option>' + hmcs[i][0] + '</option>';
}
$('#pnodeeditarea').append('<label>HMC:</label><select>' + hmcoption + '</select>');
$('#pnodeeditarea').append(scanbutton);
scanbutton.bind('click', function() {
var hmcname = $('#pnodeeditarea select').val();
$('#pnodeeditarea').append(createLoader());
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'rscan',
tgt : hmcname,
args : '',
msg : ''
},
success : function(data) {
$('#pnodeeditarea img').remove();
// Draw a table with checkbox
drawRscanResult(data.rsp[0]);
// Add the add button
$('#addpnodeDiv').dialog('option', 'buttons',
{'Add': function(){addPNode();},
'Cancel': function(){$('#addpnodeDiv').dialog('close');}});
}
});
});
}
function drawRscanResult(rscanresult){
var line = '';
var tempreg = /\S+/g;
var idpreg = /^\d+$/;
var resultDiv = $('<div class="tab" style="height:300px;overflow:auto;"></div>');
var rscantable = $('<table></table>');
var temprow = '';
var colnum = 0;
var fields = 0;
$('#pnodeeditarea div').remove();
if (!rscanresult) {
return;
}
var rows = rscanresult.split("\n");
if (rows.length < 2) {
return;
}
// Add the table header
fields = rows[0].match(tempreg);
colnum = fields.length;
temprow = '<tr><td><input type="checkbox" onclick="selectAllRscanNode(this)"></td>';
for(var i in fields) {
temprow += '<td>' + fields[i] + '</td>';
}
rscantable.append(temprow);
// Add the tbody
for (var i = 1; i < rows.length; i++) {
line = rows[i];
if (!line) {
continue;
}
var fields = line.match(tempreg);
if ('hmc' == fields[0]) {
continue;
}
// May be the 3rd field(id) is empty, so we should add the new
if (!idpreg.test(fields[2])){
fields = [fields[0], fields[1], ''].concat(fields.slice(2));
}
temprow = '<tr><td><input type="checkbox" name="' + fields[1] + '"></td>';
for(var j = 0; j < colnum; j++) {
temprow += '<td>';
if (fields[j]) {
if (j == 1){
temprow += '<input value="' + fields[j] + '">';
}
else{
temprow += fields[j];
}
}
temprow += '</td>';
}
temprow += '</tr>';
rscantable.append(temprow);
}
resultDiv.append(rscantable);
$('#pnodeeditarea').append(resultDiv);
}
/**
* Add hmc node
*
* @return Nothing
* Add HMC node
*/
function addHmcNode(){
var errorinfo = '';
// Remove existing warnings
$('#addHmc .ui-state-error').remove();
var errorMessage = '';
var args = '';
$('#pnodeeditarea input').each(function(){
if (!$(this).val()){
errorinfo = 'Please provide a value for each missing field!';
}
$('#nodeSettings input').each(function(){
if (!$(this).val())
errorMessage = 'Please provide a value for each missing field!';
args += $(this).val() + ',';
});
if (errorinfo){
// Add warning message
alert(errorinfo);
// Do no continue if an error is found
if (errorMessage){
$('#addHmc').prepend(createWarnBar(errorMessage));
return;
}
// Disabled the button
// Disabled button
$('.ui-dialog-buttonpane button').attr('disabled', 'disabled');
// Remove last comma
args = args.substr(0, args.length - 1);
$('#pnodeeditarea').append(createLoader());
// Send the save HMC request
// Append loader
$('#nodeSettings').append(createLoader());
// Send request to add HMC
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
@ -432,13 +341,139 @@ function addHmcNode(){
msg : ''
},
success : function(data){
// Refresh the area on the right side
$('#addpnodeDiv').dialog('close');
$('.selectgroup').trigger('click');
$('#addHmc').dialog('close');
}
});
}
/**
* Add HMCs into dialog
*
* @param hmcs
* HMCs
* @return Nothing
*/
function drawHmcSelector(hmcs){
// Remove existing warnings
$('#addHmc .ui-state-error').remove();
// Do not continue if no HMCs are given
if (hmcs.length < 1) {
$('#addHmc').prepend(createWarnBar('Please define an HMC node first!'));
return;
}
// Add HMCs into a dropdown and add scan button
var hmcSelect = $('<select></select>');
var scanButton = createButton('Scan');
for (var i in hmcs) {
hmcSelect.append('<option>' + hmcs[i][0] + '</option>');
}
$('#nodeSettings').append($('<div><label>HMC:</label></div>').append(hmcSelect, scanButton));
scanButton.bind('click', function() {
var hmcname = $('#nodeSettings select').val();
$('#nodeSettings').append(createLoader());
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'rscan',
tgt : hmcname,
args : '',
msg : ''
},
success : function(data) {
// Remove loader
$('#nodeSettings img').remove();
// Draw table with checkboxes
drawRscanResult(data.rsp[0]);
// Add the add button
$('#addHmc').dialog('option', 'buttons', {
'Add': function(){addPNode();},
'Cancel': function(){$('#addHmc').dialog('close');}
});
}
});
});
}
/**
* Draw table showing HMC rscan results
*
* @param results
* Data returned from rscan
* @return Nothing
*/
function drawRscanResult(results) {
var tmpRegex = /\S+/g;
var idRegex = /^\d+$/;
var rSection = $('<div class="tab" style="height:300px; overflow:auto;"></div>');
var rTable = $('<table></table>');
// Empty node settings section
$('#nodeSettings div').remove();
if (!results)
return;
var lines = results.split("\n");
// Do not continue if no results are found
if (lines.length < 2) {
return;
}
var fields = lines[0].match(tmpRegex);
var cols = fields.length;
// Add table header
var tHead = $('<thead class="ui-widget-header"></thead>').append('<th><input type="checkbox" onclick="selectAllRscanNode(this)"></th>');
for(var i in fields) {
tHead.append('<th>' + fields[i] + '</th>');
}
rTable.append(tHead);
// Add table body
var tBody = $('<tbody></tbody>');
rTable.append(tBody);
for (var i = 1; i < lines.length; i++) {
var row = $('<tr></tr>');
// Go to next row if there is nothing
if (!lines[i])
continue;
fields = lines[i].match(tmpRegex);
// Go to next row if this row is the HMC
if (fields[0] == 'hmc')
continue;
// If the 3rd field is empty, create an empty column
if (!idRegex.test(fields[2]))
fields = [fields[0], fields[1], ''].concat(fields.slice(2));
row.append('<td><input type="checkbox" name="' + fields[1] + '"></td>');
// Go through each field and add it to the row as a column
for(var j = 0; j < cols; j++) {
var col = $('<td></td>');
if (fields[j]) {
if (j == 1)
col.append('<input value="' + fields[j] + '"/>');
else
col.append(fields[j]);
}
}
tBody.append(row);
}
rSection.append(rTable);
$('#nodeSettings').append(rSection);
}
/**
* Add System p node, contains frame, cec, lpar
*
@ -446,10 +481,10 @@ function addHmcNode(){
*/
function addPNode(){
// Get the HMC name
var hmcname = $('#pnodeeditarea select').val();
var hmcname = $('#nodeSettings select').val();
var nodename = '';
// Get checked nodes
$('#pnodeeditarea :checked').each(function() {
$('#nodeSettings :checked').each(function() {
if ($(this).attr('name')) {
nodename += $(this).attr('name') + ',';
nodename += $(this).parents('tr').find('input').eq(1).val() + ',';
@ -465,7 +500,7 @@ function addPNode(){
$('.ui-dialog-buttonpane button').attr('disabled', 'disabled');
nodename = nodename.substr(0, nodename.length - 1);
$('#pnodeeditarea').append(createLoader());
$('#nodeSettings').append(createLoader());
// Send the add request
$.ajax({
url : 'lib/cmd.php',
@ -478,7 +513,7 @@ function addPNode(){
},
success : function(data) {
// Refresh the area on the right side
$('#addpnodeDiv').dialog('close');
$('#addHmc').dialog('close');
$('.selectgroup').trigger('click');
}
});

View File

@ -14,6 +14,28 @@ var ipmiPlugin = function() {
};
/**
* Steps for hardware discovery wizard
*
* @return Discovery steps
*/
ipmiPlugin.prototype.getStep = function(){
return ['Basic patterns', 'Switches', 'Network', 'Services', 'Power on hardware'];
};
/**
* return steps's init function for hardware discovery wizard
*
* @return Nothing
*/
ipmiPlugin.prototype.getInitFunction = function(){
return [idataplexInitBasic, idataplexInitSwitch, idataplexInitNetwork, idataplexInitService, idataplexInitPowerOn];
};
ipmiPlugin.prototype.getNextFunction = function(){
return [idataplexCheckBasic, undefined, idataplexCheckNetwork, undefined, undefined];
};
/**
* Clone node (service page)
*
@ -66,7 +88,6 @@ ipmiPlugin.prototype.loadInventory = function(data) {
$('#' + tabId).find('img').remove();
// Create division to hold inventory
var invDivId = tabId + 'Inventory';
var invDiv = $('<div></div>');
// Create a fieldset
@ -179,8 +200,6 @@ ipmiPlugin.prototype.loadProvisionPage = function(tabId) {
/**
* Load resources
*
* @return Nothing
*/
ipmiPlugin.prototype.loadResources = function() {
// Get resource tab ID
@ -200,38 +219,19 @@ ipmiPlugin.prototype.loadResources = function() {
/**
* Add node range
*
* @return Nothing
*/
ipmiPlugin.prototype.addNode = function() {
var diag = $('<div id="addIdplx" class="form"></div>');
var info = createInfoBar('Add a node range');
diag.append(info);
var dialog = $('<div id="addIdplx" class="form"></div>');
var info = createInfoBar('Add a iDataPlex node');
dialog.append(info);
// Create node inputs
var nodeFieldSet = $('<fieldset></fieldset>');
var legend = $('<legend>Node</legend>');
nodeFieldSet.append(legend);
diag.append(nodeFieldSet);
var nodeInputs = '<div><label>Node: </label><input type="text"></div>' +
'<div><label>MAC:</label><input type="text"></div>' +
'<div><label>IP: </label><input type="text"></div>' +
'<div><label>Groups: </label><input type="text"></div>';
nodeFieldSet.append(nodeInputs);
var bmcFieldSet = $('<fieldset></fieldset>');
var legend = $('<legend>BMC</legend>');
bmcFieldSet.append(legend);
diag.append(bmcFieldSet);
// Create BMC inputs
var bmcInputs = '<div><label>BMC:</label><input type="text"></div>' +
'<div><label>IP:</label><input type="text"></div>' +
'<div><label>Groups:</label><input type="text"></div>';
bmcFieldSet.append(bmcInputs);
dialog.append($('<div><label>Node:</label><input name="node" type="text"/></div>'));
dialog.append($('<div><label>IP address:</label><input name="ip" type="text"/></div>'));
dialog.append($('<div><label>MAC address:</label><input name="mac" type="text"/></div>'));
dialog.append($('<div><label>Groups:</label><input name="groups" type="text"/></div>'));
diag.dialog({
dialog.dialog({
title: 'Add node',
modal: true,
width: 400,
@ -243,53 +243,29 @@ ipmiPlugin.prototype.addNode = function() {
});
};
/**
* return steps name for hardware discovery wizard
*
* @return Nothing
*/
ipmiPlugin.prototype.getStep = function(){
return ['Basic Patterns', 'Swithes', 'Network', 'Services', 'Power on hardwares'];
};
/**
* return steps's init function for hardware discovery wizard
*
* @return Nothing
*/
ipmiPlugin.prototype.getInitFunction = function(){
return [idataplexInitBasic, idataplexInitSwitch, idataplexInitNetwork, idataplexInitService, idataplexInitPowerOn];
};
ipmiPlugin.prototype.getNextFunction = function(){
return [idataplexCheckBasic, undefined, idataplexCheckNetwork, undefined, undefined];
};
/**
* Add iDataPlex node range
*
* @return Nothing
*/
function addIdataplex(){
var tempArray = new Array();
var attr, args;
var errorMessage = '';
var attr = '';
var args = '';
// Remove existing warnings
$('#addIdplx .ui-state-error').remove();
// Get input values
// Return input border colors to normal
$('#addIdplx input').css('border', 'solid #BDBDBD 1px');
// Check node attributes
$('#addIdplx input').each(function(){
attr = $(this).val();
if (attr) {
tempArray.push($(this).val());
} else {
if (!attr) {
errorMessage = "Please provide a value for each missing field!";
return false;
$(this).css('border', 'solid #FF0000 1px');
}
});
// Show error message (if any)
if (errorMessage) {
$('#addIdplx').prepend(createWarnBar(errorMessage));
return;
@ -306,22 +282,11 @@ function addIdataplex(){
});
// Generate chdef arguments
args = '-t;node;-o;' + tempArray[0] + ';mac=' + tempArray[1] + ';ip=' + tempArray[2] + ';groups=' +
tempArray[3] + ';mgt=ipmi;chain="runcmd=bmcsetup";netboot=xnba;nodetype=osi;profile=compute;' +
'bmc=' + tempArray[4];
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chdef',
tgt : '',
args : args,
msg : ''
}
});
// Generate chdef arguments for BMC
args = '-t;node;-o;' + tempArray[4] + ';ip=' + tempArray[5] + ';groups=' + tempArray[6];
args = '-t;node;-o;' + $('#addIdplx input[name="node"]').val()
+ ';ip=' + $('#addIdplx input[name="ip"]').val()
+ ';mac=' + $('#addIdplx input[name="mac"]').val()
+ ';groups=' + $('#addIdplx input[name="groups"]').val()
+ ';mgt=ipmi;netboot=xnba;nodetype=osi;profile=compute';
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
@ -332,15 +297,30 @@ function addIdataplex(){
msg : ''
},
success: function(data) {
// Update /etc/hosts
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'makehosts',
tgt : '',
args : '',
msg : ''
},
});
// Remove loader
$('#addIdplx img').remove();
// Get return message
var message = '';
for (var i in data.rsp) {
message += data.rsp[i];
message += data.rsp[i] + '<br/>';
}
if (message) {
// Show return message
if (message)
$('#addIdplx').prepend(createInfoBar(message));
}
}
});
}

View File

@ -66,7 +66,6 @@ kvmPlugin.prototype.loadInventory = function(data) {
$('#' + tabId).find('img').remove();
// Create division to hold inventory
var invDivId = tabId + 'Inventory';
var invDiv = $('<div></div>');
// Create a fieldset
@ -110,7 +109,7 @@ kvmPlugin.prototype.loadClonePage = function(node) {
// If there is no existing clone tab
if (!$('#' + newTabId).length) {
// Create info bar
var infoBar = createInfoBar('Not supported');
var infoBar = createInfoBar('Not yet supported');
// Create clone form
var cloneForm = $('<div class="form"></div>');
@ -477,44 +476,25 @@ kvmPlugin.prototype.loadResources = function() {
/**
* Add node range
*
* @return Nothing
*/
kvmPlugin.prototype.addNode = function() {
var diag = $('<div id="addIdplx" class="form"></div>');
var info = createInfoBar('Add a node range');
diag.append(info);
var dialog = $('<div id="addKvm" class="form"></div>');
var info = createInfoBar('Add a KVM node');
dialog.append(info);
// Create node inputs
var nodeFieldSet = $('<fieldset></fieldset>');
var legend = $('<legend>Node</legend>');
nodeFieldSet.append(legend);
diag.append(nodeFieldSet);
var nodeInputs = '<div><label>Node: </label><input type="text"></div>' +
'<div><label>MAC:</label><input type="text"></div>' +
'<div><label>IP: </label><input type="text"></div>' +
'<div><label>Groups: </label><input type="text"></div>';
nodeFieldSet.append(nodeInputs);
dialog.append($('<div><label>Node:</label><input name="node" type="text"></div>'));
dialog.append($('<div><label>VM host:</label><input name="vmhost" type="text"></div>'));
dialog.append($('<div><label>IP address:</label><input name="ip" type="text"></div>'));
dialog.append($('<div><label>Groups:</label><input name="groups" type="text"></div>'));
var bmcFieldSet = $('<fieldset></fieldset>');
var legend = $('<legend>BMC</legend>');
bmcFieldSet.append(legend);
diag.append(bmcFieldSet);
// Create BMC inputs
var bmcInputs = '<div><label>BMC:</label><input type="text"></div>' +
'<div><label>IP:</label><input type="text"></div>' +
'<div><label>Groups:</label><input type="text"></div>';
bmcFieldSet.append(bmcInputs);
diag.dialog({
dialog.dialog({
title: 'Add node',
modal: true,
width: 400,
close: function(){$(this).remove();},
buttons: {
"OK" : function(){addIdataplex();},
"OK" : function(){addKvmNode();},
"Cancel": function(){$(this).dialog('close');}
}
});
@ -522,61 +502,48 @@ kvmPlugin.prototype.addNode = function() {
/**
* Add iDataPlex node range
*
* @return Nothing
*/
function addIdataplex(){
var tempArray = new Array();
function addKvmNode(){
var attr, args;
var errorMessage = '';
var attr = '';
var args = '';
// Remove existing warnings
$('#addIdplx .ui-state-error').remove();
$('#addKvm .ui-state-error').remove();
// Get input values
$('#addIdplx input').each(function(){
// Return input border colors to normal
$('#addKvm input').css('border', 'solid #BDBDBD 1px');
// Check node attributes
$('#addKvm input').each(function(){
attr = $(this).val();
if (attr) {
tempArray.push($(this).val());
} else {
if (!attr) {
errorMessage = "Please provide a value for each missing field!";
return false;
$(this).css('border', 'solid #FF0000 1px');
}
});
// Show error message (if any)
if (errorMessage) {
$('#addIdplx').prepend(createWarnBar(errorMessage));
$('#addKvm').prepend(createWarnBar(errorMessage));
return;
}
// Create loader
$('#addIdplx').append(createLoader());
$('#addKvm').append(createLoader());
// Change dialog buttons
$('#addIdplx').dialog('option', 'buttons', {
$('#addKvm').dialog('option', 'buttons', {
'Close':function(){
$('#addIdplx').dialog('close');
$('#addKvm').dialog('close');
}
});
// Generate chdef arguments
args = '-t;node;-o;' + tempArray[0] + ';mac=' + tempArray[1] + ';ip=' + tempArray[2] + ';groups=' +
tempArray[3] + ';mgt=kvm;chain="runcmd=bmcsetup";netboot=xnba;nodetype=osi;profile=compute;' +
'bmc=' + tempArray[4];
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chdef',
tgt : '',
args : args,
msg : ''
}
});
// Generate chdef arguments for BMC
args = '-t;node;-o;' + tempArray[4] + ';ip=' + tempArray[5] + ';groups=' + tempArray[6];
args = '-t;node;-o;' + $('#addKvm input[name="node"]').val()
+ ';ip=' + $('#addKvm input[name="ip"]').val()
+ ';groups=' + $('#addKvm input[name="groups"]').val()
+ ';vmhost=' + $('#addKvm input[name="vmhost"]').val()
+ ';mgt=kvm;netboot=xnba;nodetype=osi;profile=compute';
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
@ -587,15 +554,30 @@ function addIdataplex(){
msg : ''
},
success: function(data) {
$('#addIdplx img').remove();
// Update /etc/hosts
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'makehosts',
tgt : '',
args : '',
msg : ''
},
});
// Remove loader
$('#addKvm img').remove();
// Get return message
var message = '';
for (var i in data.rsp) {
message += data.rsp[i];
message += data.rsp[i] + '<br/>';
}
if (message) {
$('#addIdplx').prepend(createInfoBar(message));
}
// Show return message
if (message)
$('#addKvm').prepend(createInfoBar(message));
}
});
}

View File

@ -23,7 +23,7 @@ var zvmPlugin = function() {
* @return Nothing
*/
zvmPlugin.prototype.serviceClone = function(node) {
var owner = $.cookie('srv_usrname');
var owner = $.cookie('xcat_username');
var group = getUserNodeAttr(node, 'groups');
// Submit request to clone VM
@ -88,7 +88,7 @@ zvmPlugin.prototype.loadServiceProvisionPage = function(tabId) {
var hcp = $('#select-table tbody tr:eq(0) td:eq(0) input[name="hcp"]:checked').val();
var group = $('#select-table tbody tr:eq(0) td:eq(1) input[name="group"]:checked').val();
var img = $('#select-table tbody tr:eq(0) td:eq(2) input[name="image"]:checked').val();
var owner = $.cookie('srv_usrname');
var owner = $.cookie('xcat_username');
if(!hcp || !group || !img) {
// Show warning message
@ -853,7 +853,7 @@ zvmPlugin.prototype.loadInventory = function(data) {
var legend = $('<legend>General</legend>');
fieldSet.append(legend);
var oList = $('<ol></ol>');
var item, label, input, args;
var item, label, args;
// Loop through each property
for ( var k = 0; k < 5; k++) {
@ -961,7 +961,7 @@ zvmPlugin.prototype.loadInventory = function(data) {
// Table columns - Type, Address, ID, Base, Dedicated, and Affinity
var procTabRow = $('<thead class="ui-widget-header"> <th>Type</th> <th>Address</th> <th>ID</th> <th>Base</th> <th>Dedicated</th> <th>Affinity</th> </thead>');
procTable.append(procTabRow);
var procType, procAddr, procId, procAff;
var procId, procAff;
/**
* Remove processor
@ -989,7 +989,6 @@ zvmPlugin.prototype.loadInventory = function(data) {
}];
// Loop through each processor
var closeBtn;
var n, temp;
var procType, procAddr, procLink;
for (l = 0; l < attrs[keys[k]].length; l++) {
@ -1188,7 +1187,7 @@ zvmPlugin.prototype.loadInventory = function(data) {
// Table columns - Virtual device, Adapter Type, Port Name, # of Devices, MAC Address, and LAN Name
var nicTabRow = $('<thead class="ui-widget-header"> <th>Virtual Device #</th> <th>Adapter Type</th> <th>Port Name</th> <th># of Devices</th> <th>LAN Name</th></thead>');
nicTable.append(nicTabRow);
var nicVDev, nicType, nicPortName, nicNumOfDevs, nicMacAddr, nicLanName;
var nicVDev, nicType, nicPortName, nicNumOfDevs, nicLanName;
// Loop through each NIC (Data contained in 2 lines)
for (l = 0; l < attrs[keys[k]].length; l = l + 2) {
@ -1289,9 +1288,6 @@ zvmPlugin.prototype.loadProvisionPage = function(tabId) {
success : setGroupsCookies
});
// Error message string
var errMsg;
// Get provision tab instance
var inst = tabId.replace('zvmProvisionTab', '');
@ -1388,13 +1384,14 @@ zvmPlugin.prototype.loadResources = function() {
*/
zvmPlugin.prototype.addNode = function() {
// Create form to add node range
var addNodeForm = $('<div class="form"></div>');
var info = createInfoBar('Add a node range');
var addNodeForm = $('<div id="addZvm" class="form"></div>');
var info = createInfoBar('Add a z/VM node range');
addNodeForm.append(info);
addNodeForm.append('<div><label for="node">Node range:</label><input type="text" id="node" name="node"/></div>');
addNodeForm.append('<div><label for="userId">User ID range:</label><input type="text" id="userId" name="userId"/></div>');
addNodeForm.append('<div><label for="hcp">Hardware control point:</label><input type="text" id="hcp" name="hcp"/></div>');
addNodeForm.append('<div><label for="group">Group:</label><input type="text" id="group" name="group"/></div>');
addNodeForm.append('<div><label>Node range:</label><input type="text" name="node"/></div>');
addNodeForm.append('<div><label>IP address range (optional):</label><input name="ip" type="text"></div>');
addNodeForm.append('<div><label>User ID range:</label><input type="text" name="userId"/></div>');
addNodeForm.append('<div><label>Hardware control point:</label><input type="text" name="hcp"/></div>');
addNodeForm.append('<div><label>Groups:</label><input type="text" name="groups"/></div>');
// Open form as a dialog
addNodeForm.dialog({
@ -1408,13 +1405,14 @@ zvmPlugin.prototype.addNode = function() {
// Get inputs
var nodeRange = $(this).find('input[name=node]').val();
var ipRange = $(this).find('input[name=ip]').val();
var userIdRange = $(this).find('input[name=userId]').val();
var group = $(this).find('input[name=group]').val();
var group = $(this).find('input[name=groups]').val();
var hcp = $(this).find('input[name=hcp]').val();
// Show warning message if inputs are not complete
if (!nodeRange || !userIdRange || !group || !hcp) {
var warn = createWarnBar('You are missing inputs.');
var warn = createWarnBar('Please provide a value for each missing field!');
warn.prependTo($(this));
} else {
// Check node range and user ID range
@ -1422,14 +1420,12 @@ zvmPlugin.prototype.addNode = function() {
var errMsg = '';
var ready = true;
if (nodeRange.indexOf('-') > -1 || userIdRange.indexOf('-') > -1) {
if (nodeRange.indexOf('-') < 0 || userIdRange.indexOf('-') < 0) {
if (nodeRange.indexOf('-') < 0 || userIdRange.indexOf('-') < 0 || ipRange.indexOf('-') < 0) {
errMsg = errMsg + 'A user ID range and node range needs to be given. ';
ready = false;
} else {
var tmp = nodeRange.split('-');
// Get node base name
var nodeBase = tmp[0].match(/[a-zA-Z]+/);
// Get starting index
var nodeStart = parseInt(tmp[0].match(/\d+/));
// Get ending index
@ -1437,24 +1433,43 @@ zvmPlugin.prototype.addNode = function() {
tmp = userIdRange.split('-');
// Get user ID base name
var userIdBase = tmp[0].match(/[a-zA-Z]+/);
// Get starting index
var userIdStart = parseInt(tmp[0].match(/\d+/));
// Get ending index
var userIdEnd = parseInt(tmp[1].match(/\d+/));
tmp = ipRange.split('-');
// Get starting IP address
var ipStart = tmp[0].substring(tmp[0].lastIndexOf(".") + 1);
// Get ending IP address
var ipEnd = tmp[1].substring(tmp[1].lastIndexOf(".") + 1);
// If starting and ending index do not match
if (!(nodeStart == userIdStart) || !(nodeEnd == userIdEnd)) {
// Not ready
errMsg = errMsg + 'The node range and user ID range does not match. ';
ready = false;
}
// If an IP address range is given and the starting and ending index do not match
if (ipRange && !(nodeStart == ipStart) || !(nodeEnd == ipEnd)) {
errMsg = errMsg + 'The node range and IP address range does not match. ';
ready = false;
}
}
}
// If there are no errors
if (ready) {
$('#addZvm').append(createLoader());
// Change dialog buttons
$('#addZvm').dialog('option', 'buttons', {
'Close':function(){
$('#addZvm').dialog('close');
}
});
// If a node range is given
if (nodeRange.indexOf('-') > -1 && userIdRange.indexOf('-') > -1) {
var tmp = nodeRange.split('-');
@ -1474,11 +1489,21 @@ zvmPlugin.prototype.addNode = function() {
var userIdStart = parseInt(tmp[0].match(/\d+/));
// Get ending index
var userIdEnd = parseInt(tmp[1].match(/\d+/));
tmp = ipRange.split('-');
// Get network base
var ipBase = tmp[0].substring(0, tmp[0].lastIndexOf(".") + 1);
// Get starting IP address
var ipStart = tmp[0].substring(tmp[0].lastIndexOf(".") + 1);
// Get ending IP address
var ipEnd = tmp[1].substring(tmp[1].lastIndexOf(".") + 1);
// Loop through each node in the node range
for ( var i = nodeStart; i <= nodeEnd; i++) {
var node = nodeBase + i.toString();
var userId = userIdBase + i.toString();
var ip = ipBase + i.toString();
var inst = i + '/' + nodeEnd;
/**
@ -1492,7 +1517,8 @@ zvmPlugin.prototype.addNode = function() {
tgt : '',
args : node + ';zvm.hcp=' + hcp
+ ';zvm.userid=' + userId
+ ';nodehm.mgt=zvm' + ';groups=' + group,
+ ';nodehm.mgt=zvm' + ';groups=' + group
+ ';hosts.ip=' + ip,
msg : 'cmd=addnewnode;inst=' + inst + ';noderange=' + nodeRange
},
@ -1508,19 +1534,33 @@ zvmPlugin.prototype.addNode = function() {
var rsp = data.rsp;
var args = data.msg.split(';');
// Get command invoked
var cmd = args[0].replace('cmd=', '');
// Get instance returned and node range
var inst = args[1].replace('inst=', '');
var nodeRange = args[2].replace('noderange=', '');
// If the last node was added
var tmp = inst.split('/');
if (tmp[0] == tmp[1]) {
// Update /etc/hosts
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'makehosts',
tgt : '',
args : '',
msg : ''
},
});
// Remove loader
$('#addZvm img').remove();
// If there was an error, do not continue
if (rsp.length) {
openDialog('warn', '(Error) Failed to create node definitions');
$('#addZvm').prepend(createWarnBar('Failed to create node definitions'));
} else {
openDialog('info', 'Node definitions created for ' + nodeRange);
$('#addZvm').prepend(createInfoBar('Node definitions created for ' + nodeRange));
}
}
}
@ -1536,7 +1576,8 @@ zvmPlugin.prototype.addNode = function() {
tgt : '',
args : nodeRange + ';zvm.hcp=' + hcp
+ ';zvm.userid=' + userIdRange
+ ';nodehm.mgt=zvm' + ';groups=' + group,
+ ';nodehm.mgt=zvm' + ';groups=' + group
+ ';hosts.ip=' + ipRange,
msg : 'cmd=addnewnode;node=' + nodeRange
},
@ -1551,23 +1592,32 @@ zvmPlugin.prototype.addNode = function() {
// Get ajax response
var rsp = data.rsp;
var args = data.msg.split(';');
// Get command invoked
var cmd = args[0].replace('cmd=', '');
var node = args[1].replace('node=', '');
// Update /etc/hosts
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'makehosts',
tgt : '',
args : '',
msg : ''
},
});
// Remove loader
$('#addZvm img').remove();
// If there was an error, do not continue
if (rsp.length) {
openDialog('warn', '(Error) Failed to create node definition');
} else {
openDialog('info', 'Node definitions created for ' + node);
}
$('#addZvm').prepend(createWarnBar('Failed to create node definitions'));
} else {
$('#addZvm').prepend(createInfoBar('Node definitions created for ' + node));
}
}
});
}
// Close dialog
$(this).dialog( "close" );
} else {
// Show warning message
var warn = createWarnBar(errMsg);

View File

@ -1,16 +1,11 @@
/**
* Global variables
*/
// Node tabs
var nodesTab;
// Original node attributes
var origAttrs = new Object();
// Node attributes
var nodeAttrs;
// Node list
var nodesList;
// Nodes datatable ID
var nodesTableId = 'nodesDatatable';
var nodesTab; // Nodes tabs
var origAttrs = new Object(); // Original node attributes
var nodeAttrs; // Node attributes
var nodesList; // Node list
var nodesTableId = 'nodesDatatable'; // Nodes datatable ID
/**
* Set node tab

View File

@ -189,7 +189,7 @@ function loadServiceProvisionPage(tabId) {
*/
var okBtn = createButton('Ok');
okBtn.bind('click', function(event) {
var userName = $.cookie('srv_usrname');
var userName = $.cookie('xcat_username');
var tmp = $.cookie(userName + '_usrnodes');
// Get maximun number for nodes from cookie
@ -292,7 +292,7 @@ function loadManagePage(tabId) {
* Get the user nodes definitions
*/
function getUserNodesDef() {
var userName = $.cookie('srv_usrname');
var userName = $.cookie('xcat_username');
var userNodes = $.cookie(userName + '_usrnodes');
if (userNodes) {
// Get nodes definitions
@ -590,7 +590,7 @@ function loadNodesTable(data) {
getNodesCurrentLoad();
// Refresh nodes table
var userName = $.cookie('srv_usrname');
var userName = $.cookie('xcat_username');
var userNodes = $.cookie(userName + '_usrnodes');
if (userNodes) {
// Get nodes definitions
@ -1057,7 +1057,7 @@ function setOSImageCookies(data) {
function setUserNodes(data) {
if (data.rsp) {
// Get user name that is logged in
var userName = $.cookie('srv_usrname');
var userName = $.cookie('xcat_username');
var usrNodes = new Array();
// Ignore first columns because it is the header
@ -1290,7 +1290,7 @@ function monitorNode(node, monitor) {
* @return Nothing
*/
function cloneNode(tgtNodes) {
var userName = $.cookie('srv_usrname');
var userName = $.cookie('xcat_username');
var nodes = tgtNodes.split(',');
var tmp = $.cookie(userName + '_usrnodes');
var usrNodes = tmp.split(',');
@ -1586,7 +1586,7 @@ function unlockNode(tgtNodes) {
* Get nodes current load information
*/
function getNodesCurrentLoad(){
var userName = $.cookie('srv_usrname');
var userName = $.cookie('xcat_username');
var nodes = $.cookie(userName + '_usrnodes');
// Get nodes current status
@ -2144,7 +2144,7 @@ function getNodeAttr(node, attrName) {
* Set the maximum number of VMs a user could have
*/
function setMaxVM() {
var userName = $.cookie('srv_usrname');
var userName = $.cookie('xcat_username');
$.ajax( {
url : 'lib/srv_cmd.php',

View File

@ -64,11 +64,11 @@ function onlogin(data, txtStatus) {
if (data.authenticated == 'yes') {
$('#login_status').text('Login successful');
window.location = 'service.php';
// Set user name cookie
// Set user name cookie
var exDate = new Date();
exDate.setTime(exDate.getTime() + (240 * 60 * 1000));
$.cookie('srv_usrname', usrName, { expires: exDate });
$.cookie('xcat_username', usrName, { expires: exDate });
} else {
$('#login_status').text('Authentication failure');
$('#login_status').css('color', '#FF0000');

View File

@ -796,18 +796,61 @@ function createIFrame(src) {
/**
* Open dialog to set xCAT UI settings
*
* @return Nothing
*/
function openSettings() {
// Create form to add node range
var settingsForm = $('<div class="form"></div>');
var dialog = $('<div class="form"></div>');
var info = createInfoBar('Select the settings you desire');
settingsForm.append(info);
dialog.append(info);
var style = {
'color': 'blue',
'cursor': 'pointer',
'padding': '5px'
};
var changeThemeOption = $('<div><center><a style="color: blue;">Change xCAT theme</a></center></div>').css(style);
dialog.append(changeThemeOption);
var changePasswordOption = $('<div><center><a style="color: blue;">Change password</a></center></div>').css(style);
dialog.append(changePasswordOption);
// Open form as a dialog
dialog.dialog({
modal: true,
title: 'Settings',
width: 400,
buttons: {
"Cancel": function(){
$(this).dialog("close");
}
}
});
// Bind to click event
changeThemeOption.click(function() {
dialog.dialog("close");
changeTheme();
});
changePasswordOption.click(function() {
dialog.dialog("close");
changePassword();
});
}
/**
* Open dialog to change xCAT theme
*/
function changeTheme() {
// Create form to add node range
var dialog = $('<div class="form"></div>');
var info = createInfoBar('Select the xCAT theme you desire');
dialog.append(info);
// Create select drop down for themes
var themeFS = $('<fieldset></fieldset>');
settingsForm.append(themeFS);
dialog.append(themeFS);
var legend = $('<legend>Theme</legend>');
themeFS.append(legend);
var oList = $('<ol></ol>');
@ -827,9 +870,9 @@ function openSettings() {
}
// Open form as a dialog
settingsForm.dialog({
dialog.dialog({
modal: true,
title: 'Settings',
title: 'xCAT Theme',
width: 400,
buttons: {
"Ok": function(){
@ -856,6 +899,93 @@ function openSettings() {
});
}
/**
* Open dialog to change user password
*/
function changePassword() {
// Create form to add node range
var dialog = $('<div id="changePassword" class="form"></div>');
var info = createInfoBar('Change your password');
dialog.append(info);
dialog.append('<div><label>New password:</label><input type="password" name="newPassword"/></div>');
dialog.append('<div><label>Confirm password:</label><input type="password" name="confirmPassword"/></div>');
// Open form as a dialog
dialog.dialog({
modal: true,
title: 'Change Password',
width: 400,
buttons: {
"Ok": function(){
// Remove any warning messages
$(this).find('.ui-state-error').remove();
var errorMessage = "";
// Check each input is provided
$('#changePassword input').each(function() {
if (!$(this).val()) {
errorMessage = "Please provide a value for each missing input!";
}
});
// Do not continue if error found
if (errorMessage) {
dialog.prepend(createWarnBar(errorMessage));
return;
}
// Check new and confirm passwords match
var user = $.cookie('xcat_username');
var newPassword = $('#changePassword input[name="newPassword"]').val();
var confirmPassword = $('#changePassword input[name="confirmPassword"]').val();
if (newPassword != confirmPassword) {
dialog.prepend(createWarnBar("Please confirm new password!"));
return;
}
// Change dialog buttons
$('#changePassword').dialog('option', 'buttons', {
'Close':function(){
$('#changePassword').dialog('close');
}
});
// Send request to change password
var url = window.location.pathname;
var page = url.replace('/xcat/', '');
var url = 'lib/cmd.php';
// Service portal does not have access to cmd.php
if (page == 'service.php')
url = 'lib/srv_cmd.php';
$.ajax( {
url : url,
dataType : 'json',
data : {
cmd : 'webrun',
tgt : '',
args : 'passwd;' + user + ';' + newPassword,
msg : ''
},
success : function (data) {
// Show response message
var rspMessage = "";
for (var i in data.rsp)
rspMessage += data.rsp[i] + "<br/>";
$('#changePassword').prepend(createInfoBar(rspMessage));
}
});
},
"Cancel": function(){
$(this).dialog( "close" );
}
}
});
}
/**
* Adjust datatable column size
*

View File

@ -74,6 +74,12 @@ function onlogin(data, txtStatus) {
window.location = 'help.php';
}
// Set user name cookie
var usrName = $("#login input[name='username']").val();
var exDate = new Date();
exDate.setTime(exDate.getTime() + (240 * 60 * 1000));
$.cookie('xcat_username', usrName, { expires: exDate });
// Set the logonflag
$.cookie('logonflag', 'yes', {
path : '/xcat',

View File

@ -61,7 +61,8 @@ sub process_request {
'rinstall' => \&web_rinstall,
'addnode' => \&web_addnode,
'graph' => \&web_graphinfo,
'getdefaultuserentry' => \&web_getdefaultuserentry
'getdefaultuserentry' => \&web_getdefaultuserentry,
'passwd' => \&web_passwd
);
#check whether the request is authorized or not
@ -1973,13 +1974,12 @@ sub web_addnode{
`/bin/grep '$hcpname' /etc/hosts`;
if ($?){
open(OUTPUTFILE, '>>/etc/hosts');
print OUTPUTFILE "$ip $hcpname\n";
print OUTPUTFILE "$ip $hcpname\n";
close(OUTPUTFILE);
}
if ('hmc' eq $nodetype){
`chdef -t node -o $hcpname username=$username password=$passwd mgt=hmc nodetype=$nodetype groups=all`
}
else{
if ('hmc' eq $nodetype) {
`chdef -t node -o $hcpname username=$username password=$passwd mgt=hmc nodetype=$nodetype ip=$ip groups=all`
} else {
`chdef -t node -o $hcpname username=$username password=$passwd mgt=blade mpa=$hcpname nodetype=$nodetype id=0 groups=mm,all`
}
return;
@ -2225,4 +2225,21 @@ sub web_getdefaultuserentry {
$callback->( { data => $entry } );
}
sub web_passwd() {
my ( $request, $callback, $sub_req ) = @_;
# Get current and new passwords
my $user = $request->{arg}->[1];
my $newPassword = $request->{arg}->[2];
# Generate encrypted password
my $encrypted = `perl -e "print crypt($newPassword, 03162012)"`;
# Save in xCAT passwd table
`chtab username=$user passwd.key=xcat passwd.password=$encrypted`;
my $info = "Password successfully changed";
$callback->( { info => $info } );
return;
}
1;