From 711b13383fd8a5fbed1f445d58d3d014de7eb736 Mon Sep 17 00:00:00 2001 From: phamt Date: Tue, 12 Feb 2013 22:15:52 +0000 Subject: [PATCH] Added input verification. Fixed add vSwitch option. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15159 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/custom/zvmUtils.js | 527 ++++++++++++++++------------ xCAT-server/lib/xcat/plugins/zvm.pm | 27 +- 2 files changed, 310 insertions(+), 244 deletions(-) diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js index 013f654b5..5bf4c13be 100644 --- a/xCAT-UI/js/custom/zvmUtils.js +++ b/xCAT-UI/js/custom/zvmUtils.js @@ -1994,7 +1994,7 @@ function openAddScsi2SystemDialog(hcp) { systemSelect.append($('')); } - var devNum = $('
'); + var devNo = $('
'); var devPathLabel = $(''); var devPathCount = 1; var pathDiv = $('
'); @@ -2003,10 +2003,10 @@ function openAddScsi2SystemDialog(hcp) { var devPathTable = $('
'); var devPathHeader = $(' FCP Device WWPN LUN'); // Adjust header width - devPathHeader.find('th').css( { + devPathHeader.find('th').css({ 'width' : '120px' }); - devPathHeader.find('th').eq(0).css( { + devPathHeader.find('th').eq(0).css({ 'width' : '20px' }); var devPathBody = $(''); @@ -2121,7 +2121,7 @@ function openAddScsi2SystemDialog(hcp) { '' + '' + ''); - addS2SForm.append(system, devNum, devPathDiv, option, persist); + addS2SForm.append(system, devNo, devPathDiv, option, persist); // Generate tooltips addS2SForm.find('div input[title],select[title]').tooltip({ @@ -2171,42 +2171,53 @@ 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 system = $(this).find('select[name=system]').val(); + var devNo = $(this).find('input[name=devNo]').val(); var pathArray = ""; $('.devPath').each(function(index) { - pathArray += $(this).find('input[name=fcpDevNum]').val() + ' '; - pathArray += $(this).find('input[name=fcpWwpn]').val() + ' '; - pathArray += $(this).find('input[name=fcpLun]').val() + '; '; + pathArray += $(this).find('input[name=fcpDevNum]').val() + ','; + pathArray += $(this).find('input[name=fcpWwpn]').val() + ','; + pathArray += $(this).find('input[name=fcpLun]').val() + ';'; }); - path_Array = pathArray + "'"; var option = $(this).find('select[name=option]').val(); var persist = $(this).find('select[name=persist]').val(); // If inputs are not complete, show warning message - if (!system || !num || !pathArray || !option || !persist) { - 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");} - }); - - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'chhypervisor', - tgt : system, - args : "--addscsi||" + num + "||" + pathArray + "||" + option + "||" + persist, - msg : dialogId - }, - - success : updateResourceDialog - }); - + var ready = true; + var args = new Array('select[name=system]', 'input[name=devNum]', 'select[name=option]', 'select[name=persist]'); + 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'); + } } + + // Show warning message + if (!ready || !pathArray) { + 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 : "--addscsi||" + devNo + "||'" + pathArray + "'||" + option + "||" + persist, + msg : dialogId + }, + + success : updateResourceDialog + }); }, "Cancel": function() { $(this).dialog( "close" ); @@ -2283,34 +2294,46 @@ function openRemoveScsiDialog(hcp) { $(this).find('.ui-state-error').remove(); // Get inputs - var system = $(this).find('input[name=system]').val(); + var system = $(this).find('select[name=system]').val(); var devnum = $(this).find('input[name=devNum]').val(); var persist = $(this).find('select[name=persist]').val(); // If inputs are not complete, show warning message - if (!system || !devnum) { - var warn = createWarnBar('Please provide a value for each missing field.'); + 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)); - } else { - // 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 : "--removescsi;" + devnum + ";" + persist, - msg : dialogId - }, + return; + } - success : updateResourceDialog - }); + // 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 : "--removescsi;" + devnum + ";" + persist, + msg : dialogId + }, - } // End of else + success : updateResourceDialog + }); }, "Cancel": function() { $(this).dialog( "close" ); @@ -2578,7 +2601,7 @@ function openAddNicDialog(node, hcp) { $(this).dialog( "close" ); } // End of else }, - "Cancel": function(){ + "Cancel": function() { $(this).dialog( "close" ); } } @@ -2606,8 +2629,8 @@ function openAddVswitchVlanDialog(hcp) { var typeFS = $('
').hide(); var typeLegend = $('Network'); typeFS.append(typeLegend); - addVswitchForm.append(info, netFS, typeFS); + var netAttr = $('
'); netFS.append($('
')); netFS.append(netAttr); @@ -2622,120 +2645,94 @@ function openAddVswitchVlanDialog(hcp) { netAttr.append(networkTypeDiv); var system = $('
'); - var systemSelect = $(''); + var systemSelect = $(''); system.append(systemSelect); netAttr.append(system); + + // Obtain mapping for zHCP to zVM system + var hcp2zvm = new Object(); + hcp2zvm = getHcpZvmHash(); + systemSelect.append($('')); + for (var hcp in hcp2zvm) { + systemSelect.append($('')); + } var typeAttr = $('
'); typeFS.append($('
')); typeFS.append(typeAttr); // Create vSwitch parameters - var vswitchOptions = $('
').hide(); + var vswitchOptions = $('
').hide(); vswitchOptions.append($('
')); vswitchOptions.append($('
')); - vswitchOptions.append($('
')); vswitchOptions.append($('
')); - vswitchOptions.append($('
' + '' + '' + '' + '
')); - vswitchOptions.append($('
')); - vswitchOptions.append($('
')); + advanced.append($('
')); - vswitchOptions.append($('
' + '' + '' + '' + '
')); - vswitchOptions.append($('
')); - vswitchOptions.append($('
')); + advanced.append($('
')); - vswitchOptions.append($('
' + '' + '' + '' + '' + '
')); - vswitchOptions.append($('
' + '' + '' + '' + '
')); - vswitchOptions.append($('
')); + advanced.append($('
')); // Create VLAN parameters var vlanOptions = $('
').hide(); vlanOptions.append($('
')); vlanOptions.append($('
')); vlanOptions.append($('
')); vlanOptions.append($('
')); typeAttr.append(vswitchOptions, vlanOptions); - - // 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; - } - - // Append options for z/VM system - for (var hcp in hcp2zvm) { - systemSelect.append($('')); - } - + networkType.change(function() { typeFS.show(); if ($(this).val() == "vswitch") { @@ -2789,12 +2786,12 @@ function openAddVswitchVlanDialog(hcp) { $(this).find('.ui-state-error').remove(); var networkType = $(this).find('select[name=networkType]').val(); - if (networkType == "vswitch") { + if (networkType == "vswitch") { var networkArgs = "--addvswitch;"; - var hcp = $(this).find('select[name=hcp]').val(); + var system = $(this).find('select[name=system]').val(); var switchName = $(this).find('input[name=switchName]').val(); var deviceAddress = $(this).find('input[name=deviceAddress]').val(); - var portName = $(this).find('input[name=portName]').val(); + var portName = switchName; var controllerName = $(this).find('input[name=controllerName]').val(); var connection = $(this).find('select[name=connection]').val(); var queueMemoryLimit = $(this).find('input[name=queueMemoryLimit]').val(); @@ -2806,6 +2803,25 @@ function openAddVswitchVlanDialog(hcp) { var gvrp = $(this).find('select[name=gvrp]').val(); var nativeVlanId = $(this).find('input[name=nativeVlanId]').val(); + // If inputs are not complete, show warning message + var ready = true; + var args = new Array('select[name=system]', 'input[name=switchName]', 'input[name=deviceAddress]', 'input[name=controllerName]'); + 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'); + } + } + + // Show warning message + if (!ready) { + var warn = createWarnBar('Please provide a value for each required field.'); + warn.prependTo($(this)); + return; + } + if (switchName) networkArgs += switchName + ";"; if (deviceAddress) @@ -2813,9 +2829,11 @@ function openAddVswitchVlanDialog(hcp) { if (portName) networkArgs += portName + ";"; if (controllerName) - networkArgs += controllerName + ";"; + networkArgs += controllerName + ";"; + + // Optional parameters if (connection) - networkArgs += connection + ";"; + networkArgs += connection + ";"; if (queueMemoryLimit) networkArgs += queueMemoryLimit + ";"; if (routingValue) @@ -2844,7 +2862,7 @@ function openAddVswitchVlanDialog(hcp) { dataType : 'json', data : { cmd : 'chhypervisor', - tgt : hcp, + tgt : system, args : networkArgs, msg : dialogId }, @@ -2853,38 +2871,59 @@ function openAddVswitchVlanDialog(hcp) { }); } else if (networkType == "vlan") { var networkArgs = "--addvlan;"; - var hcp = $(this).find('select[name=hcp]').val(); + var system = $(this).find('select[name=system]').val(); var vlanName = $(this).find('input[name=vlanName]').val(); var vlanOwner = $(this).find('input[name=vlanOwner]').val(); var vlanType = $(this).find('select[name=vlanType]').val(); var vlanTransport = $(this).find('select[name=vlanTransport]').val(); - if (!vlanName || !vlanOwner || !vlanType || !vlanTransport) { - var warn = createWarnBar('Please provide a value for each missing field.'); - warn.prependTo($(this)); - } else { - networkArgs += vlanName + ";"; - networkArgs += vlanOwner + ";"; - networkArgs += vlanType + ";"; - networkArgs += vlanTransport; - - // Change dialog buttons - $(this).dialog('option', 'buttons', { - 'Close': function() {$(this).dialog("close");} - }); - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'chhypervisor', - tgt : hcp, - args : networkArgs, - msg : dialogId - }, - - success : updateResourceDialog - }); + // If inputs are not complete, show warning message + var ready = true; + var args = new Array('select[name=system]', 'input[name=vlanName]', 'input[name=vlanOwner]', 'select[name=vlanType]', 'select[name=vlanTransport]'); + 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'); + } } + + // Show warning message + if (!ready) { + var warn = createWarnBar('Please provide a value for each required field.'); + warn.prependTo($(this)); + return; + } + + // Ethernet Hipersockets are not supported + if (vlanTransport == "2") { + var warn = createWarnBar('Ethernet Hipersockets are not supported'); + warn.prependTo($(this)); + return; + } + + networkArgs += vlanName + ";"; + networkArgs += vlanOwner + ";"; + networkArgs += vlanType + ";"; + networkArgs += vlanTransport; + + // 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 : networkArgs, + msg : dialogId + }, + + success : updateResourceDialog + }); } // End of else if }, "Cancel": function() { @@ -3304,7 +3343,7 @@ function loadDiskPoolTable(data) { for (var i = 2; i < tmp.length; i++) { tmp[i] = jQuery.trim(tmp[i]); var diskAttrs = tmp[i].split(' '); - dTable.fnAddData( [ '', hcp2zvm[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 @@ -3477,7 +3516,7 @@ function loadZfcpPoolTable(data) { for ( var i = 2; i < tmp.length; i++) { tmp[i] = jQuery.trim(tmp[i]); var diskAttrs = tmp[i].split(','); - var key = hcp + '-' + pool + '-' + diskAttrs[2]; + var key = hcp2zvm[hcp] + '-' + pool + '-' + diskAttrs[2]; dTable.fnAddData( [ '', hcp2zvm[hcp], pool, diskAttrs[0], diskAttrs[1], diskAttrs[2], diskAttrs[3], diskAttrs[4], diskAttrs[5], diskAttrs[6], diskAttrs[7] ]); } } @@ -3608,21 +3647,21 @@ function openRemoveDiskFromPoolDialog(disks2remove) { + ''); action.append(actionSelect); - var hcp = $('
'); - var hcpSelect = $(''); - hcp.append(hcpSelect); + var system = $('
'); + var systemSelect = $(''); + system.append(systemSelect); // Set region input based on those selected on table (if any) var region = $('
'); var group = $('
'); - deleteDiskForm.append(action, hcp, region, group); + deleteDiskForm.append(action, system, region, group); // Append options for hardware control points - hcpSelect.append($('')); + systemSelect.append($('')); for (var hcp in hcp2zvm) { - hcpSelect.append($('')); + systemSelect.append($('')); } - hcpSelect.val(tgtHcp); + systemSelect.val(tgtHcp); actionSelect.change(function() { if ($(this).val() == '1' || $(this).val() == '3') { @@ -3674,12 +3713,12 @@ function openRemoveDiskFromPoolDialog(disks2remove) { // Get inputs var action = $(this).find('select[name=action]').val(); - var hcp = $(this).find('select[name=hcp]').val(); + var system = $(this).find('select[name=system]').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) { + if (!action || !system) { var warn = createWarnBar('Please provide a value for each missing field.'); warn.prependTo($(this)); } else { @@ -3699,8 +3738,8 @@ function openRemoveDiskFromPoolDialog(disks2remove) { url : 'lib/cmd.php', dataType : 'json', data : { - cmd : 'chvm', - tgt : hcp, + cmd : 'chhypervisor', + tgt : system, args : '--removediskfrompool;' + action + ';' + args, msg : dialogId }, @@ -3739,17 +3778,17 @@ function openAddDisk2PoolDialog() { + ''); action.append(actionSelect); - var hcp = $('
'); - var hcpSelect = $(''); - hcp.append(hcpSelect); + var system = $('
'); + var systemSelect = $(''); + system.append(systemSelect); var volume = $('
'); var group = $('
'); - addDiskForm.append(action, hcp, volume, group); + addDiskForm.append(action, system, volume, group); // Append options for hardware control points - hcpSelect.append($('')); + systemSelect.append($('')); for (var hcp in hcp2zvm) { - hcpSelect.append($('')); + systemSelect.append($('')); } actionSelect.change(function() { @@ -3796,12 +3835,12 @@ function openAddDisk2PoolDialog() { // Get inputs var action = $(this).find('select[name=action]').val(); - var hcp = $(this).find('select[name=hcp]').val(); + var system = $(this).find('select[name=system]').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 || !group) { + if (!action || !system || !group) { var warn = createWarnBar('Please provide a value for each missing field.'); warn.prependTo($(this)); } else { @@ -3821,8 +3860,8 @@ function openAddDisk2PoolDialog() { url : 'lib/cmd.php', dataType : 'json', data : { - cmd : 'chvm', - tgt : hcp, + cmd : 'chhypervisor', + tgt : system, args : '--adddisk2pool;' + action + ';' + args, msg : dialogId }, @@ -3877,21 +3916,21 @@ function openRemoveZfcpFromPoolDialog(devices2remove) { var info = createInfoBar('Remove a zFCP device that is defined in a zFCP pool.'); deleteDiskForm.append(info); - var hcp = $('
'); - var hcpSelect = $(''); - hcp.append(hcpSelect); + var system = $('
'); + var systemSelect = $(''); + system.append(systemSelect); var pool = $('
'); var unitNo = $('
'); var portName = $('
'); - deleteDiskForm.append(hcp, pool, unitNo, portName); + deleteDiskForm.append(system, pool, unitNo, portName); // Append options for hardware control points - hcpSelect.append($('')); + systemSelect.append($('')); for (var hcp in hcp2zvm) { - hcpSelect.append($('')); + systemSelect.append($('')); } - hcpSelect.val(tgtHcp); + systemSelect.val(tgtHcp); // Generate tooltips deleteDiskForm.find('div input[title],select[title]').tooltip({ @@ -3927,38 +3966,51 @@ function openRemoveZfcpFromPoolDialog(devices2remove) { // Remove any warning messages $(this).find('.ui-state-error').remove(); - var hcp = $(this).find('select[name=hcp]').val(); + var system = $(this).find('select[name=system]').val(); var pool = $(this).find('input[name=zfcpPool]').val(); var unitNo = $(this).find('input[name=zfcpUnitNo]').val(); var portName = $(this).find('input[name=zfcpPortName]').val(); // If inputs are not complete, show warning message - if (!hcp || !pool || !unitNo) { - 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 = '--removezfcpfrompool;' + pool + ';' + unitNo; - if (portName) { - args += ';' + portName; + var ready = true; + var args = new Array('select[name=system]', 'input[name=zfcpPool]', 'input[name=zfcpUnitNo]'); + 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'); } - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'chvm', - tgt : hcp, - args : args, - msg : dialogId - }, - - success : updateResourceDialog - }); } + + 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 args = '--removezfcpfrompool;' + pool + ';' + unitNo; + if (portName) { + args += ';' + portName; + } + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'chhypervisor', + tgt : system, + args : args, + msg : dialogId + }, + + success : updateResourceDialog + }); }, "Cancel": function() { $(this).dialog( "close" ); @@ -3981,9 +4033,9 @@ function openAddZfcp2PoolDialog() { var hcp2zvm = new Object(); hcp2zvm = getHcpZvmHash(); - var hcp = $('
'); - var hcpSelect = $(''); - hcp.append(hcpSelect); + var system = $('
'); + var systemSelect = $(''); + system.append(systemSelect); var pool = $('
'); var status = $('
'); var range = $('
'); var owner = $('
'); - addDiskForm.append(hcp, pool, status, portName, unitNo, size, range, owner); + addDiskForm.append(system, pool, status, portName, unitNo, size, range, owner); // Create a array for hardware control points - hcpSelect.append($('')); + systemSelect.append($('')); // Append options for hardware control points for (var hcp in hcp2zvm) { - hcpSelect.append($('')); + systemSelect.append($('')); } // Generate tooltips @@ -4038,7 +4090,7 @@ function openAddZfcp2PoolDialog() { // Delete any warning messages $(this).find('.ui-state-error').remove(); - var tgtHcp = $(this).find('select[name=hcp]').val(); + var tgtSystem = $(this).find('select[name=system]').val(); var tgtPool = $(this).find('input[name=zfcpPool]').val(); var tgtStatus = $(this).find('select[name=zfcpStatus]').val(); var tgtPortName = $(this).find('input[name=zfcpPortName]').val(); @@ -4051,30 +4103,43 @@ function openAddZfcp2PoolDialog() { if ($(this).find('input[name=zfcpOwner]').val()) { tgtOwner = $(this).find('input[name=zfcpOwner]').val(); } - + // If inputs are not complete, show warning message - if (!tgtHcp || !tgtPool || !tgtStatus || !tgtPortName || !tgtUnitNo || !tgtSize) { - 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");} - }); - - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'chvm', - tgt : tgtHcp, - args : '--addzfcp2pool||' + tgtPool + '||' + tgtStatus + '||"' + tgtPortName + '"||' + tgtUnitNo + '||' + tgtSize + '||' + tgtRange + '||' + tgtOwner, - msg : dialogId - }, - - success : updateResourceDialog - }); + var ready = true; + var args = new Array('select[name=system]', 'input[name=zfcpPool]', 'select[name=zfcpStatus]', 'input[name=zfcpPortName]', 'input[name=zfcpUnitNo]'); + 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 : tgtSystem, + args : '--addzfcp2pool||' + tgtPool + '||' + tgtStatus + '||"' + tgtPortName + '"||' + tgtUnitNo + '||' + tgtSize + '||' + tgtRange + '||' + tgtOwner, + msg : dialogId + }, + + success : updateResourceDialog + }); }, "Cancel": function() { $(this).dialog( "close" ); diff --git a/xCAT-server/lib/xcat/plugins/zvm.pm b/xCAT-server/lib/xcat/plugins/zvm.pm index 1b922a7ff..31240606c 100644 --- a/xCAT-server/lib/xcat/plugins/zvm.pm +++ b/xCAT-server/lib/xcat/plugins/zvm.pm @@ -6037,7 +6037,6 @@ sub changeHypervisor { # Add an ECKD disk to a running z/VM system $out = `ssh $::SUDOER\@$hcp "$::SUDO $::DIR/smcli System_Disk_Add -T $hcpUserId -k $devNo"`; - $out = xCAT::zvmUtils->appendHostname( $node, $out ); } # addscsi [dev_no] [dev_path] [option] [persist] @@ -6107,17 +6106,22 @@ sub changeHypervisor { $out .= `ssh $::SUDOER\@$hcp "$::SUDO $::DIR/smcli Virtual_Network_LAN_Create -T $hcpUserId -n $name -o $owner -t $type -p $transport"`; } - # addvswitch [name] [osa_dev_addr] [osa_exp_adapter] [controller] [connect (0, 1, or 2)] [memory_queue] [router] [transport] [vlan_id] [port_type] [update] [gvrp] [native_vlan] + # addvswitch [name] [osa_dev_addr] [port_name] [controller] [connect (0, 1, or 2)] [memory_queue] [router] [transport] [vlan_id] [port_type] [update] [gvrp] [native_vlan] elsif ( $args->[0] eq "--addvswitch" ) { my $i; my $argStr = ""; my $argsSize = @{$args}; + if ($argsSize < 5) { + xCAT::zvmUtils->printLn( $callback, "$node: (Error) Wrong number of parameters" ); + return; + } + my @options = ("", "-n", "-r", "-a", "-i", "-c", "-q", "-e", "-t", "-v", "-p", "-u", "-G", "-V"); foreach $i ( 1 .. $argsSize ) { if ( $args->[$i] ) { # Prepend options prefix to argument - $argStr .= "$options[$i] $args->[$i] "; + $argStr .= "$options[$i] $args->[$i] "; } } @@ -6167,13 +6171,7 @@ sub changeHypervisor { # Create pool directory $out = `ssh $::SUDOER\@$hcp "$::SUDO mkdir -p $::ZFCPPOOL"`; } - - if (!(`ssh $::SUDOER\@$hcp "$::SUDO test -e $::ZFCPPOOL/$pool.conf && echo Exists"`)) { - # Create pool configuration file - $out = xCAT::zvmUtils->rExecute($::SUDOER, $hcp, "echo '#status,wwpn,lun,size,range,owner,channel,tag' > $::ZFCPPOOL/$pool.conf"); - xCAT::zvmUtils->printLn( $callback, "$node: New zFCP device pool $pool created" ); - } - + # Change the file owner if using a sudoer if ($::SUDOER ne "root") { my $priv = xCAT::zvmUtils->trimStr(`ssh $::SUDOER\@$hcp "$::SUDO stat -c \"%G:%U\" /var/opt/zhcp"`); @@ -6181,6 +6179,12 @@ sub changeHypervisor { `ssh $::SUDOER\@$hcp "$::SUDO chown -R $::SUDOER:users /var/opt/zhcp"`; } } + + if (!(`ssh $::SUDOER\@$hcp "$::SUDO test -e $::ZFCPPOOL/$pool.conf && echo Exists"`)) { + # Create pool configuration file + $out = `ssh $::SUDOER\@$hcp "$::SUDO echo '#status,wwpn,lun,size,range,owner,channel,tag' > $::ZFCPPOOL/$pool.conf"`; + xCAT::zvmUtils->printLn( $callback, "$node: New zFCP device pool $pool created" ); + } # Do not update if the LUN already exists if (`ssh $::SUDOER\@$hcp "$::SUDO cat $::ZFCPPOOL/$pool.conf" | grep $lun`) { @@ -6241,7 +6245,6 @@ sub changeHypervisor { # Delete a real SCSI disk $out = `ssh $::SUDOER\@$hcp "$::SUDO $::DIR/smcli System_SCSI_Disk_Delete -T $hcpUserId -k $devNo -k $persist"`; - $out = xCAT::zvmUtils->appendHostname( $node, $out ); } # removevlan [name] [owner] @@ -6251,7 +6254,6 @@ sub changeHypervisor { # Delete a virtual network $out = `ssh $hcp "$::DIR/smcli Virtual_Network_LAN_Delete -T $hcpUserId -n $name -o $owner"`; - $out = xCAT::zvmUtils->appendHostname( $node, $out ); } # removevswitch [name] @@ -6260,7 +6262,6 @@ sub changeHypervisor { # Delete a VSWITCH $out = `ssh $hcp "$::DIR/smcli Virtual_Network_Vswitch_Delete -T $hcpUserId -n $name"`; - $out = xCAT::zvmUtils->appendHostname( $node, $out ); } # removezfcpfrompool [pool] [lun] [wwpn (optional)]