');
- 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 = '
';
- for(var i in fields) {
- temprow += '
' + fields[i] + '
';
- }
- 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 = '
';
- 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 = $('');
+ var scanButton = createButton('Scan');
+ for (var i in hmcs) {
+ hmcSelect.append('');
+ }
+
+ $('#nodeSettings').append($('').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 = $('');
+ var rTable = $('
');
+
+ // 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 = $('').append('
');
+ for(var i in fields) {
+ tHead.append('
' + fields[i] + '
');
+ }
+ rTable.append(tHead);
+
+ // Add table body
+ var tBody = $('');
+ rTable.append(tBody);
+ for (var i = 1; i < lines.length; i++) {
+ var row = $('
');
+
+ // 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('
');
+
+ // Go through each field and add it to the row as a column
+ for(var j = 0; j < cols; j++) {
+ var col = $('
');
+ if (fields[j]) {
+ if (j == 1)
+ col.append('');
+ 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');
}
});
diff --git a/xCAT-UI/js/custom/ipmi.js b/xCAT-UI/js/custom/ipmi.js
index eb32950eb..da99f1d0b 100644
--- a/xCAT-UI/js/custom/ipmi.js
+++ b/xCAT-UI/js/custom/ipmi.js
@@ -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 = $('');
// 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 = $('');
- var info = createInfoBar('Add a node range');
- diag.append(info);
+ var dialog = $('');
+ var info = createInfoBar('Add a iDataPlex node');
+ dialog.append(info);
// Create node inputs
- var nodeFieldSet = $('');
- var legend = $('');
- nodeFieldSet.append(legend);
- diag.append(nodeFieldSet);
-
- var nodeInputs = '' +
- '' +
- '' +
- '';
- nodeFieldSet.append(nodeInputs);
-
- var bmcFieldSet = $('');
- var legend = $('');
- bmcFieldSet.append(legend);
- diag.append(bmcFieldSet);
-
- // Create BMC inputs
- var bmcInputs = '' +
- '' +
- '';
- bmcFieldSet.append(bmcInputs);
+ dialog.append($(''));
+ dialog.append($(''));
+ dialog.append($(''));
+ dialog.append($(''));
- 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] + ' ';
}
- if (message) {
+ // Show return message
+ if (message)
$('#addIdplx').prepend(createInfoBar(message));
- }
}
});
}
diff --git a/xCAT-UI/js/custom/kvm.js b/xCAT-UI/js/custom/kvm.js
index bd48a855a..1388bde83 100644
--- a/xCAT-UI/js/custom/kvm.js
+++ b/xCAT-UI/js/custom/kvm.js
@@ -66,7 +66,6 @@ kvmPlugin.prototype.loadInventory = function(data) {
$('#' + tabId).find('img').remove();
// Create division to hold inventory
- var invDivId = tabId + 'Inventory';
var invDiv = $('');
// 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 = $('');
@@ -477,44 +476,25 @@ kvmPlugin.prototype.loadResources = function() {
/**
* Add node range
- *
- * @return Nothing
*/
kvmPlugin.prototype.addNode = function() {
- var diag = $('');
- var info = createInfoBar('Add a node range');
- diag.append(info);
+ var dialog = $('');
+ var info = createInfoBar('Add a KVM node');
+ dialog.append(info);
// Create node inputs
- var nodeFieldSet = $('');
- var legend = $('');
- nodeFieldSet.append(legend);
- diag.append(nodeFieldSet);
-
- var nodeInputs = '' +
- '' +
- '' +
- '';
- nodeFieldSet.append(nodeInputs);
+ dialog.append($(''));
+ dialog.append($(''));
+ dialog.append($(''));
+ dialog.append($(''));
- var bmcFieldSet = $('');
- var legend = $('');
- bmcFieldSet.append(legend);
- diag.append(bmcFieldSet);
-
- // Create BMC inputs
- var bmcInputs = '' +
- '' +
- '';
- 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] + ' ';
}
- if (message) {
- $('#addIdplx').prepend(createInfoBar(message));
- }
+ // Show return message
+ if (message)
+ $('#addKvm').prepend(createInfoBar(message));
}
});
}
diff --git a/xCAT-UI/js/custom/zvm.js b/xCAT-UI/js/custom/zvm.js
index 5befb9c14..d3ac8e98f 100644
--- a/xCAT-UI/js/custom/zvm.js
+++ b/xCAT-UI/js/custom/zvm.js
@@ -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 = $('');
fieldSet.append(legend);
var oList = $('');
- 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 = $('
Type
Address
ID
Base
Dedicated
Affinity
');
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 = $('
Virtual Device #
Adapter Type
Port Name
# of Devices
LAN Name
');
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 = $('');
- var info = createInfoBar('Add a node range');
+ var addNodeForm = $('');
+ var info = createInfoBar('Add a z/VM node range');
addNodeForm.append(info);
- addNodeForm.append('');
- addNodeForm.append('');
- addNodeForm.append('');
- addNodeForm.append('');
+ addNodeForm.append('');
+ addNodeForm.append('');
+ addNodeForm.append('');
+ addNodeForm.append('');
+ addNodeForm.append('');
// 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);
diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js
index afa7d1a4b..26b648802 100644
--- a/xCAT-UI/js/nodes/nodes.js
+++ b/xCAT-UI/js/nodes/nodes.js
@@ -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
diff --git a/xCAT-UI/js/service/service.js b/xCAT-UI/js/service/service.js
index b10ddff60..b7c35e970 100644
--- a/xCAT-UI/js/service/service.js
+++ b/xCAT-UI/js/service/service.js
@@ -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',
diff --git a/xCAT-UI/js/srv_xcatauth.js b/xCAT-UI/js/srv_xcatauth.js
index 3ec07eede..a22fc56ad 100644
--- a/xCAT-UI/js/srv_xcatauth.js
+++ b/xCAT-UI/js/srv_xcatauth.js
@@ -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');
diff --git a/xCAT-UI/js/ui.js b/xCAT-UI/js/ui.js
index 7e5b7c8d6..563bd11c6 100644
--- a/xCAT-UI/js/ui.js
+++ b/xCAT-UI/js/ui.js
@@ -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 = $('');
+ var dialog = $('');
var info = createInfoBar('Select the settings you desire');
- settingsForm.append(info);
+ dialog.append(info);
+
+ var style = {
+ 'color': 'blue',
+ 'cursor': 'pointer',
+ 'padding': '5px'
+ };
+
+ var changeThemeOption = $('