From 48872e61fdefc0cb53ad03f01af027b768486a27 Mon Sep 17 00:00:00 2001 From: phamt Date: Mon, 11 Feb 2013 16:24:06 +0000 Subject: [PATCH] Synched up with 2.8 branch code. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15136 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/custom/zvmUtils.js | 280 +++++++++++++++++++--------- xCAT-server/lib/xcat/plugins/zvm.pm | 1 - 2 files changed, 192 insertions(+), 89 deletions(-) diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js index c1adc9652..f91916fd9 100644 --- a/xCAT-UI/js/custom/zvmUtils.js +++ b/xCAT-UI/js/custom/zvmUtils.js @@ -1666,9 +1666,25 @@ function openAddEckd2SystemDialog(hcp) { // 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 @@ -1699,17 +1715,17 @@ function openAddEckd2SystemDialog(hcp) { close: function(){ $(this).remove(); }, - width: 400, + width: 420, buttons: { "Ok": function(){ // Remove any warning messages $(this).find('.ui-state-error').remove(); - // Get inputs + var system = $(this).find('select[name=system]').val(); var devnum = $(this).find('input[name=devNum]').val(); // If inputs are not complete, show warning message - if (!devnum) { + if (!system || !devnum) { var warn = createWarnBar('Please provide a value for each missing field.'); warn.prependTo($(this)); } else { @@ -1723,7 +1739,7 @@ function openAddEckd2SystemDialog(hcp) { dataType : 'json', data : { cmd : 'chhypervisor', - tgt : hcp, + tgt : system, args : "--addeckd;" + devnum, msg : dialogId }, @@ -1747,10 +1763,22 @@ function openAddEckd2SystemDialog(hcp) { */ 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 + for (var hcp in hcp2zvm) { + systemSelect.append($('')); + } + // Create info bar var info = createInfoBar('Indicate a full-pack minidisk is to be shared by the users of many real and virtual systems.'); addPageSpoolForm.append(info); @@ -1761,6 +1789,7 @@ function openAddPageSpoolDialog(hcp) { diskFS.append($('
')); diskFS.append(diskAttr); + diskAttr.append(system); diskAttr.append('
'); diskAttr.append('
'); diskAttr.append('
'); @@ -1799,12 +1828,13 @@ function openAddPageSpoolDialog(hcp) { // 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 - if (!volAddr || !volLabel || !volUse) { + if (!system || !volAddr || !volLabel || !volUse) { var warn = createWarnBar('Please provide a value for each missing field.'); warn.prependTo($(this)); } else { @@ -1813,14 +1843,14 @@ function openAddPageSpoolDialog(hcp) { 'Close': function() {$(this).dialog("close");} }); - var pageSpoolArgs = volAddr + ";" + volLabel + ";" + volUse + ";"; + var pageSpoolArgs = volAddr + ";" + volLabel + ";" + volUse; $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'chvm', - tgt : hcp, + tgt : system, args : '--addpagespool;' + pageSpoolArgs, msg : dialogId }, @@ -1847,30 +1877,23 @@ function openShareDiskDialog(disks2share) { 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); - var hcp = $('
'); - var hcpSelect = $(''); - hcp.append(hcpSelect); // Set region input based on those selected on table (if any) - var volAddr = $('
'); + var node = $('
'); + var volAddr = $('
'); var shareEnable = $('
'); - shareDiskForm.append(hcp, volAddr, shareEnable); - - // 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($('')); - } - + shareDiskForm.append(node, volAddr, shareEnable); + // Generate tooltips shareDiskForm.find('div input[title],select[title]').tooltip({ position: "center right", @@ -1906,12 +1929,12 @@ function openShareDiskDialog(disks2share) { $(this).find('.ui-state-error').remove(); // Get inputs - var hcp = $(this).find('select[name=hcp]').val(); + 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 - if (!volAddr || !shareEnable) { + if (!node || !volAddr || !shareEnable) { var warn = createWarnBar('Please provide a value for each missing field.'); warn.prependTo($(this)); } else { @@ -1926,7 +1949,7 @@ function openShareDiskDialog(disks2share) { dataType : 'json', data : { cmd : 'chvm', - tgt : hcp, + tgt : node, args : "--sharevolume;" + volAddr + ";" + shareEnable, msg : dialogId }, @@ -1953,9 +1976,23 @@ function openAddScsi2SystemDialog(hcp) { // 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.'); 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 devNum = $('
'); var devPathLabel = $(''); @@ -2084,7 +2121,7 @@ function openAddScsi2SystemDialog(hcp) { '' + '' + ''); - addS2SForm.append(devNum, devPathDiv, option, persist); + addS2SForm.append(system, devNum, devPathDiv, option, persist); // Generate tooltips addS2SForm.find('div input[title],select[title]').tooltip({ @@ -2134,6 +2171,7 @@ function openAddScsi2SystemDialog(hcp) { // Remove any warning messages $(this).find('.ui-state-error').remove(); + var system = $(this).find('input[name=system]').val(); var num = $(this).find('input[name=devNum]').val(); var pathArray = ""; $('.devPath').each(function(index) { @@ -2146,7 +2184,7 @@ function openAddScsi2SystemDialog(hcp) { var persist = $(this).find('select[name=persist]').val(); // If inputs are not complete, show warning message - if (!num || !pathArray || !option || !persist) { + if (!system || !num || !pathArray || !option || !persist) { var warn = createWarnBar('Please provide a value for each missing field.'); warn.prependTo($(this)); } else { @@ -2160,7 +2198,7 @@ function openAddScsi2SystemDialog(hcp) { dataType : 'json', data : { cmd : 'chhypervisor', - tgt : hcp, + tgt : system, args : "--addscsi||" + num + "||" + pathArray + "||" + option + "||" + persist, msg : dialogId }, @@ -2186,9 +2224,24 @@ function openRemoveScsiDialog(hcp) { var dialogId = 'zvmRemoveScsiDialog'; // Create form to add disk var removeScsiForm = $('
'); + + // 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('Delete a real SCSI disk'); - removeScsiForm.append(info); + removeScsiForm.append(info, system); removeScsiForm.append('
'); removeScsiForm.append('
', 'zHCP', 'Pool', 'Status', 'Volume', 'Device type', 'Starting address', 'Size' ]); + table.init( [ '', 'z/VM', 'Pool', 'Status', 'Volume', 'Device type', 'Starting address', 'Size' ]); // Append datatable to panel $('#' + panelId).append(table.object()); @@ -3241,12 +3299,12 @@ function loadDiskPoolTable(data) { }); setDiskDataTable(dTable); } - + // Skip index 0 and 1 because it contains nothing for (var i = 2; i < tmp.length; i++) { tmp[i] = jQuery.trim(tmp[i]); var diskAttrs = tmp[i].split(' '); - dTable.fnAddData( [ '', hcp, pool, stat, diskAttrs[0], diskAttrs[1], diskAttrs[2], diskAttrs[3] ]); + dTable.fnAddData( [ '', hcp2zvm[hcp], pool, stat, diskAttrs[0], diskAttrs[1], diskAttrs[2], diskAttrs[3] ]); } // Create actions menu @@ -3366,6 +3424,10 @@ function loadZfcpPoolTable(data) { return; } + // Obtain mapping for zHCP to zVM system + var hcp2zvm = new Object(); + hcp2zvm = getHcpZvmHash(); + var args, hcp, pool, tmp; args = data.msg.split(';'); hcp = args[0].replace('hcp=', ''); @@ -3387,7 +3449,7 @@ function loadZfcpPoolTable(data) { // Create a datatable var table = new DataTable(tableId); // Resource headers: status, WWPN, LUN, size, owner, channel, tag - table.init( [ '', 'zHCP', 'Pool', 'Status', 'Port name', 'Unit number', 'Size', 'Range', 'Owner', 'Channel', 'Tag' ]); + table.init( [ '', 'z/VM', 'Pool', 'Status', 'Port name', 'Unit number', 'Size', 'Range', 'Owner', 'Channel', 'Tag' ]); // Append datatable to panel $('#' + panelId).append(table.object()); @@ -3416,7 +3478,7 @@ function loadZfcpPoolTable(data) { tmp[i] = jQuery.trim(tmp[i]); var diskAttrs = tmp[i].split(','); var key = hcp + '-' + pool + '-' + diskAttrs[2]; - dTable.fnAddData( [ '', hcp, pool, diskAttrs[0], diskAttrs[1], diskAttrs[2], diskAttrs[3], diskAttrs[4], diskAttrs[5], diskAttrs[6], diskAttrs[7] ]); + dTable.fnAddData( [ '', hcp2zvm[hcp], pool, diskAttrs[0], diskAttrs[1], diskAttrs[2], diskAttrs[3], diskAttrs[4], diskAttrs[5], diskAttrs[6], diskAttrs[7] ]); } } @@ -3525,6 +3587,14 @@ function openRemoveDiskFromPoolDialog(disks2remove) { var dialogId = 'zvmDeleteDiskFromPool'; var deleteDiskForm = $('
'); + // Obtain mapping for zHCP to zVM system + var hcp2zvm = new Object(); + hcp2zvm = getHcpZvmHash(); + + var args = disks2remove.split(';'); + var tgtHcp = args[0]; + var tgtVol = args[1]; + // Create info bar var info = createInfoBar('Remove a disk from a disk pool defined in the EXTENT CONTROL.'); deleteDiskForm.append(info); @@ -3538,26 +3608,21 @@ function openRemoveDiskFromPoolDialog(disks2remove) { + ''); action.append(actionSelect); - var hcp = $('
'); - var hcpSelect = $(''); + var hcp = $('
'); + var hcpSelect = $(''); hcp.append(hcpSelect); // Set region input based on those selected on table (if any) - var region = $('
'); + var region = $('
'); var group = $('
'); 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($('')); + hcpSelect.append($('')); + for (var hcp in hcp2zvm) { + hcpSelect.append($('')); } + hcpSelect.val(tgtHcp); actionSelect.change(function() { if ($(this).val() == '1' || $(this).val() == '3') { @@ -3658,6 +3723,11 @@ function openAddDisk2PoolDialog() { // Create form to add disk to pool var dialogId = 'zvmAddDisk2Pool'; var addDiskForm = $('
'); + + // Obtain mapping for zHCP to zVM system + var hcp2zvm = new Object(); + hcp2zvm = getHcpZvmHash(); + // 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); @@ -3669,23 +3739,17 @@ function openAddDisk2PoolDialog() { + ''); action.append(actionSelect); - var hcp = $('
'); - var hcpSelect = $(''); + var hcp = $('
'); + var hcpSelect = $(''); hcp.append(hcpSelect); var volume = $('
'); var group = $('
'); addDiskForm.append(action, hcp, 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($('')); + hcpSelect.append($('')); + for (var hcp in hcp2zvm) { + hcpSelect.append($('')); } actionSelect.change(function() { @@ -3784,6 +3848,10 @@ function openRemoveZfcpFromPoolDialog(devices2remove) { var dialogId = 'zvmDeleteZfcpFromPool'; var deleteDiskForm = $('
'); + // Obtain mapping for zHCP to zVM system + var hcp2zvm = new Object(); + hcp2zvm = getHcpZvmHash(); + // Verify disks are in the same zFCP pool var devices = devices2remove.split(','); var tmp, tgtPool, tgtHcp; @@ -3809,8 +3877,8 @@ function openRemoveZfcpFromPoolDialog(devices2remove) { var info = createInfoBar('Remove a zFCP device that is defined in a zFCP pool.'); deleteDiskForm.append(info); - var hcp = $('
'); - var hcpSelect = $(''); + var hcp = $('
'); + var hcpSelect = $(''); hcp.append(hcpSelect); var pool = $('
'); @@ -3818,17 +3886,10 @@ function openRemoveZfcpFromPoolDialog(devices2remove) { var portName = $('
'); deleteDiskForm.append(hcp, pool, unitNo, portName); - // 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($('')); + hcpSelect.append($('')); + for (var hcp in hcp2zvm) { + hcpSelect.append($('')); } hcpSelect.val(tgtHcp); @@ -3916,8 +3977,12 @@ function openAddZfcp2PoolDialog() { var info = createInfoBar('Add a device to a zFCP pool defined in xCAT.'); addDiskForm.append(info); - var hcp = $('
'); - var hcpSelect = $(''); + // Obtain mapping for zHCP to zVM system + var hcp2zvm = new Object(); + hcp2zvm = getHcpZvmHash(); + + var hcp = $('
'); + var hcpSelect = $(''); hcp.append(hcpSelect); var pool = $('
'); @@ -3933,16 +3998,10 @@ function openAddZfcp2PoolDialog() { addDiskForm.append(hcp, pool, status, portName, unitNo, size, range, owner); // 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')); - } - - hcpSelect.append($('')); - for (var i in hcps) { - hcpSelect.append($('')); + hcpSelect.append($('')); + // Append options for hardware control points + for (var hcp in hcp2zvm) { + hcpSelect.append($('')); } // Generate tooltips @@ -6094,4 +6153,49 @@ function editProfileDialog(profile, pool, size, entry) { } } }); +} + +/** + * Get a hash map containing the zHCP to z/VM system mapping + * + * @returns Hash map containing the zHCP to z/VM system mapping + */ +function getHcpZvmHash() { + // Get zVM host names + if (!$.cookie('zvms')) { + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + async: false, + data : { + cmd : 'webportal', + tgt : '', + args : 'lszvm', + msg : '' + }, + + success : function(data) { + setzVMCookies(data); + } + }); + } + + var zvms = $.cookie('zvms').split(','); + var hcp2zvm = new Object(); + var args, zvm, iHcp, tmp; + for (var i in zvms) { + args = zvms[i].split(':'); + zvm = args[0].toLowerCase(); + + if (args[1].indexOf('.') != -1) { + tmp = args[1].split('.'); + iHcp = tmp[0]; + } else { + iHcp = args[1]; + } + + hcp2zvm[iHcp] = zvm; + } + + return hcp2zvm; } \ No newline at end of file diff --git a/xCAT-server/lib/xcat/plugins/zvm.pm b/xCAT-server/lib/xcat/plugins/zvm.pm index 845e273ed..f7b888c9b 100644 --- a/xCAT-server/lib/xcat/plugins/zvm.pm +++ b/xCAT-server/lib/xcat/plugins/zvm.pm @@ -6183,7 +6183,6 @@ sub changeHypervisor { # Update file with given WWPN, LUN, size, and owner my $entry = "'" . "$status,$wwpn,$lun,$size,$range,$owner,," . "'"; $out = `ssh $::SUDOER\@$hcp "$::SUDO echo $entry >> $::ZFCPPOOL/$pool.conf"`; - xCAT::zvmUtils->printLn( $callback, "ssh $::SUDOER\@$hcp \"$::SUDO echo \"$status,$wwpn,$lun,$size,$range,$owner,,\" >> $::ZFCPPOOL/$pool.conf"); xCAT::zvmUtils->printLn( $callback, "$node: Adding zFCP device to $pool pool... Done" ); $out = ""; }