2010-12-01 01:54:05 +00:00
/ * *
* Global variables
* /
2012-03-14 19:20:37 +00:00
var origAttrs = new Object ( ) ; // Original image attributes
var defAttrs ; // Definable image attributes
2011-09-09 21:56:30 +00:00
var imgTableId = 'imagesDatatable' ; // Images datatable ID
2011-09-12 14:24:09 +00:00
var softwareList = {
"rsct" : [ "rsct.core.utils" , "rsct.core" , "src" ] ,
"pe" : [ "IBMJava2-142-ppc64-JRE" , "ibm_lapi_ip_rh6p" , "ibm_lapi_us_rh6p" , "IBM_pe_license" , "ibm_pe_rh6p" , "ppe_pdb_ppc64_rh600" , "sci_ppc_32bit_rh600" , "sci_ppc_64bit_rh600" , "vac.cmp" ,
"vac.lib" , "vac.lic" , "vacpp.cmp" , "vacpp.help.pdf" , "vacpp.lib" , "vacpp.man" , "vacpp.rte" , "vacpp.rte.lnk" , "vacpp.samples" , "xlf.cmp" , "xlf.help.pdf" , "xlf.lib" , "xlf.lic" , "xlf.man" ,
"xlf.msg.rte" , "xlf.rte" , "xlf.rte.lnk" , "xlf.samples" , "xlmass.lib" , "xlsmp.lib" , "xlsmp.msg.rte" , "xlsmp.rte" ] ,
"gpfs" : [ "gpfs.base" , "gpfs.gpl" , "gpfs.gplbin" , "gpfs.msg.en_US" ] ,
"essl" : [ "essl.3232.rte" , "essl.3264.rte" , "essl.6464.rte" , "essl.common" , "essl.license" , "essl.man" , "essl.msg" , "essl.rte" , "ibm-java2" , "pessl.common" , "pessl.license" , "pessl.man" ,
"pessl.msg" , "pessl.rte.ppe" ] ,
"loadl" : [ "IBMJava2" , "LoadL-full-license-RH6" , "LoadL-resmgr-full-RH6" , "LoadL-scheduler-full-RH6" ] ,
2011-09-20 07:13:01 +00:00
"ganglia" : [ "rrdtool" , "ganglia" , "ganglia-gmetad" , "ganglia-gmond" ] ,
2011-09-12 14:24:09 +00:00
"base" : [ "createrepo" ]
} ;
2010-12-01 01:54:05 +00:00
/ * *
* Load images page
*
* @ return Nothing
* /
function loadImagesPage ( ) {
// Set padding for images page
$ ( '#imagesTab' ) . css ( 'padding' , '20px 60px' ) ;
// Get images within the database
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'lsdef' ,
tgt : '' ,
args : '-t;osimage;-l' ,
msg : ''
} ,
success : loadImages
} ) ;
}
/ * *
* Load images within the database
*
* @ param data
* Data returned from HTTP request
* @ return Nothing
* /
function loadImages ( data ) {
// Data returned
var rsp = data . rsp ;
// Image attributes hash
var attrs = new Object ( ) ;
// Image attributes
var headers = new Object ( ) ;
// Clear hash table containing image attributes
origAttrs = '' ;
var image ;
var args ;
for ( var i in rsp ) {
// Get the image
var pos = rsp [ i ] . indexOf ( 'Object name:' ) ;
if ( pos > - 1 ) {
var temp = rsp [ i ] . split ( ': ' ) ;
image = jQuery . trim ( temp [ 1 ] ) ;
// Create a hash for the image attributes
attrs [ image ] = new Object ( ) ;
i ++ ;
}
// Get key and value
args = rsp [ i ] . split ( '=' ) ;
var key = jQuery . trim ( args [ 0 ] ) ;
var val = jQuery . trim ( args [ 1 ] ) ;
// Create a hash table
attrs [ image ] [ key ] = val ;
headers [ key ] = 1 ;
}
// Save attributes in hash table
origAttrs = attrs ;
// Sort headers
var sorted = new Array ( ) ;
for ( var key in headers ) {
sorted . push ( key ) ;
}
sorted . sort ( ) ;
// Add column for check box and image name
sorted . unshift ( '<input type="checkbox" onclick="selectAllCheckbox(event, $(this))">' , 'imagename' ) ;
// Create a datatable
2011-09-09 21:56:30 +00:00
var dTable = new DataTable ( imgTableId ) ;
2010-12-01 01:54:05 +00:00
dTable . init ( sorted ) ;
// Go through each image
for ( var img in attrs ) {
// Create a row
var row = new Array ( ) ;
// Create a check box
var checkBx = '<input type="checkbox" name="' + img + '"/>' ;
// Push in checkbox and image name
row . push ( checkBx , img ) ;
// Go through each header
for ( var i = 2 ; i < sorted . length ; i ++ ) {
// Add the node attributes to the row
var key = sorted [ i ] ;
var val = attrs [ img ] [ key ] ;
if ( val ) {
row . push ( val ) ;
} else {
row . push ( '' ) ;
}
}
// Add the row to the table
dTable . add ( row ) ;
}
// Clear the tab before inserting the table
$ ( '#imagesTab' ) . children ( ) . remove ( ) ;
// Create info bar for images tab
2012-04-06 02:31:08 +00:00
var info = createInfoBar ( 'Double click on a cell to edit. Click outside the table to save changes. Hit the Escape key to ignore changes.' ) ;
2010-12-01 01:54:05 +00:00
$ ( '#imagesTab' ) . append ( info ) ;
/ * *
2010-12-03 22:09:36 +00:00
* The following actions are available for images :
* copy Linux distribution and edit image properties
2010-12-01 01:54:05 +00:00
* /
2012-04-06 02:31:08 +00:00
// Copy CD into install directory
2011-09-09 21:56:30 +00:00
var copyCDLnk = $ ( '<a>Copy CD</a>' ) ;
copyCDLnk . click ( function ( ) {
2012-04-06 18:11:08 +00:00
openCopyCdDialog ( ) ;
2010-12-01 01:54:05 +00:00
} ) ;
2012-04-06 02:31:08 +00:00
// Generate stateless or statelite image
var generateLnk = $ ( '<a>Generate image</a>' ) ;
generateLnk . click ( function ( ) {
2011-03-28 09:02:54 +00:00
loadCreateImage ( ) ;
} ) ;
2012-04-06 02:31:08 +00:00
// Edit image attributes
var editLnk = $ ( '<a>Edit</a>' ) ;
editLnk . click ( function ( ) {
2011-09-09 21:56:30 +00:00
var tgtImages = getNodesChecked ( imgTableId ) . split ( ',' ) ;
2012-04-06 02:31:08 +00:00
if ( tgtImages ) {
for ( var i in tgtImages ) {
2012-04-06 18:11:08 +00:00
openEditImagePage ( tgtImages [ i ] ) ;
2012-04-06 02:31:08 +00:00
}
2010-12-01 01:54:05 +00:00
}
} ) ;
2010-12-03 22:09:36 +00:00
2012-04-06 02:31:08 +00:00
// Add a row
var addLnk = $ ( '<a>Add</a>' ) ;
addLnk . click ( function ( ) {
2012-04-06 18:11:08 +00:00
openAddImageDialog ( ) ;
2012-04-06 02:31:08 +00:00
} ) ;
// Remove a row
var removeLnk = $ ( '<a>Remove</a>' ) ;
removeLnk . click ( function ( ) {
var images = getNodesChecked ( imgTableId ) ;
if ( images ) {
confirmImageDeleteDialog ( images ) ;
}
} ) ;
// Refresh image table
var refreshLnk = $ ( '<a>Refresh</a>' ) ;
refreshLnk . click ( function ( ) {
// Get images within the database
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'lsdef' ,
tgt : '' ,
args : '-t;osimage;-l' ,
msg : ''
} ,
success : loadImages
} ) ;
} ) ;
2010-12-03 22:09:36 +00:00
// Insert table
$ ( '#imagesTab' ) . append ( dTable . object ( ) ) ;
2010-12-01 01:54:05 +00:00
// Turn table into a datatable
2011-09-09 21:56:30 +00:00
var myDataTable = $ ( '#' + imgTableId ) . dataTable ( {
'iDisplayLength' : 50 ,
'bLengthChange' : false ,
"sScrollX" : "100%" ,
"bAutoWidth" : true ,
"fnInitComplete" : function ( ) {
adjustColumnSize ( imgTableId ) ;
}
2010-12-01 01:54:05 +00:00
} ) ;
// Set datatable width
2011-09-09 21:56:30 +00:00
$ ( '#' + imgTableId + '_wrapper' ) . css ( {
'width' : '880px'
2010-12-01 01:54:05 +00:00
} ) ;
2011-09-09 21:56:30 +00:00
// Actions
var actionBar = $ ( '<div class="actionBar"></div>' ) ;
2012-04-06 02:31:08 +00:00
var advancedLnk = '<a>Advanced</a>' ;
var advancedMenu = createMenu ( [ copyCDLnk , generateLnk ] ) ;
2011-09-09 21:56:30 +00:00
// Create an action menu
2012-04-06 02:31:08 +00:00
var actionsMenu = createMenu ( [ refreshLnk , addLnk , editLnk , removeLnk , [ advancedLnk , advancedMenu ] ] ) ;
2011-09-09 21:56:30 +00:00
actionsMenu . superfish ( ) ;
actionsMenu . css ( 'display' , 'inline-block' ) ;
actionBar . append ( actionsMenu ) ;
2011-09-28 21:38:12 +00:00
// Set correct theme for action menu
actionsMenu . find ( 'li' ) . hover ( function ( ) {
setMenu2Theme ( $ ( this ) ) ;
} , function ( ) {
setMenu2Normal ( $ ( this ) ) ;
} ) ;
2011-09-09 21:56:30 +00:00
// Create a division to hold actions menu
var menuDiv = $ ( '<div id="' + imgTableId + '_menuDiv" class="menuDiv"></div>' ) ;
$ ( '#' + imgTableId + '_wrapper' ) . prepend ( menuDiv ) ;
menuDiv . append ( actionBar ) ;
$ ( '#' + imgTableId + '_filter' ) . appendTo ( menuDiv ) ;
2010-12-01 01:54:05 +00:00
/ * *
* Enable editable columns
* /
2010-12-21 02:47:30 +00:00
2012-04-06 02:31:08 +00:00
// Do not make 1st column editable
$ ( '#' + imgTableId + ' td:not(td:nth-child(1))' ) . editable (
2010-12-01 01:54:05 +00:00
function ( value , settings ) {
// Get column index
var colPos = this . cellIndex ;
// Get row index
2011-09-09 21:56:30 +00:00
var dTable = $ ( '#' + imgTableId ) . dataTable ( ) ;
2010-12-01 01:54:05 +00:00
var rowPos = dTable . fnGetPosition ( this . parentNode ) ;
// Update datatable
dTable . fnUpdate ( value , rowPos , colPos ) ;
// Get image name
var image = $ ( this ) . parent ( ) . find ( 'td:eq(1)' ) . text ( ) ;
2011-07-20 21:13:09 +00:00
// Get table headers
2011-09-09 21:56:30 +00:00
var headers = $ ( '#' + imgTableId ) . parents ( '.dataTables_scroll' ) . find ( '.dataTables_scrollHead thead tr:eq(0) th' ) ;
2011-07-20 21:13:09 +00:00
// Get attribute name
var attrName = jQuery . trim ( headers . eq ( colPos ) . text ( ) ) ;
// Get column value
var value = $ ( this ) . text ( ) ;
// Build argument
var args = attrName + '=' + value ;
// Send command to change image attributes
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chdef' ,
tgt : '' ,
args : '-t;osimage;-o;' + image + ';' + args ,
msg : 'out=imagesTab;tgt=' + image
} ,
2010-12-01 01:54:05 +00:00
2011-07-20 21:13:09 +00:00
success : showChdefOutput
} ) ;
return value ;
2010-12-01 01:54:05 +00:00
} , {
2010-12-03 22:09:36 +00:00
onblur : 'submit' , // Clicking outside editable area submits changes
type : 'textarea' , // Input type to use
2010-12-01 01:54:05 +00:00
placeholder : ' ' ,
2012-04-06 02:31:08 +00:00
event : "dblclick" , // Double click and edit
2010-12-01 01:54:05 +00:00
height : '30px' // The height of the text area
} ) ;
// Get definable node attributes
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'lsdef' ,
tgt : '' ,
args : '-t;osimage;-h' ,
msg : ''
} ,
success : setImageDefAttrs
} ) ;
}
2012-04-06 02:31:08 +00:00
/ * *
* Open dialog to confirm deleting image
*
* @ param images
* Comma delimited image names
* @ return Nothing
* /
function confirmImageDeleteDialog ( images ) {
// Make images list more readable
var dialogId = 'confirmImageRemove' ;
var tmp = images . replace ( new RegExp ( ',' , 'g' ) , ', ' ) ;
var confirmDialog = $ ( '<div id="' + dialogId + '">'
+ '<p>Are you sure you want to remove ' + tmp + '?</p>'
+ '</div>' ) ;
// Open dialog to confirm delete
confirmDialog . dialog ( {
modal : true ,
2012-04-12 16:11:00 +00:00
close : function ( ) {
$ ( this ) . remove ( ) ;
} ,
2012-04-06 02:31:08 +00:00
title : 'Confirm' ,
width : 500 ,
buttons : {
"Ok" : function ( ) {
// Change dialog buttons
$ ( this ) . dialog ( 'option' , 'buttons' , {
'Close' : function ( ) { $ ( this ) . dialog ( "close" ) ; }
} ) ;
// Add image to xCAT
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'rmdef' ,
tgt : '' ,
args : '-t;osimage;-o;' + images ,
msg : dialogId
} ,
success : updateImageDialog
} ) ;
} ,
"Cancel" : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
}
} ) ;
}
/ * *
* Open a dialog to add an image
* /
2012-04-06 18:11:08 +00:00
function openAddImageDialog ( ) {
2012-04-06 02:31:08 +00:00
// Create dialog to add image
var dialogId = 'addImage' ;
var addImageForm = $ ( '<div id="' + dialogId + '" class="form"></div>' ) ;
// Create info bar
var info = createInfoBar ( 'Provide the following attributes for the image. The image name will be generated based on the attributes you will give.' ) ;
addImageForm . append ( info ) ;
// Create inputs for image attributes
var imageName = $ ( '<div><label>Image name:</label><input type="text" name="imagename" disabled="disabled"/></div>' ) ;
var imageType = $ ( '<div><label>Image type:</label><input type="text" name="imagetype"/></div>' ) ;
var architecture = $ ( '<div><label>OS architecture:</label><input type="text" name="osarch"/></div>' ) ;
var osName = $ ( '<div><label>OS name:</label><input type="text" name="osname"/></div>' ) ;
var osVersion = $ ( '<div><label>OS version:</label><input type="text" name="osvers"/></div>' ) ;
var profile = $ ( '<div><label>Profile:</label><input type="text" name="profile"/></div>' ) ;
var provisionMethod = $ ( '<div><label>Provision method:</label></div>' ) ;
var provisionSelect = $ ( '<select name="provmethod">'
+ '<option value=""></option>'
+ '<option value="install">install</option>'
+ '<option value="netboot">netboot</option>'
+ '<option value="statelite">statelite</option>'
+ '</select>' ) ;
provisionMethod . append ( provisionSelect ) ;
// Create inputs for optional attributes
2012-04-06 18:11:08 +00:00
var exList = $ ( '<div><label>Exclusion list:</label></div>' ) ;
var exListInput = $ ( '<input type="text" name="exlist"/>' ) ;
exList . append ( exListInput ) ;
exListInput . serverBrowser ( {
onSelect : function ( path ) {
$ ( '#addImage input[name="exlist"]' ) . val ( path ) ;
} ,
onLoad : function ( ) {
return $ ( '#addImage input[name="exlist"]' ) . val ( ) ;
} ,
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
} ) ;
2012-04-06 02:31:08 +00:00
var otherpkgDirectory = $ ( '<div><label>Other package directory:</label></div>' ) ;
var otherpkgDirectoryInput = $ ( '<input type="text" name="otherpkgdir"/>' ) ;
otherpkgDirectory . append ( otherpkgDirectoryInput ) ;
otherpkgDirectoryInput . serverBrowser ( {
onSelect : function ( path ) {
$ ( '#addImage input[name="otherpkgdir"]' ) . val ( path ) ;
} ,
onLoad : function ( ) {
return $ ( '#addImage input[name="otherpkgdir"]' ) . val ( ) ;
} ,
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
} ) ;
var packageDirectory = $ ( '<div><label>Package directory:</label></div>' ) ;
var packageDirectoryInput = $ ( '<input type="text" name="pkgdir"/>' ) ;
packageDirectory . append ( packageDirectoryInput ) ;
packageDirectoryInput . serverBrowser ( {
onSelect : function ( path ) {
$ ( '#addImage input[name="pkgdir"]' ) . val ( path ) ;
} ,
onLoad : function ( ) {
return $ ( '#addImage input[name="pkgdir"]' ) . val ( ) ;
} ,
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
} ) ;
var packageList = $ ( '<div><label>Package list:</label></div>' ) ;
var packageListInput = $ ( '<input type="text" name="pkglist"/>' ) ;
packageList . append ( packageListInput ) ;
packageListInput . serverBrowser ( {
onSelect : function ( path ) {
$ ( '#addImage input[name="pkglist"]' ) . val ( path ) ;
} ,
onLoad : function ( ) {
return $ ( '#addImage input[name="pkglist"]' ) . val ( ) ;
} ,
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
} ) ;
2012-04-06 18:11:08 +00:00
var postInstall = $ ( '<div><label>Post install script:</label></div>' ) ;
var postInstallInput = $ ( '<input type="text" name="postinstall"/>' ) ;
postInstall . append ( postInstallInput ) ;
postInstallInput . serverBrowser ( {
onSelect : function ( path ) {
$ ( '#addImage input[name="postinstall"]' ) . val ( path ) ;
} ,
onLoad : function ( ) {
return $ ( '#addImage input[name="postinstall"]' ) . val ( ) ;
} ,
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
} ) ;
2012-04-06 02:31:08 +00:00
var template = $ ( '<div><label>Template:</label></div>' ) ;
var templateInput = $ ( '<input type="text" name="template"/>' ) ;
template . append ( templateInput ) ;
templateInput . serverBrowser ( {
onSelect : function ( path ) {
$ ( '#addImage input[name="template"]' ) . val ( path ) ;
} ,
onLoad : function ( ) {
return $ ( '#addImage input[name="template"]' ) . val ( ) ;
} ,
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
} ) ;
addImageForm . append ( imageName , imageType , architecture , osName , osVersion , profile , provisionMethod ,
2012-04-06 18:11:08 +00:00
exList , otherpkgDirectory , packageDirectory , packageList , postInstall , template ) ;
2012-04-06 02:31:08 +00:00
// Open dialog to add image
addImageForm . dialog ( {
title : 'Add image' ,
modal : true ,
2012-04-12 16:11:00 +00:00
close : function ( ) {
$ ( this ) . remove ( ) ;
} ,
2012-04-06 18:11:08 +00:00
width : 400 ,
2012-04-06 02:31:08 +00:00
buttons : {
"Ok" : function ( ) {
// Remove any warning messages
$ ( this ) . find ( '.ui-state-error' ) . remove ( ) ;
// Get image attributes
2012-04-06 18:11:08 +00:00
var imageType = $ ( this ) . find ( 'input[name="imagetype"]' ) ;
var architecture = $ ( this ) . find ( 'input[name="osarch"]' ) ;
var osName = $ ( this ) . find ( 'input[name="osname"]' ) ;
var osVersion = $ ( this ) . find ( 'input[name="osvers"]' ) ;
var profile = $ ( this ) . find ( 'input[name="profile"]' ) ;
var provisionMethod = $ ( this ) . find ( 'select[name="provmethod"]' ) ;
2012-04-06 02:31:08 +00:00
// Get optional image attributes
2012-04-06 18:11:08 +00:00
var exList = $ ( this ) . find ( 'input[name="exlist"]' ) ;
var otherpkgDirectory = $ ( this ) . find ( 'input[name="otherpkgdir"]' ) ;
var pkgDirectory = $ ( this ) . find ( 'input[name="pkgdir"]' ) ;
var pkgList = $ ( this ) . find ( 'input[name="pkglist"]' ) ;
var postInstall = $ ( this ) . find ( 'input[name="postinstall"]' ) ;
var template = $ ( this ) . find ( 'input[name="template"]' ) ;
2012-04-06 02:31:08 +00:00
2012-04-06 18:11:08 +00:00
// Check that image attributes are provided before continuing
var ready = 1 ;
var inputs = new Array ( imageType , architecture , osName , osVersion , profile , provisionMethod ) ;
for ( var i in inputs ) {
if ( ! inputs [ i ] . val ( ) ) {
inputs [ i ] . css ( 'border-color' , 'red' ) ;
ready = 0 ;
} else
inputs [ i ] . css ( 'border-color' , '' ) ;
}
2012-04-06 02:31:08 +00:00
// If inputs are not complete, show warning message
2012-04-06 18:11:08 +00:00
if ( ! ready ) {
2012-04-06 02:31:08 +00:00
var warn = createWarnBar ( 'Please provide a value for each missing field.' ) ;
warn . prependTo ( $ ( this ) ) ;
} else {
2012-04-06 18:11:08 +00:00
// Override image name
$ ( this ) . find ( 'input[name="imagename"]' ) . val ( osVersion . val ( ) + '-' + architecture . val ( ) + '-' + provisionMethod . val ( ) + '-' + profile . val ( ) ) ;
var imageName = $ ( this ) . find ( 'input[name="imagename"]' ) ;
2012-04-06 02:31:08 +00:00
// Change dialog buttons
$ ( this ) . dialog ( 'option' , 'buttons' , {
'Close' : function ( ) { $ ( this ) . dialog ( "close" ) ; }
} ) ;
// Create arguments to send via AJAX
2012-04-06 18:11:08 +00:00
var args = '-t;osimage;-o;' + imageName . val ( ) + ';' +
'imagetype=' + imageType . val ( ) + ';' +
'osarch=' + architecture . val ( ) + ';' +
'osname=' + osName . val ( ) + ';' +
'osvers=' + osVersion . val ( ) + ';' +
'profile=' + profile . val ( ) + ';' +
'provmethod=' + provisionMethod . val ( ) ;
2012-04-06 02:31:08 +00:00
2012-04-06 18:11:08 +00:00
// Get optional attributes
if ( exList . val ( ) )
args += ';exlist=' + exList . val ( ) ;
if ( otherpkgDirectory . val ( ) )
args += ';otherpkgdir=' + otherpkgDirectory . val ( ) ;
if ( pkgDirectory . val ( ) )
args += ';pkgdir=' + pkgDirectory . val ( ) ;
if ( pkgList . val ( ) )
args += ';pkglist=' + pkgList . val ( ) ;
if ( postInstall . val ( ) )
args += ';postinstall=' + postInstall . val ( ) ;
if ( template . val ( ) )
args += ';template=' + template . val ( ) ;
2012-04-06 02:31:08 +00:00
// Add image to xCAT
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chdef' ,
tgt : '' ,
args : args ,
msg : dialogId
} ,
success : updateImageDialog
} ) ;
}
} ,
"Cancel" : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
}
} ) ;
}
/ * *
* Update image dialog
*
* @ param data
* HTTP request data
* @ return Nothing
* /
function updateImageDialog ( data ) {
var dialogId = data . msg ;
var infoMsg ;
2012-04-06 18:11:08 +00:00
// Delete loader if one does exist
$ ( '.ui-dialog #' + dialogId + ' img[src="images/loader.gif"]' ) . remove ( ) ;
2012-04-06 02:31:08 +00:00
// Create info message
if ( jQuery . isArray ( data . rsp ) ) {
infoMsg = '' ;
2012-04-06 18:11:08 +00:00
// If the data returned is more than 10 lines, get only the last line
var i , start ;
if ( data . rsp . length > 10 )
start = data . rsp . length - 1 ;
else
start = 0 ;
for ( i = start ; i < data . rsp . length ; i ++ )
2012-04-06 02:31:08 +00:00
infoMsg += data . rsp [ i ] + '</br>' ;
} else {
infoMsg = data . rsp ;
}
// Create info bar with close button
var infoBar = $ ( '<div class="ui-state-highlight ui-corner-all"></div>' ) . css ( 'margin' , '5px 0px' ) ;
var icon = $ ( '<span class="ui-icon ui-icon-info"></span>' ) . css ( {
'display' : 'inline-block' ,
'margin' : '10px 5px'
} ) ;
// Create close button to close info bar
var close = $ ( '<span class="ui-icon ui-icon-close"></span>' ) . css ( {
'display' : 'inline-block' ,
'float' : 'right'
} ) . click ( function ( ) {
$ ( this ) . parent ( ) . remove ( ) ;
} ) ;
var msg = $ ( '<p>' + infoMsg + '</p>' ) . css ( {
'display' : 'inline-block' ,
'width' : '90%'
} ) ;
infoBar . append ( icon , msg , close ) ;
infoBar . prependTo ( $ ( '.ui-dialog #' + dialogId ) ) ;
}
2010-12-01 01:54:05 +00:00
/ * *
* Set definable image attributes
*
* @ param data
* Data returned from HTTP request
* @ return Nothing
* /
function setImageDefAttrs ( data ) {
2010-12-03 22:09:36 +00:00
// Clear hash table containing definable image attributes
defAttrs = new Array ( ) ;
2010-12-01 01:54:05 +00:00
// Get definable attributes
var attrs = data . rsp [ 2 ] . split ( /\n/ ) ;
// Go through each line
var attr , key , descr ;
for ( var i in attrs ) {
attr = attrs [ i ] ;
// If the line is not empty
if ( attr ) {
// If the line has the attribute name
if ( attr . indexOf ( ':' ) && attr . indexOf ( ' ' ) ) {
// Get attribute name and description
key = jQuery . trim ( attr . substring ( 0 , attr . indexOf ( ':' ) ) ) ;
descr = jQuery . trim ( attr . substring ( attr . indexOf ( ':' ) + 1 ) ) ;
2011-04-27 20:28:00 +00:00
descr = descr . replace ( new RegExp ( '<' , 'g' ) , '[' ) . replace ( new RegExp ( '>' , 'g' ) , ']' ) ;
2010-12-01 01:54:05 +00:00
// Set hash table where key = attribute name and value = description
defAttrs [ key ] = descr ;
} else {
// Append description to hash table
2011-04-27 20:28:00 +00:00
defAttrs [ key ] = defAttrs [ key ] + '\n' + attr . replace ( new RegExp ( '<' , 'g' ) , '[' ) . replace ( new RegExp ( '>' , 'g' ) , ']' ) ;
2010-12-01 01:54:05 +00:00
}
} // End of if
} // End of for
}
2011-03-28 09:02:54 +00:00
/ * *
2011-04-16 14:40:15 +00:00
* Load create image page
2011-03-28 09:02:54 +00:00
* /
2011-04-16 14:40:15 +00:00
function loadCreateImage ( ) {
// Get nodes tab
var tab = getProvisionTab ( ) ;
2011-03-28 09:02:54 +00:00
var tabId = 'createImageTab' ;
2011-09-09 21:56:30 +00:00
2011-04-16 14:40:15 +00:00
// Generate new tab ID
if ( $ ( '#' + tabId ) . size ( ) ) {
2011-03-28 09:02:54 +00:00
tab . select ( tabId ) ;
2011-04-16 14:40:15 +00:00
return ;
2011-03-28 09:02:54 +00:00
}
2011-04-06 10:03:39 +00:00
2012-03-14 19:20:37 +00:00
var imageOsVers = $ . cookie ( "osvers" ) . split ( "," ) ;
2011-04-06 10:03:39 +00:00
var imageArch = $ . cookie ( "osarchs" ) . split ( "," ) ;
2012-03-14 19:20:37 +00:00
var profiles = $ . cookie ( "profiles" ) . split ( "," ) ;
2011-09-12 14:24:09 +00:00
2012-03-14 19:20:37 +00:00
var createImgForm = $ ( '<div class="form"></div>' ) ;
var createImgFS = $ ( '<fieldset></fieldset>' ) . append ( '<legend>Create Image</legend>' ) ;
createImgForm . append ( createImgFS ) ;
2011-03-28 09:02:54 +00:00
2012-03-14 19:20:37 +00:00
// Show info bar
2011-09-12 14:24:09 +00:00
var infoBar = createInfoBar ( 'Specify the parameters for the image (stateless or statelite) you want to create, then click Create.' ) ;
2012-03-14 19:20:37 +00:00
createImgFS . append ( infoBar ) ;
2011-04-16 14:40:15 +00:00
2012-03-14 19:20:37 +00:00
// Drop down for OS versions
var osVerSelect = $ ( '<select id="osvers" onchange="hpcShow()"></select>' ) ;
for ( var i in imageOsVers )
osVerSelect . append ( '<option value="' + imageOsVers [ i ] + '">' + imageOsVers [ i ] + '</option>' ) ;
createImgFS . append ( $ ( '<div><label>OS version:</label></div>' ) . append ( osVerSelect ) ) ;
2011-04-06 10:03:39 +00:00
2012-03-14 19:20:37 +00:00
// Drop down for OS architectures
var imgSelect = $ ( '<select id="osarch" onchange="hpcShow()"></select>' ) ;
for ( var i in imageArch )
imgSelect . append ( '<option value="' + imageArch [ i ] + '">' + imageArch [ i ] + '</option>' ) ;
createImgFS . append ( $ ( '<div><label>OS architecture:</label></div>' ) . append ( imgSelect ) ) ;
2011-04-06 10:03:39 +00:00
2011-04-16 14:40:15 +00:00
// Netboot interface input
2012-03-14 19:20:37 +00:00
createImgFS . append ( $ ( '<div><label>Netboot interface:</label><input type="text" id="netbootif"/></div>' ) ) ;
2011-09-12 14:24:09 +00:00
2011-04-16 14:40:15 +00:00
// Profile selector
2012-03-14 19:20:37 +00:00
var profileSelect = $ ( '<select id="profile" onchange="hpcShow()">' ) ;
for ( var i in profiles )
profileSelect . append ( '<option value="' + profiles [ i ] + '">' + profiles [ i ] + '</option>' ) ;
createImgFS . append ( $ ( '<div><label>Profile:</label></div>' ) . append ( profileSelect ) ) ;
// Boot method drop down
createImgFS . append ( $ ( '<div><label>Boot method:</label>' +
'<select id="bootmethod">' +
'<option value="stateless">stateless</option>' +
'<option value="statelite">statelite</option>' +
'</select></div>' ) ) ;
2011-09-12 14:24:09 +00:00
2012-03-14 19:20:37 +00:00
// Create HPC software stack fieldset
createHpcFS ( createImgForm ) ;
2011-04-16 14:40:15 +00:00
2011-07-08 08:59:58 +00:00
// The button used to create images is created here
2011-09-12 14:24:09 +00:00
var createImageBtn = createButton ( "Create" ) ;
2011-07-08 08:59:58 +00:00
createImageBtn . bind ( 'click' , function ( event ) {
createImage ( ) ;
} ) ;
2011-04-16 14:40:15 +00:00
2011-09-12 14:24:09 +00:00
createImgForm . append ( createImageBtn ) ;
2012-03-14 19:20:37 +00:00
// Add tab
2011-09-12 14:24:09 +00:00
tab . add ( tabId , 'Create' , createImgForm , true ) ;
tab . select ( tabId ) ;
2012-03-14 19:20:37 +00:00
// Check the selected OS version and OS arch for HPC stack
// If they are valid, show the HCP stack fieldset
2011-09-12 14:24:09 +00:00
hpcShow ( ) ;
2011-04-06 10:03:39 +00:00
}
2011-04-16 14:40:15 +00:00
/ * *
2012-03-14 19:20:37 +00:00
* Create HPC fieldset
2011-04-16 14:40:15 +00:00
*
* @ param container
2012-03-14 19:20:37 +00:00
* The container to hold the HPC fieldset
* @ return Nothing
2011-04-16 14:40:15 +00:00
* /
2012-03-14 19:20:37 +00:00
function createHpcFS ( container ) {
2011-04-06 10:03:39 +00:00
var hpcFieldset = $ ( '<fieldset id="hpcsoft"></fieldset>' ) ;
hpcFieldset . append ( '<legend>HPC Software Stack</legend>' ) ;
2012-03-14 19:20:37 +00:00
var str = 'Before selecting the software, you should have the following already completed on your xCAT cluster:<br/><br/>'
+ '1. If you are using the xCAT hierarchy, your service nodes are installed and running.<br/>'
+ '2. Your compute nodes are defined in xCAT, and you have verified your hardware control capabilities, '
2011-04-16 14:40:15 +00:00
+ 'gathered MAC addresses, and done all the other necessary preparations for a diskless install.<br/>'
2012-03-14 19:20:37 +00:00
+ '3. You should have a diskless image created with the base OS installed and verified it on at least one test node.<br/>'
+ '4. You should install the software on the management node and copy all correponding packages into the location "/install/custom/otherpkgs/" based on '
+ 'these <a href="http://sourceforge.net/apps/mediawiki/xcat/index.php?title=IBM_HPC_Stack_in_an_xCAT_Cluster" target="_blank">documents</a>.<br/>' ;
2011-04-06 10:03:39 +00:00
hpcFieldset . append ( createInfoBar ( str ) ) ;
2012-03-14 19:20:37 +00:00
// Advanced software
2011-09-20 07:13:01 +00:00
str = '<div id="partlysupport"><ul><li id="gpfsli"><input type="checkbox" onclick="softwareCheck(this)" name="gpfs">GPFS</li>' +
'<li id="rsctli"><input type="checkbox" onclick="softwareCheck(this)" name="rsct">RSCT</li>' +
'<li id="peli"><input type="checkbox" onclick="softwareCheck(this)" name="pe">PE</li>' +
2012-03-14 19:20:37 +00:00
'<li id="esslli"><input type="checkbox" onclick="esslCheck(this)" name="essl">ESSl & PESSL</li>' +
2011-09-20 07:13:01 +00:00
'</ul></div>' +
'<div><ul><li id="gangliali"><input type="checkbox" onclick="softwareCheck(this)" name="ganglia">Ganglia</li>' +
'</ul></div>' ;
2011-04-16 14:40:15 +00:00
hpcFieldset . append ( str ) ;
2011-09-12 14:24:09 +00:00
container . append ( $ ( '<div></div>' ) . append ( hpcFieldset ) ) ;
2011-04-06 10:03:39 +00:00
}
2011-07-20 21:13:09 +00:00
2011-04-11 02:23:32 +00:00
/ * *
2011-09-12 14:24:09 +00:00
* Check the dependance for ESSL and start the software check for ESSL
2011-04-11 02:23:32 +00:00
*
2011-04-16 14:40:15 +00:00
* @ param softwareObject
2011-09-12 14:24:09 +00:00
* The checkbox object of ESSL
2011-04-11 02:23:32 +00:00
* @ return nothing
* /
function esslCheck ( softwareObject ) {
2011-04-16 14:40:15 +00:00
var softwareName = softwareObject . name ;
2011-09-12 14:24:09 +00:00
if ( ! $ ( '#createImageTab input[name=pe]' ) . attr ( 'checked' ) ) {
var warnBar = createWarnBar ( 'You must first select the PE' ) ;
2011-04-16 14:40:15 +00:00
$ ( ':checkbox[name=essl]' ) . attr ( "checked" , false ) ;
2011-09-12 14:24:09 +00:00
// Clear existing warnings and append new warning
$ ( '#hpcsoft .ui-state-error' ) . remove ( ) ;
$ ( '#hpcsoft' ) . prepend ( warnBar ) ;
2011-04-16 14:40:15 +00:00
return ;
} else {
softwareCheck ( softwareObject ) ;
}
2011-04-11 02:23:32 +00:00
}
/ * *
2011-09-12 14:24:09 +00:00
* Check the parameters for the HPC software
2011-04-16 14:40:15 +00:00
*
* @ param softwareObject
2011-09-12 14:24:09 +00:00
* Checkbox object of the HPC software
2011-04-16 14:40:15 +00:00
* @ return True : The checkbox is checked
* False : Error message shown on page
* /
2011-04-11 02:23:32 +00:00
function softwareCheck ( softwareObject ) {
2011-04-16 14:40:15 +00:00
var softwareName = softwareObject . name ;
$ ( '#createImageTab #' + softwareName + 'li .ui-state-error' ) . remove ( ) ;
$ ( '#createImageTab #' + softwareName + 'li' ) . append ( createLoader ( ) ) ;
var cmdString = genRpmCmd ( softwareName ) ;
$ . ajax ( {
url : 'lib/systemcmd.php' ,
dataType : 'json' ,
data : {
cmd : cmdString ,
msg : softwareName
} ,
success : function ( data ) {
if ( rpmCheck ( data . rsp , data . msg ) ) {
genLsCmd ( data . msg ) ;
$ . ajax ( {
url : 'lib/systemcmd.php' ,
dataType : 'json' ,
data : {
cmd : genLsCmd ( data . msg ) ,
msg : data . msg
} ,
success : rpmCopyCheck
} ) ;
}
}
} ) ;
2011-04-11 02:23:32 +00:00
}
2011-04-16 14:40:15 +00:00
/ * *
2011-09-12 14:24:09 +00:00
* Check if the RPMs are copied to the special location
2011-04-16 14:40:15 +00:00
*
* @ param data
* Data returned from HTTP request
* @ return Nothing
* /
function rpmCopyCheck ( data ) {
// Remove the loading image
var errorStr = '' ;
var softwareName = data . msg ;
// Check the return information
var reg = /.+:(.+): No such.*/ ;
var resultArray = data . rsp . split ( "\n" ) ;
for ( var i in resultArray ) {
var temp = reg . exec ( resultArray [ i ] ) ;
if ( temp ) {
// Find out the path and RPM name
var pos = temp [ 1 ] . lastIndexOf ( '/' ) ;
var path = temp [ 1 ] . substring ( 0 , pos ) ;
var rpmName = temp [ 1 ] . substring ( pos + 1 ) . replace ( '*' , '' ) ;
errorStr += 'copy ' + rpmName + ' to ' + path + '<br/>' ;
}
}
$ ( '#createImageTab #' + softwareName + 'li' ) . find ( 'img' ) . remove ( ) ;
2011-09-12 14:24:09 +00:00
2011-04-16 14:40:15 +00:00
// No error, show the check image
2011-09-12 14:24:09 +00:00
if ( ! errorStr ) {
var infoPart = '<div style="display:inline-block; margin:0px"><span class="ui-icon ui-icon-circle-check"></span></div>' ;
2011-04-16 14:40:15 +00:00
$ ( '#createImageTab #' + softwareName + 'li' ) . append ( infoPart ) ;
} else {
// Show the error message
2011-09-12 14:24:09 +00:00
errorStr = 'To install the RSCT on your compute node. You should:<br/>' + errorStr + '</div>' ;
2011-04-16 14:40:15 +00:00
var warnBar = createWarnBar ( errorStr ) ;
$ ( ':checkbox[name=' + softwareName + ']' ) . attr ( "checked" , false ) ;
2011-09-12 14:24:09 +00:00
// Clear existing warnings and append new warning
$ ( '#hpcsoft .ui-state-error' ) . remove ( ) ;
$ ( '#hpcsoft' ) . prepend ( warnBar ) ;
2011-04-16 14:40:15 +00:00
}
2011-04-11 02:23:32 +00:00
}
2011-04-16 14:40:15 +00:00
2011-04-11 02:23:32 +00:00
/ * *
2011-04-16 14:40:15 +00:00
* Generate the RPM command for rpmcheck
*
* @ param softwareName
* The name of the software
* @ return The RPM command , e . g . 'rpm -q ***'
* /
function genRpmCmd ( softwareName ) {
var cmdString ;
2011-09-12 14:24:09 +00:00
cmdString = 'rpm -q ' ;
2011-04-16 14:40:15 +00:00
for ( var i in softwareList [ softwareName ] ) {
2011-09-12 14:24:09 +00:00
cmdString += softwareList [ softwareName ] [ i ] + ' ' ;
2011-04-16 14:40:15 +00:00
}
2011-09-12 14:24:09 +00:00
for ( var i in softwareList [ 'base' ] ) {
cmdString += softwareList [ 'base' ] [ i ] + ' ' ;
2011-04-16 14:40:15 +00:00
}
return cmdString ;
2011-04-11 02:23:32 +00:00
}
2011-04-16 14:40:15 +00:00
2011-04-11 02:23:32 +00:00
/ * *
2011-09-12 14:24:09 +00:00
* Check if the RPMs for the HPC software are copied to the special location
2011-04-16 14:40:15 +00:00
*
* @ param softwareName
* The name of the software
* @ return True : OK
* False : Add the error message to the page
* /
function genLsCmd ( softwareName ) {
2011-09-12 14:24:09 +00:00
var osvers = $ ( '#createImageTab #osvers' ) . val ( ) ;
var osarch = $ ( '#createImageTab #osarch' ) . val ( ) ;
2011-04-16 14:40:15 +00:00
var path = '/install/post/otherpkgs/' + osvers + '/' + osarch + '/' + softwareName ;
var checkCmd = 'ls ' ;
for ( var i in softwareList [ softwareName ] ) {
checkCmd += path + '/' + softwareList [ softwareName ] [ i ] + '*.rpm ' ;
}
checkCmd += '2>&1' ;
return checkCmd ;
2011-04-11 02:23:32 +00:00
}
2011-04-16 14:40:15 +00:00
2011-04-11 02:23:32 +00:00
/ * *
2011-09-12 14:24:09 +00:00
* Check if all RPMs are installed
2011-04-16 14:40:15 +00:00
*
* @ param checkInfo
2011-09-12 14:24:09 +00:00
* 'rpm -q' output
* @ return True : All RPMs are installed
* False : Some RPMs are not installed
2011-04-16 14:40:15 +00:00
* /
function rpmCheck ( checkInfo , name ) {
var errorStr = '' ;
2011-09-12 14:24:09 +00:00
var checkArray = checkInfo . split ( '\n' ) ;
for ( var i in checkArray ) {
if ( checkArray [ i ] . indexOf ( 'not install' ) != - 1 ) {
errorStr += checkArray [ i ] + '<br/>' ;
2011-04-16 14:40:15 +00:00
}
}
2011-09-12 14:24:09 +00:00
if ( ! errorStr ) {
2011-04-16 14:40:15 +00:00
return true ;
}
errorStr = errorStr . substr ( 0 , errorStr . length - 1 ) ;
2011-09-12 14:24:09 +00:00
$ ( ':checkbox[name=' + name + ']' ) . attr ( 'checked' , false ) ;
2011-04-16 14:40:15 +00:00
// Add the error
2011-09-12 14:24:09 +00:00
var warnBar = createWarnBar ( errorStr ) ;
2011-04-16 14:40:15 +00:00
$ ( '#createImageTab #' + name + 'li' ) . find ( 'img' ) . remove ( ) ;
2011-09-12 14:24:09 +00:00
// Clear existing warnings and append new warning
$ ( '#hpcsoft .ui-state-error' ) . remove ( ) ;
$ ( '#hpcsoft' ) . prepend ( warnBar ) ;
2011-04-16 14:40:15 +00:00
return ;
2011-04-11 02:23:32 +00:00
}
2011-04-06 10:03:39 +00:00
/ * *
2011-04-16 14:40:15 +00:00
* Check the option and decide whether to show the hpcsoft or not
*
* @ param Nothing
* @ return Nothing
2011-04-06 10:03:39 +00:00
* /
2011-04-11 02:23:32 +00:00
function hpcShow ( ) {
2011-04-16 14:40:15 +00:00
// The current UI only supports RHELS 6
// If you want to support all, delete the subcheck
if ( $ ( '#createImageTab #osvers' ) . attr ( 'value' ) != "rhels6" || $ ( '#createImageTab #osarch' ) . attr ( 'value' ) != "ppc64" || $ ( '#createImageTab #profile' ) . attr ( 'value' ) != "compute" ) {
2011-09-20 07:13:01 +00:00
$ ( '#createImageTab #partlysupport' ) . hide ( ) ;
2011-04-16 14:40:15 +00:00
} else {
2011-09-20 07:13:01 +00:00
$ ( '#createImageTab #partlysupport' ) . show ( ) ;
2011-04-16 14:40:15 +00:00
}
2011-03-28 09:02:54 +00:00
}
2011-04-06 10:03:39 +00:00
2010-12-01 01:54:05 +00:00
/ * *
* Load set image properties page
*
* @ param tgtImage
* Target image to set properties
* @ return Nothing
* /
2012-04-06 18:11:08 +00:00
function openEditImagePage ( tgtImage ) {
2010-12-01 01:54:05 +00:00
// Get nodes tab
var tab = getProvisionTab ( ) ;
// Generate new tab ID
var inst = 0 ;
2010-12-03 22:09:36 +00:00
var newTabId = 'editImageTab' + inst ;
2010-12-01 01:54:05 +00:00
while ( $ ( '#' + newTabId ) . length ) {
// If one already exists, generate another one
inst = inst + 1 ;
2010-12-03 22:09:36 +00:00
newTabId = 'editImageTab' + inst ;
2010-12-01 01:54:05 +00:00
}
// Open new tab
// Create set properties form
var setPropsForm = $ ( '<div class="form"></div>' ) ;
// Create info bar
var infoBar = createInfoBar ( 'Choose the properties you wish to change on the node. When you are finished, click Save.' ) ;
setPropsForm . append ( infoBar ) ;
// Create an input for each definable attribute
2011-07-20 21:13:09 +00:00
var div , label , input , value ;
2010-12-01 01:54:05 +00:00
// Set node attribute
origAttrs [ tgtImage ] [ 'imagename' ] = tgtImage ;
for ( var key in defAttrs ) {
// If an attribute value exists
if ( origAttrs [ tgtImage ] [ key ] ) {
// Set the value
value = origAttrs [ tgtImage ] [ key ] ;
} else {
value = '' ;
}
// Create label and input for attribute
div = $ ( '<div></div>' ) . css ( 'display' , 'inline' ) ;
label = $ ( '<label>' + key + ':</label>' ) . css ( 'vertical-align' , 'middle' ) ;
2010-12-20 22:25:55 +00:00
input = $ ( '<input type="text" id="' + key + '" value="' + value + '" title="' + defAttrs [ key ] + '"/>' ) . css ( 'margin-top' , '5px' ) ;
// Create server browser
switch ( key ) {
case 'pkgdir' :
input . serverBrowser ( {
onSelect : function ( path ) {
$ ( '#pkgdir' ) . val ( path ) ;
} ,
onLoad : function ( ) {
return $ ( '#pkgdir' ) . 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-20 22:25:55 +00:00
handlerUrl : 'lib/getpath.php' ,
title : 'Browse' ,
requestMethod : 'POST' ,
width : '500' ,
height : '300' ,
basePath : '/install' // Limit user to only install directory
} ) ;
break ;
case 'otherpkgdir' :
input . serverBrowser ( {
onSelect : function ( path ) {
$ ( '#otherpkgdir' ) . val ( path ) ;
} ,
onLoad : function ( ) {
return $ ( '#otherpkgdir' ) . 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-20 22:25:55 +00:00
handlerUrl : 'lib/getpath.php' ,
title : 'Browse' ,
requestMethod : 'POST' ,
width : '500' ,
height : '300' ,
basePath : '/install' // Limit user to only install directory
} ) ;
break ;
case 'pkglist' :
input . serverBrowser ( {
onSelect : function ( path ) {
$ ( '#pkglist' ) . val ( path ) ;
} ,
onLoad : function ( ) {
return $ ( '#pkglist' ) . 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-20 22:25:55 +00:00
handlerUrl : 'lib/getpath.php' ,
title : 'Browse' ,
requestMethod : 'POST' ,
width : '500' ,
height : '300' ,
basePath : '/opt/xcat/share' // Limit user to only install directory
} ) ;
break ;
case 'otherpkglist' :
input . serverBrowser ( {
onSelect : function ( path ) {
$ ( '#otherpkglist' ) . val ( path ) ;
} ,
onLoad : function ( ) {
return $ ( '#otherpkglist' ) . 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-20 22:25:55 +00:00
handlerUrl : 'lib/getpath.php' ,
title : 'Browse' ,
requestMethod : 'POST' ,
width : '500' ,
height : '300' ,
basePath : '/install' // Limit user to only install directory
} ) ;
break ;
case 'template' :
input . serverBrowser ( {
onSelect : function ( path ) {
$ ( '#template' ) . val ( path ) ;
} ,
onLoad : function ( ) {
return $ ( '#template' ) . 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-20 22:25:55 +00:00
handlerUrl : 'lib/getpath.php' ,
title : 'Browse' ,
requestMethod : 'POST' ,
width : '500' ,
height : '300' ,
basePath : '/opt/xcat/share' // Limit user to only install directory
} ) ;
break ;
default :
// Do nothing
}
2010-12-01 01:54:05 +00:00
// Change border to blue onchange
input . bind ( 'change' , function ( event ) {
$ ( this ) . css ( 'border-color' , 'blue' ) ;
} ) ;
div . append ( label ) ;
div . append ( input ) ;
setPropsForm . append ( div ) ;
}
// Change style for last division
div . css ( {
'display' : 'block' ,
'margin' : '0px 0px 10px 0px'
} ) ;
// Generate tooltips
setPropsForm . find ( 'div input[title]' ) . tooltip ( {
2010-12-03 22:09:36 +00:00
position : "center right" ,
offset : [ - 2 , 10 ] ,
effect : "fade" ,
opacity : 0.8 ,
2010-12-10 03:11:21 +00:00
delay : 500 ,
2010-12-10 14:38:30 +00:00
predelay : 800 ,
2010-12-02 21:28:24 +00:00
events : {
def : "mouseover,mouseout" ,
input : "mouseover,mouseout" ,
widget : "focus mouseover,blur mouseout" ,
tooltip : "mouseover,mouseout"
}
2010-12-01 01:54:05 +00:00
} ) ;
/ * *
* Save
* /
var saveBtn = createButton ( 'Save' ) ;
saveBtn . bind ( 'click' , function ( event ) {
// Get all inputs
var inputs = $ ( '#' + newTabId + ' input' ) ;
// Go through each input
var args = '' ;
var attrName , attrVal ;
inputs . each ( function ( ) {
// If the border color is blue
if ( $ ( this ) . css ( 'border-left-color' ) == 'rgb(0, 0, 255)' ) {
// Change border color back to normal
$ ( this ) . css ( 'border-color' , '' ) ;
// Get attribute name and value
attrName = $ ( this ) . parent ( ) . find ( 'label' ) . text ( ) . replace ( ':' , '' ) ;
attrVal = $ ( this ) . val ( ) ;
// Build argument string
if ( args ) {
// Handle subsequent arguments
args += ';' + attrName + '=' + attrVal ;
} else {
// Handle the 1st argument
args += attrName + '=' + attrVal ;
}
}
} ) ;
2010-12-03 22:09:36 +00:00
// Send command to change image attributes
2010-12-01 01:54:05 +00:00
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chdef' ,
tgt : '' ,
args : '-t;osimage;-o;' + tgtImage + ';' + args ,
2010-12-03 22:09:36 +00:00
msg : 'out=' + newTabId + ';tgt=' + tgtImage
2010-12-01 01:54:05 +00:00
} ,
success : showChdefOutput
} ) ;
} ) ;
setPropsForm . append ( saveBtn ) ;
/ * *
* Cancel
* /
var cancelBtn = createButton ( 'Cancel' ) ;
cancelBtn . bind ( 'click' , function ( event ) {
// Close the tab
tab . remove ( $ ( this ) . parent ( ) . parent ( ) . attr ( 'id' ) ) ;
} ) ;
setPropsForm . append ( cancelBtn ) ;
// Append to discover tab
2010-12-03 22:09:36 +00:00
tab . add ( newTabId , 'Edit' , setPropsForm , true ) ;
2010-12-01 01:54:05 +00:00
// Select new tab
tab . select ( newTabId ) ;
}
/ * *
2010-12-20 22:25:55 +00:00
* Load copy CD page
2010-12-01 01:54:05 +00:00
*
* @ return Nothing
* /
2012-04-06 18:11:08 +00:00
function openCopyCdDialog ( ) {
2010-12-03 22:09:36 +00:00
// Create copy Linux form
2012-04-06 18:11:08 +00:00
var dialogId = 'imageCopyCd' ;
var copyLinuxForm = $ ( '<div id="' + dialogId + '" class="form"></div>' ) ;
2010-12-09 21:43:30 +00:00
// Create info bar
var infoBar = createInfoBar ( 'Copy Linux distributions and service levels from CDs or DVDs to the install directory.' ) ;
2010-12-03 22:09:36 +00:00
copyLinuxForm . append ( infoBar ) ;
2010-12-09 21:43:30 +00:00
// Create Linux ISO input
var iso = $ ( '<div></div>' ) ;
var isoLabel = $ ( '<label> Linux ISO/DVD:</label>' ) . css ( 'vertical-align' , 'middle' ) ;
var isoInput = $ ( '<input type="text" id="iso" name="iso"/>' ) . css ( 'width' , '300px' ) ;
iso . append ( isoLabel ) ;
iso . append ( isoInput ) ;
copyLinuxForm . append ( iso ) ;
// Create architecture input
2012-04-06 18:11:08 +00:00
copyLinuxForm . append ( '<div><label>Architecture:</label><input type="text" id="arch" name="arch"/></div>' ) ;
2010-12-09 21:43:30 +00:00
// Create distribution input
2012-04-06 18:11:08 +00:00
copyLinuxForm . append ( '<div><label>Distribution:</label><input type="text" id="distro" name="distro"/></div>' ) ;
2010-12-10 03:11:21 +00:00
/ * *
* Browse
* /
var browseBtn = createButton ( 'Browse' ) ;
iso . append ( browseBtn ) ;
2010-12-01 01:54:05 +00:00
// Browse server directory and files
2010-12-10 03:11:21 +00:00
browseBtn . serverBrowser ( {
2010-12-09 21:43:30 +00:00
onSelect : function ( path ) {
2012-04-06 18:11:08 +00:00
$ ( '#imageCopyCd #iso' ) . val ( path ) ;
2010-12-09 21:43:30 +00:00
} ,
onLoad : function ( ) {
2012-04-06 18:11:08 +00:00
return $ ( '#imageCopyCd #iso' ) . val ( ) ;
2010-12-09 21:43:30 +00:00
} ,
knownExt : [ 'exe' , 'js' , 'txt' ] ,
knownPaths : [ {
text : 'Install' ,
image : 'desktop.png' ,
path : '/install'
2010-12-10 21:37:28 +00:00
} ] ,
2011-01-14 20:25:14 +00:00
imageUrl : 'images/serverbrowser/' ,
systemImageUrl : 'images/serverbrowser/' ,
2010-12-09 21:43:30 +00:00
handlerUrl : 'lib/getpath.php' ,
title : 'Browse' ,
requestMethod : 'POST' ,
width : '500' ,
height : '300' ,
2010-12-10 21:37:28 +00:00
basePath : '/install' // Limit user to only install directory
2010-12-09 21:43:30 +00:00
} ) ;
2010-12-01 01:54:05 +00:00
2012-04-06 18:11:08 +00:00
// Open dialog to copy CD
copyLinuxForm . dialog ( {
title : 'Copy CD' ,
2012-04-12 16:11:00 +00:00
close : function ( ) {
$ ( this ) . remove ( ) ;
} ,
2012-04-06 18:11:08 +00:00
modal : true ,
width : 600 ,
buttons : {
"Copy" : function ( ) {
// Show loader
$ ( '.ui-dialog #imageCopyCd' ) . append ( createLoader ( '' ) ) ;
// Change dialog buttons
$ ( this ) . dialog ( 'option' , 'buttons' , {
'Close' : function ( ) { $ ( this ) . dialog ( "close" ) ; }
} ) ;
// Get image attributes
var iso = $ ( this ) . find ( 'input[name="iso"]' ) ;
var arch = $ ( this ) . find ( 'input[name="arch"]' ) ;
var distro = $ ( this ) . find ( 'input[name="distro"]' ) ;
// Send ajax request to copy ISO
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'copycds' ,
tgt : '' ,
args : '-n;' + distro . val ( ) + ';-a;' + arch . val ( ) + ';' + iso . val ( ) ,
msg : dialogId
} ,
success : updateImageDialog
} ) ;
2010-12-09 21:43:30 +00:00
} ,
2012-04-06 18:11:08 +00:00
"Cancel" : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
}
2010-12-01 01:54:05 +00:00
} ) ;
2011-04-06 10:03:39 +00:00
}
/ * *
* use users ' input or select to create image
* /
2011-04-16 14:40:15 +00:00
function createImage ( ) {
2011-04-06 10:03:39 +00:00
var osvers = $ ( "#createImageTab #osvers" ) . val ( ) ;
var osarch = $ ( "#createImageTab #osarch" ) . val ( ) ;
var profile = $ ( "#createImageTab #profile" ) . val ( ) ;
var bootInterface = $ ( "#createImageTab #netbootif" ) . val ( ) ;
var bootMethod = $ ( "#createImageTab #bootmethod" ) . val ( ) ;
2011-04-16 14:40:15 +00:00
2011-04-06 10:03:39 +00:00
$ ( '#createImageTab .ui-state-error' ) . remove ( ) ;
// If there no input for the bootInterface
2011-04-16 14:40:15 +00:00
if ( ! bootInterface ) {
2011-09-12 14:24:09 +00:00
var warnBar = createWarnBar ( 'Please specify the netboot interface' ) ;
2011-04-16 14:40:15 +00:00
$ ( "#createImageTab" ) . prepend ( warnBar ) ;
2011-04-06 10:03:39 +00:00
return ;
}
2011-04-16 14:40:15 +00:00
var createImageArgs = "createimage;" + osvers + ";" + osarch + ";" + profile + ";" + bootInterface + ";" + bootMethod + ";" ;
$ ( "#createImageTab :checkbox:checked" ) . each ( function ( ) {
createImageArgs += $ ( this ) . attr ( "name" ) + "," ;
2011-04-06 10:03:39 +00:00
} ) ;
2011-04-16 14:40:15 +00:00
createImageArgs = createImageArgs . substring ( 0 , ( createImageArgs . length - 1 ) ) ;
2011-04-06 10:03:39 +00:00
$ . ajax ( {
2011-04-16 14:40:15 +00:00
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : createImageArgs ,
msg : ''
2011-04-06 10:03:39 +00:00
} ,
2011-04-16 14:40:15 +00:00
success : function ( data ) {
2011-04-06 10:03:39 +00:00
}
} ) ;
2011-04-16 14:40:15 +00:00
}