diff --git a/perl-xCAT/xCAT/zvmUtils.pm b/perl-xCAT/xCAT/zvmUtils.pm index 1a32ff221..373a5afde 100644 --- a/perl-xCAT/xCAT/zvmUtils.pm +++ b/perl-xCAT/xCAT/zvmUtils.pm @@ -2116,4 +2116,34 @@ sub querySSI { $ssi =~ s/^\s*//; return $ssi; +} + +#------------------------------------------------------- + +=head3 rExecute + + Description : Execute a remote command + Arguments : User (root or non-root) + Node + Returns : Output returned from executing command + Example : my $out = xCAT::zvmUtils->rExecute($user, $node, $cmd); + +=cut + +#------------------------------------------------------- +sub rExecute { + my ( $class, $user, $node, $cmd ) = @_; + + my $out; + my $sudo = "sudo"; + if ($user eq "root") { + # Just execute the command if root + $out = `ssh $user\@$node "$cmd"`; + return $out; + } + + # Encapsulate command in single quotes + $cmd = "'" . $cmd . "'"; + $out = `ssh $user\@$node "$sudo sh -c $cmd"`; + return $out; } \ 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 96c350a40..4c21756cc 100644 --- a/xCAT-server/lib/xcat/plugins/zvm.pm +++ b/xCAT-server/lib/xcat/plugins/zvm.pm @@ -1082,6 +1082,7 @@ sub changeVM { # If there are multiple paths, take the 1st one # Handle multi-pathing in postscript because autoyast/kickstart does not support it. + my $origWwpn = $wwpn; if ($wwpn =~ m/;/i) { @tmp = split(';', $wwpn); $wwpn = xCAT::zvmUtils->trimStr($tmp[0]); @@ -1233,12 +1234,12 @@ sub changeVM { } # Entry order: status,wwpn,lun,size,owner,channel,tag - my $update = "used,$wwpn,$lun,$info[3],$info[4],$node,$device,$tag"; + my $update = "used,$info[1],$lun,$info[3],$info[4],$node,$device,$tag"; my $expression = "'s#" . $select . "#" .$update . "#i'"; $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,$wwpn,$lun,$size,,$node,$device,$tag\" >> $::ZFCPPOOL/$pool.conf"`; + $out = `ssh $::SUDOER\@$hcp "$::SUDO echo \"used,$origWwpn,$lun,$size,,$node,$device,$tag\" >> $::ZFCPPOOL/$pool.conf"`; } xCAT::zvmUtils->printLn($callback, "$node: Adding FCP device... Done"); @@ -1538,13 +1539,13 @@ sub changeVM { my $mode = $args->[3]; # Dedicate device to directory entry - $out = `ssh $::SUDOER\@$hcp "$::SUDO $::DIR/smcli Image_Device_Dedicate_DM -T $userId -v $vaddr -r $raddr -o $mode"`; + $out = `ssh $::SUDOER\@$hcp "$::SUDO $::DIR/smcli Image_Device_Dedicate_DM -T $userId -v $vaddr -r $raddr -R $mode"`; xCAT::zvmUtils->printLn( $callback, "$node: $out" ); # Dedicate device to active configuration my $ping = `pping $node`; if (!($ping =~ m/noping/i)) { - $out = `ssh $::SUDOER\@$hcp "$::SUDO $::DIR/smcli Image_Device_Dedicate -T $userId -v $vaddr -r $raddr -o $mode"`; + $out = `ssh $::SUDOER\@$hcp "$::SUDO $::DIR/smcli Image_Device_Dedicate -T $userId -v $vaddr -r $raddr -R $mode"`; xCAT::zvmUtils->printLn( $callback, "$node: $out" ); }