diff --git a/xCAT-UI/js/custom/blade.js b/xCAT-UI/js/custom/blade.js index 96ba4afca..b181089f6 100644 --- a/xCAT-UI/js/custom/blade.js +++ b/xCAT-UI/js/custom/blade.js @@ -608,7 +608,7 @@ function createBladeProvisionExisting(inst) { // Create provision existing division var provExisting = $('
'); - // Create VM fieldset + // Create node fieldset var nodeFS = $('
'); var nodeLegend = $('Node'); nodeFS.append(nodeLegend); diff --git a/xCAT-UI/js/custom/customUtils.js b/xCAT-UI/js/custom/customUtils.js index 1c92d79bb..031f51d5e 100644 --- a/xCAT-UI/js/custom/customUtils.js +++ b/xCAT-UI/js/custom/customUtils.js @@ -1,5 +1,3 @@ -var provisionClock; - /** * Create nodes datatable for a given group * @@ -385,45 +383,33 @@ function createProvisionNew(plugin, inst) { } /** - * Create provision node division + * Create section to provision node * * @param plugin - * Plugin name to create division for + * Plugin name * @param container - * Container to hold provisioning form + * Container to hold provision section * @return Nothing */ -function createProvision(plugin, container){ - // Group, nodes, arch - if ('quick' == plugin) { - container.append(createProvWithUrl()); - } else { - container.append(createProvNoUrl(plugin)); - container.find('#' + plugin + 'group').bind('change', function() { - var pluginName = $(this).attr('id').replace('group', ''); - $('#' + pluginName + 'SelectNodesTable').html(''); - createNodesArea($(this).val(), pluginName + 'SelectNodesTable'); - }); - } - - // Advanced options - container.append('
'); +function appendProvisionSection(plugin, container) { + // Get provision tab ID + var tabId = container.parents('.tab').attr('id'); + if (plugin == 'quick') + appendProvision4Url(container); // For provisioning based on argmunents found in URL + else + appendProvision4NoUrl(plugin, container); + // Add provision button var provisionBtn = createButton('Provision'); provisionBtn.bind('click', function(){ - var plugin = $(this).parent().parent().attr('id').replace('ProvisionTab', ''); - quickProvision(plugin); + provisionNode(tabId); }); - provisionBtn.hide(); container.append(provisionBtn); // Bind image select to change event - container.find('#' + plugin + 'image').bind('change', function(){ - var temp = $(this).attr('id'); - temp = temp.replace('image', ''); - $('#' + temp + 'ProvisionTab #advoption').html(''); - provAdvOption($(this).val(), temp); + container.find('select[name=image]').bind('change', function() { + createAdvancedOptions($(this).val(), tabId); }); $.ajax({ @@ -433,18 +419,16 @@ function createProvision(plugin, container){ cmd : 'lsdef', tgt : '', args : '-t;osimage', - msg : plugin + msg : tabId }, success : function(data){ - var containerId = data.msg + 'ProvisionTab'; + var tabId = data.msg; var i = 0; var imageName = 0; var position = 0; - var imageSelect = $('#' + containerId + ' #' + data.msg + 'image'); - $('#' + containerId + ' img').remove(); if (!data.rsp.length) { - $('#' + containerId).prepend(createWarnBar('Please run copycds and genimage in provision page before continuing!')); + $('#' + tabId).prepend(createWarnBar('Please run copycds and genimage in provision page before continuing!')); return; } @@ -453,295 +437,307 @@ function createProvision(plugin, container){ position = imageName.indexOf(' '); imageName = imageName.substr(0, position); - imageSelect.append($('')); + $('#' + tabId + ' select[name=image]').append($('')); } // Trigger select change event - imageSelect.trigger('change'); + $('#' + tabId + ' select[name=image]').trigger('change'); // Show provision button - $('#' + containerId + ' button').show(); + $('#' + tabId + ' button').show(); } }); } /** - * Create provision node division using URL + * Create provision node section using URL * - * @returns Provisiong node division + * @param container + * Container to hold provision section + * @returns Nothing */ -function createProvWithUrl(){ - var queryStr = window.location.search; - var argArray = queryStr.substr(1).split('&'); - var tempHash = new Object(); - var i = 0; - var tempArray; +function appendProvision4Url(container){ + var query = window.location.search; + var args = query.substr(1).split('&'); + var parms = new Object(); + var tmp; - var provHtml = ''; + // Turn URL arguments into hash array + for (var i = 0; i < args.length; i++) { + tmp = args[i].split('='); + parms[tmp[0]] = tmp[1]; + } var master = ''; + if (parms['master']) + master = parms['master']; + + var nfsserver = ''; + if (parms['nfsserver']) + nfsserver = parms['nfsserver']; + var tftpserver = ''; - var nfsserver = ''; - for (i = 0; i < argArray.length; i++) { - tempArray = argArray[i].split('='); - tempHash[tempArray[0]] = tempArray[1]; - } + if (parms['tftpserver']) + tftpserver = parms['tftpserver']; - provHtml += '
'; - provHtml += '
'; - provHtml += '
' + - '
' + - '
' ; + container.append('
'); + container.append('
'); + container.append('
'); + container.append( '
'); + container.append('
'); + container.append('
'); + container.append('
'); + container.append('
'); - if (tempHash['master']) { - master = tempHash['master']; - } - - if (tempHash['nfsserver']) { - nfsserver = tempHash['nfsserver']; - } - - if (tempHash['tftpserver']) { - tftpserver = tempHash['tftpserver']; - } - - provHtml += '
'; - provHtml += '
'; - provHtml += '
'; - - return provHtml; + return; } /** - * Create provision node division without using URL + * Create section to provision node using no URL * * @param plugin - * Plugin name to create division for - * @returns {String} + * Create provision section for given plugin + * @param container + * Container to hold provision section + * @returns Nothing */ -function createProvNoUrl(plugin){ - // Select group - var groupHtml = '
'; +function appendProvision4NoUrl(plugin, container){ + // Get provision tab ID + var tabId = container.parents('.tab').attr('id'); + + // Create node fieldset + var nodeFS = $('
'); + var nodeLegend = $('Node'); + nodeFS.append(nodeLegend); + container.append(nodeFS); + + var nodeAttr = $('
'); + nodeFS.append($('
')); + nodeFS.append(nodeAttr); + + // Create image fieldset + var imgFS = $('
'); + var imgLegend = $('Image'); + imgFS.append(imgLegend); + container.append(imgFS); + + var imgAttr = $('
'); + imgFS.append($('
')); + 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 = $('

Select a group to view its nodes

'); + nodes.append(nodesTable); + nodeAttr.append(nodes); + // Select architecture - var archHtml = '
'; + 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($('Advanced')); + $('#' + 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 += ''; - for (index in nodes) { - var node = nodes[index][0]; - if (!node) { - continue; - } - nodesHtml += ''; - } - nodesHtml += '
Node
' + node + '
'; - 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 = $('Node'); 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