2010-07-29 17:32:24 +00:00
/ * *
* Load updatenode page
*
* @ param tgtNodes
* Targets to run updatenode against
* @ return Nothing
* /
function loadUpdatenodePage ( tgtNodes ) {
2010-08-04 15:47:41 +00:00
// Get OS images
2010-12-10 21:37:28 +00:00
$ . ajax ( {
2010-08-04 15:47:41 +00:00
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'tabdump' ,
tgt : '' ,
args : 'osimage' ,
msg : ''
} ,
success : setOSImageCookies
} ) ;
2010-12-10 21:37:28 +00:00
// Get node OS
2010-08-04 15:47:41 +00:00
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 ;
}
}
2010-07-29 17:32:24 +00:00
// 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 ;
}
2010-08-03 20:44:26 +00:00
2010-07-29 17:32:24 +00:00
// Create updatenode form
var updatenodeForm = $ ( '<div class="form"></div>' ) ;
// Create status bar
var statBarId = 'updatenodeStatusBar' + inst ;
2010-12-04 01:47:10 +00:00
var statusBar = createStatusBar ( statBarId ) . hide ( ) ;
2010-07-29 17:32:24 +00:00
updatenodeForm . append ( statusBar ) ;
// Create loader
var loader = createLoader ( 'updatenodeLoader' ) ;
statusBar . append ( loader ) ;
// Create info bar
var infoBar = createInfoBar ( 'Update nodes in an xCAT environment' ) ;
updatenodeForm . append ( infoBar ) ;
2010-12-10 21:37:28 +00:00
2010-07-29 17:32:24 +00:00
// Create target node or group input
2010-12-10 21:37:28 +00:00
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 ) ;
2010-07-29 17:32:24 +00:00
// Create options
2010-12-10 21:37:28 +00:00
var options = $ ( '<div></div>' ) ;
var optionsLabel = $ ( '<label>Options:</label>' ) ;
var optionsList = $ ( '<ul></ul>' ) ;
options . append ( optionsLabel ) ;
options . append ( optionsList ) ;
updatenodeForm . append ( options ) ;
2010-07-29 17:32:24 +00:00
2010-12-10 21:37:28 +00:00
// Create update all software checkbox (only AIX)
2010-08-04 15:47:41 +00:00
if ( osHash [ 'AIX' ] ) {
2010-12-10 21:37:28 +00:00
var updateAllOption = $ ( '<li></li>' ) ;
2010-08-04 15:47:41 +00:00
var updateAllChkBox = $ ( '<input type="checkbox" id="A" name="A"/>' ) ;
2010-12-10 21:37:28 +00:00
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'
} ] ,
2011-01-14 20:25:14 +00:00
imageUrl : 'images/serverbrowser/' ,
systemImageUrl : 'images/serverbrowser/' ,
2010-12-10 21:37:28 +00:00
handlerUrl : 'lib/getpath.php' ,
title : 'Browse' ,
requestMethod : 'POST' ,
width : '500' ,
height : '300' ,
2010-12-10 21:42:21 +00:00
basePath : '/install' // Limit user to only install directory
2010-12-10 21:37:28 +00:00
} ) ;
allSwScrDirectory . append ( allSWSrcDirBrowse ) ;
2010-08-04 15:47:41 +00:00
allSwScrDirectory . hide ( ) ;
2010-12-10 21:37:28 +00:00
optionsList . append ( allSwScrDirectory ) ;
// Show source directory when checked
2010-08-04 15:47:41 +00:00
updateAllChkBox . bind ( 'click' , function ( event ) {
if ( $ ( this ) . is ( ':checked' ) ) {
allSwScrDirectory . show ( ) ;
} else {
allSwScrDirectory . hide ( ) ;
}
} ) ;
}
2010-07-29 17:32:24 +00:00
// Create update software checkbox
2010-12-10 21:37:28 +00:00
var updateOption = $ ( '<li></li>' ) ;
2010-07-29 17:32:24 +00:00
var updateChkBox = $ ( '<input type="checkbox" id="S" name="S"/>' ) ;
2010-12-10 21:37:28 +00:00
optionsList . append ( updateOption ) ;
updateOption . append ( updateChkBox ) ;
updateOption . append ( 'Update existing software' ) ;
2010-07-29 17:32:24 +00:00
// Create source directory input
2010-12-10 21:37:28 +00:00
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'
} ] ,
2011-01-14 20:25:14 +00:00
imageUrl : 'images/serverbrowser/' ,
systemImageUrl : 'images/serverbrowser/' ,
2010-12-10 21:37:28 +00:00
handlerUrl : 'lib/getpath.php' ,
title : 'Browse' ,
requestMethod : 'POST' ,
width : '500' ,
height : '300' ,
2010-12-10 21:42:21 +00:00
basePath : '/install' // Limit user to only install directory
2010-12-10 21:37:28 +00:00
} ) ;
scrDirectory . append ( srcDirBrowse ) ;
2010-07-29 17:32:24 +00:00
scrDirectory . hide ( ) ;
2010-12-10 21:37:28 +00:00
optionsList . append ( scrDirectory ) ;
2010-07-29 17:32:24 +00:00
// Create other packages input
2010-12-10 21:37:28 +00:00
var otherPkgs = $ ( '<li><label for="otherpkgs" style="vertical-align: middle">otherpkgs:</label><input type="text" id="otherpkgs" name="otherpkgs"/></li>' ) ;
2010-07-29 17:32:24 +00:00
otherPkgs . hide ( ) ;
2010-12-10 21:37:28 +00:00
optionsList . append ( otherPkgs ) ;
2010-07-29 17:32:24 +00:00
2010-12-10 21:37:28 +00:00
// 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 ) ;
2010-07-29 17:32:24 +00:00
2010-12-10 21:37:28 +00:00
// 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 ) ;
2010-07-29 17:32:24 +00:00
2010-12-10 21:37:28 +00:00
// 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 ) ;
2010-08-04 15:47:41 +00:00
2010-12-10 21:37:28 +00:00
// Show flags when checked
2010-07-29 17:32:24 +00:00
updateChkBox . bind ( 'click' , function ( event ) {
if ( $ ( this ) . is ( ':checked' ) ) {
scrDirectory . show ( ) ;
otherPkgs . show ( ) ;
2010-08-04 15:47:41 +00:00
if ( osHash [ 'AIX' ] ) {
2010-12-10 21:37:28 +00:00
aixRpmFlags . show ( ) ;
aixInstallPFlags . show ( ) ;
aixEmgrFlags . show ( ) ;
2010-08-04 15:47:41 +00:00
}
2010-07-29 17:32:24 +00:00
} else {
scrDirectory . hide ( ) ;
otherPkgs . hide ( ) ;
2010-08-04 15:47:41 +00:00
if ( osHash [ 'AIX' ] ) {
2010-12-10 21:37:28 +00:00
aixRpmFlags . hide ( ) ;
aixInstallPFlags . hide ( ) ;
aixEmgrFlags . hide ( ) ;
2010-08-04 15:47:41 +00:00
}
2010-07-29 17:32:24 +00:00
}
} ) ;
// Create postscripts input
2010-12-10 21:37:28 +00:00
var postOption = $ ( '<li></li>' ) ;
2010-07-29 17:32:24 +00:00
var postChkBox = $ ( '<input type="checkbox" id="P" name="P"/>' ) ;
2010-12-10 21:37:28 +00:00
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>' ) ;
2010-07-29 17:32:24 +00:00
postscripts . hide ( ) ;
2010-12-10 21:37:28 +00:00
optionsList . append ( postscripts ) ;
2010-09-24 02:27:04 +00:00
2010-07-29 17:32:24 +00:00
// Show alternate source directory when checked
postChkBox . bind ( 'click' , function ( event ) {
if ( $ ( this ) . is ( ':checked' ) ) {
postscripts . show ( ) ;
} else {
postscripts . hide ( ) ;
}
} ) ;
2010-12-10 21:37:28 +00:00
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>' ) ;
2010-07-29 17:32:24 +00:00
// Create update OS checkbox
2010-08-04 15:47:41 +00:00
if ( ! osHash [ 'AIX' ] ) {
2010-12-10 21:37:28 +00:00
var osOption = $ ( '<li></li>' ) ;
2010-08-04 15:47:41 +00:00
var osChkBox = $ ( '<input type="checkbox" id="o" name="o"/>' ) ;
2010-12-10 21:37:28 +00:00
optionsList . append ( osOption ) ;
osOption . append ( osChkBox ) ;
osOption . append ( 'Update the operating system' ) ;
2010-08-04 15:47:41 +00:00
var os = $ ( '<li></li>' ) . hide ( ) ;
var osLabel = $ ( '<label for="os">Operating system:</label>' ) ;
2010-11-01 14:06:53 +00:00
var osInput = $ ( '<input type="text" name="os" title="You must give the operating system to upgrade to, e.g. rhel5.5"/>' ) ;
2010-08-04 15:47:41 +00:00
osInput . one ( 'focus' , function ( ) {
2010-11-22 16:18:55 +00:00
var tmp = $ . cookie ( 'osvers' ) ;
2010-08-04 15:47:41 +00:00
if ( tmp ) {
// Turn on auto complete
2011-01-14 15:16:44 +00:00
$ ( this ) . autocomplete ( {
source : tmp . split ( ',' )
} ) ;
2010-08-04 15:47:41 +00:00
}
} ) ;
os . append ( osLabel ) ;
os . append ( osInput ) ;
2010-12-10 21:37:28 +00:00
optionsList . append ( os ) ;
2010-08-04 15:47:41 +00:00
// Show alternate source directory when checked
osChkBox . bind ( 'click' , function ( event ) {
if ( $ ( this ) . is ( ':checked' ) ) {
os . show ( ) ;
} else {
os . hide ( ) ;
}
} ) ;
}
2010-07-29 17:32:24 +00:00
2010-11-01 14:06:53 +00:00
// Generate tooltips
updatenodeForm . find ( 'div input[title]' ) . tooltip ( {
2010-12-03 22:09:36 +00:00
position : "center right" ,
offset : [ - 2 , 10 ] ,
effect : "fade" ,
2010-12-04 16:04:06 +00:00
opacity : 0.7 ,
2010-12-10 14:38:30 +00:00
predelay : 800 ,
2010-12-04 16:04:06 +00:00
events : {
def : "mouseover,mouseout" ,
input : "mouseover,mouseout" ,
widget : "focus mouseover,blur mouseout" ,
tooltip : "mouseover,mouseout"
}
2010-11-01 14:06:53 +00:00
} ) ;
2010-07-29 17:32:24 +00:00
/ * *
* Ok
* /
var okBtn = createButton ( 'Ok' ) ;
okBtn . bind ( 'click' , function ( event ) {
2010-09-24 02:27:04 +00:00
// Remove any warning messages
$ ( this ) . parent ( ) . parent ( ) . find ( '.ui-state-error' ) . remove ( ) ;
2010-07-29 17:32:24 +00:00
var ready = true ;
// Generate arguments
var chkBoxes = $ ( "#" + newTabId + " input[type='checkbox']:checked" ) ;
2010-12-10 21:37:28 +00:00
var optionsStr = '' ;
var option ;
2010-07-29 17:32:24 +00:00
for ( var i = 0 ; i < chkBoxes . length ; i ++ ) {
2010-12-10 21:37:28 +00:00
option = chkBoxes . eq ( i ) . attr ( 'name' ) ;
optionsStr += '-' + option ;
2010-07-29 17:32:24 +00:00
// If update all software is checked
2010-12-10 21:37:28 +00:00
if ( option == 'S' ) {
2010-07-29 17:32:24 +00:00
var srcDir = $ ( '#' + newTabId + ' input[name=allSwSrcDirectory]' ) . val ( ) ;
if ( srcDir ) {
2010-12-10 21:37:28 +00:00
optionsStr += ';-d ' + srcDir ;
2010-09-24 02:27:04 +00:00
}
2010-07-29 17:32:24 +00:00
}
2010-09-24 02:27:04 +00:00
2010-07-29 17:32:24 +00:00
// If update software is checked
2010-12-10 21:37:28 +00:00
if ( option == 'S' ) {
2010-08-04 15:47:41 +00:00
// Get source directory
2010-12-10 21:37:28 +00:00
var srcDirectory = $ ( '#' + newTabId + ' input[name=srcDirectory]' ) . val ( ) ;
if ( srcDirectory ) {
optionsStr += ';-d;' + srcDirectory ;
2010-07-29 17:32:24 +00:00
}
2010-08-04 15:47:41 +00:00
// Get otherpkgs
2010-07-29 17:32:24 +00:00
var otherpkgs = $ ( '#' + newTabId + ' input[name=otherpkgs]' ) . val ( ) ;
if ( otherpkgs ) {
2010-12-10 21:37:28 +00:00
optionsStr += ';otherpkgs=' + otherpkgs ;
2010-07-29 17:32:24 +00:00
}
2010-08-04 15:47:41 +00:00
// Get rpm_flags
2010-07-29 17:32:24 +00:00
var rpm _flags = $ ( '#' + newTabId + ' input[name=rpm_flags]' ) . val ( ) ;
if ( rpm _flags ) {
2010-12-10 21:37:28 +00:00
optionsStr += ';rpm_flags=' + rpm _flags ;
2010-07-29 17:32:24 +00:00
}
2010-08-04 15:47:41 +00:00
// Get installp_flags
2010-07-29 17:32:24 +00:00
var installp _flags = $ ( '#' + newTabId + ' input[name=installp_flags]' ) . val ( ) ;
if ( installp _flags ) {
2010-12-10 21:37:28 +00:00
optionsStr += ';installp_flags=' + installp _flags ;
2010-07-29 17:32:24 +00:00
}
2010-08-04 15:47:41 +00:00
// Get emgr_flags
var emgr _flags = $ ( '#' + newTabId + ' input[name=emgr_flags]' ) . val ( ) ;
if ( emgr _flags ) {
2010-12-10 21:37:28 +00:00
optionsStr += ';emgr_flags=' + emgr _flags ;
2010-08-04 15:47:41 +00:00
}
2010-07-29 17:32:24 +00:00
}
// If postscripts is checked
2010-12-10 21:37:28 +00:00
if ( option == 'P' ) {
2010-07-29 17:32:24 +00:00
// Get postscripts
2010-12-10 21:37:28 +00:00
optionsStr += ';' + $ ( '#' + newTabId + ' input[name=postscripts]' ) . val ( ) ;
2010-07-29 17:32:24 +00:00
}
// If operating system is checked
2010-12-10 21:37:28 +00:00
if ( option == 'o' ) {
2010-07-29 17:32:24 +00:00
// Get the OS
2010-12-10 21:37:28 +00:00
optionsStr += ';' + $ ( '#' + newTabId + ' input[name=os]' ) . val ( ) ;
2010-07-29 17:32:24 +00:00
}
// Append ; to end of string
if ( i < ( chkBoxes . length - 1 ) ) {
2010-12-10 21:37:28 +00:00
optionsStr += ';' ;
2010-07-29 17:32:24 +00:00
}
}
// If no inputs are empty
if ( ready ) {
// Get nodes
var tgts = $ ( '#' + newTabId + ' input[name=target]' ) . val ( ) ;
2011-01-05 23:31:53 +00:00
// Disable all inputs and Ok button
$ ( '#' + newTabId + ' input' ) . attr ( 'disabled' , 'disabled' ) ;
2010-09-22 20:18:21 +00:00
$ ( this ) . attr ( 'disabled' , 'true' ) ;
2010-07-29 17:32:24 +00:00
/ * *
* ( 1 ) Boot to network
* /
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'updatenode' ,
tgt : tgts ,
2010-12-10 21:37:28 +00:00
args : optionsStr ,
2010-07-29 17:32:24 +00:00
msg : 'out=' + statBarId + ';cmd=updatenode;tgt=' + tgts
} ,
success : updateStatusBar
} ) ;
// Show status bar
statusBar . show ( ) ;
} else {
2010-09-24 02:27:04 +00:00
// Show warning message
var warn = createWarnBar ( 'You are missing some values' ) ;
warn . prependTo ( $ ( this ) . parent ( ) . parent ( ) ) ;
2010-07-29 17:32:24 +00:00
}
} ) ;
updatenodeForm . append ( okBtn ) ;
// Append to discover tab
2010-12-04 14:54:04 +00:00
tab . add ( newTabId , 'Update' , updatenodeForm , true ) ;
2010-07-29 17:32:24 +00:00
// Select new tab
tab . select ( newTabId ) ;
}