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
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'tabdump' ,
tgt : '' ,
args : 'osimage' ,
msg : ''
} ,
success : setOSImageCookies
} ) ;
// Get node OS (AIX, rh*, centos*, fedora*, or sles*)
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 ;
var statusBar = createStatusBar ( statBarId ) ;
statusBar . hide ( ) ;
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 ) ;
// Create target node or group input
2010-11-01 14:06:53 +00:00
var target = $ ( '<div><label for="target">Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to update"/></div>' ) ;
2010-07-29 17:32:24 +00:00
updatenodeForm . append ( target ) ;
// Create options
var optsDIV = $ ( '<div></div>' ) ;
var optsLabel = $ ( '<label>Options:</label>' ) ;
var optsList = $ ( '<ul></ul>' ) ;
optsDIV . append ( optsLabel ) ;
optsDIV . append ( optsList ) ;
updatenodeForm . append ( optsDIV ) ;
2010-08-04 15:47:41 +00:00
// Create update all software checkbox (AIX)
if ( osHash [ 'AIX' ] ) {
var updateAllChkBox = $ ( '<input type="checkbox" id="A" name="A"/>' ) ;
var updateAllOpt = $ ( '<li></li>' ) ;
optsList . append ( updateAllOpt ) ;
updateAllOpt . append ( updateAllChkBox ) ;
updateAllOpt . append ( 'Install or update all software contained in the source directory' ) ;
var allSwScrDirectory = $ ( '<li><label for="allSwSrcDirectory">Source directory:</label><input type="text" name="allSwSrcDirectory"/></li>' ) ;
allSwScrDirectory . hide ( ) ;
optsList . append ( allSwScrDirectory ) ;
// Show alternate source directory when checked
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
var updateChkBox = $ ( '<input type="checkbox" id="S" name="S"/>' ) ;
var updateOpt = $ ( '<li></li>' ) ;
optsList . append ( updateOpt ) ;
updateOpt . append ( updateChkBox ) ;
2010-08-04 15:47:41 +00:00
updateOpt . append ( 'Update existing software' ) ;
2010-07-29 17:32:24 +00:00
// Create source directory input
2010-11-01 14:06:53 +00:00
var scrDirectory = $ ( '<li><label for="srcDirectory">Source directory:</label><input type="text" name="srcDirectory" title="You must give the source directory containing the updated software packages"/></li>' ) ;
2010-07-29 17:32:24 +00:00
scrDirectory . hide ( ) ;
optsList . append ( scrDirectory ) ;
// Create other packages input
var otherPkgs = $ ( '<li><label for="otherpkgs">otherpkgs:</label><input type="text" name="otherpkgs"/></li>' ) ;
otherPkgs . hide ( ) ;
optsList . append ( otherPkgs ) ;
// Create RPM flags input
var rpmFlags = $ ( '<li><label for="rpm_flags">rpm_flags:</label><input type="text" name="rpm_flags"/></li>' ) ;
rpmFlags . hide ( ) ;
optsList . append ( rpmFlags ) ;
// Create installp flags input
var installPFlags = $ ( '<li><label for="installp_flags">installp_flags:</label><input type="text" name="installp_flags"/></li>' ) ;
installPFlags . hide ( ) ;
optsList . append ( installPFlags ) ;
2010-08-04 15:47:41 +00:00
// Create emgr flags input
var emgrFlags = $ ( '<li><label for="emgr_flags">emgr_flags:</label><input type="text" name="emgr_flags"/></li>' ) ;
emgrFlags . hide ( ) ;
optsList . append ( emgrFlags ) ;
2010-07-29 17:32:24 +00:00
// Show alternate source directory when checked
updateChkBox . bind ( 'click' , function ( event ) {
if ( $ ( this ) . is ( ':checked' ) ) {
scrDirectory . show ( ) ;
otherPkgs . show ( ) ;
2010-08-04 15:47:41 +00:00
if ( osHash [ 'AIX' ] ) {
rpmFlags . show ( ) ;
installPFlags . show ( ) ;
emgrFlags . show ( ) ;
}
2010-07-29 17:32:24 +00:00
} else {
scrDirectory . hide ( ) ;
otherPkgs . hide ( ) ;
2010-08-04 15:47:41 +00:00
if ( osHash [ 'AIX' ] ) {
rpmFlags . hide ( ) ;
installPFlags . hide ( ) ;
emgrFlags . hide ( ) ;
}
2010-07-29 17:32:24 +00:00
}
} ) ;
// Create postscripts input
var postChkBox = $ ( '<input type="checkbox" id="P" name="P"/>' ) ;
var postOpt = $ ( '<li></li>' ) ;
optsList . append ( postOpt ) ;
postOpt . append ( postChkBox ) ;
postOpt . append ( 'Run postscripts' ) ;
2010-11-01 14:06:53 +00:00
var postscripts = $ ( '<li><label for="postscripts">Postscripts:</label><input type="text" name="postscripts" title="You must give the postscript(s) to run"/></li>' ) ;
2010-07-29 17:32:24 +00:00
postscripts . hide ( ) ;
optsList . 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 ( ) ;
}
} ) ;
optsList . append ( '<li><input type="checkbox" id="F" name="F"/>Distribute and synchronize files</li>' ) ;
optsList . 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
2010-08-04 15:47:41 +00:00
if ( ! osHash [ 'AIX' ] ) {
var osChkBox = $ ( '<input type="checkbox" id="o" name="o"/>' ) ;
var osOpt = $ ( '<li></li>' ) ;
optsList . append ( osOpt ) ;
osOpt . append ( osChkBox ) ;
osOpt . append ( 'Update the operating system' ) ;
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 ( ) {
var tmp = $ . cookie ( 'OSVers' ) ;
if ( tmp ) {
// Turn on auto complete
$ ( this ) . autocomplete ( tmp . split ( ',' ) ) ;
}
} ) ;
os . append ( osLabel ) ;
os . append ( osInput ) ;
optsList . append ( os ) ;
// 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 ( {
position : "center right" , // Place tooltip on the right edge
offset : [ - 2 , 10 ] , // A little tweaking of the position
effect : "fade" , // Use the built-in fadeIn/fadeOut effect
opacity : 0.7 // Custom opacity setting
} ) ;
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" ) ;
var optStr = '' ;
var opt ;
for ( var i = 0 ; i < chkBoxes . length ; i ++ ) {
opt = chkBoxes . eq ( i ) . attr ( 'name' ) ;
optStr += '-' + opt ;
// If update all software is checked
if ( opt == 'S' ) {
var srcDir = $ ( '#' + newTabId + ' input[name=allSwSrcDirectory]' ) . val ( ) ;
if ( srcDir ) {
optStr += ';-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
if ( opt == 'S' ) {
2010-08-04 15:47:41 +00:00
// Get source directory
2010-07-29 17:32:24 +00:00
var srcDir = $ ( '#' + newTabId + ' input[name=srcDirectory]' ) . val ( ) ;
if ( srcDir ) {
optStr += ';-d;' + srcDir ;
}
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 ) {
optStr += ';otherpkgs=' + otherpkgs ;
}
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 ) {
optStr += ';rpm_flags=' + rpm _flags ;
}
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 ) {
optStr += ';installp_flags=' + installp _flags ;
}
2010-08-04 15:47:41 +00:00
// Get emgr_flags
var emgr _flags = $ ( '#' + newTabId + ' input[name=emgr_flags]' ) . val ( ) ;
if ( emgr _flags ) {
optStr += ';emgr_flags=' + emgr _flags ;
}
2010-07-29 17:32:24 +00:00
}
// If postscripts is checked
if ( opt == 'P' ) {
// Get postscripts
optStr += ';' + $ ( '#' + newTabId + ' input[name=postscripts]' ) . val ( ) ;
}
// If operating system is checked
if ( opt == 'o' ) {
// Get the OS
optStr += ';' + $ ( '#' + newTabId + ' input[name=os]' ) . 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 ( ) ;
// Disable Ok button
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 ,
args : optStr ,
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-08-03 14:58:08 +00:00
tab . add ( newTabId , 'Updatenode' , updatenodeForm , true ) ;
2010-07-29 17:32:24 +00:00
// Select new tab
tab . select ( newTabId ) ;
}