From 8c8d178eb31d13f90835283c241dc3f5db09a931 Mon Sep 17 00:00:00 2001 From: phamt Date: Fri, 4 May 2012 14:23:08 +0000 Subject: [PATCH] Formatted code. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12525 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/nodes/nodes.js | 204 ++-- xCAT-UI/js/nodes/nodeset.js | 656 ++++++------ xCAT-UI/js/nodes/physical.js | 1739 ++++++++++++++++---------------- xCAT-UI/js/nodes/rnetboot.js | 356 ++++--- xCAT-UI/js/nodes/updatenode.js | 732 +++++++------- 5 files changed, 1776 insertions(+), 1911 deletions(-) diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js index 6cf6e3aaa..1a7f80c30 100644 --- a/xCAT-UI/js/nodes/nodes.js +++ b/xCAT-UI/js/nodes/nodes.js @@ -47,8 +47,6 @@ function getNodesTableId() { /** * Load nodes page - * - * @return Nothing */ function loadNodesPage() { // If groups are not already loaded @@ -97,20 +95,18 @@ function loadNodesPage() { /** * Show cluster summary in pie charts * - * @param groupName - * Group name - * @return Nothing + * @param groupName Group name */ function loadPieSummary(groupName){ var summaryTable = '' + '' + - '' + - '' + - '' + + '' + + '' + + '' + '' + '' + - '' + - '' + + '' + + '' + '
'; $('#summaryTab').append(summaryTable); $('#summaryTab .summarypie').append(createLoader()); @@ -136,11 +132,8 @@ function loadPieSummary(groupName){ /** * Get nodes information and draw pie chart * - * @param index - * Node index - * @param valuePair - * Node information key value pairing - * @return Nothing + * @param index Node index + * @param valuePair Node information key value pairing */ function drawPieSummary(index, valuePair){ var position = 0; @@ -189,9 +182,7 @@ function drawPieSummary(index, valuePair){ /** * Load groups * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ function loadGroups(data) { // Remove loader @@ -231,13 +222,9 @@ function loadGroups(data) { /** * Empty the nodes area and add three tabs for nodes result * - * @param targetgroup - * The name range for nodels command - * @param cmdargs - * Filter arguments for nodels command - * @param message - * The useful information from the HTTP request - * @return Nothing + * @param targetgroup The name range for nodels command + * @param cmdargs Filter arguments for nodels command + * @param message The useful information from the HTTP request */ function drawNodesArea(targetgroup, cmdargs, message){ // Clear nodes division @@ -279,9 +266,7 @@ function drawNodesArea(targetgroup, cmdargs, message){ /** * Get node definitions for first 50 nodes * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ success : function(data) { var rsp = data.rsp; @@ -404,9 +389,7 @@ function mkAddNodeLink() { /** * Set node attributes and open dialog * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ success : function(data) { // Save node attributes @@ -481,9 +464,7 @@ function mkAddNodeLink() { /** * Load nodes belonging to a given group * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ function loadNodes(data) { // Clear the tab before inserting the table @@ -1062,8 +1043,7 @@ function loadNodes(data) { /** * Get nodes currently shown in datatable * - * @param tableId - * Datatable ID + * @param tableId Datatable ID * @return String of nodes shown */ function getNodesShown(tableId) { @@ -1089,9 +1069,7 @@ function getNodesShown(tableId) { /** * Get attributes for nodes not yet initialized * - * @param group - * Group name - * @return Nothing + * @param group Group name */ function getNodeAttrs(group) { // Get datatable headers and rows @@ -1154,9 +1132,7 @@ function getNodeAttrs(group) { /** * Add nodes to datatable * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ function addNodes2Table(data) { // Data returned @@ -1386,9 +1362,7 @@ function addNodes2Table(data) { /** * Load the status of Ganglia for a given group * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ function loadGangliaStatus(data) { // Get datatable @@ -1419,9 +1393,7 @@ function loadGangliaStatus(data) { /** * Refresh the status of Ganglia for each node * - * @param group - * Group name - * @return Nothing + * @param group Group name */ function refreshGangliaStatus(group) { // Show ganglia loader @@ -1449,9 +1421,7 @@ function refreshGangliaStatus(group) { /** * Load power status for each node * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ function loadPowerStatus(data) { var dTable = $('#' + nodesTableId).dataTable(); @@ -1480,11 +1450,8 @@ function loadPowerStatus(data) { /** * Refresh power status for each node * - * @param group - * Group name - * @param tableId - * Table to update node status - * @return Nothing + * @param group Group name + * @param tableId Table to update node status */ function refreshPowerStatus(group, tableId) { // Show power loader @@ -1512,9 +1479,7 @@ function refreshPowerStatus(group, tableId) { /** * Load node status for each node * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ function loadNodeStatus(data) { var dTable = $('#' + nodesTableId).dataTable(); @@ -1545,11 +1510,8 @@ function loadNodeStatus(data) { /** * Refresh ping status for each node * - * @param group - * Group name - * @param tableId - * Table to update node status - * @return Nothing + * @param group Group name + * @param tableId Table to update node status */ function refreshNodeStatus(group, tableId) { // Show ping loader @@ -1577,9 +1539,7 @@ function refreshNodeStatus(group, tableId) { /** * Load inventory for given node * - * @param e - * Windows event - * @return Nothing + * @param e Windows event */ function loadNode(e) { if (!e) { @@ -1652,9 +1612,7 @@ function loadNode(e) { /** * Unlock a node by setting the ssh keys * - * @param tgtNodes - * Nodes to unlock - * @return Nothing + * @param tgtNodes Nodes to unlock */ function loadUnlockPage(tgtNodes) { // Get nodes tab @@ -1749,9 +1707,7 @@ function loadUnlockPage(tgtNodes) { /** * Load script page * - * @param tgtNodes - * Targets to run script against - * @return Nothing + * @param tgtNodes Targets to run script against */ function loadScriptPage(tgtNodes) { // Get nodes tab @@ -1871,11 +1827,8 @@ function sortAlpha(a, b) { /** * Power on a given node * - * @param node - * Node to power on or off - * @param power2 - * Power node to given state - * @return Nothing + * @param node Node to power on or off + * @param power2 Power node to given state */ function powerNode(node, power2) { // Show power loader @@ -1900,9 +1853,7 @@ function powerNode(node, power2) { /** * Load delete node page * - * @param tgtNodes - * Nodes to delete - * @return Nothing + * @param tgtNodes Nodes to delete */ function loadDeletePage(tgtNodes) { // Get nodes tab @@ -2004,9 +1955,7 @@ function loadDeletePage(tgtNodes) { /** * Update status bar of a given tab * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ function updateStatusBar(data) { // Get ajax response @@ -2084,9 +2033,7 @@ function updateStatusBar(data) { /** * Update power status of a node in the datatable * - * @param data - * Data from HTTP request - * @return Nothing + * @param data Data from HTTP request */ function updatePowerStatus(data) { // Hide power loader @@ -2132,9 +2079,7 @@ function updatePowerStatus(data) { /** * Run a script * - * @param inst - * Remote script tab instance - * @return Nothing + * @param inst Remote script tab instance */ function runScript(inst) { // Get tab ID @@ -2175,10 +2120,8 @@ function runScript(inst) { /** * Get an attribute of a given node * - * @param node - * The node - * @param attrName - * The attribute + * @param node The node + * @param attrName The attribute * @return The attribute of the node */ function getNodeAttr(node, attrName) { @@ -2214,9 +2157,7 @@ function getNodeAttr(node, attrName) { /** * Set a cookie for the OS images * - * @param data - * Data from HTTP request - * @return Nothing + * @param data Data from HTTP request */ function setOSImageCookies(data) { // Get response @@ -2295,9 +2236,7 @@ function setOSImageCookies(data) { /** * Set a cookie for the groups * - * @param data - * Data from HTTP request - * @return Nothing + * @param data Data from HTTP request */ function setGroupsCookies(data) { var rsp = data.rsp; @@ -2307,12 +2246,9 @@ function setGroupsCookies(data) { /** * Find the row index containing a column with a given string * - * @param str - * String to search for - * @param table - * Table to check - * @param col - * Column to find string under + * @param str String to search for + * @param table Table to check + * @param col Column to find string under * @return The row index containing the search string */ function findRow(str, table, col){ @@ -2334,11 +2270,8 @@ function findRow(str, table, col){ /** * Select all checkboxes in the datatable * - * @param event - * Event on element - * @param obj - * Object triggering event - * @return Nothing + * @param event Event on element + * @param obj Object triggering event */ function selectAllCheckbox(event, obj) { // Get datatable ID @@ -2352,9 +2285,7 @@ function selectAllCheckbox(event, obj) { /** * Load rcons page * - * @param tgtNodes - * Targets to run rcons against - * @return Nothing + * @param tgtNodes Targets to run rcons against */ function loadRconsPage(tgtNodes){ var hostName = window.location.host; @@ -2380,8 +2311,7 @@ function loadRconsPage(tgtNodes){ /** * Create a tool tip for comments * - * @param comment - * Comments to be placed in a tool tip + * @param comment Comments to be placed in a tool tip * @return Tool tip */ function createCommentsToolTip(comment) { @@ -2543,9 +2473,7 @@ function createMonitorToolTip() { /** * Open dialog to configure xCAT monitor * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ function openConfXcatMon(data) { // Create info bar @@ -2633,9 +2561,7 @@ function openConfXcatMon(data) { /** * Show chdef output * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ function showChdefOutput(data) { // Get output @@ -2664,9 +2590,7 @@ function showChdefOutput(data) { /** * Set node attributes * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ function setNodeAttrs(data) { // Clear hash table containing definable node attributes @@ -2707,9 +2631,7 @@ function setNodeAttrs(data) { /** * Load set node properties page * - * @param tgtNode - * Target node to set properties - * @return Nothing + * @param tgtNode Target node to set properties */ function editNodeProps(tgtNode) { // Get nodes tab @@ -2845,8 +2767,6 @@ function editNodeProps(tgtNode) { /** * Open set node attributes dialog - * - * @return Nothing */ function openSetAttrsDialog() { // Open new tab @@ -3003,11 +2923,8 @@ function openSetAttrsDialog() { /** * Turn on monitoring for a given node * - * @param node - * Node to monitor on or off - * @param monitor - * Monitor state, on or off - * @return Nothing + * @param node Node to monitor on or off + * @param monitor Monitor state, on or off */ function monitorNode(node, monitor) { // Show ganglia loader @@ -3036,9 +2953,7 @@ function monitorNode(node, monitor) { /** * Start ganglia on a given node range * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ success : function(data) { // Get response @@ -3146,9 +3061,7 @@ function monitorNode(node, monitor) { /** * Install Ganglia on a given node * - * @param node - * Node to install Ganglia on - * @return Nothing + * @param node Node to install Ganglia on */ function installGanglia(node) { var iframe = createIFrame('lib/cmd.php?cmd=webrun&tgt=&args=installganglia;' + node + '&msg=' + node + '&opts=flush'); @@ -3161,9 +3074,7 @@ function installGanglia(node) { /** * After nodes are loaded, load more information based on different hardware architectures * - * @param group - * Group name - * @return Nothing + * @param group Group name */ function advancedLoad(group){ var tempIndex = 0; @@ -3240,9 +3151,7 @@ function advancedLoad(group){ /** * Jump to provision page on-click * - * @param tgtNodes - * Target nodes - * @return Nothing + * @param tgtNodes Target nodes */ function jump2Provision(tgtNodes){ var nodeArray = tgtNodes.split(','); @@ -3318,6 +3227,7 @@ function jump2Provision(tgtNodes){ if (origAttrs[nodeName]['nfsserver']) { nfsserver = origAttrs[nodeName]['nfsserver']; } + window.location.href = 'provision.php?nodes=' + tgtNodes + '&arch=' + archType + '&master=' + master + '&tftpserver=' + tftpserver + '&nfsserver=' + nfsserver; } \ No newline at end of file diff --git a/xCAT-UI/js/nodes/nodeset.js b/xCAT-UI/js/nodes/nodeset.js index 43c6428c0..d49c3871e 100644 --- a/xCAT-UI/js/nodes/nodeset.js +++ b/xCAT-UI/js/nodes/nodeset.js @@ -1,379 +1,375 @@ /** * Load nodeset page * - * @param tgtNodes - * Targets to run nodeset against - * @return Nothing + * @param tgtNodes Targets to run nodeset against */ function loadNodesetPage(tgtNodes) { - // Get OS images - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'tabdump', - tgt : '', - args : 'osimage', - msg : '' - }, + // Get OS images + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'tabdump', + tgt : '', + args : 'osimage', + msg : '' + }, - success : setOSImageCookies - }); + success : setOSImageCookies + }); - // Get nodes tab - var tab = getNodesTab(); + // Get nodes tab + var tab = getNodesTab(); - // Generate new tab ID - var inst = 0; - var tabId = 'nodesetTab' + inst; - while ($('#' + tabId).length) { - // If one already exists, generate another one - inst = inst + 1; - tabId = 'nodesetTab' + inst; - } + // Generate new tab ID + var inst = 0; + var tabId = 'nodesetTab' + inst; + while ($('#' + tabId).length) { + // If one already exists, generate another one + inst = inst + 1; + tabId = 'nodesetTab' + inst; + } - // Open new tab & create nodeset form - var nodesetForm = $('
'); + // Open new tab & create nodeset form + var nodesetForm = $('
'); - // Create status bar - var statBarId = 'nodesetStatusBar' + inst; - var statBar = createStatusBar(statBarId).hide(); - nodesetForm.append(statBar); + // Create status bar + var statBarId = 'nodesetStatusBar' + inst; + var statBar = createStatusBar(statBarId).hide(); + nodesetForm.append(statBar); - // Create loader - var loader = createLoader('nodesetLoader'); - statBar.find('div').append(loader); + // Create loader + var loader = createLoader('nodesetLoader'); + statBar.find('div').append(loader); - // Create info bar - var infoBar = createInfoBar('Set the boot state for a node range'); - nodesetForm.append(infoBar); + // Create info bar + var infoBar = createInfoBar('Set the boot state for a node range'); + nodesetForm.append(infoBar); - // Create target node or group - var tgt = $('
'); - nodesetForm.append(tgt); + // Create target node or group + var tgt = $('
'); + nodesetForm.append(tgt); - // Create boot method drop down - var method = $('
'); - var methodLabel = $(''); - var methodSelect = $(''); - methodSelect.append('' - + '' - + '' - + '' - + '' - ); - method.append(methodLabel); - method.append(methodSelect); - nodesetForm.append(method); + // Create boot method drop down + var method = $('
'); + var methodLabel = $(''); + var methodSelect = $(''); + methodSelect.append('' + + '' + + '' + + '' + + '' + ); + method.append(methodLabel); + method.append(methodSelect); + nodesetForm.append(method); - // Create boot type drop down - var type = $('
'); - var typeLabel = $(''); - var typeSelect = $(''); - typeSelect.append('' - + '' - + '' - ); - type.append(typeLabel); - type.append(typeSelect); - nodesetForm.append(type); + // Create boot type drop down + var type = $('
'); + var typeLabel = $(''); + var typeSelect = $(''); + typeSelect.append('' + + '' + + '' + ); + type.append(typeLabel); + type.append(typeSelect); + nodesetForm.append(type); - // Create operating system input - var os = $('
'); - var osLabel = $(''); - var osInput = $(''); - osInput.one('focus', function(){ - var tmp = $.cookie('osvers'); - if (tmp) { - // Turn on auto complete - $(this).autocomplete({ - source: tmp.split(',') - }); - } - }); - os.append(osLabel); - os.append(osInput); - nodesetForm.append(os); + // Create operating system input + var os = $('
'); + var osLabel = $(''); + var osInput = $(''); + osInput.one('focus', function(){ + var tmp = $.cookie('osvers'); + if (tmp) { + // Turn on auto complete + $(this).autocomplete({ + source: tmp.split(',') + }); + } + }); + os.append(osLabel); + os.append(osInput); + nodesetForm.append(os); - // Create architecture input - var arch = $('
'); - var archLabel = $(''); - var archInput = $(''); - archInput.one('focus', function(){ - var tmp = $.cookie('osarchs'); - if (tmp) { - // Turn on auto complete - $(this).autocomplete({ - source: tmp.split(',') - }); - } - }); - arch.append(archLabel); - arch.append(archInput); - nodesetForm.append(arch); + // Create architecture input + var arch = $('
'); + var archLabel = $(''); + var archInput = $(''); + archInput.one('focus', function(){ + var tmp = $.cookie('osarchs'); + if (tmp) { + // Turn on auto complete + $(this).autocomplete({ + source: tmp.split(',') + }); + } + }); + arch.append(archLabel); + arch.append(archInput); + nodesetForm.append(arch); - // Create profiles input - var profile = $('
'); - var profileLabel = $(''); - var profileInput = $(''); - profileInput.one('focus', function(){ - tmp = $.cookie('profiles'); - if (tmp) { - // Turn on auto complete - $(this).autocomplete({ - source: tmp.split(',') - }); - } - }); - profile.append(profileLabel); - profile.append(profileInput); - nodesetForm.append(profile); + // Create profiles input + var profile = $('
'); + var profileLabel = $(''); + var profileInput = $(''); + profileInput.one('focus', function(){ + tmp = $.cookie('profiles'); + if (tmp) { + // Turn on auto complete + $(this).autocomplete({ + source: tmp.split(',') + }); + } + }); + profile.append(profileLabel); + profile.append(profileInput); + nodesetForm.append(profile); - // Generate tooltips - nodesetForm.find('div input[title]').tooltip({ - position: "center right", - offset: [-2, 10], - effect: "fade", - opacity: 0.7, - predelay: 800, - events : { - def : "mouseover,mouseout", - input : "mouseover,mouseout", - widget : "focus mouseover,blur mouseout", - tooltip : "mouseover,mouseout" - } - }); - - /** - * Ok - */ - var okBtn = createButton('Ok'); - okBtn.bind('click', function(event) { - // Remove any warning messages - $(this).parent().parent().find('.ui-state-error').remove(); - - // Check state, OS, arch, and profile - var ready = true; - var inputs = $('#' + tabId + ' input'); - for ( var i = 0; i < inputs.length; i++) { - if (!inputs.eq(i).val() && inputs.eq(i).attr('name') != 'diskPw') { - inputs.eq(i).css('border', 'solid #FF0000 1px'); - ready = false; - } else { - inputs.eq(i).css('border', 'solid #BDBDBD 1px'); - } - } + // Generate tooltips + nodesetForm.find('div input[title]').tooltip({ + position: "center right", + offset: [-2, 10], + effect: "fade", + opacity: 0.7, + predelay: 800, + events : { + def : "mouseover,mouseout", + input : "mouseover,mouseout", + widget : "focus mouseover,blur mouseout", + tooltip : "mouseover,mouseout" + } + }); + + /** + * Ok + */ + var okBtn = createButton('Ok'); + okBtn.bind('click', function(event) { + // Remove any warning messages + $(this).parent().parent().find('.ui-state-error').remove(); + + // Check state, OS, arch, and profile + var ready = true; + var inputs = $('#' + tabId + ' input'); + for ( var i = 0; i < inputs.length; i++) { + if (!inputs.eq(i).val() && inputs.eq(i).attr('name') != 'diskPw') { + inputs.eq(i).css('border', 'solid #FF0000 1px'); + ready = false; + } else { + inputs.eq(i).css('border', 'solid #BDBDBD 1px'); + } + } - if (ready) { - // Get nodes - var tgts = $('#' + tabId + ' input[name=target]').val(); - // Get boot method - var method = $('#' + tabId + ' select[id=bootMethod]').val(); - // Get boot type - var type = $('#' + tabId + ' select[id=bootType]').val(); + if (ready) { + // Get nodes + var tgts = $('#' + tabId + ' input[name=target]').val(); + // Get boot method + var method = $('#' + tabId + ' select[id=bootMethod]').val(); + // Get boot type + var type = $('#' + tabId + ' select[id=bootType]').val(); - // Get OS, arch, and profile - var os = $('#' + tabId + ' input[name=os]').val(); - var arch = $('#' + tabId + ' input[name=arch]').val(); - var profile = $('#' + tabId + ' input[name=profile]').val(); + // Get OS, arch, and profile + var os = $('#' + tabId + ' input[name=os]').val(); + var arch = $('#' + tabId + ' input[name=arch]').val(); + var profile = $('#' + tabId + ' input[name=profile]').val(); - // Disable all inputs, selects, and Ok button - inputs.attr('disabled', 'disabled'); - $('#' + tabId + ' select').attr('disabled', 'disabled'); - $(this).attr('disabled', 'true'); + // Disable all inputs, selects, and Ok button + inputs.attr('disabled', 'disabled'); + $('#' + tabId + ' select').attr('disabled', 'disabled'); + $(this).attr('disabled', 'true'); - /** - * (1) Set the OS, arch, and profile - */ - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'nodeadd', - tgt : '', - args : tgts + ';noderes.netboot=' + type - + ';nodetype.os=' + os - + ';nodetype.arch=' + arch - + ';nodetype.profile=' + profile, - msg : 'cmd=nodeadd;inst=' + inst - }, + /** + * (1) Set the OS, arch, and profile + */ + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'nodeadd', + tgt : '', + args : tgts + ';noderes.netboot=' + type + + ';nodetype.os=' + os + + ';nodetype.arch=' + arch + + ';nodetype.profile=' + profile, + msg : 'cmd=nodeadd;inst=' + inst + }, - success : updateNodesetStatus - }); + success : updateNodesetStatus + }); - // Show status bar - statBar.show(); - } else { - // Show warning message - var warn = createWarnBar('You are missing some values'); - warn.prependTo($(this).parent().parent()); - } - }); - nodesetForm.append(okBtn); + // Show status bar + statBar.show(); + } else { + // Show warning message + var warn = createWarnBar('You are missing some values'); + warn.prependTo($(this).parent().parent()); + } + }); + nodesetForm.append(okBtn); - // Append to discover tab - tab.add(tabId, 'Nodeset', nodesetForm, true); + // Append to discover tab + tab.add(tabId, 'Nodeset', nodesetForm, true); - // Select new tab - tab.select(tabId); + // Select new tab + tab.select(tabId); } /** * Update nodeset status * - * @param data - * Data returned from HTTP request - * @return Nothing + * @param data Data returned from HTTP request */ function updateNodesetStatus(data) { - // Get ajax response - var rsp = data.rsp; - var args = data.msg.split(';'); - var cmd = args[0].replace('cmd=', ''); + // Get ajax response + var rsp = data.rsp; + var args = data.msg.split(';'); + var cmd = args[0].replace('cmd=', ''); - // Get nodeset instance - var inst = args[1].replace('inst=', ''); - // Get status bar ID - var statBarId = 'nodesetStatusBar' + inst; - // Get tab ID - var tabId = 'nodesetTab' + inst; + // Get nodeset instance + var inst = args[1].replace('inst=', ''); + // Get status bar ID + var statBarId = 'nodesetStatusBar' + inst; + // Get tab ID + var tabId = 'nodesetTab' + inst; - // Get nodes - var tgts = $('#' + tabId + ' input[name=target]').val(); - // Get boot method - var method = $('#' + tabId + ' select[id=bootMethod]').val(); + // Get nodes + var tgts = $('#' + tabId + ' input[name=target]').val(); + // Get boot method + var method = $('#' + tabId + ' select[id=bootMethod]').val(); - /** - * (2) Update /etc/hosts - */ - if (cmd == 'nodeadd') { - if (rsp.length) { - $('#' + statBarId).find('img').hide(); - $('#' + statBarId).find('div').append('
(Error) Failed to create node definition
'); - } else { - // Create target nodes string - var tgtNodesStr = ''; - var nodes = tgts.split(','); - - // Loop through each node - for ( var i in nodes) { - // If it is the 1st and only node - if (i == 0 && i == nodes.length - 1) { - tgtNodesStr += nodes[i]; - } - // If it is the 1st node of many nodes - else if (i == 0 && i != nodes.length - 1) { - // Append a comma to the string - tgtNodesStr += nodes[i] + ', '; - } else { - // If it is the last node - if (i == nodes.length - 1) { - // Append nothing to the string - tgtNodesStr += nodes[i]; - } else { - // Append a comma to the string - tgtNodesStr += nodes[i] + ', '; - } - } - } - - $('#' + statBarId).find('div').append('
Node definition created for ' + tgtNodesStr + '
'); - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'makehosts', - tgt : '', - args : '', - msg : 'cmd=makehosts;inst=' + inst - }, + /** + * (2) Update /etc/hosts + */ + if (cmd == 'nodeadd') { + if (rsp.length) { + $('#' + statBarId).find('img').hide(); + $('#' + statBarId).find('div').append('
(Error) Failed to create node definition
'); + } else { + // Create target nodes string + var tgtNodesStr = ''; + var nodes = tgts.split(','); + + // Loop through each node + for ( var i in nodes) { + // If it is the 1st and only node + if (i == 0 && i == nodes.length - 1) { + tgtNodesStr += nodes[i]; + } + // If it is the 1st node of many nodes + else if (i == 0 && i != nodes.length - 1) { + // Append a comma to the string + tgtNodesStr += nodes[i] + ', '; + } else { + // If it is the last node + if (i == nodes.length - 1) { + // Append nothing to the string + tgtNodesStr += nodes[i]; + } else { + // Append a comma to the string + tgtNodesStr += nodes[i] + ', '; + } + } + } + + $('#' + statBarId).find('div').append('
Node definition created for ' + tgtNodesStr + '
'); + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'makehosts', + tgt : '', + args : '', + msg : 'cmd=makehosts;inst=' + inst + }, - success : updateNodesetStatus - }); - } - } + success : updateNodesetStatus + }); + } + } - /** - * (4) Update DNS - */ - else if (cmd == 'makehosts') { - // If no output, no errors occurred - if (rsp.length) { - $('#' + statBarId).find('div').append('
(Error) Failed to update /etc/hosts
'); - } else { - $('#' + statBarId).find('div').append('
/etc/hosts updated
'); - } + /** + * (4) Update DNS + */ + else if (cmd == 'makehosts') { + // If no output, no errors occurred + if (rsp.length) { + $('#' + statBarId).find('div').append('
(Error) Failed to update /etc/hosts
'); + } else { + $('#' + statBarId).find('div').append('
/etc/hosts updated
'); + } - // Update DNS - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'makedns', - tgt : '', - args : '', - msg : 'cmd=makedns;inst=' + inst - }, + // Update DNS + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'makedns', + tgt : '', + args : '', + msg : 'cmd=makedns;inst=' + inst + }, - success : updateNodesetStatus - }); - } + success : updateNodesetStatus + }); + } - /** - * (5) Update DHCP - */ - else if (cmd == 'makedns') { - // Write ajax response to status bar - var prg = writeRsp(rsp, ''); - $('#' + statBarId).find('div').append(prg); - - // Update DHCP - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'makedhcp', - tgt : '', - args : '-a', - msg : 'cmd=makedhcp;inst=' + inst - }, + /** + * (5) Update DHCP + */ + else if (cmd == 'makedns') { + // Write ajax response to status bar + var prg = writeRsp(rsp, ''); + $('#' + statBarId).find('div').append(prg); + + // Update DHCP + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'makedhcp', + tgt : '', + args : '-a', + msg : 'cmd=makedhcp;inst=' + inst + }, - success : updateNodesetStatus - }); - } + success : updateNodesetStatus + }); + } - /** - * (6) Prepare node for boot - */ - else if (cmd == 'makedhcp') { - // Write ajax response to status bar - var prg = writeRsp(rsp, ''); - $('#' + statBarId).find('div').append(prg); + /** + * (6) Prepare node for boot + */ + else if (cmd == 'makedhcp') { + // Write ajax response to status bar + var prg = writeRsp(rsp, ''); + $('#' + statBarId).find('div').append(prg); - // Prepare node for boot - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'nodeset', - tgt : tgts, - args : method, - msg : 'cmd=nodeset;inst=' + inst - }, + // Prepare node for boot + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'nodeset', + tgt : tgts, + args : method, + msg : 'cmd=nodeset;inst=' + inst + }, - success : updateNodesetStatus - }); - } + success : updateNodesetStatus + }); + } - /** - * (7) Boot node from network - */ - else if (cmd == 'nodeset') { - // Write ajax response to status bar - var prg = writeRsp(rsp, ''); - $('#' + statBarId).find('div').append(prg); + /** + * (7) Boot node from network + */ + else if (cmd == 'nodeset') { + // Write ajax response to status bar + var prg = writeRsp(rsp, ''); + $('#' + statBarId).find('div').append(prg); - // Hide loader - $('#' + statBarId).find('img').hide(); - } + // Hide loader + $('#' + statBarId).find('img').hide(); + } } \ No newline at end of file diff --git a/xCAT-UI/js/nodes/physical.js b/xCAT-UI/js/nodes/physical.js index 18066b328..ab8ca607c 100644 --- a/xCAT-UI/js/nodes/physical.js +++ b/xCAT-UI/js/nodes/physical.js @@ -8,95 +8,95 @@ var graphicalNodeList; var selectNode; /** - * get all nodes useful attributes from remote server. + * Get all nodes useful attributes from remote server * - * @param dataTypeIndex: the index in Array graphicalDataType, which contains attributes we need. - * attrNullNode: the target node list for this attribute - * - * @return null + * @param dataTypeIndex The index in the array which contains attributes we need. + * @param attrNullNode The target node list for this attribute */ -function initGraphicalData(){ - $('#graphTab').append(createLoader()); - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'webrun', - tgt : '', - args : 'graph', - msg : '' - }, - success: function(data){ - if(!data.rsp[0]){ - return; - } - extractGraphicalData(data.rsp[0]); - getNodesAndDraw(); - } - }); +function initGraphicalData() { + $('#graphTab').append(createLoader()); + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'webrun', + tgt : '', + args : 'graph', + msg : '' + }, + success : function(data) { + if (!data.rsp[0]) { + return; + } + extractGraphicalData(data.rsp[0]); + getNodesAndDraw(); + } + }); } /** - * extract all nodes userful data into a hash, which is used for creating graphical + * Extract all nodes userful data into a hash, which will be used for creating graphical * - * @param data: the response from xcat command "nodels all nodetype.nodetype ppc.parent ..." + * @param data The response from xCAT command 'nodels all nodetype.nodetype ppc.parent ...' * @return nodes list for next time query */ -function extractGraphicalData(data){ - var nodes = data.split(';'); - var attrs; - var nodename; - //extract useful info into tempList - for (var i = 0; i < nodes.length; i++){ - attrs = nodes[i].split(':'); - nodename = attrs[0]; - if (undefined == graphicalNodeList[nodename]){ - graphicalNodeList[nodename] = new Object(); - } - graphicalNodeList[nodename]['type'] = attrs[1].toLowerCase(); - switch(attrs[1].toLowerCase()){ - case 'cec': - case 'frame': - case 'lpar': - case 'lpar,osi': - case 'osi,lpar': - graphicalNodeList[nodename]['parent'] = attrs[2]; - graphicalNodeList[nodename]['mtm'] = attrs[3]; - graphicalNodeList[nodename]['status'] = attrs[4]; - break; - case 'blade': - graphicalNodeList[nodename]['mpa'] = attrs[2]; - graphicalNodeList[nodename]['unit'] = attrs[3]; - graphicalNodeList[nodename]['status'] = attrs[4]; - break; - case 'systemx': - graphicalNodeList[nodename]['rack'] = attrs[2]; - graphicalNodeList[nodename]['unit'] = attrs[3]; - graphicalNodeList[nodename]['mtm'] = attrs[4]; - graphicalNodeList[nodename]['status'] = attrs[5]; - break; - default: - break; - } - } +function extractGraphicalData(data) { + var nodes = data.split(';'); + var attrs; + var nodeName; + + // Extract useful info into tempList + for (var i = 0; i < nodes.length; i++) { + attrs = nodes[i].split(':'); + nodeName = attrs[0]; + if (undefined == graphicalNodeList[nodeName]) { + graphicalNodeList[nodeName] = new Object(); + } + + graphicalNodeList[nodeName]['type'] = attrs[1].toLowerCase(); + switch (attrs[1].toLowerCase()) { + case 'cec': + case 'frame': + case 'lpar': + case 'lpar,osi': + case 'osi,lpar': + graphicalNodeList[nodeName]['parent'] = attrs[2]; + graphicalNodeList[nodeName]['mtm'] = attrs[3]; + graphicalNodeList[nodeName]['status'] = attrs[4]; + break; + case 'blade': + graphicalNodeList[nodeName]['mpa'] = attrs[2]; + graphicalNodeList[nodeName]['unit'] = attrs[3]; + graphicalNodeList[nodeName]['status'] = attrs[4]; + break; + case 'systemx': + graphicalNodeList[nodeName]['rack'] = attrs[2]; + graphicalNodeList[nodeName]['unit'] = attrs[3]; + graphicalNodeList[nodeName]['mtm'] = attrs[4]; + graphicalNodeList[nodeName]['status'] = attrs[5]; + break; + default: + break; + } + } } -function createPhysicalLayout(nodeList){ - var flag = false; - - //when the graphical layout is shown, do not need to redraw - if (1 < $('#graphTab').children().length){ - return; - } - - //save the new selected nodes. - if (graphicalNodeList){ - for(var i in graphicalNodeList){ - flag = true; - break; - } - } - +function createPhysicalLayout(nodeList) { + var flag = false; + + // When the graphical layout is shown, do not need to redraw + if (1 < $('#graphTab').children().length) { + return; + } + + // Save the new selected nodes + if (graphicalNodeList) { + for (var i in graphicalNodeList) { + flag = true; + break; + } + } + bpaList = new Object(); fspList = new Object(); lparList = new Object(); @@ -104,800 +104,773 @@ function createPhysicalLayout(nodeList){ selectNode = new Object(); rackList = new Object(); unknownList = new Array(); - - //there is not graphical data, get the info now - if (!flag){ - graphicalNodeList = new Object(); - initGraphicalData(); - } - else{ - getNodesAndDraw(); - } + + // There is no graphical data, get the info now + if (!flag) { + graphicalNodeList = new Object(); + initGraphicalData(); + } else { + getNodesAndDraw(); + } } -function getNodesAndDraw(){ - var groupname = $.cookie('selectgrouponnodes'); - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'nodels', - tgt : groupname, - args : '', - msg : '' - }, - success : function(data){ - for (var temp in data.rsp){ - var nodeName = data.rsp[temp][0]; - if ('' == nodeName){ - continue; - } - fillList(nodeName); - } - $('#graphTab').empty(); - createGraphical(); - } - }); +function getNodesAndDraw() { + var groupName = $.cookie('selectgrouponnodes'); + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'nodels', + tgt : groupName, + args : '', + msg : '' + }, + success : function(data) { + for (var temp in data.rsp) { + var nodeName = data.rsp[temp][0]; + if ('' == nodeName) { + continue; + } + fillList(nodeName); + } + $('#graphTab').empty(); + createGraphical(); + } + }); } -function fillList(nodeName, defaultnodetype){ +function fillList(nodeName, defaultnodetype) { var parentName = ''; var mtm = ''; var status = ''; - var nodetype = ''; + var nodeType = ''; var mpa = ''; var unit = ''; var rack = ''; - if (!graphicalNodeList[nodeName]){ + if (!graphicalNodeList[nodeName]) { parentName = ''; mtm = ''; status = ''; - nodetype = defaultnodetype; + nodeType = defaultnodetype; + } else { + status = graphicalNodeList[nodeName]['status']; + nodeType = graphicalNodeList[nodeName]['type']; + switch (nodeType) { + case 'frame': + case 'lpar,osi': + case 'lpar': + case 'osi': + case 'cec': + parentName = graphicalNodeList[nodeName]['parent']; + mtm = graphicalNodeList[nodeName]['mtm']; + break; + case 'blade': + mpa = graphicalNodeList[nodeName]['mpa']; + unit = graphicalNodeList[nodeName]['unit']; + break; + case 'systemx': + rack = graphicalNodeList[nodeName]['rack']; + unit = graphicalNodeList[nodeName]['unit']; + break; + default: + break; + } + } - else{ - status = graphicalNodeList[nodeName]['status']; - nodetype = graphicalNodeList[nodeName]['type']; - switch (nodetype){ - case 'frame': - case 'lpar,osi': - case 'lpar': - case 'osi': - case 'cec':{ - parentName = graphicalNodeList[nodeName]['parent']; - mtm = graphicalNodeList[nodeName]['mtm']; - } - break; - case 'blade':{ - mpa = graphicalNodeList[nodeName]['mpa']; - unit = graphicalNodeList[nodeName]['unit']; - } - break; - case 'systemx':{ - rack = graphicalNodeList[nodeName]['rack']; - unit = graphicalNodeList[nodeName]['unit']; - } - break; - default: - break; - } + + if ('' == status) { + status = 'unknown'; + } + + switch (nodeType) { + case 'frame': + if (undefined == bpaList[nodeName]) { + bpaList[nodeName] = new Array(); + } + break; + case 'lpar,osi': + case 'lpar': + case 'osi': + if ('' == parentName) { + break; + } + + if (undefined == fspList[parentName]) { + fillList(parentName, 'cec'); + } + + fspList[parentName]['children'].push(nodeName); + lparList[nodeName] = status; + + break; + case 'cec': + if (undefined != fspList[nodeName]) { + break; + } + + fspList[nodeName] = new Object(); + fspList[nodeName]['children'] = new Array(); + fspList[nodeName]['mtm'] = mtm; + + if ('' == parentName) { + break; + } + + if (undefined == bpaList[parentName]) { + fillList(parentName, 'frame'); + } + + bpaList[parentName].push(nodeName); + break; + case 'blade': + if (undefined == bladeList[mpa]) { + bladeList[mpa] = new Array(); + } + bladeList[mpa].push(nodeName + ',' + unit); + + break; + case 'systemx': + if (!rack) { + rack = '_notsupply_'; + } + + if (undefined == rackList[rack]) { + rackList[rack] = new Array(); + } + + rackList[rack].push(nodeName + ',' + unit); + + break; + default: + unknownList.push(nodeName); + break; + } +} + +function createGraphical() { + var tabArea = $('#graphTab'); + var selectNodeDiv = $('
'); + var temp = 0; + for (var i in selectNode) { + temp++; + break; + } + + // There is no selected LPAR, show the info bar + if (temp == 0) { + tabArea.append(createInfoBar('Hover over a CEC and select the LPARs to do operations against.')); + } else { + // Show selected LPARs + updateSelectNodeDiv(); + } + + // Add buttons + tabArea.append(createActionMenu()); + tabArea.append(selectNodeDiv); + createSystempGraphical(bpaList, fspList, tabArea); + createBladeGraphical(bladeList, tabArea); + createSystemxGraphical(rackList, tabArea); + addUnknownGraphical(unknownList, tabArea); +} + +/** + * Create the physical/graphical layout for System p machines + * + * @param bpa All BPA and their related FSPs + * @param fsp All FSP and their related LPARs + * @param area The element to append graphical layout + */ +function createSystempGraphical(bpa, fsp, area) { + var usedFsp = new Object(); + var graphTable = $('
'); + var elementNum = 0; + var row = null; + var showFlag = false; + + // There is a node in the BPA list, so show add the title and show all frames + for (var bpaName in bpa) { + showFlag = true; + $('#graphTab').append('system p
'); + $('#graphTab').append(graphTable); + break; + } + + for (var bpaName in bpa) { + if (0 == elementNum % 3) { + row = $(''); + graphTable.append(row); + } + + elementNum++; + + var td = $(''); + var frameDiv = $('
'); + frameDiv.append('
'); + + // For P7-IH, all the CECs are insert into the frame from bottom to up, + // so we have to show the CECs same as the physical layout + var tempBlankDiv = $('
'); + var tempHeight = 0; + for (var fspIndex in bpa[bpaName]) { + var fspName = bpa[bpaName][fspIndex]; + usedFsp[fspName] = 1; + + // This is the P7-IH, we should add the blank at the top + if ((0 == fspIndex) && ('9125-F2C' == fsp[fspName]['mtm'])) { + frameDiv.append(tempBlankDiv); + } + + frameDiv.append(createFspDiv(fspName, fsp[fspName]['mtm'], fsp)); + frameDiv.append(createFspTip(fspName, fsp[fspName]['mtm'], fsp)); + + tempHeight += calculateBlank(fsp[fspName]['mtm']); + } + + // tempHeight is the total height for all CECs, so we should minus BPA div + // height and CEC div heights + tempHeight = 428 - tempHeight; + tempBlankDiv.css('height', tempHeight); + td.append(frameDiv); + row.append(td); + } + + // Find the single FSP and sort descend by units + var singleFsp = new Array(); + for (var fspName in fsp) { + if (usedFsp[fspName]) { + continue; + } + + singleFsp.push([ fspName, fsp[fspName]['mtm'] ]); + } + + // If there is no frame, we should check if there is single CEC and show + // the title and add node area + if (!showFlag) { + for (var fspIndex in singleFsp) { + $('#graphTab').append('system p
'); + $('#graphTab').append(graphTable); + break; + } + } + + singleFsp.sort(function(a, b) { + var unitNumA = 4; + var unitNumB = 4; + if (hardwareInfo[a[1]]) { + unitNumA = hardwareInfo[a[1]][1]; + } + + if (hardwareInfo[b[1]]) { + unitNumB = hardwareInfo[b[1]][1]; + } + + return (unitNumB - unitNumA); + }); + + elementNum = 0; + for (var fspIndex in singleFsp) { + var fspName = singleFsp[fspIndex][0]; + if (0 == elementNum % 3) { + row = $(''); + graphTable.append(row); + } + elementNum++; + + var td = $(''); + td.append(createFspDiv(fspName, fsp[fspName]['mtm'], fsp)); + td.append(createFspTip(fspName, fsp[fspName]['mtm'], fsp)); + row.append(td); + } + + $('.tooltip input[type = checkbox]').bind('click', function() { + var lparName = $(this).attr('name'); + if ('' == lparName) { + return; + } + if (true == $(this).attr('checked')) { + changeNode(lparName, 'select'); + } else { + changeNode(lparName, 'unselect'); + } + + updateSelectNodeDiv(); + }); + + $('.fspDiv2, .fspDiv4, .fspDiv42').tooltip({ + position : "center right", + relative : true, + offset : [ 10, -40 ], + effect : "fade", + opacity : 0.9 + }); + + $('.tooltip a').bind('click', function() { + var lparName = $(this).html(); + $('#nodesDatatable #' + lparName).trigger('click'); + }); + + $('.fspDiv2, .fspDiv4, .fspDiv42').bind('click', function() { + var fspName = $(this).attr('value'); + var selectCount = 0; + for (var lparIndex in fspList[fspName]['children']) { + var lparName = fspList[fspName]['children'][lparIndex]; + if (selectNode[lparName]) { + selectCount++; + } + } + + // All LPARs are selected, so unselect nodes + if (selectCount == fspList[fspName]['children'].length) { + for (var lparIndex in fspList[fspName]['children']) { + var lparName = fspList[fspName]['children'][lparIndex]; + changeNode(lparName, 'unselect'); + } + } + + // No selected LPARs on the cec, so add all LPARs into selectNode hash + else { + for (var lparIndex in fspList[fspName]['children']) { + var lparName = fspList[fspName]['children'][lparIndex]; + changeNode(lparName, 'select'); + } + } + + updateSelectNodeDiv(); + }); + + $('.fspCheckbox').bind('click', function() { + var itemName = $(this).attr('name'); + name = itemName.substr(6); + + if ($(this).attr('checked')) { + selectNode[name] = 1; + } else { + delete selectNode[name]; + } + + updateSelectNodeDiv(); + }); +} + +/** + * Create the physical/graphical layout for blades + * + * @param blades The blade list in global + * @param area The element to append the graphical layout + */ +function createBladeGraphical(blades, area) { + var graphTable = $('
'); + var mpa = ''; + var bladeName = ''; + var index = 0; + var mpaNumber = 0; + var row; + var showFlag = false; + + // Only show the title and nodes when there are blade in the blade list + for (mpa in blades) { + showFlag = true; + break; + } + + if (showFlag) { + $('#graphTab').append('Blade
'); + $('#graphTab').append(graphTable); + } + // If there is no blade node, return directly + else { + return; + } + + for (mpa in blades) { + var tempArray = new Array(14); + var bladeInfo = new Array(); + var unit = 0; + if (0 == mpaNumber % 3) { + row = $(''); + graphTable.append(row); + } + + mpaNumber++; + + var td = $(''); + var chasisDiv = $('
'); + + // Fill the array with blade information, to create the empty slot + for (index in blades[mpa]) { + bladeInfo = blades[mpa][index].split(','); + unit = parseInt(bladeInfo[1]); + tempArray[unit - 1] = bladeInfo[0]; + + } + + // Draw the blades and empty slot in chasis + for (index = 0; index < 14; index++) { + if (tempArray[index]) { + bladeName = tempArray[index]; + chasisDiv.append('
'); + } else { + chasisDiv.append('
'); + } + } + + td.append(chasisDiv); + row.append(td); + } + +} + +/** + * Create the physical/graphical layout for System x machines + * + * @param xnodes The system x node list in global + * @param area The element to append graphical layout + */ +function createSystemxGraphical(xnodes, area) { + var graphTable = $('
'); + var xnodename = ''; + var index = 0; + var rack = ''; + var row; + var xNodeCount = 0; + var showflag = false; + + // Only the title and System x node when there are x nodes in the list + for (rack in rackList) { + showflag = true; + break; + } + + if (showflag) { + $('#graphTab').append('system x
'); + $('#graphTab').append(graphTable); + } + // There is nothing to show, return directly + else { + return; + } + + for (rack in rackList) { + for (index in rackList[rack]) { + var xNodeName = rackList[rack][index]; + if (0 == xNodeCount % 3) { + row = $(''); + graphTable.append(row); + } + xNodeCount++; + var td = $(''); + var xNodeDiv = '
'; + td.append(xNodeDiv); + row.append(td); + } + } +} + +function addUnknownGraphical(unknownNodes, tab) { + // Do not continue if no nodes were found + if (unknownNodes.length < 1) + return; + + var list = ""; + tab.append('
'); + for (var index in unknownNodes) { + list += unknownNodes[index] + ', '; + + } + + // Delete last comma + list = list.substr(0, list.length - 2); + tab.append(list); +} + +/** + * Update the LPARs background in CEC, LPAR area and selectNode + */ +function updateSelectNodeDiv() { + var temp = 0; + $('#selectNodeDiv').empty(); + + // Add buttons + if (selectNode.length) { + $('#selectNodeDiv').append('Nodes: '); + for (var lparName in selectNode) { + $('#selectNodeDiv').append(lparName + ' '); + temp++; + if (temp > 6) { + $('#selectNodeDiv').append('...'); + break; + } + } + } +} + +/** + * Create the action menu + */ +function createActionMenu() { + // Create action bar + var actionBar = $('
'); + + // Power on + var powerOnLnk = $('Power on'); + powerOnLnk.click(function() { + var tgtNodes = getSelectNodes(); + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'rpower', + tgt : tgtNodes, + args : 'on', + msg : '' + } + }); + }); + + // Power off + var powerOffLnk = $('Power off'); + powerOffLnk.click(function() { + var tgtNodes = getSelectNodes(); + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'rpower', + tgt : tgtNodes, + args : 'off', + msg : '' + } + }); + }); + + // Delete + var deleteLnk = $('Delete'); + deleteLnk.click(function() { + var tgtNodes = getSelectNodes(); + if (tgtNodes) { + loadDeletePage(tgtNodes); + } + }); + + // Unlock + var unlockLnk = $('Unlock'); + unlockLnk.click(function() { + var tgtNodes = getSelectNodes(); + if (tgtNodes) { + loadUnlockPage(tgtNodes); + } + }); + + // Run script + var scriptLnk = $('Run script'); + scriptLnk.click(function() { + var tgtNodes = getSelectNodes(); + if (tgtNodes) { + loadScriptPage(tgtNodes); + } + }); + + // Update + var updateLnk = $('Update'); + updateLnk.click(function() { + var tgtNodes = getSelectNodes(); + if (tgtNodes) { + loadUpdatenodePage(tgtNodes); + } + }); + + // Set boot state + var setBootStateLnk = $('Set boot state'); + setBootStateLnk.click(function() { + var tgtNodes = getSelectNodes(); + if (tgtNodes) { + loadNodesetPage(tgtNodes); + } + }); + + // Boot to network + var boot2NetworkLnk = $('Boot to network'); + boot2NetworkLnk.click(function() { + var tgtNodes = getSelectNodes(); + if (tgtNodes) { + loadNetbootPage(tgtNodes); + } + }); + + // Remote console + var rconLnk = $('Open console'); + rconLnk.bind('click', function(event) { + var tgtNodes = getSelectNodes(); + if (tgtNodes) { + loadRconsPage(tgtNodes); + } + }); + + // Edit properties + var editProps = $('Edit properties'); + editProps.bind('click', function(event) { + for (var node in selectNode) { + loadEditPropsPage(node); + } + }); + + // Actions + var actionsLnk = 'Actions'; + var actsMenu = createMenu([ deleteLnk, powerOnLnk, powerOffLnk, scriptLnk ]); + + // Configurations + var configLnk = 'Configuration'; + var configMenu = createMenu([ unlockLnk, updateLnk, editProps ]); + + // Provision + var provLnk = 'Provision'; + var provMenu = createMenu([ boot2NetworkLnk, setBootStateLnk, rconLnk ]); + + // Create an action menu + var actionsMenu = createMenu([ [ actionsLnk, actsMenu ], + [ configLnk, configMenu ], [ provLnk, provMenu ] ]); + actionsMenu.superfish(); + actionsMenu.css('display', 'inline-block'); + actionBar.append(actionsMenu); + actionBar.css('margin-top', '10px'); + + // Set correct theme for action menu + actionsMenu.find('li').hover(function() { + setMenu2Theme($(this)); + }, function() { + setMenu2Normal($(this)); + }); + + return actionBar; +} + +/** + * Create the physical/graphical layout + */ +function createFspDiv(fspName, mtm, fsp) { + // Create FSP title + var lparStatusRow = ''; + var temp = ''; + + for (var lparIndex in fsp[fspName]['children']) { + // Show 8 lpars on one cec at most. + if (lparIndex >= 8) { + break; + } + + var lparName = fsp[fspName]['children'][lparIndex]; + var color = statusMap(lparList[lparName]); + lparStatusRow += ''; + } + + // Select the backgroud + var divClass = ''; + if ('' == mtm) { + temp = '8231-E2B'; + } else { + temp = mtm; } - if ('' == status){ - status = 'unknown'; - } - - switch (nodetype){ - case 'frame': { - if (undefined == bpaList[nodeName]){ - bpaList[nodeName] = new Array(); - } - } - break; - case 'lpar,osi': - case 'lpar': - case 'osi': { - if ('' == parentName){ - break; - } - - if (undefined == fspList[parentName]){ - fillList(parentName, 'cec'); - } - - fspList[parentName]['children'].push(nodeName); - lparList[nodeName] = status; - } - break; - case 'cec': { - if (undefined != fspList[nodeName]){ - break; - } - - fspList[nodeName] = new Object(); - fspList[nodeName]['children'] = new Array(); - fspList[nodeName]['mtm'] = mtm; - - if ('' == parentName){ - break; - } - - if (undefined == bpaList[parentName]){ - fillList(parentName, 'frame'); - } - - bpaList[parentName].push(nodeName); - } - break; - case 'blade': { - if (undefined == bladeList[mpa]){ - bladeList[mpa] = new Array(); - } - bladeList[mpa].push(nodeName + ',' + unit); - } - break; - case 'systemx':{ - if (!rack){ - rack = '_notsupply_'; - } - if (undefined == rackList[rack]){ - rackList[rack] = new Array(); - } - rackList[rack].push(nodeName + ',' + unit); - } - break; - default: - unknownList.push(nodeName); - break; - } + if (hardwareInfo[temp][1]) { + divClass += 'fspDiv' + hardwareInfo[temp][1]; + } else { + divClass += 'fspDiv4'; + } + + // Create return value + var retHtml = ''; + retHtml += '
'; + retHtml += '
' + lparStatusRow + + '
'; + return retHtml; } -function createGraphical(){ - var tabarea = $('#graphTab'); - var selectNodeDiv = $('
'); - var temp = 0; - for (var i in selectNode){ - temp ++; - break; - } - - //there is not selected lpars, show the info bar - if (temp == 0){ - tabarea.append(createInfoBar('Hover over a CEC and select the LPARs to do operations against.')); - } - //show selected lpars - else{ - updateSelectNodeDiv(); - } - - //add buttons - tabarea.append(createActionMenu()); - tabarea.append(selectNodeDiv); - createSystempGraphical(bpaList, fspList, tabarea); - createBladeGraphical(bladeList, tabarea); - createSystemxGraphical(rackList, tabarea); - addUnknownGraphical(unknownList, tabarea); -} /** - * create the physical graphical layout for system p machines - * - * @param bpa : all bpa and there related fsps - * fsp : all fsp and there related lpars - * fspinfo : all fsps' hardwareinfo - * area: the element to append graphical layout - * @return + * Create the physical/graphical FSP tooltip which is used to select the LPAR */ -function createSystempGraphical(bpa, fsp, area){ - var usedFsp = new Object(); - var graphTable = $('
'); - var elementNum = 0; - var row; - var showflag = false; - - //there is node in bpa list, so show add the title and show all frames - for (var bpaName in bpa){ - showflag = true; - $('#graphTab').append('system p
'); - $('#graphTab').append(graphTable); - break; - } - - for (var bpaName in bpa){ - if (0 == elementNum % 3){ - row = $(''); - graphTable.append(row); - } - - elementNum ++; - - var td = $(''); - var frameDiv = $('
'); - frameDiv.append('
'); - - //for P7-IH, all the cecs are insert into the frame from down to up, so we had to show the cecs same as the - //physical layout. - var tempBlankDiv = $('
'); - var tempHeight = 0; - for (var fspIndex in bpa[bpaName]){ - var fspName = bpa[bpaName][fspIndex]; - usedFsp[fspName] = 1; - - //this is the p7IH, we should add the blank at the top - if ((0 == fspIndex) && ('9125-F2C' == fsp[fspName]['mtm'])){ - frameDiv.append(tempBlankDiv); - } - frameDiv.append(createFspDiv(fspName, fsp[fspName]['mtm'], fsp)); - frameDiv.append(createFspTip(fspName, fsp[fspName]['mtm'], fsp)); - - tempHeight += coculateBlank(fsp[fspName]['mtm']); - } - - //now the tempHeight are all cecs' height, so we should minus bpa div height and cecs' div height - tempHeight = 428 - tempHeight; - tempBlankDiv.css('height', tempHeight); - td.append(frameDiv); - row.append(td); - } - - //find the single fsp and sort descend by units - var singleFsp = new Array(); - for (var fspName in fsp){ - if (usedFsp[fspName]){ - continue; - } - - singleFsp.push([fspName, fsp[fspName]['mtm']]); - } - - //if there is not frame, so we should check if there is single cec and show the title and add node area. - if (!showflag){ - for(var fspIndex in singleFsp){ - $('#graphTab').append('system p
'); - $('#graphTab').append(graphTable); - break; - } - } - - singleFsp.sort(function(a, b){ - var unitNumA = 4; - var unitNumB = 4; - if (hardwareInfo[a[1]]){ - unitNumA = hardwareInfo[a[1]][1]; - } - - if (hardwareInfo[b[1]]){ - unitNumB = hardwareInfo[b[1]][1]; - } - - return (unitNumB - unitNumA); - }); - - - elementNum = 0; - for (var fspIndex in singleFsp){ - var fspName = singleFsp[fspIndex][0]; - if (0 == elementNum % 3){ - row = $(''); - graphTable.append(row); - } - elementNum ++; +function createFspTip(fspName, mtm, fsp) { + var tip = $('
'); + var tempTable = $('
'); + var temp = ''; + if ('' == mtm) { + temp = 'unkown'; + } else { + temp = mtm; + } - var td = $(''); - td.append(createFspDiv(fspName, fsp[fspName]['mtm'], fsp)); - td.append(createFspTip(fspName, fsp[fspName]['mtm'], fsp)); - row.append(td); - } - - - $('.tooltip input[type = checkbox]').bind('click', function(){ - var lparName = $(this).attr('name'); - if ('' == lparName){ - return; - } - if (true == $(this).attr('checked')){ - changeNode(lparName, 'select'); - } - else{ - changeNode(lparName, 'unselect'); - } - - updateSelectNodeDiv(); - }); - - $('.fspDiv2, .fspDiv4, .fspDiv42').tooltip({ - position: "center right", - relative : true, - offset : [10, -40], - effect: "fade", - opacity: 0.9 - }); - - $('.tooltip a').bind('click', function(){ - var lparName = $(this).html(); - $('#nodesDatatable #' + lparName).trigger('click'); - }); - - $('.fspDiv2, .fspDiv4, .fspDiv42').bind('click', function(){ - var fspName = $(this).attr('value'); - var selectCount = 0; - for (var lparIndex in fspList[fspName]['children']){ - var lparName = fspList[fspName]['children'][lparIndex]; - if (selectNode[lparName]){ - selectCount ++; - } - } - - //all the lpars are selected, so unselect nodes - if (selectCount == fspList[fspName]['children'].length){ - for (var lparIndex in fspList[fspName]['children']){ - var lparName = fspList[fspName]['children'][lparIndex]; - changeNode(lparName, 'unselect'); - } - } - //not select all lpars on the cec, so add all lpars into selectNode Hash. - else{ - for (var lparIndex in fspList[fspName]['children']){ - var lparName = fspList[fspName]['children'][lparIndex]; - changeNode(lparName, 'select'); - } - } - - updateSelectNodeDiv(); - }); - - $('.fspCheckbox').bind('click', function(){ - var itemName = $(this).attr('name'); - name = itemName.substr(6); - - if ($(this).attr('checked')){ - selectNode[name] = 1; - } - else{ - delete selectNode[name]; - } - - updateSelectNodeDiv(); - }); + if (hardwareInfo[temp]) { + tip.append('

' + fspName + '(' + hardwareInfo[temp][0] + ')


'); + } else { + tip.append('

' + fspName + '


'); + } + + for (var lparIndex in fsp[fspName]['children']) { + var lparName = fsp[fspName]['children'][lparIndex]; + var color = statusMap(lparList[lparName]); + var row = ''; + row += '' + lparName + ''; + row += '' + lparList[lparName] + ''; + tempTable.append(row); + } + + tip.append(tempTable); + return tip; } - /** - * create the physical graphical layout for blades + * Map the LPAR status into a color * - * @param blades : the blade list in global - * area: the element to append graphical layout - * @return + * @param status LPAR status in nodelist table + * @return Corresponding color name */ -function createBladeGraphical(blades, area){ - var graphTable = $('
'); - var mpa = ''; - var bladename = ''; - var index = 0; - var mpaNumber = 0; - var row; - var showflag = false; - - //only show the title and nodes when there are blade in the blade list - for (mpa in blades){ - showflag = true; - break; - } - - if (showflag){ - $('#graphTab').append('Blade
'); - $('#graphTab').append(graphTable); - } - //if there is not blade nodes, return directly - else{ - return; - } - - for (mpa in blades){ - var tempArray = new Array(14); - var bladeInfo = new Array(); - var unit = 0; - if (0 == mpaNumber % 3){ - row = $(''); - graphTable.append(row); - } - - mpaNumber ++; - - var td = $(''); - var chasisDiv = $('
'); - - - //fill the array with blade information, to create the empty slot - for (index in blades[mpa]){ - bladeInfo = blades[mpa][index].split(','); - unit = parseInt(bladeInfo[1]); - tempArray[unit - 1] = bladeInfo[0]; - - } - - //draw the blades and empty slot in chasis - for (index = 0; index < 14; index++){ - if (tempArray[index]){ - bladename = tempArray[index]; - chasisDiv.append('
'); - } - else{ - chasisDiv.append('
'); - } - } - - td.append(chasisDiv); - row.append(td); - } - +function statusMap(status) { + var color = 'gainsboro'; + + switch (status) { + case 'alive': + case 'ready': + case 'pbs': + case 'sshd': + case 'booting': + case 'booted': + case 'ping': + color = 'green'; + break; + case 'noping': + case 'unreachable': + color = 'red'; + break; + default: + color = 'grey'; + break; + } + + return color; } /** - * create the physical graphical layout for system x machines - * - * @param xnodes : the system x node list in global - * area: the element to append graphical layout - * @return + * Select all LPAR checkboxes */ -function createSystemxGraphical(xnodes, area){ - var graphTable = $('
'); - var xnodename = ''; - var index = 0; - var rack = ''; - var row; - var xnodenum = 0; - var showflag = false; - - //only the title and system x node when there is x nodes in the list - for (rack in rackList){ - showflag = true; - break; - } - - if (showflag){ - $('#graphTab').append('system x
'); - $('#graphTab').append(graphTable); - } - //there is nothing to show, return directly - else{ - return; - } - - for (rack in rackList){ - for(index in rackList[rack]){ - var xnodename = rackList[rack][index]; - if (0 == xnodenum % 3){ - row = $(''); - graphTable.append(row); - } - xnodenum++; - var td = $(''); - var xNodeDiv = '
'; - td.append(xNodeDiv); - row.append(td); - } - } -} - -function addUnknownGraphical(unknownNodes, tab){ - // Do not continue if no nodes were found - if (unknownNodes.length < 1) - return; - - var list = ""; - tab.append('
'); - for (var index in unknownNodes){ - list += unknownNodes[index] + ', '; - - } - - // Delete last comma - list = list.substr(0, list.length - 2); - tab.append(list); +function selectAllLpars(checkbox) { + var temp = checkbox.attr('checked'); + $('#selectNodeTable input[type = checkbox]').attr('checked', temp); } /** - * update the lpars' background in cec, lpars area and selectNode + * Export all LPAR names from selectNode * - * @param - * @return - **/ -function updateSelectNodeDiv(){ - var temp = 0; - $('#selectNodeDiv').empty(); - - //add buttons - if (selectNode.length) { - $('#selectNodeDiv').append('Nodes: '); - for (var lparName in selectNode){ - $('#selectNodeDiv').append(lparName + ' '); - temp ++; - if (temp > 6){ - $('#selectNodeDiv').append('...'); - break; - } - } - } -} - -/** - * create the action menu - * - * @param getNodesFunction - * the function that can find selected nodes name - * @return action menu object - */ -function createActionMenu(){ - // Create action bar - var actionBar = $('
'); - - // Power on - var powerOnLnk = $('Power on'); - powerOnLnk.click(function() { - var tgtNodes = getSelectNodes(); - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'rpower', - tgt : tgtNodes, - args : 'on', - msg : '' - } - }); - }); - - // Power off - var powerOffLnk = $('Power off'); - powerOffLnk.click(function() { - var tgtNodes = getSelectNodes(); - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'rpower', - tgt : tgtNodes, - args : 'off', - msg : '' - } - }); - }); - - // Delete - var deleteLnk = $('Delete'); - deleteLnk.click(function() { - var tgtNodes = getSelectNodes(); - if (tgtNodes) { - loadDeletePage(tgtNodes); - } - }); - - // Unlock - var unlockLnk = $('Unlock'); - unlockLnk.click(function() { - var tgtNodes = getSelectNodes(); - if (tgtNodes) { - loadUnlockPage(tgtNodes); - } - }); - - // Run script - var scriptLnk = $('Run script'); - scriptLnk.click(function() { - var tgtNodes = getSelectNodes(); - if (tgtNodes) { - loadScriptPage(tgtNodes); - } - }); - - // Update - var updateLnk = $('Update'); - updateLnk.click(function() { - var tgtNodes = getSelectNodes(); - if (tgtNodes) { - loadUpdatenodePage(tgtNodes); - } - }); - - // Set boot state - var setBootStateLnk = $('Set boot state'); - setBootStateLnk.click(function() { - var tgtNodes = getSelectNodes(); - if (tgtNodes) { - loadNodesetPage(tgtNodes); - } - }); - - // Boot to network - var boot2NetworkLnk = $('Boot to network'); - boot2NetworkLnk.click(function() { - var tgtNodes = getSelectNodes(); - if (tgtNodes) { - loadNetbootPage(tgtNodes); - } - }); - - // Remote console - var rconLnk = $('Open console'); - rconLnk.bind('click', function(event){ - var tgtNodes = getSelectNodes(); - if (tgtNodes) { - loadRconsPage(tgtNodes); - } - }); - - // Edit properties - var editProps = $('Edit properties'); - editProps.bind('click', function(event){ - for (var node in selectNode) { - loadEditPropsPage(node); - } - }); - - // Actions - var actionsLnk = 'Actions'; - var actsMenu = createMenu([deleteLnk, powerOnLnk, powerOffLnk, scriptLnk]); - - // Configurations - var configLnk = 'Configuration'; - var configMenu = createMenu([unlockLnk, updateLnk, editProps]); - - // Provision - var provLnk = 'Provision'; - var provMenu = createMenu([boot2NetworkLnk, setBootStateLnk, rconLnk]); - - // Create an action menu - var actionsMenu = createMenu([ [ actionsLnk, actsMenu ], [ configLnk, configMenu ], [ provLnk, provMenu ] ]); - actionsMenu.superfish(); - actionsMenu.css('display', 'inline-block'); - actionBar.append(actionsMenu); - actionBar.css('margin-top', '10px'); - - // Set correct theme for action menu - actionsMenu.find('li').hover(function() { - setMenu2Theme($(this)); - }, function() { - setMenu2Normal($(this)); - }); - - return actionBar; -} - -/** - * create the physical graphical layout - * - * @param bpaName : fsp's key - * fsp : all fsp and there related lpars - * fspinfo : all fsps' hardwareinfo - * @return - */ -function createFspDiv(fspName, mtm, fsp){ - //create fsp title - var lparStatusRow = ''; - var temp = ''; - - for (var lparIndex in fsp[fspName]['children']){ - //show 8 lpars on one cec at most. - if (lparIndex >= 8){ - break; - } - var lparName = fsp[fspName]['children'][lparIndex]; - var color = statusMap(lparList[lparName]); - lparStatusRow += ''; - } - - //select the backgroud - var divClass = ''; - if ('' == mtm){ - temp = '8231-E2B'; - } - else{ - temp = mtm; - } - if (hardwareInfo[temp][1]){ - divClass += 'fspDiv' + hardwareInfo[temp][1]; - } - else{ - divClass += 'fspDiv4'; - } - - //create return value - var retHtml = ''; - retHtml += '
'; - retHtml += '
' + lparStatusRow + '
'; - return retHtml; -} - -/** - * create the physical graphical fsps' help witch could select the lpars. - * - * @param bpaName : fsp's key - * fsp : all fsp and there related lpars - * fspinfo : all fsps' hardwareinfo - * @return - */ -function createFspTip(fspName, mtm, fsp){ - var tip = $('
'); - var tempTable = $('
'); - var temp = ''; - if ('' == mtm){ - temp = 'unkown'; - } - else{ - temp = mtm; - } - - if (hardwareInfo[temp]){ - tip.append('

' + fspName + '(' + hardwareInfo[temp][0] + ')


'); - } - else{ - tip.append('

' + fspName + '


'); - } - - for (var lparIndex in fsp[fspName]['children']){ - var lparName = fsp[fspName]['children'][lparIndex]; - var color = statusMap(lparList[lparName]); - var row = ''; - row += ''+ lparName + ''; - row += '' + lparList[lparName] + ''; - tempTable.append(row); - } - - tip.append(tempTable); - return tip; -} -/** - * map the lpar's status into a color - * - * @param status : lpar's status in nodelist table - * @return corresponding color name - */ -function statusMap(status){ - var color = 'gainsboro'; - - switch(status){ - case 'alive': - case 'ready': - case 'pbs': - case 'sshd': - case 'booting': - case 'booted': - case 'ping':{ - color = 'green'; - } - break; - case 'noping': - case 'unreachable':{ - color = 'red'; - } - break; - default: - color = 'grey'; - break; - } - - return color; -} - -/** - * select all lpars checkbox in the dialog - * - * @param - * @return - */ -function selectAllLpars(checkbox){ - var temp = checkbox.attr('checked'); - $('#selectNodeTable input[type = checkbox]').attr('checked', temp); -} - -/** - * export all lpars' name from selectNode - * - * @param - * @return lpars' string + * @return lpars' string */ function getSelectNodes() { var ret = ''; - for ( var lparName in selectNode) { + for (var lparName in selectNode) { ret += lparName + ','; } @@ -905,62 +878,52 @@ function getSelectNodes() { } /** - * when the node is selected or unselected, then update the area on cec, update the global - * list and update the tooltip table - * - * @param - * @return + * When the node is selected or unselected, update the area on CEC, update + * the global list, and update the tooltip table */ -function changeNode(lparName, status){ - var imgUrl = ''; - var checkFlag = true; - if ('select' == status){ - selectNode[lparName] = 1; - imgUrl = 'url(images/nodes/s-'+ statusMap(lparList[lparName]) + '.gif)'; - checkFlag = true; - } - else{ - delete selectNode[lparName]; - imgUrl = 'url(images/nodes/'+ statusMap(lparList[lparName]) + '.gif)'; - checkFlag = false; - } - $('#' + lparName + 'status').css('background-image', imgUrl); - $('.tooltip input[name="' + lparName + '"]').attr('checked', checkFlag); +function changeNode(lparName, status) { + var imgUrl = ''; + var checkFlag = true; + if ('select' == status) { + selectNode[lparName] = 1; + imgUrl = 'url(images/nodes/s-' + statusMap(lparList[lparName]) + + '.gif)'; + checkFlag = true; + } else { + delete selectNode[lparName]; + imgUrl = 'url(images/nodes/' + statusMap(lparList[lparName]) + '.gif)'; + checkFlag = false; + } + $('#' + lparName + 'status').css('background-image', imgUrl); + $('.tooltip input[name="' + lparName + '"]').attr('checked', checkFlag); } /** - * The P7-IH's cecs are insert from down to up, so we had to coculate the blank height. + * The P7-IH's CECs are insert from bottom to up, so we had to calculate the blank height * - * @param - * @return the height for the cec + * @return Height for the CEC */ -function coculateBlank(mtm){ - if ('' == mtm){ - return 24; - } - - if (!hardwareInfo[mtm]){ - return 24; - } - - switch(hardwareInfo[mtm][1]){ - case 1: - { - return 13; - } - break; - case 2: - { - return 24; - } - break; - case 4: - { - return 47; - } - break; - default: - return 0; - break; - } +function calculateBlank(mtm) { + if ('' == mtm) { + return 24; + } + + if (!hardwareInfo[mtm]) { + return 24; + } + + switch (hardwareInfo[mtm][1]) { + case 1: + return 13; + break; + case 2: + return 24; + break; + case 4: + return 47; + break; + default: + return 0; + break; + } } \ No newline at end of file diff --git a/xCAT-UI/js/nodes/rnetboot.js b/xCAT-UI/js/nodes/rnetboot.js index f97e25173..836f67637 100644 --- a/xCAT-UI/js/nodes/rnetboot.js +++ b/xCAT-UI/js/nodes/rnetboot.js @@ -1,202 +1,200 @@ /** * Load netboot page * - * @param tgtNodes - * Targets to run rnetboot against - * @return Nothing + * @param tgtNodes Targets to run rnetboot against */ function loadNetbootPage(tgtNodes) { - // Get node OS - var osHash = new Object(); - var nodes = tgtNodes.split(','); - for (var i in nodes) { - var os = getNodeAttr(nodes[i], 'os'); - var osBase = os.match(/[a-zA-Z]+/); - if (osBase) { - nodes[osBase] = 1; - } - } - - // Get nodes tab - var tab = getNodesTab(); - - // Generate new tab ID - var inst = 0; - var newTabId = 'netbootTab' + inst; - while ($('#' + newTabId).length) { - // If one already exists, generate another one - inst = inst + 1; - newTabId = 'netbootTab' + inst; - } + // Get node OS + var osHash = new Object(); + var nodes = tgtNodes.split(','); + for (var i in nodes) { + var os = getNodeAttr(nodes[i], 'os'); + var osBase = os.match(/[a-zA-Z]+/); + if (osBase) { + nodes[osBase] = 1; + } + } + + // Get nodes tab + var tab = getNodesTab(); + + // Generate new tab ID + var inst = 0; + var newTabId = 'netbootTab' + inst; + while ($('#' + newTabId).length) { + // If one already exists, generate another one + inst = inst + 1; + newTabId = 'netbootTab' + inst; + } - // Create netboot form - var netbootForm = $('
'); + // Create netboot form + var netbootForm = $('
'); - // Create status bar - var statBarId = 'netbootStatusBar' + inst; - var statusBar = createStatusBar(statBarId).hide(); - netbootForm.append(statusBar); + // Create status bar + var statBarId = 'netbootStatusBar' + inst; + var statusBar = createStatusBar(statBarId).hide(); + netbootForm.append(statusBar); - // Create loader - var loader = createLoader('netbootLoader'); - statusBar.find('div').append(loader); + // Create loader + var loader = createLoader('netbootLoader'); + statusBar.find('div').append(loader); - // Create info bar - var infoBar = createInfoBar('Cause the range of nodes to boot to network'); - netbootForm.append(infoBar); + // Create info bar + var infoBar = createInfoBar('Cause the range of nodes to boot to network'); + netbootForm.append(infoBar); - // Create target node or group input - var target = $('
'); - netbootForm.append(target); + // Create target node or group input + var target = $('
'); + netbootForm.append(target); - // Create options - var optsDIV = $('
'); - var optsLabel = $(''); - var optsList = $(''); - var opt = $('
  • '); - optsList.append(opt); - optsDIV.append(optsLabel); - optsDIV.append(optsList); - netbootForm.append(optsDIV); - - // Create boot order checkbox - var bootOrderChkBox = $(''); - opt.append(bootOrderChkBox); - opt.append('Set the boot device order'); - // Create boot order input - var bootOrder = $('
  • '); - bootOrder.hide(); - optsList.append(bootOrder); - - // Create force reboot checkbox - optsList.append('
  • Force reboot
  • '); - // Create force shutdown checkbox - optsList.append('
  • Force immediate shutdown of the partition
  • '); - if (osHash['AIX']) { - // Create iscsi dump checkbox - optsList.append('
  • Do a iscsi dump on AIX
  • '); - } - - // Show boot order when checkbox is checked - bootOrderChkBox.bind('click', function(event) { - if ($(this).is(':checked')) { - bootOrder.show(); - } else { - bootOrder.hide(); - } - }); + // Create options + var optsDIV = $('
    '); + var optsLabel = $(''); + var optsList = $(''); + var opt = $('
  • '); + optsList.append(opt); + optsDIV.append(optsLabel); + optsDIV.append(optsList); + netbootForm.append(optsDIV); + + // Create boot order checkbox + var bootOrderChkBox = $(''); + opt.append(bootOrderChkBox); + opt.append('Set the boot device order'); + // Create boot order input + var bootOrder = $('
  • '); + bootOrder.hide(); + optsList.append(bootOrder); + + // Create force reboot checkbox + optsList.append('
  • Force reboot
  • '); + // Create force shutdown checkbox + optsList.append('
  • Force immediate shutdown of the partition
  • '); + if (osHash['AIX']) { + // Create iscsi dump checkbox + optsList.append('
  • Do a iscsi dump on AIX
  • '); + } + + // Show boot order when checkbox is checked + bootOrderChkBox.bind('click', function(event) { + if ($(this).is(':checked')) { + bootOrder.show(); + } else { + bootOrder.hide(); + } + }); - // Determine plugin - var tmp = tgtNodes.split(','); - for ( var i = 0; i < tmp.length; i++) { - var mgt = getNodeAttr(tmp[i], 'mgt'); - // If it is zvm - if (mgt == 'zvm') { - // Add IPL input - netbootForm.append('
    '); - break; - } - } + // Determine plugin + var tmp = tgtNodes.split(','); + for ( var i = 0; i < tmp.length; i++) { + var mgt = getNodeAttr(tmp[i], 'mgt'); + // If it is zvm + if (mgt == 'zvm') { + // Add IPL input + netbootForm.append('
    '); + break; + } + } - // Generate tooltips - netbootForm.find('div input[title]').tooltip({ - position: "center right", - offset: [-2, 10], - effect: "fade", - opacity: 0.7, - predelay: 800, - events : { - def : "mouseover,mouseout", - input : "mouseover,mouseout", - widget : "focus mouseover,blur mouseout", - tooltip : "mouseover,mouseout" - } - }); - - /** - * Ok - */ - var okBtn = createButton('Ok'); - okBtn.bind('click', function(event) { - // Remove any warning messages - $(this).parent().parent().find('.ui-state-error').remove(); - - // Check inputs - var ready = true; - var inputs = $("#" + newTabId + " input[type='text']:visible"); - for ( var i = 0; i < inputs.length; i++) { - if (!inputs.eq(i).val()) { - inputs.eq(i).css('border', 'solid #FF0000 1px'); - ready = false; - } else { - inputs.eq(i).css('border', 'solid #BDBDBD 1px'); - } - } + // Generate tooltips + netbootForm.find('div input[title]').tooltip({ + position: "center right", + offset: [-2, 10], + effect: "fade", + opacity: 0.7, + predelay: 800, + events : { + def : "mouseover,mouseout", + input : "mouseover,mouseout", + widget : "focus mouseover,blur mouseout", + tooltip : "mouseover,mouseout" + } + }); + + /** + * Ok + */ + var okBtn = createButton('Ok'); + okBtn.bind('click', function(event) { + // Remove any warning messages + $(this).parent().parent().find('.ui-state-error').remove(); + + // Check inputs + var ready = true; + var inputs = $("#" + newTabId + " input[type='text']:visible"); + for ( var i = 0; i < inputs.length; i++) { + if (!inputs.eq(i).val()) { + inputs.eq(i).css('border', 'solid #FF0000 1px'); + ready = false; + } else { + inputs.eq(i).css('border', 'solid #BDBDBD 1px'); + } + } - // Generate arguments - var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked"); - var optStr = ''; - var opt; - for ( var i = 0; i < chkBoxes.length; i++) { - opt = chkBoxes.eq(i).attr('name'); - optStr += '-' + opt; - - // If it is the boot order - if (opt == 's') { - // Get the boot order - optStr += ';' + $('#' + newTabId + ' input[name=bootOrder]').val(); - } - - // Append ; to end of string - if (i < (chkBoxes.length - 1)) { - optStr += ';'; - } - } + // Generate arguments + var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked"); + var optStr = ''; + var opt; + for ( var i = 0; i < chkBoxes.length; i++) { + opt = chkBoxes.eq(i).attr('name'); + optStr += '-' + opt; + + // If it is the boot order + if (opt == 's') { + // Get the boot order + optStr += ';' + $('#' + newTabId + ' input[name=bootOrder]').val(); + } + + // Append ; to end of string + if (i < (chkBoxes.length - 1)) { + optStr += ';'; + } + } - // If no inputs are empty - if (ready) { - // Get nodes - var tgts = $('#' + newTabId + ' input[name=target]').val(); + // If no inputs are empty + if (ready) { + // Get nodes + var tgts = $('#' + newTabId + ' input[name=target]').val(); - // Get IPL address - var ipl = $('#' + newTabId + ' input[name=ipl]'); - if (ipl) { - optStr += 'ipl=' + ipl.val(); - } + // Get IPL address + var ipl = $('#' + newTabId + ' input[name=ipl]'); + if (ipl) { + optStr += 'ipl=' + ipl.val(); + } - // Disable all inputs and Ok button - $('#' + newTabId + ' input').attr('disabled', 'disabled'); - $(this).attr('disabled', 'true'); + // Disable all inputs and Ok button + $('#' + newTabId + ' input').attr('disabled', 'disabled'); + $(this).attr('disabled', 'true'); - /** - * (1) Boot to network - */ - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'rnetboot', - tgt : tgts, - args : optStr, - msg : 'out=' + statBarId + ';cmd=rnetboot;tgt=' + tgts - }, + /** + * (1) Boot to network + */ + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'rnetboot', + tgt : tgts, + args : optStr, + msg : 'out=' + statBarId + ';cmd=rnetboot;tgt=' + tgts + }, - success : updateStatusBar - }); + success : updateStatusBar + }); - // Show status bar - statusBar.show(); - } else { - // Show warning message - var warn = createWarnBar('Please provide a value for each missing field.'); - warn.prependTo($(this).parent().parent()); - } - }); - netbootForm.append(okBtn); + // Show status bar + statusBar.show(); + } else { + // Show warning message + var warn = createWarnBar('Please provide a value for each missing field.'); + warn.prependTo($(this).parent().parent()); + } + }); + netbootForm.append(okBtn); - // Append to discover tab - tab.add(newTabId, 'Boot', netbootForm, true); + // Append to discover tab + tab.add(newTabId, 'Boot', netbootForm, true); - // Select new tab - tab.select(newTabId); + // Select new tab + tab.select(newTabId); } \ No newline at end of file diff --git a/xCAT-UI/js/nodes/updatenode.js b/xCAT-UI/js/nodes/updatenode.js index 6c06b9e88..4ee383346 100644 --- a/xCAT-UI/js/nodes/updatenode.js +++ b/xCAT-UI/js/nodes/updatenode.js @@ -1,386 +1,384 @@ /** * Load updatenode page * - * @param tgtNodes - * Targets to run updatenode against - * @return Nothing + * @param tgtNodes Targets to run updatenode against */ function loadUpdatenodePage(tgtNodes) { - // Get OS images - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'tabdump', - tgt : '', - args : 'osimage', - msg : '' - }, + // Get OS images + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'tabdump', + tgt : '', + args : 'osimage', + msg : '' + }, - success : setOSImageCookies - }); - - // Get node OS - var osHash = new Object(); - var nodes = tgtNodes.split(','); - for (var i in nodes) { - var os = getNodeAttr(nodes[i], 'os'); - var osBase = os.match(/[a-zA-Z]+/); - if (osBase) { - nodes[osBase] = 1; - } - } - - // Get nodes tab - var tab = getNodesTab(); + success : setOSImageCookies + }); + + // Get node OS + var osHash = new Object(); + var nodes = tgtNodes.split(','); + for (var i in nodes) { + var os = getNodeAttr(nodes[i], 'os'); + var osBase = os.match(/[a-zA-Z]+/); + if (osBase) { + nodes[osBase] = 1; + } + } + + // Get nodes tab + var tab = getNodesTab(); - // Generate new tab ID - var inst = 0; - var newTabId = 'updatenodeTab' + inst; - while ($('#' + newTabId).length) { - // If one already exists, generate another one - inst = inst + 1; - newTabId = 'updatenodeTab' + inst; - } - - // Create updatenode form - var updatenodeForm = $('
    '); + // Generate new tab ID + var inst = 0; + var newTabId = 'updatenodeTab' + inst; + while ($('#' + newTabId).length) { + // If one already exists, generate another one + inst = inst + 1; + newTabId = 'updatenodeTab' + inst; + } + + // Create updatenode form + var updatenodeForm = $('
    '); - // Create status bar - var statBarId = 'updatenodeStatusBar' + inst; - var statusBar = createStatusBar(statBarId).hide(); - updatenodeForm.append(statusBar); + // Create status bar + var statBarId = 'updatenodeStatusBar' + inst; + var statusBar = createStatusBar(statBarId).hide(); + updatenodeForm.append(statusBar); - // Create loader - var loader = createLoader('updatenodeLoader'); - statusBar.find('div').append(loader); + // Create loader + var loader = createLoader('updatenodeLoader'); + statusBar.find('div').append(loader); - // Create info bar - var infoBar = createInfoBar('Update nodes in an xCAT environment'); - updatenodeForm.append(infoBar); - - // Create target node or group input - var tgt = $('
    '); - updatenodeForm.append(tgt); + // Create info bar + var infoBar = createInfoBar('Update nodes in an xCAT environment'); + updatenodeForm.append(infoBar); + + // Create target node or group input + var tgt = $('
    '); + updatenodeForm.append(tgt); - // Create options - var options = $('
    '); - var optionsLabel = $(''); - var optionsList = $(''); - options.append(optionsLabel); - options.append(optionsList); - updatenodeForm.append(options); - - // Create update all software checkbox (only AIX) - if (osHash['AIX']) { - var updateAllOption = $('
  • '); - var updateAllChkBox = $(''); - updateAllOption.append(updateAllChkBox); - optionsList.append(updateAllOption); - updateAllOption.append('Install or update all software contained in the source directory'); - - // Create source directory input - var allSwScrDirectory = $('
  • '); - // Browse server directory and files - var allSWSrcDirBrowse = createButton('Browse'); - allSWSrcDirBrowse.serverBrowser({ - onSelect : function(path) { - $('#allSwSrcDirectory').val(path); - }, - onLoad : function() { - return $('#allSwSrcDirectory').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 - }); - allSwScrDirectory.append(allSWSrcDirBrowse); - allSwScrDirectory.hide(); - optionsList.append(allSwScrDirectory); + // Create options + var options = $('
    '); + var optionsLabel = $(''); + var optionsList = $(''); + options.append(optionsLabel); + options.append(optionsList); + updatenodeForm.append(options); + + // Create update all software checkbox (only AIX) + if (osHash['AIX']) { + var updateAllOption = $('
  • '); + var updateAllChkBox = $(''); + updateAllOption.append(updateAllChkBox); + optionsList.append(updateAllOption); + updateAllOption.append('Install or update all software contained in the source directory'); + + // Create source directory input + var allSwScrDirectory = $('
  • '); + // Browse server directory and files + var allSWSrcDirBrowse = createButton('Browse'); + allSWSrcDirBrowse.serverBrowser({ + onSelect : function(path) { + $('#allSwSrcDirectory').val(path); + }, + onLoad : function() { + return $('#allSwSrcDirectory').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 + }); + allSwScrDirectory.append(allSWSrcDirBrowse); + allSwScrDirectory.hide(); + optionsList.append(allSwScrDirectory); - // Show source directory when checked - updateAllChkBox.bind('click', function(event) { - if ($(this).is(':checked')) { - allSwScrDirectory.show(); - } else { - allSwScrDirectory.hide(); - } - }); - } - - // Create update software checkbox - var updateOption = $('
  • '); - var updateChkBox = $(''); - optionsList.append(updateOption); - updateOption.append(updateChkBox); - updateOption.append('Update existing software'); - - // Create source directory input - var scrDirectory = $('
  • '); - // Browse server directory and files - var srcDirBrowse = createButton('Browse'); - srcDirBrowse.serverBrowser({ - onSelect : function(path) { - $('#srcDirectory').val(path); - }, - onLoad : function() { - return $('#srcDirectory').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 - }); - scrDirectory.append(srcDirBrowse); - scrDirectory.hide(); - optionsList.append(scrDirectory); - - // Create other packages input - var otherPkgs = $('
  • '); - otherPkgs.hide(); - optionsList.append(otherPkgs); - - // Create RPM flags input (only AIX) - var aixRpmFlags = $('
  • '); - aixRpmFlags.hide(); - optionsList.append(aixRpmFlags); - - // Create installp flags input (only AIX) - var aixInstallPFlags = $('
  • '); - aixInstallPFlags.hide(); - optionsList.append(aixInstallPFlags); - - // Create emgr flags input (only AIX) - var aixEmgrFlags = $('
  • '); - aixEmgrFlags.hide(); - optionsList.append(aixEmgrFlags); - - // Show flags when checked - updateChkBox.bind('click', function(event) { - if ($(this).is(':checked')) { - scrDirectory.show(); - otherPkgs.show(); - if (osHash['AIX']) { - aixRpmFlags.show(); - aixInstallPFlags.show(); - aixEmgrFlags.show(); - } - } else { - scrDirectory.hide(); - otherPkgs.hide(); - if (osHash['AIX']) { - aixRpmFlags.hide(); - aixInstallPFlags.hide(); - aixEmgrFlags.hide(); - } - } - }); - - // Create postscripts input - var postOption = $('
  • '); - var postChkBox = $(''); - optionsList.append(postOption); - postOption.append(postChkBox); - postOption.append('Run postscripts'); - var postscripts = $('
  • '); - postscripts.hide(); - optionsList.append(postscripts); - - // Show alternate source directory when checked - postChkBox.bind('click', function(event) { - if ($(this).is(':checked')) { - postscripts.show(); - } else { - postscripts.hide(); - } - }); - optionsList.append('
  • Distribute and synchronize files
  • '); - optionsList.append('
  • Update the ssh keys and host keys for the service nodes and compute nodes
  • '); - - // Create update OS checkbox - if (!osHash['AIX']) { - var osOption = $('
  • '); - var osChkBox = $(''); - optionsList.append(osOption); - osOption.append(osChkBox); - osOption.append('Update the operating system'); - - var os = $('
  • ').hide(); - var osLabel = $(''); - var osInput = $(''); - osInput.one('focus', function(){ - var tmp = $.cookie('osvers'); - if (tmp) { - // Turn on auto complete - $(this).autocomplete({ - source: tmp.split(',') - }); - } - }); - os.append(osLabel); - os.append(osInput); - optionsList.append(os); - - // Show alternate source directory when checked - osChkBox.bind('click', function(event) { - if ($(this).is(':checked')) { - os.show(); - } else { - os.hide(); - } - }); - } - - // Generate tooltips - updatenodeForm.find('div input[title]').tooltip({ - position: "center right", - offset: [-2, 10], - effect: "fade", - opacity: 0.7, - predelay: 800, - events : { - def : "mouseover,mouseout", - input : "mouseover,mouseout", - widget : "focus mouseover,blur mouseout", - tooltip : "mouseover,mouseout" - } - }); - - /** - * Ok - */ - var okBtn = createButton('Ok'); - okBtn.bind('click', function(event) { - // Remove any warning messages - $(this).parent().parent().find('.ui-state-error').remove(); - var ready = true; - - // Generate arguments - var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked"); - var optionsStr = ''; - var option; - for ( var i = 0; i < chkBoxes.length; i++) { - option = chkBoxes.eq(i).attr('name'); - optionsStr += '-' + option; - - // If update all software is checked - if (option == 'S') { - var srcDir = $('#' + newTabId + ' input[name=allSwSrcDirectory]').val(); - if (srcDir) { - optionsStr += ';-d ' + srcDir; - } - } + // Show source directory when checked + updateAllChkBox.bind('click', function(event) { + if ($(this).is(':checked')) { + allSwScrDirectory.show(); + } else { + allSwScrDirectory.hide(); + } + }); + } + + // Create update software checkbox + var updateOption = $('
  • '); + var updateChkBox = $(''); + optionsList.append(updateOption); + updateOption.append(updateChkBox); + updateOption.append('Update existing software'); + + // Create source directory input + var scrDirectory = $('
  • '); + // Browse server directory and files + var srcDirBrowse = createButton('Browse'); + srcDirBrowse.serverBrowser({ + onSelect : function(path) { + $('#srcDirectory').val(path); + }, + onLoad : function() { + return $('#srcDirectory').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 + }); + scrDirectory.append(srcDirBrowse); + scrDirectory.hide(); + optionsList.append(scrDirectory); + + // Create other packages input + var otherPkgs = $('
  • '); + otherPkgs.hide(); + optionsList.append(otherPkgs); + + // Create RPM flags input (only AIX) + var aixRpmFlags = $('
  • '); + aixRpmFlags.hide(); + optionsList.append(aixRpmFlags); + + // Create installp flags input (only AIX) + var aixInstallPFlags = $('
  • '); + aixInstallPFlags.hide(); + optionsList.append(aixInstallPFlags); + + // Create emgr flags input (only AIX) + var aixEmgrFlags = $('
  • '); + aixEmgrFlags.hide(); + optionsList.append(aixEmgrFlags); + + // Show flags when checked + updateChkBox.bind('click', function(event) { + if ($(this).is(':checked')) { + scrDirectory.show(); + otherPkgs.show(); + if (osHash['AIX']) { + aixRpmFlags.show(); + aixInstallPFlags.show(); + aixEmgrFlags.show(); + } + } else { + scrDirectory.hide(); + otherPkgs.hide(); + if (osHash['AIX']) { + aixRpmFlags.hide(); + aixInstallPFlags.hide(); + aixEmgrFlags.hide(); + } + } + }); + + // Create postscripts input + var postOption = $('
  • '); + var postChkBox = $(''); + optionsList.append(postOption); + postOption.append(postChkBox); + postOption.append('Run postscripts'); + var postscripts = $('
  • '); + postscripts.hide(); + optionsList.append(postscripts); + + // Show alternate source directory when checked + postChkBox.bind('click', function(event) { + if ($(this).is(':checked')) { + postscripts.show(); + } else { + postscripts.hide(); + } + }); + optionsList.append('
  • Distribute and synchronize files
  • '); + optionsList.append('
  • Update the ssh keys and host keys for the service nodes and compute nodes
  • '); + + // Create update OS checkbox + if (!osHash['AIX']) { + var osOption = $('
  • '); + var osChkBox = $(''); + optionsList.append(osOption); + osOption.append(osChkBox); + osOption.append('Update the operating system'); + + var os = $('
  • ').hide(); + var osLabel = $(''); + var osInput = $(''); + osInput.one('focus', function(){ + var tmp = $.cookie('osvers'); + if (tmp) { + // Turn on auto complete + $(this).autocomplete({ + source: tmp.split(',') + }); + } + }); + os.append(osLabel); + os.append(osInput); + optionsList.append(os); + + // Show alternate source directory when checked + osChkBox.bind('click', function(event) { + if ($(this).is(':checked')) { + os.show(); + } else { + os.hide(); + } + }); + } + + // Generate tooltips + updatenodeForm.find('div input[title]').tooltip({ + position: "center right", + offset: [-2, 10], + effect: "fade", + opacity: 0.7, + predelay: 800, + events : { + def : "mouseover,mouseout", + input : "mouseover,mouseout", + widget : "focus mouseover,blur mouseout", + tooltip : "mouseover,mouseout" + } + }); + + /** + * Ok + */ + var okBtn = createButton('Ok'); + okBtn.bind('click', function(event) { + // Remove any warning messages + $(this).parent().parent().find('.ui-state-error').remove(); + var ready = true; + + // Generate arguments + var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked"); + var optionsStr = ''; + var option; + for ( var i = 0; i < chkBoxes.length; i++) { + option = chkBoxes.eq(i).attr('name'); + optionsStr += '-' + option; + + // If update all software is checked + if (option == 'S') { + var srcDir = $('#' + newTabId + ' input[name=allSwSrcDirectory]').val(); + if (srcDir) { + optionsStr += ';-d ' + srcDir; + } + } - // If update software is checked - if (option == 'S') { - // Get source directory - var srcDirectory = $('#' + newTabId + ' input[name=srcDirectory]').val(); - if (srcDirectory) { - optionsStr += ';-d;' + srcDirectory; - } - - // Get otherpkgs - var otherpkgs = $('#' + newTabId + ' input[name=otherpkgs]').val(); - if (otherpkgs) { - optionsStr += ';otherpkgs=' + otherpkgs; - } - - // Get rpm_flags - var rpm_flags = $('#' + newTabId + ' input[name=rpm_flags]').val(); - if (rpm_flags) { - optionsStr += ';rpm_flags=' + rpm_flags; - } - - // Get installp_flags - var installp_flags = $('#' + newTabId + ' input[name=installp_flags]').val(); - if (installp_flags) { - optionsStr += ';installp_flags=' + installp_flags; - } - - // Get emgr_flags - var emgr_flags = $('#' + newTabId + ' input[name=emgr_flags]').val(); - if (emgr_flags) { - optionsStr += ';emgr_flags=' + emgr_flags; - } - } - - // If postscripts is checked - if (option == 'P') { - // Get postscripts - optionsStr += ';' + $('#' + newTabId + ' input[name=postscripts]').val(); - } - - // If operating system is checked - if (option == 'o') { - // Get the OS - optionsStr += ';' + $('#' + newTabId + ' input[name=os]').val(); - } - - // Append ; to end of string - if (i < (chkBoxes.length - 1)) { - optionsStr += ';'; - } - } - - // If no inputs are empty - if (ready) { - // Get nodes - var tgts = $('#' + newTabId + ' input[name=target]').val(); + // If update software is checked + if (option == 'S') { + // Get source directory + var srcDirectory = $('#' + newTabId + ' input[name=srcDirectory]').val(); + if (srcDirectory) { + optionsStr += ';-d;' + srcDirectory; + } + + // Get otherpkgs + var otherpkgs = $('#' + newTabId + ' input[name=otherpkgs]').val(); + if (otherpkgs) { + optionsStr += ';otherpkgs=' + otherpkgs; + } + + // Get rpm_flags + var rpm_flags = $('#' + newTabId + ' input[name=rpm_flags]').val(); + if (rpm_flags) { + optionsStr += ';rpm_flags=' + rpm_flags; + } + + // Get installp_flags + var installp_flags = $('#' + newTabId + ' input[name=installp_flags]').val(); + if (installp_flags) { + optionsStr += ';installp_flags=' + installp_flags; + } + + // Get emgr_flags + var emgr_flags = $('#' + newTabId + ' input[name=emgr_flags]').val(); + if (emgr_flags) { + optionsStr += ';emgr_flags=' + emgr_flags; + } + } + + // If postscripts is checked + if (option == 'P') { + // Get postscripts + optionsStr += ';' + $('#' + newTabId + ' input[name=postscripts]').val(); + } + + // If operating system is checked + if (option == 'o') { + // Get the OS + optionsStr += ';' + $('#' + newTabId + ' input[name=os]').val(); + } + + // Append ; to end of string + if (i < (chkBoxes.length - 1)) { + optionsStr += ';'; + } + } + + // If no inputs are empty + if (ready) { + // Get nodes + var tgts = $('#' + newTabId + ' input[name=target]').val(); - // Disable all inputs and Ok button - $('#' + newTabId + ' input').attr('disabled', 'disabled'); - $(this).attr('disabled', 'true'); - - /** - * (1) Boot to network - */ - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'updatenode', - tgt : tgts, - args : optionsStr, - msg : 'out=' + statBarId + ';cmd=updatenode;tgt=' + tgts - }, + // Disable all inputs and Ok button + $('#' + newTabId + ' input').attr('disabled', 'disabled'); + $(this).attr('disabled', 'true'); + + /** + * (1) Boot to network + */ + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'updatenode', + tgt : tgts, + args : optionsStr, + msg : 'out=' + statBarId + ';cmd=updatenode;tgt=' + tgts + }, - success : updateStatusBar - }); + success : updateStatusBar + }); - // Show status bar - statusBar.show(); - } else { - // Show warning message - var warn = createWarnBar('You are missing some values'); - warn.prependTo($(this).parent().parent()); - } - }); - updatenodeForm.append(okBtn); + // Show status bar + statusBar.show(); + } else { + // Show warning message + var warn = createWarnBar('You are missing some values'); + warn.prependTo($(this).parent().parent()); + } + }); + updatenodeForm.append(okBtn); - // Append to discover tab - tab.add(newTabId, 'Update', updatenodeForm, true); + // Append to discover tab + tab.add(newTabId, 'Update', updatenodeForm, true); - // Select new tab - tab.select(newTabId); + // Select new tab + tab.select(newTabId); } \ No newline at end of file