From 5f7bca49f8c7cc93b2910cda39756a461c559cfa Mon Sep 17 00:00:00 2001 From: phamt Date: Mon, 19 Jul 2010 18:28:31 +0000 Subject: [PATCH] Cleaned up code git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6797 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/configure/configure.js | 113 ++-- xCAT-UI/js/custom/hmc.js | 17 +- xCAT-UI/js/custom/zvm.js | 964 +++++++++++++++--------------- xCAT-UI/js/custom/zvmUtils.js | 96 +-- xCAT-UI/js/nodes/nodes.js | 45 +- xCAT-UI/js/provision/provision.js | 1 + xCAT-UI/lib/functions.php | 6 +- xCAT-UI/lib/zCmd.php | 2 +- 8 files changed, 616 insertions(+), 628 deletions(-) diff --git a/xCAT-UI/js/configure/configure.js b/xCAT-UI/js/configure/configure.js index a16e2c2d7..da426c86d 100644 --- a/xCAT-UI/js/configure/configure.js +++ b/xCAT-UI/js/configure/configure.js @@ -2,7 +2,7 @@ * Global variables */ var configTabs; // Config tabs -var configDataTables = new Object(); // Datatables on the config page +var configDatatables = new Object(); // Datatables on the config page /** * Set the datatable @@ -14,7 +14,7 @@ var configDataTables = new Object(); // Datatables on the config page * @return Nothing */ function setConfigDatatable(id, obj) { - configDataTables[id] = obj; + configDatatables[id] = obj; } /** @@ -25,7 +25,7 @@ function setConfigDatatable(id, obj) { * @return Datatable object */ function getConfigDatatable(id) { - return configDataTables[id]; + return configDatatables[id]; } /** @@ -71,7 +71,7 @@ function loadConfigPage() { var loader = createLoader(); loader = $('
').append(loader); - // Configure xCAT tables + // Configure xCAT datable tables tab.add('configTablesTab', 'Tables', loader); // Get list of tables and their descriptions @@ -90,7 +90,7 @@ function loadConfigPage() { } /** - * Load xCAT table names and their descriptions + * Load xCAT database table names and their descriptions * * @param data * Data returned from HTTP request @@ -105,7 +105,7 @@ function loadTableNames(data) { $('#' + tabId).find('img').hide(); // Create a groups division - var tablesDIV = $('
'); + var tablesDIV = $('
'); $('#' + tabId).append(tablesDIV); // Create info bar @@ -167,7 +167,7 @@ function loadTableNames(data) { } /** - * Load a given table + * Load a given database table * * @param data * Data returned from HTTP request @@ -209,10 +209,10 @@ function loadTable(data) { newCont[0] = tmp; // Create a new datatable - var tableId = id + 'DataTable'; + var tableId = id + 'Datatable'; var table = new DataTable(tableId); - // Add column for the remove button + // Add column for the remove row button headers.unshift(''); table.init(headers); headers.shift(); @@ -248,8 +248,7 @@ function loadTable(data) { } // Add remove button - cols - .unshift(''); + cols.unshift(''); // Add row table.add(cols); @@ -274,15 +273,14 @@ function loadTable(data) { return (value); }, { - onblur : 'submit', // Clicking outside editable area submits - // changes + onblur : 'submit', // Clicking outside editable area submits changes type : 'textarea', height : '30px' // The height of the text area }); // Turn table into datatable - dTable = $('#' + id + 'DataTable').dataTable(); - setConfigDatatable(id + 'DataTable', dTable); + dTable = $('#' + id + 'Datatable').dataTable(); + setConfigDatatable(id + 'Datatable', dTable); // Create add row button var addBar = $('
'); @@ -299,54 +297,50 @@ function loadTable(data) { /** * Add row */ - addRowBtn - .bind( - 'click', - function(event) { - // Create an empty row - var row = new Array(); + addRowBtn.bind('click', function(event) { + // Create an empty row + var row = new Array(); - /** - * Remove button - */ - row - .push(''); - for ( var i = 0; i < headers.length; i++) { - row.push(''); - } + /** + * Remove button + */ + row.push(''); + for ( var i = 0; i < headers.length; i++) { + row.push(''); + } - // Get tab ID - var tabId = $(this).parent().parent().attr('id'); - // Get table name - var tableName = tabId.replace('Tab', ''); - // Get table ID - var tableId = tableName + 'DataTable'; + // Get tab ID + var tabId = $(this).parent().parent().attr('id'); + // Get table name + var tableName = tabId.replace('Tab', ''); + // Get table ID + var tableId = tableName + 'Datatable'; - // Get datatable - var dTable = getConfigDatatable(tableId); - // Add the row to the data table - dTable.fnAddData(row); + // Get datatable + var dTable = getConfigDatatable(tableId); + // Add the row to the data table + dTable.fnAddData(row); - // Enable editable columns (again) - // Do not make 1st column editable - $('#' + tabId + ' td:not(td:nth-child(1))').editable( - function(value, settings) { - // Get column index - var colPos = this.cellIndex; - // Get row index - var rowPos = dTable.fnGetPosition(this.parentNode); + // Enable editable columns (again) + // Do not make 1st column editable + $('#' + tabId + ' td:not(td:nth-child(1))').editable( + function(value, settings) { + // Get column index + var colPos = this.cellIndex; + // Get row index + var rowPos = dTable.fnGetPosition(this.parentNode); - // Update datatable - dTable.fnUpdate(value, rowPos, colPos); + // Update datatable + dTable.fnUpdate(value, rowPos, colPos); - return (value); - }, { - onblur : 'submit', // Clicking outside editable area - // submits changes - type : 'textarea', - height : '30px' // The height of the text area - }); + return (value); + }, { + onblur : 'submit', // Clicking outside editable area + // submits changes + type : 'textarea', + height : '30px' // The height of the text area }); + }); /** * Save changes @@ -357,7 +351,7 @@ function loadTable(data) { // Get table name var tableName = tabId.replace('Tab', ''); // Get table ID - var tableId = tableName + 'DataTable'; + var tableId = tableName + 'Datatable'; // Get datatable var dTable = getConfigDatatable(tableId); @@ -415,7 +409,7 @@ function loadTable(data) { // Get table name var tableName = tabId.replace('Tab', ''); // Get table ID - var tableId = tableName + 'DataTable'; + var tableId = tableName + 'Datatable'; // Get datatable var dTable = getConfigDatatable(tableId); @@ -489,6 +483,5 @@ function deleteRow(obj) { * @return The number of occurrences */ String.prototype.count = function(char) { - return (this.length - this.replace(new RegExp(char, "g"), '').length) - / char.length; + return (this.length - this.replace(new RegExp(char, "g"), '').length)/char.length; }; \ No newline at end of file diff --git a/xCAT-UI/js/custom/hmc.js b/xCAT-UI/js/custom/hmc.js index 70c7965c8..52ba6486d 100644 --- a/xCAT-UI/js/custom/hmc.js +++ b/xCAT-UI/js/custom/hmc.js @@ -1,5 +1,5 @@ $(document).ready(function(){ - // Include utility script + // Include utility scripts }); /** @@ -14,10 +14,10 @@ function loadInventory(data) { } /** - * Load the clone page + * Load clone page * * @param node - * Source node + * Source node to clone * @return Nothing */ function loadClonePage(node) { @@ -25,7 +25,7 @@ function loadClonePage(node) { } /** - * Load zVM provision page + * Load provision page * * @param tabId * The provision tab ID @@ -33,4 +33,13 @@ function loadClonePage(node) { */ function loadProvisionPage(tabId) { +} + +/** + * Load resources + * + * @return Nothing + */ +function loadResources() { + } \ No newline at end of file diff --git a/xCAT-UI/js/custom/zvm.js b/xCAT-UI/js/custom/zvm.js index 127414eb8..57cc418c0 100644 --- a/xCAT-UI/js/custom/zvm.js +++ b/xCAT-UI/js/custom/zvm.js @@ -1,13 +1,13 @@ $(document).ready(function() { - // Include utility script + // Include utility scripts includeJs("js/custom/zvmUtils.js"); }); /** - * Load the clone page + * Load clone page * * @param node - * Source node + * Source node to clone * @return Nothing */ function loadClonePage(node) { @@ -31,9 +31,9 @@ function loadClonePage(node) { // Get hardware control point var nodeRow = $('#' + node).parent().parent(); - var myDataTable = getNodesDataTable(); - var rowPos = myDataTable.fnGetPosition(nodeRow.get(0)); - var aData = myDataTable.fnGetData(rowPos); + var dTable = getNodesDataTable(); + var rowPos = dTable.fnGetPosition(nodeRow.get(0)); + var aData = dTable.fnGetData(rowPos); var hcp = aData[hcpCol]; // Create status bar, hide on load @@ -50,19 +50,15 @@ function loadClonePage(node) { cloneForm.append(infoBar); // Target node range - cloneForm - .append('
'); + cloneForm.append('
'); // Target user ID range - cloneForm - .append('
'); + cloneForm.append('
'); // Create the rest of the form // Include clone source, hardware control point, group, disk pool, and // disk password - cloneForm - .append('
'); - cloneForm - .append('
'); + cloneForm.append('
'); + cloneForm.append('
'); // Group var group = $('
'); @@ -78,7 +74,6 @@ function loadClonePage(node) { $(this).autocomplete(groupNames.split(',')); } }); - group.append(groupLabel); group.append(groupInput); cloneForm.append(group); @@ -96,142 +91,114 @@ function loadClonePage(node) { poolDiv.append(poolInput); cloneForm.append(poolDiv); - cloneForm - .append('
'); + cloneForm.append('
'); /** * Clone */ var cloneBtn = createButton('Clone'); - cloneBtn - .bind('click', function(event) { - var ready = true; - var errMsg = ''; + cloneBtn.bind('click', function(event) { + var ready = true; + var errMsg = ''; - // Check node name, userId, hardware control point, group, - // and password - var inputs = $('#' + newTabId + ' input'); - for ( var i = 0; i < inputs.length; i++) { - if (!inputs.eq(i).val() - && inputs.eq(i).attr('name') != 'diskPw' - && inputs.eq(i).attr('name') != 'diskPool') { - inputs.eq(i).css('border', 'solid #FF0000 1px'); + // Check node name, userId, hardware control point, group, + // and password + var inputs = $('#' + newTabId + ' input'); + for ( var i = 0; i < inputs.length; i++) { + if (!inputs.eq(i).val() + && inputs.eq(i).attr('name') != 'diskPw' + && inputs.eq(i).attr('name') != 'diskPool') { + inputs.eq(i).css('border', 'solid #FF0000 1px'); + ready = false; + } else { + inputs.eq(i).css('border', 'solid #BDBDBD 1px'); + } + } + + if (!ready) { + errMsg = errMsg + 'You are missing some inputs. '; + } + + // Get target node + var nodeRange = $('#' + newTabId + ' input[name=tgtNode]').val(); + // Get target user ID + var userIdRange = $('#' + newTabId + ' input[name=tgtUserId]').val(); + + // Is a node range given + if (nodeRange.indexOf('-') > -1 || userIdRange.indexOf('-') > -1) { + if (nodeRange.indexOf('-') < 0 || userIdRange.indexOf('-') < 0) { + errMsg = errMsg + 'A user ID range and node range needs to be given. '; + ready = false; + } else { + var tmp = nodeRange.split('-'); + + // Get node base name + var nodeBase = tmp[0].match(/[a-zA-Z]+/); + // Get the starting index + var nodeStart = parseInt(tmp[0].match(/\d+/)); + // Get the ending index + var nodeEnd = parseInt(tmp[1]); + + tmp = userIdRange.split('-'); + + // Get user ID base name + var userIdBase = tmp[0].match(/[a-zA-Z]+/); + // Get the starting index + var userIdStart = parseInt(tmp[0].match(/\d+/)); + // Get the ending index + var userIdEnd = parseInt(tmp[1]); + + // If the starting and ending index do not match + if (!(nodeStart == userIdStart) || !(nodeEnd == userIdEnd)) { + // Not ready to provision + errMsg = errMsg + 'The node range and user ID range does not match. '; ready = false; - } else { - inputs.eq(i).css('border', 'solid #BDBDBD 1px'); } } + } - if (!ready) { - errMsg = errMsg + 'You are missing some inputs. '; - } + var srcNode = $('#' + newTabId + ' input[name=srcNode]').val(); + hcp = $('#' + newTabId + ' input[name=newHcp]').val(); + var group = $('#' + newTabId + ' input[name=newGroup]').val(); + var diskPool = $('#' + newTabId + ' input[name=diskPool]').val(); + var diskPw = $('#' + newTabId + ' input[name=diskPw]').val(); - // Get target node - var nodeRange = $('#' + newTabId + ' input[name=tgtNode]') - .val(); - // Get target user ID - var userIdRange = $('#' + newTabId + ' input[name=tgtUserId]') - .val(); + // If a value is given for every input + if (ready) { + // Disable all inputs + var inputs = cloneForm.find('input'); + inputs.attr('readonly', 'readonly'); + inputs.css( { + 'background-color' : '#F2F2F2' + }); - // Is a node range given - if (nodeRange.indexOf('-') > -1 - || userIdRange.indexOf('-') > -1) { - if (nodeRange.indexOf('-') < 0 - || userIdRange.indexOf('-') < 0) { - errMsg = errMsg + 'A user ID range and node range needs to be given. '; - ready = false; - } else { - var tmp = nodeRange.split('-'); + // If a node range is given + if (nodeRange.indexOf('-') > -1) { + var tmp = nodeRange.split('-'); - // Get node base name - var nodeBase = tmp[0].match(/[a-zA-Z]+/); - // Get the starting index - var nodeStart = parseInt(tmp[0].match(/\d+/)); - // Get the ending index - var nodeEnd = parseInt(tmp[1]); + // Get node base name + var nodeBase = tmp[0].match(/[a-zA-Z]+/); + // Get the starting index + var nodeStart = parseInt(tmp[0].match(/\d+/)); + // Get the ending index + var nodeEnd = parseInt(tmp[1]); - tmp = userIdRange.split('-'); + tmp = userIdRange.split('-'); - // Get user ID base name - var userIdBase = tmp[0].match(/[a-zA-Z]+/); - // Get the starting index - var userIdStart = parseInt(tmp[0].match(/\d+/)); - // Get the ending index - var userIdEnd = parseInt(tmp[1]); + // Get user ID base name + var userIdBase = tmp[0].match(/[a-zA-Z]+/); + // Get the starting index + var userIdStart = parseInt(tmp[0].match(/\d+/)); + // Get the ending index + var userIdEnd = parseInt(tmp[1]); - // Does starting and ending index match - if (!(nodeStart == userIdStart) - || !(nodeEnd == userIdEnd)) { - errMsg = errMsg + 'The node range and user ID range does not match. '; - ready = false; - } - } - } + for ( var i = nodeStart; i <= nodeEnd; i++) { + var node = nodeBase + i.toString(); + var userId = userIdBase + i.toString(); + var inst = i + '/' + nodeEnd; - var srcNode = $('#' + newTabId + ' input[name=srcNode]').val(); - hcp = $('#' + newTabId + ' input[name=newHcp]').val(); - var group = $('#' + newTabId + ' input[name=newGroup]').val(); - var diskPool = $('#' + newTabId + ' input[name=diskPool]') - .val(); - var diskPw = $('#' + newTabId + ' input[name=diskPw]').val(); - - // If a value is given for every input - if (ready) { - // Disable all inputs - var inputs = cloneForm.find('input'); - inputs.attr('readonly', 'readonly'); - inputs.css( { - 'background-color' : '#F2F2F2' - }); - - // If a node range is given - if (nodeRange.indexOf('-') > -1) { - var tmp = nodeRange.split('-'); - - // Get node base name - var nodeBase = tmp[0].match(/[a-zA-Z]+/); - // Get the starting index - var nodeStart = parseInt(tmp[0].match(/\d+/)); - // Get the ending index - var nodeEnd = parseInt(tmp[1]); - - tmp = userIdRange.split('-'); - - // Get user ID base name - var userIdBase = tmp[0].match(/[a-zA-Z]+/); - // Get the starting index - var userIdStart = parseInt(tmp[0].match(/\d+/)); - // Get the ending index - var userIdEnd = parseInt(tmp[1]); - - for ( var i = nodeStart; i <= nodeEnd; i++) { - var node = nodeBase + i.toString(); - var userId = userIdBase + i.toString(); - var inst = i + '/' + nodeEnd; - - /** - * 1. Define node - */ - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'nodeadd', - tgt : '', - args : node + ';zvm.hcp=' + hcp - + ';zvm.userid=' + userId - + ';nodehm.mgt=zvm' + ';groups=' - + group, - msg : 'cmd=nodeadd;inst=' + inst + ';out=' - + statBarId + ';node=' + node - }, - - success : updateCloneStatus - }); - } - } else { /** - * 1. Define node + * (1) Define node */ $.ajax( { url : 'lib/cmd.php', @@ -239,33 +206,54 @@ function loadClonePage(node) { data : { cmd : 'nodeadd', tgt : '', - args : nodeRange + ';zvm.hcp=' + hcp - + ';zvm.userid=' + userIdRange - + ';nodehm.mgt=zvm' + ';groups=' + group, - msg : 'cmd=nodeadd;inst=1/1;out=' + statBarId - + ';node=' + nodeRange + args : node + ';zvm.hcp=' + hcp + + ';zvm.userid=' + userId + + ';nodehm.mgt=zvm' + ';groups=' + + group, + msg : 'cmd=nodeadd;inst=' + inst + ';out=' + + statBarId + ';node=' + node }, success : updateCloneStatus }); } - - // Create loader - var loader = createLoader(''); - $('#' + statBarId).append(loader); - $('#' + statBarId).show(); - - // Stop this function from executing again - // Unbind event - $(this).unbind(event); - $(this).css( { - 'background-color' : '#F2F2F2', - 'color' : '#BDBDBD' - }); } else { - alert('(Error) ' + errMsg); + /** + * (1) Define node + */ + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'nodeadd', + tgt : '', + args : nodeRange + ';zvm.hcp=' + hcp + + ';zvm.userid=' + userIdRange + + ';nodehm.mgt=zvm' + ';groups=' + group, + msg : 'cmd=nodeadd;inst=1/1;out=' + statBarId + + ';node=' + nodeRange + }, + + success : updateCloneStatus + }); } - }); + + // Create loader + var loader = createLoader(''); + $('#' + statBarId).append(loader); + $('#' + statBarId).show(); + + // Stop this function from executing again + // Unbind event + $(this).unbind(event); + $(this).css( { + 'background-color' : '#F2F2F2', + 'color' : '#BDBDBD' + }); + } else { + alert('(Error) ' + errMsg); + } + }); cloneForm.append(cloneBtn); // Add clone tab @@ -297,15 +285,15 @@ function loadInventory(data) { $('#' + loaderId).remove(); // Create status bar - var statusBarId = node + 'StatusBar'; - var statusBar = createStatusBar(statusBarId); + var statBarId = node + 'StatusBar'; + var statBar = createStatusBar(statBarId); // Add loader to status bar, but hide it loaderId = node + 'StatusBarLoader'; var loader = createLoader(loaderId); - statusBar.append(loader); + statBar.append(loader); loader.hide(); - statusBar.hide(); + statBar.hide(); // Create array of property keys var keys = new Array('userId', 'host', 'os', 'arch', 'hcp', 'priv', @@ -345,7 +333,7 @@ function loadInventory(data) { $('#' + invDivId).toggle(); // Create loader - loader = createLoader(node + 'TabLoader'); + var loader = createLoader(node + 'TabLoader'); loader = $('
').append(loader); ueDiv.append(loader); @@ -378,7 +366,7 @@ function loadInventory(data) { toggleLnkDiv.append(toggleLink); /** - * General inventory + * General info */ var fieldSet = $('
'); var legend = $('General'); @@ -409,7 +397,7 @@ function loadInventory(data) { invDiv.append(fieldSet); /** - * Hardware inventory + * Hardware info */ var hwList, hwItem; fieldSet = $('
'); @@ -495,14 +483,16 @@ function loadInventory(data) { procTable.append(procTabRow); var procType, procAddr, procId, procAff; - // Create context menu - Remove processor - var contextMenu = [ { + /** + * Remove processor + */ + var contextMenu = [{ 'Remove' : function(menuItem, menu) { if (confirm('Are you sure?')) { removeProcessor(node, $(this).text()); } } - } ]; + }]; // Loop through each processor var closeBtn; @@ -562,30 +552,27 @@ function loadInventory(data) { * Add processor */ var addProcLink = $('Add processor'); - addProcLink - .bind( - 'click', - function(event) { - var procForm = '
' - + '
' - + '
' - + '
' - + '' + '
' + '
'; - - $.prompt(procForm, { - callback : addProcessor, - buttons : { - Ok : true, - Cancel : false - }, - prefix : 'cleanblue' - }); - }); + addProcLink.bind('click', function(event) { + var procForm = '
' + + '
' + + '
' + + '
' + + '' + '
' + '
'; + + $.prompt(procForm, { + callback : addProcessor, + buttons : { + Ok : true, + Cancel : false + }, + prefix : 'cleanblue' + }); + }); procFooter.append(addProcLink); procTable.append(procFooter); @@ -605,14 +592,16 @@ function loadInventory(data) { var dasdBody = $(''); var dasdFooter = $(''); - // Create context menu - Remove disk - contextMenu = [ { + /** + * Remove disk + */ + contextMenu = [{ 'Remove' : function(menuItem, menu) { if (confirm('Are you sure?')) { removeDisk(node, $(this).text()); } } - } ]; + }]; // Table columns - Virtual Device, Type, VolID, Type of Access, and // Size @@ -654,46 +643,45 @@ function loadInventory(data) { dasdTable.append(dasdBody); /** - * Add DASD + * Add disk */ var addDasdLink = $('Add disk'); - addDasdLink - .bind('click', function(event) { - // Get list of disk pools - var temp = attrs['hcp'][0].split('.'); - var cookie = $.cookie(temp[0] + 'DiskPools'); + addDasdLink.bind('click', function(event) { + // Get list of disk pools + var temp = attrs['hcp'][0].split('.'); + var cookie = $.cookie(temp[0] + 'DiskPools'); - // Create drop down list for disk pool - var pools = cookie.split(','); - var selectPool = ''; + // Create drop down list for disk pool + var pools = cookie.split(','); + var selectPool = ''; - var dasdForm = '
' - + '
' - + '
' - + '
' - + '
' - + '
' - + selectPool - + '
' - + '
' - + '
'; + var dasdForm = '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + selectPool + + '
' + + '
' + + '
'; - $.prompt(dasdForm, { - callback : addDisk, - buttons : { - Ok : true, - Cancel : false - }, - prefix : 'cleanblue' - }); + $.prompt(dasdForm, { + callback : addDisk, + buttons : { + Ok : true, + Cancel : false + }, + prefix : 'cleanblue' }); + }); dasdFooter.append(addDasdLink); dasdTable.append(dasdFooter); @@ -713,8 +701,9 @@ function loadInventory(data) { var nicBody = $(''); var nicFooter = $(''); - // Create context menu - Remove NIC - contextMenu = [ { + /** + * Remove NIC + */contextMenu = [ { 'Remove' : function(menuItem, menu) { if (confirm('Are you sure?')) { removeNic(node, $(this).text()); @@ -769,120 +758,119 @@ function loadInventory(data) { * Add NIC */ var addNicLink = $('Add NIC'); - addNicLink - .bind('click', function(event) { - // Get network names - var temp = attrs['hcp'][0].split('.'); - var networks = $.cookie(temp[0] + 'Networks').split(','); + addNicLink.bind('click', function(event) { + // Get network names + var temp = attrs['hcp'][0].split('.'); + var networks = $.cookie(temp[0] + 'Networks').split(','); - // Create a drop down list - var gLans = ''; - for ( var i = 0; i < networks.length; i++) { - var network = networks[i].split(' '); + // Create a drop down list + var gLans = ''; + for ( var i = 0; i < networks.length; i++) { + var network = networks[i].split(' '); - // Get VSwitches - if (network[0] == 'VSWITCH') { - vswitches = vswitches + ''; + // Get VSwitches + if (network[0] == 'VSWITCH') { + vswitches = vswitches + ''; + } + + // Get Guest LAN + else if (network[0] == 'LAN') { + gLans = gLans + ''; + } + } + vswitches = vswitches + ''; + gLans = gLans + ''; + + var nicTypeForm = '
' + + '
' + + '
' + + '
' + + '' + + '
' + + '
' + + '' + + '
' + '
'; + var configGuestLanForm = '
' + + '
' + + gLans + '
' + '
'; + var configVSwitchForm = '
' + + '
' + + vswitches + '
' + '
'; + + var states = { + // Select NIC type + type : { + html : nicTypeForm, + buttons : { + Ok : true, + Cancel : false + }, + focus : 1, + prefix : 'cleanblue', + submit : function(v, m, f) { + if (!v) { + return true; + } else { + var networkType = f.nicNetworkType; + if (networkType == 'Guest LAN') + $.prompt.goToState('configGuestLan'); + else + $.prompt.goToState('configVSwitch'); + return false; + } } + }, - // Get Guest LAN - else if (network[0] == 'LAN') { - gLans = gLans + ''; + // Configure guest LAN + configGuestLan : { + html : configGuestLanForm, + callback : addNic, + buttons : { + Ok : true, + Cancel : false + }, + focus : 1, + prefix : 'cleanblue', + submit : function(v, m, f) { + if (v) { + return true; + } + } + }, + + // Configure VSwitch + configVSwitch : { + html : configVSwitchForm, + callback : addNic, + buttons : { + Ok : true, + Cancel : false + }, + focus : 1, + prefix : 'cleanblue', + submit : function(v, m, f) { + if (v) { + return true; + } } } - vswitches = vswitches + ''; - gLans = gLans + ''; + }; - var nicTypeForm = '
' - + '
' - + '
' - + '
' - + '' - + '
' - + '
' - + '' - + '
' + '
'; - var configGuestLanForm = '
' - + '
' - + gLans + '
' + '
'; - var configVSwitchForm = '
' - + '
' - + vswitches + '
' + '
'; - - var states = { - // Select NIC type - type : { - html : nicTypeForm, - buttons : { - Ok : true, - Cancel : false - }, - focus : 1, - prefix : 'cleanblue', - submit : function(v, m, f) { - if (!v) { - return true; - } else { - var networkType = f.nicNetworkType; - if (networkType == 'Guest LAN') - $.prompt.goToState('configGuestLan'); - else - $.prompt.goToState('configVSwitch'); - return false; - } - } - }, - - // Configure guest LAN - configGuestLan : { - html : configGuestLanForm, - callback : addNic, - buttons : { - Ok : true, - Cancel : false - }, - focus : 1, - prefix : 'cleanblue', - submit : function(v, m, f) { - if (v) { - return true; - } - } - }, - - // Configure VSwitch - configVSwitch : { - html : configVSwitchForm, - callback : addNic, - buttons : { - Ok : true, - Cancel : false - }, - focus : 1, - prefix : 'cleanblue', - submit : function(v, m, f) { - if (v) { - return true; - } - } - } - }; - - $.prompt(states, { - callback : addNic, - prefix : 'cleanblue' - }); + $.prompt(states, { + callback : addNic, + prefix : 'cleanblue' }); + }); nicFooter.append(addNicLink); nicTable.append(nicFooter); @@ -897,14 +885,14 @@ function loadInventory(data) { invDiv.append(fieldSet); // Append to tab - $('#' + tabId).append(statusBar); + $('#' + tabId).append(statBar); $('#' + tabId).append(toggleLnkDiv); $('#' + tabId).append(ueDiv); $('#' + tabId).append(invDiv); } /** - * Load zVM provision page + * Load provision page * * @param tabId * The provision tab ID @@ -1128,169 +1116,90 @@ function loadProvisionPage(tabId) { * Provision */ var provisionBtn = createButton('Provision'); - provisionBtn - .bind('click', function(event) { - var ready = true; - errMsg = ''; + provisionBtn.bind('click', function(event) { + var ready = true; + errMsg = ''; - // Get the tab ID - var thisTabId = $(this).parent().parent().attr('id'); - var out2Id = thisTabId.replace('zvmProvisionTab', ''); + // Get the tab ID + var thisTabId = $(this).parent().parent().attr('id'); + var out2Id = thisTabId.replace('zvmProvisionTab', ''); - // Check node name, userId, hardware control point, and - // group - var inputs = $('#' + thisTabId + ' input'); - for ( var i = 0; i < inputs.length; i++) { - // Do not check OS or disk password - if (!inputs.eq(i).val() && inputs.eq(i).attr('name') != 'os' - && inputs.eq(i).attr('type') != 'password') { - inputs.eq(i).css('border', 'solid #FF0000 1px'); - ready = false; - } else { - inputs.eq(i).css('border', 'solid #BDBDBD 1px'); - } - } - - // Check user entry - var thisUserEntry = $('#' + thisTabId + ' textarea'); - thisUserEntry.val(thisUserEntry.val().toUpperCase()); - if (!thisUserEntry.val()) { - thisUserEntry.css('border', 'solid #FF0000 1px'); + // Check node name, userId, hardware control point, and group + var inputs = $('#' + thisTabId + ' input'); + for ( var i = 0; i < inputs.length; i++) { + // Do not check OS or disk password + if (!inputs.eq(i).val() && inputs.eq(i).attr('name') != 'os' + && inputs.eq(i).attr('type') != 'password') { + inputs.eq(i).css('border', 'solid #FF0000 1px'); ready = false; } else { - thisUserEntry.css('border', 'solid #BDBDBD 1px'); + inputs.eq(i).css('border', 'solid #BDBDBD 1px'); } + } - // Check if user entry contains user ID - var thisUserId = $('#' + thisTabId + ' input[name=userId]'); - var pos = thisUserEntry.val().indexOf( - 'USER ' + thisUserId.val().toUpperCase()); - if (pos < 0) { - errMsg = errMsg + 'The user entry does not contain the correct user ID. '; + // Check user entry + var thisUserEntry = $('#' + thisTabId + ' textarea'); + thisUserEntry.val(thisUserEntry.val().toUpperCase()); + if (!thisUserEntry.val()) { + thisUserEntry.css('border', 'solid #FF0000 1px'); + ready = false; + } else { + thisUserEntry.css('border', 'solid #BDBDBD 1px'); + } + + // Check if user entry contains user ID + var thisUserId = $('#' + thisTabId + ' input[name=userId]'); + var pos = thisUserEntry.val().indexOf( + 'USER ' + thisUserId.val().toUpperCase()); + if (pos < 0) { + errMsg = errMsg + 'The user entry does not contain the correct user ID. '; + ready = false; + } + + // If no operating system is specified, create only user entry + os = $('#' + thisTabId + ' input[name=os]'); + + // Check number of disks + var diskRows = $('#' + thisTabId + ' table tr'); + // If an OS is given, disks are needed + if (os.val() && (diskRows.length < 1)) { + errMsg = errMsg + 'You need to add at some disks. '; + ready = false; + } + + // Check address, size, pool, and password + var diskArgs = $('#' + thisTabId + ' table input'); + for ( var i = 0; i < diskArgs.length; i++) { + if (!diskArgs.eq(i).val() + && diskArgs.eq(i).attr('type') != 'password') { + diskArgs.eq(i).css('border', 'solid #FF0000 1px'); ready = false; + } else { + diskArgs.eq(i).css('border', 'solid #BDBDBD 1px'); } + } - // If no operating system is specified, create only user - // entry - os = $('#' + thisTabId + ' input[name=os]'); - - // Check number of disks - var diskRows = $('#' + thisTabId + ' table tr'); - // If an OS is given, disks are needed - if (os.val() && (diskRows.length < 1)) { - errMsg = errMsg + 'You need to add at some disks. '; - ready = false; - } - - // Check address, size, pool, and password - var diskArgs = $('#' + thisTabId + ' table input'); - for ( var i = 0; i < diskArgs.length; i++) { - if (!diskArgs.eq(i).val() - && diskArgs.eq(i).attr('type') != 'password') { - diskArgs.eq(i).css('border', 'solid #FF0000 1px'); - ready = false; - } else { - diskArgs.eq(i).css('border', 'solid #BDBDBD 1px'); + if (ready) { + if (!os.val()) { + /* + * If no OS is given, create a virtual server + */ + var msg = ''; + if (diskRows.length > 0) { + msg = 'Do you want to create virtual server(s) without an operating system ?'; } - } - if (ready) { - if (!os.val()) { - /** - * If no OS is given, create a virtual server - */ - var msg = ''; - if (diskRows.length > 0) { - msg = 'Do you want to create virtual server(s) without an operating system ?'; - } - - // If no disks are given, create a virtual - // server (no disk) - else { - msg = 'Do you want to create virtual server(s) without an operating system or disk(s) ?'; - } - - // If the user clicks Ok - if (confirm(msg)) { - // Stop this function from executing again - // Unbind event - provisionBtn.unbind('click'); - provisionBtn.css( { - 'background-color' : '#F2F2F2', - 'color' : '#BDBDBD' - }); - - // Show loader - $('#zProvisionStatBar' + out2Id).show(); - $('#zProvisionLoader' + out2Id).show(); - - // Stop this function from executing again - // Unbind event - addDiskLink.unbind('click'); - addDiskLink.css( { - 'color' : '#BDBDBD' - }); - - // Disable close button on disk table - $('#' + thisTabId + ' table span').unbind('click'); - - // Disable all fields - var inputs = $('#' + thisTabId + ' input'); - inputs.attr('readonly', 'readonly'); - inputs.css( { - 'background-color' : '#F2F2F2' - }); - - var textarea = $('#' + thisTabId + ' textarea'); - - // Add a new line at the end of the user entry - var tmp = jQuery.trim(textarea.val()); - textarea.val(tmp + '\n'); - - textarea.attr('readonly', 'readonly'); - textarea.css( { - 'background-color' : '#F2F2F2' - }); - - // Get node name - var node = $('#' + thisTabId + ' input[name=nodeName]') - .val(); - // Get userId - var userId = $('#' + thisTabId + ' input[name=userId]') - .val(); - // Get hardware control point - var hcp = $('#' + thisTabId + ' input[name=hcp]').val(); - // Get group - var group = $('#' + thisTabId + ' input[name=group]') - .val(); - - /** - * 1. Define node - */ - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'nodeadd', - tgt : '', - args : node + ';zvm.hcp=' + hcp - + ';zvm.userid=' + userId - + ';nodehm.mgt=zvm' + ';groups=' + group, - msg : 'cmd=nodeadd;out=' + out2Id - }, - - success : updateProvisionStatus - }); - } - } else { - /** - * Create a virtual server and install OS - */ + // If no disks are given, create a virtual server (no disk) + else { + msg = 'Do you want to create virtual server(s) without an operating system or disk(s) ?'; + } + // If the user clicks Ok + if (confirm(msg)) { // Stop this function from executing again // Unbind event - $(this).unbind(event); - $(this).css( { + provisionBtn.unbind('click'); + provisionBtn.css( { 'background-color' : '#F2F2F2', 'color' : '#BDBDBD' }); @@ -1336,10 +1245,11 @@ function loadProvisionPage(tabId) { // Get hardware control point var hcp = $('#' + thisTabId + ' input[name=hcp]').val(); // Get group - var group = $('#' + thisTabId + ' input[name=group]').val(); + var group = $('#' + thisTabId + ' input[name=group]') + .val(); /** - * 1. Define node + * (1) Define node */ $.ajax( { url : 'lib/cmd.php', @@ -1347,9 +1257,9 @@ function loadProvisionPage(tabId) { data : { cmd : 'nodeadd', tgt : '', - args : node + ';zvm.hcp=' + hcp + ';zvm.userid=' - + userId + ';nodehm.mgt=zvm' + ';groups=' - + group, + args : node + ';zvm.hcp=' + hcp + + ';zvm.userid=' + userId + + ';nodehm.mgt=zvm' + ';groups=' + group, msg : 'cmd=nodeadd;out=' + out2Id }, @@ -1357,9 +1267,83 @@ function loadProvisionPage(tabId) { }); } } else { - alert('(Error) ' + errMsg); + /** + * Create a virtual server and install OS + */ + + // Stop this function from executing again + // Unbind event + $(this).unbind(event); + $(this).css( { + 'background-color' : '#F2F2F2', + 'color' : '#BDBDBD' + }); + + // Show loader + $('#zProvisionStatBar' + out2Id).show(); + $('#zProvisionLoader' + out2Id).show(); + + // Stop this function from executing again + // Unbind event + addDiskLink.unbind('click'); + addDiskLink.css( { + 'color' : '#BDBDBD' + }); + + // Disable close button on disk table + $('#' + thisTabId + ' table span').unbind('click'); + + // Disable all fields + var inputs = $('#' + thisTabId + ' input'); + inputs.attr('readonly', 'readonly'); + inputs.css( { + 'background-color' : '#F2F2F2' + }); + + var textarea = $('#' + thisTabId + ' textarea'); + + // Add a new line at the end of the user entry + var tmp = jQuery.trim(textarea.val()); + textarea.val(tmp + '\n'); + + textarea.attr('readonly', 'readonly'); + textarea.css( { + 'background-color' : '#F2F2F2' + }); + + // Get node name + var node = $('#' + thisTabId + ' input[name=nodeName]') + .val(); + // Get userId + var userId = $('#' + thisTabId + ' input[name=userId]') + .val(); + // Get hardware control point + var hcp = $('#' + thisTabId + ' input[name=hcp]').val(); + // Get group + var group = $('#' + thisTabId + ' input[name=group]').val(); + + /** + * (1) Define node + */ + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'nodeadd', + tgt : '', + args : node + ';zvm.hcp=' + hcp + ';zvm.userid=' + + userId + ';nodehm.mgt=zvm' + ';groups=' + + group, + msg : 'cmd=nodeadd;out=' + out2Id + }, + + success : updateProvisionStatus + }); } - }); + } else { + alert('(Error) ' + errMsg); + } + }); provForm.append(provisionBtn); } diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js index cd071f374..cc9f1dd30 100644 --- a/xCAT-UI/js/custom/zvmUtils.js +++ b/xCAT-UI/js/custom/zvmUtils.js @@ -1,8 +1,8 @@ /** * Global variables */ -var diskDataTable; // zVM datatable containing disks -var networkDataTable; // zVM datatable containing networks +var diskDatatable; // zVM datatable containing disks +var networkDatatable; // zVM datatable containing networks /** * Get the disk datatable @@ -11,7 +11,7 @@ var networkDataTable; // zVM datatable containing networks * @return Data table object */ function getDiskDataTable() { - return diskDataTable; + return diskDatatable; } /** @@ -22,7 +22,7 @@ function getDiskDataTable() { * @return Nothing */ function setDiskDataTable(table) { - diskDataTable = table; + diskDatatable = table; } /** @@ -32,7 +32,7 @@ function setDiskDataTable(table) { * @return Data table object */ function getNetworkDataTable() { - return networkDataTable; + return networkDatatable; } /** @@ -43,7 +43,7 @@ function getNetworkDataTable() { * @return Nothing */ function setNetworkDataTable(table) { - networkDataTable = table; + networkDatatable = table; } /** @@ -115,7 +115,9 @@ function loadUserEntry(data) { cancelBtn.show(); }); - // Save button + /** + * Save + */ var saveBtn = createButton('Save'); saveBtn.hide(); saveBtn.bind('click', function(event) { @@ -144,7 +146,7 @@ function loadUserEntry(data) { }); // Increment node process and save it in a cookie - incrementZNodeProcess(node); + incrementNodeProcess(node); txtArea.attr('readonly', 'readonly'); txtArea.css( { @@ -158,7 +160,9 @@ function loadUserEntry(data) { cancelBtn.hide(); }); - // Cancel button + /** + * Cancel + */ var cancelBtn = createButton('Cancel'); cancelBtn.hide(); cancelBtn.bind('click', function(event) { @@ -188,20 +192,20 @@ function loadUserEntry(data) { * Node to set cookie for * @return Nothing */ -function incrementZNodeProcess(node) { +function incrementNodeProcess(node) { // Set cookie for number actions performed against node - var actions = $.cookie(node + 'Processes'); - if (actions) { + var procs = $.cookie(node + 'Processes'); + if (procs) { // One more process - actions = parseInt(actions) + 1; - $.cookie(node + 'Processes', actions); + procs = parseInt(procs) + 1; + $.cookie(node + 'Processes', procs); } else { $.cookie(node + 'Processes', 1); } } /** - * Update the provision status bar + * Update the provision status * * @param data * Data returned from HTTP request @@ -235,10 +239,9 @@ function updateProvisionStatus(data) { var osImage = $('#' + tabId + ' input[name=os]').val(); /** - * 2. Update /etc/hosts + * (2) Update /etc/hosts */ if (cmd == 'nodeadd') { - // If no output, no errors occurred if (rsp.length) { $('#' + statBarId).append( @@ -264,7 +267,7 @@ function updateProvisionStatus(data) { } /** - * 3. Update DNS + * (3) Update DNS */ else if (cmd == 'makehosts') { // If no output, no errors occurred @@ -291,7 +294,7 @@ function updateProvisionStatus(data) { } /** - * 4. Create user entry + * (4) Create user entry */ else if (cmd == 'makedns') { // Reset the number of tries @@ -325,7 +328,7 @@ function updateProvisionStatus(data) { } /** - * 5. Add disk and format disk + * (5) Add disk */ else if (cmd == 'mkvm') { var failed = false; @@ -383,14 +386,12 @@ function updateProvisionStatus(data) { } // If there were no errors else { - // Reset the number of tries $.cookie('tries4' + tabId, 0); // Set cookie for number of disks var diskRows = $('#' + tabId + ' table tr'); $.cookie('zProvisionDisks2Add' + out2Id, diskRows.length); - if (diskRows.length > 0) { for ( var i = 0; i < diskRows.length; i++) { var diskArgs = diskRows.eq(i).find('td'); @@ -431,7 +432,7 @@ function updateProvisionStatus(data) { } /** - * 6. Set the operating system for given node + * (6) Set the operating system for given node */ else if (cmd == 'chvm') { var failed = false; @@ -550,7 +551,7 @@ function updateProvisionStatus(data) { } /** - * 7. Update DHCP + * (7) Update DHCP */ else if (cmd == 'noderes') { // If no output, no errors occurred @@ -578,7 +579,7 @@ function updateProvisionStatus(data) { } /** - * 8. Prepare node for boot + * (8) Prepare node for boot */ else if (cmd == 'makedhcp') { var failed = false; @@ -619,7 +620,7 @@ function updateProvisionStatus(data) { } /** - * 9. Boot node from network + * (9) Boot node to network */ else if (cmd == 'nodeset') { var failed = false; @@ -667,7 +668,7 @@ function updateProvisionStatus(data) { } /** - * 10. Done + * (10) Done */ else if (cmd == 'rnetboot') { var failed = false; @@ -705,7 +706,7 @@ function updateProvisionStatus(data) { } /** - * Update node status bar + * Update zVM node status * * @param data * Data returned from HTTP request @@ -720,13 +721,14 @@ function updateZNodeStatus(data) { // One less process actions = actions - 1; $.cookie(node + 'Processes', actions); + if (actions < 1) { // Hide loader when there are no more processes var statusBarLoaderId = node + 'StatusBarLoader'; $('#' + statusBarLoaderId).hide(); } - var statusId = node + 'StatusBar'; + var statBarId = node + 'StatusBar'; var failed = false; // Separate output into lines @@ -746,11 +748,11 @@ function updateZNodeStatus(data) { } } - $('#' + statusId).append(p); + $('#' + statBarId).append(p); } /** - * Update the clone status bar + * Update the clone status * * @param data * Data returned from HTTP request @@ -766,7 +768,7 @@ function updateCloneStatus(data) { var out2Id = args[2].replace('out=', ''); /** - * 2. Update /etc/hosts + * (2) Update /etc/hosts */ if (cmd == 'nodeadd') { var node = args[3].replace('node=', ''); @@ -800,7 +802,7 @@ function updateCloneStatus(data) { } /** - * 3. Update DNS + * (3) Update DNS */ else if (cmd == 'makehosts') { // If no output, no errors occurred @@ -827,7 +829,7 @@ function updateCloneStatus(data) { } /** - * 4. Clone + * (4) Clone */ else if (cmd == 'makedns') { // Separate output into lines @@ -841,6 +843,8 @@ function updateCloneStatus(data) { $('#' + out2Id).append(p); + // The tab must be opened for this to work + // Get clone tab var tabId = out2Id.replace('CloneStatusBar', 'CloneTab'); @@ -849,6 +853,7 @@ function updateCloneStatus(data) { var tgtNodes = ''; if (tgtNodeRange.indexOf('-') > -1) { var tmp = tgtNodeRange.split('-'); + // Get node base name var nodeBase = tmp[0].match(/[a-zA-Z]+/); // Get the starting index @@ -867,9 +872,7 @@ function updateCloneStatus(data) { } else { tgtNodes = tgtNodeRange; } - - // The tab must be opened for this to work - + // Get other inputs var srcNode = $('#' + tabId + ' input[name=srcNode]').val(); hcp = $('#' + tabId + ' input[name=newHcp]').val(); @@ -896,7 +899,7 @@ function updateCloneStatus(data) { } /** - * 5. Done + * (5) Done */ else if (cmd == 'mkvm') { var failed = false; @@ -924,14 +927,14 @@ function updateCloneStatus(data) { } /** - * Get the resources + * Get zVM resources * * @param data * Data from HTTP request * @return Nothing */ function getZResources(data) { - // Do not set cookie if there is no output + // Do not continue if there is no output if (data.rsp) { // Loop through each line var node, hcp; @@ -1007,7 +1010,6 @@ function getNodeAttrs(keys, propNames, data) { // Loop through property keys // Does this line contains one of the properties? for ( var j = 0; j < keys.length; j++) { - // Find property name if (data[i].indexOf(propNames[keys[j]]) > -1) { attrs[keys[j]] = new Array(); @@ -1073,7 +1075,7 @@ function addProcessor(v, m, f) { }); // Increment node process and save it in a cookie - incrementZNodeProcess(node); + incrementNodeProcess(node); // Show loader var statusId = node + 'StatusBar'; @@ -1122,7 +1124,7 @@ function addDisk(v, m, f) { }); // Increment node process and save it in a cookie - incrementZNodeProcess(node); + incrementNodeProcess(node); // Show loader var statusId = node + 'StatusBar'; @@ -1200,7 +1202,7 @@ function addNic(v, m, f) { } // Increment node process and save it in a cookie - incrementZNodeProcess(node); + incrementNodeProcess(node); // Show loader var statusId = node + 'StatusBar'; @@ -1235,7 +1237,7 @@ function removeProcessor(node, address) { }); // Increment node process and save it in a cookie - incrementZNodeProcess(node); + incrementNodeProcess(node); // Show loader var statusId = node + 'StatusBar'; @@ -1269,7 +1271,7 @@ function removeDisk(node, address) { }); // Increment node process and save it in a cookie - incrementZNodeProcess(node); + incrementNodeProcess(node); // Show loader var statusId = node + 'StatusBar'; @@ -1306,7 +1308,7 @@ function removeNic(node, nic) { }); // Set cookie for number actions performed against node - incrementZNodeProcess(node); + incrementNodeProcess(node); // Show loader var statusId = node + 'StatusBar'; diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js index 396a8702e..a2feb0302 100644 --- a/xCAT-UI/js/nodes/nodes.js +++ b/xCAT-UI/js/nodes/nodes.js @@ -203,7 +203,7 @@ function loadNodes(data) { // Load the plugin code // Plugin code should be located under js/custom/ - // Plugin names should be valid values of mgt + // Plugin names should be valid values of nodehm.mgt for ( var p in plugins) { resetJs(); includeJs("js/custom/" + p + ".js"); @@ -858,14 +858,14 @@ function loadNodesetPage(trgtNodes) { var nodesetForm = $('
'); // Create status bar - var barId = 'nodesetStatusBar' + inst; - var statusBar = createStatusBar(barId); - statusBar.hide(); - nodesetForm.append(statusBar); + var statBarId = 'nodesetStatusBar' + inst; + var statBar = createStatusBar(statBarId); + statBar.hide(); + nodesetForm.append(statBar); // Create loader var loader = createLoader('nodesetLoader'); - statusBar.append(loader); + statBar.append(loader); // Create info bar var infoBar = createInfoBar('Set the boot state for a node range'); @@ -997,7 +997,7 @@ function loadNodesetPage(trgtNodes) { }); /** - * 1. Set the OS, arch, and profile + * (1) Set the OS, arch, and profile */ $.ajax( { url : 'lib/cmd.php', @@ -1015,7 +1015,7 @@ function loadNodesetPage(trgtNodes) { }); // Show status bar - statusBar.show(); + statBar.show(); } else { alert('You are missing some values'); } @@ -1174,7 +1174,7 @@ function loadNetbootPage(tgtNodes) { }); /** - * 1. Boot to network + * (1) Boot to network */ $.ajax( { url : 'lib/cmd.php', @@ -1431,7 +1431,7 @@ function loadUpdatenodePage(tgtNodes) { }); /** - * 1. Boot to network + * (1) Boot to network */ $.ajax( { url : 'lib/cmd.php', @@ -1455,7 +1455,7 @@ function loadUpdatenodePage(tgtNodes) { updatenodeForm.append(okBtn); // Append to discover tab - tab.add(newTabId, 'updatenode', updatenodeForm); + tab.add(newTabId, 'Updatenode', updatenodeForm); // Select new tab tab.select(newTabId); @@ -1625,7 +1625,7 @@ function updateNodesetStatus(data) { var method = $('#' + tabId + ' select[id=bootMethod]').val(); /** - * 2. Update /etc/hosts + * (2) Update /etc/hosts */ if (cmd == 'nodeadd') { // If no output, no errors occurred @@ -1682,7 +1682,7 @@ function updateNodesetStatus(data) { } /** - * 4. Update DNS + * (4) Update DNS */ else if (cmd == 'makehosts') { // If no output, no errors occurred @@ -1709,7 +1709,7 @@ function updateNodesetStatus(data) { } /** - * 5. Update DHCP + * (5) Update DHCP */ else if (cmd == 'makedns') { // Separate output into lines @@ -1739,7 +1739,7 @@ function updateNodesetStatus(data) { } /** - * 6. Prepare node for boot + * (6) Prepare node for boot */ else if (cmd == 'makedhcp') { var failed = false; @@ -1780,7 +1780,7 @@ function updateNodesetStatus(data) { } /** - * 7. Boot node from network + * (7) Boot node from network */ else if (cmd == 'nodeset') { var tgtsArray = tgts.split(','); @@ -1808,7 +1808,7 @@ function updateNodesetStatus(data) { } /** - * Update the status bar + * Update the status bar of a given tab * * @param data * Data returned from HTTP request @@ -1848,8 +1848,7 @@ function updateStatusBar(data) { for ( var i = 0; i < rsp.length; i++) { if (rsp[i]) { // Determine if the command failed - if (rsp[i].indexOf("Error") > -1 - || rsp[i].indexOf("Failed") > -1) { + if (rsp[i].indexOf("Error") > -1 || rsp[i].indexOf("Failed") > -1) { failed = true; } @@ -1886,8 +1885,7 @@ function updateStatusBar(data) { if (rsp[i]) { // Find the node name and insert a break before it for ( var j = 0; j < tgts.length; j++) { - rsp[i] = rsp[i].replace(new RegExp(tgts[j], 'g'), - '
' + tgts[j]); + rsp[i] = rsp[i].replace(new RegExp(tgts[j], 'g'), '
' + tgts[j]); } p.append(rsp[i]); @@ -1900,7 +1898,7 @@ function updateStatusBar(data) { } /** - * Check the completeness of the form + * Check if the form is complete * * @param tabId * Tab ID containing form @@ -1915,6 +1913,7 @@ function formComplete(tabId) { // If there is no value given in the input if (!inputs.eq(i).val()) { inputs.eq(i).css('border', 'solid #FF0000 1px'); + // It is not complete ready = false; } else { @@ -1926,7 +1925,7 @@ function formComplete(tabId) { } /** - * Update the power status of the node + * Update the power status of a node in the datatable * * @param data * Data from HTTP request diff --git a/xCAT-UI/js/provision/provision.js b/xCAT-UI/js/provision/provision.js index 9c57044fe..515d7d125 100644 --- a/xCAT-UI/js/provision/provision.js +++ b/xCAT-UI/js/provision/provision.js @@ -99,6 +99,7 @@ function loadProvisionPage() { tab.add(newTabId, hw, ''); // Load plugin code + resetJs(); includeJs("js/custom/" + hw + ".js"); // Select tab diff --git a/xCAT-UI/lib/functions.php b/xCAT-UI/lib/functions.php index b35e1d32b..79ae00801 100644 --- a/xCAT-UI/lib/functions.php +++ b/xCAT-UI/lib/functions.php @@ -111,7 +111,7 @@ function submit_request($req, $skipVerify){ * $key * @return */ -function xorcrypt($data,$key) { +function xorcrypt($data, $key) { $datalen = strlen($data); $keylen = strlen($key); for ($i=0;$i<$datalen;$i++) { @@ -142,7 +142,7 @@ function getpassword() { /** * Get the password splitting knowledge between server * and client side persistant storage. Caller should regenerate - * session id when contemplating a new user/password, to preclude + * session ID when contemplating a new user/password, to preclude * session fixation, though fixation is limited without the secret. * * @param $password Password @@ -161,7 +161,7 @@ function setpassword($password) { } /** - * Get RAND characters. + * Get RAND characters * * @param $length Length of characters * @return RAND characters diff --git a/xCAT-UI/lib/zCmd.php b/xCAT-UI/lib/zCmd.php index 9b81d8162..03ec6eb38 100644 --- a/xCAT-UI/lib/zCmd.php +++ b/xCAT-UI/lib/zCmd.php @@ -95,7 +95,7 @@ if (isset($_GET["cmd"])) { } } - // Unlock virtual server + // Run shell script // This is a typical command used by all platforms. It is put here because // most of the code needed are already here else if (strncasecmp($cmd, "xdsh", 4) == 0) {