2010-07-15 22:57:48 +00:00
/ * *
* Global variables
* /
2010-07-19 18:28:31 +00:00
var diskDatatable ; // zVM datatable containing disks
var networkDatatable ; // zVM datatable containing networks
2010-07-15 22:57:48 +00:00
/ * *
* Get the disk datatable
*
* @ param Nothing
* @ return Data table object
* /
function getDiskDataTable ( ) {
2010-07-19 18:28:31 +00:00
return diskDatatable ;
2010-07-15 22:57:48 +00:00
}
/ * *
* Set the disk datatable
*
* @ param table
* Data table object
* @ return Nothing
* /
function setDiskDataTable ( table ) {
2010-07-19 18:28:31 +00:00
diskDatatable = table ;
2010-07-15 22:57:48 +00:00
}
/ * *
* Get the network datatable
*
* @ param Nothing
* @ return Data table object
* /
function getNetworkDataTable ( ) {
2010-07-19 18:28:31 +00:00
return networkDatatable ;
2010-07-15 22:57:48 +00:00
}
/ * *
* Set the network datatable
*
* @ param table
* Data table object
* @ return Nothing
* /
function setNetworkDataTable ( table ) {
2010-07-19 18:28:31 +00:00
networkDatatable = table ;
2010-07-15 22:57:48 +00:00
}
2010-11-03 16:23:54 +00:00
/ * *
* Load HCP specific info
*
* @ param data
* Data from HTTP request
* @ return Nothing
* /
function loadHcpInfo ( data ) {
var args = data . msg . split ( ';' ) ;
// Get group
var group = args [ 0 ] . replace ( 'group=' , '' ) ;
// Get hardware control point
var hcp = args [ 1 ] . replace ( 'hcp=' , '' ) ;
// Get user directory entry
var userEntry = data . rsp ;
2010-11-12 20:11:04 +00:00
if ( userEntry [ 0 ] . indexOf ( 'Failed' ) < 0 ) {
2010-12-03 22:09:36 +00:00
if ( hcp ) {
2010-12-09 03:44:11 +00:00
// If there is no cookie for the disk pool names
if ( ! $ . cookie ( hcp + 'diskpools' ) ) {
// Get disk pools
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'lsvm' ,
tgt : hcp ,
args : '--diskpoolnames' ,
msg : hcp
} ,
success : setDiskPoolCookies
} ) ;
}
2010-12-03 22:09:36 +00:00
2010-12-09 03:44:11 +00:00
// If there is no cookie for the network names
if ( ! $ . cookie ( hcp + 'networks' ) ) {
// Get network names
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'lsvm' ,
tgt : hcp ,
args : '--getnetworknames' ,
msg : hcp
} ,
success : setNetworkCookies
} ) ;
}
2010-12-03 22:09:36 +00:00
} // End of if (hcp)
2010-11-03 16:23:54 +00:00
} else {
2011-01-19 15:56:43 +00:00
// Create warning dialog
2012-03-14 19:20:37 +00:00
var warning = createWarnBar ( 'z/VM SMAPI is not responding to ' + hcp + '. It needs to be reset.' ) ;
var warnDialog = $ ( '<div></div>' ) . append ( warning ) ;
2012-01-22 13:06:32 +00:00
2010-11-03 16:23:54 +00:00
// Open dialog
warnDialog . dialog ( {
2011-12-01 04:10:40 +00:00
title : 'Warning' ,
2010-11-03 16:23:54 +00:00
modal : true ,
width : 400 ,
buttons : {
"Reset" : function ( ) {
$ ( this ) . dialog ( "close" ) ;
// Reset SMAPI
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : hcp ,
args : '--resetsmapi' ,
msg : 'group=' + group + ';hcp=' + hcp
} ,
/ * *
* Refresh group tab
*
* @ param data
* Data from HTTP request
* @ return Nothing
* /
success : function ( data ) {
var args = data . msg . split ( ';' ) ;
// Get group
var group = args [ 0 ] . replace ( 'group=' , '' ) ;
// Get hardware control point
var hcp = args [ 1 ] . replace ( 'hcp=' , '' ) ;
// Clear nodes division
$ ( '#nodes' ) . children ( ) . remove ( ) ;
// Create loader
var loader = $ ( '<center></center>' ) . append ( createLoader ( ) ) ;
// Create a tab for this group
var tab = new Tab ( ) ;
setNodesTab ( tab ) ;
tab . init ( ) ;
$ ( '#nodes' ) . append ( tab . object ( ) ) ;
tab . add ( 'nodesTab' , 'Nodes' , loader , false ) ;
// Get nodes within selected group
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'lsdef' ,
tgt : '' ,
args : group ,
msg : group
} ,
success : loadNodes
} ) ;
} // End of function
} ) ;
} ,
"Ignore" : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
}
} ) ;
}
}
2010-07-15 22:57:48 +00:00
/ * *
* Load user entry of a given node
*
* @ param data
* Data from HTTP request
* @ return Nothing
* /
function loadUserEntry ( data ) {
var args = data . msg . split ( ';' ) ;
// Get tab ID
var ueDivId = args [ 0 ] . replace ( 'out=' , '' ) ;
// Get node
var node = args [ 1 ] . replace ( 'node=' , '' ) ;
2010-09-24 02:27:04 +00:00
// Get user directory entry
2010-07-15 22:57:48 +00:00
var userEntry = data . rsp [ 0 ] . split ( node + ':' ) ;
// Remove loader
2011-01-19 15:56:43 +00:00
$ ( '#' + node + 'TabLoader' ) . remove ( ) ;
2010-07-15 22:57:48 +00:00
var toggleLinkId = node + 'ToggleLink' ;
$ ( '#' + toggleLinkId ) . click ( function ( ) {
2010-07-29 17:32:24 +00:00
// Get text within this link
2010-07-15 22:57:48 +00:00
var lnkText = $ ( this ) . text ( ) ;
// Toggle user entry division
$ ( '#' + node + 'UserEntry' ) . toggle ( ) ;
// Toggle inventory division
$ ( '#' + node + 'Inventory' ) . toggle ( ) ;
// Change text
2010-09-24 02:27:04 +00:00
if ( lnkText == 'Show directory entry' ) {
2010-07-15 22:57:48 +00:00
$ ( this ) . text ( 'Show inventory' ) ;
} else {
2010-09-24 02:27:04 +00:00
$ ( this ) . text ( 'Show directory entry' ) ;
2010-07-15 22:57:48 +00:00
}
} ) ;
// Put user entry into a list
var fieldSet = $ ( '<fieldset></fieldset>' ) ;
2010-09-24 02:27:04 +00:00
var legend = $ ( '<legend>Directory Entry</legend>' ) ;
2010-07-15 22:57:48 +00:00
fieldSet . append ( legend ) ;
var txtArea = $ ( '<textarea></textarea>' ) ;
for ( var i = 1 ; i < userEntry . length ; i ++ ) {
userEntry [ i ] = jQuery . trim ( userEntry [ i ] ) ;
txtArea . append ( userEntry [ i ] ) ;
if ( i < userEntry . length ) {
txtArea . append ( '\n' ) ;
}
}
txtArea . attr ( 'readonly' , 'readonly' ) ;
fieldSet . append ( txtArea ) ;
/ * *
* Edit user entry
* /
txtArea . bind ( 'dblclick' , function ( event ) {
txtArea . attr ( 'readonly' , '' ) ;
txtArea . css ( {
'border-width' : '1px'
} ) ;
saveBtn . show ( ) ;
cancelBtn . show ( ) ;
2011-01-11 21:49:46 +00:00
saveBtn . css ( 'display' , 'inline-table' ) ;
cancelBtn . css ( 'display' , 'inline-table' ) ;
2010-07-15 22:57:48 +00:00
} ) ;
2010-07-29 17:32:24 +00:00
2010-07-19 18:28:31 +00:00
/ * *
* Save
* /
2011-01-19 15:56:43 +00:00
var saveBtn = createButton ( 'Save' ) . hide ( ) ;
2010-07-15 22:57:48 +00:00
saveBtn . bind ( 'click' , function ( event ) {
// Show loader
2011-01-19 15:56:43 +00:00
$ ( '#' + node + 'StatusBarLoader' ) . show ( ) ;
$ ( '#' + node + 'StatusBar' ) . show ( ) ;
2010-07-15 22:57:48 +00:00
// Replace user entry
var newUserEntry = jQuery . trim ( txtArea . val ( ) ) + '\n' ;
// Replace user entry
$ . ajax ( {
url : 'lib/zCmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : node ,
args : '--replacevs' ,
att : newUserEntry ,
msg : node
} ,
success : updateZNodeStatus
} ) ;
// Increment node process and save it in a cookie
2010-07-19 18:28:31 +00:00
incrementNodeProcess ( node ) ;
2010-07-15 22:57:48 +00:00
txtArea . attr ( 'readonly' , 'readonly' ) ;
txtArea . css ( {
'border-width' : '0px'
} ) ;
2010-07-29 17:32:24 +00:00
// Disable save button
2010-07-15 22:57:48 +00:00
$ ( this ) . hide ( ) ;
cancelBtn . hide ( ) ;
} ) ;
2010-07-19 18:28:31 +00:00
/ * *
* Cancel
* /
2011-01-19 15:56:43 +00:00
var cancelBtn = createButton ( 'Cancel' ) . hide ( ) ;
2010-07-15 22:57:48 +00:00
cancelBtn . bind ( 'click' , function ( event ) {
txtArea . attr ( 'readonly' , 'readonly' ) ;
txtArea . css ( {
'border-width' : '0px'
} ) ;
cancelBtn . hide ( ) ;
saveBtn . hide ( ) ;
} ) ;
// Create info bar
2010-12-04 15:22:16 +00:00
var infoBar = createInfoBar ( 'Double click on the directory entry to edit it.' ) ;
2010-07-15 22:57:48 +00:00
// Append user entry into division
$ ( '#' + ueDivId ) . append ( infoBar ) ;
$ ( '#' + ueDivId ) . append ( fieldSet ) ;
$ ( '#' + ueDivId ) . append ( saveBtn ) ;
$ ( '#' + ueDivId ) . append ( cancelBtn ) ;
}
/ * *
2010-07-29 17:32:24 +00:00
* Increment number of processes running against a node
2010-07-15 22:57:48 +00:00
*
* @ param node
2010-07-29 17:32:24 +00:00
* Node to increment running processes
2010-07-15 22:57:48 +00:00
* @ return Nothing
* /
2010-07-19 18:28:31 +00:00
function incrementNodeProcess ( node ) {
2010-07-29 17:32:24 +00:00
// Get current processes
2010-11-22 16:18:55 +00:00
var procs = $ . cookie ( node + 'processes' ) ;
2010-07-19 18:28:31 +00:00
if ( procs ) {
2010-07-15 22:57:48 +00:00
// One more process
2010-07-19 18:28:31 +00:00
procs = parseInt ( procs ) + 1 ;
2010-11-22 16:18:55 +00:00
$ . cookie ( node + 'processes' , procs ) ;
2010-07-15 22:57:48 +00:00
} else {
2010-11-22 16:18:55 +00:00
$ . cookie ( node + 'processes' , 1 ) ;
2010-07-15 22:57:48 +00:00
}
}
/ * *
2010-07-29 17:32:24 +00:00
* Update provision new node status
2010-07-15 22:57:48 +00:00
*
* @ param data
* Data returned from HTTP request
* @ return Nothing
* /
2010-07-29 20:22:09 +00:00
function updateZProvisionNewStatus ( data ) {
2010-07-27 22:56:42 +00:00
// Get ajax response
2010-07-15 22:57:48 +00:00
var rsp = data . rsp ;
var args = data . msg . split ( ';' ) ;
// Get command invoked
var cmd = args [ 0 ] . replace ( 'cmd=' , '' ) ;
// Get output ID
var out2Id = args [ 1 ] . replace ( 'out=' , '' ) ;
2010-07-29 17:32:24 +00:00
// Get status bar ID
2010-07-15 22:57:48 +00:00
var statBarId = 'zProvisionStatBar' + out2Id ;
2010-07-29 17:32:24 +00:00
// Get provision tab ID
2010-07-15 22:57:48 +00:00
var tabId = 'zvmProvisionTab' + out2Id ;
2010-07-29 17:32:24 +00:00
// Get loader ID
var loaderId = 'zProvisionLoader' + out2Id ;
2010-07-15 22:57:48 +00:00
// Get node name
var node = $ ( '#' + tabId + ' input[name=nodeName]' ) . val ( ) ;
/ * *
2010-07-19 18:28:31 +00:00
* ( 2 ) Update / etc / hosts
2010-07-15 22:57:48 +00:00
* /
if ( cmd == 'nodeadd' ) {
2010-09-24 02:27:04 +00:00
// If there was an error, do not continue
2010-07-15 22:57:48 +00:00
if ( rsp . length ) {
2010-07-29 17:32:24 +00:00
$ ( '#' + loaderId ) . hide ( ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( '<pre>(Error) Failed to create node definition</pre>' ) ;
2010-07-15 22:57:48 +00:00
} else {
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( '<pre>Node definition created for ' + node + '</pre>' ) ;
2010-07-29 17:32:24 +00:00
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'makehosts' ,
tgt : '' ,
args : '' ,
msg : 'cmd=makehosts;out=' + out2Id
} ,
2010-07-29 20:22:09 +00:00
success : updateZProvisionNewStatus
2010-07-29 17:32:24 +00:00
} ) ;
2010-07-15 22:57:48 +00:00
}
}
/ * *
2010-07-19 18:28:31 +00:00
* ( 3 ) Update DNS
2010-07-15 22:57:48 +00:00
* /
else if ( cmd == 'makehosts' ) {
2010-09-24 02:27:04 +00:00
// If there was an error, do not continue
2010-07-15 22:57:48 +00:00
if ( rsp . length ) {
2010-07-29 17:32:24 +00:00
$ ( '#' + loaderId ) . hide ( ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( '<pre>(Error) Failed to update /etc/hosts</pre>' ) ;
2010-07-15 22:57:48 +00:00
} else {
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( '<pre>/etc/hosts updated</pre>' ) ;
2010-07-29 17:32:24 +00:00
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'makedns' ,
tgt : '' ,
args : '' ,
msg : 'cmd=makedns;out=' + out2Id
} ,
2010-07-15 22:57:48 +00:00
2010-07-29 20:22:09 +00:00
success : updateZProvisionNewStatus
2010-07-29 17:32:24 +00:00
} ) ;
}
2010-07-15 22:57:48 +00:00
}
/ * *
2010-07-19 18:28:31 +00:00
* ( 4 ) Create user entry
2010-07-15 22:57:48 +00:00
* /
2010-07-29 17:32:24 +00:00
else if ( cmd == 'makedns' ) {
// Reset number of tries
2010-07-15 22:57:48 +00:00
$ . cookie ( 'tries4' + tabId , 0 ) ;
2010-07-27 22:56:42 +00:00
// Write ajax response to status bar
var prg = writeRsp ( rsp , '' ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( prg ) ;
2010-07-15 22:57:48 +00:00
2010-07-29 17:32:24 +00:00
// Get user entry
var userEntry = $ ( '#' + tabId + ' textarea' ) . val ( ) ;
2010-07-15 22:57:48 +00:00
// Create user entry
$ . ajax ( {
url : 'lib/zCmd.php' ,
dataType : 'json' ,
data : {
cmd : 'mkvm' ,
tgt : node ,
args : '' ,
att : userEntry ,
msg : 'cmd=mkvm;out=' + out2Id
} ,
2010-07-29 20:22:09 +00:00
success : updateZProvisionNewStatus
2010-07-15 22:57:48 +00:00
} ) ;
}
/ * *
2010-07-19 18:28:31 +00:00
* ( 5 ) Add disk
2010-07-15 22:57:48 +00:00
* /
2010-07-29 17:32:24 +00:00
else if ( cmd == 'mkvm' ) {
2010-07-27 22:56:42 +00:00
// Write ajax response to status bar
var prg = writeRsp ( rsp , '' ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( prg ) ;
2010-07-15 22:57:48 +00:00
2010-09-24 02:27:04 +00:00
// If there was an error, do not continue
2010-07-27 22:56:42 +00:00
if ( prg . html ( ) . indexOf ( 'Error' ) > - 1 ) {
2010-07-29 17:32:24 +00:00
// Try again
2010-07-15 22:57:48 +00:00
var tries = parseInt ( $ . cookie ( 'tries4' + tabId ) ) ;
if ( tries < 2 ) {
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( '<pre>Trying again...</pre>' ) ;
2010-07-15 22:57:48 +00:00
tries = tries + 1 ;
// One more try
$ . cookie ( 'tries4' + tabId , tries ) ;
2010-07-29 17:32:24 +00:00
// Get user entry
var userEntry = $ ( '#' + tabId + ' textarea' ) . val ( ) ;
2010-07-15 22:57:48 +00:00
// Create user entry
$ . ajax ( {
url : 'lib/zCmd.php' ,
dataType : 'json' ,
data : {
cmd : 'mkvm' ,
tgt : node ,
args : '' ,
att : userEntry ,
msg : 'cmd=mkvm;out=' + out2Id
} ,
2010-07-29 20:22:09 +00:00
success : updateZProvisionNewStatus
2010-07-15 22:57:48 +00:00
} ) ;
} else {
$ ( '#' + loaderId ) . hide ( ) ;
}
2010-07-29 17:32:24 +00:00
} else {
// Reset number of tries
2010-07-15 22:57:48 +00:00
$ . cookie ( 'tries4' + tabId , 0 ) ;
// Set cookie for number of disks
2011-04-01 14:35:29 +00:00
var diskRows = $ ( '#' + tabId + ' table:visible tbody tr' ) ;
2010-11-22 16:18:55 +00:00
$ . cookie ( 'disks2add' + out2Id , diskRows . length ) ;
2010-07-15 22:57:48 +00:00
if ( diskRows . length > 0 ) {
for ( var i = 0 ; i < diskRows . length ; i ++ ) {
2010-09-01 15:36:05 +00:00
// Get disk type, address, size, mode, pool, and password
2010-07-15 22:57:48 +00:00
var diskArgs = diskRows . eq ( i ) . find ( 'td' ) ;
var type = diskArgs . eq ( 1 ) . find ( 'select' ) . val ( ) ;
var address = diskArgs . eq ( 2 ) . find ( 'input' ) . val ( ) ;
var size = diskArgs . eq ( 3 ) . find ( 'input' ) . val ( ) ;
2010-09-01 15:36:05 +00:00
var mode = diskArgs . eq ( 4 ) . find ( 'select' ) . val ( ) ;
var pool = diskArgs . eq ( 5 ) . find ( 'input' ) . val ( ) ;
var password = diskArgs . eq ( 6 ) . find ( 'input' ) . val ( ) ;
// Create ajax arguments
var args = '' ;
if ( type == '3390' ) {
args = '--add' + type + ';' + pool + ';' + address
+ ';' + size + ';' + mode + ';' + password + ';'
+ password + ';' + password ;
} else if ( type == '9336' ) {
var blkSize = '512' ;
args = '--add' + type + ';' + pool + ';' + address + ';'
+ blkSize + ';' + size + ';' + mode + ';' + password + ';'
+ password + ';' + password ;
}
2010-07-15 22:57:48 +00:00
2010-07-29 17:32:24 +00:00
// Add disk
2010-09-01 15:36:05 +00:00
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : node ,
args : args ,
msg : 'cmd=chvm;out=' + out2Id
} ,
2010-07-15 22:57:48 +00:00
2010-09-01 15:36:05 +00:00
success : updateZProvisionNewStatus
} ) ;
2010-07-15 22:57:48 +00:00
}
} else {
$ ( '#' + loaderId ) . hide ( ) ;
}
}
}
/ * *
2010-07-29 17:32:24 +00:00
* ( 6 ) Set operating system for given node
2010-07-15 22:57:48 +00:00
* /
else if ( cmd == 'chvm' ) {
2010-07-27 22:56:42 +00:00
// Write ajax response to status bar
var prg = writeRsp ( rsp , '' ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( prg ) ;
2010-07-15 22:57:48 +00:00
2010-09-24 02:27:04 +00:00
// If there was an error, do not continue
2010-07-27 22:56:42 +00:00
if ( prg . html ( ) . indexOf ( 'Error' ) > - 1 ) {
2010-07-29 17:32:24 +00:00
$ ( '#' + loaderId ) . hide ( ) ;
2010-07-15 22:57:48 +00:00
2010-07-29 17:32:24 +00:00
// Try again
2010-07-15 22:57:48 +00:00
var tries = parseInt ( $ . cookie ( 'tries4' + tabId ) ) ;
if ( tries < 2 ) {
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( '<pre>Trying again...</pre>' ) ;
2010-07-15 22:57:48 +00:00
tries = tries + 1 ;
// One more try
$ . cookie ( 'tries4' + tabId , tries ) ;
// Set cookie for number of disks
2011-04-01 14:35:29 +00:00
var diskRows = $ ( '#' + tabId + ' table:visible tbody tr' ) ;
2010-11-22 16:18:55 +00:00
$ . cookie ( 'disks2add' + out2Id , diskRows . length ) ;
2010-07-15 22:57:48 +00:00
if ( diskRows . length > 0 ) {
for ( var i = 0 ; i < diskRows . length ; i ++ ) {
2010-07-29 17:32:24 +00:00
// Get disk type, address, size, pool, and password
2010-07-15 22:57:48 +00:00
var diskArgs = diskRows . eq ( i ) . find ( 'td' ) ;
2010-09-01 15:36:05 +00:00
var type = diskArgs . eq ( 1 ) . find ( 'select' ) . val ( ) ;
var address = diskArgs . eq ( 2 ) . find ( 'input' ) . val ( ) ;
var size = diskArgs . eq ( 3 ) . find ( 'input' ) . val ( ) ;
var mode = diskArgs . eq ( 4 ) . find ( 'select' ) . val ( ) ;
var pool = diskArgs . eq ( 5 ) . find ( 'input' ) . val ( ) ;
var password = diskArgs . eq ( 6 ) . find ( 'input' ) . val ( ) ;
// Create ajax arguments
var args = '' ;
if ( type == '3390' ) {
args = '--add' + type + ';' + pool + ';' + address
+ ';' + size + ';' + mode + ';' + password + ';'
+ password + ';' + password ;
} else if ( type == '9336' ) {
var blkSize = '512' ;
args = '--add' + type + ';' + pool + ';' + address + ';'
+ blkSize + ';' + size + ';' + mode + ';' + password + ';'
+ password + ';' + password ;
}
2010-07-15 22:57:48 +00:00
2010-07-29 17:32:24 +00:00
// Add disk
2010-07-15 22:57:48 +00:00
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : node ,
2010-09-01 15:36:05 +00:00
args : args ,
2010-07-15 22:57:48 +00:00
msg : 'cmd=chvm;out=' + out2Id
} ,
2010-07-29 20:22:09 +00:00
success : updateZProvisionNewStatus
2010-07-15 22:57:48 +00:00
} ) ;
}
} else {
$ ( '#' + loaderId ) . hide ( ) ;
}
} else {
2010-07-29 17:32:24 +00:00
$ ( '#' + loaderId ) . hide ( ) ;
2010-07-15 22:57:48 +00:00
}
} else {
2010-07-29 17:32:24 +00:00
// Reset number of tries
2010-07-15 22:57:48 +00:00
$ . cookie ( 'tries4' + tabId , 0 ) ;
2010-07-29 17:32:24 +00:00
// Get operating system image
2010-07-29 20:22:09 +00:00
var osImage = $ ( '#' + tabId + ' input[name=os]:visible' ) . val ( ) ;
2010-07-29 17:32:24 +00:00
2010-07-15 22:57:48 +00:00
// Get cookie for number of disks
2010-11-22 16:18:55 +00:00
var disks2add = $ . cookie ( 'disks2add' + out2Id ) ;
2010-07-15 22:57:48 +00:00
// One less disk to add
disks2add = disks2add - 1 ;
// Set cookie for number of disks
2010-11-22 16:18:55 +00:00
$ . cookie ( 'disks2add' + out2Id , disks2add ) ;
2010-07-15 22:57:48 +00:00
2010-07-29 17:32:24 +00:00
// If an operating system image is given
2010-07-15 22:57:48 +00:00
if ( osImage ) {
var tmp = osImage . split ( '-' ) ;
2010-07-29 20:22:09 +00:00
2010-07-29 17:32:24 +00:00
// Get operating system, architecture, provision method, and profile
2010-07-15 22:57:48 +00:00
var os = tmp [ 0 ] ;
var arch = tmp [ 1 ] ;
var profile = tmp [ 3 ] ;
2010-07-29 17:32:24 +00:00
// If the last disk is added
2010-07-15 22:57:48 +00:00
if ( disks2add < 1 ) {
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'nodeadd' ,
tgt : '' ,
args : node + ';noderes.netboot=zvm;nodetype.os='
+ os + ';nodetype.arch=' + arch
+ ';nodetype.profile=' + profile ,
msg : 'cmd=noderes;out=' + out2Id
} ,
2010-07-29 20:22:09 +00:00
success : updateZProvisionNewStatus
2010-07-15 22:57:48 +00:00
} ) ;
}
} else {
$ ( '#' + loaderId ) . hide ( ) ;
}
}
}
/ * *
2010-07-19 18:28:31 +00:00
* ( 7 ) Update DHCP
2010-07-15 22:57:48 +00:00
* /
else if ( cmd == 'noderes' ) {
2010-10-08 03:03:42 +00:00
// If there was an error, do not continue
2010-07-15 22:57:48 +00:00
if ( rsp . length ) {
2010-07-29 17:32:24 +00:00
$ ( '#' + loaderId ) . hide ( ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( '<pre>(Error) Failed to set operating system</pre>' ) ;
2010-07-15 22:57:48 +00:00
} else {
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( '<pre>Operating system for ' + node + ' set</pre>' ) ;
2010-07-29 17:32:24 +00:00
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'makedhcp' ,
tgt : '' ,
args : '-a' ,
msg : 'cmd=makedhcp;out=' + out2Id
} ,
2010-07-15 22:57:48 +00:00
2010-07-29 20:22:09 +00:00
success : updateZProvisionNewStatus
2010-07-29 17:32:24 +00:00
} ) ;
2011-10-14 19:21:07 +00:00
}
2010-07-15 22:57:48 +00:00
}
/ * *
2010-07-19 18:28:31 +00:00
* ( 8 ) Prepare node for boot
2010-07-15 22:57:48 +00:00
* /
2011-10-14 19:21:07 +00:00
else if ( cmd == 'makedhcp' ) {
2010-07-15 22:57:48 +00:00
// Prepare node for boot
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'nodeset' ,
tgt : node ,
args : 'install' ,
msg : 'cmd=nodeset;out=' + out2Id
} ,
2010-07-29 20:22:09 +00:00
success : updateZProvisionNewStatus
2010-07-15 22:57:48 +00:00
} ) ;
}
/ * *
2010-07-19 18:28:31 +00:00
* ( 9 ) Boot node to network
2010-07-15 22:57:48 +00:00
* /
else if ( cmd == 'nodeset' ) {
2010-07-27 22:56:42 +00:00
// Write ajax response to status bar
var prg = writeRsp ( rsp , '' ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( prg ) ;
2010-07-27 22:56:42 +00:00
// If there was an error
// Do not continue
if ( prg . html ( ) . indexOf ( 'Error' ) > - 1 ) {
2010-07-29 17:32:24 +00:00
$ ( '#' + loaderId ) . hide ( ) ;
2010-07-15 22:57:48 +00:00
} else {
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'rnetboot' ,
tgt : node ,
args : 'ipl=000C' ,
msg : 'cmd=rnetboot;out=' + out2Id
} ,
2010-07-29 20:22:09 +00:00
success : updateZProvisionNewStatus
2010-07-15 22:57:48 +00:00
} ) ;
}
}
/ * *
2010-07-19 18:28:31 +00:00
* ( 10 ) Done
2010-07-15 22:57:48 +00:00
* /
else if ( cmd == 'rnetboot' ) {
2010-07-27 22:56:42 +00:00
// Write ajax response to status bar
var prg = writeRsp ( rsp , '' ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( prg ) ;
2010-07-29 17:32:24 +00:00
if ( prg . html ( ) . indexOf ( 'Error' ) < 0 ) {
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( '<pre>Open a VNC viewer to see the installation progress. It might take a couple of minutes before you can connect.</pre>' ) ;
2010-07-15 22:57:48 +00:00
}
// Hide loader
2010-07-29 17:32:24 +00:00
$ ( '#' + loaderId ) . hide ( ) ;
2010-07-15 22:57:48 +00:00
}
}
2010-07-27 19:50:01 +00:00
/ * *
* Update the provision existing node status
*
* @ param data
* Data returned from HTTP request
* @ return Nothing
* /
2010-07-29 20:22:09 +00:00
function updateZProvisionExistingStatus ( data ) {
2010-07-27 19:50:01 +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 = 'zProvisionStatBar' + inst ;
var tabId = 'zvmProvisionTab' + inst ;
/ * *
* ( 2 ) Prepare node for boot
* /
2010-07-27 22:56:42 +00:00
if ( cmd == 'nodeadd' ) {
2010-07-27 19:50:01 +00:00
// Get operating system
var bootMethod = $ ( '#' + tabId + ' select[name=bootMethod]' ) . val ( ) ;
// Get nodes that were checked
2010-08-03 18:55:42 +00:00
var dTableId = 'zNodesDatatable' + inst ;
2010-07-27 19:50:01 +00:00
var tgts = getNodesChecked ( dTableId ) ;
// Prepare node for boot
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'nodeset' ,
tgt : tgts ,
args : bootMethod ,
msg : 'cmd=nodeset;out=' + inst
} ,
2010-07-29 20:22:09 +00:00
success : updateZProvisionExistingStatus
2010-07-27 19:50:01 +00:00
} ) ;
}
/ * *
* ( 3 ) Boot node from network
* /
else if ( cmd == 'nodeset' ) {
// Write ajax response to status bar
2010-07-27 22:56:42 +00:00
var prg = writeRsp ( rsp , '' ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( prg ) ;
2010-07-27 19:50:01 +00:00
2010-10-08 03:03:42 +00:00
// If there was an error, do not continue
2010-07-27 19:50:01 +00:00
if ( prg . html ( ) . indexOf ( 'Error' ) > - 1 ) {
var loaderId = 'zProvisionLoader' + inst ;
$ ( '#' + loaderId ) . remove ( ) ;
2010-07-27 22:56:42 +00:00
return ;
2010-07-27 19:50:01 +00:00
}
// Get nodes that were checked
2010-08-03 18:55:42 +00:00
var dTableId = 'zNodesDatatable' + inst ;
2010-07-27 19:50:01 +00:00
var tgts = getNodesChecked ( dTableId ) ;
// Boot node from network
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'rnetboot' ,
tgt : tgts ,
args : 'ipl=000C' ,
msg : 'cmd=rnetboot;out=' + inst
} ,
2010-07-29 20:22:09 +00:00
success : updateZProvisionExistingStatus
2010-07-27 19:50:01 +00:00
} ) ;
}
/ * *
* ( 4 ) Done
* /
else if ( cmd == 'rnetboot' ) {
// Write ajax response to status bar
2010-07-27 22:56:42 +00:00
var prg = writeRsp ( rsp , '' ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( prg ) ;
2010-07-27 19:50:01 +00:00
var loaderId = 'zProvisionLoader' + inst ;
$ ( '#' + loaderId ) . remove ( ) ;
}
}
2010-07-15 22:57:48 +00:00
/ * *
2010-07-19 18:28:31 +00:00
* Update zVM node status
2010-07-15 22:57:48 +00:00
*
* @ param data
* Data returned from HTTP request
* @ return Nothing
* /
function updateZNodeStatus ( data ) {
var node = data . msg ;
var rsp = data . rsp ;
// Get cookie for number processes performed against this node
2010-11-22 16:18:55 +00:00
var actions = $ . cookie ( node + 'processes' ) ;
2010-07-15 22:57:48 +00:00
// One less process
actions = actions - 1 ;
2010-11-22 16:18:55 +00:00
$ . cookie ( node + 'processes' , actions ) ;
2010-07-19 18:28:31 +00:00
2010-07-15 22:57:48 +00:00
if ( actions < 1 ) {
// Hide loader when there are no more processes
var statusBarLoaderId = node + 'StatusBarLoader' ;
$ ( '#' + statusBarLoaderId ) . hide ( ) ;
}
2010-07-19 18:28:31 +00:00
var statBarId = node + 'StatusBar' ;
2010-07-27 22:56:42 +00:00
// Write ajax response to status bar
var prg = writeRsp ( rsp , '[A-Za-z0-9._-]+:' ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + statBarId ) . find ( 'div' ) . append ( prg ) ;
2010-07-15 22:57:48 +00:00
}
/ * *
2010-07-29 17:32:24 +00:00
* Update clone status
2010-07-15 22:57:48 +00:00
*
* @ param data
* Data returned from HTTP request
* @ return Nothing
* /
2010-07-28 20:24:29 +00:00
function updateZCloneStatus ( data ) {
2010-07-29 17:32:24 +00:00
// Get ajax response
2010-07-15 22:57:48 +00:00
var rsp = data . rsp ;
var args = data . msg . split ( ';' ) ;
var cmd = args [ 0 ] . replace ( 'cmd=' , '' ) ;
// Get provision instance
var inst = args [ 1 ] . replace ( 'inst=' , '' ) ;
2010-07-29 17:32:24 +00:00
// Get output division ID
2010-07-15 22:57:48 +00:00
var out2Id = args [ 2 ] . replace ( 'out=' , '' ) ;
/ * *
2010-07-19 18:28:31 +00:00
* ( 2 ) Update / etc / hosts
2010-07-15 22:57:48 +00:00
* /
if ( cmd == 'nodeadd' ) {
var node = args [ 3 ] . replace ( 'node=' , '' ) ;
2010-10-08 03:03:42 +00:00
// If there was an error, do not continue
2010-07-15 22:57:48 +00:00
if ( rsp . length ) {
2010-07-29 17:32:24 +00:00
$ ( '#' + out2Id ) . find ( 'img' ) . hide ( ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + out2Id ) . find ( 'div' ) . append ( '<pre>(Error) Failed to create node definition</pre>' ) ;
2010-07-15 22:57:48 +00:00
} else {
2011-04-27 20:28:00 +00:00
$ ( '#' + out2Id ) . find ( 'div' ) . append ( '<pre>Node definition created for ' + node + '</pre>' ) ;
2010-07-29 17:32:24 +00:00
// If last node definition was created
var tmp = inst . split ( '/' ) ;
if ( tmp [ 0 ] == tmp [ 1 ] ) {
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'makehosts' ,
tgt : '' ,
args : '' ,
msg : 'cmd=makehosts;inst=' + inst + ';out=' + out2Id
} ,
2010-07-15 22:57:48 +00:00
2010-07-29 17:32:24 +00:00
success : updateZCloneStatus
} ) ;
}
}
2010-07-15 22:57:48 +00:00
}
/ * *
2010-07-19 18:28:31 +00:00
* ( 3 ) Update DNS
2010-07-15 22:57:48 +00:00
* /
else if ( cmd == 'makehosts' ) {
2010-10-08 03:03:42 +00:00
// If there was an error, do not continue
2010-07-15 22:57:48 +00:00
if ( rsp . length ) {
2010-07-29 17:32:24 +00:00
$ ( '#' + out2Id ) . find ( 'img' ) . hide ( ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + out2Id ) . find ( 'div' ) . append ( '<pre>(Error) Failed to update /etc/hosts</pre>' ) ;
2010-07-15 22:57:48 +00:00
} else {
2011-04-27 20:28:00 +00:00
$ ( '#' + out2Id ) . find ( 'div' ) . append ( '<pre>/etc/hosts updated</pre>' ) ;
2010-07-29 17:32:24 +00:00
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'makedns' ,
tgt : '' ,
args : '' ,
msg : 'cmd=makedns;inst=' + inst + ';out=' + out2Id
} ,
2010-07-15 22:57:48 +00:00
2010-07-29 17:32:24 +00:00
success : updateZCloneStatus
} ) ;
}
2010-07-15 22:57:48 +00:00
}
/ * *
2010-07-19 18:28:31 +00:00
* ( 4 ) Clone
2010-07-15 22:57:48 +00:00
* /
else if ( cmd == 'makedns' ) {
2010-07-27 22:56:42 +00:00
// Write ajax response to status bar
var prg = writeRsp ( rsp , '' ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + out2Id ) . find ( 'div' ) . append ( prg ) ;
2010-07-27 22:56:42 +00:00
2010-07-15 22:57:48 +00:00
// Get clone tab
var tabId = out2Id . replace ( 'CloneStatusBar' , 'CloneTab' ) ;
// If a node range is given
var tgtNodeRange = $ ( '#' + tabId + ' input[name=tgtNode]' ) . val ( ) ;
var tgtNodes = '' ;
if ( tgtNodeRange . indexOf ( '-' ) > - 1 ) {
var tmp = tgtNodeRange . split ( '-' ) ;
2010-07-19 18:28:31 +00:00
2010-07-15 22:57:48 +00:00
// Get node base name
var nodeBase = tmp [ 0 ] . match ( /[a-zA-Z]+/ ) ;
// Get the starting index
var nodeStart = parseInt ( tmp [ 0 ] . match ( /\d+/ ) ) ;
// Get the ending index
2010-10-08 14:52:48 +00:00
var nodeEnd = parseInt ( tmp [ 1 ] . match ( /\d+/ ) ) ;
2010-07-15 22:57:48 +00:00
for ( var i = nodeStart ; i <= nodeEnd ; i ++ ) {
// Do not append comma for last node
if ( i == nodeEnd ) {
tgtNodes += nodeBase + i . toString ( ) ;
} else {
tgtNodes += nodeBase + i . toString ( ) + ',' ;
}
}
} else {
tgtNodes = tgtNodeRange ;
}
2010-07-19 18:28:31 +00:00
2010-07-15 22:57:48 +00:00
// Get other inputs
var srcNode = $ ( '#' + tabId + ' input[name=srcNode]' ) . val ( ) ;
hcp = $ ( '#' + tabId + ' input[name=newHcp]' ) . val ( ) ;
var group = $ ( '#' + tabId + ' input[name=newGroup]' ) . val ( ) ;
var diskPool = $ ( '#' + tabId + ' input[name=diskPool]' ) . val ( ) ;
var diskPw = $ ( '#' + tabId + ' input[name=diskPw]' ) . val ( ) ;
if ( ! diskPw ) {
diskPw = '' ;
}
// Clone
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'mkvm' ,
tgt : tgtNodes ,
args : srcNode + ';pool=' + diskPool + ';pw=' + diskPw ,
msg : 'cmd=mkvm;inst=' + inst + ';out=' + out2Id
} ,
2010-07-29 17:32:24 +00:00
success : updateZCloneStatus
2010-07-15 22:57:48 +00:00
} ) ;
}
/ * *
2010-07-19 18:28:31 +00:00
* ( 5 ) Done
2010-07-15 22:57:48 +00:00
* /
else if ( cmd == 'mkvm' ) {
2010-07-27 22:56:42 +00:00
// Write ajax response to status bar
var prg = writeRsp ( rsp , '' ) ;
2011-04-27 20:28:00 +00:00
$ ( '#' + out2Id ) . find ( 'div' ) . append ( prg ) ;
2010-07-27 22:56:42 +00:00
2010-07-15 22:57:48 +00:00
// Hide loader
$ ( '#' + out2Id ) . find ( 'img' ) . hide ( ) ;
}
}
2010-07-15 23:22:13 +00:00
/ * *
2010-07-19 18:28:31 +00:00
* Get zVM resources
2010-07-15 23:22:13 +00:00
*
* @ param data
* Data from HTTP request
* @ return Nothing
* /
function getZResources ( data ) {
2010-07-19 18:28:31 +00:00
// Do not continue if there is no output
2010-07-15 23:22:13 +00:00
if ( data . rsp ) {
2012-04-02 04:08:30 +00:00
// Push hardware control points into an array
2010-07-15 23:22:13 +00:00
var node , hcp ;
var hcpHash = new Object ( ) ;
2012-04-02 04:08:30 +00:00
for ( var i in data . rsp ) {
2010-07-15 23:22:13 +00:00
node = data . rsp [ i ] [ 0 ] ;
hcp = data . rsp [ i ] [ 1 ] ;
hcpHash [ hcp ] = 1 ;
}
// Create an array for hardware control points
var hcps = new Array ( ) ;
2012-04-02 04:08:30 +00:00
for ( var key in hcpHash ) {
2010-07-15 23:22:13 +00:00
// Get the short host name
hcp = key . split ( '.' ) [ 0 ] ;
2012-04-02 04:08:30 +00:00
hcps . push ( hcp ) ;
2010-07-15 23:22:13 +00:00
}
2012-04-02 04:08:30 +00:00
// Set hardware control point cookie
2010-11-22 16:18:55 +00:00
$ . cookie ( 'hcp' , hcps ) ;
2012-04-02 04:08:30 +00:00
// Delete loader
var tabId = 'zvmResourceTab' ;
$ ( '#' + tabId ) . find ( 'img[src="images/loader.gif"]' ) . remove ( ) ;
// Create accordion panel for disk
var resourcesAccordion = $ ( '<div id="zvmResourceAccordion"></div>' ) ;
var diskSection = $ ( '<div id="zvmDiskResource"></div>' ) ;
var diskLnk = $ ( '<h3><a href="#">Disks</a></h3>' ) . click ( function ( ) {
// Do not load panel again if it is already loaded
if ( $ ( '#zvmDiskResource' ) . children ( ) . length )
return ;
else
$ ( '#zvmDiskResource' ) . append ( createLoader ( '' ) ) ;
// Resize accordion
$ ( '#zvmResourceAccordion' ) . accordion ( 'resize' ) ;
// Create a array for hardware control points
var hcps = new Array ( ) ;
if ( $ . cookie ( 'hcp' ) . indexOf ( ',' ) > - 1 )
hcps = $ . cookie ( 'hcp' ) . split ( ',' ) ;
else
hcps . push ( $ . cookie ( 'hcp' ) ) ;
// Query the disk pools for each
for ( var i in hcps ) {
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'lsvm' ,
tgt : hcps [ i ] ,
args : '--diskpoolnames' ,
msg : hcps [ i ]
} ,
success : getDiskPool
} ) ;
}
} ) ;
// Create accordion panel for network
var networkSection = $ ( '<div id="zvmNetworkResource"></div>' ) ;
var networkLnk = $ ( '<h3><a href="#">Networks</a></h3>' ) . click ( function ( ) {
// Do not load panel again if it is already loaded
if ( $ ( '#zvmNetworkResource' ) . children ( ) . length )
return ;
else
$ ( '#zvmNetworkResource' ) . append ( createLoader ( '' ) ) ;
// Resize accordion
$ ( '#zvmResourceAccordion' ) . accordion ( 'resize' ) ;
// Create a array for hardware control points
var hcps = new Array ( ) ;
if ( $ . cookie ( 'hcp' ) . indexOf ( ',' ) > - 1 )
hcps = $ . cookie ( 'hcp' ) . split ( ',' ) ;
else
hcps . push ( $ . cookie ( 'hcp' ) ) ;
for ( var i in hcps ) {
// Gather networks from hardware control points
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'lsvm' ,
tgt : hcps [ i ] ,
args : '--getnetworknames' ,
msg : hcps [ i ]
} ,
success : getNetwork
} ) ;
}
} ) ;
resourcesAccordion . append ( diskLnk , diskSection , networkLnk , networkSection ) ;
// Append accordion to tab
$ ( '#' + tabId ) . append ( resourcesAccordion ) ;
resourcesAccordion . accordion ( ) ;
diskLnk . trigger ( 'click' ) ;
2010-07-15 23:22:13 +00:00
}
}
2010-07-15 22:57:48 +00:00
/ * *
* Get node attributes from HTTP request data
*
* @ param propNames
* Hash table of property names
* @ param keys
* Property keys
* @ param data
* Data from HTTP request
* @ return Hash table of property values
* /
2010-08-03 20:44:26 +00:00
function getAttrs ( keys , propNames , data ) {
2010-07-15 22:57:48 +00:00
// Create hash table for property values
var attrs = new Object ( ) ;
// Go through inventory and separate each property out
var curKey ; // Current property key
var addLine ; // Add a line to the current property?
for ( var i = 1 ; i < data . length ; i ++ ) {
addLine = true ;
// Loop through property keys
// Does this line contains one of the properties?
for ( var j = 0 ; j < keys . length ; j ++ ) {
// Find property name
if ( data [ i ] . indexOf ( propNames [ keys [ j ] ] ) > - 1 ) {
attrs [ keys [ j ] ] = new Array ( ) ;
// Get rid of property name in the line
data [ i ] = data [ i ] . replace ( propNames [ keys [ j ] ] , '' ) ;
// Trim the line
data [ i ] = jQuery . trim ( data [ i ] ) ;
// Do not insert empty line
if ( data [ i ] . length > 0 ) {
attrs [ keys [ j ] ] . push ( data [ i ] ) ;
}
curKey = keys [ j ] ;
addLine = false ; // This line belongs to a property
}
}
// Line does not contain a property
// Must belong to previous property
if ( addLine && data [ i ] . length > 1 ) {
data [ i ] = jQuery . trim ( data [ i ] ) ;
attrs [ curKey ] . push ( data [ i ] ) ;
}
}
return attrs ;
}
/ * *
2010-09-23 20:43:10 +00:00
* Create add processor dialog
2010-07-15 22:57:48 +00:00
*
2010-09-23 20:43:10 +00:00
* @ param node
* Node to add processor to
2010-07-15 22:57:48 +00:00
* @ return Nothing
* /
2010-09-24 02:27:04 +00:00
function openAddProcDialog ( node ) {
// Create form to add processor
var addProcForm = $ ( '<div class="form"></div>' ) ;
2010-09-23 20:43:10 +00:00
// Create info bar
2010-12-04 15:22:16 +00:00
var info = createInfoBar ( 'Add a temporary processor to this virtual server.' ) ;
2010-09-23 20:43:10 +00:00
addProcForm . append ( info ) ;
2010-12-04 15:22:16 +00:00
addProcForm . append ( '<div><label for="procNode">Node:</label><input type="text" readonly="readonly" id="procNode" name="procNode" value="' + node + '"/></div>' ) ;
2010-09-23 20:43:10 +00:00
addProcForm . append ( '<div><label for="procAddress">Processor address:</label><input type="text" id="procAddress" name="procAddress"/></div>' ) ;
// Create drop down for processor type
var procType = $ ( '<div></div>' ) ;
procType . append ( '<label for="procType">Processor type:</label>' ) ;
var typeSelect = $ ( '<select id="procType" name="procType"></select>' ) ;
2010-09-24 02:27:04 +00:00
typeSelect . append ( '<option>CP</option>'
+ '<option>IFL</option>'
+ '<option>ZAAP</option>'
+ '<option>ZIIP</option>'
) ;
2010-09-23 20:43:10 +00:00
procType . append ( typeSelect ) ;
addProcForm . append ( procType ) ;
2010-09-24 02:27:04 +00:00
// Open dialog to add processor
2010-09-23 20:43:10 +00:00
addProcForm . dialog ( {
2011-12-01 04:10:40 +00:00
title : 'Add processor' ,
2010-09-23 20:43:10 +00:00
modal : true ,
width : 400 ,
buttons : {
2010-10-07 21:01:14 +00:00
"Ok" : function ( ) {
2010-09-23 20:43:10 +00:00
// Remove any warning messages
$ ( this ) . find ( '.ui-state-error' ) . remove ( ) ;
2010-09-24 02:27:04 +00:00
// Get inputs
2010-09-23 20:43:10 +00:00
var node = $ ( this ) . find ( 'input[name=procNode]' ) . val ( ) ;
var address = $ ( this ) . find ( 'input[name=procAddress]' ) . val ( ) ;
var type = $ ( this ) . find ( 'select[name=procType]' ) . val ( ) ;
2010-09-24 02:27:04 +00:00
// If inputs are not complete, show warning message
2010-09-23 20:43:10 +00:00
if ( ! node || ! address || ! type ) {
2011-12-19 05:03:27 +00:00
var warn = createWarnBar ( 'Please provide a value for each missing field.' ) ;
2010-09-23 20:43:10 +00:00
warn . prependTo ( $ ( this ) ) ;
} else {
// Add processor
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : node ,
args : '--addprocessoractive;' + address + ';' + type ,
msg : node
} ,
success : updateZNodeStatus
} ) ;
// Increment node process
incrementNodeProcess ( node ) ;
// Show loader
var statusId = node + 'StatusBar' ;
var statusBarLoaderId = node + 'StatusBarLoader' ;
$ ( '#' + statusBarLoaderId ) . show ( ) ;
$ ( '#' + statusId ) . show ( ) ;
// Close dialog
$ ( this ) . dialog ( "close" ) ;
}
2010-10-07 21:01:14 +00:00
} ,
"Cancel" : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
2010-09-23 20:43:10 +00:00
}
} ) ;
2010-07-15 22:57:48 +00:00
}
/ * *
2010-09-23 20:43:10 +00:00
* Create add disk dialog
2010-07-15 22:57:48 +00:00
*
2010-09-23 20:43:10 +00:00
* @ param node
* Node to add disk to
* @ param hcp
* Hardware control point of node
2010-07-15 22:57:48 +00:00
* @ return Nothing
* /
2010-09-24 02:27:04 +00:00
function openAddDiskDialog ( node , hcp ) {
2010-09-23 20:43:10 +00:00
// Get list of disk pools
2010-11-22 16:18:55 +00:00
var cookie = $ . cookie ( hcp + 'diskpools' ) ;
2010-09-23 20:43:10 +00:00
var pools = cookie . split ( ',' ) ;
2010-09-24 02:27:04 +00:00
// Create form to add disk
var addDiskForm = $ ( '<div class="form"></div>' ) ;
2010-09-23 20:43:10 +00:00
// Create info bar
2010-12-04 15:22:16 +00:00
var info = createInfoBar ( 'Add a ECKD|3390 or FBA|9336 disk to this virtual server.' ) ;
2010-09-23 20:43:10 +00:00
addDiskForm . append ( info ) ;
2010-12-04 15:22:16 +00:00
addDiskForm . append ( '<div><label for="diskNode">Node:</label><input type="text" readonly="readonly" id="diskNode" name="diskNode" value="' + node + '"/></div>' ) ;
2010-09-23 20:43:10 +00:00
addDiskForm . append ( '<div><label for="diskType">Disk type:</label><select id="diskType" name="diskType"><option value="3390">3390</option><option value="9336">9336</option></select></div>' ) ;
addDiskForm . append ( '<div><label for="diskAddress">Disk address:</label><input type="text" id="diskAddress" name="diskAddress"/></div>' ) ;
addDiskForm . append ( '<div><label for="diskSize">Disk size:</label><input type="text" id="diskSize" name="diskSize"/></div>' ) ;
// Create drop down for disk pool
var diskPool = $ ( '<div></div>' ) ;
diskPool . append ( '<label for="diskPool">Disk pool:</label>' ) ;
var poolSelect = $ ( '<select id="diskPool" name="diskPool"></select>' ) ;
for ( var i = 0 ; i < pools . length ; i ++ ) {
poolSelect . append ( '<option>' + pools [ i ] + '</option>' ) ;
2010-07-15 22:57:48 +00:00
}
2010-09-23 20:43:10 +00:00
diskPool . append ( poolSelect ) ;
addDiskForm . append ( diskPool ) ;
// Create drop down for disk mode
var diskMode = $ ( '<div></div>' ) ;
diskMode . append ( '<label for="diskMode">Disk mode:</label>' ) ;
var modeSelect = $ ( '<select id="diskMode" name="diskMode"></select>' ) ;
2010-09-24 02:27:04 +00:00
modeSelect . append ( '<option>R</option>'
+ '<option>RR</option>'
+ '<option>W</option>'
+ '<option>WR</option>'
+ '<option>M</option>'
+ '<option>MR</option>'
+ '<option>MW</option>'
) ;
2010-09-23 20:43:10 +00:00
diskMode . append ( modeSelect ) ;
addDiskForm . append ( diskMode ) ;
addDiskForm . append ( '<div><label for="diskPassword">Disk password:</label><input type="password" id="diskPassword" name="diskPassword"/></div>' ) ;
2010-09-24 02:27:04 +00:00
// Open dialog to add disk
2010-09-23 20:43:10 +00:00
addDiskForm . dialog ( {
2011-12-01 04:10:40 +00:00
title : 'Add disk' ,
2010-09-23 20:43:10 +00:00
modal : true ,
width : 400 ,
buttons : {
2010-10-07 21:01:14 +00:00
"Ok" : function ( ) {
2010-09-23 20:43:10 +00:00
// Remove any warning messages
$ ( this ) . find ( '.ui-state-error' ) . remove ( ) ;
2010-09-24 02:27:04 +00:00
// Get inputs
2010-09-23 20:43:10 +00:00
var node = $ ( this ) . find ( 'input[name=diskNode]' ) . val ( ) ;
var type = $ ( this ) . find ( 'select[name=diskType]' ) . val ( ) ;
var address = $ ( this ) . find ( 'input[name=diskAddress]' ) . val ( ) ;
var size = $ ( this ) . find ( 'input[name=diskSize]' ) . val ( ) ;
var pool = $ ( this ) . find ( 'select[name=diskPool]' ) . val ( ) ;
var mode = $ ( this ) . find ( 'select[name=diskMode]' ) . val ( ) ;
var password = $ ( this ) . find ( 'input[name=diskPassword]' ) . val ( ) ;
2010-09-24 02:27:04 +00:00
// If inputs are not complete, show warning message
2010-09-23 20:43:10 +00:00
if ( ! node || ! type || ! address || ! size || ! pool || ! mode ) {
2011-12-19 05:03:27 +00:00
var warn = createWarnBar ( 'Please provide a value for each missing field.' ) ;
2010-09-23 20:43:10 +00:00
warn . prependTo ( $ ( this ) ) ;
} else {
// Add disk
if ( type == '3390' ) {
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : node ,
args : '--add3390;' + pool + ';' + address + ';' + size
+ ';' + mode + ';' + password + ';' + password + ';' + password ,
msg : node
} ,
success : updateZNodeStatus
} ) ;
// Increment node process
incrementNodeProcess ( node ) ;
// Show loader
var statusId = node + 'StatusBar' ;
var statusBarLoaderId = node + 'StatusBarLoader' ;
$ ( '#' + statusBarLoaderId ) . show ( ) ;
$ ( '#' + statusId ) . show ( ) ;
} else if ( type == '9336' ) {
// Default block size for FBA volumes = 512
var blkSize = '512' ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : node ,
args : '--add9336;' + pool + ';' + address + ';' + blkSize + ';' + size
+ ';' + mode + ';' + password + ';' + password + ';' + password ,
msg : node
} ,
success : updateZNodeStatus
} ) ;
// Increment node process
incrementNodeProcess ( node ) ;
// Show loader
var statusId = node + 'StatusBar' ;
var statusBarLoaderId = node + 'StatusBarLoader' ;
$ ( '#' + statusBarLoaderId ) . show ( ) ;
$ ( '#' + statusId ) . show ( ) ;
}
// Close dialog
$ ( this ) . dialog ( "close" ) ;
} // End of else
2010-10-07 21:01:14 +00:00
} ,
"Cancel" : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
2010-09-23 20:43:10 +00:00
}
} ) ;
2010-07-15 22:57:48 +00:00
}
/ * *
2010-09-23 20:43:10 +00:00
* Create add NIC dialog
2010-07-15 22:57:48 +00:00
*
2010-09-23 20:43:10 +00:00
* @ param node
* Node to add NIC to
* @ param hcp
* Hardware control point of node
2010-07-15 22:57:48 +00:00
* @ return Nothing
* /
2010-09-24 02:27:04 +00:00
function openAddNicDialog ( node , hcp ) {
2010-09-23 20:43:10 +00:00
// Get network names
2010-11-22 16:18:55 +00:00
var networks = $ . cookie ( hcp + 'networks' ) . split ( ',' ) ;
2010-09-10 16:07:48 +00:00
2010-09-24 02:27:04 +00:00
// Create form to add NIC
2010-09-23 20:43:10 +00:00
var addNicForm = $ ( '<div class="form"></div>' ) ;
2010-09-24 02:27:04 +00:00
// Create info bar
2010-12-04 15:22:16 +00:00
var info = createInfoBar ( 'Add a NIC to this virtual server.' ) ;
2010-09-23 20:43:10 +00:00
addNicForm . append ( info ) ;
2010-12-04 15:22:16 +00:00
addNicForm . append ( '<div><label for="nicNode">Node:</label><input type="text" readonly="readonly" id="nicNode" name="nicNode" value="' + node + '"/></div>' ) ;
2010-09-23 20:43:10 +00:00
addNicForm . append ( '<div><label for="nicAddress">NIC address:</label><input type="text" id="nicAddress" name="nicAddress"/></div>' ) ;
// Create drop down for NIC types
var nicType = $ ( '<div></div>' ) ;
nicType . append ( '<label for="nicType">NIC type:</label>' ) ;
var nicTypeSelect = $ ( '<select id="nicType" name="nicType"></select>' ) ;
2010-09-24 02:27:04 +00:00
nicTypeSelect . append ( '<option></option>'
+ '<option>QDIO</option>'
+ '<option>HiperSockets</option>'
) ;
2010-09-23 20:43:10 +00:00
nicType . append ( nicTypeSelect ) ;
addNicForm . append ( nicType ) ;
// Create drop down for network types
var networkType = $ ( '<div></div>' ) ;
networkType . append ( '<label for="nicNetworkType">Network type:</label>' ) ;
var networkTypeSelect = $ ( '<select id="nicNetworkType" name="nicNetworkType"></select>' ) ;
2010-09-24 02:27:04 +00:00
networkTypeSelect . append ( '<option></option>'
+ '<option>Guest LAN</option>'
+ '<option>Virtual Switch</option>'
) ;
2010-09-23 20:43:10 +00:00
networkType . append ( networkTypeSelect ) ;
addNicForm . append ( networkType ) ;
2010-09-10 16:07:48 +00:00
2010-09-23 20:43:10 +00:00
// Create drop down for network names
var gLansQdioSelect = $ ( '<select id="nicLanQdioName" name="nicLanQdioName"></select>' ) ;
var gLansHipersSelect = $ ( '<select id="nicLanHipersName" name="nicLanHipersName"></select>' ) ;
var vswitchSelect = $ ( '<select id="nicVSwitchName" name="nicVSwitchName"></select>' ) ;
for ( var i = 0 ; i < networks . length ; i ++ ) {
var network = networks [ i ] . split ( ' ' ) ;
var networkOption = $ ( '<option>' + network [ 1 ] + ' ' + network [ 2 ] + '</option>' ) ;
if ( network [ 0 ] == 'VSWITCH' ) {
vswitchSelect . append ( networkOption ) ;
} else if ( network [ 0 ] == 'LAN:QDIO' ) {
gLansQdioSelect . append ( networkOption ) ;
} else if ( network [ 0 ] == 'LAN:HIPERS' ) {
gLansHipersSelect . append ( networkOption ) ;
2010-07-15 22:57:48 +00:00
}
2010-09-23 20:43:10 +00:00
}
2010-09-24 02:27:04 +00:00
// Hide network name drop downs until the NIC type and network type is selected
// QDIO Guest LAN drop down
2010-09-23 20:43:10 +00:00
var guestLanQdio = $ ( '<div></div>' ) . hide ( ) ;
guestLanQdio . append ( '<label for="nicLanQdioName">Guest LAN name:</label>' ) ;
guestLanQdio . append ( gLansQdioSelect ) ;
addNicForm . append ( guestLanQdio ) ;
2010-09-24 02:27:04 +00:00
// HIPERS Guest LAN drop down
2010-09-23 20:43:10 +00:00
var guestLanHipers = $ ( '<div></div>' ) . hide ( ) ;
guestLanHipers . append ( '<label for="nicLanHipersName">Guest LAN name:</label>' ) ;
guestLanHipers . append ( gLansHipersSelect ) ;
addNicForm . append ( guestLanHipers ) ;
2010-09-24 02:27:04 +00:00
// VSWITCH drop down
2010-09-23 20:43:10 +00:00
var vswitch = $ ( '<div></div>' ) . hide ( ) ;
vswitch . append ( '<label for="nicVSwitchName">VSWITCH name:</label>' ) ;
vswitch . append ( vswitchSelect ) ;
addNicForm . append ( vswitch ) ;
// Show network names on change
networkTypeSelect . change ( function ( ) {
// Remove any warning messages
$ ( this ) . parent ( ) . parent ( ) . find ( '.ui-state-error' ) . remove ( ) ;
2010-09-24 02:27:04 +00:00
// Get NIC type and network type
2010-09-24 12:27:54 +00:00
var nicType = $ ( this ) . parent ( ) . parent ( ) . find ( 'select[name=nicType]' ) . val ( ) ;
2010-09-23 20:43:10 +00:00
var networkType = $ ( this ) . val ( ) ;
2010-09-24 02:27:04 +00:00
// Hide network name drop downs
2010-09-24 12:27:54 +00:00
var guestLanQdio = $ ( this ) . parent ( ) . parent ( ) . find ( 'select[name=nicLanQdioName]' ) . parent ( ) ;
var guestLanHipers = $ ( this ) . parent ( ) . parent ( ) . find ( 'select[name=nicLanHipersName]' ) . parent ( ) ;
var vswitch = $ ( this ) . parent ( ) . parent ( ) . find ( 'select[name=nicVSwitchName]' ) . parent ( ) ;
2010-09-23 20:43:10 +00:00
guestLanQdio . hide ( ) ;
guestLanHipers . hide ( ) ;
vswitch . hide ( ) ;
2010-09-24 02:27:04 +00:00
// Show correct network name
if ( networkType == 'Guest LAN' && nicType == 'QDIO' ) {
2010-09-23 20:43:10 +00:00
guestLanQdio . show ( ) ;
2010-09-24 02:27:04 +00:00
} else if ( networkType == 'Guest LAN' && nicType == 'HiperSockets' ) {
2010-09-23 20:43:10 +00:00
guestLanHipers . show ( ) ;
2010-09-24 02:27:04 +00:00
} else if ( networkType == 'Virtual Switch' ) {
if ( nicType == 'QDIO' ) {
vswitch . show ( ) ;
} else {
// No such thing as HIPERS VSWITCH
var warn = createWarnBar ( 'The selected choices are not valid.' ) ;
warn . prependTo ( $ ( this ) . parent ( ) . parent ( ) ) ;
}
2010-07-15 22:57:48 +00:00
}
2010-09-23 20:43:10 +00:00
} ) ;
2010-09-24 02:27:04 +00:00
// Show network names on change
2010-09-23 20:43:10 +00:00
nicTypeSelect . change ( function ( ) {
// Remove any warning messages
$ ( this ) . parent ( ) . parent ( ) . find ( '.ui-state-error' ) . remove ( ) ;
2010-09-24 02:27:04 +00:00
// Get NIC type and network type
2010-09-23 20:43:10 +00:00
var nicType = $ ( this ) . val ( ) ;
2010-09-24 12:27:54 +00:00
var networkType = $ ( this ) . parent ( ) . parent ( ) . find ( 'select[name=nicNetworkType]' ) . val ( ) ;
2010-07-15 22:57:48 +00:00
2010-09-24 02:27:04 +00:00
// Hide network name drop downs
2010-09-24 12:27:54 +00:00
var guestLanQdio = $ ( this ) . parent ( ) . parent ( ) . find ( 'select[name=nicLanQdioName]' ) . parent ( ) ;
var guestLanHipers = $ ( this ) . parent ( ) . parent ( ) . find ( 'select[name=nicLanHipersName]' ) . parent ( ) ;
var vswitch = $ ( this ) . parent ( ) . parent ( ) . find ( 'select[name=nicVSwitchName]' ) . parent ( ) ;
2010-09-23 20:43:10 +00:00
guestLanQdio . hide ( ) ;
guestLanHipers . hide ( ) ;
vswitch . hide ( ) ;
2010-09-24 02:27:04 +00:00
// Show correct network name
if ( networkType == 'Guest LAN' && nicType == 'QDIO' ) {
2010-09-23 20:43:10 +00:00
guestLanQdio . show ( ) ;
2010-09-24 02:27:04 +00:00
} else if ( networkType == 'Guest LAN' && nicType == 'HiperSockets' ) {
2010-09-23 20:43:10 +00:00
guestLanHipers . show ( ) ;
2010-09-24 02:27:04 +00:00
} else if ( networkType == 'Virtual Switch' ) {
if ( nicType == 'QDIO' ) {
vswitch . show ( ) ;
} else {
// No such thing as HIPERS VSWITCH
var warn = createWarnBar ( 'The selected choices are not valid.' ) ;
warn . prependTo ( $ ( this ) . parent ( ) . parent ( ) ) ;
}
2010-09-23 20:43:10 +00:00
}
} ) ;
2010-09-24 02:27:04 +00:00
// Open dialog to add NIC
2010-09-23 20:43:10 +00:00
addNicForm . dialog ( {
2011-12-01 04:10:40 +00:00
title : 'Add NIC' ,
2010-09-23 20:43:10 +00:00
modal : true ,
width : 400 ,
buttons : {
2010-10-07 21:01:14 +00:00
"Ok" : function ( ) {
2010-09-23 20:43:10 +00:00
// Remove any warning messages
$ ( this ) . find ( '.ui-state-error' ) . remove ( ) ;
2010-09-24 02:27:04 +00:00
var ready = true ;
var errMsg = '' ;
// Get inputs
2010-09-23 20:43:10 +00:00
var node = $ ( this ) . find ( 'input[name=nicNode]' ) . val ( ) ;
var nicType = $ ( this ) . find ( 'select[name=nicType]' ) . val ( ) ;
var networkType = $ ( this ) . find ( 'select[name=nicNetworkType]' ) . val ( ) ;
var address = $ ( this ) . find ( 'input[name=nicAddress]' ) . val ( ) ;
2010-09-24 02:27:04 +00:00
// If inputs are not complete, show warning message
2010-09-23 20:43:10 +00:00
if ( ! node || ! nicType || ! networkType || ! address ) {
2011-12-19 05:03:27 +00:00
errMsg = 'Please provide a value for each missing field.<br>' ;
2010-09-24 02:27:04 +00:00
ready = false ;
}
// If a HIPERS VSWITCH is selected, show warning message
if ( nicType == 'HiperSockets' && networkType == 'Virtual Switch' ) {
errMsg += 'The selected choices are not valid.' ;
ready = false ;
}
// If there are errors
if ( ! ready ) {
// Show warning message
var warn = createWarnBar ( errMsg ) ;
warn . prependTo ( $ ( this ) ) ;
2010-09-23 20:43:10 +00:00
} else {
2010-09-24 02:27:04 +00:00
// Add guest LAN
2010-09-23 20:43:10 +00:00
if ( networkType == 'Guest LAN' ) {
var temp ;
if ( nicType == 'QDIO' ) {
temp = $ ( this ) . find ( 'select[name=nicLanQdioName]' ) . val ( ) . split ( ' ' ) ;
} else {
temp = $ ( this ) . find ( 'select[name=nicLanHipersName]' ) . val ( ) . split ( ' ' ) ;
}
var lanOwner = temp [ 0 ] ;
var lanName = temp [ 1 ] ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : node ,
args : '--addnic;' + address + ';' + nicType + ';3' ,
msg : 'node=' + node + ';addr=' + address + ';lan='
+ lanName + ';owner=' + lanOwner
} ,
success : connect2GuestLan
} ) ;
}
2010-09-24 02:27:04 +00:00
// Add virtual switch
2010-09-23 20:43:10 +00:00
else if ( networkType == 'Virtual Switch' && nicType == 'QDIO' ) {
var temp = $ ( this ) . find ( 'select[name=nicVSwitchName]' ) . val ( ) . split ( ' ' ) ;
var vswitchName = temp [ 1 ] ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : node ,
args : '--addnic;' + address + ';' + nicType + ';3' ,
msg : 'node=' + node + ';addr=' + address + ';vsw='
+ vswitchName
} ,
success : connect2VSwitch
} ) ;
}
// Increment node process
incrementNodeProcess ( node ) ;
// Show loader
2011-01-19 15:56:43 +00:00
$ ( '#' + node + 'StatusBarLoader' ) . show ( ) ;
$ ( '#' + node + 'StatusBar' ) . show ( ) ;
2010-09-23 20:43:10 +00:00
// Close dialog
$ ( this ) . dialog ( "close" ) ;
} // End of else
2010-10-07 21:01:14 +00:00
} ,
"Cancel" : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
2010-09-23 20:43:10 +00:00
}
} ) ;
2010-07-15 22:57:48 +00:00
}
/ * *
* Remove processor
*
* @ param node
* Node where processor is attached
* @ param address
* Virtual address of processor
* @ return Nothing
* /
function removeProcessor ( node , address ) {
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : node ,
args : '--removeprocessor;' + address ,
msg : node
} ,
success : updateZNodeStatus
} ) ;
2010-07-29 17:32:24 +00:00
// Increment node process
2010-07-19 18:28:31 +00:00
incrementNodeProcess ( node ) ;
2010-07-15 22:57:48 +00:00
// Show loader
2011-01-19 15:56:43 +00:00
$ ( '#' + node + 'StatusBarLoader' ) . show ( ) ;
$ ( '#' + node + 'StatusBar' ) . show ( ) ;
2010-07-15 22:57:48 +00:00
}
/ * *
* Remove disk
*
* @ param node
* Node where disk is attached
* @ param address
* Virtual address of disk
* @ return Nothing
* /
function removeDisk ( node , address ) {
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : node ,
args : '--removedisk;' + address ,
msg : node
} ,
success : updateZNodeStatus
} ) ;
2010-07-29 17:32:24 +00:00
// Increment node process
2010-07-19 18:28:31 +00:00
incrementNodeProcess ( node ) ;
2010-07-15 22:57:48 +00:00
// Show loader
2011-01-19 15:56:43 +00:00
$ ( '#' + node + 'StatusBarLoader' ) . show ( ) ;
$ ( '#' + node + 'StatusBar' ) . show ( ) ;
2010-07-15 22:57:48 +00:00
}
/ * *
* Remove NIC
*
* @ param node
* Node where NIC is attached
* @ param address
* Virtual address of NIC
* @ return Nothing
* /
function removeNic ( node , nic ) {
var args = nic . split ( '.' ) ;
var address = args [ 0 ] ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : node ,
args : '--removenic;' + address ,
msg : node
} ,
success : updateZNodeStatus
} ) ;
2010-07-29 17:32:24 +00:00
// Increment node process
2010-07-19 18:28:31 +00:00
incrementNodeProcess ( node ) ;
2010-07-15 22:57:48 +00:00
// Show loader
2011-01-19 15:56:43 +00:00
$ ( '#' + node + 'StatusBarLoader' ) . show ( ) ;
$ ( '#' + node + 'StatusBar' ) . show ( ) ;
2010-07-15 22:57:48 +00:00
}
/ * *
* Set a cookie for the network names of a given node
*
* @ param data
* Data from HTTP request
* @ return Nothing
* /
function setNetworkCookies ( data ) {
if ( data . rsp ) {
var node = data . msg ;
var networks = data . rsp [ 0 ] . split ( node + ': ' ) ;
2010-12-09 03:44:11 +00:00
2010-12-09 19:27:05 +00:00
// Set cookie to expire in 60 minutes
2010-12-09 03:44:11 +00:00
var exDate = new Date ( ) ;
2010-12-09 19:27:05 +00:00
exDate . setTime ( exDate . getTime ( ) + ( 60 * 60 * 1000 ) ) ;
2010-12-09 03:44:11 +00:00
$ . cookie ( node + 'networks' , networks , { expires : exDate } ) ;
2010-07-15 22:57:48 +00:00
}
}
/ * *
2010-07-29 17:32:24 +00:00
* Get contents of each disk pool
2010-07-15 22:57:48 +00:00
*
* @ param data
* HTTP request data
* @ return Nothing
* /
function getDiskPool ( data ) {
if ( data . rsp ) {
var hcp = data . msg ;
var pools = data . rsp [ 0 ] . split ( hcp + ': ' ) ;
2010-07-29 17:32:24 +00:00
// Get contents of each disk pool
2010-07-15 22:57:48 +00:00
for ( var i in pools ) {
if ( pools [ i ] ) {
2010-07-29 20:22:09 +00:00
pools [ i ] = jQuery . trim ( pools [ i ] ) ;
2010-07-15 22:57:48 +00:00
// Get used space
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'lsvm' ,
tgt : hcp ,
args : '--diskpool;' + pools [ i ] + ';used' ,
msg : 'hcp=' + hcp + ';pool=' + pools [ i ] + ';stat=used'
} ,
success : loadDiskPoolTable
} ) ;
// Get free space
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'lsvm' ,
tgt : hcp ,
args : '--diskpool;' + pools [ i ] + ';free' ,
msg : 'hcp=' + hcp + ';pool=' + pools [ i ] + ';stat=free'
} ,
success : loadDiskPoolTable
} ) ;
2010-09-24 02:27:04 +00:00
} // End of if
} // End of for
2010-07-15 22:57:48 +00:00
}
}
/ * *
2010-07-29 17:32:24 +00:00
* Get details of each network
2010-07-15 22:57:48 +00:00
*
* @ param data
* HTTP request data
* @ return Nothing
* /
function getNetwork ( data ) {
if ( data . rsp ) {
var hcp = data . msg ;
var networks = data . rsp [ 0 ] . split ( hcp + ': ' ) ;
2010-07-29 17:32:24 +00:00
// Loop through each network
2010-07-15 22:57:48 +00:00
for ( var i = 1 ; i < networks . length ; i ++ ) {
var args = networks [ i ] . split ( ' ' ) ;
var type = args [ 0 ] ;
2010-09-10 16:35:53 +00:00
var name = args [ 2 ] ;
2010-07-15 22:57:48 +00:00
// Get network details
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'lsvm' ,
tgt : hcp ,
args : '--getnetwork;' + name ,
msg : 'hcp=' + hcp + ';type=' + type + ';network=' + name
} ,
success : loadNetworkTable
} ) ;
2010-09-24 02:27:04 +00:00
} // End of for
} // End of if
2010-07-15 22:57:48 +00:00
}
/ * *
2010-07-29 17:32:24 +00:00
* Load disk pool contents into a table
2010-07-15 22:57:48 +00:00
*
* @ param data
* HTTP request data
* @ return Nothing
* /
function loadDiskPoolTable ( data ) {
2012-04-02 04:08:30 +00:00
// Remove loader
var panelId = 'zvmDiskResource' ;
$ ( '#' + panelId ) . find ( 'img[src="images/loader.gif"]' ) . remove ( ) ;
2010-07-15 22:57:48 +00:00
var args = data . msg . split ( ';' ) ;
var hcp = args [ 0 ] . replace ( 'hcp=' , '' ) ;
var pool = args [ 1 ] . replace ( 'pool=' , '' ) ;
var stat = args [ 2 ] . replace ( 'stat=' , '' ) ;
var tmp = data . rsp [ 0 ] . split ( hcp + ': ' ) ;
2012-04-02 04:08:30 +00:00
// Resource tab ID
var info = $ ( '#' + panelId ) . find ( '.ui-state-highlight' ) ;
2010-12-04 16:04:06 +00:00
// If there is no info bar
if ( ! info . length ) {
// Create info bar
2012-04-02 04:08:30 +00:00
info = createInfoBar ( 'Below are disks that are defined in the EXTENT CONTROL file.' ) ;
$ ( '#' + panelId ) . append ( info ) ;
2010-12-04 16:04:06 +00:00
}
2010-07-15 22:57:48 +00:00
2010-07-29 17:32:24 +00:00
// Get datatable
2012-04-02 04:08:30 +00:00
var tableId = 'zDiskDataTable' ;
2010-07-15 22:57:48 +00:00
var dTable = getDiskDataTable ( ) ;
if ( ! dTable ) {
2012-04-02 04:08:30 +00:00
// Create a datatable
var table = new DataTable ( tableId ) ;
2010-07-15 22:57:48 +00:00
// Resource headers: volume ID, device type, start address, and size
2012-04-02 04:08:30 +00:00
table . init ( [ '<input type="checkbox" onclick="selectAllDisk(event, $(this))">' , 'HCP' , 'Pool' , 'Status' , 'Region' , 'Device type' , 'Starting address' , 'Size' ] ) ;
2010-07-15 22:57:48 +00:00
2012-04-02 04:08:30 +00:00
// Append datatable to panel
$ ( '#' + panelId ) . append ( table . object ( ) ) ;
2010-07-15 22:57:48 +00:00
// Turn into datatable
2012-04-02 04:08:30 +00:00
dTable = $ ( '#' + tableId ) . dataTable ( ) ;
2010-07-15 22:57:48 +00:00
setDiskDataTable ( dTable ) ;
}
// Skip index 0 and 1 because it contains nothing
for ( var i = 2 ; i < tmp . length ; i ++ ) {
2010-07-29 20:22:09 +00:00
tmp [ i ] = jQuery . trim ( tmp [ i ] ) ;
2010-07-15 22:57:48 +00:00
var diskAttrs = tmp [ i ] . split ( ' ' ) ;
2012-04-02 15:43:37 +00:00
dTable . fnAddData ( [ '<input type="checkbox" name="' + diskAttrs [ 0 ] + '"/>' , hcp , pool , stat , diskAttrs [ 0 ] , diskAttrs [ 1 ] , diskAttrs [ 2 ] , diskAttrs [ 3 ] ] ) ;
2012-04-02 04:08:30 +00:00
}
// Create actions menu
if ( ! $ ( '#zvmResourceActions' ) . length ) {
// Empty filter area
$ ( '#' + tableId + '_length' ) . empty ( ) ;
// Add disk to pool
var addLnk = $ ( '<a>Add</a>' ) ;
addLnk . bind ( 'click' , function ( event ) {
openAddDisk2PoolDialog ( ) ;
} ) ;
// Delete disk from pool
var deleteLnk = $ ( '<a>Delete</a>' ) ;
deleteLnk . bind ( 'click' , function ( event ) {
2012-04-02 15:43:37 +00:00
var disks = getNodesChecked ( tableId ) ;
openDeleteDiskFromPoolDialog ( disks ) ;
2012-04-02 04:08:30 +00:00
} ) ;
// Refresh table
var refreshLnk = $ ( '<a>Refresh</a>' ) ;
refreshLnk . bind ( 'click' , function ( event ) {
2012-04-02 15:43:37 +00:00
$ ( '#zvmDiskResource' ) . empty ( ) . append ( createLoader ( '' ) ) ;
setDiskDataTable ( '' ) ;
2012-04-02 04:08:30 +00:00
2012-04-02 15:43:37 +00:00
// Create a array for hardware control points
var hcps = new Array ( ) ;
if ( $ . cookie ( 'hcp' ) . indexOf ( ',' ) > - 1 )
hcps = $ . cookie ( 'hcp' ) . split ( ',' ) ;
else
hcps . push ( $ . cookie ( 'hcp' ) ) ;
// Query the disk pools for each
for ( var i in hcps ) {
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'lsvm' ,
tgt : hcps [ i ] ,
args : '--diskpoolnames' ,
msg : hcps [ i ]
} ,
success : getDiskPool
} ) ;
}
2012-04-02 04:08:30 +00:00
} ) ;
// Create action bar
var actionBar = $ ( '<div id="zvmResourceActions" class="actionBar"></div>' ) ;
// Create an action menu
var actionsMenu = createMenu ( [ addLnk , deleteLnk , refreshLnk ] ) ;
actionsMenu . superfish ( ) ;
actionsMenu . css ( 'display' , 'inline-block' ) ;
actionBar . append ( actionsMenu ) ;
// Set correct theme for action menu
actionsMenu . find ( 'li' ) . hover ( function ( ) {
setMenu2Theme ( $ ( this ) ) ;
} , function ( ) {
setMenu2Normal ( $ ( this ) ) ;
} ) ;
// Create a division to hold actions menu
var menuDiv = $ ( '<div id="' + tableId + '_menuDiv" class="menuDiv"></div>' ) ;
$ ( '#' + tableId + '_length' ) . prepend ( menuDiv ) ;
$ ( '#' + tableId + '_length' ) . css ( {
'padding' : '0px' ,
'width' : '500px'
} ) ;
$ ( '#' + tableId + '_filter' ) . css ( { 'padding' : '10px' , } ) ;
menuDiv . append ( actionBar ) ;
}
/ * *
* Enable editable columns
* /
// Do not make 1st, 2nd, 4th, 5th, 6th, 7th, or 8th column editable
$ ( '#' + tableId + ' td:not(td:nth-child(1),td:nth-child(2),td:nth-child(4),td:nth-child(5),td:nth-child(6),td:nth-child(7),td:nth-child(8))' ) . editable (
function ( value , settings ) {
// If users did not make changes, return the value directly
// jeditable saves the old value in this.revert
if ( $ ( this ) . attr ( 'revert' ) == value ) {
return value ;
}
// Get column index
var colPos = this . cellIndex ;
// Get row index
var dTable = $ ( '#' + tableId ) . dataTable ( ) ;
var rowPos = dTable . fnGetPosition ( this . parentNode ) ;
// Update datatable
dTable . fnUpdate ( value , rowPos , colPos , false ) ;
// Get table headers
var headers = $ ( '#' + nodesTableId ) . parents ( '.dataTables_scroll' ) . find ( '.dataTables_scrollHead thead tr:eq(0) th' ) ;
// Get node name
var node = $ ( this ) . parent ( ) . find ( 'td a.node' ) . text ( ) ;
// 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 node attributes
// $.ajax( {
// url : 'lib/cmd.php',
// dataType : 'json',
// data : {
// cmd : 'chdef',
// tgt : '',
// args : '-t;node;-o;' + node + ';' + args,
// msg : 'out=nodesTab;tgt=' + node
// },
//
// success: showChdefOutput
// });
return value ;
} , {
onblur : 'submit' , // Clicking outside editable area submits changes
type : 'textarea' ,
placeholder : ' ' ,
event : "dblclick" , // Double click and edit
height : '50px' // The height of the text area
} ) ;
// Resize accordion
$ ( '#zvmResourceAccordion' ) . accordion ( 'resize' ) ;
}
/ * *
* Open dialog to delete disk from pool
2012-04-02 15:43:37 +00:00
*
* @ param disks2delete
* Disks selected in table
* @ return Nothing
2012-04-02 04:08:30 +00:00
* /
2012-04-02 15:43:37 +00:00
function openDeleteDiskFromPoolDialog ( disks2delete ) {
2012-04-02 04:08:30 +00:00
// Create form to delete disk to pool
var dialogId = 'zvmDeleteDiskFromPool' ;
var deleteDiskForm = $ ( '<div id="' + dialogId + '" class="form"></div>' ) ;
// Create info bar
var info = createInfoBar ( 'Remove a disk from a disk pool defined in the EXTENT CONTROL.' ) ;
deleteDiskForm . append ( info ) ;
var action = $ ( '<div><label>Action:</label></div>' ) ;
var actionSelect = $ ( '<select name="action">'
+ '<option value=""></option>'
+ '<option value="1">Remove region</option>'
+ '<option value="2">Remove region from group</option>'
+ '<option value="3">Remove region from all groups</option>'
+ '<option value="7">Remove entire group</option>'
+ '</select>' ) ;
action . append ( actionSelect ) ;
var hcp = $ ( '<div><label>Hardware control point:</label></div>' ) ;
var hcpSelect = $ ( '<select name="hcp"></select>' ) ;
hcp . append ( hcpSelect ) ;
2012-04-02 15:43:37 +00:00
// Set region input based on those selected on table (if any)
var region = $ ( '<div><label>Region name:</label><input type="text" name="region" value="' + disks2delete + '"/></div>' ) ;
2012-04-02 04:08:30 +00:00
var group = $ ( '<div><label>Group name:</label><input type="text" name="group"/></div>' ) ;
deleteDiskForm . append ( action , hcp , region , group ) ;
// Create a array for hardware control points
var hcps = new Array ( ) ;
if ( $ . cookie ( 'hcp' ) . indexOf ( ',' ) > - 1 )
hcps = $ . cookie ( 'hcp' ) . split ( ',' ) ;
else
hcps . push ( $ . cookie ( 'hcp' ) ) ;
// Append options for hardware control points
for ( var i in hcps ) {
hcpSelect . append ( $ ( '<option value="' + hcps [ i ] + '">' + hcps [ i ] + '</option>' ) ) ;
}
actionSelect . change ( function ( ) {
if ( $ ( this ) . val ( ) == '1' || $ ( this ) . val ( ) == '3' ) {
region . show ( ) ;
group . hide ( ) ;
} else if ( $ ( this ) . val ( ) == '2' ) {
region . show ( ) ;
group . show ( ) ;
} else if ( $ ( this ) . val ( ) == '7' ) {
region . val ( 'FOOBAR' ) ;
region . hide ( ) ;
group . show ( ) ;
}
} ) ;
2012-04-02 15:43:37 +00:00
2012-04-02 04:08:30 +00:00
// Open dialog to delete disk
deleteDiskForm . dialog ( {
title : 'Delete disk from pool' ,
modal : true ,
width : 400 ,
buttons : {
"Ok" : function ( ) {
// Remove any warning messages
$ ( this ) . find ( '.ui-state-error' ) . remove ( ) ;
// Get inputs
var action = $ ( this ) . find ( 'select[name=action]' ) . val ( ) ;
var hcp = $ ( this ) . find ( 'select[name=hcp]' ) . val ( ) ;
var region = $ ( this ) . find ( 'input[name=region]' ) . val ( ) ;
var group = $ ( this ) . find ( 'input[name=group]' ) . val ( ) ;
// If inputs are not complete, show warning message
if ( ! action || ! hcp ) {
var warn = createWarnBar ( 'Please provide a value for each missing field.' ) ;
warn . prependTo ( $ ( this ) ) ;
} else {
// Change dialog buttons
$ ( this ) . dialog ( 'option' , 'buttons' , {
'Close' : function ( ) { $ ( this ) . dialog ( "close" ) ; }
} ) ;
var args ;
if ( action == '2' || action == '7' )
args = region + ';' + group ;
else
args = group ;
// Add disk to pool
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : hcp ,
args : '--removediskfrompool;' + action + ';' + args ,
msg : dialogId
} ,
success : updateResourceDialog
} ) ;
}
} ,
"Cancel" : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
}
} ) ;
}
/ * *
* Open dialog to add disk to pool
* /
function openAddDisk2PoolDialog ( ) {
// Create form to add disk to pool
var dialogId = 'zvmAddDisk2Pool' ;
var addDiskForm = $ ( '<div id="' + dialogId + '" class="form"></div>' ) ;
// Create info bar
var info = createInfoBar ( 'Add a disk to a disk pool defined in the EXTENT CONTROL. The disk has to already be attached to SYSTEM.' ) ;
addDiskForm . append ( info ) ;
var action = $ ( '<div><label>Action:</label></div>' ) ;
var actionSelect = $ ( '<select name="action">'
+ '<option value=""></option>'
+ '<option value="4">Define region and add to group</option>'
+ '<option value="5">Add existing region to group</option>'
+ '</select>' ) ;
action . append ( actionSelect ) ;
var hcp = $ ( '<div><label>Hardware control point:</label></div>' ) ;
var hcpSelect = $ ( '<select name="hcp"></select>' ) ;
hcp . append ( hcpSelect ) ;
var region = $ ( '<div><label>Region name:</label><input type="text" name="region"/></div>' ) ;
var volume = $ ( '<div><label>Volume name:</label><input type="text" name="volume"/></div>' ) ;
var group = $ ( '<div><label>Group name:</label><input type="text" name="group"/></div>' ) ;
addDiskForm . append ( action , hcp , region , volume , group ) ;
// Create a array for hardware control points
var hcps = new Array ( ) ;
if ( $ . cookie ( 'hcp' ) . indexOf ( ',' ) > - 1 )
hcps = $ . cookie ( 'hcp' ) . split ( ',' ) ;
else
hcps . push ( $ . cookie ( 'hcp' ) ) ;
// Append options for hardware control points
for ( var i in hcps ) {
hcpSelect . append ( $ ( '<option value="' + hcps [ i ] + '">' + hcps [ i ] + '</option>' ) ) ;
2010-07-15 22:57:48 +00:00
}
2012-04-02 04:08:30 +00:00
actionSelect . change ( function ( ) {
if ( $ ( this ) . val ( ) == '4' ) {
volume . show ( ) ;
} else if ( $ ( this ) . val ( ) == '5' ) {
volume . hide ( ) ;
}
} ) ;
// Open dialog to add disk
addDiskForm . dialog ( {
title : 'Add disk to pool' ,
modal : true ,
width : 400 ,
buttons : {
"Ok" : function ( ) {
// Remove any warning messages
$ ( this ) . find ( '.ui-state-error' ) . remove ( ) ;
// Get inputs
var action = $ ( this ) . find ( 'select[name=action]' ) . val ( ) ;
var hcp = $ ( this ) . find ( 'select[name=hcp]' ) . val ( ) ;
var region = $ ( this ) . find ( 'input[name=region]' ) . val ( ) ;
var volume = $ ( this ) . find ( 'input[name=volume]' ) . val ( ) ;
var group = $ ( this ) . find ( 'input[name=group]' ) . val ( ) ;
// If inputs are not complete, show warning message
if ( ! action || ! hcp || ! region || ! group ) {
var warn = createWarnBar ( 'Please provide a value for each missing field.' ) ;
warn . prependTo ( $ ( this ) ) ;
} else {
// Change dialog buttons
$ ( this ) . dialog ( 'option' , 'buttons' , {
'Close' : function ( ) { $ ( this ) . dialog ( "close" ) ; }
} ) ;
var args ;
if ( action == '4' )
args = region + ';' + volume + ';' + group ;
else
args = region + ';' + group ;
// Add disk to pool
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : hcp ,
args : '--adddisk2pool;' + action + ';' + args ,
msg : dialogId
} ,
success : updateResourceDialog
} ) ;
}
} ,
"Cancel" : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
}
} ) ;
}
/ * *
* Update resource dialog
*
* @ param data
* HTTP request data
* @ return Nothing
* /
function updateResourceDialog ( data ) {
var dialogId = data . msg ;
var infoMsg ;
// Create info message
if ( jQuery . isArray ( data . rsp ) ) {
infoMsg = '' ;
for ( var i in data . rsp ) {
infoMsg += data . rsp [ i ] + '</br>' ;
}
} else {
infoMsg = data . rsp ;
}
// Append info to dialog
var info = createInfoBar ( infoMsg ) ;
info . prependTo ( $ ( '#' + dialogId ) ) ;
}
/ * *
* Select all checkboxes in the datatable
*
* @ param event
* Event on element
* @ param obj
* Object triggering event
* @ return Nothing
* /
function selectAllDisk ( event , obj ) {
// Get datatable ID
// This will ascend from <input> <th> <tr> <thead> <table>
var tableObj = obj . parents ( '.datatable' ) ;
var status = obj . attr ( 'checked' ) ;
tableObj . find ( ' :checkbox' ) . attr ( 'checked' , status ) ;
event . stopPropagation ( ) ;
2010-07-15 22:57:48 +00:00
}
/ * *
2010-07-29 17:32:24 +00:00
* Load network details into a table
2010-07-15 22:57:48 +00:00
*
* @ param data
* HTTP request data
* @ return Nothing
* /
function loadNetworkTable ( data ) {
2012-04-02 04:08:30 +00:00
// Remove loader
var panelId = 'zvmNetworkResource' ;
$ ( '#' + panelId ) . find ( 'img[src="images/loader.gif"]' ) . remove ( ) ;
2010-07-15 22:57:48 +00:00
var args = data . msg . split ( ';' ) ;
var hcp = args [ 0 ] . replace ( 'hcp=' , '' ) ;
var type = args [ 1 ] . replace ( 'type=' , '' ) ;
var name = args [ 2 ] . replace ( 'network=' , '' ) ;
var tmp = data . rsp [ 0 ] . split ( hcp + ': ' ) ;
2012-04-02 04:08:30 +00:00
// Resource tab ID
var info = $ ( '#' + panelId ) . find ( '.ui-state-highlight' ) ;
2010-12-04 16:04:06 +00:00
// If there is no info bar
if ( ! info . length ) {
// Create info bar
2012-04-02 04:08:30 +00:00
info = createInfoBar ( 'Below are LANs/VSWITCHes available to use.' ) ;
$ ( '#' + panelId ) . append ( info ) ;
2010-12-04 16:04:06 +00:00
}
2010-07-15 22:57:48 +00:00
2010-07-29 17:32:24 +00:00
// Get datatable
2010-07-15 22:57:48 +00:00
var dTable = getNetworkDataTable ( ) ;
2012-04-02 04:08:30 +00:00
if ( ! dTable ) {
2010-07-15 22:57:48 +00:00
// Create table
2011-01-19 15:56:43 +00:00
var tableId = 'zNetworkDataTable' ;
var table = new DataTable ( tableId ) ;
2011-11-23 17:59:48 +00:00
table . init ( [ 'HCP' , 'Type' , 'Name' , 'Details' ] ) ;
2010-07-15 22:57:48 +00:00
// Append datatable to tab
2012-04-02 04:08:30 +00:00
$ ( '#' + panelId ) . append ( table . object ( ) ) ;
2010-07-15 22:57:48 +00:00
// Turn into datatable
2011-01-19 15:56:43 +00:00
dTable = $ ( '#' + tableId ) . dataTable ( ) ;
2010-07-15 22:57:48 +00:00
setNetworkDataTable ( dTable ) ;
// Set the column width
var cols = table . object ( ) . find ( 'thead tr th' ) ;
cols . eq ( 0 ) . css ( 'width' , '20px' ) ; // HCP column
cols . eq ( 1 ) . css ( 'width' , '20px' ) ; // Type column
cols . eq ( 2 ) . css ( 'width' , '20px' ) ; // Name column
2011-11-23 17:59:48 +00:00
cols . eq ( 3 ) . css ( { 'width' : '600px' } ) ; // Details column
2010-07-15 22:57:48 +00:00
}
// Skip index 0 because it contains nothing
2011-11-23 17:59:48 +00:00
var details = '<pre style="text-align: left;">' ;
2010-07-15 22:57:48 +00:00
for ( var i = 1 ; i < tmp . length ; i ++ ) {
2011-11-23 17:59:48 +00:00
details += tmp [ i ] ;
2010-07-15 22:57:48 +00:00
}
2011-11-23 17:59:48 +00:00
details += '</pre>' ;
2012-04-02 04:08:30 +00:00
dTable . fnAddData ( [ '<pre>' + hcp + '</pre>' , '<pre>' + type + '</pre>' , '<pre>' + name + '</pre>' , details ] ) ;
// Resize accordion
$ ( '#zvmResourceAccordion' ) . accordion ( 'resize' ) ;
2010-07-15 22:57:48 +00:00
}
/ * *
* Connect a NIC to a Guest LAN
*
* @ param data
* Data from HTTP request
* @ return Nothing
* /
function connect2GuestLan ( data ) {
var rsp = data . rsp ;
var args = data . msg . split ( ';' ) ;
var node = args [ 0 ] . replace ( 'node=' , '' ) ;
var address = args [ 1 ] . replace ( 'addr=' , '' ) ;
var lanName = args [ 2 ] . replace ( 'lan=' , '' ) ;
var lanOwner = args [ 3 ] . replace ( 'owner=' , '' ) ;
2010-07-27 22:56:42 +00:00
// Write ajax response to status bar
2012-01-25 13:44:26 +00:00
var prg = writeRsp ( rsp , node + ': ' ) ;
$ ( '#' + node + 'StatusBar' ) . find ( 'div' ) . append ( prg ) ;
2010-07-28 20:24:29 +00:00
2010-07-15 22:57:48 +00:00
// Connect NIC to Guest LAN
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : node ,
args : '--connectnic2guestlan;' + address + ';' + lanName + ';'
+ lanOwner ,
msg : node
} ,
success : updateZNodeStatus
} ) ;
}
/ * *
* Connect a NIC to a VSwitch
*
* @ param data
* Data from HTTP request
* @ return Nothing
* /
function connect2VSwitch ( data ) {
var rsp = data . rsp ;
var args = data . msg . split ( ';' ) ;
var node = args [ 0 ] . replace ( 'node=' , '' ) ;
var address = args [ 1 ] . replace ( 'addr=' , '' ) ;
var vswitchName = args [ 2 ] . replace ( 'vsw=' , '' ) ;
2010-07-27 22:56:42 +00:00
// Write ajax response to status bar
2012-01-25 13:44:26 +00:00
var prg = writeRsp ( rsp , node + ': ' ) ;
$ ( '#' + node + 'StatusBar' ) . find ( 'div' ) . append ( prg ) ;
2010-07-15 22:57:48 +00:00
// Connect NIC to VSwitch
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'chvm' ,
tgt : node ,
args : '--connectnic2vswitch;' + address + ';' + vswitchName ,
msg : node
} ,
success : updateZNodeStatus
} ) ;
2010-07-27 19:50:01 +00:00
}
/ * *
* Create provision existing node division
*
* @ param inst
* Provision tab instance
* @ return Provision existing node division
* /
function createZProvisionExisting ( inst ) {
// Create provision existing and hide it
var provExisting = $ ( '<div></div>' ) . hide ( ) ;
2011-11-23 17:59:48 +00:00
var vmFS = $ ( '<fieldset></fieldset>' ) ;
var vmLegend = $ ( '<legend>Virtual Machine</legend>' ) ;
vmFS . append ( vmLegend ) ;
provExisting . append ( vmFS ) ;
2011-12-19 05:03:27 +00:00
var vmAttr = $ ( '<div style="display: inline-table; vertical-align: middle; width: 85%; margin-left: 10px;"></div>' ) ;
vmFS . append ( $ ( '<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/computer.png"></img></div>' ) ) ;
vmFS . append ( vmAttr ) ;
2011-11-23 17:59:48 +00:00
var osFS = $ ( '<fieldset></fieldset>' ) ;
var osLegend = $ ( '<legend>Operating System</legend>' ) ;
osFS . append ( osLegend ) ;
provExisting . append ( osFS ) ;
2011-12-19 05:03:27 +00:00
var osAttr = $ ( '<div style="display: inline-table; vertical-align: middle;"></div>' ) ;
osFS . append ( $ ( '<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/operating_system.png"></img></div>' ) ) ;
osFS . append ( osAttr ) ;
2010-07-27 19:50:01 +00:00
// Create group input
var group = $ ( '<div></div>' ) ;
var groupLabel = $ ( '<label for="provType">Group:</label>' ) ;
group . append ( groupLabel ) ;
// Turn on auto complete for group
2010-11-22 16:18:55 +00:00
var groupNames = $ . cookie ( 'groups' ) ;
2010-07-27 19:50:01 +00:00
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
2010-07-27 22:56:42 +00:00
groupSelect . change ( function ( ) {
2010-07-27 19:50:01 +00:00
// Get group selected
var thisGroup = $ ( this ) . val ( ) ;
// If a valid group is selected
if ( thisGroup ) {
2010-07-28 20:24:29 +00:00
createNodesDatatable ( thisGroup , 'zNodesDatatableDIV' + inst ) ;
}
2010-07-27 19:50:01 +00:00
} ) ;
} else {
// If no groups are cookied
var groupInput = $ ( '<input type="text" name="group"/>' ) ;
group . append ( groupInput ) ;
}
2011-12-19 05:03:27 +00:00
vmAttr . append ( group ) ;
2010-07-27 19:50:01 +00:00
// Create node input
var node = $ ( '<div></div>' ) ;
var nodeLabel = $ ( '<label for="nodeName">Nodes:</label>' ) ;
2011-12-19 05:03:27 +00:00
var nodeDatatable = $ ( '<div class="indent" id="zNodesDatatableDIV' + inst + '" style="display: inline-block; max-width: 800px;"><p>Select a group to view its nodes</p></div>' ) ;
2010-07-27 19:50:01 +00:00
node . append ( nodeLabel ) ;
node . append ( nodeDatatable ) ;
2011-12-19 05:03:27 +00:00
vmAttr . append ( node ) ;
2010-07-27 19:50:01 +00:00
// Create operating system image input
var os = $ ( '<div></div>' ) ;
var osLabel = $ ( '<label for="os">Operating system image:</label>' ) ;
2010-11-01 14:28:11 +00:00
var osInput = $ ( '<input type="text" name="os" title="You must give the operating system to install on this node or node range, e.g. rhel5.5-s390x-install-compute"/>' ) ;
2010-07-27 19:50:01 +00:00
// Get image names on focus
osInput . one ( 'focus' , function ( ) {
2010-11-22 16:18:55 +00:00
var imageNames = $ . cookie ( 'imagenames' ) ;
2010-07-27 19:50:01 +00:00
if ( imageNames ) {
// Turn on auto complete
2011-01-14 15:16:44 +00:00
$ ( this ) . autocomplete ( {
source : imageNames . split ( ',' )
} ) ;
2010-07-27 19:50:01 +00:00
}
} ) ;
os . append ( osLabel ) ;
os . append ( osInput ) ;
2011-12-19 05:03:27 +00:00
osAttr . append ( os ) ;
2010-07-27 19:50:01 +00:00
// Create boot method drop down
var bootMethod = $ ( '<div></div>' ) ;
var methoddLabel = $ ( '<label>Boot method:</label>' ) ;
var methodSelect = $ ( '<select name="bootMethod"></select>' ) ;
2010-09-24 02:27:04 +00:00
methodSelect . append ( '<option value="boot">boot</option>'
+ '<option value="install">install</option>'
+ '<option value="iscsiboot">iscsiboot</option>'
+ '<option value="netboot">netboot</option>'
+ '<option value="statelite">statelite</option>'
) ;
2010-07-27 19:50:01 +00:00
bootMethod . append ( methoddLabel ) ;
bootMethod . append ( methodSelect ) ;
2011-12-19 05:03:27 +00:00
osAttr . append ( bootMethod ) ;
2010-07-27 19:50:01 +00:00
2010-11-01 14:28:11 +00:00
// Generate tooltips
provExisting . find ( 'div input[title]' ) . tooltip ( {
2010-12-03 22:09:36 +00:00
position : "center right" ,
offset : [ - 2 , 10 ] ,
effect : "fade" ,
2010-12-08 16:28:12 +00:00
opacity : 0.7 ,
2010-12-10 14:38:30 +00:00
predelay : 800 ,
2010-12-08 16:28:12 +00:00
events : {
def : "mouseover,mouseout" ,
input : "mouseover,mouseout" ,
widget : "focus mouseover,blur mouseout" ,
tooltip : "mouseover,mouseout"
}
2010-11-01 14:28:11 +00:00
} ) ;
2010-07-27 19:50:01 +00:00
/ * *
* Provision existing
* /
var provisionBtn = createButton ( 'Provision' ) ;
provisionBtn . 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-27 19:50:01 +00:00
var ready = true ;
var errMsg = '' ;
// Get provision tab ID
var thisTabId = $ ( this ) . parent ( ) . parent ( ) . parent ( ) . attr ( 'id' ) ;
// Get provision tab instance
var inst = thisTabId . replace ( 'zvmProvisionTab' , '' ) ;
// Get nodes that were checked
2010-08-03 18:55:42 +00:00
var dTableId = 'zNodesDatatable' + inst ;
2010-07-27 19:50:01 +00:00
var tgts = getNodesChecked ( dTableId ) ;
if ( ! tgts ) {
2010-09-24 02:27:04 +00:00
errMsg += 'You need to select a node.<br>' ;
2010-07-27 19:50:01 +00:00
ready = false ;
}
// Check operating system image
var os = $ ( '#' + thisTabId + ' input[name=os]:visible' ) ;
if ( ! os . val ( ) ) {
2010-09-24 02:27:04 +00:00
errMsg += 'You need to select a operating system image.' ;
2010-07-27 19:50:01 +00:00
os . css ( 'border' , 'solid #FF0000 1px' ) ;
ready = false ;
} else {
os . css ( 'border' , 'solid #BDBDBD 1px' ) ;
}
// If all inputs are valid, ready to provision
if ( ready ) {
// Disable provision button
2010-09-22 20:18:21 +00:00
$ ( this ) . attr ( 'disabled' , 'true' ) ;
2010-07-27 19:50:01 +00:00
// Show loader
$ ( '#zProvisionStatBar' + inst ) . show ( ) ;
$ ( '#zProvisionLoader' + inst ) . show ( ) ;
// Disable all inputs
2010-07-29 20:22:09 +00:00
var inputs = $ ( '#' + thisTabId + ' input:visible' ) ;
2010-07-27 19:50:01 +00:00
inputs . attr ( 'disabled' , 'disabled' ) ;
// Disable all selects
var selects = $ ( '#' + thisTabId + ' select' ) ;
selects . attr ( 'disabled' , 'disabled' ) ;
// Get operating system image
var osImage = $ ( '#' + thisTabId + ' input[name=os]:visible' ) . val ( ) ;
var tmp = osImage . split ( '-' ) ;
var os = tmp [ 0 ] ;
var arch = tmp [ 1 ] ;
var profile = tmp [ 3 ] ;
/ * *
* ( 1 ) Set operating system
* /
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'nodeadd' ,
2010-07-27 22:56:42 +00:00
tgt : '' ,
args : tgts + ';noderes.netboot=zvm;nodetype.os=' + os + ';nodetype.arch=' + arch + ';nodetype.profile=' + profile ,
msg : 'cmd=nodeadd;out=' + inst
2010-07-27 19:50:01 +00:00
} ,
2010-07-29 20:22:09 +00:00
success : updateZProvisionExistingStatus
2010-07-27 19:50:01 +00:00
} ) ;
} else {
2010-09-24 02:27:04 +00:00
// Show warning message
var warn = createWarnBar ( errMsg ) ;
warn . prependTo ( $ ( this ) . parent ( ) . parent ( ) ) ;
2010-07-27 19:50:01 +00:00
}
} ) ;
provExisting . append ( provisionBtn ) ;
return provExisting ;
}
/ * *
* Create provision new node division
*
* @ param inst
* Provision tab instance
* @ return Provision new node division
* /
function createZProvisionNew ( inst ) {
// Create provision new node division
var provNew = $ ( '<div></div>' ) ;
2011-12-19 05:03:27 +00:00
// Create VM fieldset
2011-11-23 17:59:48 +00:00
var vmFS = $ ( '<fieldset></fieldset>' ) ;
var vmLegend = $ ( '<legend>Virtual Machine</legend>' ) ;
vmFS . append ( vmLegend ) ;
provNew . append ( vmFS ) ;
2011-12-19 05:03:27 +00:00
var vmAttr = $ ( '<div style="display: inline-table; vertical-align: middle;"></div>' ) ;
vmFS . append ( $ ( '<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/computer.png"></img></div>' ) ) ;
vmFS . append ( vmAttr ) ;
2012-02-11 00:46:54 +00:00
// Create OS fieldset
var osFS = $ ( '<fieldset></fieldset>' ) ;
var osLegend = $ ( '<legend>Operating System</legend>' ) ;
osFS . append ( osLegend ) ;
provNew . append ( osFS ) ;
2011-12-19 05:03:27 +00:00
// Create hardware fieldset
2011-11-23 17:59:48 +00:00
var hwFS = $ ( '<fieldset></fieldset>' ) ;
var hwLegend = $ ( '<legend>Hardware</legend>' ) ;
hwFS . append ( hwLegend ) ;
provNew . append ( hwFS ) ;
2011-12-19 05:03:27 +00:00
var hwAttr = $ ( '<div style="display: inline-table; vertical-align: middle;"></div>' ) ;
hwFS . append ( $ ( '<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/hardware.png"></img></div>' ) ) ;
hwFS . append ( hwAttr ) ;
2012-02-11 00:46:54 +00:00
2011-12-19 05:03:27 +00:00
var osAttr = $ ( '<div style="display: inline-table; vertical-align: middle;"></div>' ) ;
osFS . append ( $ ( '<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/operating_system.png"></img></div>' ) ) ;
osFS . append ( osAttr ) ;
2010-07-27 19:50:01 +00:00
// Create group input
var group = $ ( '<div></div>' ) ;
var groupLabel = $ ( '<label>Group:</label>' ) ;
2010-11-01 14:19:14 +00:00
var groupInput = $ ( '<input type="text" name="group" title="You must give the group name that the node(s) will be placed under"/>' ) ;
2010-07-27 19:50:01 +00:00
// Get groups on-focus
groupInput . one ( 'focus' , function ( ) {
2010-11-22 16:18:55 +00:00
var groupNames = $ . cookie ( 'groups' ) ;
2010-07-27 19:50:01 +00:00
if ( groupNames ) {
// Turn on auto complete
2011-01-14 15:16:44 +00:00
$ ( this ) . autocomplete ( {
source : groupNames . split ( ',' )
} ) ;
2010-07-27 19:50:01 +00:00
}
} ) ;
group . append ( groupLabel ) ;
group . append ( groupInput ) ;
2011-12-19 05:03:27 +00:00
vmAttr . append ( group ) ;
2010-07-27 19:50:01 +00:00
// Create node input
var nodeName = $ ( '<div></div>' ) ;
var nodeLabel = $ ( '<label>Node:</label>' ) ;
2010-11-01 14:19:14 +00:00
var nodeInput = $ ( '<input type="text" name="nodeName" title="You must give a node or a node range. A node range must be given as: node1-node9 or node[1-9]."/>' ) ;
2010-07-27 19:50:01 +00:00
nodeName . append ( nodeLabel ) ;
nodeName . append ( nodeInput ) ;
2011-12-19 05:03:27 +00:00
vmAttr . append ( nodeName ) ;
2010-07-27 19:50:01 +00:00
// Create user ID input
2010-11-01 14:19:14 +00:00
var userId = $ ( '<div><label>User ID:</label><input type="text" name="userId" title="You must give a user ID or a user ID range. A user ID range must be given as: user1-user9 or user[1-9]."/></div>' ) ;
2011-12-19 05:03:27 +00:00
vmAttr . append ( userId ) ;
2010-07-27 19:50:01 +00:00
// Create hardware control point input
var hcpDiv = $ ( '<div></div>' ) ;
var hcpLabel = $ ( '<label for="hcp">Hardware control point:</label>' ) ;
2010-11-01 14:19:14 +00:00
var hcpInput = $ ( '<input type="text" name="hcp" title="You must give the System z hardware control point (zHCP) responsible for managing the node(s)"/>' ) ;
2010-07-27 19:50:01 +00:00
hcpInput . blur ( function ( ) {
if ( $ ( this ) . val ( ) ) {
var args = $ ( this ) . val ( ) . split ( '.' ) ;
2010-12-20 15:17:15 +00:00
if ( ! $ . cookie ( args [ 0 ] + 'diskpools' ) ) {
// Get disk pools
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'lsvm' ,
tgt : args [ 0 ] ,
args : '--diskpoolnames' ,
msg : args [ 0 ]
} ,
success : setDiskPoolCookies
} ) ;
}
2010-07-27 19:50:01 +00:00
}
} ) ;
hcpDiv . append ( hcpLabel ) ;
hcpDiv . append ( hcpInput ) ;
2011-12-19 05:03:27 +00:00
vmAttr . append ( hcpDiv ) ;
2010-07-27 19:50:01 +00:00
2012-03-14 19:20:37 +00:00
// Create an advanced link to set IP address and hostname
var advancedLnk = $ ( '<div><label><a style="color: blue; cursor: pointer;">Advanced</a></label></div>' ) ;
vmAttr . append ( advancedLnk ) ;
var advanced = $ ( '<div style="margin-left: 20px;"></div>' ) . hide ( ) ;
vmAttr . append ( advanced ) ;
var ip = $ ( '<div><label>IP address:</label><input type="text" name="ip" ' +
'title="Optional. Specify the IP address that will be assigned to this node. An IP address must be given in the following format: 192.168.0.1."/></div>' ) ;
advanced . append ( ip ) ;
var hostname = $ ( '<div><label>Hostname:</label><input type="text" name="hostname" ' +
'title="Optional. Specify the hostname that will be assigned to this node. A hostname must be given in the following format: ihost1.sourceforge.net."/></div>' ) ;
advanced . append ( hostname ) ;
// Show IP address and hostname inputs on-click
advancedLnk . click ( function ( ) {
advanced . toggle ( ) ;
} ) ;
2010-07-27 19:50:01 +00:00
// Create operating system image input
var os = $ ( '<div></div>' ) ;
var osLabel = $ ( '<label for="os">Operating system image:</label>' ) ;
2010-11-01 14:19:14 +00:00
var osInput = $ ( '<input type="text" name="os" title="You must give the operating system to install on this node or node range, e.g. rhel5.5-s390x-install-compute"/>' ) ;
2010-07-27 19:50:01 +00:00
// Get image names on focus
osInput . one ( 'focus' , function ( ) {
2010-11-22 16:18:55 +00:00
var imageNames = $ . cookie ( 'imagenames' ) ;
2010-07-27 19:50:01 +00:00
if ( imageNames ) {
// Turn on auto complete
2011-01-14 15:16:44 +00:00
$ ( this ) . autocomplete ( {
source : imageNames . split ( ',' )
} ) ;
2010-07-27 19:50:01 +00:00
}
} ) ;
os . append ( osLabel ) ;
os . append ( osInput ) ;
2011-12-19 05:03:27 +00:00
osAttr . append ( os ) ;
2010-07-27 19:50:01 +00:00
// Create user entry input
2011-10-25 14:53:59 +00:00
var defaultChkbox = $ ( '<input type="checkbox" name="userEntry" value="default"/>' ) . click ( function ( ) {
// Remove any warning messages
$ ( this ) . parents ( '.form' ) . find ( '.ui-state-error' ) . remove ( ) ;
// Get tab ID
var thisTabId = $ ( this ) . parents ( '.ui-tabs-panel' ) . attr ( 'id' ) ;
2011-12-24 14:57:13 +00:00
// Get objects for HCP, user ID, and OS
2011-10-25 14:53:59 +00:00
var hcp = $ ( '#' + thisTabId + ' input[name=hcp]' ) ;
var userId = $ ( '#' + thisTabId + ' input[name=userId]' ) ;
2011-12-24 14:57:13 +00:00
var os = $ ( '#' + thisTabId + ' input[name=os]' ) ;
2011-10-25 14:53:59 +00:00
// Get default user entry when clicked
if ( $ ( this ) . attr ( 'checked' ) ) {
2011-12-24 14:57:13 +00:00
if ( ! hcp . val ( ) || ! os . val ( ) || ! userId . val ( ) ) {
2011-10-25 14:53:59 +00:00
// Show warning message
2011-12-24 14:57:13 +00:00
var warn = createWarnBar ( 'Please specify the hardware control point, operating system, and user ID before checking this box' ) ;
2011-10-25 14:53:59 +00:00
warn . prependTo ( $ ( this ) . parents ( '.form' ) ) ;
// Highlight empty fields
2011-12-24 14:57:13 +00:00
jQuery . each ( [ hcp , os , userId ] , function ( ) {
2011-10-25 14:53:59 +00:00
if ( ! $ ( this ) . val ( ) ) {
$ ( this ) . css ( 'border' , 'solid #FF0000 1px' ) ;
}
} ) ;
} else {
// Un-highlight empty fields
2011-12-24 14:57:13 +00:00
jQuery . each ( [ hcp , os , userId ] , function ( ) {
2011-10-25 14:53:59 +00:00
$ ( this ) . css ( 'border' , 'solid #BDBDBD 1px' ) ;
} ) ;
2011-12-24 14:57:13 +00:00
// Get profile name
var tmp = os . val ( ) . split ( '-' ) ;
var profile = tmp [ 3 ] ;
2011-10-25 14:53:59 +00:00
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
2011-12-24 14:57:13 +00:00
args : 'getdefaultuserentry;' + hcp . val ( ) + ';' + profile ,
2011-10-25 14:53:59 +00:00
msg : thisTabId
} ,
success : function ( data ) {
// Populate user entry
var tabId = data . msg ;
var entry = new String ( data . rsp ) ;
var userId = $ ( '#' + tabId + ' input[name=userId]' ) . val ( ) ;
entry = entry . replace ( new RegExp ( 'LXUSR' , 'g' ) , userId ) ;
$ ( '#' + tabId + ' textarea:visible' ) . val ( entry ) ;
}
} ) ;
}
} else {
$ ( '#' + thisTabId + ' textarea:visible' ) . val ( '' ) ;
// Un-highlight empty fields
2011-12-24 14:57:13 +00:00
jQuery . each ( [ hcp , os , userId ] , function ( ) {
2011-10-25 14:53:59 +00:00
$ ( this ) . css ( 'border' , 'solid #BDBDBD 1px' ) ;
} ) ;
}
} ) ;
2012-03-14 04:38:48 +00:00
var userEntry = $ ( '<div><label style="vertical-align: top;">Directory entry:</label><textarea/></textarea></div>' ) ;
2011-10-25 14:53:59 +00:00
userEntry . append ( $ ( '<span></span>' ) . append ( defaultChkbox , 'Use default' ) ) ;
2011-12-19 05:03:27 +00:00
hwAttr . append ( userEntry ) ;
2010-07-27 19:50:01 +00:00
// Create disk table
var diskDiv = $ ( '<div class="provision"></div>' ) ;
var diskLabel = $ ( '<label>Disks:</label>' ) ;
var diskTable = $ ( '<table></table>' ) ;
2011-09-28 21:38:12 +00:00
var diskHeader = $ ( '<thead class="ui-widget-header"> <th></th> <th>Type</th> <th>Address</th> <th>Size</th> <th>Mode</th> <th>Pool</th> <th>Password</th> </thead>' ) ;
2010-07-27 19:50:01 +00:00
// Adjust header width
diskHeader . find ( 'th' ) . css ( {
'width' : '80px'
} ) ;
diskHeader . find ( 'th' ) . eq ( 0 ) . css ( {
'width' : '20px'
} ) ;
var diskBody = $ ( '<tbody></tbody>' ) ;
var diskFooter = $ ( '<tfoot></tfoot>' ) ;
/ * *
* Add disks
* /
2010-09-28 20:24:31 +00:00
var addDiskLink = $ ( '<a>Add disk</a>' ) ;
2010-07-27 19:50:01 +00:00
addDiskLink . bind ( 'click' , function ( event ) {
// Create a row
var diskRow = $ ( '<tr></tr>' ) ;
// Add remove button
var removeBtn = $ ( '<span class="ui-icon ui-icon-close"></span>' ) ;
var col = $ ( '<td></td>' ) . append ( removeBtn ) ;
removeBtn . bind ( 'click' , function ( event ) {
diskRow . remove ( ) ;
} ) ;
diskRow . append ( col ) ;
// Create disk type drop down
var diskType = $ ( '<td></td>' ) ;
var diskTypeSelect = $ ( '<select></select>' ) ;
2010-09-24 02:27:04 +00:00
diskTypeSelect . append ( '<option value="3390">3390</option>'
+ '<option value="9336">9336</option>'
) ;
2010-07-27 19:50:01 +00:00
diskType . append ( diskTypeSelect ) ;
diskRow . append ( diskType ) ;
// Create disk address input
2010-11-01 18:39:03 +00:00
var diskAddr = $ ( '<td><input type="text" title="You must give the virtual device address of the disk to be added"/></td>' ) ;
2010-07-27 19:50:01 +00:00
diskRow . append ( diskAddr ) ;
// Create disk size input
2010-11-01 18:39:03 +00:00
var diskSize = $ ( '<td><input type="text" title="You must give the size of the disk to be created. The size value is one of the following: cylinders or block size. "/></td>' ) ;
2010-07-27 19:50:01 +00:00
diskRow . append ( diskSize ) ;
2010-09-01 15:36:05 +00:00
// Create disk mode input
var diskMode = $ ( '<td></td>' ) ;
var diskModeSelect = $ ( '<select></select>' ) ;
2010-09-24 02:27:04 +00:00
diskModeSelect . append ( '<option value="R">R</option>'
+ '<option value="RR">RR</option>'
+ '<option value="W">W</option>'
+ '<option value="WR">WR</option>'
+ '<option value="M">M</option>'
+ '<option value="MR">MR</option>'
+ '<option value="MW">MW</option>'
) ;
2010-09-01 15:36:05 +00:00
diskMode . append ( diskModeSelect ) ;
diskRow . append ( diskMode ) ;
2010-07-27 19:50:01 +00:00
// Get list of disk pools
2011-11-23 17:59:48 +00:00
var thisTabId = $ ( this ) . parents ( '.tab' ) . attr ( 'id' ) ;
2010-07-27 19:50:01 +00:00
var thisHcp = $ ( '#' + thisTabId + ' input[name=hcp]' ) . val ( ) ;
var definedPools ;
if ( thisHcp ) {
// Get node without domain name
var temp = thisHcp . split ( '.' ) ;
2010-11-22 16:18:55 +00:00
definedPools = $ . cookie ( temp [ 0 ] + 'diskpools' ) ;
2010-07-27 19:50:01 +00:00
}
// Create disk pool input
// Turn on auto complete for disk pool
2011-01-14 15:16:44 +00:00
var diskPoolInput = $ ( '<input type="text" title="You must give the group or region where the new image disk is to be created"/>' ) . autocomplete ( {
source : definedPools . split ( ',' )
} ) ;
2010-07-27 19:50:01 +00:00
var diskPool = $ ( '<td></td>' ) . append ( diskPoolInput ) ;
diskRow . append ( diskPool ) ;
// Create disk password input
2010-11-01 18:39:03 +00:00
var diskPw = $ ( '<td><input type="password" title="You must give the password that will be used for accessing the disk"/></td>' ) ;
2010-07-27 19:50:01 +00:00
diskRow . append ( diskPw ) ;
diskBody . append ( diskRow ) ;
2010-11-01 18:39:03 +00:00
// Generate tooltips
diskBody . find ( 'td input[title]' ) . tooltip ( {
2010-12-03 22:09:36 +00:00
position : "top right" ,
offset : [ - 4 , 4 ] ,
effect : "fade" ,
2010-12-08 16:28:12 +00:00
opacity : 0.7 ,
2010-12-10 14:38:30 +00:00
predelay : 800 ,
2010-12-08 16:28:12 +00:00
events : {
def : "mouseover,mouseout" ,
input : "mouseover,mouseout" ,
widget : "focus mouseover,blur mouseout" ,
tooltip : "mouseover,mouseout"
}
2010-11-01 18:39:03 +00:00
} ) ;
2010-07-27 19:50:01 +00:00
} ) ;
// Create disk table
diskFooter . append ( addDiskLink ) ;
diskTable . append ( diskHeader ) ;
diskTable . append ( diskBody ) ;
diskTable . append ( diskFooter ) ;
diskDiv . append ( diskLabel ) ;
diskDiv . append ( diskTable ) ;
2011-12-19 05:03:27 +00:00
hwAttr . append ( diskDiv ) ;
2010-07-27 19:50:01 +00:00
2010-11-01 14:19:14 +00:00
// Generate tooltips
provNew . find ( 'div input[title]' ) . tooltip ( {
2010-12-03 22:09:36 +00:00
position : "center right" ,
offset : [ - 2 , 10 ] ,
effect : "fade" ,
2010-12-08 16:28:12 +00:00
opacity : 0.7 ,
2010-12-10 14:38:30 +00:00
predelay : 800 ,
2010-12-08 16:28:12 +00:00
events : {
def : "mouseover,mouseout" ,
input : "mouseover,mouseout" ,
widget : "focus mouseover,blur mouseout" ,
tooltip : "mouseover,mouseout"
}
2010-11-01 14:19:14 +00:00
} ) ;
2010-07-27 19:50:01 +00:00
/ * *
* Provision new
* /
var provisionBtn = createButton ( 'Provision' ) ;
provisionBtn . 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-27 19:50:01 +00:00
var ready = true ;
var errMsg = '' ;
// Get tab ID
2011-10-25 14:53:59 +00:00
var thisTabId = $ ( this ) . parents ( '.ui-tabs-panel' ) . attr ( 'id' ) ;
2010-07-27 19:50:01 +00:00
// Get provision tab instance
var inst = thisTabId . replace ( 'zvmProvisionTab' , '' ) ;
// Check node name, userId, hardware control point, and group
2010-07-29 20:22:09 +00:00
var inputs = $ ( '#' + thisTabId + ' input:visible' ) ;
2010-07-27 19:50:01 +00:00
for ( var i = 0 ; i < inputs . length ; i ++ ) {
// Do not check OS or disk password
if ( ! inputs . eq ( i ) . val ( )
&& inputs . eq ( i ) . attr ( 'name' ) != 'os'
&& inputs . eq ( i ) . attr ( 'type' ) != 'password' ) {
inputs . eq ( i ) . css ( 'border' , 'solid #FF0000 1px' ) ;
ready = false ;
} else {
inputs . eq ( i ) . css ( 'border' , 'solid #BDBDBD 1px' ) ;
}
}
// Check user entry
var thisUserEntry = $ ( '#' + thisTabId + ' textarea:visible' ) ;
thisUserEntry . val ( thisUserEntry . val ( ) . toUpperCase ( ) ) ;
if ( ! thisUserEntry . val ( ) ) {
thisUserEntry . css ( 'border' , 'solid #FF0000 1px' ) ;
ready = false ;
} else {
thisUserEntry . css ( 'border' , 'solid #BDBDBD 1px' ) ;
}
2010-09-26 13:47:09 +00:00
// Show error message for missing inputs
if ( ! ready ) {
2011-12-19 05:03:27 +00:00
errMsg = errMsg + 'Please provide a value for each missing field.<br>' ;
2010-09-26 13:47:09 +00:00
}
2010-07-27 19:50:01 +00:00
// Check if user entry contains user ID
var thisUserId = $ ( '#' + thisTabId + ' input[name=userId]:visible' ) ;
var pos = thisUserEntry . val ( ) . indexOf ( 'USER ' + thisUserId . val ( ) . toUpperCase ( ) ) ;
if ( pos < 0 ) {
2010-09-26 13:40:16 +00:00
errMsg = errMsg + 'The directory entry does not contain the correct user ID.<br>' ;
2010-07-27 19:50:01 +00:00
ready = false ;
}
// If no operating system is specified, create only user entry
os = $ ( '#' + thisTabId + ' input[name=os]:visible' ) ;
2010-07-29 20:22:09 +00:00
2010-07-27 19:50:01 +00:00
// Check number of disks
var diskRows = $ ( '#' + thisTabId + ' table tr' ) ;
// If an OS is given, disks are needed
if ( os . val ( ) && ( diskRows . length < 1 ) ) {
2010-09-24 02:27:04 +00:00
errMsg = errMsg + 'You need to add at some disks.<br>' ;
2010-07-27 19:50:01 +00:00
ready = false ;
}
2010-09-01 15:36:05 +00:00
// Check address, size, mode, pool, and password
2010-07-27 19:50:01 +00:00
var diskArgs = $ ( '#' + thisTabId + ' table input:visible' ) ;
for ( var i = 0 ; i < diskArgs . length ; i ++ ) {
if ( ! diskArgs . eq ( i ) . val ( )
&& diskArgs . eq ( i ) . attr ( 'type' ) != 'password' ) {
diskArgs . eq ( i ) . css ( 'border' , 'solid #FF0000 1px' ) ;
ready = false ;
} else {
diskArgs . eq ( i ) . css ( 'border' , 'solid #BDBDBD 1px' ) ;
}
}
2012-03-14 19:20:37 +00:00
2010-07-27 19:50:01 +00:00
// If inputs are valid, ready to provision
if ( ready ) {
if ( ! os . val ( ) ) {
// If no OS is given, create a virtual server
var msg = '' ;
if ( diskRows . length > 0 ) {
2010-09-24 03:06:44 +00:00
msg = 'Do you want to create a virtual server without an operating system?' ;
} else {
// If no disks are given, create a virtual server (no disk)
msg = 'Do you want to create a virtual server without an operating system or disks?' ;
2010-07-27 19:50:01 +00:00
}
2010-09-24 03:06:44 +00:00
// Open dialog to confirm
var confirmDialog = $ ( '<div><p>' + msg + '</p></div>' ) ;
confirmDialog . dialog ( {
2011-12-01 04:10:40 +00:00
title : 'Confirm' ,
2010-09-24 03:06:44 +00:00
modal : true ,
width : 400 ,
buttons : {
"Ok" : function ( ) {
// Disable provision button
provisionBtn . attr ( 'disabled' , 'true' ) ;
// Show loader
$ ( '#zProvisionStatBar' + inst ) . show ( ) ;
$ ( '#zProvisionLoader' + inst ) . show ( ) ;
// Disable add disk button
addDiskLink . attr ( 'disabled' , 'true' ) ;
// Disable close button on disk table
$ ( '#' + thisTabId + ' table span' ) . unbind ( 'click' ) ;
// Disable all inputs
var inputs = $ ( '#' + thisTabId + ' input' ) ;
inputs . attr ( 'disabled' , 'disabled' ) ;
// Disable all selects
var selects = $ ( '#' + thisTabId + ' select' ) ;
selects . attr ( 'disabled' , 'disabled' ) ;
// Add a new line at the end of the user entry
var textarea = $ ( '#' + thisTabId + ' textarea' ) ;
var tmp = jQuery . trim ( textarea . val ( ) ) ;
textarea . val ( tmp + '\n' ) ;
textarea . attr ( 'readonly' , 'readonly' ) ;
textarea . css ( {
'background-color' : '#F2F2F2'
} ) ;
// Get node name
var node = $ ( '#' + thisTabId + ' input[name=nodeName]' ) . val ( ) ;
// Get userId
var userId = $ ( '#' + thisTabId + ' input[name=userId]' ) . val ( ) ;
// Get hardware control point
var hcp = $ ( '#' + thisTabId + ' input[name=hcp]' ) . val ( ) ;
// Get group
var group = $ ( '#' + thisTabId + ' input[name=group]' ) . val ( ) ;
2012-03-14 19:20:37 +00:00
// Get IP address and hostname
var ip = $ ( '#' + thisTabId + ' input[name=ip]' ) . val ( ) ;
var hostname = $ ( '#' + thisTabId + ' input[name=hostname]' ) . val ( ) ;
// Generate arguments to sent
var args = node + ';zvm.hcp=' + hcp
+ ';zvm.userid=' + userId
+ ';nodehm.mgt=zvm'
+ ';groups=' + group ;
if ( ip )
args += ';hosts.ip=' + ip ;
if ( hostname )
args += ';hosts.hostnames=' + hostname ;
2010-09-24 03:06:44 +00:00
/ * *
* ( 1 ) Define node
* /
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'nodeadd' ,
tgt : '' ,
2012-03-14 19:20:37 +00:00
args : args ,
2010-09-24 03:06:44 +00:00
msg : 'cmd=nodeadd;out=' + inst
} ,
success : updateZProvisionNewStatus
} ) ;
$ ( this ) . dialog ( "close" ) ;
2010-10-07 21:01:14 +00:00
} ,
"Cancel" : function ( ) {
$ ( this ) . dialog ( "close" ) ;
}
2010-09-24 03:06:44 +00:00
}
} ) ;
2010-07-27 19:50:01 +00:00
} else {
/ * *
* Create a virtual server and install OS
* /
// Disable provision button
2010-09-22 20:18:21 +00:00
$ ( this ) . attr ( 'disabled' , 'true' ) ;
2010-07-27 19:50:01 +00:00
// Show loader
$ ( '#zProvisionStatBar' + inst ) . show ( ) ;
$ ( '#zProvisionLoader' + inst ) . show ( ) ;
// Disable add disk button
2010-09-22 20:18:21 +00:00
addDiskLink . attr ( 'disabled' , 'true' ) ;
2010-07-27 19:50:01 +00:00
// Disable close button on disk table
$ ( '#' + thisTabId + ' table span' ) . unbind ( 'click' ) ;
// Disable all inputs
var inputs = $ ( '#' + thisTabId + ' input' ) ;
inputs . attr ( 'disabled' , 'disabled' ) ;
inputs . css ( {
'background-color' : '#F2F2F2'
} ) ;
// Disable all selects
var selects = $ ( '#' + thisTabId + ' select' ) ;
selects . attr ( 'disabled' , 'disabled' ) ;
selects . css ( {
'background-color' : '#F2F2F2'
} ) ;
// Add a new line at the end of the user entry
var textarea = $ ( '#' + thisTabId + ' textarea' ) ;
var tmp = jQuery . trim ( textarea . val ( ) ) ;
textarea . val ( tmp + '\n' ) ;
textarea . attr ( 'readonly' , 'readonly' ) ;
textarea . css ( {
'background-color' : '#F2F2F2'
} ) ;
// Get node name
var node = $ ( '#' + thisTabId + ' input[name=nodeName]' ) . val ( ) ;
// Get userId
var userId = $ ( '#' + thisTabId + ' input[name=userId]' ) . val ( ) ;
// Get hardware control point
var hcp = $ ( '#' + thisTabId + ' input[name=hcp]' ) . val ( ) ;
// Get group
var group = $ ( '#' + thisTabId + ' input[name=group]' ) . val ( ) ;
2012-03-14 19:20:37 +00:00
// Get IP address and hostname
var ip = $ ( '#' + thisTabId + ' input[name=ip]' ) . val ( ) ;
var hostname = $ ( '#' + thisTabId + ' input[name=hostname]' ) . val ( ) ;
// Generate arguments to sent
var args = node + ';zvm.hcp=' + hcp
+ ';zvm.userid=' + userId
+ ';nodehm.mgt=zvm'
+ ';groups=' + group ;
if ( ip )
args += ';hosts.ip=' + ip ;
if ( hostname )
args += ';hosts.hostnames=' + hostname ;
2010-07-27 19:50:01 +00:00
/ * *
* ( 1 ) Define node
* /
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'nodeadd' ,
tgt : '' ,
2012-03-14 19:20:37 +00:00
args : args ,
2010-07-27 19:50:01 +00:00
msg : 'cmd=nodeadd;out=' + inst
} ,
2010-07-29 20:22:09 +00:00
success : updateZProvisionNewStatus
2010-07-27 19:50:01 +00:00
} ) ;
}
} else {
2010-09-24 02:27:04 +00:00
// Show warning message
var warn = createWarnBar ( errMsg ) ;
warn . prependTo ( $ ( this ) . parent ( ) . parent ( ) ) ;
2010-07-27 19:50:01 +00:00
}
} ) ;
provNew . append ( provisionBtn ) ;
return provNew ;
2011-09-30 18:29:27 +00:00
}
/ * *
* Load zVMs into column ( service page )
*
* @ param col
* Table column where OS images will be placed
* @ return Nothing
* /
function loadzVMs ( col ) {
// Get group names and description and append to group column
var groupNames = $ . cookie ( 'srv_zvms' ) . split ( ',' ) ;
var radio , zvmBlock , args , zvm , hcp ;
for ( var i in groupNames ) {
args = groupNames [ i ] . split ( ':' ) ;
zvm = args [ 0 ] ;
hcp = args [ 1 ] ;
// Create block for each group
zvmBlock = $ ( '<div class="ui-state-default"></div>' ) . css ( {
'border' : '1px solid' ,
'max-width' : '200px' ,
'margin' : '5px auto' ,
'padding' : '5px' ,
'display' : 'block' ,
'vertical-align' : 'middle' ,
'cursor' : 'pointer' ,
'white-space' : 'normal'
} ) . click ( function ( ) {
$ ( this ) . children ( 'input:radio' ) . attr ( 'checked' , 'checked' ) ;
$ ( this ) . parents ( 'td' ) . find ( 'div' ) . attr ( 'class' , 'ui-state-default' ) ;
$ ( this ) . attr ( 'class' , 'ui-state-active' ) ;
} ) ;
radio = $ ( '<input type="radio" name="hcp" value="' + hcp + '"/>' ) . css ( 'display' , 'none' ) ;
2011-10-18 01:25:25 +00:00
zvmBlock . append ( radio , $ ( '<span style="font-weight: normal;"><b>' + zvm + '</b> managed by ' + hcp + '</span>' ) ) ;
2011-09-30 18:29:27 +00:00
zvmBlock . children ( 'span' ) . css ( {
'display' : 'block' ,
'margin' : '5px' ,
'text-align' : 'left'
} ) ;
col . append ( zvmBlock ) ;
}
}
/ * *
* Load groups into column
*
* @ param col
* Table column where OS images will be placed
* @ return Nothing
* /
2011-10-04 13:55:27 +00:00
function loadSrvGroups ( col ) {
2011-09-30 18:29:27 +00:00
// Get group names and description and append to group column
var groupNames = $ . cookie ( 'srv_groups' ) . split ( ',' ) ;
var groupBlock , radio , args , name , ip , hostname , desc ;
for ( var i in groupNames ) {
args = groupNames [ i ] . split ( ':' ) ;
name = args [ 0 ] ;
ip = args [ 1 ] ;
hostname = args [ 2 ] ;
desc = args [ 3 ] ;
// Create block for each group
groupBlock = $ ( '<div class="ui-state-default"></div>' ) . css ( {
'border' : '1px solid' ,
'max-width' : '200px' ,
'margin' : '5px auto' ,
'padding' : '5px' ,
'display' : 'block' ,
'vertical-align' : 'middle' ,
'cursor' : 'pointer' ,
'white-space' : 'normal'
} ) . click ( function ( ) {
$ ( this ) . children ( 'input:radio' ) . attr ( 'checked' , 'checked' ) ;
$ ( this ) . parents ( 'td' ) . find ( 'div' ) . attr ( 'class' , 'ui-state-default' ) ;
$ ( this ) . attr ( 'class' , 'ui-state-active' ) ;
} ) ;
radio = $ ( '<input type="radio" name="group" value="' + name + '"/>' ) . css ( 'display' , 'none' ) ;
2011-10-18 01:25:25 +00:00
groupBlock . append ( radio , $ ( '<span style="font-weight: normal;"><b>' + name + '</b>: ' + desc + '</span>' ) ) ;
2011-09-30 18:29:27 +00:00
groupBlock . children ( 'span' ) . css ( {
'display' : 'block' ,
'margin' : '5px' ,
'text-align' : 'left'
} ) ;
col . append ( groupBlock ) ;
}
}
/ * *
* Load OS images into column
*
* @ param col
* Table column where OS images will be placed
* @ return Nothing
* /
function loadOSImages ( col ) {
// Get group names and description and append to group column
var imgNames = $ . cookie ( 'srv_imagenames' ) . split ( ',' ) ;
var imgBlock , radio , args , name , desc ;
for ( var i in imgNames ) {
args = imgNames [ i ] . split ( ':' ) ;
name = args [ 0 ] ;
desc = args [ 1 ] ;
// Create block for each image
imgBlock = $ ( '<div class="ui-state-default"></div>' ) . css ( {
'border' : '1px solid' ,
'max-width' : '200px' ,
'margin' : '5px auto' ,
'padding' : '5px' ,
'display' : 'block' ,
'vertical-align' : 'middle' ,
'cursor' : 'pointer' ,
'white-space' : 'normal'
} ) . click ( function ( ) {
$ ( this ) . children ( 'input:radio' ) . attr ( 'checked' , 'checked' ) ;
$ ( this ) . parents ( 'td' ) . find ( 'div' ) . attr ( 'class' , 'ui-state-default' ) ;
$ ( this ) . attr ( 'class' , 'ui-state-active' ) ;
} ) ;
radio = $ ( '<input type="radio" name="image" value="' + name + '"/>' ) . css ( 'display' , 'none' ) ;
2011-10-18 01:25:25 +00:00
imgBlock . append ( radio , $ ( '<span style="font-weight: normal;"><b>' + name + '</b>: ' + desc + '</span>' ) ) ;
2011-09-30 18:29:27 +00:00
imgBlock . children ( 'span' ) . css ( {
'display' : 'block' ,
'margin' : '5px' ,
'text-align' : 'left'
} ) ;
col . append ( imgBlock ) ;
}
}
/ * *
* Set a cookie for zVM host names ( service page )
*
* @ param data
* Data from HTTP request
* @ return Nothing
* /
function setzVMCookies ( data ) {
if ( data . rsp ) {
var zvms = new Array ( ) ;
for ( var i = 0 ; i < data . rsp . length ; i ++ ) {
zvms . push ( data . rsp [ i ] ) ;
}
// Set cookie to expire in 60 minutes
var exDate = new Date ( ) ;
exDate . setTime ( exDate . getTime ( ) + ( 240 * 60 * 1000 ) ) ;
$ . cookie ( 'srv_zvms' , zvms , { expires : exDate } ) ;
}
}
/ * *
* Set a cookie for disk pool names of a given node ( service page )
*
* @ param data
* Data from HTTP request
* @ return Nothing
* /
function setDiskPoolCookies ( data ) {
if ( data . rsp ) {
var node = data . msg ;
var pools = data . rsp [ 0 ] . split ( node + ': ' ) ;
for ( var i in pools ) {
pools [ i ] = jQuery . trim ( pools [ i ] ) ;
}
// Set cookie to expire in 60 minutes
var exDate = new Date ( ) ;
exDate . setTime ( exDate . getTime ( ) + ( 240 * 60 * 1000 ) ) ;
$ . cookie ( node + 'diskpools' , pools , { expires : exDate } ) ;
}
}
/ * *
* Create virtual machine ( service page )
*
* @ param tabId
* Tab ID
* @ param group
* Group
* @ param hcp
* Hardware control point
* @ param img
* OS image
* @ return Nothing
* /
function createzVM ( tabId , group , hcp , img , owner ) {
// Submit request to create VM
// webportal provzlinux [group] [hcp] [image] [owner]
2011-10-14 00:02:12 +00:00
var iframe = createIFrame ( 'lib/srv_cmd.php?cmd=webportal&tgt=&args=provzlinux;' + group + ';' + hcp + ';' + img + ';' + owner + '&msg=&opts=flush' ) ;
iframe . prependTo ( $ ( '#' + tabId ) ) ;
2010-07-15 22:57:48 +00:00
}