Formatted code.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12525 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
phamt 2012-05-04 14:23:08 +00:00
parent 5e12d730ff
commit 8c8d178eb3
5 changed files with 1776 additions and 1911 deletions

View File

@ -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 = '<table style="border: 0px none;">' +
'<tr>' +
'<td><div id="statuspie" class="summarypie"></div></td>' +
'<td><div id="ospie" class="summarypie"></div></td>' +
'<td><div id="archpie" class="summarypie"></div></td>' +
'<td><div id="statuspie" class="summarypie"></div></td>' +
'<td><div id="ospie" class="summarypie"></div></td>' +
'<td><div id="archpie" class="summarypie"></div></td>' +
'</tr>' +
'<tr>' +
'<td><div id="provmethodpie" class="summarypie"></td>' +
'<td><div id="nodetypepie" class="summarypie"></div></td>' +
'<td><div id="provmethodpie" class="summarypie"></td>' +
'<td><div id="nodetypepie" class="summarypie"></div></td>' +
'</tr></table>';
$('#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;
}

View File

@ -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 = $('<div class="form"></div>');
// Open new tab & create nodeset form
var nodesetForm = $('<div class="form"></div>');
// 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 = $('<div><label for="target">Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to set the boot state for"/></div>');
nodesetForm.append(tgt);
// Create target node or group
var tgt = $('<div><label for="target">Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to set the boot state for"/></div>');
nodesetForm.append(tgt);
// Create boot method drop down
var method = $('<div></div>');
var methodLabel = $('<label for="method">Boot method:</label>');
var methodSelect = $('<select id="bootMethod" name="bootMethod"></select>');
methodSelect.append('<option value="boot">boot</option>'
+ '<option value="install">install</option>'
+ '<option value="iscsiboot">iscsiboot</option>'
+ '<option value="netboot">netboot</option>'
+ '<option value="statelite">statelite</option>'
);
method.append(methodLabel);
method.append(methodSelect);
nodesetForm.append(method);
// Create boot method drop down
var method = $('<div></div>');
var methodLabel = $('<label for="method">Boot method:</label>');
var methodSelect = $('<select id="bootMethod" name="bootMethod"></select>');
methodSelect.append('<option value="boot">boot</option>'
+ '<option value="install">install</option>'
+ '<option value="iscsiboot">iscsiboot</option>'
+ '<option value="netboot">netboot</option>'
+ '<option value="statelite">statelite</option>'
);
method.append(methodLabel);
method.append(methodSelect);
nodesetForm.append(method);
// Create boot type drop down
var type = $('<div></div>');
var typeLabel = $('<label for="type">Boot type:</label>');
var typeSelect = $('<select id="bootType" name="bootType"></select>');
typeSelect.append('<option value="zvm">zvm</option>'
+ '<option value="install">pxe</option>'
+ '<option value="iscsiboot">yaboot</option>'
);
type.append(typeLabel);
type.append(typeSelect);
nodesetForm.append(type);
// Create boot type drop down
var type = $('<div></div>');
var typeLabel = $('<label for="type">Boot type:</label>');
var typeSelect = $('<select id="bootType" name="bootType"></select>');
typeSelect.append('<option value="zvm">zvm</option>'
+ '<option value="install">pxe</option>'
+ '<option value="iscsiboot">yaboot</option>'
);
type.append(typeLabel);
type.append(typeSelect);
nodesetForm.append(type);
// Create operating system input
var os = $('<div></div>');
var osLabel = $('<label for="os">Operating system:</label>');
var osInput = $('<input type="text" name="os" title="You must give the operating system of this node or node range, e.g. rhel5.5"/>');
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 = $('<div></div>');
var osLabel = $('<label for="os">Operating system:</label>');
var osInput = $('<input type="text" name="os" title="You must give the operating system of this node or node range, e.g. rhel5.5"/>');
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 = $('<div></div>');
var archLabel = $('<label for="arch">Architecture:</label>');
var archInput = $('<input type="text" name="arch" title="You must give the architecture of this node or node range, e.g. s390x"/>');
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 = $('<div></div>');
var archLabel = $('<label for="arch">Architecture:</label>');
var archInput = $('<input type="text" name="arch" title="You must give the architecture of this node or node range, e.g. s390x"/>');
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 = $('<div></div>');
var profileLabel = $('<label for="profile">Profile:</label>');
var profileInput = $('<input type="text" name="profile" title="You must give the profile for this node or node range. The typical default profile is: compute."/>');
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 = $('<div></div>');
var profileLabel = $('<label for="profile">Profile:</label>');
var profileInput = $('<input type="text" name="profile" title="You must give the profile for this node or node range. The typical default profile is: compute."/>');
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('<pre>(Error) Failed to create node definition</pre>');
} 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('<pre>Node definition created for ' + tgtNodesStr + '</pre>');
$.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('<pre>(Error) Failed to create node definition</pre>');
} 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('<pre>Node definition created for ' + tgtNodesStr + '</pre>');
$.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('<pre>(Error) Failed to update /etc/hosts</pre>');
} else {
$('#' + statBarId).find('div').append('<pre>/etc/hosts updated</pre>');
}
/**
* (4) Update DNS
*/
else if (cmd == 'makehosts') {
// If no output, no errors occurred
if (rsp.length) {
$('#' + statBarId).find('div').append('<pre>(Error) Failed to update /etc/hosts</pre>');
} else {
$('#' + statBarId).find('div').append('<pre>/etc/hosts updated</pre>');
}
// 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();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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 = $('<div class="form"></div>');
// Create netboot form
var netbootForm = $('<div class="form"></div>');
// 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 = $('<div><label for="target">Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to boot to network"/></div>');
netbootForm.append(target);
// Create target node or group input
var target = $('<div><label for="target">Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to boot to network"/></div>');
netbootForm.append(target);
// Create options
var optsDIV = $('<div></div>');
var optsLabel = $('<label>Options:</label>');
var optsList = $('<ul></ul>');
var opt = $('<li></li>');
optsList.append(opt);
optsDIV.append(optsLabel);
optsDIV.append(optsList);
netbootForm.append(optsDIV);
// Create boot order checkbox
var bootOrderChkBox = $('<input type="checkbox" id="s" name="s"/>');
opt.append(bootOrderChkBox);
opt.append('Set the boot device order');
// Create boot order input
var bootOrder = $('<li><label for="bootOrder">Boot order:</label><input type="text" name="bootOrder"/></li>');
bootOrder.hide();
optsList.append(bootOrder);
// Create force reboot checkbox
optsList.append('<li><input type="checkbox" id="F" name="F"/>Force reboot</li>');
// Create force shutdown checkbox
optsList.append('<li><input type="checkbox" id="f" name="f"/>Force immediate shutdown of the partition</li>');
if (osHash['AIX']) {
// Create iscsi dump checkbox
optsList.append('<li><input type="checkbox" id="I" name="I"/>Do a iscsi dump on AIX</li>');
}
// 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 = $('<div></div>');
var optsLabel = $('<label>Options:</label>');
var optsList = $('<ul></ul>');
var opt = $('<li></li>');
optsList.append(opt);
optsDIV.append(optsLabel);
optsDIV.append(optsList);
netbootForm.append(optsDIV);
// Create boot order checkbox
var bootOrderChkBox = $('<input type="checkbox" id="s" name="s"/>');
opt.append(bootOrderChkBox);
opt.append('Set the boot device order');
// Create boot order input
var bootOrder = $('<li><label for="bootOrder">Boot order:</label><input type="text" name="bootOrder"/></li>');
bootOrder.hide();
optsList.append(bootOrder);
// Create force reboot checkbox
optsList.append('<li><input type="checkbox" id="F" name="F"/>Force reboot</li>');
// Create force shutdown checkbox
optsList.append('<li><input type="checkbox" id="f" name="f"/>Force immediate shutdown of the partition</li>');
if (osHash['AIX']) {
// Create iscsi dump checkbox
optsList.append('<li><input type="checkbox" id="I" name="I"/>Do a iscsi dump on AIX</li>');
}
// 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('<div><label for="ipl">IPL:</label><input type="text" name="ipl" title="The virtual address to IPL"/></div>');
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('<div><label for="ipl">IPL:</label><input type="text" name="ipl" title="The virtual address to IPL"/></div>');
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);
}

