2011-08-24 15:09:28 +00:00
/ * *
* Execute when the DOM is fully loaded
* /
$ ( document ) . ready ( function ( ) {
2012-05-04 00:54:58 +00:00
// Load utility scripts (if any)
2011-08-24 15:09:28 +00:00
} ) ;
/ * *
* Constructor
* /
var ipmiPlugin = function ( ) {
} ;
2012-03-14 04:32:06 +00:00
/ * *
* Steps for hardware discovery wizard
*
* @ return Discovery steps
* /
2012-05-04 00:54:58 +00:00
ipmiPlugin . prototype . getStep = function ( ) {
return [ 'Basic patterns' , 'Switches' , 'Network' , 'Services' ,
'Power on hardware' ] ;
2012-03-14 04:32:06 +00:00
} ;
/ * *
2012-05-04 00:54:58 +00:00
* Return step init function for hardware discovery wizard
2012-03-14 04:32:06 +00:00
* /
2012-05-04 00:54:58 +00:00
ipmiPlugin . prototype . getInitFunction = function ( ) {
return [ idataplexInitBasic , idataplexInitSwitch , idataplexInitNetwork ,
idataplexInitService , idataplexInitPowerOn ] ;
2012-03-14 04:32:06 +00:00
} ;
2012-05-04 00:54:58 +00:00
ipmiPlugin . prototype . getNextFunction = function ( ) {
return [ idataplexCheckBasic , undefined , idataplexCheckNetwork , undefined ,
undefined ] ;
2012-03-14 04:32:06 +00:00
} ;
2011-08-24 15:09:28 +00:00
/ * *
* Load node inventory
*
2012-05-04 00:54:58 +00:00
* @ param data Data from HTTP request
2011-08-24 15:09:28 +00:00
* /
ipmiPlugin . prototype . loadInventory = function ( data ) {
2012-05-04 00:54:58 +00:00
var args = data . msg . split ( ',' ) ;
var tabId = args [ 0 ] . replace ( 'out=' , '' ) ;
var node = args [ 1 ] . replace ( 'node=' , '' ) ;
// Get node inventory
var inv = data . rsp ;
// Remove loader
$ ( '#' + tabId ) . find ( 'img' ) . remove ( ) ;
// Create division to hold inventory
var invDiv = $ ( '<div></div>' ) ;
// Create a fieldset
var fieldSet = $ ( '<fieldset></fieldset>' ) ;
var legend = $ ( '<legend>Hardware</legend>' ) ;
fieldSet . append ( legend ) ;
var oList = $ ( '<ol></ol>' ) ;
fieldSet . append ( oList ) ;
invDiv . append ( fieldSet ) ;
// Loop through each line
var item ;
for ( var k = 0 ; k < inv . length ; k ++ ) {
// Remove node name
var attr = inv [ k ] . replace ( node + ': ' , '' ) ;
attr = jQuery . trim ( attr ) ;
// Append attribute to list
item = $ ( '<li></li>' ) ;
item . append ( attr ) ;
oList . append ( item ) ;
}
// Append to inventory form
$ ( '#' + tabId ) . append ( invDiv ) ;
2011-08-24 15:09:28 +00:00
} ;
/ * *
* Load clone page
*
2012-05-04 00:54:58 +00:00
* @ param node Source node to clone
2011-08-24 15:09:28 +00:00
* /
ipmiPlugin . prototype . loadClonePage = function ( node ) {
2012-05-04 00:54:58 +00:00
// Get nodes tab
var tab = getNodesTab ( ) ;
var newTabId = node + 'CloneTab' ;
// If there is no existing clone tab
if ( ! $ ( '#' + newTabId ) . length ) {
// Create info bar
var infoBar = createInfoBar ( 'Not supported' ) ;
// Create clone form
var cloneForm = $ ( '<div class="form"></div>' ) ;
cloneForm . append ( infoBar ) ;
// Add clone tab
tab . add ( newTabId , 'Clone' , cloneForm , true ) ;
}
tab . select ( newTabId ) ;
2011-08-24 15:09:28 +00:00
} ;
/ * *
* Load provision page
*
2012-05-04 00:54:58 +00:00
* @ param tabId The provision tab ID
2011-08-24 15:09:28 +00:00
* /
ipmiPlugin . prototype . loadProvisionPage = function ( tabId ) {
2012-05-04 00:54:58 +00:00
// Get OS image names
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'tabdump' ,
tgt : '' ,
args : 'osimage' ,
msg : ''
} ,
success : setOSImageCookies
} ) ;
// Get groups
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'extnoderange' ,
tgt : '/.*' ,
args : 'subgroups' ,
msg : ''
} ,
success : setGroupsCookies
} ) ;
// Get provision tab instance
var inst = tabId . replace ( 'ipmiProvisionTab' , '' ) ;
// Create provision form
var provForm = $ ( '<div class="form"></div>' ) ;
// Create info bar
var infoBar = createInfoBar ( 'Provision an iDataPlex. This will install an operating system onto the iDataPlex.' ) ;
provForm . append ( infoBar ) ;
// Append to provision tab
$ ( '#' + tabId ) . append ( provForm ) ;
// Create provision existing node division
var provExisting = createIpmiProvisionExisting ( inst ) ;
provForm . append ( provExisting ) ;
2011-08-24 15:09:28 +00:00
} ;
/ * *
* Load resources
* /
ipmiPlugin . prototype . loadResources = function ( ) {
2012-05-04 00:54:58 +00:00
// Get resource tab ID
var tabId = 'ipmiResourceTab' ;
// Remove loader
$ ( '#' + tabId ) . find ( 'img' ) . remove ( ) ;
// Create info bar
var infoBar = createInfoBar ( 'Not yet supported' ) ;
// Create resource form
var resrcForm = $ ( '<div class="form"></div>' ) ;
resrcForm . append ( infoBar ) ;
$ ( '#' + tabId ) . append ( resrcForm ) ;
2011-08-24 15:09:28 +00:00
} ;
/ * *
* Add node range
* /
ipmiPlugin . prototype . addNode = function ( ) {
2012-03-14 04:32:06 +00:00
var dialog = $ ( '<div id="addIdplx" class="form"></div>' ) ;
var info = createInfoBar ( 'Add a iDataPlex node' ) ;
dialog . append ( info ) ;
2012-05-04 00:54:58 +00:00
2011-08-24 19:28:24 +00:00
// Create node inputs
2012-05-04 00:54:58 +00:00
dialog
. append ( $ ( '<div><label>Node:</label><input name="node" type="text"/></div>' ) ) ;
dialog
. append ( $ ( '<div><label>IP address:</label><input name="ip" type="text"/></div>' ) ) ;
dialog
. append ( $ ( '<div><label>MAC address:</label><input name="mac" type="text"/></div>' ) ) ;
dialog
. append ( $ ( '<div><label>Groups:</label><input name="groups" type="text"/></div>' ) ) ;
2011-08-24 19:28:24 +00:00
2012-03-14 04:32:06 +00:00
dialog . dialog ( {
2012-05-04 00:54:58 +00:00
title : 'Add node' ,
modal : true ,
width : 400 ,
close : function ( ) {
$ ( this ) . remove ( ) ;
} ,
buttons : {
"OK" : function ( ) {
addIdataplex ( ) ;
} ,
"Cancel" : function ( ) {
$ ( this ) . dialog ( 'close' ) ;
}
2011-08-24 15:09:28 +00:00
}
} ) ;
} ;
2011-08-24 19:28:24 +00:00
/ * *
* Add iDataPlex node range
* /
2012-05-04 00:54:58 +00:00
function addIdataplex ( ) {
var attr , args ;
2011-09-12 19:47:26 +00:00
var errorMessage = '' ;
2012-05-04 00:54:58 +00:00
2011-09-12 19:47:26 +00:00
// Remove existing warnings
$ ( '#addIdplx .ui-state-error' ) . remove ( ) ;
2012-05-04 00:54:58 +00:00
2012-03-14 04:32:06 +00:00
// Return input border colors to normal
$ ( '#addIdplx input' ) . css ( 'border' , 'solid #BDBDBD 1px' ) ;
2012-05-04 00:54:58 +00:00
2012-03-14 04:32:06 +00:00
// Check node attributes
2012-05-04 00:54:58 +00:00
$ ( '#addIdplx input' ) . each ( function ( ) {
2011-08-24 15:09:28 +00:00
attr = $ ( this ) . val ( ) ;
2012-03-14 04:32:06 +00:00
if ( ! attr ) {
2011-12-01 04:10:40 +00:00
errorMessage = "Please provide a value for each missing field!" ;
2012-03-14 04:32:06 +00:00
$ ( this ) . css ( 'border' , 'solid #FF0000 1px' ) ;
2011-08-24 15:09:28 +00:00
}
} ) ;
2012-05-04 00:54:58 +00:00
2012-03-14 04:32:06 +00:00
// Show error message (if any)
2011-09-12 19:47:26 +00:00
if ( errorMessage ) {
$ ( '#addIdplx' ) . prepend ( createWarnBar ( errorMessage ) ) ;
2011-08-24 15:09:28 +00:00
return ;
}
2012-05-04 00:54:58 +00:00
2011-09-12 19:47:26 +00:00
// Create loader
$ ( '#addIdplx' ) . append ( createLoader ( ) ) ;
2012-05-04 00:54:58 +00:00
2011-09-12 19:47:26 +00:00
// Change dialog buttons
$ ( '#addIdplx' ) . dialog ( 'option' , 'buttons' , {
2012-05-04 00:54:58 +00:00
'Close' : function ( ) {
$ ( '#addIdplx' ) . dialog ( 'close' ) ;
}
2011-09-12 19:47:26 +00:00
} ) ;
2012-05-04 00:54:58 +00:00
2011-09-12 19:47:26 +00:00
// Generate chdef arguments
2012-05-04 00:54:58 +00:00
args = '-t;node;-o;' + $ ( '#addIdplx input[name="node"]' ) . val ( ) + ';ip='
+ $ ( '#addIdplx input[name="ip"]' ) . val ( ) + ';mac='
+ $ ( '#addIdplx input[name="mac"]' ) . val ( ) + ';groups='
+ $ ( '#addIdplx input[name="groups"]' ) . val ( )
+ ';mgt=ipmi;netboot=xnba;nodetype=osi;profile=compute' ;
2011-08-24 15:09:28 +00:00
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chdef' ,
tgt : '' ,
args : args ,
msg : ''
} ,
2012-05-04 00:54:58 +00:00
success : function ( data ) {
// Update /etc/hosts
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'makehosts' ,
tgt : '' ,
args : '' ,
msg : ''
}
} ) ;
// Remove loader
2011-09-12 19:47:26 +00:00
$ ( '#addIdplx img' ) . remove ( ) ;
2012-05-04 00:54:58 +00:00
2012-03-14 04:32:06 +00:00
// Get return message
2011-08-24 15:09:28 +00:00
var message = '' ;
2012-05-04 00:54:58 +00:00
for ( var i in data . rsp ) {
2012-03-14 04:32:06 +00:00
message += data . rsp [ i ] + '<br/>' ;
2011-08-24 15:09:28 +00:00
}
2012-05-04 00:54:58 +00:00
2012-03-14 04:32:06 +00:00
// Show return message
if ( message )
2011-09-12 19:47:26 +00:00
$ ( '#addIdplx' ) . prepend ( createInfoBar ( message ) ) ;
2011-08-24 15:09:28 +00:00
}
} ) ;
}
/ * *
* Create provision existing node division
*
2012-05-04 00:54:58 +00:00
* @ param inst Provision tab instance
2011-08-24 15:09:28 +00:00
* @ return Provision existing node division
* /
2011-11-03 02:21:11 +00:00
function createIpmiProvisionExisting ( inst ) {
2012-05-04 00:54:58 +00:00
// Create provision existing division
var provExisting = $ ( '<div></div>' ) ;
// Create node fieldset
var nodeFS = $ ( '<fieldset></fieldset>' ) ;
var nodeLegend = $ ( '<legend>Node</legend>' ) ;
nodeFS . append ( nodeLegend ) ;
var nodeAttr = $ ( '<div style="display: inline-table; vertical-align: middle; width: 85%; margin-left: 10px;"></div>' ) ;
nodeFS
. append ( $ ( '<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/computer.png"></img></div>' ) ) ;
nodeFS . append ( nodeAttr ) ;
// Create image fieldset
var imgFS = $ ( '<fieldset></fieldset>' ) ;
var imgLegend = $ ( '<legend>Image</legend>' ) ;
imgFS . append ( imgLegend ) ;
var imgAttr = $ ( '<div style="display: inline-table; vertical-align: middle;"></div>' ) ;
imgFS
. append ( $ ( '<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/operating_system.png"></img></div>' ) ) ;
imgFS . append ( imgAttr ) ;
provExisting . append ( nodeFS , imgFS ) ;
// Create group input
var group = $ ( '<div></div>' ) ;
2013-02-05 15:43:57 +00:00
var groupLabel = $ ( '<label>Group:</label>' ) ;
2012-05-04 00:54:58 +00:00
group . append ( groupLabel ) ;
// Turn on auto complete for group
var dTableDivId = 'ipmiNodesDatatableDIV' + inst ; // Division ID where
// nodes datatable will
// be appended
var groupNames = $ . cookie ( 'groups' ) ;
if ( groupNames ) {
// Split group names into an array
var tmp = groupNames . split ( ',' ) ;
// Create drop down for groups
var groupSelect = $ ( '<select></select>' ) ;
groupSelect . append ( '<option></option>' ) ;
for ( var i in tmp ) {
// Add group into drop down
var opt = $ ( '<option value="' + tmp [ i ] + '">' + tmp [ i ]
+ '</option>' ) ;
groupSelect . append ( opt ) ;
}
group . append ( groupSelect ) ;
// Create node datatable
groupSelect . change ( function ( ) {
// Get group selected
var thisGroup = $ ( this ) . val ( ) ;
// If a valid group is selected
if ( thisGroup ) {
createNodesDatatable ( thisGroup , dTableDivId ) ;
} // End of if (thisGroup)
} ) ;
} else {
// If no groups are cookied
var groupInput = $ ( '<input type="text" name="group"/>' ) ;
group . append ( groupInput ) ;
}
nodeAttr . append ( group ) ;
// Create node input
var node = $ ( '<div></div>' ) ;
2013-02-05 15:43:57 +00:00
var nodeLabel = $ ( '<label>Nodes:</label>' ) ;
2012-05-04 00:54:58 +00:00
var nodeDatatable = $ ( '<div id="'
+ dTableDivId
+ '" style="display: inline-block; max-width: 800px;"><p>Select a group to view its nodes</p></div>' ) ;
node . append ( nodeLabel ) ;
node . append ( nodeDatatable ) ;
nodeAttr . append ( node ) ;
// Create boot method drop down
var method = $ ( '<div></div>' ) ;
2013-02-05 15:43:57 +00:00
var methodLabel = $ ( '<label>Boot method:</label>' ) ;
2012-05-04 00:54:58 +00:00
var methodSelect = $ ( '<select id="bootMethod" name="bootMethod"></select>' ) ;
methodSelect . append ( '<option value=""></option>'
+ '<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 ) ;
imgAttr . append ( method ) ;
// Create operating system input
var os = $ ( '<div></div>' ) ;
2013-02-05 15:43:57 +00:00
var osLabel = $ ( '<label>Operating system:</label>' ) ;
2012-05-04 00:54:58 +00:00
var osInput = $ ( '<input type="text" name="os"/>' ) ;
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 ) ;
imgAttr . append ( os ) ;
// Create architecture input
var arch = $ ( '<div></div>' ) ;
2013-02-05 15:43:57 +00:00
var archLabel = $ ( '<label>Architecture:</label>' ) ;
2012-05-04 00:54:58 +00:00
var archInput = $ ( '<input type="text" name="arch"/>' ) ;
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 ) ;
imgAttr . append ( arch ) ;
// Create profile input
var profile = $ ( '<div></div>' ) ;
2013-02-05 15:43:57 +00:00
var profileLabel = $ ( '<label>Profile:</label>' ) ;
2012-05-04 00:54:58 +00:00
var profileInput = $ ( '<input type="text" name="profile"/>' ) ;
profileInput . one ( 'focus' , function ( ) {
var tmp = $ . cookie ( 'profiles' ) ;
if ( tmp ) {
// Turn on auto complete
$ ( this ) . autocomplete ( {
source : tmp . split ( ',' )
} ) ;
}
} ) ;
profile . append ( profileLabel ) ;
profile . append ( profileInput ) ;
imgAttr . append ( profile ) ;
/ * *
* Provision existing
* /
var provisionBtn = createButton ( 'Provision' ) ;
provisionBtn . bind ( 'click' , function ( event ) {
// Remove any warning messages
$ ( this ) . parents ( '.ui-tabs-panel' ) . find ( '.ui-state-error' ) . remove ( ) ;
var ready = true ;
var errorMessage = '' ;
// Get provision tab ID
var thisTabId = 'ipmiProvisionTab' + inst ;
// Get nodes that were checked
var dTableId = 'ipmiNodesDatatable' + inst ;
var tgts = getNodesChecked ( dTableId ) ;
if ( ! tgts ) {
errorMessage += 'You need to select a node. ' ;
ready = false ;
}
// Check booth method
var boot = $ ( '#' + thisTabId + ' select[name=bootMethod]' ) ;
if ( ! boot . val ( ) ) {
errorMessage += 'You need to select a boot method. ' ;
boot . css ( 'border' , 'solid #FF0000 1px' ) ;
ready = false ;
} else {
boot . css ( 'border' , 'solid #BDBDBD 1px' ) ;
}
// Check operating system image
var os = $ ( '#' + thisTabId + ' input[name=os]' ) ;
if ( ! os . val ( ) ) {
errorMessage += 'You need to select a operating system image. ' ;
os . css ( 'border' , 'solid #FF0000 1px' ) ;
ready = false ;
} else {
os . css ( 'border' , 'solid #BDBDBD 1px' ) ;
}
// Check architecture
var arch = $ ( '#' + thisTabId + ' input[name=arch]' ) ;
if ( ! arch . val ( ) ) {
errorMessage += 'You need to select an architecture. ' ;
arch . css ( 'border' , 'solid #FF0000 1px' ) ;
ready = false ;
} else {
arch . css ( 'border' , 'solid #BDBDBD 1px' ) ;
}
// Check profile
var profile = $ ( '#' + thisTabId + ' input[name=profile]' ) ;
if ( ! profile . val ( ) ) {
errorMessage += 'You need to select a profile. ' ;
profile . css ( 'border' , 'solid #FF0000 1px' ) ;
ready = false ;
} else {
profile . css ( 'border' , 'solid #BDBDBD 1px' ) ;
}
// If all inputs are valid, ready to provision
if ( ready ) {
// Disable provision button
$ ( this ) . attr ( 'disabled' , 'true' ) ;
// Prepend status bar
var statBar = createStatusBar ( 'ipmiProvisionStatBar' + inst ) ;
statBar . append ( createLoader ( '' ) ) ;
statBar . prependTo ( $ ( '#' + thisTabId ) ) ;
// Disable all inputs
var inputs = $ ( '#' + thisTabId + ' input' ) ;
inputs . attr ( 'disabled' , 'disabled' ) ;
// Disable all selects
var selects = $ ( '#' + thisTabId + ' select' ) ;
selects . attr ( 'disabled' , 'disabled' ) ;
/ * *
* ( 1 ) Set operating system
* /
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'nodeadd' ,
tgt : '' ,
args : tgts + ';noderes.netboot=xnba;nodetype.os='
+ os . val ( ) + ';nodetype.arch=' + arch . val ( )
+ ';nodetype.profile=' + profile . val ( )
+ ';nodetype.provmethod=' + boot . val ( ) ,
msg : 'cmd=nodeadd;out=' + inst
} ,
success : updateIpmiProvisionExistingStatus
} ) ;
} else {
// Show warning message
var warn = createWarnBar ( errorMessage ) ;
warn . prependTo ( $ ( this ) . parent ( ) . parent ( ) ) ;
}
} ) ;
provExisting . append ( provisionBtn ) ;
return provExisting ;
2011-08-24 15:09:28 +00:00
}
/ * *
* Update the provision existing node status
*
2012-05-04 00:54:58 +00:00
* @ param data Data returned from HTTP request
2011-08-24 15:09:28 +00:00
* /
function updateIpmiProvisionExistingStatus ( data ) {
2012-05-04 00:54:58 +00:00
// Get ajax response
var rsp = data . rsp ;
var args = data . msg . split ( ';' ) ;
// Get command invoked
var cmd = args [ 0 ] . replace ( 'cmd=' , '' ) ;
// Get provision tab instance
var inst = args [ 1 ] . replace ( 'out=' , '' ) ;
// Get provision tab and status bar ID
var statBarId = 'ipmiProvisionStatBar' + inst ;
var tabId = 'ipmiProvisionTab' + inst ;
/ * *
* ( 2 ) Remote install
* /
if ( cmd == 'nodeadd' ) {
// Write ajax response to status bar
var prg = writeRsp ( rsp , '' ) ;
$ ( '#' + statBarId ) . find ( 'div' ) . append ( prg ) ;
// Get parameters
var os = $ ( '#' + tabId + ' input[name="os"]' ) . val ( ) ;
var profile = $ ( '#' + tabId + ' input[name="profile"]' ) . val ( ) ;
var arch = $ ( '#' + tabId + ' input[name="arch"]' ) . val ( ) ;
// Get nodes that were checked
var dTableId = 'ipmiNodesDatatable' + inst ;
var tgts = getNodesChecked ( dTableId ) ;
// Begin installation
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'rinstall;' + os + ';' + profile + ';' + arch + ';'
+ tgts ,
msg : 'cmd=rinstall;out=' + inst
} ,
success : updateIpmiProvisionExistingStatus
} ) ;
}
/ * *
* ( 3 ) Done
* /
else if ( cmd == 'rinstall' ) {
// Write ajax response to status bar
var prg = writeRsp ( rsp , '' ) ;
$ ( '#' + statBarId ) . find ( 'div' ) . append ( prg ) ;
$ ( '#' + statBarId ) . find ( 'img' ) . remove ( ) ;
// If installation was successful
if ( prg . html ( ) . indexOf ( 'Error' ) == - 1 ) {
$ ( '#' + statBarId )
. find ( 'div' )
. append (
'<pre>It will take several minutes before the nodes are up and ready. Use nodestat to check the status of the install.</pre>' ) ;
}
}
2011-12-31 06:46:13 +00:00
}
/ * *
2012-05-04 00:54:58 +00:00
* Step 2 : Init the iDataplex basic pattern
2011-12-31 06:46:13 +00:00
* /
2012-05-04 00:54:58 +00:00
function idataplexInitBasic ( ) {
2011-12-31 06:46:13 +00:00
var tempip = '' ;
$ ( '#discoverContentDiv' ) . empty ( ) ;
$ ( '.tooltip' ) . remove ( ) ;
2012-05-04 00:54:58 +00:00
var showString = '<div style="min-height:360px" id="patternDiv"><h2>'
+ steps [ currentStep ] + '</h2>' ;
2011-12-31 06:46:13 +00:00
showString += '<table><tbody>' ;
2012-05-04 00:54:58 +00:00
2011-12-31 06:46:13 +00:00
showString += '<tr><td><h3>Nodes:</h3></td></tr>' ;
2012-05-04 00:54:58 +00:00
showString += '<tr><td>Name Range:</td><td><input type="text" title="node[1-167] or node1-node167" '
+ 'name="idataplexnodename" value="'
+ getDiscoverEnv ( 'idataplexnodename' ) + '"></td>' ;
if ( getDiscoverEnv ( 'idataplexnodeip' ) ) {
2011-12-31 06:46:13 +00:00
tempip = getDiscoverEnv ( 'idataplexnodeip' ) ;
2012-05-04 00:54:58 +00:00
} else {
2011-12-31 06:46:13 +00:00
tempip = '172.30.20.1' ;
}
2012-05-04 00:54:58 +00:00
showString += '<td>Start IP:</td><td><input type="text" title="Format: XXX.XXX.XXX.1, last number must be 1.<br/> 172.30.20.1 is suggested." '
+ 'name="idataplexnodeip" value="' + tempip + '"></td></tr>' ;
showString += '<tr><td>Nodes number <br/>per Frame:</td><td><input type="text" title="84: Each frame contains 84 nodes.<br/>Valide Number:20,21,40,41,42,84." '
+ 'name="idataplexperframe" value="'
+ getDiscoverEnv ( 'idataplexperframe' )
+ '"></td><td></td><td></td></tr>' ;
2011-12-31 06:46:13 +00:00
showString += '<tr><td><h3>BMCs:</h3></td></tr>' ;
2012-05-04 00:54:58 +00:00
showString += '<tr><td>Name Range:</td><td><input type="text" title="bmc[1-167] or bmc1-bmc167" '
+ 'name="idataplexbmcname" value="'
+ getDiscoverEnv ( 'idataplexbmcname' ) + '"></td>' ;
if ( getDiscoverEnv ( 'idataplexbmcip' ) ) {
2011-12-31 06:46:13 +00:00
tempip = getDiscoverEnv ( 'idataplexbmcip' ) ;
2012-05-04 00:54:58 +00:00
} else {
2011-12-31 06:46:13 +00:00
tempip = '172.30.120.1' ;
}
2012-05-04 00:54:58 +00:00
showString += '<td>Start IP:</td><td><input type="text" title="Format: XXX.XXX.XXX.1, last number must be 1.<br/>172.30.120.1 is suggested." '
+ 'name="idataplexbmcip" value="' + tempip + '"></td></tr>' ;
2011-12-31 06:46:13 +00:00
showString += '<tr><td><h3>Switches:</h3></td></tr>' ;
2012-05-04 00:54:58 +00:00
showString += '<tr><td>Name Range:</td><td><input type="text" title="switch[1-4] or switch1-switch4" '
+ 'name="idataplexswitchname" value="'
+ getDiscoverEnv ( 'idataplexswitchname' ) + '"></td>' ;
if ( getDiscoverEnv ( 'idataplexswitchip' ) ) {
2011-12-31 06:46:13 +00:00
tempip = getDiscoverEnv ( 'idataplexswitchip' ) ;
2012-05-04 00:54:58 +00:00
} else {
2011-12-31 06:46:13 +00:00
tempip = '172.30.10.1' ;
}
2012-05-04 00:54:58 +00:00
showString += '<td>Start IP:</td><td><input type="text" title="Format: XXX.XXX.XXX.1, last number must be 1.<br/>172.30.10.1 is suggested." '
+ 'name="idataplexswitchip" value="' + tempip + '"></td></tr>' ;
2011-12-31 06:46:13 +00:00
2012-05-04 00:54:58 +00:00
showString += '<tr><td>Nodes number <br/>per Switch:</td><td><input type="text" title="42: Each switch connect 42 nodes.<br/>Valide Number:20,21,40,41,42."'
+ 'name="idataplexperswitch" value="'
+ getDiscoverEnv ( 'idataplexperswitch' )
+ '"></td><td></td><td></td></tr>' ;
showString += '</tbody></table></div>' ;
2011-12-31 06:46:13 +00:00
$ ( '#discoverContentDiv' ) . append ( showString ) ;
2012-05-04 00:54:58 +00:00
2011-12-31 06:46:13 +00:00
$ ( '#discoverContentDiv [title]' ) . tooltip ( {
2012-05-04 00:54:58 +00:00
position : "center right" ,
offset : [ - 2 , 10 ] ,
effect : "fade" ,
opacity : 1
2011-12-31 06:46:13 +00:00
} ) ;
2012-05-04 00:54:58 +00:00
2011-12-31 06:46:13 +00:00
createDiscoverButtons ( ) ;
}
/ * *
2012-05-04 00:54:58 +00:00
* Step 2 : Collect and check the basic pattern input
2011-12-31 06:46:13 +00:00
*
2012-05-04 00:54:58 +00:00
* @ param operType Operating type
* @ return True if the inputs are correct , false otherwise
2011-12-31 06:46:13 +00:00
* /
2012-05-04 00:54:58 +00:00
function idataplexCheckBasic ( operType ) {
2011-12-31 06:46:13 +00:00
collectInputValue ( ) ;
2012-05-04 00:54:58 +00:00
if ( 'back' == operType ) {
2011-12-31 06:46:13 +00:00
return true ;
}
2012-05-04 00:54:58 +00:00
2011-12-31 06:46:13 +00:00
$ ( '#patternDiv .ui-state-error' ) . remove ( ) ;
var errMessage = '' ;
var nodename = getDiscoverEnv ( 'idataplexnodename' ) ;
var nodeip = getDiscoverEnv ( 'idataplexnodeip' ) ;
var bmcname = getDiscoverEnv ( 'idataplexbmcname' ) ;
var bmcip = getDiscoverEnv ( 'idataplexbmcip' ) ;
var switchname = getDiscoverEnv ( 'idataplexswitchname' ) ;
var switchip = getDiscoverEnv ( 'idataplexswitchip' ) ;
var nodesperswitch = getDiscoverEnv ( 'idataplexperswitch' ) ;
var nodesperframe = getDiscoverEnv ( 'idataplexperframe' ) ;
2012-05-04 00:54:58 +00:00
if ( ! nodename ) {
2011-12-31 06:46:13 +00:00
errMessage += 'Input the Nodes name.<br/>' ;
}
2012-05-04 00:54:58 +00:00
if ( ! verifyIp ( nodeip ) ) {
2011-12-31 06:46:13 +00:00
errMessage += 'Input valid Nodes start ip.<br/>' ;
}
2012-05-04 00:54:58 +00:00
if ( ! bmcname ) {
2011-12-31 06:46:13 +00:00
errMessage += 'Input the BMC name.<br/>' ;
}
2012-05-04 00:54:58 +00:00
if ( ! verifyIp ( bmcip ) ) {
2011-12-31 06:46:13 +00:00
errMessage += 'Input valid BMC start ip.<br/>' ;
}
2012-05-04 00:54:58 +00:00
if ( ! switchname ) {
2011-12-31 06:46:13 +00:00
errMessage += 'Input the switch name.<br/>' ;
}
2012-05-04 00:54:58 +00:00
if ( ! verifyIp ( switchip ) ) {
2011-12-31 06:46:13 +00:00
errMessage += 'Input valid switch start ip.<br/>' ;
}
2012-05-04 00:54:58 +00:00
if ( ! nodesperswitch ) {
2011-12-31 06:46:13 +00:00
errMessage += 'Input the nodes number per switch.<br/>' ;
}
2012-05-04 00:54:58 +00:00
if ( ! nodesperframe ) {
2011-12-31 06:46:13 +00:00
errMessage += 'Input the nodes number per frame.<br/>' ;
}
2012-05-04 00:54:58 +00:00
if ( '' != errMessage ) {
2011-12-31 06:46:13 +00:00
var warnBar = createWarnBar ( errMessage ) ;
$ ( '#patternDiv' ) . prepend ( warnBar ) ;
return false ;
}
2012-05-04 00:54:58 +00:00
// Check the relations among nodes, bmcs and switches
2011-12-31 06:46:13 +00:00
var nodeNum = expandNR ( nodename ) . length ;
var bmcNum = expandNR ( bmcname ) . length ;
var switchNum = expandNR ( switchname ) . length ;
var tempNumber = 0 ;
2012-05-04 00:54:58 +00:00
// Node number and BMC number
if ( nodeNum != bmcNum ) {
2011-12-31 06:46:13 +00:00
errMessage += 'The number of Node must equal the number of BMC.<br/>' ;
}
2012-05-04 00:54:58 +00:00
// Node number calculate by switches
2011-12-31 06:46:13 +00:00
tempNumber += Number ( nodesperswitch ) * switchNum ;
2012-05-04 00:54:58 +00:00
if ( tempNumber < nodeNum ) {
2011-12-31 06:46:13 +00:00
errMessage += 'Input the node number per switch correctly.<br/>' ;
}
2012-05-04 00:54:58 +00:00
if ( '' != errMessage ) {
2011-12-31 06:46:13 +00:00
var warnBar = createWarnBar ( errMessage ) ;
$ ( '#patternDiv' ) . prepend ( warnBar ) ;
return false ;
}
return true ;
}
/ * *
2012-05-04 00:54:58 +00:00
* Step 3 : Tell users to configure the switches
2011-12-31 06:46:13 +00:00
* /
2012-05-04 00:54:58 +00:00
function idataplexInitSwitch ( ) {
2011-12-31 06:46:13 +00:00
$ ( '#discoverContentDiv' ) . empty ( ) ;
$ ( '.tooltip' ) . remove ( ) ;
var switchArray = expandNR ( getDiscoverEnv ( 'idataplexswitchname' ) ) ;
var switchIp = getDiscoverEnv ( 'idataplexswitchip' ) ;
2012-05-04 00:54:58 +00:00
var showString = '<div style="min-height:360px" id="switchDiv"><h2>'
+ steps [ currentStep ] + '</h2>' ;
showString += '<p>You defined ' + switchArray . length
+ ' switches in last step. Configure them manually please:<br/>' ;
showString += '<ul><li>1. Start IP address: ' + switchIp
+ ', and the IPs must be continuous.</li>' ;
2011-12-31 06:46:13 +00:00
showString += '<li>2. Enable the SNMP agent on switches.</li>' ;
showString += '<li>3. If you want to use the SNMP V3, the user/password and AuthProto (default is \'md5\') should be set in the switches table.</li>' ;
showString += '<li>4. Click the next button.</li>' ;
showString += '</p>' ;
$ ( '#discoverContentDiv' ) . append ( showString ) ;
2012-05-04 00:54:58 +00:00
2011-12-31 06:46:13 +00:00
createDiscoverButtons ( ) ;
}
/ * *
2012-05-04 00:54:58 +00:00
* Step 4 : Init the interface and DHCP dynamic range for hardware discovery page
2011-12-31 06:46:13 +00:00
* /
2012-05-04 00:54:58 +00:00
function idataplexInitNetwork ( ) {
2011-12-31 06:46:13 +00:00
$ ( '#discoverContentDiv' ) . empty ( ) ;
$ ( '.tooltip' ) . remove ( ) ;
var startIp = '172.30.200.1' ;
var endIp = '172.30.255.254' ;
2012-05-04 00:54:58 +00:00
var showDiv = $ ( '<div style="min-height:360px" id="networkDiv"><h2>'
+ steps [ currentStep ] + '</h2>' ) ;
2011-12-31 06:46:13 +00:00
var infoBar = createInfoBar ( 'Make sure the discovery NIC\'s IP, start IP addresses and DHCP dynamic IP range are in the same subnet.' ) ;
showDiv . append ( infoBar ) ;
2012-05-04 00:54:58 +00:00
// Init the IP range by input
if ( getDiscoverEnv ( 'idataplexIpStart' ) ) {
2011-12-31 06:46:13 +00:00
startIp = getDiscoverEnv ( 'idataplexIpStart' ) ;
}
2012-05-04 00:54:58 +00:00
if ( getDiscoverEnv ( 'idataplexIpEnd' ) ) {
2011-12-31 06:46:13 +00:00
endIp = getDiscoverEnv ( 'idataplexIpEnd' ) ;
}
var showString = '<table><tbody>' ;
2012-05-04 00:54:58 +00:00
showString += '<tr><td>DHCP Dynamic Range:</td><td><input type="text" name="idataplexIpStart" value="'
+ startIp
+ '" title="A start Ip address for DHCP dynamic range.<br/>172.30.200.1 is suggested.">-<input type="text" name="idataplexIpEnd" value="'
+ endIp
+ '" title="This IP must larger than start IP, and the range must large than the number of nodes and bmcs.<br/>172.30.255.254 is suggested."></td></tr>' ;
2011-12-31 06:46:13 +00:00
showString += '</tbody></table>' ;
showDiv . append ( showString ) ;
2012-05-04 00:54:58 +00:00
2011-12-31 06:46:13 +00:00
$ ( '#discoverContentDiv' ) . append ( showDiv ) ;
2012-05-04 00:54:58 +00:00
2011-12-31 06:46:13 +00:00
$ ( '#discoverContentDiv [title]' ) . tooltip ( {
2012-05-04 00:54:58 +00:00
position : "center right" ,
offset : [ - 2 , 10 ] ,
effect : "fade" ,
opacity : 1
2011-12-31 06:46:13 +00:00
} ) ;
2012-05-04 00:54:58 +00:00
2011-12-31 06:46:13 +00:00
createDiscoverButtons ( ) ;
}
/ * *
2012-05-04 00:54:58 +00:00
* Step 4 : Check the dynamic range for DHCP
2011-12-31 06:46:13 +00:00
* /
2012-05-04 00:54:58 +00:00
function idataplexCheckNetwork ( operType ) {
2011-12-31 06:46:13 +00:00
collectInputValue ( ) ;
2012-05-04 00:54:58 +00:00
if ( 'back' == operType ) {
2011-12-31 06:46:13 +00:00
return true ;
}
2012-05-04 00:54:58 +00:00
2011-12-31 06:46:13 +00:00
$ ( '#networkDiv .ui-state-error' ) . remove ( ) ;
var startIp = getDiscoverEnv ( 'idataplexIpStart' ) ;
var endIp = getDiscoverEnv ( 'idataplexIpEnd' ) ;
var errMessage = '' ;
2012-05-04 00:54:58 +00:00
if ( ! verifyIp ( startIp ) ) {
2011-12-31 06:46:13 +00:00
errMessage += 'Input the correct start IP address.<br/>' ;
}
2012-05-04 00:54:58 +00:00
if ( ! verifyIp ( endIp ) ) {
2011-12-31 06:46:13 +00:00
errMessage += 'Input the correct end IP address.<br/>' ;
}
2012-05-04 00:54:58 +00:00
if ( '' != errMessage ) {
2011-12-31 06:46:13 +00:00
var warnBar = createWarnBar ( errMessage ) ;
$ ( '#networkDiv' ) . prepend ( warnBar ) ;
return false ;
}
2012-05-04 00:54:58 +00:00
if ( ip2Decimal ( endIp ) <= ip2Decimal ( startIp ) ) {
2011-12-31 06:46:13 +00:00
var warnBar = createWarnBar ( 'the end IP must larger than start IP.<br/>' ) ;
$ ( '#networkDiv' ) . prepend ( warnBar ) ;
return false ;
}
2012-05-04 00:54:58 +00:00
2011-12-31 06:46:13 +00:00
return true ;
}
/ * *
2012-05-04 00:54:58 +00:00
* Step 5 : Configure service by xCAT command and restart
2011-12-31 06:46:13 +00:00
* /
2012-05-04 00:54:58 +00:00
function idataplexInitService ( operType ) {
2011-12-31 06:46:13 +00:00
$ ( '#discoverContentDiv' ) . empty ( ) ;
$ ( '.tooltip' ) . remove ( ) ;
var showStr = '<div style="min-height:360px" id="serviceDiv"><h2>' + steps [ currentStep ] + '</h2>' ;
showStr += '<ul>' ;
showStr += '<li id="fileLine"><span class="ui-icon ui-icon-wrench"></span>Create configure file for xcatsetup.</li>' ;
showStr += '<li id="setupLine"><span class="ui-icon ui-icon-wrench"></span>Wrote Objects into xCAT database by xcatsetup.</li>' ;
showStr += '<li id="hostsLine"><span class="ui-icon ui-icon-wrench"></span>Configure Hosts.</li>' ;
showStr += '<li id="dnsLine"><span class="ui-icon ui-icon-wrench"></span>Configure DNS.</li>' ;
showStr += '<li id="dhcpLine"><span class="ui-icon ui-icon-wrench"></span>Configure DHCP.</li>' ;
showStr += '<li id="conserverLine"><span class="ui-icon ui-icon-wrench"></span>Configure Conserver.</li>' ;
showStr += '</ul>' ;
showStr += '</div>' ;
$ ( '#discoverContentDiv' ) . append ( showStr ) ;
2012-05-04 00:54:58 +00:00
if ( 'back' == operType ) {
2011-12-31 06:46:13 +00:00
createDiscoverButtons ( ) ;
return ;
}
2012-05-04 00:54:58 +00:00
2011-12-31 06:46:13 +00:00
idataplexCreateSetupFile ( ) ;
}
/ * *
2012-05-04 00:54:58 +00:00
* Step 5 : Create the stanza file for xcatsetup
2011-12-31 06:46:13 +00:00
* /
2012-05-04 00:54:58 +00:00
function idataplexCreateSetupFile ( ) {
2011-12-31 06:46:13 +00:00
var fileContent = '' ;
2012-05-04 00:54:58 +00:00
// Add the waiting loader
2011-12-31 06:46:13 +00:00
$ ( '#fileLine' ) . append ( createLoader ( ) ) ;
2012-05-04 00:54:58 +00:00
fileContent += "xcat-site:\n" + " domain = cluster.com\n"
+ " cluster-type = idataplex\n" ;
fileContent += "xcat-service-lan:\n" + " dhcp-dynamic-range = "
+ getDiscoverEnv ( 'idataplexIpStart' ) + "-"
+ getDiscoverEnv ( 'idataplexIpEnd' ) + "\n" ;
2011-12-31 06:46:13 +00:00
2012-05-04 00:54:58 +00:00
fileContent += "xcat-switches:\n" + " hostname-range = "
+ getDiscoverEnv ( 'idataplexswitchname' ) + "\n" + " starting-ip = "
+ getDiscoverEnv ( 'idataplexswitchip' ) + "\n" ;
fileContent += "xcat-nodes:\n" + " hostname-range = "
+ getDiscoverEnv ( 'idataplexnodename' ) + "\n" + " starting-ip = "
+ getDiscoverEnv ( 'idataplexnodeip' ) + "\n"
+ " num-nodes-per-switch = "
+ getDiscoverEnv ( 'idataplexperswitch' ) + "\n"
+ " num-nodes-per-frame = " + getDiscoverEnv ( 'idataplexperframe' )
+ "\n" ;
fileContent += "xcat-bmcs:\n" + " hostname-range = "
+ getDiscoverEnv ( 'idataplexbmcname' ) + "\n" + " starting-ip = "
+ getDiscoverEnv ( 'idataplexbmcip' ) + "\n" ;
2011-12-31 06:46:13 +00:00
$ . ajax ( {
url : 'lib/systemcmd.php' ,
dataType : 'json' ,
data : {
cmd : 'echo -e "' + fileContent + '" > /tmp/webxcat.conf'
} ,
2012-05-04 00:54:58 +00:00
success : function ( data ) {
2011-12-31 06:46:13 +00:00
$ ( '#fileLine img' ) . remove ( ) ;
var tempSpan = $ ( '#fileLine' ) . find ( 'span' ) ;
tempSpan . removeClass ( 'ui-icon-wrench' ) ;
tempSpan . addClass ( 'ui-icon-check' ) ;
idataplexSetup ( ) ;
}
} ) ;
}
/ * *
2012-05-04 00:54:58 +00:00
* Step 5 : Run xcatsetup to create the database for iDataplex cluster
2011-12-31 06:46:13 +00:00
* /
2012-05-04 00:54:58 +00:00
function idataplexSetup ( ) {
2011-12-31 06:46:13 +00:00
$ ( '#setupLine' ) . append ( createLoader ( ) ) ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'xcatsetup' ,
tgt : '' ,
args : '/tmp/webxcat.conf' ,
msg : ''
} ,
2012-05-04 00:54:58 +00:00
success : function ( data ) {
2011-12-31 06:46:13 +00:00
$ ( '#setupLine img' ) . remove ( ) ;
var tempSpan = $ ( '#setupLine' ) . find ( 'span' ) ;
tempSpan . removeClass ( 'ui-icon-wrench' ) ;
tempSpan . addClass ( 'ui-icon-check' ) ;
idataplexMakehosts ( ) ;
}
} ) ;
}
/ * *
2012-05-04 00:54:58 +00:00
* Step 5 : Run makehosts for iDataplex
2011-12-31 06:46:13 +00:00
* /
2012-05-04 00:54:58 +00:00
function idataplexMakehosts ( ) {
2011-12-31 06:46:13 +00:00
createDiscoverButtons ( ) ;
}
2012-05-04 00:54:58 +00:00
2011-12-31 06:46:13 +00:00
/ * *
2012-05-04 00:54:58 +00:00
* Step 6 : Tell users to power on all hardware for discovery
2011-12-31 06:46:13 +00:00
* /
2012-05-04 00:54:58 +00:00
function idataplexInitPowerOn ( ) {
2011-12-31 06:46:13 +00:00
$ ( '#discoverContentDiv' ) . empty ( ) ;
$ ( '.tooltip' ) . remove ( ) ;
2012-05-04 00:54:58 +00:00
var showString = '<div style="min-height:360px" id="poweronDiv"><h2>'
+ steps [ currentStep ] + '</h2>' ;
showString += 'Walk over to each idataplex server and push the power button to power on. <br/>'
+ 'After about 5-10 minutes, nodes should be configured and ready for hardware management.<br/>' ;
2011-12-31 06:46:13 +00:00
$ ( '#discoverContentDiv' ) . append ( showString ) ;
2012-05-04 00:54:58 +00:00
// Add the refresh button
2011-12-31 06:46:13 +00:00
var refreshButton = createButton ( "Refresh" ) ;
$ ( '#poweronDiv' ) . append ( refreshButton ) ;
2012-05-04 00:54:58 +00:00
refreshButton . bind ( 'click' , function ( ) {
2011-12-31 06:46:13 +00:00
var tempObj = $ ( '#poweronDiv div p' ) ;
tempObj . empty ( ) . append ( createLoader ( ) ) ;
2012-05-04 00:54:58 +00:00
2011-12-31 06:46:13 +00:00
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'rpower' ,
tgt : 'all' ,
args : 'stat' ,
msg : ''
} ,
2012-05-04 00:54:58 +00:00
success : function ( data ) {
2011-12-31 06:46:13 +00:00
var tempObj = $ ( '#poweronDiv div p' ) ;
tempObj . empty ( ) ;
2012-05-04 00:54:58 +00:00
for ( var i in data . rsp ) {
2011-12-31 06:46:13 +00:00
tempObj . append ( data . rsp [ i ] + '<br/>' ) ;
}
}
} ) ;
} ) ;
2012-05-04 00:54:58 +00:00
// Add the info area
2011-12-31 06:46:13 +00:00
var infoBar = createInfoBar ( 'Click the refresh button to check all nodes\' status.' ) ;
$ ( '#poweronDiv' ) . append ( infoBar ) ;
createDiscoverButtons ( ) ;
2011-08-24 15:09:28 +00:00
}