From a4000ce977377d39379814703b4bbb65742f2886 Mon Sep 17 00:00:00 2001 From: phamt Date: Thu, 14 Feb 2013 05:19:00 +0000 Subject: [PATCH] Fixed SCSI/FCP devices in nodeset. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15171 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/zvmUtils.pm | 10 ++--- xCAT-UI/js/custom/zvmUtils.js | 8 ++-- xCAT-server/lib/xcat/plugins/zvm.pm | 57 +++++++++++++++++++++++------ 3 files changed, 54 insertions(+), 21 deletions(-) diff --git a/perl-xCAT/xCAT/zvmUtils.pm b/perl-xCAT/xCAT/zvmUtils.pm index de8e528fa..a7ee21798 100644 --- a/perl-xCAT/xCAT/zvmUtils.pm +++ b/perl-xCAT/xCAT/zvmUtils.pm @@ -682,7 +682,7 @@ sub getMdisks { sub getDedicates { # Get inputs - my ( $class, $user, $callback, $node ) = @_; + my ( $class, $callback, $user, $node ) = @_; my $sudo = "sudo"; if ($user eq "root") { @@ -697,18 +697,18 @@ sub getDedicates { my $propVals = xCAT::zvmUtils->getNodeProps( 'zvm', $node, @propNames ); my $hcp = $propVals->{'hcp'}; - # Get node userID + # Get node userId my $userId = $propVals->{'userid'}; - my $out = `ssh $user\@$hcp "$sudo $dir/getuserentry $userId" | grep "DEDICATE"`; - + my $out = `ssh $user\@$hcp "$sudo $dir/smcli Image_Query_DM -T $userId" | egrep -i "DEDICATE"`; + # Get DEDICATE statements my @lines = split( '\n', $out ); my @dedicates; foreach (@lines) { $_ = xCAT::zvmUtils->trimStr($_); - # Save MDISK statements + # Save statements push( @dedicates, $_ ); } diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js index 202706bdc..27a50451c 100644 --- a/xCAT-UI/js/custom/zvmUtils.js +++ b/xCAT-UI/js/custom/zvmUtils.js @@ -1501,14 +1501,14 @@ function openAddZfcpDialog(node, hcp, zvm) { loaddev = 0; } - var args = '--addzfcp;' + pool + ';' + address + ';' + loaddev + ';' + size; + var args = '--addzfcp||' + pool + '||' + address + '||' + loaddev + '||' + size; if (tag && tag != "null") { - args += ';' + tag; + args += '||' + tag; } if (portName && tag != "null") { - args += ';' + portName; + args += '||' + portName; } if (unitNo && tag != "null") { - args += ';' + unitNo; + args += '||' + unitNo; } // Add zFCP device diff --git a/xCAT-server/lib/xcat/plugins/zvm.pm b/xCAT-server/lib/xcat/plugins/zvm.pm index 6a5bb6a2a..9e4c933e0 100644 --- a/xCAT-server/lib/xcat/plugins/zvm.pm +++ b/xCAT-server/lib/xcat/plugins/zvm.pm @@ -1054,7 +1054,7 @@ sub changeVM { # #status,wwpn,lun,size,range,owner,channel,tag # used,1000000000000000,2000000000000110,8g,3B00-3B3F,ihost1,1a23,$root_device$ # free,1000000000000000,2000000000000111,,3B00-3B3F,,, - # free,1230000000000000,2000000000000112,,3B00-3B3F,,, + # free,1230000000000000;4560000000000000,2000000000000112,,3B00-3B3F,,, if (!$useWwpnLun) { my @devices = split("\n", `ssh $::SUDOER\@$hcp "$::SUDO cat $::ZFCPPOOL/$pool.conf" | egrep -i free`); $sizeFound = 0; @@ -1165,7 +1165,14 @@ sub changeVM { return; } } - + + # If there are multiple devices (multipathing), take the 1st one + my $origDevice = $device; + if ($device =~ m/;/i) { + @tmp = split(';', $device); + $device = xCAT::zvmUtils->trimStr($tmp[0]); + } + # Make sure channel has a length of 4 while (length($device) < 4) { $device = "0" . $device; @@ -1282,7 +1289,7 @@ sub changeVM { $out = `ssh $::SUDOER\@$hcp "$::SUDO sed --in-place -e $expression $::ZFCPPOOL/$pool.conf"`; } else { # Insert device entry into file - $out = `ssh $::SUDOER\@$hcp "$::SUDO echo \"used,$origWwpn,$lun,$size,,$node,$device,$tag\" >> $::ZFCPPOOL/$pool.conf"`; + $out = `ssh $::SUDOER\@$hcp "$::SUDO echo \"used,$origWwpn,$lun,$size,,$node,$origDevice,$tag\" >> $::ZFCPPOOL/$pool.conf"`; } xCAT::zvmUtils->printLn($callback, "$node: Adding FCP device... Done"); @@ -4849,7 +4856,7 @@ sub nodeSet { my $entry; my $zfcpSection = ""; foreach (@pools) { - $entry = `ssh $::SUDOER\@$hcp "$::SUDO cat $::ZFCPPOOL/$_" | egrep -i $userId`; + $entry = `ssh $::SUDOER\@$hcp "$::SUDO cat $::ZFCPPOOL/$_" | egrep -i ",$node,"`; chomp($entry); if (!$entry) { next; @@ -4858,12 +4865,23 @@ sub nodeSet { # Go through each zFCP device my @device = split('\n', $entry); foreach (@device) { - # Each entry contains: status,wwpn,lun,size,owner,channel,tag + # Each entry contains: status,wwpn,lun,size,range,owner,channel,tag @tmp = split(',', $_); my $wwpn = $tmp[1]; my $lun = $tmp[2]; - my $device = $tmp[5]; - my $tag = $tmp[6]; + my $device = $tmp[6]; + my $tag = $tmp[7]; + + # If multiple WWPNs or device channels are specified (multipathing), just take the 1st one + if ($wwpn =~ m/;/i) { + @tmp = split(';', $wwpn); + $wwpn = xCAT::zvmUtils->trimStr($tmp[0]); + } + + if ($device =~ m/;/i) { + @tmp = split(';', $device); + $device = xCAT::zvmUtils->trimStr($tmp[0]); + } # Make sure WWPN and LUN do not have 0x prefix $wwpn = xCAT::zvmUtils->replaceStr($wwpn, "0x", ""); @@ -5055,7 +5073,7 @@ END my $entry; my $zfcpSection = ""; foreach (@pools) { - $entry = `ssh $::SUDOER\@$hcp "$::SUDO cat $::ZFCPPOOL/$_" | egrep -i $userId`; + $entry = `ssh $::SUDOER\@$hcp "$::SUDO cat $::ZFCPPOOL/$_" | egrep -i ",$node,"`; chomp($entry); if (!$entry) { next; @@ -5064,12 +5082,23 @@ END # Go through each zFCP device my @device = split('\n', $entry); foreach (@device) { - # Each entry contains: status,wwpn,lun,size,owner,channel,tag + # Each entry contains: status,wwpn,lun,size,range,owner,channel,tag @tmp = split(',', $_); my $wwpn = $tmp[1]; my $lun = $tmp[2]; - my $device = $tmp[5]; - my $tag = $tmp[6]; + my $device = $tmp[6]; + my $tag = $tmp[7]; + + # If multiple WWPNs or device channels are specified (multipathing), just take the 1st one + if ($wwpn =~ m/;/i) { + @tmp = split(';', $wwpn); + $wwpn = xCAT::zvmUtils->trimStr($tmp[0]); + } + + if ($device =~ m/;/i) { + @tmp = split(';', $device); + $device = xCAT::zvmUtils->trimStr($tmp[0]); + } # Make sure WWPN and LUN do not have 0x prefix $wwpn = xCAT::zvmUtils->replaceStr($wwpn, "0x", ""); @@ -5162,7 +5191,11 @@ END # Concat dedicated devices and DASD together if ($devices) { - $dasd = $dasd . "," . $devices; + if ($dasd) { + $dasd = $dasd . "," . $devices; + } else { + $dasd = $devices; + } } # Create parmfile -- Limited to 80 characters/line, maximum of 11 lines