From 7ba40528e451aed2b7893bc6ee9054ba51dcab5d Mon Sep 17 00:00:00 2001 From: phamt Date: Thu, 14 Feb 2013 04:09:07 +0000 Subject: [PATCH] Added option to query all accessible LUNs. Fixed query WWPNs. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15170 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/custom/zvmUtils.js | 75 +----------------------- xCAT-UI/js/nodes/nodes.js | 1 - xCAT-server/lib/xcat/plugins/zvm.pm | 89 ++++++++++++++++++++++++++--- 3 files changed, 81 insertions(+), 84 deletions(-) diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js index f856b8f46..202706bdc 100644 --- a/xCAT-UI/js/custom/zvmUtils.js +++ b/xCAT-UI/js/custom/zvmUtils.js @@ -1440,15 +1440,7 @@ function openAddZfcpDialog(node, hcp, zvm) { var portName = $('
'); var unitNo = $('
'); advanced.append(portName, unitNo); - - var wwpns = $.cookie(zvm + 'wwpns'); - if (wwpns) { - // Turn on auto complete - portName.find('input').autocomplete({ - source: wwpns.split(',') - }); - } - + // Toggle port name and unit number when clicking on advanced link advancedLnk.click(function() { advanced.toggle(); @@ -2064,7 +2056,6 @@ function openAddScsi2SystemDialog(hcp) { var fcpWwpn = $(''); devPathRow.append(fcpWwpn); - var wwpns = ""; if ($.cookie('zvms')) { zvms = $.cookie('zvms').split(','); var zvm; @@ -2072,14 +2063,7 @@ function openAddScsi2SystemDialog(hcp) { var args = zvms[i].split(':'); var zvm = args[0].toLowerCase(); var iHcp = args[1]; - - wwpns += "," + $.cookie(zvm + 'wwpns'); } - - wwpns = wwpns.replace(',,', ','); - fcpWwpn.find('input').autocomplete({ - source: wwpns.split(',') - }); } // Create FCP LUN input @@ -2112,9 +2096,6 @@ function openAddScsi2SystemDialog(hcp) { // Create FCP WWPN input var fcpWwpn = $(''); devPathRow.append(fcpWwpn); - fcpWwpn.find('input').autocomplete({ - source: wwpns.split(',') - }); // Create FCP LUN input var fcpLun = $(''); @@ -5457,40 +5438,6 @@ function createZProvisionNew(inst) { return provNew; } -/** - * Load WWPNs - */ -function loadWwpns() { - if (!$.cookie('zvms')) { - return; - } - - // Retrieve WWPNs found on z/VM system - var zvms = $.cookie('zvms').split(','); - for (var i in zvms) { - args = zvms[i].split(':'); - zvm = args[0].toLowerCase(); - hcp = args[1]; - - if (!$.cookie(zvm + 'wwpns')) { - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'rinv', - tgt : zvm, - args : '--wwpn', - msg : zvm - }, - - success : function(data) { - setWwpnCookies(data); - } - }); - } - } -} - /** * Load zVMs into column (service page) * @@ -5696,26 +5643,6 @@ function setZfcpPoolCookies(data) { } } -/** - * Set a cookie for WWPNs of z/VM system - * - * @param data Data from HTTP request - */ -function setWwpnCookies(data) { - if (data.rsp[0].length) { - var zvm = data.msg; - var wwpns = data.rsp[0].split(zvm + ': '); - for (var i in wwpns) { - wwpns[i] = jQuery.trim(wwpns[i]); - } - - // Set cookie to expire in 60 minutes - var exDate = new Date(); - exDate.setTime(exDate.getTime() + (240 * 60 * 1000)); - $.cookie(zvm + 'wwpns', wwpns, { expires: exDate }); - } -} - /** * Create virtual machine (service page) * diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js index bd867788b..668704211 100644 --- a/xCAT-UI/js/nodes/nodes.js +++ b/xCAT-UI/js/nodes/nodes.js @@ -3276,7 +3276,6 @@ function advancedLoad(group){ success : function(data) { setzVMCookies(data); - loadWwpns(); } }); } diff --git a/xCAT-server/lib/xcat/plugins/zvm.pm b/xCAT-server/lib/xcat/plugins/zvm.pm index ff8dd5b85..6a5bb6a2a 100644 --- a/xCAT-server/lib/xcat/plugins/zvm.pm +++ b/xCAT-server/lib/xcat/plugins/zvm.pm @@ -6650,6 +6650,68 @@ sub inventoryHypervisor { } } + # luns [fcp_device] (supported only on z/VM 6.2) + elsif ( $args->[0] eq "--luns" ) { + # Find the LUNs accessible thru given zFCP device + my $fcp = lc($args->[1]); + my $argsSize = @{$args}; + if ($argsSize < 2) { + xCAT::zvmUtils->printLn( $callback, "$node: (Error) Wrong number of parameters" ); + return; + } + + $out = `ssh $::SUDOER\@$hcp "$::SUDO $::DIR/smcli System_FCP_Free_Query -T $hcpUserId -k fcp_dev=$fcp" | egrep -i "FCP device number:|World wide port number:|Logical unit number:|Number of bytes residing on the logical unit:"`; + + my @wwpns = split( "\n", $out ); + my %map; + + my $wwpn = ""; + my $lun = ""; + my $size = ""; + foreach (@wwpns) { + # Extract the device number + if ($_ =~ "World wide port number:") { + $_ =~ s/^\s+World wide port number:(.*)/$1/; + $_ =~ s/^\s+//; + $_ =~ s/\s+$//; + $wwpn = $_; + + if (!scalar($map{$wwpn})) { + $map{$wwpn} = {}; + } + } elsif ($_ =~ "Logical unit number:") { + $_ =~ s/^\s+Logical unit number:(.*)/$1/; + $_ =~ s/^\s+//; + $_ =~ s/\s+$//; + $lun = $_; + + $map{$wwpn}{$lun} = ""; + } elsif ($_ =~ "Number of bytes residing on the logical unit:") { + $_ =~ s/^\s+Number of bytes residing on the logical unit:(.*)/$1/; + $_ =~ s/^\s+//; + $_ =~ s/\s+$//; + $size = $_; + + $map{$wwpn}{$lun} = $size; + } + } + + xCAT::zvmUtils->printLn($callback, "#status,wwpn,lun,size,range,owner,channel,tag"); + foreach $wwpn (sort keys %map) { + foreach $lun (sort keys %{$map{$wwpn}}) { + # status, wwpn, lun, size, range, owner, channel, tag + $size = sprintf("%.1f", $map{$wwpn}{$lun}/1073741824); # Convert size to GB + + if ($size > 0) { + $size .= "G"; + xCAT::zvmUtils->printLn($callback, "unknown,$wwpn,$lun,$size,,,,"); + } + } + } + + $str = ""; + } + # networknames elsif ( $args->[0] eq "--networknames" || $args->[0] eq "--getnetworknames" ) { $str = xCAT::zvmCPUtils->getNetworkNames($::SUDOER, $hcp); @@ -6771,20 +6833,29 @@ sub inventoryHypervisor { $str = `ssh $::SUDOER\@$hcp "$::SUDO $::DIR/smcli Virtual_Network_Vswitch_Query_Stats -T $hcpUserId $argStr"`; } - # wwpn - elsif ( $args->[0] eq "--wwpn" ) { - $out = `ssh $::SUDOER\@$hcp "$::SUDO $::DIR/smcli System_WWPN_Query -T $hcpUserId" | egrep -i "Physical world wide port number"`; + # wwpn [fcp_device] (supported only on z/VM 6.2) + elsif ( $args->[0] eq "--wwpns" ) { + my $fcp = lc($args->[1]); + my $argsSize = @{$args}; + if ($argsSize < 2) { + xCAT::zvmUtils->printLn( $callback, "$node: (Error) Wrong number of parameters" ); + return; + } + + $out = `ssh $::SUDOER\@$hcp "$::SUDO $::DIR/smcli System_FCP_Free_Query -T $hcpUserId -k fcp_dev=$fcp" | egrep -i "World wide port number:"`; my @wwpns = split( "\n", $out ); my %uniqueWwpns; foreach (@wwpns) { # Extract the device number - $_ =~ s/^\s+Physical world wide port number:(.*)/$1/; - $_ =~ s/^\s+//; - $_ =~ s/\s+$//; - - # Save only unique WWPNs - $uniqueWwpns{$_} = 1; + if ($_ =~ "World wide port number:") { + $_ =~ s/^\s+World wide port number:(.*)/$1/; + $_ =~ s/^\s+//; + $_ =~ s/\s+$//; + + # Save only unique WWPNs + $uniqueWwpns{$_} = 1; + } } my $wwpn;