2009-10-01 18:28:00 +00:00
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head1
|
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
This is a CP utility plugin for z/VM.
|
2009-10-01 18:28:00 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
package xCAT::zvmCPUtils;
|
|
|
|
use xCAT::zvmUtils;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
1;
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getUserId
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Get userID of given node
|
|
|
|
Arguments : Node
|
2009-10-01 18:28:00 +00:00
|
|
|
Returns : UserID
|
|
|
|
Example : my $userID = xCAT::zvmCPUtils->getUserId($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getUserId {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Get userId using VMCP
|
2009-12-08 19:39:00 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q userid"`;
|
2009-10-01 18:28:00 +00:00
|
|
|
my @results = split( ' ', $out );
|
2009-12-08 19:39:00 +00:00
|
|
|
|
2009-10-01 18:28:00 +00:00
|
|
|
return ( $results[0] );
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getSn
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Get serial number for given node
|
|
|
|
Arguments : Node
|
2009-10-01 18:28:00 +00:00
|
|
|
Returns : Serial number
|
|
|
|
Example : my $sn = xCAT::zvmCPUtils->getSn($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getSn {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
# Get node properties from 'zvm' table
|
|
|
|
my @propNames = ('hcp');
|
|
|
|
my $propVals = xCAT::zvmUtils->getNodeProps( 'zvm', $node, @propNames );
|
|
|
|
|
2009-10-01 18:28:00 +00:00
|
|
|
# Get HCP
|
2009-11-09 21:12:41 +00:00
|
|
|
my $hcp = $propVals->{'hcp'};
|
2009-10-01 18:28:00 +00:00
|
|
|
|
|
|
|
# Look in /proc/sysinfo to get serial number
|
2009-11-09 21:12:41 +00:00
|
|
|
my $out = `ssh $hcp "cat /proc/sysinfo" | egrep -i "manufacturer|type|model|sequence code|plant"`;
|
2009-10-01 18:28:00 +00:00
|
|
|
my @props = split( '\n', $out );
|
|
|
|
my $man = $props[0];
|
|
|
|
my $type = $props[1];
|
|
|
|
my $model = $props[2];
|
|
|
|
my $sn = $props[3];
|
|
|
|
my $plant = $props[4];
|
|
|
|
|
|
|
|
# Trim and get property value
|
|
|
|
# Get manufacturer
|
|
|
|
@props = split( ':', $man );
|
2009-11-09 21:12:41 +00:00
|
|
|
$man = xCAT::zvmUtils->trimStr( $props[1] );
|
2009-10-01 18:28:00 +00:00
|
|
|
|
|
|
|
# Get machine type
|
|
|
|
@props = split( ':', $type );
|
2009-11-09 21:12:41 +00:00
|
|
|
$type = xCAT::zvmUtils->trimStr( $props[1] );
|
2009-10-01 18:28:00 +00:00
|
|
|
|
|
|
|
# Get model
|
|
|
|
@props = split( ': ', $model );
|
2009-11-09 21:12:41 +00:00
|
|
|
$model = xCAT::zvmUtils->trimStr( $props[1] );
|
2009-10-01 18:28:00 +00:00
|
|
|
@props = split( ' ', $model );
|
2009-11-09 21:12:41 +00:00
|
|
|
$model = xCAT::zvmUtils->trimStr( $props[0] );
|
2009-10-01 18:28:00 +00:00
|
|
|
|
|
|
|
# Get sequence number
|
|
|
|
@props = split( ':', $sn );
|
2009-11-09 21:12:41 +00:00
|
|
|
$sn = xCAT::zvmUtils->trimStr( $props[1] );
|
2009-10-01 18:28:00 +00:00
|
|
|
|
|
|
|
# Get plant
|
|
|
|
@props = split( ':', $plant );
|
2009-11-09 21:12:41 +00:00
|
|
|
$plant = xCAT::zvmUtils->trimStr( $props[1] );
|
2009-10-01 18:28:00 +00:00
|
|
|
|
|
|
|
return ("$man-$type-$model-$plant-$sn");
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getHost
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Get z/VM host for given node
|
|
|
|
Arguments : Node
|
2009-10-01 18:28:00 +00:00
|
|
|
Returns : z/VM host
|
|
|
|
Example : my $host = xCAT::zvmCPUtils->getHost($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getHost {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Get host using VMCP
|
2009-11-09 21:12:41 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q userid"`;
|
2009-10-01 18:28:00 +00:00
|
|
|
my @results = split( ' ', $out );
|
|
|
|
my $host = $results[2];
|
|
|
|
|
|
|
|
return ($host);
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getOs
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Get operating system name of given node
|
|
|
|
Arguments : Node
|
2009-10-01 18:28:00 +00:00
|
|
|
Returns : Operating system name
|
|
|
|
Example : my $osName = xCAT::zvmCPUtils->getOs($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getOs {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Get operating system
|
2009-11-09 21:12:41 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=10 $node "cat /etc/*release"`;
|
2009-10-01 18:28:00 +00:00
|
|
|
my @results = split( '\n', $out );
|
2009-11-09 21:12:41 +00:00
|
|
|
return ( xCAT::zvmUtils->trimStr( $results[0] ) );
|
2009-10-01 18:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getArch
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Get architecture of given node
|
|
|
|
Arguments : Node
|
2009-10-01 18:28:00 +00:00
|
|
|
Returns : Architecture of node
|
|
|
|
Example : my $arch = xCAT::zvmCPUtils->getArch($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getArch {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Get host using VMCP
|
2009-11-09 21:12:41 +00:00
|
|
|
my $arch = `ssh $node "uname -p"`;
|
2009-10-01 18:28:00 +00:00
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
return ( xCAT::zvmUtils->trimStr($arch) );
|
2009-10-01 18:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getPrivileges
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Get privilege class of given node
|
|
|
|
Arguments : Node
|
2009-11-09 21:12:41 +00:00
|
|
|
Returns : Privilege class
|
2009-10-01 18:28:00 +00:00
|
|
|
Example : my $memory = xCAT::zvmCPUtils->getPrivileges($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getPrivileges {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
# Get privilege class
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q priv"`;
|
2009-10-01 18:28:00 +00:00
|
|
|
my @out = split( '\n', $out );
|
2009-11-09 21:12:41 +00:00
|
|
|
$out[1] = xCAT::zvmUtils->trimStr( $out[1] );
|
|
|
|
$out[2] = xCAT::zvmUtils->trimStr( $out[2] );
|
2009-10-01 18:28:00 +00:00
|
|
|
my $str = " $out[1]\n $out[2]\n";
|
2009-12-08 19:39:00 +00:00
|
|
|
|
2009-10-01 18:28:00 +00:00
|
|
|
return ($str);
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getMemory
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Get memory of given node
|
|
|
|
Arguments : Node
|
2009-11-09 21:12:41 +00:00
|
|
|
Returns : Memory
|
2009-10-01 18:28:00 +00:00
|
|
|
Example : my $memory = xCAT::zvmCPUtils->getMemory($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getMemory {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
# Get memory
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q virtual storage"`;
|
2009-10-01 18:28:00 +00:00
|
|
|
my @out = split( '=', $out );
|
2009-12-08 19:39:00 +00:00
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
return ( xCAT::zvmUtils->trimStr( $out[1] ) );
|
2009-10-01 18:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getCpu
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Get processor(s) of given node
|
|
|
|
Arguments : Node
|
|
|
|
Returns : Processor(s)
|
2009-10-01 18:28:00 +00:00
|
|
|
Example : my $proc = xCAT::zvmCPUtils->getCpu($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getCpu {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
# Get processors
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q virtual cpus"`;
|
2009-10-01 18:28:00 +00:00
|
|
|
my $str = xCAT::zvmUtils->tabStr($out);
|
|
|
|
|
|
|
|
return ($str);
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getNic
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Get network interface card (NIC) of given node
|
|
|
|
Arguments : Node
|
|
|
|
Returns : NIC(s)
|
2009-10-01 18:28:00 +00:00
|
|
|
Example : my $nic = xCAT::zvmCPUtils->getNic($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getNic {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
# Get NIC
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q virtual nic"`;
|
2009-10-01 18:28:00 +00:00
|
|
|
my $str = xCAT::zvmUtils->tabStr($out);
|
2009-12-08 19:39:00 +00:00
|
|
|
|
2009-10-01 18:28:00 +00:00
|
|
|
return ($str);
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getDisks
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Get disk(s) of given node
|
|
|
|
Arguments : Node
|
|
|
|
Returns : Disk(s)
|
2009-10-01 18:28:00 +00:00
|
|
|
Example : my $storage = xCAT::zvmCPUtils->getDisks($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getDisks {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
# Get disks
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q virtual dasd"`;
|
2009-10-01 18:28:00 +00:00
|
|
|
my $str = xCAT::zvmUtils->tabStr($out);
|
2009-12-08 19:39:00 +00:00
|
|
|
|
2009-10-01 18:28:00 +00:00
|
|
|
return ($str);
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 loadVmcp
|
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
Description : Load VMCP module on specified node
|
2009-12-08 19:39:00 +00:00
|
|
|
Arguments : Node
|
2009-10-01 18:28:00 +00:00
|
|
|
Returns : Nothing
|
2009-12-08 19:39:00 +00:00
|
|
|
Example : xCAT::zvmCPUtils->loadVmcp($node);
|
2009-10-01 18:28:00 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub loadVmcp {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
# Load Linux VMCP module
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "modprobe vmcp"`;
|
2009-10-01 18:28:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getVswitchId
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Get VSWITCH ID of given node
|
|
|
|
Arguments : Node
|
2009-11-09 21:12:41 +00:00
|
|
|
Returns : VSwitch IDs
|
2009-10-01 18:28:00 +00:00
|
|
|
Example : my @vswitch = xCAT::zvmCPUtils->getVswitchId($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getVswitchId {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
# Get VSwitch
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q nic" | grep "VSWITCH"`;
|
2009-10-01 18:28:00 +00:00
|
|
|
my @lines = split( '\n', $out );
|
|
|
|
my @parms;
|
|
|
|
my @vswitch;
|
|
|
|
foreach (@lines) {
|
|
|
|
@parms = split( ' ', $_ );
|
|
|
|
push( @vswitch, $parms[4] );
|
|
|
|
}
|
|
|
|
|
|
|
|
return @vswitch;
|
|
|
|
}
|
2009-10-21 18:03:40 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 grantVSwitch
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Grant access to virtual switch (VSWITCH) for given userID
|
|
|
|
Arguments : HCP node
|
2009-10-21 18:03:40 +00:00
|
|
|
User ID
|
2009-12-08 19:39:00 +00:00
|
|
|
VSWITCH ID
|
|
|
|
Returns : Operation results (Done/Failed)
|
2009-10-21 18:03:40 +00:00
|
|
|
Example : my $out = xCAT::zvmCPUtils->grantVswitch($callback, $hcp, $userId, $vswitchId);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub grantVSwitch {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $callback, $hcp, $userId, $vswitchId ) = @_;
|
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
# Grant VSwitch for specified userID
|
|
|
|
my $out = `ssh $hcp "vmcp set vswitch $vswitchId grant $userId"`;
|
|
|
|
$out = xCAT::zvmUtils->trimStr($out);
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
# If return string contains 'Command complete' -- Operation was successful
|
2009-10-21 18:03:40 +00:00
|
|
|
my $retStr;
|
2009-11-09 21:12:41 +00:00
|
|
|
if ( $out =~ m/Command complete/i ) {
|
2009-10-21 18:03:40 +00:00
|
|
|
$retStr = "Done\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$retStr = "Failed\n";
|
2009-12-08 19:39:00 +00:00
|
|
|
return $retStr;
|
2009-10-21 18:03:40 +00:00
|
|
|
}
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
return $retStr;
|
2009-10-21 18:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 flashCopy
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Flash copy (Class B users only)
|
2009-10-21 18:03:40 +00:00
|
|
|
Arguments : Node
|
|
|
|
Source address
|
|
|
|
Target address
|
2009-12-08 19:39:00 +00:00
|
|
|
Returns : Operation results (Done/Failed)
|
|
|
|
Example : my $results = xCAT::zvmCPUtils->flashCopy($node, $srcAddr, $targetAddr);
|
2009-10-21 18:03:40 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub flashCopy {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node, $srcAddr, $targetAddr ) = @_;
|
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
# Flash copy
|
|
|
|
my $out = `ssh $node "vmcp flashcopy $srcAddr 0 end to $targetAddr 0 end"`;
|
|
|
|
$out = xCAT::zvmUtils->trimStr($out);
|
2009-10-21 18:03:40 +00:00
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
# If return string contains 'Command complete' -- Operation was successful
|
|
|
|
my $retStr = "";
|
2009-10-21 18:03:40 +00:00
|
|
|
if ( $out =~ m/Command complete/i ) {
|
|
|
|
$retStr = "Done\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$retStr = "Failed\n";
|
|
|
|
}
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
return $retStr;
|
2009-10-21 18:03:40 +00:00
|
|
|
}
|
|
|
|
|
2009-11-09 21:12:41 +00:00
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 punch2Reader
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
Description : Write file to z/VM punch and transfer it to reader
|
2009-11-09 21:12:41 +00:00
|
|
|
Arguments : HCP node
|
|
|
|
UserID to receive file
|
2009-12-08 19:39:00 +00:00
|
|
|
Source file
|
|
|
|
Target file name and type to be created by punch (e.g. sles.parm)
|
2009-11-09 21:12:41 +00:00
|
|
|
Options (e.g. -t -- Convert EBCDIC to ASCII)
|
2009-12-08 19:39:00 +00:00
|
|
|
Returns : Operation results (Done/Failed)
|
|
|
|
Example : my $rc = xCAT::zvmCPUtils->punch2Reader($hcp, $userId, $srcFile, $trgtFile, $options);
|
2009-11-09 21:12:41 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub punch2Reader {
|
2009-12-08 19:39:00 +00:00
|
|
|
my ( $class, $hcp, $userId, $srcFile, $trgtFile, $options ) = @_;
|
2009-11-09 21:12:41 +00:00
|
|
|
|
|
|
|
# Punch to reader
|
2009-12-08 19:39:00 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $hcp "vmur punch $options -u $userId -r $srcFile -N $trgtFile"`;
|
|
|
|
|
|
|
|
# If punch is successful -- Look for this string
|
|
|
|
my $searchStr = "created and transferred";
|
|
|
|
if ( !( $out =~ m/$searchStr/i ) ) {
|
|
|
|
$out = "Failed\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$out = "Done\n";
|
|
|
|
}
|
2009-11-09 21:12:41 +00:00
|
|
|
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 purgeReader
|
|
|
|
|
|
|
|
Description : Purge reader (Class D users only)
|
|
|
|
Arguments : HCP node
|
|
|
|
UserID to purge reader for
|
|
|
|
Returns : Nothing
|
|
|
|
Example : my $rc = xCAT::zvmCPUtils->purgeReader($hcp, $userId);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub purgeReader {
|
|
|
|
my ( $class, $hcp, $userId ) = @_;
|
|
|
|
|
2009-12-08 19:39:00 +00:00
|
|
|
# Purge reader
|
2009-11-09 21:12:41 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $hcp "vmcp purge $userId rdr all"`;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 sendCPCmd
|
|
|
|
|
|
|
|
Description : Send CP command to given userID (Class C users only)
|
|
|
|
Arguments : HCP node
|
|
|
|
UserID to send CP command
|
|
|
|
Returns : Nothing
|
2009-12-08 19:39:00 +00:00
|
|
|
Example : xCAT::zvmCPUtils->sendCPCmd($hcp, $userId, $cmd);
|
2009-11-09 21:12:41 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub sendCPCmd {
|
|
|
|
my ( $class, $hcp, $userId, $cmd ) = @_;
|
|
|
|
|
|
|
|
# Send CP command to given userID
|
|
|
|
my $out = `ssh $hcp "vmcp send cp $userId $cmd"`;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2009-12-08 19:39:00 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getNetworkLayer
|
|
|
|
|
|
|
|
Description : Get the network layer for a given node
|
|
|
|
Arguments : Node
|
|
|
|
Network name (Optional)
|
|
|
|
Returns : 2 -- Layer 2
|
|
|
|
3 -- Layer 3
|
|
|
|
-1 -- Failed to get network layer
|
|
|
|
Example : my $layer = xCAT::zvmCPUtils->getNetworkLayer($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getNetworkLayer {
|
|
|
|
my ( $class, $node, $netName ) = @_;
|
|
|
|
|
|
|
|
# Get node properties from 'zvm' table
|
|
|
|
my @propNames = ('hcp');
|
|
|
|
my $propVals = xCAT::zvmUtils->getNodeProps( 'zvm', $node, @propNames );
|
|
|
|
|
|
|
|
# Get HCP
|
|
|
|
my $hcp = $propVals->{'hcp'};
|
|
|
|
if ( !$hcp ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get network name
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q v nic" | egrep -i "VSWITCH|LAN"`;
|
|
|
|
my @lines = split( '\n', $out );
|
|
|
|
|
|
|
|
# Go through each line and extract VSwitch and Lan names
|
|
|
|
# Get the first network name found
|
|
|
|
if ( !$netName ) {
|
|
|
|
my $i;
|
|
|
|
my @vars;
|
|
|
|
for ( $i = 0 ; $i < @lines ; $i++ ) {
|
|
|
|
|
|
|
|
# Extract VSwitch name
|
|
|
|
if ( $lines[$i] =~ m/VSWITCH/i ) {
|
|
|
|
@vars = split( ' ', $lines[$i] );
|
|
|
|
$netName = $vars[4];
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Extract Lan name
|
|
|
|
elsif ( $lines[$i] =~ m/LAN/i ) {
|
|
|
|
@vars = split( ' ', $lines[$i] );
|
|
|
|
$netName = $vars[4];
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
} # End of for
|
|
|
|
} # End of if ( !$netName )
|
|
|
|
|
|
|
|
# If the network name could not be found
|
|
|
|
if ( !$netName ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get network type (Layer 2 or 3)
|
|
|
|
$out = `ssh -o ConnectTimeout=5 $hcp "vmcp q lan $netName"`;
|
|
|
|
if ( !$out ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Go through each line
|
|
|
|
my $layer = 3; # Default to layer 3
|
|
|
|
@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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getNetworkType
|
|
|
|
|
|
|
|
Description : Get the network type for a given network name
|
|
|
|
Arguments : HCP node
|
|
|
|
Name of network
|
|
|
|
Returns : Network type (VSWITCH/HIPERS/QDIO)
|
|
|
|
Example : my $netType = xCAT::zvmCPUtils->getNetworkType($hcp, $netName);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getNetworkType {
|
|
|
|
my ( $class, $hcp, $netName ) = @_;
|
|
|
|
|
|
|
|
# Get network details
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $hcp "vmcp q lan $netName" | grep "Type"`;
|
|
|
|
|
|
|
|
# Go through each line and determine network type
|
|
|
|
my @lines = split( '\n', $out );
|
|
|
|
my $netType = "";
|
|
|
|
foreach (@lines) {
|
|
|
|
|
|
|
|
# Virtual switch
|
|
|
|
if ( $_ =~ m/VSWITCH/i ) {
|
|
|
|
$netType = "VSWITCH";
|
|
|
|
}
|
|
|
|
|
|
|
|
# HiperSocket guest LAN
|
|
|
|
elsif ( $_ =~ m/HIPERS/i ) {
|
|
|
|
$netType = "HIPERS";
|
|
|
|
}
|
|
|
|
|
|
|
|
# QDIO guest LAN
|
|
|
|
elsif ( $_ =~ m/QDIO/i ) {
|
|
|
|
$netType = "QDIO";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $netType;
|
|
|
|
}
|