From 3db536fdca59c57c447d97d256cf227df9739c25 Mon Sep 17 00:00:00 2001 From: phamt Date: Thu, 21 Apr 2011 19:09:11 +0000 Subject: [PATCH] Started feature to install Ganglia onto nodes. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9370 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/monitor/gangliamon.js | 142 +++++++++++++++++++++++++++---- xCAT-UI/js/monitor/monitor.js | 8 +- 2 files changed, 129 insertions(+), 21 deletions(-) diff --git a/xCAT-UI/js/monitor/gangliamon.js b/xCAT-UI/js/monitor/gangliamon.js index 7afb91e4d..7962d5932 100644 --- a/xCAT-UI/js/monitor/gangliamon.js +++ b/xCAT-UI/js/monitor/gangliamon.js @@ -203,9 +203,9 @@ function loadGroups4Ganglia(data) { var info = $('
'); info.append(''); var msg = $('

'); - msg.append('Review the nodes that are monitored by Ganglia. You can turn on Ganglia monitoring on a node by selecting it and clicking on Monitor. If you are satisfied with the nodes you want to monitor, '); + msg.append('Review the nodes that are monitored by Ganglia. Install Ganglia onto a node you want to monitor by selecting it and clicking on Install. Turn on Ganglia monitoring for a node by selecting it and clicking on Monitor. If you are satisfied with the nodes you want to monitor, '); msg.append(gangliaLnk); - msg.append(' to open Ganglia page.'); + msg.append(' to open the Ganglia page.'); info.append(msg); info.css('margin-bottom', '10px'); $('#nodes').append(info); @@ -376,7 +376,7 @@ function loadNodes4Ganglia(data) { 'node', 'status', 'power', - 'ganglia'); + 'ganglia'); // Create a datatable var gangliaTable = new DataTable(gangliaTableId); @@ -481,6 +481,15 @@ function loadNodes4Ganglia(data) { monitorNode(tgtNodes, 'off'); } }); + + // Install Ganglia + var installLnk = $('Install'); + installLnk.click(function() { + var tgtNodes = getNodesChecked(gangliaTableId); + if (tgtNodes) { + openInstallDialog(tgtNodes); + } + }); // Power actions var monitorActions = [ monitorOnLnk, monitorOffLnk ]; @@ -488,7 +497,7 @@ function loadNodes4Ganglia(data) { // Create an action menu var actionsDIV = $('
'); - var actions = [ [ powerLnk, powerActionMenu ], [ monitorLnk, monitorActionMenu ] ]; + var actions = [ [ powerLnk, powerActionMenu ], [ monitorLnk, monitorActionMenu ], installLnk ]; var actionMenu = createMenu(actions); actionMenu.superfish(); actionsDIV.append(actionMenu); @@ -546,33 +555,33 @@ function loadNodes4Ganglia(data) { powerCol.find('span a').bind('click', function(event) { refreshPowerStatus(group, gangliaTableId); }); - gangliaCol.bind('click', function(event) { + gangliaCol.find('span a').bind('click', function(event) { refreshGangliaStatus(group); }); // Create tooltip for status - var pingTip = createStatusToolTip(); - pingCol.find('span').append(pingTip); - pingCol.find('span a').tooltip({ + var tooltipConf = { position: "center right", offset: [-2, 10], effect: "fade", opacity: 0.8, relative: true, predelay: 800 - }); + }; + + var pingTip = createStatusToolTip(); + pingCol.find('span').append(pingTip); + pingCol.find('span a').tooltip(tooltipConf); // Create tooltip for power var powerTip = createPowerToolTip(); powerCol.find('span').append(powerTip); - powerCol.find('span a').tooltip({ - position: "center right", - offset: [-2, 10], - effect: "fade", - opacity: 0.8, - relative: true, - predelay: 800 - }); + powerCol.find('span a').tooltip(tooltipConf); + + // Create tooltip for ganglia + var gangliaTip = createGangliaToolTip(); + gangliaCol.find('span').append(gangliaTip); + gangliaCol.find('span a').tooltip(tooltipConf); /** * Get node and ganglia status @@ -1003,4 +1012,103 @@ function addNodes2GangliaTable(data) { success : loadGangliaStatus }); +} + +/** + * Create a tool tip for ganglia status + * + * @return Tool tip + */ +function createGangliaToolTip() { + // Create tooltip container + var toolTip = $('
Click here to refresh the Ganglia status
').css({ + 'width': '150px' + }); + return toolTip; +} + +/** + * Open dialog to install Ganglia on a given node + * + * @param node + * Node to install Ganglia on + * @return Nothing + */ +function openInstallDialog(node) { + var form = $('
'); + + // Create info bar + var info = createInfoBar('Select the directory containing the Ganglia packages to install onto the given node range. Be aware that the Ganglia packages must be present in the /install directory.'); + form.append(info); + + // Create node range input + var nr = $('
'); + var nrLabel = $('').css('vertical-align', 'middle'); + var nrInput = $('').val(node); + nr.append(nrLabel); + nr.append(nrInput); + form.append(nr); + + // Create Ganglia directory input + var directory = $('
'); + var dirLabel = $('').css('vertical-align', 'middle'); + var dirInput = $('').css('width', '300px'); + directory.append(dirLabel); + directory.append(dirInput); + form.append(directory); + + // Create button to browse for Ganglia directory + var browseBtn = createButton('Browse'); + directory.append(browseBtn); + // Browse server directory and files + browseBtn.serverBrowser({ + onSelect : function(path) { + $('input[name="directory"]').val(path); + }, + onLoad : function() { + return $('input[name="directory"]').val(); + }, + knownExt : [ 'exe', 'js', 'txt' ], + knownPaths : [ { + text : 'Install', + image : 'desktop.png', + path : '/install' + } ], + imageUrl : 'images/serverbrowser/', + systemImageUrl : 'images/serverbrowser/', + handlerUrl : 'lib/getpath.php', + title : 'Browse', + requestMethod : 'POST', + width : '500', + height : '300', + basePath : '/install' // Limit user to only install directory + }); + + // Open dialog to install Ganglia + form.dialog({ + modal: true, + width: 600, + buttons: { + 'Install': function(){ + installGanglia($('input[name="node"]').val(), $('input[name="directory"]').val()); + $(this).dialog('close'); + }, + 'Cancel': function(){ + $(this).dialog('close'); + } + } + }); +} + +/** + * Install Ganglia on a given node + * + * @param node + * Node to install Ganglia on + * @param directory + * Directory containing Ganglia packages + * @return Nothing + */ +function installGanglia(node, directory) { + } \ No newline at end of file diff --git a/xCAT-UI/js/monitor/monitor.js b/xCAT-UI/js/monitor/monitor.js index dc308a87b..5a25c12a1 100644 --- a/xCAT-UI/js/monitor/monitor.js +++ b/xCAT-UI/js/monitor/monitor.js @@ -159,7 +159,7 @@ function loadMonitorPage() { monTableBody.find('td:nth-child(1)').css('white-space', 'nowrap'); // Append info bar - $('#monitorTab div').empty().append(createInfoBar('Select a monitoring tool to use.')); + $('#monitorTab div').empty().append(createInfoBar('Select a monitoring tool to use')); $('#monitorTab .form').append(monTable); // Open monitoring tool onclick @@ -289,7 +289,7 @@ function loadUnfinish(monitorName, tab) { * * @return Nothing */ -function toggleMonitor() { +function toggleMonitor() { // Get the name of the monitoring tool var name = $(this).attr('name'); // Get the status to toggle to, either on or off @@ -300,8 +300,8 @@ function toggleMonitor() { if (status == 'Off') { command = 'monstop' ; } - - $.ajax( { + + $.ajax({ url : 'lib/cmd.php', dataType : 'json', data : {