2013-02-03 02:16:05 +00:00
|
|
|
# IBM(c) 2013 EPL license http://www.eclipse.org/legal/epl-v10.html
|
2010-04-22 18:53:46 +00:00
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head1
|
2012-05-01 21:14:16 +00:00
|
|
|
|
|
|
|
This is a CP utility plugin for z/VM.
|
2010-04-22 18:53:46 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
package xCAT::zvmCPUtils;
|
|
|
|
use xCAT::zvmUtils;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
1;
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2010-04-22 20:19:35 +00:00
|
|
|
=head3 getUserId
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Get the user ID of a given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Returns : UserID
|
|
|
|
Example : my $userID = xCAT::zvmCPUtils->getUserId($node);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getUserId {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node ) = @_;
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get user ID using VMCP
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q userid"`;
|
2012-05-01 21:14:16 +00:00
|
|
|
my @results = split( ' ', $out );
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
return ( $results[0] );
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getHost
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Get the z/VM host of a given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Returns : z/VM host
|
|
|
|
Example : my $host = xCAT::zvmCPUtils->getHost($node);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getHost {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node ) = @_;
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get host using VMCP
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q userid"`;
|
2012-05-01 21:14:16 +00:00
|
|
|
my @results = split( ' ', $out );
|
|
|
|
my $host = $results[2];
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
return ($host);
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getPrivileges
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Get the privilege class of a given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Returns : Privilege class
|
|
|
|
Example : my $class = xCAT::zvmCPUtils->getPrivileges($node);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getPrivileges {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node ) = @_;
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get privilege class
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q priv"`;
|
2012-05-01 21:14:16 +00:00
|
|
|
my @out = split( '\n', $out );
|
|
|
|
$out[1] = xCAT::zvmUtils->trimStr( $out[1] );
|
|
|
|
$out[2] = xCAT::zvmUtils->trimStr( $out[2] );
|
|
|
|
my $str = " $out[1]\n $out[2]\n";
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
return ($str);
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getMemory
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Get the memory of a given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Returns : Memory
|
|
|
|
Example : my $memory = xCAT::zvmCPUtils->getMemory($node);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getMemory {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node ) = @_;
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get memory
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q virtual storage"`;
|
|
|
|
my @out = split( ' ', $out );
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
return ( xCAT::zvmUtils->trimStr( $out[2] ) );
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
|
|
|
|
|
2010-04-22 20:19:35 +00:00
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getCpu
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Get the processor(s) of a given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Returns : Processor(s)
|
|
|
|
Example : my $proc = xCAT::zvmCPUtils->getCpu($node);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getCpu {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node ) = @_;
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get processors
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q virtual cpus"`;
|
2012-05-01 21:14:16 +00:00
|
|
|
my $str = xCAT::zvmUtils->tabStr($out);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
return ($str);
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getNic
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Get the network interface card (NIC) of a given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Returns : NIC(s)
|
|
|
|
Example : my $nic = xCAT::zvmCPUtils->getNic($node);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getNic {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node ) = @_;
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get NIC
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q virtual nic"`;
|
2012-05-01 21:14:16 +00:00
|
|
|
my $str = xCAT::zvmUtils->tabStr($out);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
return ($str);
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getNetworkNames
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Get a list of network names available to a given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Returns : Network names
|
2013-06-19 15:58:26 +00:00
|
|
|
Example : my $lans = xCAT::zvmCPUtils->getNetworkNames($user, $node);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getNetworkNames {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node ) = @_;
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
2012-05-01 21:14:16 +00:00
|
|
|
|
|
|
|
# Get network names
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q lan | egrep 'LAN|VSWITCH'"`;
|
2012-05-01 21:14:16 +00:00
|
|
|
my @lines = split( '\n', $out );
|
|
|
|
my @parms;
|
|
|
|
my $names;
|
|
|
|
foreach (@lines) {
|
|
|
|
|
|
|
|
# Trim output
|
|
|
|
$_ = xCAT::zvmUtils->trimStr($_);
|
|
|
|
@parms = split( ' ', $_ );
|
|
|
|
|
|
|
|
# Get the network name
|
|
|
|
if ( $parms[0] eq "LAN" ) {
|
|
|
|
|
|
|
|
# Determine if this network is a hipersocket
|
|
|
|
# Only hipersocket guest LANs are supported
|
|
|
|
if ( $_ =~ m/Type: HIPERS/i ) {
|
|
|
|
$names .= $parms[0] . ":HIPERS " . $parms[1] . " " . $parms[2] . "\n";
|
|
|
|
} else {
|
|
|
|
$names .= $parms[0] . ":QDIO " . $parms[1] . " " . $parms[2] . "\n";
|
|
|
|
}
|
|
|
|
} elsif ( $parms[0] eq "VSWITCH" ) {
|
|
|
|
$names .= $parms[0] . " " . $parms[1] . " " . $parms[2] . "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ($names);
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2012-02-03 05:23:03 +00:00
|
|
|
=head3 getNetworkNamesArray
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Get an array of network names available to a given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Returns : Array of networks names
|
2013-06-19 15:58:26 +00:00
|
|
|
Example : my @networks = xCAT::zvmCPUtils->getNetworkNamesArray($user, $node);
|
2012-02-03 05:23:03 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getNetworkNamesArray {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node ) = @_;
|
2012-05-01 21:14:16 +00:00
|
|
|
my @networks;
|
|
|
|
my %netHash;
|
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get the networks used by the node
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh $user\@$node "$sudo /sbin/vmcp q v nic" | egrep -i "VSWITCH|LAN"`;
|
2012-05-01 21:14:16 +00:00
|
|
|
my @lines = split( '\n', $out );
|
|
|
|
|
|
|
|
# Loop through each line
|
|
|
|
my $line;
|
|
|
|
my @words;
|
|
|
|
my $name;
|
|
|
|
foreach(@lines) {
|
|
|
|
# Get network name
|
|
|
|
# Line should contain: MAC: 02-00-01-00-00-12 VSWITCH: SYSTEM VSW1
|
|
|
|
$line = xCAT::zvmUtils->trimStr( $_ );
|
|
|
|
@words = split( ' ', $line );
|
|
|
|
if (@words) {
|
|
|
|
$name = xCAT::zvmUtils->trimStr( $words[4] );
|
|
|
|
|
|
|
|
# If network is not 'None'
|
|
|
|
if ($name ne 'None') {
|
|
|
|
# Save network
|
|
|
|
$netHash{$name} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Push networks into array
|
|
|
|
foreach $name ( keys %netHash ) {
|
|
|
|
push(@networks, $name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return @networks;
|
2012-02-03 05:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2010-04-22 20:19:35 +00:00
|
|
|
=head3 getNetwork
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Get the network info for a given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Network name
|
|
|
|
Returns : Network configuration
|
|
|
|
Example : my $config = xCAT::zvmCPUtils->getNetwork($node, $netName);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getNetwork {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node, $netName ) = @_;
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get network info
|
|
|
|
my $out;
|
|
|
|
if ( $netName eq "all" ) {
|
2013-02-03 02:16:05 +00:00
|
|
|
$out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q lan"`;
|
2012-05-01 21:14:16 +00:00
|
|
|
} else {
|
2013-02-03 02:16:05 +00:00
|
|
|
$out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q lan $netName"`;
|
2012-05-01 21:14:16 +00:00
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
return ($out);
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getDisks
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Get the disk(s) of given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Returns : Disk(s)
|
|
|
|
Example : my $storage = xCAT::zvmCPUtils->getDisks($node);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getDisks {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node ) = @_;
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get disks
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q virtual dasd"`;
|
2012-05-01 21:14:16 +00:00
|
|
|
my $str = xCAT::zvmUtils->tabStr($out);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
return ($str);
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 loadVmcp
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Load Linux VMCP module on a given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Returns : Nothing
|
|
|
|
Example : xCAT::zvmCPUtils->loadVmcp($node);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub loadVmcp {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node ) = @_;
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Load Linux VMCP module
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/modprobe vmcp"`;
|
2012-05-01 21:14:16 +00:00
|
|
|
return;
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getVswitchId
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Get the VSwitch ID(s) of given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Returns : VSwitch ID(s)
|
|
|
|
Example : my @vswitch = xCAT::zvmCPUtils->getVswitchId($node);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getVswitchId {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node ) = @_;
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get VSwitch
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q v nic" | grep "VSWITCH"`;
|
2012-05-01 21:14:16 +00:00
|
|
|
my @lines = split( '\n', $out );
|
|
|
|
my @parms;
|
|
|
|
my @vswitch;
|
|
|
|
foreach (@lines) {
|
|
|
|
@parms = split( ' ', $_ );
|
|
|
|
push( @vswitch, $parms[4] );
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
return @vswitch;
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 grantVSwitch
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Grant VSwitch access for a given userID
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
zHCP
|
2012-05-01 21:14:16 +00:00
|
|
|
User ID
|
|
|
|
VSWITCH ID
|
|
|
|
Returns : Operation results (Done/Failed)
|
|
|
|
Example : my $out = xCAT::zvmCPUtils->grantVswitch($callback, $hcp, $userId, $vswitchId);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub grantVSwitch {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $callback, $user, $hcp, $userId, $vswitchId ) = @_;
|
|
|
|
|
|
|
|
# Directory where executables are
|
|
|
|
my $dir = '/opt/zhcp/bin';
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
# Use SMAPI EXEC
|
|
|
|
my $out = `ssh $user\@$hcp "$sudo $dir/smcli Virtual_Network_Vswitch_Set -T SYSTEM -n $vswitchId -I $userId"`;
|
2013-03-12 23:10:58 +00:00
|
|
|
xCAT::zvmUtils->printSyslog("grantVSwitch- ssh $user\@$hcp $sudo $dir/smcli Virtual_Network_Vswitch_Set -T SYSTEM -n $vswitchId -I $userId");
|
2012-05-01 21:14:16 +00:00
|
|
|
$out = xCAT::zvmUtils->trimStr($out);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
# If return string contains 'Done' - Operation was successful
|
2012-05-01 21:14:16 +00:00
|
|
|
my $retStr;
|
2013-02-03 02:16:05 +00:00
|
|
|
if ( $out =~ m/Done/i ) {
|
2012-05-01 21:14:16 +00:00
|
|
|
$retStr = "Done\n";
|
|
|
|
} else {
|
|
|
|
$retStr = "Failed\n";
|
|
|
|
return $retStr;
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
return $retStr;
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 flashCopy
|
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
Description : Flash copy
|
|
|
|
Arguments : User (root or non-root)
|
|
|
|
zHCP
|
|
|
|
Source userId
|
2012-05-01 21:14:16 +00:00
|
|
|
Source address
|
2013-02-03 02:16:05 +00:00
|
|
|
Target userId
|
2012-05-01 21:14:16 +00:00
|
|
|
Target address
|
|
|
|
Returns : Operation results (Done/Failed)
|
2013-02-03 02:16:05 +00:00
|
|
|
Example : my $results = xCAT::zvmCPUtils->flashCopy($user, $hcp, $srcAddr, $targetAddr);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub flashCopy {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $hcp, $srcAddr, $tgtAddr ) = @_;
|
|
|
|
|
|
|
|
# Directory where executables are
|
|
|
|
my $dir = '/opt/zhcp/bin';
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
# Flash copy using CP
|
|
|
|
my $out = `ssh $user\@$hcp "$sudo /sbin/vmcp flashcopy $srcAddr 0 end to $tgtAddr 0 end synchronous"`;
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
$out = xCAT::zvmUtils->trimStr($out);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# If return string contains 'Command complete' - Operation was successful
|
|
|
|
my $retStr = "";
|
|
|
|
if ( $out =~ m/Command complete/i ) {
|
2013-02-03 02:16:05 +00:00
|
|
|
$retStr = "Copying data via CP FLASHCOPY... Done\n";
|
|
|
|
} else {
|
|
|
|
$out = xCAT::zvmUtils->tabStr($out);
|
|
|
|
$retStr = "Copying data via CP FLASHCOPY... Failed\n$out";
|
|
|
|
}
|
|
|
|
|
|
|
|
return $retStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 smapiFlashCopy
|
|
|
|
|
|
|
|
Description : Flash copy using SMAPI
|
|
|
|
Arguments : User (root or non-root)
|
|
|
|
zHCP
|
|
|
|
Source userId
|
|
|
|
Source address
|
|
|
|
Target userId
|
|
|
|
Target address
|
|
|
|
Returns : Operation results (Done/Failed)
|
|
|
|
Example : my $results = xCAT::zvmCPUtils->smapiFlashCopy($user, $node, $srcId, $srcAddr, $tgtId, $targetAddr);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub smapiFlashCopy {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $user, $hcp, $srcId, $srcAddr, $tgtId, $tgtAddr ) = @_;
|
|
|
|
|
|
|
|
# Directory where executables are
|
|
|
|
my $dir = '/opt/zhcp/bin';
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
my $hcpUserId = xCAT::zvmCPUtils->getUserId($user, $hcp);
|
|
|
|
|
|
|
|
# Use SMAPI EXEC to flash copy
|
|
|
|
my $cmd = '\"' . "CMD=FLASHCOPY $srcId $srcAddr 0 END $tgtId $tgtAddr 0 END" . '\"';
|
|
|
|
my $out = `ssh $user\@$hcp "$sudo $dir/smcli xCAT_Commands_IUO -T $hcpUserId -c $cmd"`;
|
2013-03-12 23:10:58 +00:00
|
|
|
xCAT::zvmUtils->printSyslog("smapiFlashCopy- ssh $user\@$hcp $sudo $dir/smcli xCAT_Commands_IUO -T $hcpUserId -c $cmd");
|
2013-02-03 02:16:05 +00:00
|
|
|
|
|
|
|
$out = xCAT::zvmUtils->trimStr($out);
|
|
|
|
|
|
|
|
# If return string contains 'Done' - Operation was successful
|
|
|
|
my $retStr = "";
|
|
|
|
if ( $out =~ m/Done/i ) {
|
|
|
|
$retStr = "Copying data via SMAPI FLASHCOPY... Done\n";
|
2012-05-01 21:14:16 +00:00
|
|
|
} else {
|
|
|
|
$out = xCAT::zvmUtils->tabStr($out);
|
2013-02-03 02:16:05 +00:00
|
|
|
$retStr = "Copying data via SMAPI FLASHCOPY... $out";
|
2012-05-01 21:14:16 +00:00
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
return $retStr;
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 punch2Reader
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Write file to z/VM punch and transfer it to reader
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
zHCP
|
2012-05-01 21:14:16 +00:00
|
|
|
UserID to receive file
|
|
|
|
Source file
|
|
|
|
Target file to be created by punch (e.g. sles.parm)
|
|
|
|
Options, e.g. -t (Convert EBCDIC to ASCII)
|
|
|
|
Returns : Operation results (Done/Failed)
|
|
|
|
Example : my $rc = xCAT::zvmCPUtils->punch2Reader($hcp, $userId, $srcFile, $tgtFile, $options);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub punch2Reader {
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $hcp, $userId, $srcFile, $tgtFile, $options ) = @_;
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get source node OS
|
|
|
|
my $os = xCAT::zvmUtils->getOsVersion($user, $hcp);
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Punch to reader
|
2013-02-03 02:16:05 +00:00
|
|
|
# VMUR located in different directories on RHEL and SLES
|
2013-10-23 19:40:25 +00:00
|
|
|
my $vmur;
|
2013-02-03 02:16:05 +00:00
|
|
|
if ( $os =~ m/sles10/i ) {
|
2013-10-23 19:40:25 +00:00
|
|
|
$vmur = "/sbin/vmur";
|
2013-02-03 02:16:05 +00:00
|
|
|
} else {
|
2013-10-23 19:40:25 +00:00
|
|
|
$vmur = "/usr/sbin/vmur";
|
2013-02-03 02:16:05 +00:00
|
|
|
}
|
2013-10-23 19:40:25 +00:00
|
|
|
my $out;
|
|
|
|
my $done = 0;
|
|
|
|
|
|
|
|
until ( $done ) {
|
|
|
|
$out = `ssh -o ConnectTimeout=5 $user\@$hcp "$sudo $vmur punch $options -u $userId -r $srcFile -N $tgtFile" 2>&1`;
|
|
|
|
my $rc = $? >> 8;
|
|
|
|
if ( $rc == 255 ) {
|
|
|
|
$out = "(Error) Unable to communicate with the zHCP system: $hcp";
|
|
|
|
$done = 1;
|
|
|
|
} elsif ( $out =~ m/A concurrent instance of vmur is already active/i ) {
|
|
|
|
# Recoverable error: retry the command after a delay
|
|
|
|
xCAT::zvmUtils->printSyslog( "punch2Reader() Punch in use on $hcp, retrying in 15 seconds" );
|
|
|
|
sleep( 15 );
|
|
|
|
} else {
|
|
|
|
# Punch appears successful -- Look for the completion string
|
|
|
|
my $searchStr = "created and transferred";
|
|
|
|
if ( !( $out =~ m/$searchStr/i ) ) {
|
|
|
|
chomp( $out );
|
|
|
|
$out = "Failed, punch info: '$out'\n";
|
|
|
|
xCAT::zvmUtils->printSyslog( "punch2Reader() Failed punching $srcFile to $userId from $hcp, info: '$out'" );
|
|
|
|
} else {
|
|
|
|
$out = "Done\n";
|
|
|
|
}
|
|
|
|
$done = 1;
|
|
|
|
}
|
2012-05-01 21:14:16 +00:00
|
|
|
}
|
2013-10-23 19:40:25 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
return $out;
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 purgeReader
|
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
Description : Purge reader
|
|
|
|
Arguments : User (root or non-root)
|
|
|
|
zHCP
|
2012-05-01 21:14:16 +00:00
|
|
|
UserID to purge reader
|
|
|
|
Returns : Nothing
|
|
|
|
Example : my $rc = xCAT::zvmCPUtils->purgeReader($hcp, $userId);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub purgeReader {
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $hcp, $userId ) = @_;
|
|
|
|
|
|
|
|
# Directory where executables are
|
|
|
|
my $dir = '/opt/zhcp/bin';
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
|
|
|
|
2013-03-20 20:47:12 +00:00
|
|
|
xCAT::zvmUtils->printSyslog("sudoer:$user zHCP:$hcp sudo:$sudo");
|
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out;
|
|
|
|
if (xCAT::zvmUtils->smapi4xcat($user, $hcp)) {
|
|
|
|
# Use SMAPI EXEC to purge reader
|
|
|
|
my $cmd = '\"' . "CMD=PURGE $userId RDR ALL" . '\"';
|
|
|
|
$out = `ssh $user\@$hcp "$sudo $dir/smcli xCAT_Commands_IUO -T $userId -c $cmd"`;
|
2013-03-20 20:47:12 +00:00
|
|
|
xCAT::zvmUtils->printSyslog("smcli xCAT_Commands_IUO -T $userId -c $cmd");
|
2013-02-03 02:16:05 +00:00
|
|
|
} else {
|
|
|
|
# Purge reader using CP
|
|
|
|
$out = `ssh -o ConnectTimeout=5 $user\@$hcp "$sudo /sbin/vmcp purge $userId rdr all"`;
|
2013-03-20 20:47:12 +00:00
|
|
|
xCAT::zvmUtils->printSyslog("/sbin/vmcp purge $userId rdr all");
|
2013-02-03 02:16:05 +00:00
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
$out = xCAT::zvmUtils->trimStr($out);
|
|
|
|
return $out;
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 sendCPCmd
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Send CP command to a given userID (Class C users only)
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
zHCP
|
2012-05-01 21:14:16 +00:00
|
|
|
UserID to send CP command
|
|
|
|
Returns : Nothing
|
|
|
|
Example : xCAT::zvmCPUtils->sendCPCmd($hcp, $userId, $cmd);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub sendCPCmd {
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $hcp, $userId, $cmd ) = @_;
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
# Directory where executables are
|
|
|
|
my $dir = '/opt/zhcp/bin';
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
|
|
|
|
2013-03-20 20:47:12 +00:00
|
|
|
xCAT::zvmUtils->printSyslog("sudoer:$user zHCP:$hcp sudo:$sudo");
|
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out;
|
|
|
|
if (xCAT::zvmUtils->smapi4xcat($user, $hcp)) {
|
|
|
|
# Use SMAPI EXEC to send command
|
|
|
|
$cmd = '\"' . "CMD=SEND CP $userId " . uc($cmd) . '\"';
|
|
|
|
$out = `ssh $user\@$hcp "$sudo $dir/smcli xCAT_Commands_IUO -T $userId -c $cmd"`;
|
2013-03-20 20:47:12 +00:00
|
|
|
xCAT::zvmUtils->printSyslog("smcli xCAT_Commands_IUO -T $userId -c $cmd");
|
2013-02-03 02:16:05 +00:00
|
|
|
} else {
|
|
|
|
# Send CP command to given user
|
|
|
|
$out = `ssh $user\@$hcp "$sudo /sbin/vmcp send cp $userId $cmd"`;
|
2013-03-20 20:47:12 +00:00
|
|
|
xCAT::zvmUtils->printSyslog("/sbin/vmcp send cp $userId $cmd");
|
2013-02-03 02:16:05 +00:00
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
$out = xCAT::zvmUtils->trimStr($out);
|
2012-05-01 21:14:16 +00:00
|
|
|
return;
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getNetworkLayer
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Get the network layer for a given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Network name
|
|
|
|
Returns : 2 - Layer 2
|
|
|
|
3 - Layer 3
|
|
|
|
-1 - Failed to get network layer
|
|
|
|
Example : my $layer = xCAT::zvmCPUtils->getNetworkLayer($node);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getNetworkLayer {
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node, $netName ) = @_;
|
2012-05-01 21:14:16 +00:00
|
|
|
|
2013-02-03 02:16:05 +00:00
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Exit if the network name is not given
|
|
|
|
if ( !$netName ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get network type (Layer 2 or 3)
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q lan $netName"`;
|
2012-05-01 21:14:16 +00:00
|
|
|
if ( !$out ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Go through each line
|
|
|
|
my $layer = 3; # Default to layer 3
|
|
|
|
my @lines = split( '\n', $out );
|
|
|
|
foreach (@lines) {
|
|
|
|
|
|
|
|
# If the line contains ETHERNET, then it is a layer 2 network
|
|
|
|
if ( $_ =~ m/ETHERNET/i ) {
|
|
|
|
$layer = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $layer;
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getNetworkType
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Get the network type of a given network
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
zHCP
|
2012-05-01 21:14:16 +00:00
|
|
|
Name of network
|
|
|
|
Returns : Network type (VSWITCH/HIPERS/QDIO)
|
|
|
|
Example : my $netType = xCAT::zvmCPUtils->getNetworkType($hcp, $netName);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getNetworkType {
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $hcp, $netName ) = @_;
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get network details
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $user\@$hcp "$sudo /sbin/vmcp q lan $netName" | grep "Type"`;
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Go through each line and determine network type
|
|
|
|
my @lines = split( '\n', $out );
|
|
|
|
my $netType = "";
|
|
|
|
foreach (@lines) {
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Virtual switch
|
|
|
|
if ( $_ =~ m/VSWITCH/i ) {
|
|
|
|
$netType = "VSWITCH";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# HiperSocket guest LAN
|
|
|
|
elsif ( $_ =~ m/HIPERS/i ) {
|
|
|
|
$netType = "HIPERS";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# QDIO guest LAN
|
|
|
|
elsif ( $_ =~ m/QDIO/i ) {
|
|
|
|
$netType = "QDIO";
|
|
|
|
}
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
return $netType;
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 defineCpu
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
Description : Add processor(s) to given node
|
2013-02-03 02:16:05 +00:00
|
|
|
Arguments : User (root or non-root)
|
|
|
|
Node
|
2012-05-01 21:14:16 +00:00
|
|
|
Returns : Nothing
|
|
|
|
Example : my $out = xCAT::zvmCPUtils->defineCpu($node, $addr, $type);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub defineCpu {
|
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Get inputs
|
2013-02-03 02:16:05 +00:00
|
|
|
my ( $class, $user, $node, $addr, $type ) = @_;
|
|
|
|
|
|
|
|
my $sudo = "sudo";
|
|
|
|
if ($user eq "root") {
|
|
|
|
$sudo = "";
|
|
|
|
}
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
# Define processor(s)
|
2013-02-03 02:16:05 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp define cpu $addr type $type"`;
|
2010-04-22 20:19:35 +00:00
|
|
|
|
2012-05-01 21:14:16 +00:00
|
|
|
return ($out);
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|