/*"use strict"; */
/**
* Global variables
*/
var diskDatatable; // zVM datatable containing disks
var zfcpDatatable; // zVM datatable containing zFCP devices
var networkDatatable; // zVM datatable containing networks
var builtInXCAT = 1; // 1 means xCAT shipped with zVM
var zhcpQueryCountForDisks = 0;
var zhcpQueryCountForZfcps = 0;
var zhcpQueryCountForNetworks = 0;
var selectedNetworkHash; // Network details for each network
/**
* Get the disk datatable
*
* @return Data table object
*/
function getDiskDataTable() {
return diskDatatable;
}
/**
* Set the disk datatable
*
* @param table Data table object
*/
function setDiskDataTable(table) {
diskDatatable = table;
}
/**
* Get the zFCP datatable
*
* @return Data table object
*/
function getZfcpDataTable() {
return zfcpDatatable;
}
/**
* Set the zFCP datatable
*
* @param table Data table object
*/
function setZfcpDataTable(table) {
zfcpDatatable = table;
}
/**
* Get the network datatable
*
* @return Data table object
*/
function getNetworkDataTable() {
return networkDatatable;
}
/**
* Set the network datatable
*
* @param table Data table object
*/
function setNetworkDataTable(table) {
networkDatatable = table;
}
/**
* Get the selectedNetworkHash datatable
*
* @return selectedNetworkHash two dimensional hash table object
*/
function getselectedNetworkHash() {
return selectedNetworkHash;
}
/**
* Set the selectedNetworkHash two dimensional hash table
*
* @param table selectedNetworkHash object
*/
function setselectedNetworkHash(table) {
selectedNetworkHash = table;
}
/**
* Display hcp node pool lookup finished
*/
function displayNodeHcpFinished(count){
var infoBar = getNodesTabInfoBar();
if (infoBar !== null) {
if (count <= 0) {
infoBar.append(" Done.");
}else {
infoBar.append(" .");
}
}
}
/**
* Load HCP specific info
*
* @param data Data from HTTP request
*/
function loadHcpInfo(data) {
var args = data.msg.split(';');
var findingPools = 0;
var findingPoolsCount = 0;
// 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;
if (!userEntry.length)
return;
// Get Nodes info bar
var nodeInfoBar = getNodesTabInfoBar();
//nodeInfoBar.append("\nEntering loadHcpInfo Load...\n");
if (userEntry[0].indexOf('Failed') < 0) {
if (hcp) {
// If there is no cookie for the disk pool names
if (!$.cookie('xcat_' + hcp + 'diskpools') || $.cookie('xcat_' + hcp + 'diskpools') === null) {
if (nodeInfoBar !== null) {
nodeInfoBar.append(" Finding pools and networks...");
findingPools = 1;
findingPoolsCount++;
}
// Get disk pools
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'lsvm',
tgt : hcp,
args : '--diskpoolnames',
msg : hcp
},
success : function(data) {
data = decodeRsp(data);
setDiskPoolCookies(data);
},
complete : function() {
if (nodeInfoBar !== null) {
findingPoolsCount--;
displayNodeHcpFinished(findingPoolsCount);
}
}
});
}
// If there is no cookie for the zFCP pool names
if (!$.cookie('xcat_' + hcp + 'zfcppools') || $.cookie('xcat_' + hcp + 'zfcppools') === null) {
if (nodeInfoBar !== null) {
if (findingPools = 0) {
nodeInfoBar.append(" Finding pools and networks...");
}
findingPools = 1;
findingPoolsCount++;
}
// Get fcp pools
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'lsvm',
tgt : hcp,
args : '--zfcppoolnames',
msg : hcp
},
success : function(data) {
data = decodeRsp(data);
setZfcpPoolCookies(data);
},
complete : function() {
if (nodeInfoBar !== null) {
findingPoolsCount--;
displayNodeHcpFinished(findingPoolsCount);
}
}
});
}
// If there is no cookie for the network names
if (!$.cookie('xcat_' + hcp + 'networks') || $.cookie('xcat_' + hcp + 'networks') === null) {
if (nodeInfoBar !== null) {
if (findingPools = 0) {
nodeInfoBar.append(" Finding pools and networks...");
}
findingPools = 1;
findingPoolsCount++;
}
// Get network names
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'lsvm',
tgt : hcp,
args : '--getnetworknames',
msg : hcp
},
success : function(data) {
data = decodeRsp(data);
setNetworkCookies(data);
},
complete : function() {
if (nodeInfoBar !== null) {
findingPoolsCount--;
displayNodeHcpFinished(findingPoolsCount);
}
}
});
}
} // End of if (hcp)
} else {
// Create warning dialog
var warning = createWarnBar('z/VM SMAPI is not responding to ' + hcp + '. SMAPI may need to be reset. '+userEntry[0]);
var warnDialog = $('
').append(warning);
// Open dialog
warnDialog.dialog({
title:'Warning',
modal: true,
close: function(){
$(this).remove();
},
width: 400,
buttons: {
"Ok": function() {
$(this).dialog("close");
}
}
});
}
}
/**
* Load user entry of a given node
*
* @param data Data from HTTP request
*/
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=', '');
// Get user directory entry
var userEntry = data.rsp[0].split(node + ':');
// Remove loader
$('#' + node + 'TabLoader').remove();
var toggleLinkId = node + 'ToggleLink';
$('#' + toggleLinkId).click(function() {
// Get text within this link
var lnkText = $(this).text();
// Toggle user entry division
$('#' + node + 'UserEntry').toggle();
// Toggle inventory division
$('#' + node + 'Inventory').toggle();
// Change text
if (lnkText == 'Show directory entry') {
$(this).text('Show inventory');
} else {
$(this).text('Show directory entry');
}
});
// Put user entry into a list
var fieldSet = $('');
var legend = $('');
fieldSet.append(legend);
var txtArea = $('');
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();
saveBtn.css('display', 'inline-table');
cancelBtn.css('display', 'inline-table');
});
/**
* Save
*/
var saveBtn = createButton('Save').hide();
saveBtn.bind('click', function(event) {
// Show loader
$('#' + node + 'StatusBarLoader').show();
$('#' + node + 'StatusBar').show();
// 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 : function(data) {
data = decodeRsp(data);
updateZNodeStatus(data);
}
});
// Increment node process and save it in a cookie
incrementNodeProcess(node);
txtArea.attr('readonly', 'readonly');
txtArea.css( {
'border-width' : '0px'
});
// Disable save button
$(this).hide();
cancelBtn.hide();
});
/**
* Cancel
*/
var cancelBtn = createButton('Cancel').hide();
cancelBtn.bind('click', function(event) {
txtArea.attr('readonly', 'readonly');
txtArea.css( {
'border-width' : '0px'
});
cancelBtn.hide();
saveBtn.hide();
});
// Create info bar
var infoBar = createInfoBar('Double click on the directory entry to edit it.');
// Append user entry into division
$('#' + ueDivId).append(infoBar);
$('#' + ueDivId).append(fieldSet);
$('#' + ueDivId).append(saveBtn);
$('#' + ueDivId).append(cancelBtn);
}
/**
* Increment number of processes running against a node
*
* @param node Node to increment running processes
*/
function incrementNodeProcess(node) {
// Get current processes
var procs = $.cookie('xcat_' + node + 'processes');
if (procs) {
// One more process
procs = parseInt(procs) + 1;
$.cookie('xcat_' + node + 'processes', procs);
} else {
$.cookie('xcat_' + node + 'processes', 1);
}
}
/**
* Update provision new node status
*
* @param data Data returned from HTTP request
*/
function updateZProvisionNewStatus(data) {
// Parse ajax response
var rsp = data.rsp;
var args = data.msg.split(';');
var lastCmd = args[0].replace('cmd=', '');
var out2Id = args[1].replace('out=', '');
if (typeof console == "object"){
console.log("Entering updateZProvisionNewStatus. Last command:<"+lastCmd+"> All args:<"+args+">");
}
// IDs for status bar, tab, and loader
var statBarId = 'zProvisionStatBar' + out2Id;
var tabId = 'zvmProvisionTab' + out2Id;
var loaderId = 'zProvisionLoader' + out2Id;
var node = $('#' + tabId + ' input[name=nodeName]').val();
/**
* (2) Create user entry
*/
if (lastCmd == 'nodeadd') {
if (rsp.length) {
$('#' + loaderId).hide();
$('#' + statBarId).find('div').append('
');
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'makedns',
tgt : '',
args : '',
msg : 'cmd=makedns;out=' + out2Id
},
success : function(data) {
data = decodeRsp(data);
updateZProvisionNewStatus(data);
}
});
}
}
/**
* If built in zVM xcat and last command was makehosts or
* If sourceforge xCAT and lastCmd was makedns
* (5) Add disk
*
*/
else if (((lastCmd == 'makehosts') && (builtInXCAT == 1)) ||
((lastCmd == 'makedns') && (builtInXCAT == 0))) {
// Write ajax response to status bar
var prg = writeRsp(rsp, '');
$('#' + statBarId).find('div').append(prg);
// If there was an error, quit
if (rsp.length) {
$('#' + loaderId).hide();
if (builtInXCAT == 1) {
$('#' + statBarId).find('div').append('
');
}
// Set cookie for number of disks
var diskRows = $('#' + tabId + ' table:eq(0):visible tbody tr');
$.cookie('xcat_disks2add' + out2Id, diskRows.length, {path: '/xcat', secure:true });
if (diskRows.length > 0) {
for (var i = 0; i < diskRows.length; i++) {
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();
var mode = diskArgs.eq(4).find('select').val();
var pool = diskArgs.eq(5).find('select').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') {
args = '--add' + type + ';' + pool + ';' + address + ';'
+ size + ';' + mode + ';' + password + ';'
+ password + ';' + password;
}
// Attach disk to node
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chvm',
tgt : node,
args : args,
msg : 'cmd=chvm-disk;out=' + out2Id
},
success : function(data) {
data = decodeRsp(data);
updateZProvisionNewStatus(data);
}
});
}
}
// Set cookie for number of zFCP devices
var zfcpRows = $('#' + tabId + ' table:eq(1):visible tbody tr');
$.cookie('xcat_zfcp2add' + out2Id, zfcpRows.length, {path: '/xcat', secure:true });
if (zfcpRows.length > 0) {
for ( var i = 0; i < zfcpRows.length; i++) {
var diskArgs = zfcpRows.eq(i).find('td');
var address = diskArgs.eq(1).find('input').val();
var size = diskArgs.eq(2).find('input').val();
var pool = diskArgs.eq(3).find('select').val();
var tag = diskArgs.eq(4).find('input').val();
var portName = diskArgs.eq(5).find('input').val();
var unitNo = diskArgs.eq(6).find('input').val();
// This is either true or false
var loaddev = diskArgs.eq(7).find('input').attr('checked');
if (loaddev) {
loaddev = "1";
} else {
loaddev = "0";
}
// Create ajax arguments
var args = '--addzfcp;' + pool + ';' + address + ';' + loaddev + ';' + size;
if (tag && tag != "null") {
args += ';' + tag;
} else {
args += ';';
}
if (portName && tag != "null") {
args += ';' + portName;
} else {
args += ';';
} if (unitNo && tag != "null") {
args += ';' + unitNo;
} else {
args += ';';
}
// Attach zFCP device to node
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chvm',
tgt : node,
args : args,
msg : 'cmd=chvm-zfcp;out=' + out2Id
},
success : function(data) {
data = decodeRsp(data);
updateZProvisionNewStatus(data);
}
});
}
}
// Done if no disks to add
if (diskRows.length < 1 && zfcpRows.length < 1) {
$('#' + statBarId).find('div').append('
No disks found to provison, finished.
');
$('#' + loaderId).hide();
}
}
}
/**
* (6) Set operating system for given node
*/
else if (lastCmd == 'chvm-disk' || lastCmd == 'chvm-zfcp') {
// Write ajax response to status bar
var prg = writeRsp(rsp, '');
$('#' + statBarId).find('div').append(prg);
// If there was an error, quit
if (containErrors(prg.html())) {
$('#' + loaderId).hide();
} else {
// Set cookie for number of disks
// One less disk to add
var disks2add = $.cookie('xcat_disks2add' + out2Id);
if (lastCmd == 'chvm-disk') {
if (disks2add > 0) {
disks2add--;
$.cookie('xcat_disks2add' + out2Id, disks2add, {path: '/xcat', secure:true });
}
}
var zfcp2add = $.cookie('xcat_zfcp2add' + out2Id);
if (lastCmd == 'chvm-zfcp') {
if (zfcp2add > 0) {
zfcp2add--;
$.cookie('xcat_zfcp2add' + out2Id, zfcp2add, {path: '/xcat', secure:true });
}
}
// Only set operating system if there are no more disks to add
if (zfcp2add < 1 && disks2add < 1) {
// If an operating system image is given
var osImage = $('#' + tabId + ' select[name=os]:visible').val();
if (osImage) {
// Get operating system, architecture, provision method, and profile
var tmp = osImage.split('-');
var os = tmp[0];
var arch = tmp[1];
var profile = tmp[3];
// If the last disk is added
$.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
},
success : function(data) {
data = decodeRsp(data);
updateZProvisionNewStatus(data);
}
});
} else {
$('#' + loaderId).hide();
}
}
}
}
/**
* (7) If sourceforge xCAT Update DHCP
*/
else if ((lastCmd == 'noderes') && (builtInXCAT == 0)) {
// If there was an error, do not continue
if (rsp.length) {
$('#' + loaderId).hide();
$('#' + statBarId).find('div').append('
');
}
// Prepare node for boot
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'nodeset',
tgt : node,
args : 'install',
msg : 'cmd=nodeset;out=' + out2Id
},
success : function(data) {
data = decodeRsp(data);
updateZProvisionNewStatus(data);
}
});
}
}
/**
* (9) Boot node to network
*/
else if (lastCmd == 'nodeset') {
// Write ajax response to status bar
var prg = writeRsp(rsp, '');
$('#' + statBarId).find('div').append(prg);
// If there was an error
// Do not continue
if (containErrors(prg.html())) {
$('#' + loaderId).hide();
} else {
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'rnetboot',
tgt : node,
args : 'ipl=000C',
msg : 'cmd=rnetboot;out=' + out2Id
},
success : function(data) {
data = decodeRsp(data);
updateZProvisionNewStatus(data);
}
});
}
}
/**
* (10) Done
*/
else if (lastCmd == 'rnetboot') {
// Write ajax response to status bar
var prg = writeRsp(rsp, '');
$('#' + statBarId).find('div').append(prg);
if (prg.html().indexOf('Error') < 0) {
$('#' + statBarId).find('div').append('
Open a VNC viewer to see the installation progress. It might take a couple of minutes before you can connect.
');
}
// Hide loader
$('#' + loaderId).hide();
}
}
/**
* Update the provision existing node status
*
* @param data Data returned from HTTP request
*/
function updateZProvisionExistingStatus(data) {
// 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=', '');
if (typeof console == "object"){
console.log("Entering updateZProvisionExistingStatus. Last command:<"+cmd+"> All args:<"+args+">");
}
// Get provision tab and status bar ID
var statBarId = 'zProvisionStatBar' + inst;
var tabId = 'zvmProvisionTab' + inst;
/**
* (2) Prepare node for boot
*/
if (cmd == 'nodeadd') {
// Get operating system
var bootMethod = $('#' + tabId + ' select[name=bootMethod]').val();
// Get nodes that were checked
var dTableId = 'zNodesDatatable' + inst;
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
},
success : function(data) {
data = decodeRsp(data);
updateZProvisionExistingStatus(data);
}
});
}
/**
* (3) Boot node from network
*/
else if (cmd == 'nodeset') {
// Write ajax response to status bar
var prg = writeRsp(rsp, '');
$('#' + statBarId).find('div').append(prg);
// If there was an error, do not continue
if (containErrors(prg.html())) {
var loaderId = 'zProvisionLoader' + inst;
$('#' + loaderId).remove();
return;
}
// Get nodes that were checked
var dTableId = 'zNodesDatatable' + inst;
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
},
success : function(data) {
data = decodeRsp(data);
updateZProvisionExistingStatus(data);
}
});
}
/**
* (4) Done
*/
else if (cmd == 'rnetboot') {
// Write ajax response to status bar
var prg = writeRsp(rsp, '');
$('#' + statBarId).find('div').append(prg);
if (prg.html().indexOf('Error') < 0) {
$('#' + statBarId).find('div').append('
Open a VNC viewer to see the installation progress. It might take a couple of minutes before you can connect.
');
}
var loaderId = 'zProvisionLoader' + inst;
$('#' + loaderId).remove();
}
}
/**
* Update zVM node status
*
* @param data Data returned from HTTP request
*/
function updateZNodeStatus(data) {
var node = data.msg;
var rsp = data.rsp;
// Get cookie for number processes performed against this node
var actions = $.cookie('xcat_' + node + 'processes');
// One less process
actions = actions - 1;
$.cookie('xcat_' + node + 'processes', actions, {path: '/xcat', secure:true });
if (actions < 1) {
// Hide loader when there are no more processes
var statusBarLoaderId = node + 'StatusBarLoader';
$('#' + statusBarLoaderId).hide();
}
var statBarId = node + 'StatusBar';
// Write ajax response to status bar
var prg = writeRsp(rsp, node + ': ');
$('#' + statBarId).find('div').append(prg);
}
/**
* Update clone status
*
* @param data Data returned from HTTP request
*/
function updateZCloneStatus(data) {
// Get ajax response
var rsp = data.rsp;
var args = data.msg.split(';');
var cmd = args[0].replace('cmd=', '');
// Get provision instance
var inst = args[1].replace('inst=', '');
// Get output division ID
var out2Id = args[2].replace('out=', '');
/**
* (2) Update /etc/hosts
*/
if (cmd == 'nodeadd') {
var node = args[3].replace('node=', '');
// If there was an error, do not continue
if (rsp.length) {
$('#' + out2Id).find('img').hide();
$('#' + out2Id).find('div').append('
(Error) Failed to create node definition
');
} else {
$('#' + out2Id).find('div').append('
Node definition created for ' + node + '
');
// 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
},
success : function(data) {
data = decodeRsp(data);
updateZCloneStatus(data);
}
});
}
}
}
/**
* (3a) Update DNS if source forge xCAT then do makedns
*/
else if ((cmd == 'makehosts') && (builtInXCAT == 0)) {
// Write ajax response to status bar
var prg = writeRsp(rsp, '');
$('#' + out2Id).find('div').append(prg);
// If there was an error, do not continue
if (rsp.length) {
$('#' + out2Id).find('img').hide();
$('#' + out2Id).find('div').append('
(Error) Failed to update /etc/hosts
');
} else {
$('#' + out2Id).find('div').append('
/etc/hosts updated
');
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'makedns',
tgt : '',
args : '',
msg : 'cmd=makedns;inst=' + inst + ';out=' + out2Id
},
success : function(data) {
data = decodeRsp(data);
updateZCloneStatus(data);
}
});
}
}
/**
* (3b) Update DNS for built in xCAT and clone
* Just clone for sourceforge xCAT
*/
else if (((cmd == 'makehosts') && (builtInXCAT == 1)) ||
((cmd == 'makedns') && (builtInXCAT == 0))) {
// Write ajax response to status bar
var prg = writeRsp(rsp, '');
$('#' + out2Id).find('div').append(prg);
// If there was an error, do not continue
if (rsp.length) {
$('#' + out2Id).find('img').hide();
if (builtInXCAT == 1) {
$('#' + out2Id).find('div').append('
(Error) Failed to update /etc/hosts
');
} else {
$('#' + out2Id).find('div').append('
(Error) Failed to makedns
');
}
}
// 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('-');
// 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
var nodeEnd = parseInt(tmp[1].match(/\d+/));
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;
}
// 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
},
error: function(jqXHR, textStatus) {
$('#' + out2Id).find('div').append('
(Error) Failed in clone call with ' + textStatus + '
');
},
success : function(data) {
data = decodeRsp(data);
updateZCloneStatus(data);
}
});
}
/**
* (5) Done
*/
else if (cmd == 'mkvm') {
// Write ajax response to status bar
var prg = writeRsp(rsp, '');
$('#' + out2Id).find('div').append(prg);
// Hide loader
$('#' + out2Id).find('img').hide();
}
}
/**
* Get zVM resources
*
* @param data Data from HTTP request
*/
function getZResources(data) {
var tabId = 'zvmResourceTab';
var info = createInfoBar('Manage storage and networks');
$('#' + tabId).append(info);
// Do not continue if there is no output
if (data.rsp.length) {
if (typeof console == "object"){
console.log("Entering getZResources.");
}
// Push hardware control points into an array
var node, hcp;
var hcpHash = new Object();
var hostnameHash = new Object();
for (var i in data.rsp) {
node = data.rsp[i][0];
hcp = data.rsp[i][1];
// data will be coming in like "xcat xcat.endicott.ibm.com hosts.hostnames"
// or xcat zhcp.endicott.ibm.com zvm.hcp"
if (data.rsp[i][2]== "zvm.hcp") {
hcpHash[hcp] = 1;
} else {
if (hcp.length) {
hostnameHash[hcp] = node;
}
}
}
// Create an array for hardware control points
var hcps = new Array();
for (var key in hcpHash) {
// Get the short host name
//hcp = key.split('.')[0]; //old code
hcp = hostnameHash[key];
if (typeof console == "object"){
console.log("getZResources lookup for hostname "+key+" found nodename <"+hcp+">");
}
if (jQuery.inArray(hcp, hcps) == -1) {
hcps.push(hcp);
}
}
// Set hardware control point cookie
$.cookie('xcat_hcp', hcps, {path: '/xcat', secure:true });
// Delete loader
$('#' + tabId).find('img[src="images/loader.gif"]').remove();
// Create accordion panel for disk
var resourcesAccordion = $('');
var diskSection = $('');
var diskLnk = $('
').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('xcat_hcp').indexOf(',') > -1) {
hcps = $.cookie('xcat_hcp').split(',');
} else {
hcps.push($.cookie('xcat_hcp'));
}
// Query the disk pools for each hcp
var panelId = 'zvmDiskResource';
var info = $('#' + panelId).find('.ui-state-highlight');
if (!info.length) {
info = createInfoBar("Querying "+hcps.length+" zhcp(s) for disk pools.");
$('#' + panelId).append(info);
}
zhcpQueryCountForDisks = hcps.length;
for (var i in hcps) {
var itemcount = +i + 1;
info.append(" Querying disk pools from: "+hcps[i]+" ("+itemcount+" of "+hcps.length+")");
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'lsvm',
tgt : hcps[i],
args : '--diskpoolnames',
msg : hcps[i]
},
success : function(data) {
data = decodeRsp(data);
getDiskPool(data);
}
});
zhcpQueryCountForDisks--;
}
});
// Create accordion panel for zFCP devices
var zfcpSection = $('');
var zfcpLnk = $('
').click(function () {
// Do not load panel again if it is already loaded
if ($('#zfcpResource').children().length)
return;
else
$('#zfcpResource').append(createLoader(''));
// Resize accordion
$('#zvmResourceAccordion').accordion('resize');
// Create a array for hardware control points
var hcps = new Array();
if ($.cookie('xcat_hcp').indexOf(',') > -1) {
hcps = $.cookie('xcat_hcp').split(',');
} else {
hcps.push($.cookie('xcat_hcp'));
}
// Query the fcp pools for each hcp
var panelId = 'zfcpResource';
var info = $('#' + panelId).find('.ui-state-highlight');
if (!info.length) {
info = createInfoBar("Querying "+hcps.length+" zhcp(s) for fcp pools.");
$('#' + panelId).append(info);
}
zhcpQueryCountForZfcps = hcps.length;
for (var i in hcps) {
// Gather fcp pools from hardware control points
var itemcount = +i + 1;
info.append(" Querying fcp pools from: "+hcps[i]+" ("+itemcount+" of "+hcps.length+")");
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'lsvm',
tgt : hcps[i],
args : '--zfcppoolnames',
msg : hcps[i]
},
success : function(data) {
data = decodeRsp(data);
getZfcpPool(data);
}
});
zhcpQueryCountForZfcps--;
}
});
// Create accordion panel for network
var networkSection = $('');
var networkLnk = $('
').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('xcat_hcp').indexOf(',') > -1) {
hcps = $.cookie('xcat_hcp').split(',');
} else {
hcps.push($.cookie('xcat_hcp'));
}
// Query the networks for each
var panelId = 'zvmNetworkResource';
var info = $('#' + panelId).find('.ui-state-highlight');
if (!info.length) {
info = createInfoBar("Querying "+hcps.length+" zhcp(s) for networks.");
$('#' + panelId).append(info);
}
zhcpQueryCountForNetworks = hcps.length;
for (var i in hcps) {
var itemcount = +i + 1;
info.append(" Querying networks from: "+hcps[i]+" ("+itemcount+" of "+hcps.length+")");
$('#zvmResourceAccordion').accordion('resize');
// 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 : function(data) {
data = decodeRsp(data);
getNetwork(data);
}
});
zhcpQueryCountForNetworks--;
}
});
resourcesAccordion.append(diskLnk, diskSection, zfcpLnk, zfcpSection, networkLnk, networkSection);
// Append accordion to tab
$('#' + tabId).append(resourcesAccordion);
resourcesAccordion.accordion();
networkLnk.trigger('click');
}
}
/**
* 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
*/
function getAttrs(keys, propNames, data) {
// Create hash table for property values
var attrs = new Object();
// Go through inventory and separate each property out
var curKey = null; // 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;
}
/**
* Create add processor dialog
*
* @param node Node to add processor to
*/
function openAddProcDialog(node) {
// Create form to add processor
var addProcForm = $('');
// Create info bar
var info = createInfoBar('Add a temporary processor to this virtual server.');
addProcForm.append(info);
addProcForm.append('');
addProcForm.append('');
// Create drop down for processor type
var procType = $('');
procType.append('');
var typeSelect = $('');
typeSelect.append(''
+ ''
+ ''
+ ''
);
procType.append(typeSelect);
addProcForm.append(procType);
// Generate tooltips
addProcForm.find('div input[title],select[title]').tooltip({
position: "center right",
offset: [-2, 10],
effect: "fade",
opacity: 0.8,
delay: 0,
predelay: 800,
events: {
def: "mouseover,mouseout",
input: "mouseover,mouseout",
widget: "focus mouseover,blur mouseout",
tooltip: "mouseover,mouseout"
},
// Change z index to show tooltip in front
onBeforeShow: function() {
this.getTip().css('z-index', $.topZIndex());
}
});
// Open dialog to add processor
addProcForm.dialog({
title:'Add processor',
modal: true,
close: function(){
$(this).remove();
},
width: 400,
buttons: {
"Ok": function(){
// Remove any warning messages
$(this).find('.ui-state-error').remove();
// Get inputs
var node = $(this).find('input[name=procNode]').val();
var address = $(this).find('input[name=procAddress]').val();
var type = $(this).find('select[name=procType]').val();
// If inputs are not complete, show warning message
if (!node || !address || !type) {
var warn = createWarnBar('Please provide a value for each missing field.');
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 : function(data) {
data = decodeRsp(data);
updateZNodeStatus(data);
}
});
// Increment node process
incrementNodeProcess(node);
// Show loader
var statusId = node + 'StatusBar';
var statusBarLoaderId = node + 'StatusBarLoader';
$('#' + statusBarLoaderId).show();
$('#' + statusId).show();
// Close dialog
$(this).dialog( "close" );
}
},
"Cancel": function() {
$(this).dialog( "close" );
}
}
});
}
/**
* Create add disk dialog
*
* @param node Node to add disk to
* @param hcp Hardware control point of node
*/
function openAddDiskDialog(node, hcp) {
// Get list of disk pools
var cookie = $.cookie('xcat_' + hcp + 'diskpools');
var pools = new Array();
if (cookie) {
pools = cookie.split(',');
}
// Create form to add disk
var addDiskForm = $('');
// Create info bar
var info = createInfoBar('Add a ECKD|3390 or FBA|9336 disk to this virtual server.');
addDiskForm.append(info);
addDiskForm.append('');
addDiskForm.append('');
addDiskForm.append('');
addDiskForm.append('');
// Create drop down for disk pool
var diskPool = $('');
diskPool.append('');
var poolSelect = $('');
for ( var i = 0; i < pools.length; i++) {
if( !pools[i] || 0 === pools[i].length) continue;
poolSelect.append('');
}
diskPool.append(poolSelect);
addDiskForm.append(diskPool);
// Create drop down for disk mode
var diskMode = $('');
diskMode.append('');
var modeSelect = $('');
modeSelect.append(''
+ ''
+ ''
+ ''
+ ''
+ ''
+ ''
);
diskMode.append(modeSelect);
addDiskForm.append(diskMode);
addDiskForm.append('');
// Generate tooltips
addDiskForm.find('div input[title],select[title]').tooltip({
position: "center right",
offset: [-2, 10],
effect: "fade",
opacity: 0.8,
delay: 0,
predelay: 800,
events: {
def: "mouseover,mouseout",
input: "mouseover,mouseout",
widget: "focus mouseover,blur mouseout",
tooltip: "mouseover,mouseout"
},
// Change z index to show tooltip in front
onBeforeShow: function() {
this.getTip().css('z-index', $.topZIndex());
}
});
// Open dialog to add disk
addDiskForm.dialog({
title:'Add disk',
modal: true,
close: function(){
$(this).remove();
},
width: 400,
buttons: {
"Ok": function(){
// Remove any warning messages
$(this).find('.ui-state-error').remove();
// Get inputs
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();
// If inputs are not complete, show warning message
if (!node || !type || !address || !size || !pool || !mode) {
var warn = createWarnBar('Please provide a value for each missing field.');
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 : function(data) {
data = decodeRsp(data);
updateZNodeStatus(data);
}
});
// 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
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chvm',
tgt : node,
args : '--add9336;' + pool + ';' + address + ';' + size
+ ';' + mode + ';' + password + ';' + password + ';' + password,
msg : node
},
success : function(data) {
data = decodeRsp(data);
updateZNodeStatus(data);
}
});
// 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
},
"Cancel": function() {
$(this).dialog( "close" );
}
}
});
}
/**
* Create add zFCP device dialog
*
* @param node Node to add disk to
* @param hcp Hardware control point of node
* @param zvm The z/VM system of node
*/
function openAddZfcpDialog(node, hcp, zvm) {
// Get list of disk pools
var cookie = $.cookie('xcat_' + hcp + 'zfcppools');
var pools = new Array();
if (cookie) {
pools = cookie.split(',');
}
// Create form to add disk
var addZfcpForm = $('');
// Create info bar
var info = createInfoBar('Add a SCSI|FCP disk to this virtual server.');
addZfcpForm.append(info);
addZfcpForm.append('');
addZfcpForm.append('');
addZfcpForm.append('');
addZfcpForm.append('');
// Create drop down for disk pool
var diskPool = $('');
diskPool.append('');
var poolSelect = $('');
for ( var i = 0; i < pools.length; i++) {
if( !pools[i] || 0 === pools[i].length) continue;
poolSelect.append('');
}
diskPool.append(poolSelect);
addZfcpForm.append(diskPool);
// Tag to identify where device will be used
addZfcpForm.append('');
// Create advanced link to set advanced zFCP properties
var advancedLnk = $('');
addZfcpForm.append(advancedLnk);
var advanced = $('').hide();
addZfcpForm.append(advanced);
var portName = $('');
var unitNo = $('');
advanced.append(portName, unitNo);
// Toggle port name and unit number when clicking on advanced link
advancedLnk.click(function() {
advanced.toggle();
});
// Generate tooltips
addZfcpForm.find('div input[title],select[title]').tooltip({
position: "center right",
offset: [-2, 10],
effect: "fade",
opacity: 0.8,
delay: 0,
predelay: 800,
events: {
def: "mouseover,mouseout",
input: "mouseover,mouseout",
widget: "focus mouseover,blur mouseout",
tooltip: "mouseover,mouseout"
},
// Change z index to show tooltip in front
onBeforeShow: function() {
this.getTip().css('z-index', $.topZIndex());
}
});
// Open dialog to add disk
addZfcpForm.dialog({
title:'Add zFCP device',
modal: true,
close: function(){
$(this).remove();
},
width: 400,
buttons: {
"Ok": function(){
// Remove any warning messages
$(this).find('.ui-state-error').remove();
// Get inputs
var node = $(this).find('input[name=diskNode]').val();
var address = $(this).find('input[name=diskAddress]').val();
var loaddev = $(this).find('input[name=diskLoaddev]');
var size = $(this).find('input[name=diskSize]').val();
var pool = $(this).find('select[name=diskPool]').val();
var tag = $(this).find('input[name=diskTag]').val();
var portName = $(this).find('input[name=diskPortName]').val();
var unitNo = $(this).find('input[name=diskUnitNo]').val();
// If inputs are not complete, show warning message
if (!node || !address || !size || !pool) {
var warn = createWarnBar('Please provide a value for each missing field.');
warn.prependTo($(this));
} else {
if (loaddev.attr('checked')) {
loaddev = 1;
} else {
loaddev = 0;
}
var args = '--addzfcp||' + pool + '||' + address + '||' + loaddev + '||' + size;
if (tag && tag != "null") {
args += '||' + tag;
} else {
args += '|| ""';
}
if ((portName && portName != "null") && (unitNo && unitNo != "null")) {
args += '||' + portName + '||' + unitNo;
}
// Add zFCP device
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chvm',
tgt : node,
args : args,
msg : node
},
success : function(data) {
data = decodeRsp(data);
updateZNodeStatus(data);
}
});
// Increment node process
incrementNodeProcess(node);
// Show loader
var statusId = node + 'StatusBar';
var statusBarLoaderId = node + 'StatusBarLoader';
$('#' + statusBarLoaderId).show();
$('#' + statusId).show();
// Close dialog
$(this).dialog( "close" );
}
},
"Cancel": function() {
$(this).dialog( "close" );
}
}
});
}
/**
* Create dedicate device dialog
*
* @param node Node to dedicate device to
* @param hcp Hardware control point of node
*/
function openDedicateDeviceDialog(node, hcp) {
// Create form to add disk
var dedicateForm = $('');
// Create info bar
var info = createInfoBar('Add a dedicated device to the configuration');
dedicateForm.append(info);
dedicateForm.append('');
dedicateForm.append('');
dedicateForm.append('');
dedicateForm.append('
');
// Generate tooltips
dedicateForm.find('div input[title],select[title]').tooltip({
position: "center right",
offset: [-2, 10],
effect: "fade",
opacity: 0.8,
delay: 0,
predelay: 800,
events: {
def: "mouseover,mouseout",
input: "mouseover,mouseout",
widget: "focus mouseover,blur mouseout",
tooltip: "mouseover,mouseout"
},
// Change z index to show tooltip in front
onBeforeShow: function() {
this.getTip().css('z-index', $.topZIndex());
}
});
// Open dialog to add dedicated device
dedicateForm.dialog({
title:'Add dedicated device',
modal: true,
close: function(){
$(this).remove();
},
width: 400,
buttons: {
"Ok": function(){
// Remove any warning messages
$(this).find('.ui-state-error').remove();
// Get inputs
var node = $(this).find('input[name=diskNode]').val();
var vAddress = $(this).find('input[name=virtualAddress]').val();
var rAddress = $(this).find('input[name=realAddress]').val()
var mode = $(this).find('select[name=mode]').val();
// If inputs are not complete, show warning message
if (!node || !vAddress || !rAddress || !mode) {
var warn = createWarnBar('Please provide a value for each missing field.');
warn.prependTo($(this));
} else {
var args = '--dedicatedevice;' + vAddress + ';' + rAddress + ';' + mode;
// Add zFCP device
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chvm',
tgt : node,
args : args,
msg : node
},
success : function(data) {
data = decodeRsp(data);
updateZNodeStatus(data);
}
});
// Increment node process
incrementNodeProcess(node);
// Show loader
var statusId = node + 'StatusBar';
var statusBarLoaderId = node + 'StatusBarLoader';
$('#' + statusBarLoaderId).show();
$('#' + statusId).show();
// Close dialog
$(this).dialog( "close" );
}
},
"Cancel": function() {
$(this).dialog( "close" );
}
}
});
}
/**
* Create add ECKD to system dialog
*
* @param hcp Hardware control point of node
*/
function openAddEckd2SystemDialog(hcp) {
var dialogId = 'zvmAddEckd2System';
// Create form to add disk
var addE2SForm = $('');
// Obtain mapping for zHCP to zVM system
var hcp2zvm = new Object();
hcp2zvm = getHcpZvmHash();
var system = $('');
var systemSelect = $('');
system.append(systemSelect);
// Append options for hardware control points
//systemSelect.append($(''));
for (var hcp in hcp2zvm) {
systemSelect.append($(''));
}
// Create info bar
var info = createInfoBar('Dynamically add an ECKD disk to a running z/VM system.');
addE2SForm.append(info);
addE2SForm.append(system);
addE2SForm.append('');
// Generate tooltips
addE2SForm.find('div input[title],select[title]').tooltip({
position: "center right",
offset: [-2, 10],
effect: "fade",
opacity: 0.8,
delay: 0,
predelay: 800,
events: {
def: "mouseover,mouseout",
input: "mouseover,mouseout",
widget: "focus mouseover,blur mouseout",
tooltip: "mouseover,mouseout"
},
// Change z index to show tooltip in front
onBeforeShow: function() {
this.getTip().css('z-index', $.topZIndex());
}
});
// Open dialog to add disk
addE2SForm.dialog({
title:'Add ECKD to system',
modal: true,
close: function(){
$(this).remove();
},
width: 420,
buttons: {
"Ok": function(){
// Remove any warning messages
$(this).find('.ui-state-error').remove();
var system = $(this).find('select[name=system]').val();
var devnum = $(this).find('input[name=devNum]').val();
// If inputs are not complete, show warning message
var ready = true;
var args = new Array('select[name=system]', 'input[name=devNum]');
for (var i in args) {
if (!$(this).find(args[i]).val()) {
$(this).find(args[i]).css('border', 'solid #FF0000 1px');
ready = false;
} else {
$(this).find(args[i]).css('border', 'solid #BDBDBD 1px');
}
}
if (!ready) {
// Show warning message
var warn = createWarnBar('Please provide a value for each required field.');
warn.prependTo($(this));
return;
}
// Change dialog buttons
$(this).dialog('option', 'buttons', {
'Close': function() {$(this).dialog("close");}
});
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chhypervisor',
tgt : system,
args : "--addeckd;" + devnum,
msg : dialogId
},
success : function(data) {
data = decodeRsp(data);
updateResourceDialog(data);
}
});
},
"Cancel": function() {
$(this).dialog( "close" );
}
}
});
}
/**
* Create add Volume to system dialog
*
* @param hcp Hardware control point of node
*/
function openAddVolume2SystemDialog(hcp) {
var dialogId = 'zvmAddVolume2System';
// Create form to add volume
var addV2SForm = $('');
// Obtain mapping for zHCP to zVM system
var hcp2zvm = new Object();
hcp2zvm = getHcpZvmHash();
var system = $('');
var systemSelect = $('');
system.append(systemSelect);
// Append options for hardware control points
//systemSelect.append($(''));
for (var hcp in hcp2zvm) {
systemSelect.append($(''));
}
// Create info bar
var info = createInfoBar('Permanently add a volume to the z/VM system configuration.');
addV2SForm.append(info);
addV2SForm.append(system);
addV2SForm.append('');
addV2SForm.append('');
// Generate tooltips
addV2SForm.find('div input[title],select[title]').tooltip({
position: "center right",
offset: [-2, 10],
effect: "fade",
opacity: 0.8,
delay: 0,
predelay: 800,
events: {
def: "mouseover,mouseout",
input: "mouseover,mouseout",
widget: "focus mouseover,blur mouseout",
tooltip: "mouseover,mouseout"
},
// Change z index to show tooltip in front
onBeforeShow: function() {
this.getTip().css('z-index', $.topZIndex());
}
});
// Open dialog to add volume
addV2SForm.dialog({
title:'Add volume to system configuration',
modal: true,
close: function(){
$(this).remove();
},
width: 480,
buttons: {
"Ok": function(){
// Remove any warning messages
$(this).find('.ui-state-error').remove();
var system = $(this).find('select[name=system]').val();
var devnum = $(this).find('input[name=devNum]').val();
var volser = $(this).find('input[name=volser]').val();
// If inputs are not complete, show warning message
var ready = true;
var args = new Array('select[name=system]', 'input[name=devNum]', 'input[name=volser]' );
for (var i in args) {
if (!$(this).find(args[i]).val()) {
$(this).find(args[i]).css('border', 'solid #FF0000 1px');
ready = false;
} else {
$(this).find(args[i]).css('border', 'solid #BDBDBD 1px');
}
}
if (!ready) {
// Show warning message
var warn = createWarnBar('Please provide a value for each required field.');
warn.prependTo($(this));
return;
}
// Change dialog buttons
$(this).dialog('option', 'buttons', {
'Close': function() {$(this).dialog("close");}
});
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chhypervisor',
tgt : system,
args : "--addvolume;" + devnum + ";" + volser,
msg : dialogId
},
success : function(data) {
data = decodeRsp(data);
updateResourceDialog(data);
}
});
},
"Cancel": function() {
$(this).dialog( "close" );
}
}
});
}
/**
* Create remove Volume to system dialog
*
* @param hcp Hardware control point of node
*/
function openRemoveVolumeFromSystemDialog(hcp) {
var dialogId = 'zvmRemoveVolumeFromSystem';
// Create form to remove volume
var remVfromSForm = $('');
// Obtain mapping for zHCP to zVM system
var hcp2zvm = new Object();
hcp2zvm = getHcpZvmHash();
var system = $('');
var systemSelect = $('');
system.append(systemSelect);
// Append options for hardware control points
//systemSelect.append($(''));
for (var hcp in hcp2zvm) {
systemSelect.append($(''));
}
// Create info bar
var info = createInfoBar('Permanently remove a volume from the z/VM system configuration.');
remVfromSForm.append(info);
remVfromSForm.append(system);
remVfromSForm.append('');
remVfromSForm.append('');
// Generate tooltips
remVfromSForm.find('div input[title],select[title]').tooltip({
position: "center right",
offset: [-2, 10],
effect: "fade",
opacity: 0.8,
delay: 0,
predelay: 800,
events: {
def: "mouseover,mouseout",
input: "mouseover,mouseout",
widget: "focus mouseover,blur mouseout",
tooltip: "mouseover,mouseout"
},
// Change z index to show tooltip in front
onBeforeShow: function() {
this.getTip().css('z-index', $.topZIndex());
}
});
// Open dialog to remove volume
remVfromSForm.dialog({
title:'Remove volume from system configuration',
modal: true,
close: function(){
$(this).remove();
},
width: 580,
buttons: {
"Ok": function(){
// Remove any warning messages
$(this).find('.ui-state-error').remove();
var system = $(this).find('select[name=system]').val();
var devnum = $(this).find('input[name=devNum]').val();
var volser = $(this).find('input[name=volser]').val();
// If inputs are not complete, show warning message
var ready = true;
var args = new Array('select[name=system]', 'input[name=devNum]', 'input[name=volser]' );
for (var i in args) {
if (!$(this).find(args[i]).val()) {
$(this).find(args[i]).css('border', 'solid #FF0000 1px');
ready = false;
} else {
$(this).find(args[i]).css('border', 'solid #BDBDBD 1px');
}
}
if (!ready) {
// Show warning message
var warn = createWarnBar('Please provide a value for each required field.');
warn.prependTo($(this));
return;
}
// Change dialog buttons
$(this).dialog('option', 'buttons', {
'Close': function() {$(this).dialog("close");}
});
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chhypervisor',
tgt : system,
args : "--removevolume;" + devnum + ";" + volser,
msg : dialogId
},
success : function(data) {
data = decodeRsp(data);
updateResourceDialog(data);
}
});
},
"Cancel": function() {
$(this).dialog( "close" );
}
}
});
}
/**
* Create add page or spool dialog
*
* @param hcp Hardware control point of node
*/
function openAddPageSpoolDialog(hcp) {
var dialogId = 'zvmAddPageSpool';
// Create form to add disk
var addPageSpoolForm = $('');
// Obtain mapping for zHCP to zVM system
var hcp2zvm = new Object();
hcp2zvm = getHcpZvmHash();
var system = $('');
var systemSelect = $('');
system.append(systemSelect);
// Append options for hardware control points
//systemSelect.append($(''));
for (var hcp in hcp2zvm) {
systemSelect.append($(''));
}
// Create info bar
var info = createInfoBar('Add a page or spool volume to be used by zVM.');
addPageSpoolForm.append(info);
var diskFS = $('');
addPageSpoolForm.append(diskFS);
var diskAttr = $('');
diskFS.append($('
'));
diskFS.append(diskAttr);
diskAttr.append(system);
diskAttr.append('');
diskAttr.append('');
diskAttr.append('');
// Generate tooltips
addPageSpoolForm.find('div input[title],select[title]').tooltip({
position: "center right",
offset: [-2, 10],
effect: "fade",
opacity: 0.8,
delay: 0,
predelay: 800,
events: {
def: "mouseover,mouseout",
input: "mouseover,mouseout",
widget: "focus mouseover,blur mouseout",
tooltip: "mouseover,mouseout"
},
// Change z index to show tooltip in front
onBeforeShow: function() {
this.getTip().css('z-index', $.topZIndex());
}
});
// Open dialog to add disk
addPageSpoolForm.dialog({
title:'Add page or spool',
modal: true,
close: function(){
$(this).remove();
},
width: 500,
buttons: {
"Ok": function(){
// Remove any warning messages
$(this).find('.ui-state-error').remove();
var system = $(this).find('select[name=system]').val();
var volAddr = $(this).find('input[name=volAddr]').val();
var volLabel = $(this).find('input[name=volLabel]').val();
var volUse = $(this).find('select[name=volUse]').val();
// If inputs are not complete, show warning message
var ready = true;
var args = new Array('select[name=system]', 'input[name=volAddr]', 'input[name=volLabel]', 'select[name=volUse]');
for (var i in args) {
if (!$(this).find(args[i]).val()) {
$(this).find(args[i]).css('border', 'solid #FF0000 1px');
ready = false;
} else {
$(this).find(args[i]).css('border', 'solid #BDBDBD 1px');
}
}
if (!ready) {
// Show warning message
var warn = createWarnBar('Please provide a value for each required field.');
warn.prependTo($(this));
return;
}
// Change dialog buttons
$(this).dialog('option', 'buttons', {
'Close': function() {$(this).dialog("close");}
});
var pageSpoolArgs = volAddr + ";" + volLabel + ";" + volUse;
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chvm',
tgt : system,
args : '--addpagespool;' + pageSpoolArgs,
msg : dialogId
},
success : function(data) {
data = decodeRsp(data);
updateResourceDialog(data);
}
});
},
"Cancel": function() {
$(this).dialog( "close" );
}
}
});
}
/**
* Open dialog to share disk
*
* @param disks2share Disks selected in table
*/
function openShareDiskDialog(disks2share) {
// Create form to share disk
var dialogId = 'zvmShareDisk';
var shareDiskForm = $('');
var args = disks2share.split(';');
var tgtHcp = args[0];
var tgtVol = args[1];
if (!tgtVol || tgtVol == "undefined")
tgtVol = "";
// Create info bar
var info = createInfoBar('Indicate a full-pack minidisk is to be shared by the users of many real and virtual systems.');
shareDiskForm.append(info);
// Set region input based on those selected on table (if any)
var node = $('');
var volAddr = $('');
var shareEnable = $('');
shareDiskForm.append(node, volAddr, shareEnable);
// Generate tooltips
shareDiskForm.find('div input[title],select[title]').tooltip({
position: "center right",
offset: [-2, 10],
effect: "fade",
opacity: 0.8,
delay: 0,
predelay: 800,
events: {
def: "mouseover,mouseout",
input: "mouseover,mouseout",
widget: "focus mouseover,blur mouseout",
tooltip: "mouseover,mouseout"
},
// Change z index to show tooltip in front
onBeforeShow: function() {
this.getTip().css('z-index', $.topZIndex());
}
});
// Open dialog to delete disk
shareDiskForm.dialog({
title:'Share disk',
modal: true,
close: function(){
$(this).remove();
},
width: 500,
buttons: {
"Ok": function(){
// Remove any warning messages
$(this).find('.ui-state-error').remove();
// Get inputs
var node = $(this).find('input[name=node]').val();
var volAddr = $(this).find('input[name=volAddr]').val();
var shareEnable = $(this).find('select[name=shareEnable]').val();
// If inputs are not complete, show warning message
var ready = true;
var args = new Array('input[name=node]', 'input[name=volAddr]', 'select[name=shareEnable]');
for (var i in args) {
if (!$(this).find(args[i]).val()) {
$(this).find(args[i]).css('border', 'solid #FF0000 1px');
ready = false;
} else {
$(this).find(args[i]).css('border', 'solid #BDBDBD 1px');
}
}
if (!ready) {
// Show warning message
var warn = createWarnBar('Please provide a value for each required field.');
warn.prependTo($(this));
return;
}
// Change dialog buttons
$(this).dialog('option', 'buttons', {
'Close': function() {$(this).dialog("close");}
});
// Remove disk from pool
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'chvm',
tgt : node,
args : "--sharevolume;" + volAddr + ";" + shareEnable,
msg : dialogId
},
success : function(data) {
data = decodeRsp(data);
updateResourceDialog(data);
}
});
},
"Cancel": function() {
$(this).dialog( "close" );
}
}
});
}
/**
* Create add SCSI 2 system dialog
*
* @param hcp Hardware control point of node
*/
function openAddScsi2SystemDialog(hcp) {
var dialogId = 'zvmAddScsi2System';
// Create form to add disk
var addS2SForm = $('');
// Obtain mapping for zHCP to zVM system
var hcp2zvm = new Object();
hcp2zvm = getHcpZvmHash();
// Create info bar
var info = createInfoBar('Dynamically add an SCSI disk to a running z/VM system as an EDEV.');
addS2SForm.append(info);
var system = $('');
var systemSelect = $('');
system.append(systemSelect);
// Append options for hardware control points
//systemSelect.append($(''));
for (var hcp in hcp2zvm) {
systemSelect.append($(''));
}
var devNo = $('');
var devPathLabel = $('');
var devPathCount = 1;
//var pathDiv = $('');
var devPathDiv = $('');
var devPathTable = $('
');
var devPathHeader = $('
FCP Device
WWPN
LUN
');
// Adjust header width
devPathHeader.find('th').css({
'width' : '120px'
});
devPathHeader.find('th').eq(0).css({
'width' : '20px'
});
var devPathBody = $('');
var devPathFooter = $('');
// Create a row
var devPathRow = $('