View File

@ -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 = $('<div class="form"></div>');
// 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 = $('<div class="form"></div>');
// 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 = $('<div><label for="target">Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to update"/></div>');
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 = $('<div><label for="target">Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to update"/></div>');
updatenodeForm.append(tgt);
// Create options
var options = $('<div></div>');
var optionsLabel = $('<label>Options:</label>');
var optionsList = $('<ul></ul>');
options.append(optionsLabel);
options.append(optionsList);
updatenodeForm.append(options);
// Create update all software checkbox (only AIX)
if (osHash['AIX']) {
var updateAllOption = $('<li></li>');
var updateAllChkBox = $('<input type="checkbox" id="A" name="A"/>');
updateAllOption.append(updateAllChkBox);
optionsList.append(updateAllOption);
updateAllOption.append('Install or update all software contained in the source directory');
// Create source directory input
var allSwScrDirectory = $('<li><label for="allSwSrcDirectory" style="vertical-align: middle">Source directory:</label><input type="text" id="allSwSrcDirectory" name="allSwSrcDirectory"/></li>');
// 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 = $('<div></div>');
var optionsLabel = $('<label>Options:</label>');
var optionsList = $('<ul></ul>');
options.append(optionsLabel);
options.append(optionsList);
updatenodeForm.append(options);
// Create update all software checkbox (only AIX)
if (osHash['AIX']) {
var updateAllOption = $('<li></li>');
var updateAllChkBox = $('<input type="checkbox" id="A" name="A"/>');
updateAllOption.append(updateAllChkBox);
optionsList.append(updateAllOption);
updateAllOption.append('Install or update all software contained in the source directory');
// Create source directory input
var allSwScrDirectory = $('<li><label for="allSwSrcDirectory" style="vertical-align: middle">Source directory:</label><input type="text" id="allSwSrcDirectory" name="allSwSrcDirectory"/></li>');
// 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 = $('<li></li>');
var updateChkBox = $('<input type="checkbox" id="S" name="S"/>');
optionsList.append(updateOption);
updateOption.append(updateChkBox);
updateOption.append('Update existing software');
// Create source directory input
var scrDirectory = $('<li><label for="srcDirectory" style="vertical-align: middle">Source directory:</label><input type="text" id="srcDirectory" name="srcDirectory" title="You must give the source directory containing the updated software packages"/></li>');
// 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 = $('<li><label for="otherpkgs" style="vertical-align: middle">otherpkgs:</label><input type="text" id="otherpkgs" name="otherpkgs"/></li>');
otherPkgs.hide();
optionsList.append(otherPkgs);
// Create RPM flags input (only AIX)
var aixRpmFlags = $('<li><label for="rpm_flags">rpm_flags:</label><input type="text" name="rpm_flags"/></li>');
aixRpmFlags.hide();
optionsList.append(aixRpmFlags);
// Create installp flags input (only AIX)
var aixInstallPFlags = $('<li><label for="installp_flags">installp_flags:</label><input type="text" name="installp_flags"/></li>');
aixInstallPFlags.hide();
optionsList.append(aixInstallPFlags);
// Create emgr flags input (only AIX)
var aixEmgrFlags = $('<li><label for="emgr_flags">emgr_flags:</label><input type="text" name="emgr_flags"/></li>');
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 = $('<li></li>');
var postChkBox = $('<input type="checkbox" id="P" name="P"/>');
optionsList.append(postOption);
postOption.append(postChkBox);
postOption.append('Run postscripts');
var postscripts = $('<li><label for="postscripts" style="vertical-align: middle">Postscripts:</label><input type="text" id="postscripts" name="postscripts" title="You must give the postscript(s) to run"/></li>');
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('<li><input type="checkbox" id="F" name="F"/>Distribute and synchronize files</li>');
optionsList.append('<li><input type="checkbox" id="k" name="k"/>Update the ssh keys and host keys for the service nodes and compute nodes</li>');
// Create update OS checkbox
if (!osHash['AIX']) {
var osOption = $('<li></li>');
var osChkBox = $('<input type="checkbox" id="o" name="o"/>');
optionsList.append(osOption);
osOption.append(osChkBox);
osOption.append('Update the operating system');
var os = $('<li></li>').hide();
var osLabel = $('<label for="os">Operating system:</label>');
var osInput = $('<input type="text" name="os" title="You must give the operating system to upgrade to, e.g. rhel5.5"/>');
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 = $('<li></li>');
var updateChkBox = $('<input type="checkbox" id="S" name="S"/>');
optionsList.append(updateOption);
updateOption.append(updateChkBox);
updateOption.append('Update existing software');
// Create source directory input
var scrDirectory = $('<li><label for="srcDirectory" style="vertical-align: middle">Source directory:</label><input type="text" id="srcDirectory" name="srcDirectory" title="You must give the source directory containing the updated software packages"/></li>');
// 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 = $('<li><label for="otherpkgs" style="vertical-align: middle">otherpkgs:</label><input type="text" id="otherpkgs" name="otherpkgs"/></li>');
otherPkgs.hide();
optionsList.append(otherPkgs);
// Create RPM flags input (only AIX)
var aixRpmFlags = $('<li><label for="rpm_flags">rpm_flags:</label><input type="text" name="rpm_flags"/></li>');
aixRpmFlags.hide();
optionsList.append(aixRpmFlags);
// Create installp flags input (only AIX)
var aixInstallPFlags = $('<li><label for="installp_flags">installp_flags:</label><input type="text" name="installp_flags"/></li>');
aixInstallPFlags.hide();
optionsList.append(aixInstallPFlags);
// Create emgr flags input (only AIX)
var aixEmgrFlags = $('<li><label for="emgr_flags">emgr_flags:</label><input type="text" name="emgr_flags"/></li>');
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 = $('<li></li>');
var postChkBox = $('<input type="checkbox" id="P" name="P"/>');
optionsList.append(postOption);
postOption.append(postChkBox);
postOption.append('Run postscripts');
var postscripts = $('<li><label for="postscripts" style="vertical-align: middle">Postscripts:</label><input type="text" id="postscripts" name="postscripts" title="You must give the postscript(s) to run"/></li>');
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('<li><input type="checkbox" id="F" name="F"/>Distribute and synchronize files</li>');
optionsList.append('<li><input type="checkbox" id="k" name="k"/>Update the ssh keys and host keys for the service nodes and compute nodes</li>');
// Create update OS checkbox
if (!osHash['AIX']) {
var osOption = $('<li></li>');
var osChkBox = $('<input type="checkbox" id="o" name="o"/>');
optionsList.append(osOption);
osOption.append(osChkBox);
osOption.append('Update the operating system');
var os = $('<li></li>').hide();
var osLabel = $('<label for="os">Operating system:</label>');
var osInput = $('<input type="text" name="os" title="You must give the operating system to upgrade to, e.g. rhel5.5"/>');
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);
}