2010-04-22 18:53:46 +00:00
|
|
|
# IBM(c) 2010 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head1
|
2010-05-06 20:42:14 +00:00
|
|
|
|
2010-04-22 18:53:46 +00:00
|
|
|
This is a CP utility plugin for z/VM.
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
package xCAT::zvmCPUtils;
|
|
|
|
use xCAT::zvmUtils;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
1;
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2010-04-22 20:19:35 +00:00
|
|
|
=head3 getUserId
|
|
|
|
|
|
|
|
Description : Get the userID of a given node
|
|
|
|
Arguments : Node
|
|
|
|
Returns : UserID
|
|
|
|
Example : my $userID = xCAT::zvmCPUtils->getUserId($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getUserId {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Get userId using VMCP
|
2010-06-15 21:09:35 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q userid"`;
|
2010-04-22 20:19:35 +00:00
|
|
|
my @results = split( ' ', $out );
|
|
|
|
|
|
|
|
return ( $results[0] );
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getHost
|
|
|
|
|
2010-07-07 15:12:44 +00:00
|
|
|
Description : Get the z/VM host of a given node
|
2010-04-22 20:19:35 +00:00
|
|
|
Arguments : Node
|
|
|
|
Returns : z/VM host
|
|
|
|
Example : my $host = xCAT::zvmCPUtils->getHost($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getHost {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Get host using VMCP
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q userid"`;
|
|
|
|
my @results = split( ' ', $out );
|
|
|
|
my $host = $results[2];
|
|
|
|
|
|
|
|
return ($host);
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getPrivileges
|
|
|
|
|
|
|
|
Description : Get the privilege class of a given node
|
|
|
|
Arguments : Node
|
|
|
|
Returns : Privilege class
|
2010-07-07 15:12:44 +00:00
|
|
|
Example : my $class = xCAT::zvmCPUtils->getPrivileges($node);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getPrivileges {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Get privilege class
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q priv"`;
|
|
|
|
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";
|
|
|
|
|
|
|
|
return ($str);
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getMemory
|
|
|
|
|
|
|
|
Description : Get the memory of a given node
|
|
|
|
Arguments : Node
|
|
|
|
Returns : Memory
|
|
|
|
Example : my $memory = xCAT::zvmCPUtils->getMemory($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getMemory {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Get memory
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q virtual storage"`;
|
|
|
|
my @out = split( '=', $out );
|
|
|
|
|
|
|
|
return ( xCAT::zvmUtils->trimStr( $out[1] ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getCpu
|
|
|
|
|
|
|
|
Description : Get the processor(s) of a given node
|
|
|
|
Arguments : Node
|
|
|
|
Returns : Processor(s)
|
|
|
|
Example : my $proc = xCAT::zvmCPUtils->getCpu($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getCpu {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Get processors
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q virtual cpus"`;
|
|
|
|
my $str = xCAT::zvmUtils->tabStr($out);
|
|
|
|
|
|
|
|
return ($str);
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getNic
|
|
|
|
|
|
|
|
Description : Get the network interface card (NIC) of a given node
|
|
|
|
Arguments : Node
|
|
|
|
Returns : NIC(s)
|
|
|
|
Example : my $nic = xCAT::zvmCPUtils->getNic($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getNic {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Get NIC
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q virtual nic"`;
|
|
|
|
my $str = xCAT::zvmUtils->tabStr($out);
|
|
|
|
|
|
|
|
return ($str);
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getNetworkNames
|
|
|
|
|
2010-07-07 15:12:44 +00:00
|
|
|
Description : Get a list of network names available to a given node
|
2010-04-22 20:19:35 +00:00
|
|
|
Arguments : Node
|
|
|
|
Returns : Network names
|
|
|
|
Example : my $lans = xCAT::zvmCPUtils->getNetworkNames($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getNetworkNames {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Get network names
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q lan | egrep 'LAN|VSWITCH'"`;
|
|
|
|
my @lines = split( '\n', $out );
|
|
|
|
my @parms;
|
|
|
|
my $names;
|
|
|
|
foreach (@lines) {
|
2010-09-10 16:17:23 +00:00
|
|
|
|
2010-04-22 20:19:35 +00:00
|
|
|
# Trim output
|
2010-06-15 21:09:35 +00:00
|
|
|
$_ = xCAT::zvmUtils->trimStr($_);
|
2010-04-22 20:19:35 +00:00
|
|
|
@parms = split( ' ', $_ );
|
2010-09-10 16:17:23 +00:00
|
|
|
|
2010-04-22 20:19:35 +00:00
|
|
|
# Get the network name
|
2010-09-10 16:17:23 +00:00
|
|
|
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";
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ($names);
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getNetwork
|
|
|
|
|
2010-07-07 15:12:44 +00:00
|
|
|
Description : Get the network info for a given node
|
2010-04-22 20:19:35 +00:00
|
|
|
Arguments : Node
|
|
|
|
Network name
|
|
|
|
Returns : Network configuration
|
|
|
|
Example : my $config = xCAT::zvmCPUtils->getNetwork($node, $netName);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getNetwork {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node, $netName ) = @_;
|
|
|
|
|
2010-07-07 15:12:44 +00:00
|
|
|
# Get network info
|
2010-04-22 20:19:35 +00:00
|
|
|
my $out;
|
|
|
|
if ( $netName eq "all" ) {
|
|
|
|
$out = `ssh -o ConnectTimeout=5 $node "vmcp q lan"`;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$out = `ssh -o ConnectTimeout=5 $node "vmcp q lan $netName"`;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ($out);
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getDisks
|
|
|
|
|
|
|
|
Description : Get the disk(s) of given node
|
|
|
|
Arguments : Node
|
|
|
|
Returns : Disk(s)
|
|
|
|
Example : my $storage = xCAT::zvmCPUtils->getDisks($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getDisks {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Get disks
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q virtual dasd"`;
|
|
|
|
my $str = xCAT::zvmUtils->tabStr($out);
|
|
|
|
|
|
|
|
return ($str);
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 loadVmcp
|
|
|
|
|
|
|
|
Description : Load Linux VMCP module on a given node
|
|
|
|
Arguments : Node
|
|
|
|
Returns : Nothing
|
|
|
|
Example : xCAT::zvmCPUtils->loadVmcp($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub loadVmcp {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Load Linux VMCP module
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "modprobe vmcp"`;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getVswitchId
|
|
|
|
|
2010-07-07 15:12:44 +00:00
|
|
|
Description : Get the VSwitch ID(s) of given node
|
2010-04-22 20:19:35 +00:00
|
|
|
Arguments : Node
|
2010-07-07 15:12:44 +00:00
|
|
|
Returns : VSwitch ID(s)
|
2010-04-22 20:19:35 +00:00
|
|
|
Example : my @vswitch = xCAT::zvmCPUtils->getVswitchId($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getVswitchId {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node ) = @_;
|
|
|
|
|
|
|
|
# Get VSwitch
|
2011-10-14 00:46:37 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q v nic" | grep "VSWITCH"`;
|
2010-04-22 20:19:35 +00:00
|
|
|
my @lines = split( '\n', $out );
|
|
|
|
my @parms;
|
|
|
|
my @vswitch;
|
|
|
|
foreach (@lines) {
|
|
|
|
@parms = split( ' ', $_ );
|
|
|
|
push( @vswitch, $parms[4] );
|
|
|
|
}
|
|
|
|
|
|
|
|
return @vswitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 grantVSwitch
|
|
|
|
|
2010-07-07 15:12:44 +00:00
|
|
|
Description : Grant VSwitch access for a given userID
|
2010-04-22 20:19:35 +00:00
|
|
|
Arguments : HCP node
|
|
|
|
User ID
|
|
|
|
VSWITCH ID
|
|
|
|
Returns : Operation results (Done/Failed)
|
|
|
|
Example : my $out = xCAT::zvmCPUtils->grantVswitch($callback, $hcp, $userId, $vswitchId);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub grantVSwitch {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $callback, $hcp, $userId, $vswitchId ) = @_;
|
|
|
|
|
|
|
|
# Grant VSwitch for specified userID
|
|
|
|
my $out = `ssh $hcp "vmcp set vswitch $vswitchId grant $userId"`;
|
|
|
|
$out = xCAT::zvmUtils->trimStr($out);
|
|
|
|
|
2010-07-07 15:12:44 +00:00
|
|
|
# If return string contains 'Command complete' - Operation was successful
|
2010-04-22 20:19:35 +00:00
|
|
|
my $retStr;
|
|
|
|
if ( $out =~ m/Command complete/i ) {
|
|
|
|
$retStr = "Done\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$retStr = "Failed\n";
|
|
|
|
return $retStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $retStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 flashCopy
|
|
|
|
|
|
|
|
Description : Flash copy (Class B users only)
|
|
|
|
Arguments : Node
|
|
|
|
Source address
|
|
|
|
Target address
|
|
|
|
Returns : Operation results (Done/Failed)
|
|
|
|
Example : my $results = xCAT::zvmCPUtils->flashCopy($node, $srcAddr, $targetAddr);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub flashCopy {
|
|
|
|
|
|
|
|
# Get inputs
|
2010-07-07 15:12:44 +00:00
|
|
|
my ( $class, $node, $srcAddr, $tgtAddr ) = @_;
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
# Flash copy
|
2010-07-07 15:12:44 +00:00
|
|
|
my $out = `ssh $node "vmcp flashcopy $srcAddr 0 end to $tgtAddr 0 end synchronous"`;
|
2010-04-22 20:19:35 +00:00
|
|
|
$out = xCAT::zvmUtils->trimStr($out);
|
|
|
|
|
2010-07-07 15:12:44 +00:00
|
|
|
# If return string contains 'Command complete' - Operation was successful
|
2010-04-22 20:19:35 +00:00
|
|
|
my $retStr = "";
|
|
|
|
if ( $out =~ m/Command complete/i ) {
|
|
|
|
$retStr = "Done\n";
|
|
|
|
}
|
|
|
|
else {
|
2010-07-07 15:12:44 +00:00
|
|
|
$out = xCAT::zvmUtils->tabStr($out);
|
|
|
|
$retStr = "Failed\n$out";
|
2010-04-22 20:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $retStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 punch2Reader
|
|
|
|
|
|
|
|
Description : Write file to z/VM punch and transfer it to reader
|
|
|
|
Arguments : HCP node
|
|
|
|
UserID to receive file
|
|
|
|
Source file
|
2010-07-07 15:12:44 +00:00
|
|
|
Target file to be created by punch (e.g. sles.parm)
|
|
|
|
Options, e.g. -t (Convert EBCDIC to ASCII)
|
2010-04-22 20:19:35 +00:00
|
|
|
Returns : Operation results (Done/Failed)
|
2010-07-07 15:12:44 +00:00
|
|
|
Example : my $rc = xCAT::zvmCPUtils->punch2Reader($hcp, $userId, $srcFile, $tgtFile, $options);
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub punch2Reader {
|
2010-07-07 15:12:44 +00:00
|
|
|
my ( $class, $hcp, $userId, $srcFile, $tgtFile, $options ) = @_;
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
# Punch to reader
|
2010-07-07 15:12:44 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $hcp "vmur punch $options -u $userId -r $srcFile -N $tgtFile"`;
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
# 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";
|
|
|
|
}
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 purgeReader
|
|
|
|
|
|
|
|
Description : Purge reader (Class D users only)
|
|
|
|
Arguments : HCP node
|
2010-07-07 15:12:44 +00:00
|
|
|
UserID to purge reader
|
2010-04-22 20:19:35 +00:00
|
|
|
Returns : Nothing
|
|
|
|
Example : my $rc = xCAT::zvmCPUtils->purgeReader($hcp, $userId);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub purgeReader {
|
|
|
|
my ( $class, $hcp, $userId ) = @_;
|
|
|
|
|
|
|
|
# Purge reader
|
|
|
|
my $out = `ssh -o ConnectTimeout=5 $hcp "vmcp purge $userId rdr all"`;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 sendCPCmd
|
|
|
|
|
|
|
|
Description : Send CP command to a given userID (Class C users only)
|
|
|
|
Arguments : HCP node
|
|
|
|
UserID to send CP command
|
|
|
|
Returns : Nothing
|
|
|
|
Example : 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 getNetworkLayer
|
|
|
|
|
|
|
|
Description : Get the network layer for a given node
|
|
|
|
Arguments : Node
|
|
|
|
Network name (Optional)
|
2010-07-07 15:12:44 +00:00
|
|
|
Returns : 2 - Layer 2
|
|
|
|
3 - Layer 3
|
|
|
|
-1 - Failed to get network layer
|
2010-04-22 20:19:35 +00:00
|
|
|
Example : my $layer = xCAT::zvmCPUtils->getNetworkLayer($node);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub getNetworkLayer {
|
|
|
|
my ( $class, $node, $netName ) = @_;
|
|
|
|
|
|
|
|
# Get node properties from 'zvm' table
|
|
|
|
my @propNames = ('hcp');
|
2010-06-15 21:09:35 +00:00
|
|
|
my $propVals = xCAT::zvmUtils->getNodeProps( 'zvm', $node, @propNames );
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
# Get HCP
|
|
|
|
my $hcp = $propVals->{'hcp'};
|
|
|
|
if ( !$hcp ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get network name
|
2010-06-15 21:09:35 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp q v nic" | egrep -i "VSWITCH|LAN"`;
|
2010-04-22 20:19:35 +00:00
|
|
|
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
|
|
|
|
|
2010-07-07 15:12:44 +00:00
|
|
|
Description : Get the network type of a given network
|
2010-04-22 20:19:35 +00:00
|
|
|
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
|
2010-06-15 21:09:35 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $hcp "vmcp q lan $netName" | grep "Type"`;
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
# 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 defineCpu
|
|
|
|
|
|
|
|
Description : Add processor(s) to given node
|
|
|
|
Arguments : Node
|
|
|
|
Returns : Nothing
|
|
|
|
Example : my $out = xCAT::zvmCPUtils->defineCpu($node, $addr, $type);
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub defineCpu {
|
|
|
|
|
|
|
|
# Get inputs
|
|
|
|
my ( $class, $node, $addr, $type ) = @_;
|
|
|
|
|
|
|
|
# Define processor(s)
|
2010-06-15 21:09:35 +00:00
|
|
|
my $out = `ssh -o ConnectTimeout=5 $node "vmcp define cpu $addr type $type"`;
|
2010-04-22 20:19:35 +00:00
|
|
|
|
|
|
|
return ($out);
|
|
|
|
}
|