From 72b785338b8107b25a51bd710c316be8dd1a78a3 Mon Sep 17 00:00:00 2001 From: phamt Date: Tue, 12 Feb 2013 22:53:08 +0000 Subject: [PATCH] Fixed add disk to pool. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15160 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/custom/zvmUtils.js | 332 ++++++++++++++++------------ xCAT-server/lib/xcat/plugins/zvm.pm | 2 +- 2 files changed, 196 insertions(+), 138 deletions(-) diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js index 5bf4c13be..0df7bd9e1 100644 --- a/xCAT-UI/js/custom/zvmUtils.js +++ b/xCAT-UI/js/custom/zvmUtils.js @@ -1725,29 +1725,41 @@ function openAddEckd2SystemDialog(hcp) { var devnum = $(this).find('input[name=devNum]').val(); // If inputs are not complete, show warning message - if (!system || !devnum) { - 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 : "--addeckd;" + devnum, - msg : dialogId - }, - - success : updateResourceDialog - }); - + 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 : updateResourceDialog + }); }, "Cancel": function() { $(this).dialog( "close" ); @@ -1775,6 +1787,7 @@ function openAddPageSpoolDialog(hcp) { var systemSelect = $(''); system.append(systemSelect); // Append options for hardware control points + systemSelect.append($('')); for (var hcp in hcp2zvm) { systemSelect.append($('')); } @@ -1834,31 +1847,43 @@ function openAddPageSpoolDialog(hcp) { var volUse = $(this).find('select[name=volUse]').val(); // If inputs are not complete, show warning message - if (!system || !volAddr || !volLabel || !volUse) { - 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 pageSpoolArgs = volAddr + ";" + volLabel + ";" + volUse; - - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'chvm', - tgt : system, - args : '--addpagespool;' + pageSpoolArgs, - msg : dialogId - }, - - success : updateResourceDialog - }); - + 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 : updateResourceDialog + }); }, "Cancel": function() { $(this).dialog( "close" ); @@ -1932,31 +1957,44 @@ function openShareDiskDialog(disks2share) { 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 (!node || !volAddr || !shareEnable) { - 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");} - }); - - // Remove disk from pool - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'chvm', - tgt : node, - args : "--sharevolume;" + volAddr + ";" + shareEnable, - msg : dialogId - }, - - success : updateResourceDialog - }); + 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 : updateResourceDialog + }); }, "Cancel": function() { $(this).dialog( "close" ); @@ -3343,7 +3381,8 @@ 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] ]); + var key = hcp2zvm[hcp] + "-" + pool + "-" + diskAttrs[0]; + dTable.fnAddData( [ '', hcp2zvm[hcp], pool, stat, diskAttrs[0], diskAttrs[1], diskAttrs[2], diskAttrs[3] ]); } // Create actions menu @@ -3630,9 +3669,10 @@ function openRemoveDiskFromPoolDialog(disks2remove) { var hcp2zvm = new Object(); hcp2zvm = getHcpZvmHash(); - var args = disks2remove.split(';'); + var args = disks2remove.split('-'); var tgtHcp = args[0]; - var tgtVol = args[1]; + var tgtPool = args[1]; + var tgtVol = args[2]; // Create info bar var info = createInfoBar('Remove a disk from a disk pool defined in the EXTENT CONTROL.'); @@ -3653,7 +3693,7 @@ function openRemoveDiskFromPoolDialog(disks2remove) { // Set region input based on those selected on table (if any) var region = $('
'); - var group = $('
'); + var group = $('
'); deleteDiskForm.append(action, system, region, group); // Append options for hardware control points @@ -3718,35 +3758,48 @@ function openRemoveDiskFromPoolDialog(disks2remove) { var group = $(this).find('input[name=group]').val(); // If inputs are not complete, show warning message - if (!action || !system) { - var warn = createWarnBar('Please provide a value for each missing field.'); - warn.prependTo($(this)); - } else { - // Change dialog buttons - $(this).dialog('option', 'buttons', { - 'Close': function() {$(this).dialog("close");} - }); - - var args; - if (action == '2' || action == '7') - args = region + ';' + group; - else - args = group; - - // Remove disk from pool - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'chhypervisor', - tgt : system, - args : '--removediskfrompool;' + action + ';' + args, - msg : dialogId - }, - - success : updateResourceDialog - }); + var ready = true; + var args = new Array('select[name=system]', 'select[name=action]', 'input[name=region]', 'input[name=group]'); + 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 args; + if (action == '2' || action == '7') + args = region + ';' + group; + else + args = group; + + // Remove disk from pool + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'chhypervisor', + tgt : system, + args : '--removediskfrompool;' + action + ';' + args, + msg : dialogId + }, + + success : updateResourceDialog + }); }, "Cancel": function() { $(this).dialog( "close" ); @@ -3790,14 +3843,6 @@ function openAddDisk2PoolDialog() { for (var hcp in hcp2zvm) { systemSelect.append($('')); } - - actionSelect.change(function() { - if ($(this).val() == '4') { - volume.show(); - } else if ($(this).val() == '5') { - volume.hide(); - } - }); // Generate tooltips addDiskForm.find('div input[title],select[title]').tooltip({ @@ -3840,35 +3885,48 @@ function openAddDisk2PoolDialog() { var group = $(this).find('input[name=group]').val(); // If inputs are not complete, show warning message - if (!action || !system || !group) { - var warn = createWarnBar('Please provide a value for each missing field.'); - warn.prependTo($(this)); - } else { - // Change dialog buttons - $(this).dialog('option', 'buttons', { - 'Close': function() {$(this).dialog("close");} - }); - - var args; - if (action == '4') - args = volume + ';' + volume + ';' + group; - else - args = volume + ';' + group; - - // Add disk to pool - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'chhypervisor', - tgt : system, - args : '--adddisk2pool;' + action + ';' + args, - msg : dialogId - }, - - success : updateResourceDialog - }); + var ready = true; + var args = new Array('select[name=system]', 'select[name=action]', 'input[name=volume]', 'input[name=group]'); + 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 args; + if (action == '4') + args = volume + ';' + volume + ';' + group; + else + args = volume + ';' + group; + + // Add disk to pool + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'chhypervisor', + tgt : system, + args : '--adddisk2pool;' + action + ';' + args, + 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 31240606c..ff8dd5b85 100644 --- a/xCAT-server/lib/xcat/plugins/zvm.pm +++ b/xCAT-server/lib/xcat/plugins/zvm.pm @@ -6026,7 +6026,7 @@ sub changeHypervisor { } # addeckd [dev_no] - if ( $args->[0] eq "--addeckd" ) { + elsif ( $args->[0] eq "--addeckd" ) { my $argsSize = @{$args}; if ($argsSize != 2) { xCAT::zvmUtils->printLn( $callback, "$node: (Error) Wrong number of parameters" );