Add subroutines to support new z/VM functionality.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4524 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
a3524a7cdb
commit
cb35ae47fb
@ -3,7 +3,7 @@
|
||||
|
||||
=head1
|
||||
|
||||
This is a CP utility plugin for the z/VM.
|
||||
This is a CP utility plugin for z/VM.
|
||||
|
||||
=cut
|
||||
|
||||
@ -32,7 +32,7 @@ sub getUserId {
|
||||
my ( $class, $node ) = @_;
|
||||
|
||||
# Get userId using VMCP
|
||||
my $out = `ssh -o ConnectTimeout=5 $node vmcp q userid`;
|
||||
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q userid"`;
|
||||
my @results = split( ' ', $out );
|
||||
return ( $results[0] );
|
||||
}
|
||||
@ -54,11 +54,15 @@ sub getSn {
|
||||
# Get inputs
|
||||
my ( $class, $node ) = @_;
|
||||
|
||||
# Get node properties from 'zvm' table
|
||||
my @propNames = ('hcp');
|
||||
my $propVals = xCAT::zvmUtils->getNodeProps( 'zvm', $node, @propNames );
|
||||
|
||||
# Get HCP
|
||||
my $hcp = xCAT::zvmUtils->getTabProp( 'zvm', $node, 'hcp' );
|
||||
my $hcp = $propVals->{'hcp'};
|
||||
|
||||
# Look in /proc/sysinfo to get serial number
|
||||
my $out = `ssh $hcp cat /proc/sysinfo | egrep -i "manufacturer|type|model|sequence code|plant"`;
|
||||
my $out = `ssh $hcp "cat /proc/sysinfo" | egrep -i "manufacturer|type|model|sequence code|plant"`;
|
||||
my @props = split( '\n', $out );
|
||||
my $man = $props[0];
|
||||
my $type = $props[1];
|
||||
@ -69,25 +73,25 @@ sub getSn {
|
||||
# Trim and get property value
|
||||
# Get manufacturer
|
||||
@props = split( ':', $man );
|
||||
$man = xCAT::zvmUtils->trim( $props[1] );
|
||||
$man = xCAT::zvmUtils->trimStr( $props[1] );
|
||||
|
||||
# Get machine type
|
||||
@props = split( ':', $type );
|
||||
$type = xCAT::zvmUtils->trim( $props[1] );
|
||||
$type = xCAT::zvmUtils->trimStr( $props[1] );
|
||||
|
||||
# Get model
|
||||
@props = split( ': ', $model );
|
||||
$model = xCAT::zvmUtils->trim( $props[1] );
|
||||
$model = xCAT::zvmUtils->trimStr( $props[1] );
|
||||
@props = split( ' ', $model );
|
||||
$model = xCAT::zvmUtils->trim( $props[0] );
|
||||
$model = xCAT::zvmUtils->trimStr( $props[0] );
|
||||
|
||||
# Get sequence number
|
||||
@props = split( ':', $sn );
|
||||
$sn = xCAT::zvmUtils->trim( $props[1] );
|
||||
$sn = xCAT::zvmUtils->trimStr( $props[1] );
|
||||
|
||||
# Get plant
|
||||
@props = split( ':', $plant );
|
||||
$plant = xCAT::zvmUtils->trim( $props[1] );
|
||||
$plant = xCAT::zvmUtils->trimStr( $props[1] );
|
||||
|
||||
return ("$man-$type-$model-$plant-$sn");
|
||||
}
|
||||
@ -110,7 +114,7 @@ sub getHost {
|
||||
my ( $class, $node ) = @_;
|
||||
|
||||
# Get host using VMCP
|
||||
my $out = `ssh -o ConnectTimeout=5 $node vmcp q userid`;
|
||||
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q userid"`;
|
||||
my @results = split( ' ', $out );
|
||||
my $host = $results[2];
|
||||
|
||||
@ -135,9 +139,9 @@ sub getOs {
|
||||
my ( $class, $node ) = @_;
|
||||
|
||||
# Get operating system
|
||||
my $out = `ssh -o ConnectTimeout=5 $node cat /etc/*release`;
|
||||
my $out = `ssh -o ConnectTimeout=10 $node "cat /etc/*release"`;
|
||||
my @results = split( '\n', $out );
|
||||
return ( xCAT::zvmUtils->trim( $results[0] ) );
|
||||
return ( xCAT::zvmUtils->trimStr( $results[0] ) );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
@ -158,18 +162,18 @@ sub getArch {
|
||||
my ( $class, $node ) = @_;
|
||||
|
||||
# Get host using VMCP
|
||||
my $arch = `ssh $node uname -p`;
|
||||
my $arch = `ssh $node "uname -p"`;
|
||||
|
||||
return ( xCAT::zvmUtils->trim($arch) );
|
||||
return ( xCAT::zvmUtils->trimStr($arch) );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 getPrivileges
|
||||
|
||||
Description : Get privilege classes of specified node
|
||||
Description : Get privilege class of specified node
|
||||
Arguments : Node name
|
||||
Returns : Privilege classes
|
||||
Returns : Privilege class
|
||||
Example : my $memory = xCAT::zvmCPUtils->getPrivileges($node);
|
||||
|
||||
=cut
|
||||
@ -180,11 +184,11 @@ sub getPrivileges {
|
||||
# Get inputs
|
||||
my ( $class, $node ) = @_;
|
||||
|
||||
# Get memory configuration
|
||||
my $out = `ssh -o ConnectTimeout=5 $node vmcp q priv`;
|
||||
# Get privilege class
|
||||
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q priv"`;
|
||||
my @out = split( '\n', $out );
|
||||
$out[1] = xCAT::zvmUtils->trim( $out[1] );
|
||||
$out[2] = xCAT::zvmUtils->trim( $out[2] );
|
||||
$out[1] = xCAT::zvmUtils->trimStr( $out[1] );
|
||||
$out[2] = xCAT::zvmUtils->trimStr( $out[2] );
|
||||
my $str = " $out[1]\n $out[2]\n";
|
||||
return ($str);
|
||||
}
|
||||
@ -193,9 +197,9 @@ sub getPrivileges {
|
||||
|
||||
=head3 getMemory
|
||||
|
||||
Description : Get memory configuration of specified node
|
||||
Description : Get memory of specified node
|
||||
Arguments : Node name
|
||||
Returns : Memory configuration
|
||||
Returns : Memory
|
||||
Example : my $memory = xCAT::zvmCPUtils->getMemory($node);
|
||||
|
||||
=cut
|
||||
@ -206,19 +210,19 @@ sub getMemory {
|
||||
# Get inputs
|
||||
my ( $class, $node ) = @_;
|
||||
|
||||
# Get memory configuration
|
||||
my $out = `ssh -o ConnectTimeout=5 $node vmcp q virtual storage`;
|
||||
# Get memory
|
||||
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q virtual storage"`;
|
||||
my @out = split( '=', $out );
|
||||
return ( xCAT::zvmUtils->trim( $out[1] ) );
|
||||
return ( xCAT::zvmUtils->trimStr( $out[1] ) );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 getCpu
|
||||
|
||||
Description : Get processor configuration of specified node
|
||||
Description : Get processor of specified node
|
||||
Arguments : Node name
|
||||
Returns : Processor configuration
|
||||
Returns : Processor
|
||||
Example : my $proc = xCAT::zvmCPUtils->getCpu($node);
|
||||
|
||||
=cut
|
||||
@ -229,8 +233,8 @@ sub getCpu {
|
||||
# Get inputs
|
||||
my ( $class, $node ) = @_;
|
||||
|
||||
# Get processors configuration
|
||||
my $out = `ssh -o ConnectTimeout=5 $node vmcp q virtual cpus`;
|
||||
# Get processors
|
||||
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q virtual cpus"`;
|
||||
my $str = xCAT::zvmUtils->tabStr($out);
|
||||
|
||||
return ($str);
|
||||
@ -240,9 +244,9 @@ sub getCpu {
|
||||
|
||||
=head3 getNic
|
||||
|
||||
Description : Get network interface card (NIC) configuration of specified node
|
||||
Description : Get network interface card (NIC) of specified node
|
||||
Arguments : Node name
|
||||
Returns : NIC configuration
|
||||
Returns : NIC
|
||||
Example : my $nic = xCAT::zvmCPUtils->getNic($node);
|
||||
|
||||
=cut
|
||||
@ -253,8 +257,8 @@ sub getNic {
|
||||
# Get inputs
|
||||
my ( $class, $node ) = @_;
|
||||
|
||||
# Get NIC configuration
|
||||
my $out = `ssh -o ConnectTimeout=5 $node vmcp q virtual nic`;
|
||||
# Get NIC
|
||||
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q virtual nic"`;
|
||||
my $str = xCAT::zvmUtils->tabStr($out);
|
||||
return ($str);
|
||||
}
|
||||
@ -263,9 +267,9 @@ sub getNic {
|
||||
|
||||
=head3 getDisks
|
||||
|
||||
Description : Get disk configuration of specified node
|
||||
Description : Get disk of specified node
|
||||
Arguments : Node name
|
||||
Returns : Disk configuration
|
||||
Returns : Disk
|
||||
Example : my $storage = xCAT::zvmCPUtils->getDisks($node);
|
||||
|
||||
=cut
|
||||
@ -276,8 +280,8 @@ sub getDisks {
|
||||
# Get inputs
|
||||
my ( $class, $node ) = @_;
|
||||
|
||||
# Get disks configuration
|
||||
my $out = `ssh -o ConnectTimeout=5 $node vmcp q virtual dasd`;
|
||||
# Get disks
|
||||
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q virtual dasd"`;
|
||||
my $str = xCAT::zvmUtils->tabStr($out);
|
||||
return ($str);
|
||||
}
|
||||
@ -286,7 +290,7 @@ sub getDisks {
|
||||
|
||||
=head3 loadVmcp
|
||||
|
||||
Description : Load VMCP module for specified node
|
||||
Description : Load VMCP module on specified node
|
||||
Arguments : Node name
|
||||
Returns : Nothing
|
||||
Example : my $out = xCAT::zvmCPUtils->loadVmcp($node);
|
||||
@ -299,8 +303,8 @@ sub loadVmcp {
|
||||
# Get inputs
|
||||
my ( $class, $node ) = @_;
|
||||
|
||||
# Get VSWITCH of master node
|
||||
my $out = `ssh -o ConnectTimeout=5 $node modprobe vmcp`;
|
||||
# Load Linux VMCP module
|
||||
my $out = `ssh -o ConnectTimeout=5 $node "modprobe vmcp"`;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -308,9 +312,9 @@ sub loadVmcp {
|
||||
|
||||
=head3 getVswitchId
|
||||
|
||||
Description : Get VSWITCH ID for specified node
|
||||
Description : Get VSwitch ID of specified node
|
||||
Arguments : Node name
|
||||
Returns : VSWITCH IDs
|
||||
Returns : VSwitch IDs
|
||||
Example : my @vswitch = xCAT::zvmCPUtils->getVswitchId($node);
|
||||
|
||||
=cut
|
||||
@ -321,8 +325,8 @@ sub getVswitchId {
|
||||
# Get inputs
|
||||
my ( $class, $node ) = @_;
|
||||
|
||||
# Get VSWITCH of master node
|
||||
my $out = `ssh -o ConnectTimeout=5 $node vmcp q nic | grep "VSWITCH"`;
|
||||
# Get VSwitch
|
||||
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q nic" | grep "VSWITCH"`;
|
||||
my @lines = split( '\n', $out );
|
||||
my @parms;
|
||||
my @vswitch;
|
||||
@ -338,7 +342,7 @@ sub getVswitchId {
|
||||
|
||||
=head3 grantVSwitch
|
||||
|
||||
Description : Grant access to VSwitch for specified user ID
|
||||
Description : Grant access to VSwitch for specified userID
|
||||
Arguments : zHCP node
|
||||
User ID
|
||||
Vswitch ID
|
||||
@ -353,10 +357,13 @@ sub grantVSwitch {
|
||||
# Get inputs
|
||||
my ( $class, $callback, $hcp, $userId, $vswitchId ) = @_;
|
||||
|
||||
my $out = `ssh $hcp vmcp set vswitch $vswitchId grant $userId`;
|
||||
$out = xCAT::zvmUtils->trim($out);
|
||||
# Grant VSwitch for specified userID
|
||||
my $out = `ssh $hcp "vmcp set vswitch $vswitchId grant $userId"`;
|
||||
$out = xCAT::zvmUtils->trimStr($out);
|
||||
|
||||
# If return string contains 'Command complete'
|
||||
my $retStr;
|
||||
if ( $out eq "Command complete" ) {
|
||||
if ( $out =~ m/Command complete/i ) {
|
||||
$retStr = "Done\n";
|
||||
}
|
||||
else {
|
||||
@ -371,7 +378,7 @@ sub grantVSwitch {
|
||||
|
||||
=head3 flashCopy
|
||||
|
||||
Description : Flash copy disks
|
||||
Description : Flash copy
|
||||
Arguments : Node
|
||||
Source address
|
||||
Target address
|
||||
@ -386,11 +393,12 @@ sub flashCopy {
|
||||
# Get inputs
|
||||
my ( $class, $node, $srcAddr, $targetAddr ) = @_;
|
||||
|
||||
my $out = `ssh $node vmcp flashcopy $srcAddr 0 end to $targetAddr 0 end`;
|
||||
$out = xCAT::zvmUtils->trim($out);
|
||||
my $retStr;
|
||||
# Flash copy
|
||||
my $out = `ssh $node "vmcp flashcopy $srcAddr 0 end to $targetAddr 0 end"`;
|
||||
$out = xCAT::zvmUtils->trimStr($out);
|
||||
|
||||
# If return string contains 'Command complete'
|
||||
my $retStr;
|
||||
if ( $out =~ m/Command complete/i ) {
|
||||
|
||||
# Done
|
||||
@ -404,3 +412,71 @@ sub flashCopy {
|
||||
return ($retStr);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 punch2Reader
|
||||
|
||||
Description : Write file to z/VM punch and transfer it to reader
|
||||
Arguments : HCP node
|
||||
UserID to receive file
|
||||
File to transfer
|
||||
File name and type to be created by punch (e.g. sles.parm)
|
||||
Options (e.g. -t -- Convert EBCDIC to ASCII)
|
||||
Returns : Nothing
|
||||
Example : my $rc = xCAT::zvmCPUtils->punch2Reader($hcp, $userId, $file, $fileName, $options);
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub punch2Reader {
|
||||
my ( $class, $hcp, $userId, $file, $fileName, $options ) = @_;
|
||||
|
||||
# Punch to reader
|
||||
my $out = `ssh -o ConnectTimeout=5 $hcp "vmur punch $options -u $userId -r $file -N $fileName"`;
|
||||
|
||||
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 ) = @_;
|
||||
|
||||
# Punch to reader
|
||||
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
|
||||
Example : my $rc = xCAT::zvmCPUtils->sendCPCmd($hcp, $userId, $cmd);
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub sendCPCmd {
|
||||
my ( $class, $hcp, $userId, $cmd ) = @_;
|
||||
|
||||
# Send CP command to given userID
|
||||
my $out = `ssh $hcp "vmcp send cp $userId $cmd"`;
|
||||
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user