'));
+ imgFS.append(imgAttr);
+
+ // Select group name
+ var group = $('').append('');
+ var groupSelect = $('');
+ group.append(groupSelect);
var groupNames = $.cookie('groups');
if (groupNames) {
- groupHtml += '';
- }
- groupHtml += '
';
-
- // Select nodes
- var nodesHtml = '
Select a group to view its nodes
';
+ var tmp = groupNames.split(',');
+ groupSelect.append(''); // Append empty group name
+ for (var i in tmp)
+ groupSelect.append('');
+ }
+ nodeAttr.append(group);
+ // Select node from table
+ var nodes = $('');
+ var nodesTable = $('
';
+ var arch = $('').append('');
var archName = $.cookie('osarchs');
if (archName) {
- archHtml += '';
+ var archSelect = $('');
+ arch.append(archSelect);
+
+ var tmp = archName.split(',');
+ for (var i in tmp)
+ archSelect.append('');
} else {
- archHtml += '';
+ arch.append('');
}
- archHtml += '
';
+ imgAttr.append(arch);
- // Add static input part
- var staticHtml = '
' +
- '' +
- '' +
- '' +
- '' +
- '';
- return groupHtml + nodesHtml + archHtml + staticHtml;
+ imgAttr.append('');
+ imgAttr.append('');
+ imgAttr.append('');
+ imgAttr.append('');
+ imgAttr.append('');
+ imgAttr.append('');
+
+ // 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;
}
/**
- * Get needed fields for provsioning and send command to server
+ * Provision node
*
- * @param plugin
- * Plugin name of platform to provision
+ * @param tabId
+ * Provision tab ID
* @return Nothing
*/
-function quickProvision(plugin){
- var errorMessage = '';
- var argsArray = new Array();
- var nodesName = '';
- var provisionArg = '';
- var provisionFrame;
- var imageName = '';
- var url = '';
- var softwareArg = '';
- var containerId = plugin + 'ProvisionTab';
- $('#' + containerId + ' .ui-state-error').remove();
+function provisionNode(tabId) {
+ var plugin = tabId;
+ var errorMessage = "";
+ var args = new Array();
+ var node = "";
- $('#' + containerId + ' input[type!="checkbox"]').each(function() {
+ // Delete any existing warnings
+ $('#' + tabId + ' .ui-state-error').remove();
+
+ // Go through each input
+ $('#' + tabId + ' input[type!="checkbox"]').each(function() {
if (!$(this).val()) {
errorMessage = 'Please provide a value for each missing field!';
return false;
} else {
- argsArray.push($(this).val());
+ args.push($(this).val());
}
});
+ // Do not continue if error was found
if (errorMessage) {
- $('#' + containerId).prepend('
' + errorMessage + '
');
+ $('#' + tabId).prepend(createWarnBar(errorMessage));
return;
}
- // If jumped from nodes page, get node names
- if ('quick' == plugin) {
- nodesName = argsArray.shift();
- }
- // Select platform, get node names from table checkbox
- else {
- // Should unshift the arch type
- argsArray.unshift($('#' + containerId + ' #arch').val());
- nodesName = getCheckedByObj($('#' + containerId + ' #' + plugin + 'SelectNodesTable'));
+ // 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'));
}
- if (!nodesName) {
- $('#' + containerId).prepend('
Please select a node
');
+ // Do not continue if a node is not given
+ if (!node) {
+ $('#' + tabId).prepend(createWarnBar('Please select a node!'));
return;
}
- softwareArg = getCheckedByObj($('#' + containerId + ' #advoption'));
- imageName = $('#' + containerId + ' #' + plugin + 'image').val();
- provisionArg = argsArray.join(',');
+ var software = getCheckedByObj($('#' + tabId + ' #advanced'));
+ var imageName = $('#' + tabId + ' select[name=image]').val();
+ var provision = args.join(',');
- url = 'lib/cmd.php?cmd=webrun&tgt=&args=provision;' + nodesName + ';' + imageName + ';' +
- provisionArg + ';' + softwareArg + '&msg=&opts=flush';
-
- // Show output
- var deployDia = $('');
- deployDia.append(createLoader()).append(' ');
- deployDia.append('');
- deployDia.dialog({
- modal: true,
- width: 600,
- height: 480,
- title:'Provision return',
- close: function(){$(this).remove();},
- buttons: {
- Close : function(){$(this).dialog('close');}
- }
- });
-
- provisionStopCheck();
+ var url = 'lib/cmd.php?cmd=webrun&tgt=&args=provision;' +
+ node + ';' + imageName + ';' + provision + ';' + software + '&msg=&opts=flush';
+ $('#' + tabId).prepend(createIFrame(url));
}
/**
- * Create provisioning advance option
+ * Create advance option
*
* @param imagename
* Image name
- * @param plugin
- * Plugin name of platform to provision
+ * @param outId
+ * Output area ID
* @return Nothing
*/
-function provAdvOption(imagename, plugin) {
+function createAdvancedOptions(image, outId) {
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'lsdef',
tgt : '',
- args : '-t;osimage;' + imagename + ';-i;osname,provmethod',
- msg : plugin
+ args : '-t;osimage;' + image + ';-i;osname,provmethod',
+ msg : outId
},
success : function(data) {
- var containerId = data.msg + 'ProvisionTab';
- var i = 0;
+ var outId = data.msg;
var osName = '';
var provMethod = '';
- var tempStr = '';
+ var tmpStr = '';
var position = 0;
- for (i = 0; i < data.rsp.length; i++) {
- tempStr = data.rsp[i];
- if (tempStr.indexOf('osname') != -1) {
- position = tempStr.indexOf('=');
- osName = tempStr.substr(position + 1);
+
+ 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);
}
- if (tempStr.indexOf('provmethod') != -1) {
- position = tempStr.indexOf('=');
- provMethod = tempStr.substr(position + 1);
+ if (tmpStr.indexOf('provmethod') != -1) {
+ position = tmpStr.indexOf('=');
+ provMethod = tmpStr.substr(position + 1);
}
}
- $('#' + containerId + ' #advoption').empty();
- if ('aix' == osName.toLowerCase()) {
+ $('#' + outId + ' #advanced').remove();
+ if (osName.toLowerCase() == 'aix')
return;
- }
- if ('install' == provMethod){
- $('#' + containerId + ' #advoption').html('Install Ganglia.');
- }
- }
+ if (provMethod == 'install') {
+ // Create advanced fieldset
+ var advancedFS = $('').append($(''));
+ $('#' + outId + ' div.form fieldset:eq(1)').after(advancedFS);
+
+ advancedFS.append('
Install Ganglia monitoring
');
+ }
+ }
});
}
/**
- * Refresh nodes area base on group selected
+ * Create nodes table
*
- * @param groupName
+ * @param group
* Group name
- * @param areaId
- * Area ID to refresh
+ * @param outId
+ * Output section ID
* @return Nothing
*/
-function createNodesArea(groupName, areaId) {
+function createNodesTable(group, outId) {
// Get group nodes
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'nodels',
- tgt : groupName,
+ tgt : group,
args : '',
- msg : areaId
+ msg : outId
},
success : function(data) {
- var areaObj = $('#' + data.msg);
+ var outId = $(data.msg);
var nodes = data.rsp;
- var index;
- var nodesHtml = '
';
- nodesHtml += '
Node
';
- for (index in nodes) {
- var node = nodes[index][0];
- if (!node) {
- continue;
- }
- nodesHtml += '
' + node + '
';
- }
- nodesHtml += '
';
- areaObj.empty().append(nodesHtml);
- if (index > 10) {
- areaObj.css('height', '300px');
- } else {
- areaObj.css('height', 'auto');
+ // Create table to hold nodes
+ var nTable = $('
');
+ var tHead = $('
Node
');
+ nTable.append(tHead);
+ var 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)
+ continue;
+ // Insert node into table
+ tBody.append('
' + node + '
');
}
- } // End of function(data)
+
+ outId.empty().append(nTable);
+
+ if (index > 10)
+ outId.css('height', '300px');
+ else
+ outId.css('height', 'auto');
+ }
});
}
-function provisionStopCheck(){
- var content = $('#provisionFrame').contents().find('body').text();
- if (content.indexOf('provision stop') != -1) {
- $('#deployDia img').remove();
- clearTimeout(provisionClock);
- } else {
- provisionClock = setTimeout('provisionStopCheck()', 5000);
- }
-}
-
/**
* Get select element names
*
diff --git a/xCAT-UI/js/custom/hmc.js b/xCAT-UI/js/custom/hmc.js
index 38aae66e8..33e7df115 100644
--- a/xCAT-UI/js/custom/hmc.js
+++ b/xCAT-UI/js/custom/hmc.js
@@ -193,17 +193,14 @@ hmcPlugin.prototype.loadProvisionPage = function(tabId) {
var provForm = $('');
// Create info bar
- var infoBar = createInfoBar('Provision a node on System p.');
+ var infoBar = createInfoBar('Provision a node on System p');
provForm.append(infoBar);
// Append to provision tab
$('#' + tabId).append(provForm);
-
- /**
- * Create provision new node division
- */
- // You should copy whatever is in this function, put it here, and customize it
- createProvision('hmc', provForm);
+
+ // Append provisioning section for HMC
+ appendProvisionSection('hmc', provForm);
};
/**
diff --git a/xCAT-UI/js/custom/ipmi.js b/xCAT-UI/js/custom/ipmi.js
index 426751db4..d2a5b65b6 100644
--- a/xCAT-UI/js/custom/ipmi.js
+++ b/xCAT-UI/js/custom/ipmi.js
@@ -336,7 +336,7 @@ function createIpmiProvisionExisting(inst) {
// Create provision existing division
var provExisting = $('');
- // Create VM fieldset
+ // Create node fieldset
var nodeFS = $('');
var nodeLegend = $('');
nodeFS.append(nodeLegend);
diff --git a/xCAT-UI/js/provision/provision.js b/xCAT-UI/js/provision/provision.js
index eb00921ba..aab9e5b1b 100644
--- a/xCAT-UI/js/provision/provision.js
+++ b/xCAT-UI/js/provision/provision.js
@@ -172,6 +172,6 @@ function loadProvisionPage() {
var provForm = $('');
$('#quickProvisionTab').append(provForm);
- createProvision('quick', provForm);
+ appendProvisionSection('quick', provForm);
}
}
\ No newline at end of file