2012-02-03 05:23:03 +00:00
# IBM(c) 2012 EPL license http://www.eclipse.org/legal/epl-v10.html
2010-04-12 14:44:14 +00:00
#-------------------------------------------------------
= head1
2010-07-07 15:12:44 +00:00
xCAT plugin to support z / VM ( s390x )
2010-04-12 14:44:14 +00:00
= cut
#-------------------------------------------------------
package xCAT_plugin::zvm ;
use xCAT::Client ;
use xCAT::zvmUtils ;
use xCAT::zvmCPUtils ;
use xCAT::MsgUtils ;
use Sys::Hostname ;
use xCAT::Table ;
use xCAT::Utils ;
2011-12-09 19:29:33 +00:00
use xCAT::NetworkUtils ;
2010-04-12 14:44:14 +00:00
use Getopt::Long ;
use strict ;
# If the following line is not included, you get:
# /opt/xcat/lib/perl/xCAT_plugin/zvm.pm did not return a true value
1 ;
#-------------------------------------------------------
= head3 handled_commands
Return list of commands handled by this plugin
= cut
#-------------------------------------------------------
sub handled_commands {
return {
2010-06-15 21:09:35 +00:00
rpower = > 'nodehm:power,mgt' ,
rinv = > 'nodehm:mgt' ,
mkvm = > 'nodehm:mgt' ,
rmvm = > 'nodehm:mgt' ,
lsvm = > 'nodehm:mgt' ,
chvm = > 'nodehm:mgt' ,
rscan = > 'nodehm:mgt' ,
nodeset = > 'noderes:netboot' ,
getmacs = > 'nodehm:getmac,mgt' ,
rnetboot = > 'nodehm:mgt' ,
2010-04-12 14:44:14 +00:00
} ;
}
#-------------------------------------------------------
= head3 preprocess_request
2010-06-15 21:09:35 +00:00
Check and setup for hierarchy
2010-04-12 14:44:14 +00:00
= cut
#-------------------------------------------------------
sub preprocess_request {
my $ req = shift ;
my $ callback = shift ;
# Hash array
my % sn ;
# Scalar variable
my $ sn ;
# Array
my @ requests ;
# If already preprocessed, go straight to request
2010-07-07 15:12:44 +00:00
if ( $ req - > { _xcatpreprocessed } - > [ 0 ] == 1 ) {
return [ $ req ] ;
}
2010-04-12 14:44:14 +00:00
my $ nodes = $ req - > { node } ;
my $ service = "xcat" ;
# Find service nodes for requested nodes
# Build an individual request for each service node
if ( $ nodes ) {
$ sn = xCAT::Utils - > get_ServiceNode ( $ nodes , $ service , "MN" ) ;
# Build each request for each service node
foreach my $ snkey ( keys %$ sn ) {
my $ n = $ sn - > { $ snkey } ;
print "snkey=$snkey, nodes=@$n\n" ;
my $ reqcopy = { %$ req } ;
$ reqcopy - > { node } = $ sn - > { $ snkey } ;
$ reqcopy - > { '_xcatdest' } = $ snkey ;
$ reqcopy - > { _xcatpreprocessed } - > [ 0 ] = 1 ;
push @ requests , $ reqcopy ;
}
return \ @ requests ;
}
else {
# Input error
my % rsp ;
my $ rsp ;
2010-06-15 21:09:35 +00:00
$ rsp - > { data } - > [ 0 ] = "Input noderange missing. Useage: zvm <noderange> \n" ;
2010-04-12 14:44:14 +00:00
xCAT::MsgUtils - > message ( "I" , $ rsp , $ callback , 0 ) ;
return 1 ;
}
}
#-------------------------------------------------------
= head3 process_request
Process the command . This is the main call .
= cut
#-------------------------------------------------------
sub process_request {
my $ request = shift ;
my $ callback = shift ;
my $ nodes = $ request - > { node } ;
my $ command = $ request - > { command } - > [ 0 ] ;
my $ args = $ request - > { arg } ;
my $ envs = $ request - > { env } ;
my % rsp ;
my $ rsp ;
my @ nodes = @$ nodes ;
my $ host = hostname ( ) ;
2010-07-07 15:12:44 +00:00
# Directory where executables are on zHCP
2010-04-12 14:44:14 +00:00
$ ::DIR = "/opt/zhcp/bin" ;
# Process ID for xfork()
my $ pid ;
# Child process IDs
my @ children ;
2010-07-07 15:12:44 +00:00
#*** Power on or off a node ***
2010-04-12 14:44:14 +00:00
if ( $ command eq "rpower" ) {
foreach ( @ nodes ) {
$ pid = xCAT::Utils - > xfork ( ) ;
# Parent process
if ( $ pid ) {
push ( @ children , $ pid ) ;
}
# Child process
elsif ( $ pid == 0 ) {
powerVM ( $ callback , $ _ , $ args ) ;
# Exit process
exit ( 0 ) ;
}
else {
# Ran out of resources
die "Error: Could not fork\n" ;
}
2010-07-07 15:12:44 +00:00
# Handle 10 nodes at a time, else you will get errors
if ( ! ( @ children % 10 ) ) {
# Wait for all processes to end
foreach ( @ children ) {
waitpid ( $ _ , 0 ) ;
}
# Clear children
@ children = ( ) ;
}
2010-04-12 14:44:14 +00:00
} # End of foreach
} # End of case
2010-07-07 15:12:44 +00:00
#*** Hardware and software inventory ***
2010-04-12 14:44:14 +00:00
elsif ( $ command eq "rinv" ) {
foreach ( @ nodes ) {
$ pid = xCAT::Utils - > xfork ( ) ;
# Parent process
if ( $ pid ) {
push ( @ children , $ pid ) ;
}
# Child process
elsif ( $ pid == 0 ) {
inventoryVM ( $ callback , $ _ , $ args ) ;
# Exit process
exit ( 0 ) ;
}
else {
# Ran out of resources
die "Error: Could not fork\n" ;
}
} # End of foreach
} # End of case
2010-07-07 15:12:44 +00:00
#*** Create a virtual server ***
2010-04-12 14:44:14 +00:00
elsif ( $ command eq "mkvm" ) {
# Determine if the argument is a node
my $ clone = 'FALSE' ;
if ( $ args - > [ 0 ] ) {
$ clone = xCAT::zvmUtils - > isZvmNode ( $ args - > [ 0 ] ) ;
}
2010-07-07 15:12:44 +00:00
#*** Clone virtual server ***
2010-04-12 14:44:14 +00:00
if ( $ clone eq 'TRUE' ) {
cloneVM ( $ callback , \ @ nodes , $ args ) ;
}
2010-07-07 15:12:44 +00:00
#*** Create user entry ***
2010-04-12 14:44:14 +00:00
# Create node based on directory entry
# or create a NOLOG if no entry is provided
else {
foreach ( @ nodes ) {
$ pid = xCAT::Utils - > xfork ( ) ;
# Parent process
if ( $ pid ) {
push ( @ children , $ pid ) ;
}
# Child process
elsif ( $ pid == 0 ) {
makeVM ( $ callback , $ _ , $ args ) ;
# Exit process
exit ( 0 ) ;
} # End of elsif
else {
# Ran out of resources
die "Error: Could not fork\n" ;
}
} # End of foreach
} # End of else
} # End of case
2010-07-07 15:12:44 +00:00
#*** Remove a virtual server ***
2010-04-12 14:44:14 +00:00
elsif ( $ command eq "rmvm" ) {
foreach ( @ nodes ) {
2010-06-16 00:09:21 +00:00
$ pid = xCAT::Utils - > xfork ( ) ;
# Parent process
if ( $ pid ) {
push ( @ children , $ pid ) ;
}
# Child process
elsif ( $ pid == 0 ) {
removeVM ( $ callback , $ _ ) ;
# Exit process
exit ( 0 ) ;
}
else {
# Ran out of resources
die "Error: Could not fork\n" ;
}
2010-04-12 14:44:14 +00:00
2010-07-07 15:12:44 +00:00
# Handle 10 nodes at a time, else you will get errors
if ( ! ( @ children % 10 ) ) {
# Wait for all processes to end
foreach ( @ children ) {
waitpid ( $ _ , 0 ) ;
}
# Clear children
@ children = ( ) ;
}
2010-04-12 14:44:14 +00:00
} # End of foreach
} # End of case
2010-07-07 15:12:44 +00:00
#*** Print the user entry ***
2010-04-12 14:44:14 +00:00
elsif ( $ command eq "lsvm" ) {
foreach ( @ nodes ) {
$ pid = xCAT::Utils - > xfork ( ) ;
# Parent process
if ( $ pid ) {
push ( @ children , $ pid ) ;
}
# Child process
elsif ( $ pid == 0 ) {
listVM ( $ callback , $ _ , $ args ) ;
# Exit process
exit ( 0 ) ;
}
else {
# Ran out of resources
die "Error: Could not fork\n" ;
}
2010-07-07 15:12:44 +00:00
# Handle 10 nodes at a time, else you will get errors
if ( ! ( @ children % 10 ) ) {
# Wait for all processes to end
foreach ( @ children ) {
waitpid ( $ _ , 0 ) ;
}
# Clear children
@ children = ( ) ;
}
2010-04-12 14:44:14 +00:00
} # End of foreach
} # End of case
2010-07-07 15:12:44 +00:00
#*** Change the user entry ***
2010-04-12 14:44:14 +00:00
elsif ( $ command eq "chvm" ) {
foreach ( @ nodes ) {
$ pid = xCAT::Utils - > xfork ( ) ;
# Parent process
if ( $ pid ) {
push ( @ children , $ pid ) ;
}
# Child process
elsif ( $ pid == 0 ) {
changeVM ( $ callback , $ _ , $ args ) ;
# Exit process
exit ( 0 ) ;
}
else {
# Ran out of resources
die "Error: Could not fork\n" ;
}
2010-07-07 15:12:44 +00:00
# Handle 10 nodes at a time, else you will get errors
if ( ! ( @ children % 10 ) ) {
# Wait for all processes to end
foreach ( @ children ) {
waitpid ( $ _ , 0 ) ;
}
# Clear children
@ children = ( ) ;
}
2010-04-12 14:44:14 +00:00
} # End of foreach
} # End of case
2010-07-07 15:12:44 +00:00
#*** Collect node information from zHCP ***
2010-04-12 14:44:14 +00:00
elsif ( $ command eq "rscan" ) {
foreach ( @ nodes ) {
$ pid = xCAT::Utils - > xfork ( ) ;
# Parent process
if ( $ pid ) {
push ( @ children , $ pid ) ;
}
# Child process
elsif ( $ pid == 0 ) {
2011-05-17 19:57:04 +00:00
scanVM ( $ callback , $ _ , $ args ) ;
2010-04-12 14:44:14 +00:00
# Exit process
exit ( 0 ) ;
}
else {
# Ran out of resources
die "Error: Could not fork\n" ;
}
} # End of foreach
} # End of case
2010-07-07 15:12:44 +00:00
#*** Set the boot state for a node ***
2010-04-12 14:44:14 +00:00
elsif ( $ command eq "nodeset" ) {
foreach ( @ nodes ) {
2010-06-15 21:09:35 +00:00
# Only one file can be punched to reader at a time
# Forking this process is not possible
nodeSet ( $ callback , $ _ , $ args ) ;
2010-04-12 14:44:14 +00:00
} # End of foreach
} # End of case
2010-07-07 15:12:44 +00:00
#*** Get the MAC address of a node ***
2010-04-12 14:44:14 +00:00
elsif ( $ command eq "getmacs" ) {
foreach ( @ nodes ) {
$ pid = xCAT::Utils - > xfork ( ) ;
# Parent process
if ( $ pid ) {
push ( @ children , $ pid ) ;
}
# Child process
elsif ( $ pid == 0 ) {
getMacs ( $ callback , $ _ , $ args ) ;
# Exit process
exit ( 0 ) ;
}
else {
# Ran out of resources
die "Error: Could not fork\n" ;
}
} # End of foreach
} # End of case
2010-07-07 15:12:44 +00:00
#*** Boot from network ***
2010-04-12 14:44:14 +00:00
elsif ( $ command eq "rnetboot" ) {
foreach ( @ nodes ) {
$ pid = xCAT::Utils - > xfork ( ) ;
# Parent process
if ( $ pid ) {
push ( @ children , $ pid ) ;
}
# Child process
elsif ( $ pid == 0 ) {
netBoot ( $ callback , $ _ , $ args ) ;
# Exit process
exit ( 0 ) ;
}
else {
# Ran out of resources
die "Error: Could not fork\n" ;
}
2010-07-07 15:12:44 +00:00
# Handle 10 nodes at a time, else you will get errors
if ( ! ( @ children % 10 ) ) {
# Wait for all processes to end
foreach ( @ children ) {
waitpid ( $ _ , 0 ) ;
}
# Clear children
@ children = ( ) ;
}
2010-04-12 14:44:14 +00:00
} # End of foreach
} # End of case
2010-07-07 15:12:44 +00:00
#*** Update the node (no longer supported) ***
2010-04-12 14:44:14 +00:00
elsif ( $ command eq "updatenode" ) {
foreach ( @ nodes ) {
$ pid = xCAT::Utils - > xfork ( ) ;
# Parent process
if ( $ pid ) {
push ( @ children , $ pid ) ;
}
# Child process
elsif ( $ pid == 0 ) {
updateNode ( $ callback , $ _ , $ args ) ;
# Exit process
exit ( 0 ) ;
}
else {
# Ran out of resources
die "Error: Could not fork\n" ;
}
} # End of foreach
} # End of case
# Wait for all processes to end
foreach ( @ children ) {
waitpid ( $ _ , 0 ) ;
}
return ;
}
#-------------------------------------------------------
= head3 removeVM
Description : Delete the user entry from user directory
Arguments : Node to remove
Returns : Nothing
Example : removeVM ( $ callback , $ node ) ;
= cut
#-------------------------------------------------------
sub removeVM {
# Get inputs
my ( $ callback , $ node ) = @ _ ;
# Get node properties from 'zvm' table
my @ propNames = ( 'hcp' , 'userid' ) ;
my $ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ node , @ propNames ) ;
# Get HCP
my $ hcp = $ propVals - > { 'hcp' } ;
if ( ! $ hcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing node HCP" ) ;
return ;
}
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-04-12 14:44:14 +00:00
my $ userId = $ propVals - > { 'userid' } ;
if ( ! $ userId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ userId =~ tr /a-z/ A - Z / ;
2010-04-12 14:44:14 +00:00
2012-02-03 05:23:03 +00:00
# Power off user ID
2010-04-12 14:44:14 +00:00
my $ out = `ssh $hcp "$::DIR/stopvs $userId"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
# Delete user entry
$ out = `ssh $hcp "$::DIR/deletevs $userId"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
# Check for errors
my $ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
return ;
}
# Remove node from 'zvm', 'nodelist', 'nodetype', 'noderes', and 'nodehm' tables
# Save node entry in 'mac' table
xCAT::zvmUtils - > delTabEntry ( 'zvm' , 'node' , $ node ) ;
xCAT::zvmUtils - > delTabEntry ( 'nodelist' , 'node' , $ node ) ;
xCAT::zvmUtils - > delTabEntry ( 'nodetype' , 'node' , $ node ) ;
xCAT::zvmUtils - > delTabEntry ( 'noderes' , 'node' , $ node ) ;
xCAT::zvmUtils - > delTabEntry ( 'nodehm' , 'node' , $ node ) ;
2011-10-13 23:05:43 +00:00
# Remove old hostname from known_hosts
$ out = `ssh-keygen -R $node` ;
2010-04-12 14:44:14 +00:00
return ;
}
#-------------------------------------------------------
= head3 changeVM
2012-02-03 05:23:03 +00:00
Description : Change a virtual machine ' s configuration
2010-04-12 14:44:14 +00:00
Arguments : Node
Option
Options supported:
2010-07-07 15:12:44 +00:00
* add3390 [ disk pool ] [ device address ] [ cylinders ] [ mode ] [ read password ] [ write password ] [ multi password ]
* add3390active [ device address ] [ mode ]
* add9336 [ disk pool ] [ virtual device ] [ block size ] [ mode ] [ blocks ] [ read password ] [ write password ] [ multi password ]
* addnic [ address ] [ type ] [ device count ]
* addprocessor [ address ]
* addvdisk [ userID ] [ device address ] [ size ]
* connectnic2guestlan [ address ] [ lan ] [ owner ]
* connectnic2vswitch [ address ] [ vswitch ]
* copydisk [ target address ] [ source node ] [ source address ]
* dedicatedevice [ virtual device ] [ real device ] [ mode ]
* deleteipl
* formatdisk [ disk address ] [ multi password ]
* disconnectnic [ address ]
* grantvswitch [ VSwitch ]
* removedisk [ virtual device ]
* removenic [ address ]
* removeprocessor [ address ]
* replacevs [ user directory entry ]
* setipl [ ipl target ] [ load parms ] [ parms ]
* setpassword [ password ]
2010-04-12 14:44:14 +00:00
Returns : Nothing
Example : changeVM ( $ callback , $ node , $ args ) ;
= cut
#-------------------------------------------------------
sub changeVM {
# Get inputs
my ( $ callback , $ node , $ args ) = @ _ ;
# Get node properties from 'zvm' table
my @ propNames = ( 'hcp' , 'userid' ) ;
my $ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ node , @ propNames ) ;
# Get HCP
my $ hcp = $ propVals - > { 'hcp' } ;
if ( ! $ hcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing node HCP" ) ;
return ;
}
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-04-12 14:44:14 +00:00
my $ userId = $ propVals - > { 'userid' } ;
if ( ! $ userId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ userId =~ tr /a-z/ A - Z / ;
2010-04-12 14:44:14 +00:00
# Output string
2012-02-17 15:42:50 +00:00
my $ out = "" ;
2010-04-12 14:44:14 +00:00
# add3390 [disk pool] [device address] [cylinders] [mode] [read password] [write password] [multi password]
2012-02-03 05:23:03 +00:00
# [read password] [write password] [multi password] are optional
2010-04-12 14:44:14 +00:00
if ( $ args - > [ 0 ] eq "--add3390" ) {
my $ pool = $ args - > [ 1 ] ;
my $ addr = $ args - > [ 2 ] ;
my $ cyl = $ args - > [ 3 ] ;
my $ mode = $ args - > [ 4 ] ;
my $ readPw = $ args - > [ 5 ] ;
my $ writePw = $ args - > [ 6 ] ;
my $ multiPw = $ args - > [ 7 ] ;
2012-02-17 15:42:50 +00:00
# Add to directory entry
2010-04-12 14:44:14 +00:00
$ out = `ssh $hcp "$::DIR/add3390 $userId $pool $addr $cyl $mode $readPw $writePw $multiPw"` ;
2012-02-17 15:42:50 +00:00
# Add to active configuration
2012-02-17 16:14:34 +00:00
my $ ping = `pping $node` ;
2012-02-17 16:22:18 +00:00
if ( ! ( $ ping =~ m/noping/i ) ) {
2012-02-17 16:14:34 +00:00
$ out . = `ssh $hcp "$::DIR/add3390active $userId $addr $mode"` ;
2012-03-27 13:14:11 +00:00
}
2010-04-12 14:44:14 +00:00
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# add3390active [device address] [mode]
elsif ( $ args - > [ 0 ] eq "--add3390active" ) {
my $ addr = $ args - > [ 1 ] ;
my $ mode = $ args - > [ 2 ] ;
$ out = `ssh $hcp "$::DIR/add3390active $userId $addr $mode"` ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# add9336 [disk pool] [virtual device address] [block size] [blocks] [mode] [read password] [write password] [multi password]
2012-02-03 05:23:03 +00:00
# [read password] [write password] [multi password] are optional
2010-04-12 14:44:14 +00:00
elsif ( $ args - > [ 0 ] eq "--add9336" ) {
my $ pool = $ args - > [ 1 ] ;
my $ addr = $ args - > [ 2 ] ;
my $ blksize = $ args - > [ 3 ] ;
my $ blks = $ args - > [ 4 ] ;
my $ mode = $ args - > [ 5 ] ;
my $ readPw = $ args - > [ 6 ] ;
my $ writePw = $ args - > [ 7 ] ;
my $ multiPw = $ args - > [ 8 ] ;
2010-08-25 01:03:40 +00:00
$ out = `ssh $hcp "$::DIR/add9336 $userId $pool $addr $blksize $blks $mode $readPw $writePw $multiPw"` ;
2010-04-12 14:44:14 +00:00
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
2011-05-17 19:57:04 +00:00
# adddisk2pool [function] [region] [volume] [group]
elsif ( $ args - > [ 0 ] eq "--adddisk2pool" ) {
my $ funct = $ args - > [ 1 ] ;
my $ region = $ args - > [ 2 ] ;
my $ volume = "" ;
my $ group = "" ;
# Define region as full volume and add to group
if ( $ funct eq "4" ) {
$ volume = $ args - > [ 3 ] ;
$ group = $ args - > [ 4 ] ;
$ out = `ssh $hcp "$::DIR/adddisk2pool $funct $region $volume $group"` ;
}
# Add existing region to group
elsif ( $ funct eq "5" ) {
$ group = $ args - > [ 3 ] ;
$ out = `ssh $hcp "$::DIR/adddisk2pool $funct $region $group"` ;
}
# Exit
else {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Option not supported" ) ;
return ;
}
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
2010-04-12 14:44:14 +00:00
# addnic [address] [type] [device count]
elsif ( $ args - > [ 0 ] eq "--addnic" ) {
my $ addr = $ args - > [ 1 ] ;
my $ type = $ args - > [ 2 ] ;
my $ devcount = $ args - > [ 3 ] ;
2012-02-17 15:13:59 +00:00
# Add to active configuration
2012-02-17 15:42:50 +00:00
my $ ping = `pping $node` ;
2012-02-17 16:22:18 +00:00
if ( ! ( $ ping =~ m/noping/i ) ) {
2012-02-17 15:42:50 +00:00
$ out = `ssh $node "vmcp define nic $addr type $type"` ;
}
2012-02-17 15:13:59 +00:00
# Add to directory entry
$ out . = `ssh $hcp "$::DIR/addnic $userId $addr $type $devcount"` ;
2010-04-12 14:44:14 +00:00
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# addprocessor [type] address]
elsif ( $ args - > [ 0 ] eq "--addprocessor" ) {
my $ type = $ args - > [ 1 ] ;
my $ addr = $ args - > [ 2 ] ;
$ out = `ssh $hcp "$::DIR/addprocessor $userId $type $addr"` ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# addprocessoractive [address] [type]
elsif ( $ args - > [ 0 ] eq "--addprocessoractive" ) {
my $ addr = $ args - > [ 1 ] ;
my $ type = $ args - > [ 2 ] ;
$ out = xCAT::zvmCPUtils - > defineCpu ( $ node , $ addr , $ type ) ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# addvdisk [device address] [size]
elsif ( $ args - > [ 0 ] eq "--addvdisk" ) {
my $ addr = $ args - > [ 1 ] ;
my $ size = $ args - > [ 2 ] ;
$ out = `ssh $hcp "$::DIR/addvdisk $userId $addr $size"` ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# connectnic2guestlan [address] [lan] [owner]
elsif ( $ args - > [ 0 ] eq "--connectnic2guestlan" ) {
my $ addr = $ args - > [ 1 ] ;
my $ lan = $ args - > [ 2 ] ;
my $ owner = $ args - > [ 3 ] ;
2012-02-17 15:42:50 +00:00
2012-02-17 15:13:59 +00:00
# Connect to LAN in active configuration
2012-02-17 15:42:50 +00:00
my $ ping = `pping $node` ;
2012-02-17 16:22:18 +00:00
if ( ! ( $ ping =~ m/noping/i ) ) {
2012-02-17 15:42:50 +00:00
$ out = `ssh $node "vmcp couple $addr to $owner $lan"` ;
}
2012-02-17 15:13:59 +00:00
$ out . = `ssh $hcp "$::DIR/connectnic2guestlan $userId $addr $lan $owner"` ;
2010-04-12 14:44:14 +00:00
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# connectnic2vswitch [address] [vswitch]
elsif ( $ args - > [ 0 ] eq "--connectnic2vswitch" ) {
my $ addr = $ args - > [ 1 ] ;
my $ vswitch = $ args - > [ 2 ] ;
# Grant access to VSWITCH for Linux user
2012-02-17 15:13:59 +00:00
$ out = "Granting access to VSWITCH for $userId\n " ;
2010-04-12 14:44:14 +00:00
$ out . = `ssh $hcp "vmcp set vswitch $vswitch grant $userId"` ;
2012-02-17 15:42:50 +00:00
2012-02-17 15:13:59 +00:00
# Connect to VSwitch in active configuration
2012-02-17 15:42:50 +00:00
my $ ping = `pping $node` ;
2012-02-17 16:22:18 +00:00
if ( ! ( $ ping =~ m/noping/i ) ) {
2012-02-17 15:42:50 +00:00
$ out . = `ssh $node "vmcp couple $addr to system $vswitch"` ;
}
2012-02-17 15:13:59 +00:00
# Connect to VSwitch in directory entry
$ out . = `ssh $hcp "$::DIR/connectnic2vswitch $userId $addr $vswitch"` ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
2010-04-12 14:44:14 +00:00
}
# copydisk [target address] [source node] [source address]
elsif ( $ args - > [ 0 ] eq "--copydisk" ) {
2010-07-07 15:12:44 +00:00
my $ tgtNode = $ node ;
my $ tgtUserId = $ userId ;
my $ tgtAddr = $ args - > [ 1 ] ;
my $ srcNode = $ args - > [ 2 ] ;
my $ srcAddr = $ args - > [ 3 ] ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get source userID
@ propNames = ( 'hcp' , 'userid' ) ;
$ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ srcNode , @ propNames ) ;
my $ sourceId = $ propVals - > { 'userid' } ;
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
#*** Link and copy disk ***
2010-04-12 14:44:14 +00:00
my $ rc ;
my $ try ;
my $ srcDevNode ;
my $ tgtDevNode ;
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# Link source disk to HCP
my $ srcLinkAddr ;
2012-02-03 05:23:03 +00:00
$ try = 5 ;
2010-04-12 14:44:14 +00:00
while ( $ try > 0 ) {
# New disk address
2010-07-07 15:12:44 +00:00
$ srcLinkAddr = $ srcAddr + 1000 ;
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# Check if new disk address is used (source)
$ rc = xCAT::zvmUtils - > isAddressUsed ( $ hcp , $ srcLinkAddr ) ;
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# If disk address is used (source)
2010-04-12 14:44:14 +00:00
while ( $ rc == 0 ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Generate a new disk address
# Sleep 5 seconds to let existing disk appear
sleep ( 5 ) ;
2010-07-07 15:12:44 +00:00
$ srcLinkAddr = $ srcLinkAddr + 1 ;
$ rc = xCAT::zvmUtils - > isAddressUsed ( $ hcp , $ srcLinkAddr ) ;
2010-04-12 14:44:14 +00:00
}
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# Link source disk
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Linking source disk ($srcAddr) as ($srcLinkAddr)" ) ;
$ out = `ssh -o ConnectTimeout=5 $hcp "vmcp link $sourceId $srcAddr $srcLinkAddr MR"` ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# If link fails
if ( $ out =~ m/not linked/i ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Wait before trying again
sleep ( 5 ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
$ try = $ try - 1 ;
2012-02-03 05:23:03 +00:00
} else {
2010-04-12 14:44:14 +00:00
last ;
}
2010-06-15 21:09:35 +00:00
} # End of while ( $try > 0 )
2010-04-12 14:44:14 +00:00
2010-07-07 15:12:44 +00:00
# Link target disk to HCP
my $ tgtLinkAddr ;
2012-02-03 05:23:03 +00:00
$ try = 5 ;
2010-04-12 14:44:14 +00:00
while ( $ try > 0 ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# New disk address
2010-07-07 15:12:44 +00:00
$ tgtLinkAddr = $ tgtAddr + 2000 ;
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# Check if new disk address is used (target)
$ rc = xCAT::zvmUtils - > isAddressUsed ( $ hcp , $ tgtLinkAddr ) ;
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# If disk address is used (target)
2010-04-12 14:44:14 +00:00
while ( $ rc == 0 ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Generate a new disk address
# Sleep 5 seconds to let existing disk appear
sleep ( 5 ) ;
2010-07-07 15:12:44 +00:00
$ tgtLinkAddr = $ tgtLinkAddr + 1 ;
$ rc = xCAT::zvmUtils - > isAddressUsed ( $ hcp , $ tgtLinkAddr ) ;
2010-04-12 14:44:14 +00:00
}
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# Link target disk
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Linking target disk ($tgtAddr) as ($tgtLinkAddr)" ) ;
$ out = `ssh -o ConnectTimeout=5 $hcp "vmcp link $tgtUserId $tgtAddr $tgtLinkAddr MR"` ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# If link fails
if ( $ out =~ m/not linked/i ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Wait before trying again
sleep ( 5 ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
$ try = $ try - 1 ;
2012-02-03 05:23:03 +00:00
} else {
2010-04-12 14:44:14 +00:00
last ;
}
2010-06-15 21:09:35 +00:00
} # End of while ( $try > 0 )
2010-07-07 15:12:44 +00:00
# If target disk is not linked
if ( $ out =~ m/not linked/i ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Failed to link target disk ($tgtAddr)" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Failed" ) ;
# Exit
return ;
}
2010-04-12 14:44:14 +00:00
# If source disk is not linked
if ( $ out =~ m/not linked/i ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Failed to link source disk ($srcAddr)" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Failed" ) ;
# Exit
return ;
}
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
#*** Use flashcopy ***
2011-12-21 17:40:40 +00:00
# Flashcopy only supports ECKD volumes
my $ ddCopy = 0 ;
2010-07-07 15:12:44 +00:00
$ out = `ssh $hcp "vmcp flashcopy"` ;
if ( $ out =~ m/HCPNFC026E/i ) {
2010-04-12 14:44:14 +00:00
2010-07-07 15:12:44 +00:00
# Flashcopy is supported
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Copying source disk ($srcLinkAddr) to target disk ($tgtLinkAddr) using FLASHCOPY" ) ;
# Check for flashcopy lock
my $ wait = 0 ;
while ( `ssh $hcp "ls /tmp/.flashcopy_lock"` && $ wait < 90 ) {
# Wait until the lock dissappears
# 90 seconds wait limit
sleep ( 2 ) ;
$ wait = $ wait + 2 ;
}
# If flashcopy locks still exists
if ( `ssh $hcp "ls /tmp/.flashcopy_lock"` ) {
# Detatch disks from HCP
$ out = `ssh $hcp "vmcp det $tgtLinkAddr"` ;
$ out = `ssh $hcp "vmcp det $srcLinkAddr"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Flashcopy lock is enabled" ) ;
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Solution) Remove lock by deleting /tmp/.flashcopy_lock on the zHCP. Use caution!" ) ;
2010-07-07 15:12:44 +00:00
return ;
2011-12-21 17:40:40 +00:00
} else {
2010-07-07 15:12:44 +00:00
# Enable lock
$ out = `ssh $hcp "touch /tmp/.flashcopy_lock"` ;
# Flashcopy source disk
$ out = xCAT::zvmCPUtils - > flashCopy ( $ hcp , $ srcLinkAddr , $ tgtLinkAddr ) ;
$ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: $out" ) ;
# Detatch disks from HCP
$ out = `ssh $hcp "vmcp det $tgtAddr"` ;
$ out = `ssh $hcp "vmcp det $srcLinkAddr"` ;
# Remove lock
$ out = `ssh $hcp "rm -f /tmp/.flashcopy_lock"` ;
return ;
}
# Remove lock
$ out = `ssh $hcp "rm -f /tmp/.flashcopy_lock"` ;
}
2011-12-21 17:40:40 +00:00
} else {
$ ddCopy = 1 ;
2010-07-07 15:12:44 +00:00
}
2011-12-21 17:40:40 +00:00
# Flashcopy not supported, use Linux dd
if ( $ ddCopy ) {
2010-07-07 15:12:44 +00:00
#*** Use Linux dd to copy ***
2011-12-21 17:40:40 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: FLASHCOPY not working. Using Linux DD" ) ;
2010-04-12 14:44:14 +00:00
# Enable disks
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-e" , $ tgtLinkAddr ) ;
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-e" , $ srcLinkAddr ) ;
# Determine source device node
2010-08-31 19:51:06 +00:00
$ srcDevNode = xCAT::zvmUtils - > getDeviceNode ( $ hcp , $ srcLinkAddr ) ;
2010-04-12 14:44:14 +00:00
# Determine target device node
2010-08-31 19:51:06 +00:00
$ tgtDevNode = xCAT::zvmUtils - > getDeviceNode ( $ hcp , $ tgtLinkAddr ) ;
2010-04-12 14:44:14 +00:00
# Format target disk
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Formating target disk ($tgtDevNode)" ) ;
$ out = `ssh $hcp "dasdfmt -b 4096 -y -f /dev/$tgtDevNode"` ;
# Check for errors
$ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: $out" ) ;
return ;
}
# Sleep 2 seconds to let the system settle
sleep ( 2 ) ;
2010-07-07 15:12:44 +00:00
# Copy source disk to target disk (4096 block size)
2010-04-12 14:44:14 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Copying source disk ($srcDevNode) to target disk ($tgtDevNode)" ) ;
$ out = `ssh $hcp "dd if=/dev/$srcDevNode of=/dev/$tgtDevNode bs=4096"` ;
2010-07-07 15:12:44 +00:00
# Disable disks
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-d" , $ tgtLinkAddr ) ;
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-d" , $ srcLinkAddr ) ;
2010-04-12 14:44:14 +00:00
# Check for error
$ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: $out" ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Detatch disks from HCP
$ out = `ssh $hcp "vmcp det $tgtLinkAddr"` ;
$ out = `ssh $hcp "vmcp det $srcLinkAddr"` ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
return ;
}
# Sleep 2 seconds to let the system settle
sleep ( 2 ) ;
}
# Detatch disks from HCP
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Detatching target disk ($tgtLinkAddr)" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Detatching source disk ($srcLinkAddr)" ) ;
$ out = `ssh $hcp "vmcp det $tgtLinkAddr"` ;
$ out = `ssh $hcp "vmcp det $srcLinkAddr"` ;
$ out = "$tgtNode: Done" ;
}
# dedicatedevice [virtual device] [real device] [mode]
elsif ( $ args - > [ 0 ] eq "--dedicatedevice" ) {
my $ vaddr = $ args - > [ 1 ] ;
my $ raddr = $ args - > [ 2 ] ;
my $ mode = $ args - > [ 3 ] ;
$ out = `ssh $hcp "$::DIR/dedicatedevice $userId $vaddr $raddr $mode"` ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# deleteipl
elsif ( $ args - > [ 0 ] eq "--deleteipl" ) {
$ out = `ssh $hcp "$::DIR/deleteipl $userId"` ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# formatdisk [address] [multi password]
elsif ( $ args - > [ 0 ] eq "--formatdisk" ) {
2010-07-07 15:12:44 +00:00
my $ tgtNode = $ node ;
my $ tgtUserId = $ userId ;
my $ tgtAddr = $ args - > [ 1 ] ;
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
#*** Link and format disk ***
2010-04-12 14:44:14 +00:00
my $ rc ;
my $ try ;
my $ tgtDevNode ;
2010-06-15 21:09:35 +00:00
2012-02-03 05:23:03 +00:00
# Link target disk to zHCP
2010-04-12 14:44:14 +00:00
my $ tgtLinkAddr ;
2012-02-03 05:23:03 +00:00
$ try = 5 ;
2010-04-12 14:44:14 +00:00
while ( $ try > 0 ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# New disk address
$ tgtLinkAddr = $ tgtAddr + 1000 ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Check if new disk address is used (target)
$ rc = xCAT::zvmUtils - > isAddressUsed ( $ hcp , $ tgtLinkAddr ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# If disk address is used (target)
while ( $ rc == 0 ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Generate a new disk address
# Sleep 5 seconds to let existing disk appear
sleep ( 5 ) ;
$ tgtLinkAddr = $ tgtLinkAddr + 1 ;
$ rc = xCAT::zvmUtils - > isAddressUsed ( $ hcp , $ tgtLinkAddr ) ;
}
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Link target disk
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Linking target disk ($tgtAddr) as ($tgtLinkAddr)" ) ;
2010-07-07 15:12:44 +00:00
$ out = `ssh -o ConnectTimeout=5 $hcp "vmcp link $tgtUserId $tgtAddr $tgtLinkAddr MR"` ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# If link fails
if ( $ out =~ m/not linked/i ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Wait before trying again
sleep ( 5 ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
$ try = $ try - 1 ;
2010-06-15 21:09:35 +00:00
}
else {
2010-04-12 14:44:14 +00:00
last ;
}
2010-06-15 21:09:35 +00:00
} # End of while ( $try > 0 )
2010-04-12 14:44:14 +00:00
# If target disk is not linked
if ( $ out =~ m/not linked/i ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Failed to link target disk ($tgtAddr)" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Failed" ) ;
# Exit
return ;
}
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
#*** Format disk ***
2010-04-12 14:44:14 +00:00
my @ words ;
if ( $ rc == - 1 ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Enable disk
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-e" , $ tgtLinkAddr ) ;
# Determine target device node
2010-08-31 19:51:06 +00:00
$ tgtDevNode = xCAT::zvmUtils - > getDeviceNode ( $ hcp , $ tgtLinkAddr ) ;
2010-04-12 14:44:14 +00:00
# Format target disk
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Formating target disk ($tgtDevNode)" ) ;
$ out = `ssh $hcp "dasdfmt -b 4096 -y -f /dev/$tgtDevNode"` ;
# Check for errors
$ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: $out" ) ;
return ;
}
# Sleep 2 seconds to let the system settle
sleep ( 2 ) ;
}
# Disable disk
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-d" , $ tgtLinkAddr ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Detatch disk from HCP
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Detatching target disk ($tgtLinkAddr)" ) ;
$ out = `ssh $hcp "vmcp det $tgtLinkAddr"` ;
$ out = "$tgtNode: Done" ;
}
# grantvswitch [VSwitch]
elsif ( $ args - > [ 0 ] eq "--grantvswitch" ) {
my $ vsw = $ args - > [ 1 ] ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
$ out = xCAT::zvmCPUtils - > grantVSwitch ( $ callback , $ hcp , $ userId , $ vsw ) ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# disconnectnic [address]
elsif ( $ args - > [ 0 ] eq "--disconnectnic" ) {
my $ addr = $ args - > [ 1 ] ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
$ out = `ssh $hcp "$::DIR/disconnectnic $userId $addr"` ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
2011-05-17 19:57:04 +00:00
# removediskfrompool [function] [region] [group]
elsif ( $ args - > [ 0 ] eq "--removediskfrompool" ) {
my $ funct = $ args - > [ 1 ] ;
my $ region = $ args - > [ 2 ] ;
my $ group = "" ;
# Remove region from group | Remove entire group
if ( $ funct eq "2" || $ funct eq "7" ) {
$ group = $ args - > [ 3 ] ;
$ out = `ssh $hcp "$::DIR/removediskfrompool $funct $region $group"` ;
}
# Remove region | Remove region from all groups
elsif ( $ funct eq "1" || $ funct eq "3" ) {
$ out = `ssh $hcp "$::DIR/removediskfrompool $funct $region"` ;
}
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
2010-04-12 14:44:14 +00:00
# removedisk [virtual device address]
elsif ( $ args - > [ 0 ] eq "--removedisk" ) {
my $ addr = $ args - > [ 1 ] ;
2012-02-27 22:16:42 +00:00
# Remove from active configuration
my $ ping = `pping $node` ;
if ( ! ( $ ping =~ m/noping/i ) ) {
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ node , "-d" , $ addr ) ;
$ out = `ssh $node "vmcp det $addr"` ;
}
2010-06-15 21:09:35 +00:00
2012-02-27 22:16:42 +00:00
# Remove from user directory entry
2010-04-12 14:44:14 +00:00
$ out = `ssh $hcp "$::DIR/removemdisk $userId $addr"` ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# removenic [address]
elsif ( $ args - > [ 0 ] eq "--removenic" ) {
my $ addr = $ args - > [ 1 ] ;
2012-02-27 22:16:42 +00:00
# Remove from active configuration
my $ ping = `pping $node` ;
if ( ! ( $ ping =~ m/noping/i ) ) {
$ out = `ssh $node "vmcp det nic $addr"` ;
}
2010-06-15 21:09:35 +00:00
2012-02-27 22:16:42 +00:00
# Remove from user directory entry
2010-04-12 14:44:14 +00:00
$ out = `ssh $hcp "$::DIR/removenic $userId $addr"` ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# removeprocessor [address]
elsif ( $ args - > [ 0 ] eq "--removeprocessor" ) {
my $ addr = $ args - > [ 1 ] ;
2012-02-27 22:16:42 +00:00
# Remove from user directory entry
2010-04-12 14:44:14 +00:00
$ out = `ssh $hcp "$::DIR/removeprocessor $userId $addr"` ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# replacevs [file]
elsif ( $ args - > [ 0 ] eq "--replacevs" ) {
my $ file = $ args - > [ 1 ] ;
2010-07-07 15:12:44 +00:00
# Target system (HCP), e.g. root@gpok2.endicott.ibm.com
2010-04-12 14:44:14 +00:00
my $ target = "root@" ;
$ target . = $ hcp ;
if ( $ file ) {
2012-02-03 05:23:03 +00:00
# SCP file over to zHCP
2010-04-12 14:44:14 +00:00
$ out = `scp $file $target:$file` ;
# Replace user directory entry
$ out = `ssh $hcp "$::DIR/replacevs $userId $file"` ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
else {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) No directory entry file specified" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Specify a text file containing the updated directory entry" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
}
2010-11-01 19:33:41 +00:00
# resetsmapi
2012-02-03 05:23:03 +00:00
elsif ( $ args - > [ 0 ] eq "--resetsmapi" ) {
# Assuming zVM 6.1 or older
2010-11-01 19:33:41 +00:00
# Force each worker machine off
my @ workers = ( 'VSMWORK1' , 'VSMWORK2' , 'VSMWORK3' , 'VSMREQIN' , 'VSMREQIU' ) ;
foreach ( @ workers ) {
$ out = `ssh $hcp "vmcp force $_ logoff immediate"` ;
}
# Log on VSMWORK1
$ out = `ssh $hcp "vmcp xautolog VSMWORK1"` ;
$ out = "$node: Resetting SMAPI... Done" ;
}
2010-04-12 14:44:14 +00:00
# setipl [ipl target] [load parms] [parms]
elsif ( $ args - > [ 0 ] eq "--setipl" ) {
my $ trgt = $ args - > [ 1 ] ;
my $ loadparms = $ args - > [ 2 ] ;
my $ parms = $ args - > [ 3 ] ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
$ out = `ssh $hcp "$::DIR/setipl $userId $trgt $loadparms $parms"` ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# setpassword [password]
elsif ( $ args - > [ 0 ] eq "--setpassword" ) {
my $ pw = $ args - > [ 1 ] ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
$ out = `ssh $hcp "$::DIR/setpassword $userId $pw"` ;
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
}
# Otherwise, print out error
else {
$ out = "$node: (Error) Option not supported" ;
}
xCAT::zvmUtils - > printLn ( $ callback , "$out" ) ;
return ;
}
#-------------------------------------------------------
= head3 powerVM
2010-07-07 15:12:44 +00:00
Description : Power on or off a given node
2010-04-12 14:44:14 +00:00
Arguments : Node
Option [ on | off | reset | stat ]
Returns : Nothing
Example : powerVM ( $ callback , $ node , $ args ) ;
= cut
#-------------------------------------------------------
sub powerVM {
# Get inputs
my ( $ callback , $ node , $ args ) = @ _ ;
# Get node properties from 'zvm' table
my @ propNames = ( 'hcp' , 'userid' ) ;
my $ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ node , @ propNames ) ;
# Get HCP
my $ hcp = $ propVals - > { 'hcp' } ;
if ( ! $ hcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing node HCP" ) ;
return ;
}
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-04-12 14:44:14 +00:00
my $ userId = $ propVals - > { 'userid' } ;
if ( ! $ userId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ userId =~ tr /a-z/ A - Z / ;
2010-04-12 14:44:14 +00:00
# Output string
my $ out ;
# Power on virtual server
if ( $ args - > [ 0 ] eq 'on' ) {
$ out = `ssh $hcp "$::DIR/startvs $userId"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
}
# Power off virtual server
elsif ( $ args - > [ 0 ] eq 'off' ) {
$ out = `ssh $hcp "$::DIR/stopvs $userId"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
}
2011-10-04 14:09:27 +00:00
# Power off virtual server (gracefully)
elsif ( $ args - > [ 0 ] eq 'softoff' ) {
$ out = `ssh -o ConnectTimeout=10 $node "shutdown -h now"` ;
2011-10-05 18:04:33 +00:00
sleep ( 90 ) ; # Wait 1.5 minutes before logging user off
2011-10-04 14:09:27 +00:00
$ out = `ssh $hcp "$::DIR/stopvs $userId"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
}
2010-04-12 14:44:14 +00:00
# Get the status (on|off)
elsif ( $ args - > [ 0 ] eq 'stat' ) {
$ out = `ssh $hcp "vmcp q user $userId 2>/dev/null" | sed 's/HCPCQU045E.*/off/' | sed 's/$userId.*/on/'` ;
2010-06-15 21:09:35 +00:00
# Wait for output
my $ max = 0 ;
while ( ! $ out && $ max < 10 ) {
$ out = `ssh $hcp "vmcp q user $userId 2>/dev/null" | sed 's/HCPCQU045E.*/off/' | sed 's/$userId.*/on/'` ;
$ max + + ;
}
2010-04-12 14:44:14 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
}
# Reset a virtual server
elsif ( $ args - > [ 0 ] eq 'reset' ) {
$ out = `ssh $hcp "$::DIR/stopvs $userId"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
# Wait for output
2010-06-15 21:09:35 +00:00
while ( `vmcp q user $userId 2>/dev/null | sed 's/HCPCQU045E.*/Done/'` != "Done" ) {
2010-04-12 14:44:14 +00:00
# Do nothing
}
$ out = `ssh $hcp "$::DIR/startvs $userId"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
}
else {
2010-06-15 21:09:35 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Option not supported" ) ;
2010-04-12 14:44:14 +00:00
}
return ;
}
#-------------------------------------------------------
= head3 scanVM
2010-07-07 15:12:44 +00:00
Description : Get node information from zHCP
2012-02-03 05:23:03 +00:00
Arguments : zHCP
2010-04-12 14:44:14 +00:00
Returns : Nothing
Example : scanVM ( $ callback , $ node , $ args ) ;
= cut
#-------------------------------------------------------
sub scanVM {
# Get inputs
2011-05-17 19:57:04 +00:00
my ( $ callback , $ node , $ args ) = @ _ ;
my $ write2db = '' ;
if ( $ args ) {
@ ARGV = @$ args ;
# Parse options
GetOptions ( 'w' = > \ $ write2db ) ;
}
2011-05-24 18:26:13 +00:00
2010-04-12 14:44:14 +00:00
# Get node properties from 'zvm' table
my @ propNames = ( 'hcp' , 'userid' ) ;
my $ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ node , @ propNames ) ;
2012-02-03 05:23:03 +00:00
# Get zHCP
2010-04-12 14:44:14 +00:00
my $ hcp = $ propVals - > { 'hcp' } ;
if ( ! $ hcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing node HCP" ) ;
return ;
}
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-04-12 14:44:14 +00:00
my $ userId = $ propVals - > { 'userid' } ;
if ( ! $ userId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ userId =~ tr /a-z/ A - Z / ;
2011-05-24 14:48:59 +00:00
# Exit if node is not a HCP
2012-02-03 05:23:03 +00:00
if ( ! ( $ hcp =~ m/$node/i ) ) {
2011-05-24 14:48:59 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) $node is not a hardware control point" ) ;
return ;
}
2010-04-12 14:44:14 +00:00
# Print output string
# [Node name]:
# objtype=node
# id=[userID]
# arch=[Architecture]
# hcp=[HCP node name]
# groups=[Group]
# mgt=zvm
#
# gpok123:
# objtype=node
# id=LINUX123
# arch=s390x
# hcp=gpok456.endicott.ibm.com
# groups=all
# mgt=zvm
# Output string
my $ str = "" ;
2012-02-03 05:23:03 +00:00
# Get nodes managed by this zHCP
2010-04-12 14:44:14 +00:00
# Look in 'zvm' table
my $ tab = xCAT::Table - > new ( 'zvm' , - create = > 1 , - autocommit = > 0 ) ;
my @ entries = $ tab - > getAllAttribsWhere ( "hcp like '%" . $ hcp . "%'" , 'node' , 'userid' ) ;
my $ out ;
2011-05-17 19:57:04 +00:00
my $ node ;
2010-04-12 14:44:14 +00:00
my $ id ;
my $ os ;
my $ arch ;
my $ groups ;
2011-05-17 19:57:04 +00:00
# Get node hierarchy from /proc/sysinfo
my $ hierarchy ;
my $ host = xCAT::zvmCPUtils - > getHost ( $ hcp ) ;
my $ sysinfo = `ssh -o ConnectTimeout=5 $hcp "cat /proc/sysinfo"` ;
# Get node CEC
my $ cec = `echo "$sysinfo" | grep "Sequence Code"` ;
my @ args = split ( ':' , $ cec ) ;
# Remove leading spaces and zeros
$ args [ 1 ] =~ s/^\s*0*// ;
$ cec = xCAT::zvmUtils - > trimStr ( $ args [ 1 ] ) ;
# Get node LPAR
my $ lpar = `echo "$sysinfo" | grep "LPAR Name"` ;
@ args = split ( ':' , $ lpar ) ;
$ lpar = xCAT::zvmUtils - > trimStr ( $ args [ 1 ] ) ;
# Save CEC, LPAR, and zVM to 'zvm' table
my % propHash ;
if ( $ write2db ) {
# Save CEC to 'zvm' table
% propHash = (
'nodetype' = > 'cec' ,
'parent' = > ''
) ;
xCAT::zvmUtils - > setNodeProps ( 'zvm' , $ cec , \ % propHash ) ;
# Save LPAR to 'zvm' table
% propHash = (
'nodetype' = > 'lpar' ,
'parent' = > $ cec
) ;
xCAT::zvmUtils - > setNodeProps ( 'zvm' , $ lpar , \ % propHash ) ;
# Save zVM to 'zvm' table
% propHash = (
'nodetype' = > 'zvm' ,
'parent' = > $ lpar
) ;
xCAT::zvmUtils - > setNodeProps ( 'zvm' , $ host , \ % propHash ) ;
}
2012-02-03 05:23:03 +00:00
# Search for nodes managed by given zHCP
2010-04-12 14:44:14 +00:00
# Get 'node' and 'userid' properties
2011-05-17 19:57:04 +00:00
% propHash = ( ) ;
2010-04-12 14:44:14 +00:00
foreach ( @ entries ) {
2011-05-17 19:57:04 +00:00
$ node = $ _ - > { 'node' } ;
2010-04-12 14:44:14 +00:00
# Get groups
@ propNames = ( 'groups' ) ;
2011-05-17 19:57:04 +00:00
$ propVals = xCAT::zvmUtils - > getNodeProps ( 'nodelist' , $ node , @ propNames ) ;
2010-06-15 21:09:35 +00:00
$ groups = $ propVals - > { 'groups' } ;
2010-04-12 14:44:14 +00:00
# Load VMCP module
2011-05-17 19:57:04 +00:00
xCAT::zvmCPUtils - > loadVmcp ( $ node ) ;
2010-04-12 14:44:14 +00:00
2012-02-03 05:23:03 +00:00
# Get user ID
2011-05-17 19:57:04 +00:00
@ propNames = ( 'userid' ) ;
$ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ node , @ propNames ) ;
$ id = $ propVals - > { 'userid' } ;
if ( ! $ id ) {
$ id = xCAT::zvmCPUtils - > getUserId ( $ node ) ;
}
2010-04-12 14:44:14 +00:00
# Get architecture
2011-05-17 19:57:04 +00:00
$ arch = `ssh -o ConnectTimeout=2 $node "uname -p"` ;
$ arch = xCAT::zvmUtils - > trimStr ( $ arch ) ;
if ( ! $ arch ) {
# Assume arch is s390x
$ arch = 's390x' ;
}
2011-05-24 18:26:13 +00:00
# Get OS
$ os = xCAT::zvmUtils - > getOsVersion ( $ node ) ;
# Save node attributes
2011-05-17 19:57:04 +00:00
if ( $ write2db ) {
2011-05-24 18:26:13 +00:00
# Save to 'zvm' table
2011-05-17 19:57:04 +00:00
% propHash = (
'hcp' = > $ hcp ,
'userid' = > $ id ,
'nodetype' = > 'vm' ,
'parent' = > $ host
2011-05-24 18:26:13 +00:00
) ;
2011-05-17 19:57:04 +00:00
xCAT::zvmUtils - > setNodeProps ( 'zvm' , $ node , \ % propHash ) ;
2011-05-24 18:26:13 +00:00
# Save to 'nodetype' table
% propHash = (
'arch' = > $ arch ,
'os' = > $ os
) ;
xCAT::zvmUtils - > setNodeProps ( 'nodetype' , $ node , \ % propHash ) ;
2011-05-17 19:57:04 +00:00
}
2010-04-12 14:44:14 +00:00
# Create output string
2011-05-17 19:57:04 +00:00
$ str . = "$node:\n" ;
2010-04-12 14:44:14 +00:00
$ str . = " objtype=node\n" ;
$ str . = " arch=$arch\n" ;
2011-05-24 18:26:13 +00:00
$ str . = " os=$os\n" ;
2010-04-12 14:44:14 +00:00
$ str . = " hcp=$hcp\n" ;
2011-05-17 19:57:04 +00:00
$ str . = " userid=$id\n" ;
$ str . = " nodetype=vm\n" ;
$ str . = " parent=$host\n" ;
2010-04-12 14:44:14 +00:00
$ str . = " groups=$groups\n" ;
$ str . = " mgt=zvm\n\n" ;
}
xCAT::zvmUtils - > printLn ( $ callback , "$str" ) ;
return ;
}
#-------------------------------------------------------
= head3 inventoryVM
2010-07-07 15:12:44 +00:00
Description : Get hardware and software inventory of a given node
2010-04-12 14:44:14 +00:00
Arguments : Node
Type of inventory ( config | all )
Returns : Nothing
Example : inventoryVM ( $ callback , $ node , $ args ) ;
= cut
#-------------------------------------------------------
sub inventoryVM {
# Get inputs
my ( $ callback , $ node , $ args ) = @ _ ;
# Get node properties from 'zvm' table
my @ propNames = ( 'hcp' , 'userid' ) ;
my $ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ node , @ propNames ) ;
2012-02-03 05:23:03 +00:00
# Get zHCP
2010-04-12 14:44:14 +00:00
my $ hcp = $ propVals - > { 'hcp' } ;
if ( ! $ hcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing node HCP" ) ;
return ;
}
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-04-12 14:44:14 +00:00
my $ userId = $ propVals - > { 'userid' } ;
if ( ! $ userId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ userId =~ tr /a-z/ A - Z / ;
2010-04-12 14:44:14 +00:00
# Output string
my $ str = "" ;
# Load VMCP module
xCAT::zvmCPUtils - > loadVmcp ( $ node ) ;
# Get configuration
if ( $ args - > [ 0 ] eq 'config' ) {
# Get z/VM host for specified node
my $ host = xCAT::zvmCPUtils - > getHost ( $ node ) ;
# Get architecture
my $ arch = xCAT::zvmUtils - > getArch ( $ node ) ;
# Get operating system
my $ os = xCAT::zvmUtils - > getOs ( $ node ) ;
# Get privileges
my $ priv = xCAT::zvmCPUtils - > getPrivileges ( $ node ) ;
# Get memory configuration
my $ memory = xCAT::zvmCPUtils - > getMemory ( $ node ) ;
# Get processors configuration
my $ proc = xCAT::zvmCPUtils - > getCpu ( $ node ) ;
$ str . = "z/VM UserID: $userId\n" ;
$ str . = "z/VM Host: $host\n" ;
$ str . = "Operating System: $os\n" ;
$ str . = "Architecture: $arch\n" ;
$ str . = "HCP: $hcp\n" ;
$ str . = "Privileges: \n$priv\n" ;
$ str . = "Total Memory: $memory\n" ;
$ str . = "Processors: \n$proc\n" ;
}
elsif ( $ args - > [ 0 ] eq 'all' ) {
# Get z/VM host for specified node
my $ host = xCAT::zvmCPUtils - > getHost ( $ node ) ;
# Get architecture
my $ arch = xCAT::zvmUtils - > getArch ( $ node ) ;
# Get operating system
my $ os = xCAT::zvmUtils - > getOs ( $ node ) ;
# Get privileges
my $ priv = xCAT::zvmCPUtils - > getPrivileges ( $ node ) ;
# Get memory configuration
my $ memory = xCAT::zvmCPUtils - > getMemory ( $ node ) ;
# Get processors configuration
my $ proc = xCAT::zvmCPUtils - > getCpu ( $ node ) ;
# Get disks configuration
my $ storage = xCAT::zvmCPUtils - > getDisks ( $ node ) ;
# Get NICs configuration
my $ nic = xCAT::zvmCPUtils - > getNic ( $ node ) ;
# Create output string
$ str . = "z/VM UserID: $userId\n" ;
$ str . = "z/VM Host: $host\n" ;
$ str . = "Operating System: $os\n" ;
$ str . = "Architecture: $arch\n" ;
$ str . = "HCP: $hcp\n" ;
$ str . = "Privileges: \n$priv\n" ;
$ str . = "Total Memory: $memory\n" ;
$ str . = "Processors: \n$proc\n" ;
$ str . = "Disks: \n$storage\n" ;
$ str . = "NICs: \n$nic\n" ;
}
else {
$ str = "$node: (Error) Option not supported" ;
xCAT::zvmUtils - > printLn ( $ callback , "$str" ) ;
return ;
}
# Append hostname (e.g. gpok3) in front
$ str = xCAT::zvmUtils - > appendHostname ( $ node , $ str ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$str" ) ;
return ;
}
#-------------------------------------------------------
= head3 listVM
2010-07-07 15:12:44 +00:00
Description : Show the info for a given node
2010-04-12 14:44:14 +00:00
Arguments : Node
Option
2012-02-03 05:23:03 +00:00
2010-04-12 14:44:14 +00:00
Options supported:
2010-07-07 15:12:44 +00:00
* getnetworknames
* getnetwork [ networkname ]
* diskpoolnames
* diskpool [ pool name ] [ space ( free or used ) ]
2010-04-12 14:44:14 +00:00
Returns : Nothing
Example : listVM ( $ callback , $ node ) ;
= cut
#-------------------------------------------------------
sub listVM {
# Get inputs
my ( $ callback , $ node , $ args ) = @ _ ;
2010-11-23 16:42:37 +00:00
# Set cache directory
2010-12-03 21:28:43 +00:00
my $ cache = '/var/opt/zhcp/cache' ;
2010-11-23 16:42:37 +00:00
2010-04-12 14:44:14 +00:00
# Get node properties from 'zvm' table
my @ propNames = ( 'hcp' , 'userid' ) ;
my $ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ node , @ propNames ) ;
2012-02-03 05:23:03 +00:00
# Get zHCP
2010-04-12 14:44:14 +00:00
my $ hcp = $ propVals - > { 'hcp' } ;
if ( ! $ hcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing node HCP" ) ;
return ;
}
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-04-12 14:44:14 +00:00
my $ userId = $ propVals - > { 'userid' } ;
if ( ! $ userId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ userId =~ tr /a-z/ A - Z / ;
2010-04-12 14:44:14 +00:00
my $ out ;
# Get disk pool names
if ( $ args - > [ 0 ] eq "--diskpoolnames" ) {
2010-12-03 21:28:43 +00:00
# If the cache directory does not exist
if ( ! ( `ssh $hcp "test -d $cache && echo Exists"` ) ) {
# Create cache directory
$ out = `ssh $hcp "mkdir -p $cache"` ;
}
2010-11-23 16:42:37 +00:00
my $ file = "$cache/diskpoolnames" ;
# If a cache for disk pool names exists
if ( `ssh $hcp "ls $file"` ) {
# Get current Epoch
my $ curTime = time ( ) ;
# Get time of last change as seconds since Epoch
my $ fileTime = xCAT::zvmUtils - > trimStr ( `ssh $hcp "stat -c %Z $file"` ) ;
# If the current time is greater than 5 minutes of the file timestamp
my $ interval = 300 ; # 300 seconds = 5 minutes * 60 seconds/minute
if ( $ curTime > $ fileTime + $ interval ) {
# Get disk pool names and save it in a file
$ out = `ssh $hcp "$::DIR/getdiskpoolnames $userId > $file"` ;
}
} else {
# Get disk pool names and save it in a file
$ out = `ssh $hcp "$::DIR/getdiskpoolnames $userId > $file"` ;
}
# Print out the file contents
$ out = `ssh $hcp "cat $file"` ;
2010-04-12 14:44:14 +00:00
}
# Get disk pool configuration
elsif ( $ args - > [ 0 ] eq "--diskpool" ) {
my $ pool = $ args - > [ 1 ] ;
my $ space = $ args - > [ 2 ] ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
$ out = `ssh $hcp "$::DIR/getdiskpool $userId $pool $space"` ;
}
# Get network names
elsif ( $ args - > [ 0 ] eq "--getnetworknames" ) {
$ out = xCAT::zvmCPUtils - > getNetworkNames ( $ hcp ) ;
}
# Get network
elsif ( $ args - > [ 0 ] eq "--getnetwork" ) {
my $ netName = $ args - > [ 1 ] ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
$ out = xCAT::zvmCPUtils - > getNetwork ( $ hcp , $ netName ) ;
}
# Get user entry
elsif ( ! $ args - > [ 0 ] ) {
$ out = `ssh $hcp "$::DIR/getuserentry $userId"` ;
}
else {
$ out = "$node: (Error) Option not supported" ;
}
# Append hostname (e.g. gpok3) in front
$ out = xCAT::zvmUtils - > appendHostname ( $ node , $ out ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$out" ) ;
return ;
}
#-------------------------------------------------------
= head3 makeVM
2012-02-03 05:23:03 +00:00
Description : Create a virtual machine
2010-07-07 15:12:44 +00:00
* A unique MAC address will be assigned
2010-04-12 14:44:14 +00:00
Arguments : Node
2012-02-03 05:23:03 +00:00
Directory entry text file ( optional )
2010-04-12 14:44:14 +00:00
Returns : Nothing
Example : makeVM ( $ callback , $ node , $ args ) ;
= cut
#-------------------------------------------------------
sub makeVM {
# Get inputs
my ( $ callback , $ node , $ args ) = @ _ ;
# Get node properties from 'zvm' table
my @ propNames = ( 'hcp' , 'userid' ) ;
my $ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ node , @ propNames ) ;
# Get HCP
my $ hcp = $ propVals - > { 'hcp' } ;
if ( ! $ hcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing node HCP" ) ;
return ;
}
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-04-12 14:44:14 +00:00
my $ userId = $ propVals - > { 'userid' } ;
if ( ! $ userId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ userId =~ tr /a-z/ A - Z / ;
2010-04-12 14:44:14 +00:00
# Get user entry file (if any)
my $ userEntry = $ args - > [ 0 ] ;
# Create virtual server
2010-06-15 21:09:35 +00:00
my $ out ;
2012-01-21 14:55:19 +00:00
my @ lines ;
my @ words ;
2010-04-12 14:44:14 +00:00
my $ target = "root@" . $ hcp ;
if ( $ userEntry ) {
2012-01-21 13:53:46 +00:00
# Copy user entry
$ out = `cp $userEntry /tmp/$node.txt` ;
$ userEntry = "/tmp/$node.txt" ;
2010-04-12 14:44:14 +00:00
# Get MAC address in 'mac' table
my $ macId ;
2012-01-21 14:55:19 +00:00
my $ generateNew = 1 ;
2010-04-12 14:44:14 +00:00
@ propNames = ( 'mac' ) ;
$ propVals = xCAT::zvmUtils - > getNodeProps ( 'mac' , $ node , @ propNames ) ;
2012-01-21 14:55:19 +00:00
# If MAC address exists
2010-08-31 19:51:06 +00:00
if ( $ propVals - > { 'mac' } ) {
2010-04-12 14:44:14 +00:00
# Get MAC suffix (MACID)
$ macId = $ propVals - > { 'mac' } ;
$ macId = xCAT::zvmUtils - > replaceStr ( $ macId , ":" , "" ) ;
$ macId = substr ( $ macId , 6 ) ;
2012-01-21 14:55:19 +00:00
} else {
2012-02-03 05:23:03 +00:00
# Get zHCP MAC address
# The MAC address prefix is the same for all network devices
2012-01-21 14:55:19 +00:00
xCAT::zvmCPUtils - > loadVmcp ( $ hcp ) ;
$ out = `ssh -o ConnectTimeout=5 $hcp "vmcp q v nic" | grep "MAC:"` ;
if ( $ out ) {
@ lines = split ( "\n" , $ out ) ;
@ words = split ( " " , $ lines [ 0 ] ) ;
2010-04-12 14:44:14 +00:00
2012-01-21 14:55:19 +00:00
# Extract MAC prefix
my $ prefix = $ words [ 1 ] ;
$ prefix = xCAT::zvmUtils - > replaceStr ( $ prefix , "-" , "" ) ;
$ prefix = substr ( $ prefix , 0 , 6 ) ;
2010-04-12 14:44:14 +00:00
2012-01-21 14:55:19 +00:00
# Generate MAC address
my $ mac ;
while ( $ generateNew ) {
# If no MACID is found, get one
$ macId = xCAT::zvmUtils - > getMacID ( $ hcp ) ;
if ( ! $ macId ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Could not generate MACID" ) ;
return ;
}
# Create MAC address
$ mac = $ prefix . $ macId ;
# If length is less than 12, append a zero
if ( length ( $ mac ) != 12 ) {
$ mac = "0" . $ mac ;
}
# Format MAC address
$ mac =
substr ( $ mac , 0 , 2 ) . ":"
. substr ( $ mac , 2 , 2 ) . ":"
. substr ( $ mac , 4 , 2 ) . ":"
. substr ( $ mac , 6 , 2 ) . ":"
. substr ( $ mac , 8 , 2 ) . ":"
. substr ( $ mac , 10 , 2 ) ;
# Check 'mac' table for MAC address
my $ tab = xCAT::Table - > new ( 'mac' , - create = > 1 , - autocommit = > 0 ) ;
my @ entries = $ tab - > getAllAttribsWhere ( "mac = '" . $ mac . "'" , 'node' ) ;
# If MAC address exists
if ( @ entries ) {
# Generate new MACID
$ out = xCAT::zvmUtils - > generateMacId ( $ hcp ) ;
$ generateNew = 1 ;
} else {
$ generateNew = 0 ;
# Save MAC address in 'mac' table
xCAT::zvmUtils - > setNodeProp ( 'mac' , $ node , 'mac' , $ mac ) ;
}
} # End of while ($generateNew)
# Generate new MACID
$ out = xCAT::zvmUtils - > generateMacId ( $ hcp ) ;
} else {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Could not find the MAC address of the zHCP" ) ;
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Verify that the node's zHCP($hcp) is correct, the node is online, and the SSH keys are setup for the zHCP" ) ;
2012-01-21 14:55:19 +00:00
}
2010-04-12 14:44:14 +00:00
}
2012-02-03 05:23:03 +00:00
# If the directory entry contains a NICDEF statement, append MACID to the end
# User must select the right one (layer) based on template chosen
2012-01-21 13:53:46 +00:00
my $ line ;
2012-02-03 05:23:03 +00:00
$ out = `cat $userEntry | egrep -i "NICDEF"` ;
2010-06-15 21:09:35 +00:00
if ( $ out ) {
2012-02-03 05:23:03 +00:00
# Get the networks used by the zHCP
my @ hcpNets = xCAT::zvmCPUtils - > getNetworkNamesArray ( $ hcp ) ;
# Search user entry for network name
my $ netName = '' ;
foreach ( @ hcpNets ) {
if ( $ out =~ m/ $_/i ) {
$ netName = $ _ ;
last ;
}
}
2010-06-15 21:09:35 +00:00
# Find NICDEF statement
my $ oldNicDef = `cat $userEntry | egrep -i "NICDEF" | egrep -i "$netName"` ;
2012-02-03 05:23:03 +00:00
if ( $ oldNicDef ) {
$ oldNicDef = xCAT::zvmUtils - > trimStr ( $ oldNicDef ) ;
my $ nicDef = xCAT::zvmUtils - > replaceStr ( $ oldNicDef , $ netName , "$netName MACID $macId" ) ;
2010-06-15 21:09:35 +00:00
2012-02-03 05:23:03 +00:00
# Append MACID at the end
$ out = `sed --in-place -e "s,$oldNicDef,$nicDef,i" $userEntry` ;
}
2010-06-15 21:09:35 +00:00
}
2012-01-21 13:53:46 +00:00
# Open user entry
$ out = `cat $userEntry` ;
@ lines = split ( '\n' , $ out ) ;
# Get the userID in user entry
$ line = xCAT::zvmUtils - > trimStr ( $ lines [ 0 ] ) ;
@ words = split ( ' ' , $ line ) ;
my $ id = $ words [ 1 ] ;
# Change userID in user entry to match userID defined in xCAT
$ out = `sed --in-place -e "s,$id,$userId,i" $userEntry` ;
2010-06-15 21:09:35 +00:00
2012-02-03 05:23:03 +00:00
# SCP file over to zHCP
2010-04-12 14:44:14 +00:00
$ out = `scp $userEntry $target:$userEntry` ;
2012-01-21 13:53:46 +00:00
# Remove user entry
$ out = `rm $userEntry` ;
2010-04-12 14:44:14 +00:00
# Create virtual server
$ out = `ssh $hcp "$::DIR/createvs $userId $userEntry"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
# Check output
my $ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == 0 ) {
2012-02-03 05:23:03 +00:00
# Get VSwitch of zHCP (if any)
2010-06-17 19:15:56 +00:00
my @ vswId = xCAT::zvmCPUtils - > getVswitchId ( $ hcp ) ;
# Grant access to VSwitch for Linux user
# GuestLan do not need permissions
foreach ( @ vswId ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: Granting VSwitch ($_) access for $userId" ) ;
$ out = xCAT::zvmCPUtils - > grantVSwitch ( $ callback , $ hcp , $ userId , $ _ ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
}
2012-02-03 05:23:03 +00:00
# Remove user entry file (on zHCP)
2010-05-06 20:42:14 +00:00
$ out = `ssh -o ConnectTimeout=5 $hcp "rm $userEntry"` ;
2010-04-12 14:44:14 +00:00
}
}
else {
# Create NOLOG virtual server
$ out = `ssh $hcp "$::DIR/createvs $userId"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
}
return ;
}
#-------------------------------------------------------
= head3 cloneVM
Description : Clone a virtual server
Arguments : Node
Disk pool
Disk password
Returns : Nothing
Example : cloneVM ( $ callback , $ targetNode , $ args ) ;
= cut
#-------------------------------------------------------
sub cloneVM {
# Get inputs
my ( $ callback , $ nodes , $ args ) = @ _ ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get nodes
my @ nodes = @$ nodes ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Return code for each command
my $ rc ;
my $ out ;
# Child process IDs
my @ children ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Process ID for xfork()
my $ pid ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get source node
my $ sourceNode = $ args - > [ 0 ] ;
2010-06-15 21:09:35 +00:00
my @ propNames = ( 'hcp' , 'userid' ) ;
my $ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ sourceNode , @ propNames ) ;
2012-02-03 05:23:03 +00:00
# Get zHCP
2010-04-12 14:44:14 +00:00
my $ srcHcp = $ propVals - > { 'hcp' } ;
2010-06-15 21:09:35 +00:00
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-04-12 14:44:14 +00:00
my $ sourceId = $ propVals - > { 'userid' } ;
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ sourceId =~ tr /a-z/ A - Z / ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
foreach ( @ nodes ) {
xCAT::zvmUtils - > printLn ( $ callback , "$_: Cloning $sourceNode" ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Exit if missing source node
if ( ! $ sourceNode ) {
xCAT::zvmUtils - > printLn ( $ callback , "$_: (Error) Missing source node" ) ;
return ;
}
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Exit if missing source HCP
if ( ! $ srcHcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$_: (Error) Missing source node HCP" ) ;
return ;
}
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Exit if missing source user ID
if ( ! $ sourceId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$_: (Error) Missing source user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get target node
@ propNames = ( 'hcp' , 'userid' ) ;
$ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ _ , @ propNames ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get target HCP
my $ tgtHcp = $ propVals - > { 'hcp' } ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get node userID
my $ tgtId = $ propVals - > { 'userid' } ;
2012-01-21 12:54:05 +00:00
# Capitalize userID
$ tgtId =~ tr /a-z/ A - Z / ;
2010-06-15 21:09:35 +00:00
2012-02-03 05:23:03 +00:00
# Exit if missing target zHCP
2010-04-12 14:44:14 +00:00
if ( ! $ tgtHcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$_: (Error) Missing target node HCP" ) ;
return ;
}
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Exit if missing target user ID
if ( ! $ tgtId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$_: (Error) Missing target user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2010-06-15 21:09:35 +00:00
2012-02-03 05:23:03 +00:00
# Exit if source and target zHCP are not equal
2010-06-15 21:09:35 +00:00
if ( $ srcHcp ne $ tgtHcp ) {
2010-04-12 14:44:14 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$_: (Error) Source and target HCP are not equal" ) ;
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$_: (Solution) Set the source and target HCP appropriately in the zvm table" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
#*** Get MAC address ***
2010-04-12 14:44:14 +00:00
my $ targetMac ;
my $ macId ;
my $ generateNew = 0 ; # Flag to generate new MACID
@ propNames = ( 'mac' ) ;
$ propVals = xCAT::zvmUtils - > getNodeProps ( 'mac' , $ _ , @ propNames ) ;
2010-08-13 23:14:00 +00:00
if ( ! $ propVals - > { 'mac' } ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# If no MACID is found, get one
$ macId = xCAT::zvmUtils - > getMacID ( $ tgtHcp ) ;
if ( ! $ macId ) {
xCAT::zvmUtils - > printLn ( $ callback , "$_: (Error) Could not generate MACID" ) ;
return ;
}
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Create MAC address (target)
$ targetMac = xCAT::zvmUtils - > createMacAddr ( $ _ , $ macId ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Save MAC address in 'mac' table
xCAT::zvmUtils - > setNodeProp ( 'mac' , $ _ , 'mac' , $ targetMac ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Generate new MACID
$ out = xCAT::zvmUtils - > generateMacId ( $ tgtHcp ) ;
}
}
2010-07-07 15:12:44 +00:00
#*** Link source disks ***
2010-04-12 14:44:14 +00:00
# Get MDisk statements of source node
my @ words ;
my $ addr ;
2010-07-07 15:12:44 +00:00
my $ type ;
2010-04-12 14:44:14 +00:00
my $ srcMultiPw ;
my $ linkAddr ;
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# Load vmcp module
xCAT::zvmCPUtils - > loadVmcp ( $ sourceNode ) ;
2010-04-12 14:44:14 +00:00
# Hash table of source disk addresses
# $srcLinkAddr[$addr] = $linkAddr
my % srcLinkAddr ;
2010-07-07 15:12:44 +00:00
my % srcDiskSize ;
2010-08-31 19:51:06 +00:00
# Hash table of source disk type
# $srcLinkAddr[$addr] = $type
my % srcDiskType ;
2010-04-12 14:44:14 +00:00
my @ srcDisks = xCAT::zvmUtils - > getMdisks ( $ callback , $ sourceNode ) ;
foreach ( @ srcDisks ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get disk address
2010-06-15 21:09:35 +00:00
@ words = split ( ' ' , $ _ ) ;
$ addr = $ words [ 1 ] ;
2010-07-07 15:12:44 +00:00
$ type = $ words [ 2 ] ;
2010-04-12 14:44:14 +00:00
$ srcMultiPw = $ words [ 9 ] ;
2010-06-15 21:09:35 +00:00
2011-12-05 18:07:28 +00:00
# Add 0 in front if address length is less than 4
while ( length ( $ addr ) < 4 ) {
$ addr = '0' . $ addr ;
}
2010-08-31 19:51:06 +00:00
# Get disk type
$ srcDiskType { $ addr } = $ type ;
2010-07-07 15:12:44 +00:00
2010-08-31 19:51:06 +00:00
# Get disk size (cylinders or blocks)
# ECKD or FBA disk
if ( $ type eq '3390' || $ type eq '9336' ) {
$ out = `ssh -o ConnectTimeout=5 $sourceNode "vmcp q v dasd" | grep "DASD $addr"` ;
@ words = split ( ' ' , $ out ) ;
$ srcDiskSize { $ addr } = xCAT::zvmUtils - > trimStr ( $ words [ 5 ] ) ;
2010-07-07 15:12:44 +00:00
}
2010-04-12 14:44:14 +00:00
# If source disk is not linked
2012-02-03 05:23:03 +00:00
my $ try = 5 ;
2010-04-12 14:44:14 +00:00
while ( $ try > 0 ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# New disk address
$ linkAddr = $ addr + 1000 ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Check if new disk address is used (source)
$ rc = xCAT::zvmUtils - > isAddressUsed ( $ srcHcp , $ linkAddr ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# If disk address is used (source)
while ( $ rc == 0 ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Generate a new disk address
# Sleep 5 seconds to let existing disk appear
sleep ( 5 ) ;
$ linkAddr = $ linkAddr + 1 ;
$ rc = xCAT::zvmUtils - > isAddressUsed ( $ srcHcp , $ linkAddr ) ;
}
2010-06-15 21:09:35 +00:00
$ srcLinkAddr { $ addr } = $ linkAddr ;
2010-04-12 14:44:14 +00:00
# Link source disk to HCP
foreach ( @ nodes ) {
xCAT::zvmUtils - > printLn ( $ callback , "$_: Linking source disk ($addr) as ($linkAddr)" ) ;
}
$ out = `ssh -o ConnectTimeout=5 $srcHcp "vmcp link $sourceId $addr $linkAddr RR $srcMultiPw"` ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
if ( $ out =~ m/not linked/i ) {
# Do nothing
2012-02-03 05:23:03 +00:00
} else {
2010-06-15 21:09:35 +00:00
last ;
}
$ try = $ try - 1 ;
2010-04-12 14:44:14 +00:00
# Wait before next try
2010-06-15 21:09:35 +00:00
sleep ( 5 ) ;
} # End of while ( $try > 0 )
2010-04-12 14:44:14 +00:00
# If source disk is not linked
if ( $ out =~ m/not linked/i ) {
foreach ( @ nodes ) {
xCAT::zvmUtils - > printLn ( $ callback , "$_: Failed" ) ;
}
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Exit
return ;
}
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Enable source disk
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ srcHcp , "-e" , $ linkAddr ) ;
2010-06-15 21:09:35 +00:00
} # End of foreach (@srcDisks)
2012-02-03 05:23:03 +00:00
# Get the networks the HCP is on
my @ hcpNets = xCAT::zvmCPUtils - > getNetworkNamesArray ( $ srcHcp ) ;
2010-06-15 21:09:35 +00:00
# Get the NICDEF address of the network on the source node
my @ tmp ;
my $ i ;
2012-02-03 05:23:03 +00:00
my $ hcpNicAddr = '' ;
my $ hcpNetName = '' ;
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# Find the NIC address
2010-06-15 21:09:35 +00:00
xCAT::zvmCPUtils - > loadVmcp ( $ sourceNode ) ;
2010-07-07 15:12:44 +00:00
$ out = `ssh $sourceNode "vmcp q v nic"` ;
2012-02-03 05:23:03 +00:00
my @ lines = split ( '\n' , $ out ) ;
# Loop through each line
my $ line ;
2010-06-15 21:09:35 +00:00
for ( $ i = 0 ; $ i < @ lines ; $ i + + ) {
2012-02-03 05:23:03 +00:00
# Loop through each network name
foreach ( @ hcpNets ) {
# If the network is found
if ( $ lines [ $ i ] =~ m/ $_/i ) {
# Save network name
$ hcpNetName = $ _ ;
# Get NIC address
$ line = xCAT::zvmUtils - > trimStr ( $ lines [ $ i - 1 ] ) ;
@ words = split ( ' ' , $ line ) ;
@ tmp = split ( /\./ , $ words [ 1 ] ) ;
$ hcpNicAddr = $ tmp [ 0 ] ;
last ;
}
2010-06-15 21:09:35 +00:00
}
}
2012-02-03 05:23:03 +00:00
# If no network name is found, exit
if ( ! $ hcpNetName || ! $ hcpNicAddr ) {
2010-06-15 21:09:35 +00:00
foreach ( @ nodes ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$_: (Error) No suitable network device found in user directory entry" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$_: (Solution) Verify that the node has one of the following network devices: @hcpNets" ) ;
2010-06-15 21:09:35 +00:00
}
return ;
}
2010-07-07 15:12:44 +00:00
# Get VSwitch of source node (if any)
my @ srcVswitch = xCAT::zvmCPUtils - > getVswitchId ( $ sourceNode ) ;
# Get device address that is the root partition (/)
my $ srcRootPartAddr = xCAT::zvmUtils - > getRootDeviceAddr ( $ sourceNode ) ;
# Get source node OS
my $ srcOs = xCAT::zvmUtils - > getOs ( $ sourceNode ) ;
# Get source MAC address in 'mac' table
my $ srcMac ;
@ propNames = ( 'mac' ) ;
$ propVals = xCAT::zvmUtils - > getNodeProps ( 'mac' , $ sourceNode , @ propNames ) ;
2010-08-31 19:51:06 +00:00
if ( $ propVals - > { 'mac' } ) {
2010-07-07 15:12:44 +00:00
# Get MAC address
$ srcMac = $ propVals - > { 'mac' } ;
}
# Get network configuration file
# Location of this file depends on the OS
my $ srcIfcfg = xCAT::zvmUtils - > getIfcfgByNic ( $ sourceNode , "0.0." . $ hcpNicAddr ) ;
# Get source hardware configuration (SUSE only)
my $ srcHwcfg = '' ;
if ( $ srcOs =~ m/SUSE/i ) {
$ srcHwcfg = xCAT::zvmUtils - > getHwcfg ( $ sourceNode ) ;
}
2010-04-12 14:44:14 +00:00
# Get user entry of source node
my $ srcUserEntry = "/tmp/$sourceNode.txt" ;
$ out = `rm $srcUserEntry` ;
$ out = xCAT::zvmUtils - > getUserEntryWODisk ( $ callback , $ sourceNode , $ srcUserEntry ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Check if user entry is valid
$ out = `cat $srcUserEntry` ;
# If output contains USER LINUX123, then user entry is good
if ( $ out =~ m/USER $sourceId/i ) {
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# Turn off source node
2011-10-14 00:06:47 +00:00
$ out = `ssh -o ConnectTimeout=10 $sourceNode "shutdown -h now"` ;
sleep ( 90 ) ; # Wait 1.5 minutes before logging user off
2010-07-07 15:12:44 +00:00
$ out = `ssh $srcHcp "$::DIR/stopvs $sourceId"` ;
foreach ( @ nodes ) {
xCAT::zvmUtils - > printLn ( $ callback , "$_: $out" ) ;
}
#*** Clone source node ***
# Remove flashcopy lock (if any)
$ out = `ssh $srcHcp "rm -f /tmp/.flashcopy_lock"` ;
2010-04-12 14:44:14 +00:00
foreach ( @ nodes ) {
$ pid = xCAT::Utils - > xfork ( ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Parent process
if ( $ pid ) {
push ( @ children , $ pid ) ;
}
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Child process
elsif ( $ pid == 0 ) {
2010-07-07 15:12:44 +00:00
clone (
2010-08-31 19:51:06 +00:00
$ callback , $ _ , $ args , \ @ srcDisks , \ % srcLinkAddr , \ % srcDiskSize , \ % srcDiskType ,
$ hcpNicAddr , $ hcpNetName , \ @ srcVswitch , $ srcOs , $ srcMac , $ srcRootPartAddr , $ srcIfcfg ,
$ srcHwcfg
2010-07-07 15:12:44 +00:00
) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Exit process
exit ( 0 ) ;
2010-07-07 15:12:44 +00:00
}
# End of elsif
2010-04-12 14:44:14 +00:00
else {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Ran out of resources
die "Error: Could not fork\n" ;
}
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# Clone 4 nodes at a time
# If you handle more than this, some nodes will not be cloned
# You will get errors because SMAPI cannot handle many nodes
if ( ! ( @ children % 4 ) ) {
# Wait for all processes to end
foreach ( @ children ) {
waitpid ( $ _ , 0 ) ;
}
# Clear children
@ children = ( ) ;
}
2010-04-12 14:44:14 +00:00
} # End of foreach
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# Handle the remaining nodes
2010-04-12 14:44:14 +00:00
# Wait for all processes to end
foreach ( @ children ) {
waitpid ( $ _ , 0 ) ;
}
2010-06-15 21:09:35 +00:00
2010-05-06 20:42:14 +00:00
# Remove source user entry
$ out = `rm $srcUserEntry` ;
2010-07-07 15:12:44 +00:00
} # End of if
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
#*** Detatch source disks ***
2010-04-12 14:44:14 +00:00
for $ addr ( keys % srcLinkAddr ) {
2010-06-15 21:09:35 +00:00
$ linkAddr = $ srcLinkAddr { $ addr } ;
2010-07-07 15:12:44 +00:00
# Disable and detatch source disk
2010-04-12 14:44:14 +00:00
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ srcHcp , "-d" , $ linkAddr ) ;
$ out = `ssh -o ConnectTimeout=5 $srcHcp "vmcp det $linkAddr"` ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
foreach ( @ nodes ) {
xCAT::zvmUtils - > printLn ( $ callback , "$_: Detatching source disk ($addr) at ($linkAddr)" ) ;
2010-06-15 21:09:35 +00:00
}
2010-04-12 14:44:14 +00:00
}
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# Turn back on source node
$ out = `ssh $srcHcp "$::DIR/startvs $sourceId"` ;
foreach ( @ nodes ) {
xCAT::zvmUtils - > printLn ( $ callback , "$_: $out" ) ;
}
#*** Done ***
2010-04-12 14:44:14 +00:00
foreach ( @ nodes ) {
xCAT::zvmUtils - > printLn ( $ callback , "$_: Done" ) ;
}
return ;
}
#-------------------------------------------------------
= head3 clone
Description : Clone a virtual server
Arguments : Target node
Disk pool
Disk password ( optional )
Source disks
Source disk link addresses
2010-07-07 15:12:44 +00:00
Source disk sizes
2010-06-15 21:09:35 +00:00
NIC address
Network name
2010-07-07 15:12:44 +00:00
VSwitch names ( if any )
Operating system
MAC address
Root parition device address
Path to network configuration file
Path to hardware configuration file ( SUSE only )
2010-04-12 14:44:14 +00:00
Returns : Nothing
2010-07-07 15:12:44 +00:00
Example : clone ( $ callback , $ _ , $ args , \ @ srcDisks , \ % srcLinkAddr , \ % srcDiskSize ,
$ hcpNicAddr , $ hcpNetName , \ @ srcVswitch , $ srcOs , $ srcMac ,
$ srcRootPartAddr , $ srcIfcfg , $ srcHwcfg ) ;
2010-04-12 14:44:14 +00:00
= cut
#-------------------------------------------------------
sub clone {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get inputs
2010-07-07 15:12:44 +00:00
my (
2010-08-31 19:51:06 +00:00
$ callback , $ tgtNode , $ args , $ srcDisksRef , $ srcLinkAddrRef , $ srcDiskSizeRef , $ srcDiskTypeRef ,
$ hcpNicAddr , $ hcpNetName , $ srcVswitchRef , $ srcOs , $ srcMac , $ srcRootPartAddr , $ srcIfcfg , $ srcHwcfg
2010-07-07 15:12:44 +00:00
)
= @ _ ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get source node properties from 'zvm' table
my $ sourceNode = $ args - > [ 0 ] ;
2010-06-15 21:09:35 +00:00
my @ propNames = ( 'hcp' , 'userid' ) ;
my $ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ sourceNode , @ propNames ) ;
2012-02-03 05:23:03 +00:00
# Get zHCP
2010-04-12 14:44:14 +00:00
my $ srcHcp = $ propVals - > { 'hcp' } ;
2010-06-15 21:09:35 +00:00
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-04-12 14:44:14 +00:00
my $ sourceId = $ propVals - > { 'userid' } ;
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ sourceId =~ tr /a-z/ A - Z / ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get source disks
2010-06-15 21:09:35 +00:00
my @ srcDisks = @$ srcDisksRef ;
2010-04-12 14:44:14 +00:00
my % srcLinkAddr = %$ srcLinkAddrRef ;
2010-07-07 15:12:44 +00:00
my % srcDiskSize = %$ srcDiskSizeRef ;
2010-08-31 19:51:06 +00:00
my % srcDiskType = %$ srcDiskTypeRef ;
2010-07-07 15:12:44 +00:00
my @ srcVswitch = @$ srcVswitchRef ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Return code for each command
my $ rc ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get node properties from 'zvm' table
@ propNames = ( 'hcp' , 'userid' ) ;
$ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ tgtNode , @ propNames ) ;
2012-02-03 05:23:03 +00:00
# Get zHCP
2010-04-12 14:44:14 +00:00
my $ hcp = $ propVals - > { 'hcp' } ;
if ( ! $ hcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Missing node HCP" ) ;
return ;
}
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-07-07 15:12:44 +00:00
my $ tgtUserId = $ propVals - > { 'userid' } ;
if ( ! $ tgtUserId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Missing user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ tgtUserId =~ tr /a-z/ A - Z / ;
2010-04-12 14:44:14 +00:00
# Exit if source node HCP is not the same as target node HCP
if ( ! ( $ srcHcp eq $ hcp ) ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Source node HCP ($srcHcp) is not the same as target node HCP ($hcp)" ) ;
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Solution) Set the source and target HCP appropriately in the zvm table" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
# Get target IP from /etc/hosts
my $ targetIp = xCAT::zvmUtils - > getIp ( $ tgtNode ) ;
if ( ! $ targetIp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Missing IP for $tgtNode in /etc/hosts" ) ;
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Solution) Verify that the node's IP address is specified in the hosts table and then run makehosts" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
my $ out ;
my @ lines ;
my @ words ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get disk pool and multi password
my $ i ;
my % inputs ;
foreach $ i ( 1 .. 2 ) {
if ( $ args - > [ $ i ] ) {
# Split parameters by '='
@ words = split ( "=" , $ args - > [ $ i ] ) ;
# Create hash array
$ inputs { $ words [ 0 ] } = $ words [ 1 ] ;
}
}
# Get disk pool
my $ pool = $ inputs { "pool" } ;
if ( ! $ pool ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Missing disk pool. Please specify one." ) ;
2010-04-12 14:44:14 +00:00
return ;
}
# Get multi password
# It is Ok not have a password
my $ tgtPw = $ inputs { "pw" } ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Set IP address
my $ sourceIp = xCAT::zvmUtils - > getIp ( $ sourceNode ) ;
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# Save user directory entry as /tmp/hostname.txt, e.g. /tmp/gpok3.txt
2010-04-12 14:44:14 +00:00
# The source user entry is retrieved in cloneVM()
2010-06-15 21:09:35 +00:00
my $ userEntry = "/tmp/$tgtNode.txt" ;
2010-04-12 14:44:14 +00:00
my $ srcUserEntry = "/tmp/$sourceNode.txt" ;
# Remove existing user entry if any
$ out = `rm $userEntry` ;
$ out = `ssh -o ConnectTimeout=5 $hcp "rm $userEntry"` ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Copy user entry of source node
$ out = `cp $srcUserEntry $userEntry` ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Replace source userID with target userID
2012-01-03 20:55:48 +00:00
$ out = `sed --in-place -e "s,$sourceId,$tgtUserId,i" $userEntry` ;
2010-04-12 14:44:14 +00:00
# Get target MAC address in 'mac' table
my $ targetMac ;
2010-04-12 19:09:15 +00:00
my $ macId ;
2010-04-12 14:44:14 +00:00
my $ generateNew = 0 ; # Flag to generate new MACID
@ propNames = ( 'mac' ) ;
$ propVals = xCAT::zvmUtils - > getNodeProps ( 'mac' , $ tgtNode , @ propNames ) ;
if ( $ propVals ) {
# Get MACID
$ targetMac = $ propVals - > { 'mac' } ;
2010-04-12 19:09:15 +00:00
$ macId = $ propVals - > { 'mac' } ;
$ macId = xCAT::zvmUtils - > replaceStr ( $ macId , ":" , "" ) ;
$ macId = substr ( $ macId , 6 ) ;
2010-06-15 21:09:35 +00:00
}
else {
2010-04-12 19:09:15 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Missing target MAC address" ) ;
return ;
}
2010-06-15 21:09:35 +00:00
# If the user entry contains a NICDEF statement
$ out = `cat $userEntry | egrep -i "NICDEF"` ;
if ( $ out ) {
2012-02-03 05:23:03 +00:00
# Get the networks used by the zHCP
my @ hcpNets = xCAT::zvmCPUtils - > getNetworkNamesArray ( $ hcp ) ;
# Search user entry for network name
my $ hcpNetName = '' ;
foreach ( @ hcpNets ) {
if ( $ out =~ m/ $_/i ) {
$ hcpNetName = $ _ ;
last ;
}
}
2010-06-15 21:09:35 +00:00
# If the user entry contains a MACID
$ out = `cat $userEntry | egrep -i "MACID"` ;
if ( $ out ) {
my $ pos = rindex ( $ out , "MACID" ) ;
my $ oldMacId = substr ( $ out , $ pos + 6 , 12 ) ;
$ oldMacId = xCAT::zvmUtils - > trimStr ( $ oldMacId ) ;
2010-07-07 15:12:44 +00:00
# Replace old MACID
2012-01-03 20:55:48 +00:00
$ out = `sed --in-place -e "s,$oldMacId,$macId,i" $userEntry` ;
2012-02-03 05:23:03 +00:00
} else {
2010-06-15 21:09:35 +00:00
# Find NICDEF statement
2010-07-07 15:12:44 +00:00
my $ oldNicDef = `cat $userEntry | egrep -i "NICDEF" | egrep -i "$hcpNetName"` ;
2010-06-15 21:09:35 +00:00
$ oldNicDef = xCAT::zvmUtils - > trimStr ( $ oldNicDef ) ;
2010-07-07 15:12:44 +00:00
my $ nicDef = xCAT::zvmUtils - > replaceStr ( $ oldNicDef , $ hcpNetName , "$hcpNetName MACID $macId" ) ;
2010-06-15 21:09:35 +00:00
# Append MACID at the end
2012-01-03 20:55:48 +00:00
$ out = `sed --in-place -e "s,$oldNicDef,$nicDef,i" $userEntry` ;
2010-06-15 21:09:35 +00:00
}
}
2010-04-12 14:44:14 +00:00
# SCP user entry file over to HCP
xCAT::zvmUtils - > sendFile ( $ hcp , $ userEntry , $ userEntry ) ;
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
#*** Create new virtual server ***
2012-02-03 05:23:03 +00:00
my $ try = 5 ;
2010-06-15 21:09:35 +00:00
while ( $ try > 0 ) {
2012-02-03 05:23:03 +00:00
if ( $ try > 4 ) {
2010-04-12 14:44:14 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Creating user directory entry" ) ;
2010-06-15 21:09:35 +00:00
}
else {
2010-04-12 14:44:14 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Trying again ($try) to create user directory entry" ) ;
}
2010-07-07 15:12:44 +00:00
$ out = `ssh $hcp "$::DIR/createvs $tgtUserId $userEntry"` ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Check if user entry is created
2010-07-07 15:12:44 +00:00
$ out = `ssh $hcp "$::DIR/getuserentry $tgtUserId"` ;
2010-06-15 21:09:35 +00:00
$ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
2010-04-12 14:44:14 +00:00
# Wait before trying again
sleep ( 5 ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
$ try = $ try - 1 ;
2010-06-15 21:09:35 +00:00
}
else {
2010-04-12 14:44:14 +00:00
last ;
}
}
2010-06-15 21:09:35 +00:00
2010-05-06 20:42:14 +00:00
# Remove user entry
$ out = `rm $userEntry` ;
$ out = `ssh -o ConnectTimeout=5 $hcp "rm $userEntry"` ;
2010-04-12 14:44:14 +00:00
# Exit on bad output
if ( $ rc == - 1 ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Could not create user entry" ) ;
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Solution) Verify that the node's zHCP and its zVM's SMAPI are both online" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Load VMCP module on HCP and source node
xCAT::zvmCPUtils - > loadVmcp ( $ hcp ) ;
# Grant access to VSwitch for Linux user
# GuestLan do not need permissions
2010-07-07 15:12:44 +00:00
foreach ( @ srcVswitch ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Granting VSwitch ($_) access for $tgtUserId" ) ;
$ out = xCAT::zvmCPUtils - > grantVSwitch ( $ callback , $ hcp , $ tgtUserId , $ _ ) ;
2010-04-12 14:44:14 +00:00
# Check for errors
$ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
# Exit on bad output
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: $out" ) ;
return ;
}
} # End of foreach (@vswitchId)
2010-07-07 15:12:44 +00:00
#*** Add MDisk to target user entry ***
2010-04-12 14:44:14 +00:00
my $ addr ;
my @ tgtDisks ;
my $ type ;
my $ mode ;
my $ cyl ;
my $ srcMultiPw ;
foreach ( @ srcDisks ) {
# Get disk address
@ words = split ( ' ' , $ _ ) ;
$ addr = $ words [ 1 ] ;
push ( @ tgtDisks , $ addr ) ;
2010-06-15 21:09:35 +00:00
$ type = $ words [ 2 ] ;
2010-04-12 14:44:14 +00:00
$ mode = $ words [ 6 ] ;
$ srcMultiPw = $ words [ 9 ] ;
2011-12-05 18:07:28 +00:00
# Add 0 in front if address length is less than 4
while ( length ( $ addr ) < 4 ) {
$ addr = '0' . $ addr ;
}
2010-04-12 14:44:14 +00:00
# Add ECKD disk
if ( $ type eq '3390' ) {
# Get disk size (cylinders)
2010-07-07 15:12:44 +00:00
$ cyl = $ srcDiskSize { $ addr } ;
2010-04-12 14:44:14 +00:00
2012-02-03 05:23:03 +00:00
$ try = 5 ;
2010-04-12 14:44:14 +00:00
while ( $ try > 0 ) {
# Add ECKD disk
2012-02-03 05:23:03 +00:00
if ( $ try > 4 ) {
2010-04-12 14:44:14 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Adding minidisk ($addr)" ) ;
2010-06-15 21:09:35 +00:00
}
else {
2010-04-12 14:44:14 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Trying again ($try) to add minidisk ($addr)" ) ;
}
2010-07-07 15:12:44 +00:00
$ out = `ssh $hcp "$::DIR/add3390 $tgtUserId $pool $addr $cyl $mode $tgtPw $tgtPw $tgtPw"` ;
2010-04-12 14:44:14 +00:00
# Check output
$ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Wait before trying again
sleep ( 5 ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# One less try
2010-06-15 21:09:35 +00:00
$ try = $ try - 1 ;
2010-04-12 14:44:14 +00:00
}
else {
# If output is good, exit loop
last ;
}
} # End of while ( $try > 0 )
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Exit on bad output
if ( $ rc == - 1 ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Could not add minidisk ($addr)" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2010-06-15 21:09:35 +00:00
} # End of if ( $type eq '3390' )
2010-04-12 14:44:14 +00:00
# Add FBA disk
elsif ( $ type eq '9336' ) {
# Get disk size (blocks)
2010-08-31 19:51:06 +00:00
my $ blkSize = '512' ;
my $ blks = $ srcDiskSize { $ addr } ;
$ try = 10 ;
while ( $ try > 0 ) {
# Add FBA disk
if ( $ try > 9 ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Adding minidisk ($addr)" ) ;
}
else {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Trying again ($try) to add minidisk ($addr)" ) ;
}
$ out = `ssh $hcp "$::DIR/add9336 $tgtUserId $pool $addr $blkSize $blks $mode $tgtPw $tgtPw $tgtPw"` ;
# Check output
$ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
# Wait before trying again
sleep ( 5 ) ;
# One less try
$ try = $ try - 1 ;
}
else {
# If output is good, exit loop
last ;
}
} # End of while ( $try > 0 )
# Exit on bad output
if ( $ rc == - 1 ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Could not add minidisk ($addr)" ) ;
2010-08-31 19:51:06 +00:00
return ;
}
} # End of elsif ( $type eq '9336' )
2010-04-12 14:44:14 +00:00
}
2010-06-15 21:09:35 +00:00
# Check if the number of disks in target user entry
2010-04-12 14:44:14 +00:00
# is equal to the number of disks added
my @ disks ;
2010-06-15 21:09:35 +00:00
$ try = 10 ;
2010-04-12 14:44:14 +00:00
while ( $ try > 0 ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get disks within user entry
2010-07-07 15:12:44 +00:00
$ out = `ssh $hcp "$::DIR/getuserentry $tgtUserId" | grep "MDISK"` ;
2010-04-12 14:44:14 +00:00
@ disks = split ( '\n' , $ out ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Disks added (" . @ tgtDisks . "). Disks in user entry (" . @ disks . ")" ) ;
2010-06-15 21:09:35 +00:00
if ( @ disks != @ tgtDisks ) {
2010-04-12 14:44:14 +00:00
$ try = $ try - 1 ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Wait before trying again
sleep ( 5 ) ;
2010-06-15 21:09:35 +00:00
}
else {
2010-04-12 14:44:14 +00:00
last ;
2010-06-15 21:09:35 +00:00
}
2010-04-12 14:44:14 +00:00
}
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Exit if all disks are not present
2010-06-15 21:09:35 +00:00
if ( @ disks != @ tgtDisks ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Disks not present in user entry" ) ;
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Solution) Verify disk pool($pool) has free disks" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
#*** Link, format, and copy source disks ***
2010-04-12 14:44:14 +00:00
my $ srcAddr ;
my $ tgtAddr ;
my $ srcDevNode ;
my $ tgtDevNode ;
2010-08-31 19:51:06 +00:00
my $ tgtDiskType ;
2010-04-12 14:44:14 +00:00
foreach ( @ tgtDisks ) {
2010-07-07 15:12:44 +00:00
#*** Link target disk ***
2010-04-12 14:44:14 +00:00
$ try = 10 ;
while ( $ try > 0 ) {
2011-12-05 18:07:28 +00:00
# Add 0 in front if address length is less than 4
while ( length ( $ _ ) < 4 ) {
$ _ = '0' . $ _ ;
}
2010-04-12 14:44:14 +00:00
# New disk address
2010-06-15 21:09:35 +00:00
$ srcAddr = $ srcLinkAddr { $ _ } ;
2010-04-12 14:44:14 +00:00
$ tgtAddr = $ _ + 2000 ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Check if new disk address is used (target)
$ rc = xCAT::zvmUtils - > isAddressUsed ( $ hcp , $ tgtAddr ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# If disk address is used (target)
while ( $ rc == 0 ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Generate a new disk address
# Sleep 5 seconds to let existing disk appear
sleep ( 5 ) ;
$ tgtAddr = $ tgtAddr + 1 ;
$ rc = xCAT::zvmUtils - > isAddressUsed ( $ hcp , $ tgtAddr ) ;
}
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Link target disk
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Linking target disk ($_) as ($tgtAddr)" ) ;
2010-07-07 15:12:44 +00:00
$ out = `ssh -o ConnectTimeout=5 $hcp "vmcp link $tgtUserId $_ $tgtAddr MR $tgtPw"` ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# If link fails
if ( $ out =~ m/not linked/i ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Wait before trying again
sleep ( 5 ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
$ try = $ try - 1 ;
2010-06-15 21:09:35 +00:00
}
else {
2010-04-12 14:44:14 +00:00
last ;
}
2010-06-15 21:09:35 +00:00
} # End of while ( $try > 0 )
2010-04-12 14:44:14 +00:00
# If target disk is not linked
if ( $ out =~ m/not linked/i ) {
2010-07-07 15:12:44 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Failed to link target disk ($_)" ) ;
2010-04-12 14:44:14 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Failed" ) ;
# Exit
return ;
}
2010-08-31 19:51:06 +00:00
# Get disk type (3390 or 9336)
$ tgtDiskType = $ srcDiskType { $ _ } ;
2010-07-07 15:12:44 +00:00
#*** Use flashcopy ***
2010-08-31 19:51:06 +00:00
# Flashcopy only supports ECKD volumes
2011-12-05 18:07:28 +00:00
my $ ddCopy = 0 ;
2010-07-07 15:12:44 +00:00
$ out = `ssh $hcp "vmcp flashcopy"` ;
2010-08-31 19:51:06 +00:00
if ( ( $ out =~ m/HCPNFC026E/i ) && ( $ tgtDiskType eq '3390' ) ) {
2010-04-12 14:44:14 +00:00
2010-07-07 15:12:44 +00:00
# Flashcopy is supported
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Copying source disk ($srcAddr) to target disk ($tgtAddr) using FLASHCOPY" ) ;
# Check for flashcopy lock
my $ wait = 0 ;
while ( `ssh $hcp "ls /tmp/.flashcopy_lock"` && $ wait < 90 ) {
# Wait until the lock dissappears
# 90 seconds wait limit
sleep ( 2 ) ;
$ wait = $ wait + 2 ;
}
# If flashcopy locks still exists
if ( `ssh $hcp "ls /tmp/.flashcopy_lock"` ) {
# Detatch disks from HCP
$ out = `ssh $hcp "vmcp det $tgtAddr"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Flashcopy lock is enabled" ) ;
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Solution) Remove lock by deleting /tmp/.flashcopy_lock on the zHCP. Use caution!" ) ;
2010-07-07 15:12:44 +00:00
return ;
}
else {
# Enable lock
$ out = `ssh $hcp "touch /tmp/.flashcopy_lock"` ;
# Flashcopy source disk
$ out = xCAT::zvmCPUtils - > flashCopy ( $ hcp , $ srcAddr , $ tgtAddr ) ;
$ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: $out" ) ;
2011-12-05 18:07:28 +00:00
# Try Linux dd
$ ddCopy = 1 ;
2010-07-07 15:12:44 +00:00
}
# Wait a while for flashcopy to completely finish
sleep ( 10 ) ;
# Remove lock
$ out = `ssh $hcp "rm -f /tmp/.flashcopy_lock"` ;
}
2011-12-05 18:07:28 +00:00
} else {
$ ddCopy = 1 ;
2010-07-07 15:12:44 +00:00
}
2011-12-05 18:07:28 +00:00
# Flashcopy not supported, use Linux dd
if ( $ ddCopy ) {
2010-07-07 15:12:44 +00:00
#*** Use Linux dd to copy ***
2011-12-05 18:07:28 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: FLASHCOPY not working. Using Linux DD" ) ;
2010-04-12 14:44:14 +00:00
# Enable target disk
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-e" , $ tgtAddr ) ;
# Determine source device node
2010-08-31 19:51:06 +00:00
$ srcDevNode = xCAT::zvmUtils - > getDeviceNode ( $ hcp , $ srcAddr ) ;
2010-04-12 14:44:14 +00:00
# Determine target device node
2010-08-31 19:51:06 +00:00
$ tgtDevNode = xCAT::zvmUtils - > getDeviceNode ( $ hcp , $ tgtAddr ) ;
2010-04-12 14:44:14 +00:00
# Format target disk
2010-08-31 19:51:06 +00:00
# Only ECKD disks need to be formated
if ( $ tgtDiskType eq '3390' ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Formating target disk ($tgtAddr)" ) ;
$ out = `ssh $hcp "dasdfmt -b 4096 -y -f /dev/$tgtDevNode"` ;
2010-04-12 14:44:14 +00:00
2010-08-31 19:51:06 +00:00
# Check for errors
$ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: $out" ) ;
return ;
}
# Sleep 2 seconds to let the system settle
sleep ( 2 ) ;
# Copy source disk to target disk
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Copying source disk ($srcAddr) to target disk ($tgtAddr)" ) ;
$ out = `ssh $hcp "dd if=/dev/$srcDevNode of=/dev/$tgtDevNode bs=4096"` ;
} else {
# Copy source disk to target disk
# Block size = 512
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Copying source disk ($srcAddr) to target disk ($tgtAddr)" ) ;
$ out = `ssh $hcp "dd if=/dev/$srcDevNode of=/dev/$tgtDevNode bs=512"` ;
# Force Linux to re-read partition table
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Forcing Linux to re-read partition table" ) ;
$ out =
` ssh $ hcp " cat << EOM | fdisk /dev/ $ tgtDevNode
p
w
EOM " ` ;
2010-04-12 14:44:14 +00:00
}
2010-08-31 19:51:06 +00:00
2010-04-12 14:44:14 +00:00
# Check for error
$ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: $out" ) ;
return ;
}
# Sleep 2 seconds to let the system settle
sleep ( 2 ) ;
}
# Disable and enable target disk
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-d" , $ tgtAddr ) ;
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-e" , $ tgtAddr ) ;
# Determine target device node (it might have changed)
2010-08-31 19:51:06 +00:00
$ tgtDevNode = xCAT::zvmUtils - > getDeviceNode ( $ hcp , $ tgtAddr ) ;
2010-04-12 14:44:14 +00:00
# Get disk address that is the root partition (/)
2010-07-07 15:12:44 +00:00
if ( $ _ eq $ srcRootPartAddr ) {
2010-04-12 14:44:14 +00:00
# Mount target disk
2010-07-07 15:12:44 +00:00
my $ cloneMntPt = "/mnt/$tgtUserId" ;
2010-04-12 14:44:14 +00:00
$ tgtDevNode . = "1" ;
2010-07-07 15:12:44 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Mounting /dev/$tgtDevNode to $cloneMntPt" ) ;
# Check the disk is mounted
$ try = 10 ;
while ( ! ( `ssh $hcp "ls $cloneMntPt/etc/"` ) && $ try > 0 ) {
$ out = `ssh $hcp "mkdir -p $cloneMntPt"` ;
$ out = `ssh $hcp "mount /dev/$tgtDevNode $cloneMntPt"` ;
# Wait before trying again
sleep ( 10 ) ;
$ try = $ try - 1 ;
}
# If the disk is not mounted
if ( ! ( `ssh $hcp "ls $cloneMntPt/etc/"` ) ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Could not mount /dev/$tgtDevNode" ) ;
# Flush disk
$ out = `ssh $hcp "sync"` ;
# Unmount disk
$ out = `ssh $hcp "umount $cloneMntPt"` ;
# Remove mount point
$ out = `ssh $hcp "rm -rf $cloneMntPt"` ;
# Disable disks
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-d" , $ tgtAddr ) ;
# Detatch disks from HCP
$ out = `ssh $hcp "vmcp det $tgtAddr"` ;
return ;
}
#*** Set network configuration ***
2010-04-12 14:44:14 +00:00
# Set hostname
2010-07-07 15:12:44 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Setting network configuration" ) ;
2012-01-25 22:37:03 +00:00
$ out = `ssh $hcp sed --in-place -e "s/$sourceNode/$tgtNode/i" $cloneMntPt/etc/HOSTNAME` ;
2010-04-12 14:44:14 +00:00
2010-07-07 15:12:44 +00:00
# If Red Hat - Set hostname in /etc/sysconfig/network
if ( $ srcOs =~ m/Red Hat/i ) {
2012-01-25 22:37:03 +00:00
$ out = `ssh $hcp sed --in-place -e "s/$sourceNode/$tgtNode/i" $cloneMntPt/etc/sysconfig/network` ;
2010-04-12 14:44:14 +00:00
}
# Get network configuration file
# Location of this file depends on the OS
my $ ifcfgPath = $ cloneMntPt ;
2010-07-07 15:12:44 +00:00
$ ifcfgPath . = $ srcIfcfg ;
2012-01-25 22:37:03 +00:00
$ out = `ssh $hcp sed --in-place -e "s/$sourceNode/$tgtNode/i" \ -e "s/$sourceIp/$targetIp/i" $cloneMntPt/etc/hosts` ;
$ out = `ssh $hcp sed --in-place -e "s/$sourceIp/$targetIp/i" \ -e "s/$sourceNode/$tgtNode/i" $ifcfgPath` ;
2010-04-12 14:44:14 +00:00
2012-01-04 02:29:36 +00:00
# Get network layer
my $ layer = xCAT::zvmCPUtils - > getNetworkLayer ( $ hcp , $ hcpNetName ) ;
2010-04-12 14:44:14 +00:00
# Set MAC address
2010-05-06 20:42:14 +00:00
my $ networkFile = $ tgtNode . "NetworkConfig" ;
2010-07-07 15:12:44 +00:00
if ( $ srcOs =~ m/Red Hat/i ) {
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Red Hat only
$ out = `ssh $hcp "cat $ifcfgPath" | grep -v "MACADDR" > /tmp/$networkFile` ;
$ out = `echo "MACADDR='$targetMac'" >> /tmp/$networkFile` ;
2010-06-15 21:09:35 +00:00
}
else {
2010-07-07 15:12:44 +00:00
# SUSE only
2010-04-12 14:44:14 +00:00
$ out = `ssh $hcp "cat $ifcfgPath" | grep -v "LLADDR" | grep -v "UNIQUE" > /tmp/$networkFile` ;
2012-01-04 02:29:36 +00:00
# Set to MAC address (only for layer 2)
if ( $ layer == 2 ) {
$ out = `echo "LLADDR='$targetMac'" >> /tmp/$networkFile` ;
$ out = `echo "UNIQUE=''" >> /tmp/$networkFile` ;
}
2010-04-12 14:44:14 +00:00
}
xCAT::zvmUtils - > sendFile ( $ hcp , "/tmp/$networkFile" , $ ifcfgPath ) ;
2010-06-15 21:09:35 +00:00
2010-05-06 20:42:14 +00:00
# Remove network file from /tmp
$ out = `rm /tmp/$networkFile` ;
2010-04-12 14:44:14 +00:00
2012-01-04 02:29:36 +00:00
# Set to hardware configuration (only for layer 2)
2010-04-12 14:44:14 +00:00
if ( $ layer == 2 ) {
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
#*** Red Hat ***
if ( $ srcOs =~ m/Red Hat/i ) {
2010-04-12 14:44:14 +00:00
my $ srcMac ;
# Get source MAC address in 'mac' table
@ propNames = ( 'mac' ) ;
2010-06-15 21:09:35 +00:00
$ propVals = xCAT::zvmUtils - > getNodeProps ( 'mac' , $ sourceNode , @ propNames ) ;
2010-04-12 14:44:14 +00:00
if ( $ propVals ) {
# Get MAC address
$ srcMac = $ propVals - > { 'mac' } ;
}
else {
2010-07-07 15:12:44 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: (Error) Could not find MAC address of $sourceNode" ) ;
2010-04-12 14:44:14 +00:00
# Unmount disk
$ out = `ssh $hcp "umount $cloneMntPt"` ;
# Disable disks
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-d" , $ tgtAddr ) ;
# Detatch disks from HCP
$ out = `ssh $hcp "vmcp det $tgtAddr"` ;
return ;
}
# Set MAC address
2012-01-03 20:55:48 +00:00
$ out = `ssh $hcp sed --in-place -e "s/$srcMac/$targetMac/i" $ifcfgPath` ;
2010-04-12 14:44:14 +00:00
}
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
#*** SUSE ***
2010-04-12 14:44:14 +00:00
else {
# Get hardware configuration
my $ hwcfgPath = $ cloneMntPt ;
# Set layer 2 support
2010-07-07 15:12:44 +00:00
$ hwcfgPath . = $ srcHwcfg ;
2010-05-06 20:42:14 +00:00
my $ hardwareFile = $ tgtNode . "HardwareConfig" ;
2010-04-12 14:44:14 +00:00
$ out = `ssh $hcp "cat $hwcfgPath" | grep -v "QETH_LAYER2_SUPPORT" > /tmp/$hardwareFile` ;
$ out = `echo "QETH_LAYER2_SUPPORT='1'" >> /tmp/$hardwareFile` ;
xCAT::zvmUtils - > sendFile ( $ hcp , "/tmp/$hardwareFile" , $ hwcfgPath ) ;
2010-06-15 21:09:35 +00:00
2010-05-06 20:42:14 +00:00
# Remove hardware file from /tmp
$ out = `rm /tmp/$hardwareFile` ;
2010-04-12 14:44:14 +00:00
}
} # End of if ( $layer == 2 )
2010-09-16 18:57:44 +00:00
# Remove old SSH keys
$ out = `ssh $hcp "rm -f $cloneMntPt/etc/ssh/ssh_host_*"` ;
2010-04-12 14:44:14 +00:00
# Flush disk
$ out = `ssh $hcp "sync"` ;
# Unmount disk
$ out = `ssh $hcp "umount $cloneMntPt"` ;
2010-06-15 21:09:35 +00:00
# Remove mount point
$ out = `ssh $hcp "rm -rf $cloneMntPt"` ;
2010-04-12 14:44:14 +00:00
}
# Disable disks
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-d" , $ tgtAddr ) ;
# Detatch disks from HCP
$ out = `ssh $hcp "vmcp det $tgtAddr"` ;
sleep ( 5 ) ;
} # End of foreach (@tgtDisks)
2010-07-07 15:12:44 +00:00
# Update DHCP
$ out = `makedhcp -a` ;
2010-04-12 14:44:14 +00:00
# Power on target virtual server
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: Powering on" ) ;
2010-07-07 15:12:44 +00:00
$ out = `ssh $hcp "$::DIR/startvs $tgtUserId"` ;
2010-04-12 14:44:14 +00:00
# Check for error
$ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
xCAT::zvmUtils - > printLn ( $ callback , "$tgtNode: $out" ) ;
return ;
}
}
#-------------------------------------------------------
= head3 nodeSet
Description : Set the boot state for a node
2010-07-07 15:12:44 +00:00
* Punch initrd , kernel , and parmfile to node reader
* Layer 2 and 3 VSwitch / Lan supported
2010-04-12 14:44:14 +00:00
Arguments : Node
Returns : Nothing
Example : nodeSet ( $ callback , $ node , $ args ) ;
= cut
#-------------------------------------------------------
sub nodeSet {
# Get inputs
my ( $ callback , $ node , $ args ) = @ _ ;
# Get node properties from 'zvm' table
my @ propNames = ( 'hcp' , 'userid' ) ;
my $ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ node , @ propNames ) ;
2012-02-03 05:23:03 +00:00
# Get zHCP
2010-04-12 14:44:14 +00:00
my $ hcp = $ propVals - > { 'hcp' } ;
if ( ! $ hcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing node HCP" ) ;
return ;
}
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-04-12 14:44:14 +00:00
my $ userId = $ propVals - > { 'userid' } ;
if ( ! $ userId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ userId =~ tr /a-z/ A - Z / ;
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Get install directory and domain from site table
my $ siteTab = xCAT::Table - > new ( 'site' ) ;
my $ installDirHash = $ siteTab - > getAttribs ( { key = > "installdir" } , 'value' ) ;
my $ installDir = $ installDirHash - > { 'value' } ;
my $ domainHash = $ siteTab - > getAttribs ( { key = > "domain" } , 'value' ) ;
my $ domain = $ domainHash - > { 'value' } ;
my $ masterHash = $ siteTab - > getAttribs ( { key = > "master" } , 'value' ) ;
my $ master = $ masterHash - > { 'value' } ;
my $ xcatdPortHash = $ siteTab - > getAttribs ( { key = > "xcatdport" } , 'value' ) ;
my $ xcatdPort = $ xcatdPortHash - > { 'value' } ;
# Get node OS, arch, and profile from 'nodetype' table
@ propNames = ( 'os' , 'arch' , 'profile' ) ;
$ propVals = xCAT::zvmUtils - > getNodeProps ( 'nodetype' , $ node , @ propNames ) ;
my $ os = $ propVals - > { 'os' } ;
my $ arch = $ propVals - > { 'arch' } ;
2010-04-12 14:44:14 +00:00
my $ profile = $ propVals - > { 'profile' } ;
2010-06-15 21:09:35 +00:00
# If no OS, arch, or profile is found
if ( ! $ os || ! $ arch || ! $ profile ) {
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Exit
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing node OS, arch, and profile in nodetype table" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2010-06-15 21:09:35 +00:00
# Get action
my $ action = $ args - > [ 0 ] ;
my $ out ;
if ( $ action eq "install" ) {
# Get node root password
@ propNames = ( 'password' ) ;
$ propVals = xCAT::zvmUtils - > getTabPropsByKey ( 'passwd' , 'key' , 'system' , @ propNames ) ;
my $ passwd = $ propVals - > { 'password' } ;
if ( ! $ passwd ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing root password for this node" ) ;
return ;
}
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Get node OS base
2010-08-17 20:57:18 +00:00
my @ tmp ;
if ( $ os =~ m/sp/i ) {
@ tmp = split ( /sp/ , $ os ) ;
} else {
@ tmp = split ( /\./ , $ os ) ;
}
2010-06-15 21:09:35 +00:00
my $ osBase = $ tmp [ 0 ] ;
2012-02-17 16:14:34 +00:00
# Get node distro
my $ distro = "" ;
if ( $ os =~ m/sles/i ) {
$ distro = "sles" ;
} elsif ( $ os =~ m/rhel/i ) {
$ distro = "rh" ;
} else {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Unable to determine node Linux distribution" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Verify the node Linux distribution is either sles* or rh*" ) ;
return ;
}
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Get autoyast/kickstart template
2012-02-17 16:14:34 +00:00
my $ tmpl ;
# Check for $profile.$os.$arch.tmpl
if ( - e "$installDir/custom/install/$distro/$profile.$os.$arch.tmpl" ) {
$ tmpl = "$profile.$os.$arch.tmpl" ;
}
# Check for $profile.$osBase.$arch.tmpl
elsif ( - e "$installDir/custom/install/$distro/$profile.$osBase.$arch.tmpl" ) {
$ tmpl = "$profile.$osBase.$arch.tmpl" ;
}
# Check for $profile.$arch.tmpl
elsif ( - e "$installDir/custom/install/$distro/$profile.$arch.tmpl" ) {
$ tmpl = "$profile.$arch.tmpl" ;
}
# Check for $profile.tmpl second
elsif ( - e "$installDir/custom/install/$distro/$profile.tmpl" ) {
$ tmpl = "$profile.tmpl" ;
}
else {
# No template exists
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing autoyast/kickstart template" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Create a template under $installDir/custom/install/$distro/" ) ;
return ;
}
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Get host IP and hostname from /etc/hosts
2010-08-03 19:15:43 +00:00
$ out = `cat /etc/hosts | grep "$node "` ;
2010-06-15 21:09:35 +00:00
my @ words = split ( ' ' , $ out ) ;
my $ hostIP = $ words [ 0 ] ;
my $ hostname = $ words [ 2 ] ;
if ( ! $ hostIP || ! $ hostname ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing IP for $node in /etc/hosts" ) ;
2012-02-17 16:14:34 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Verify that the nodes IP address is specified in the hosts table and then run makehosts" ) ;
2010-06-15 21:09:35 +00:00
return ;
2010-04-12 14:44:14 +00:00
}
2012-02-03 05:23:03 +00:00
# Check template if DHCP is used
my $ dhcp = 0 ;
2012-02-17 16:14:34 +00:00
if ( $ distro eq "sles" ) {
# Check autoyast template
if ( - e "$installDir/custom/install/sles/$tmpl" ) {
$ out = `cat $installDir/custom/install/sles/$tmpl | egrep -i "<bootproto>"` ;
if ( $ out =~ m/dhcp/i ) {
$ dhcp = 1 ;
}
}
} elsif ( $ distro eq "rh" ) {
# Check kickstart template
if ( - e "$installDir/custom/install/rh/$tmpl" ) {
2012-02-28 18:56:10 +00:00
$ out = `cat $installDir/custom/install/rh/$tmpl | egrep -ie "--bootproto dhcp"` ;
2012-02-17 16:14:34 +00:00
if ( $ out =~ m/dhcp/i ) {
$ dhcp = 1 ;
}
2012-02-03 05:23:03 +00:00
}
}
# Get the networks used by the zHCP
my @ hcpNets = xCAT::zvmCPUtils - > getNetworkNamesArray ( $ hcp ) ;
my $ hcpNetName = '' ;
my $ channel ;
my $ layer ;
my $ i ;
# Search directory entry for network name
2010-06-15 21:09:35 +00:00
my $ userEntry = `ssh $hcp "$::DIR/getuserentry $userId"` ;
2012-02-03 05:23:03 +00:00
$ out = `echo "$userEntry" | grep "NICDEF"` ;
my @ lines = split ( '\n' , $ out ) ;
# Go through each line
for ( $ i = 0 ; $ i < @ lines ; $ i + + ) {
# Go through each network device attached to zHCP
foreach ( @ hcpNets ) {
# If network device is found
if ( $ lines [ $ i ] =~ m/ $_/i ) {
# Get network layer
$ layer = xCAT::zvmCPUtils - > getNetworkLayer ( $ hcp , $ _ ) ;
# If template using DHCP, layer must be 2
2012-02-03 19:17:59 +00:00
if ( ( ! $ dhcp && $ layer != 2 ) || ( ! $ dhcp && $ layer == 2 ) || ( $ dhcp && $ layer == 2 ) ) {
2012-02-03 05:23:03 +00:00
# Save network name
$ hcpNetName = $ _ ;
# Get network virtual address
@ words = split ( ' ' , $ lines [ $ i ] ) ;
# Get virtual address (channel)
# Convert subchannel to decimal
$ channel = sprintf ( '%d' , hex ( $ words [ 1 ] ) ) ;
last ;
} else {
# Go to next network available
$ hcpNetName = ''
}
}
}
}
# If network device is not found
if ( ! $ hcpNetName ) {
2010-10-28 20:46:47 +00:00
# Check for user profile
2010-11-23 16:42:37 +00:00
my $ profileName = `echo "$userEntry" | grep "INCLUDE"` ;
if ( $ profileName ) {
@ words = split ( ' ' , xCAT::zvmUtils - > trimStr ( $ profileName ) ) ;
# Get user profile
my $ userProfile = xCAT::zvmUtils - > getUserProfile ( $ hcp , $ words [ 1 ] ) ;
2012-02-03 05:23:03 +00:00
2010-11-23 16:42:37 +00:00
# Get the NICDEF statement containing the HCP network
2012-02-03 05:23:03 +00:00
$ out = `echo "$userProfile" | grep "NICDEF"` ;
@ lines = split ( '\n' , $ out ) ;
# Go through each line
for ( $ i = 0 ; $ i < @ lines ; $ i + + ) {
# Go through each network device attached to zHCP
foreach ( @ hcpNets ) {
# If network device is found
if ( $ lines [ $ i ] =~ m/ $_/i ) {
# Get network layer
2012-02-28 17:51:51 +00:00
$ layer = xCAT::zvmCPUtils - > getNetworkLayer ( $ hcp , $ _ ) ;
2012-02-03 05:23:03 +00:00
# If template using DHCP, layer must be 2
2012-02-03 19:17:59 +00:00
if ( ( ! $ dhcp && $ layer != 2 ) || ( ! $ dhcp && $ layer == 2 ) || ( $ dhcp && $ layer == 2 ) ) {
2012-02-03 05:23:03 +00:00
# Save network name
$ hcpNetName = $ _ ;
# Get network virtual address
@ words = split ( ' ' , $ lines [ $ i ] ) ;
# Get virtual address (channel)
# Convert subchannel to decimal
$ channel = sprintf ( '%d' , hex ( $ words [ 1 ] ) ) ;
last ;
} else {
# Go to next network available
2012-02-28 18:56:10 +00:00
$ hcpNetName = '' ;
2012-02-03 05:23:03 +00:00
}
}
} # End of foreach
} # End of for
} # End of if
2010-06-15 21:09:35 +00:00
}
2012-02-03 05:23:03 +00:00
# Exit if no suitable network found
if ( ! $ hcpNetName ) {
if ( $ dhcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) The template selected uses DHCP. A layer 2 VSWITCH or GLAN is required. None were found." ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Modify the template to use <bootproto>static</bootproto> or change the network device attached to virtual machine" ) ;
} else {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) No suitable network device found in user directory entry" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Verify that the node has one of the following network devices: @hcpNets" ) ;
}
2010-04-12 14:44:14 +00:00
return ;
}
2012-02-03 05:23:03 +00:00
2012-02-28 18:56:10 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: Setting up networking on $hcpNetName (layer:$layer | DHCP:$dhcp)" ) ;
2012-02-28 17:51:51 +00:00
2012-02-03 05:23:03 +00:00
# Generate read, write, and data channels
my $ readChannel = "0.0." . ( sprintf ( '%X' , $ channel + 0 ) ) ;
2010-06-15 21:09:35 +00:00
if ( length ( $ readChannel ) < 8 ) {
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Prepend a zero
2010-10-28 20:46:47 +00:00
$ readChannel = "0.0.0" . ( sprintf ( '%X' , $ channel + 0 ) ) ;
2010-06-15 21:09:35 +00:00
}
2010-04-12 14:44:14 +00:00
2012-02-03 05:23:03 +00:00
my $ writeChannel = "0.0." . ( sprintf ( '%X' , $ channel + 1 ) ) ;
2010-06-15 21:09:35 +00:00
if ( length ( $ writeChannel ) < 8 ) {
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Prepend a zero
2010-10-28 20:46:47 +00:00
$ writeChannel = "0.0.0" . ( sprintf ( '%X' , $ channel + 1 ) ) ;
2010-06-15 21:09:35 +00:00
}
2010-04-12 14:44:14 +00:00
2012-02-03 05:23:03 +00:00
my $ dataChannel = "0.0." . ( sprintf ( '%X' , $ channel + 2 ) ) ;
2010-06-15 21:09:35 +00:00
if ( length ( $ dataChannel ) < 8 ) {
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Prepend a zero
2010-10-28 20:46:47 +00:00
$ dataChannel = "0.0.0" . ( sprintf ( '%X' , $ channel + 2 ) ) ;
2010-04-12 14:44:14 +00:00
}
2010-06-15 21:09:35 +00:00
2010-07-07 15:12:44 +00:00
# Get MAC address (Only for layer 2)
2010-06-15 21:09:35 +00:00
my $ mac = "" ;
my @ propNames ;
my $ propVals ;
if ( $ layer == 2 ) {
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Search 'mac' table for node
@ propNames = ( 'mac' ) ;
$ propVals = xCAT::zvmUtils - > getTabPropsByKey ( 'mac' , 'node' , $ node , @ propNames ) ;
$ mac = $ propVals - > { 'mac' } ;
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# If no MAC address is found, exit
# MAC address should have been assigned to the node upon creation
if ( ! $ mac ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing MAC address of node" ) ;
return ;
}
}
2011-01-27 21:44:56 +00:00
2010-06-15 21:09:35 +00:00
# Get networks in 'networks' table
my $ entries = xCAT::zvmUtils - > getAllTabEntries ( 'networks' ) ;
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Go through each network
2011-12-09 19:29:33 +00:00
my $ network = "" ;
my $ mask ;
2010-06-15 21:09:35 +00:00
foreach ( @$ entries ) {
2010-04-12 14:44:14 +00:00
2011-12-09 19:29:33 +00:00
# Get network and mask
2010-06-15 21:09:35 +00:00
$ network = $ _ - > { 'net' } ;
2011-12-09 19:29:33 +00:00
$ mask = $ _ - > { 'mask' } ;
# If the host IP address is in this subnet, return
if ( xCAT::NetworkUtils - > ishostinsubnet ( $ hostIP , $ mask , $ network ) ) {
2010-06-15 21:09:35 +00:00
# Exit loop
last ;
}
else {
$ network = "" ;
}
2010-04-12 14:44:14 +00:00
}
2011-12-09 19:29:33 +00:00
2010-06-15 21:09:35 +00:00
# If no network found
if ( ! $ network ) {
# Exit
2010-07-07 15:12:44 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Node does not belong to any network in the networks table" ) ;
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Specify the subnet in the networks table. The mask, gateway, tftpserver, and nameservers must be specified for the subnet." ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2010-08-31 19:51:06 +00:00
2010-06-15 21:09:35 +00:00
@ propNames = ( 'mask' , 'gateway' , 'tftpserver' , 'nameservers' ) ;
$ propVals = xCAT::zvmUtils - > getTabPropsByKey ( 'networks' , 'net' , $ network , @ propNames ) ;
my $ mask = $ propVals - > { 'mask' } ;
my $ gateway = $ propVals - > { 'gateway' } ;
my $ ftp = $ propVals - > { 'tftpserver' } ;
2011-05-10 08:36:19 +00:00
2011-05-17 19:57:04 +00:00
# Convert <xcatmaster> to nameserver IP
2011-05-10 08:36:19 +00:00
my $ nameserver ;
2011-05-17 19:57:04 +00:00
if ( $ propVals - > { 'nameservers' } eq '<xcatmaster>' ) {
2011-05-10 08:36:19 +00:00
$ nameserver = xCAT::InstUtils - > convert_xcatmaster ( ) ;
2011-05-17 19:57:04 +00:00
} else {
2011-05-10 08:36:19 +00:00
$ nameserver = $ propVals - > { 'nameservers' } ;
}
2010-06-15 21:09:35 +00:00
if ( ! $ network || ! $ mask || ! $ ftp || ! $ nameserver ) {
# It is acceptable to not have a gateway
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing network information" ) ;
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Specify the mask, gateway, tftpserver, and nameservers for the subnet in the networks table" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2010-08-31 19:51:06 +00:00
2010-06-15 21:09:35 +00:00
# Get broadcast address of NIC
my $ ifcfg = xCAT::zvmUtils - > getIfcfgByNic ( $ hcp , $ readChannel ) ;
2010-06-17 19:15:56 +00:00
$ out = `ssh $hcp "cat $ifcfg" | grep "BROADCAST"` ;
2010-06-15 21:09:35 +00:00
@ words = split ( '=' , $ out ) ;
my $ broadcast = $ words [ 1 ] ;
$ broadcast = xCAT::zvmUtils - > trimStr ( $ broadcast ) ;
2010-06-17 19:15:56 +00:00
$ broadcast =~ s ; " | ' ; ; g ;
2010-06-15 21:09:35 +00:00
# Load VMCP module on HCP
xCAT::zvmCPUtils - > loadVmcp ( $ hcp ) ;
2010-07-07 15:12:44 +00:00
# Sample paramter file exists in installation CD (Use that as a guide)
2010-06-15 21:09:35 +00:00
my $ sampleParm ;
my $ parmHeader ;
my $ parms ;
my $ parmFile ;
my $ kernelFile ;
my $ initFile ;
2010-07-07 15:12:44 +00:00
# If punch is successful - Look for this string
2010-06-15 21:09:35 +00:00
my $ searchStr = "created and transferred" ;
2010-07-07 15:12:44 +00:00
# Default parameters - SUSE
2010-06-15 21:09:35 +00:00
my $ instNetDev = "osa" ; # Only OSA interface type is supported
my $ osaInterface = "qdio" ; # OSA interface = qdio or lcs
my $ osaMedium = "eth" ; # OSA medium = eth (ethernet) or tr (token ring)
2010-07-07 15:12:44 +00:00
# Default parameters - RHEL
2010-06-15 21:09:35 +00:00
my $ netType = "qeth" ;
my $ portName = "FOOBAR" ;
my $ portNo = "0" ;
2010-08-23 15:41:08 +00:00
# Get postscript content
my $ postScript ;
if ( $ os =~ m/sles10/i ) {
$ postScript = "/opt/xcat/share/xcat/install/scripts/post.sles10.s390x" ;
} elsif ( $ os =~ m/sles11/i ) {
$ postScript = "/opt/xcat/share/xcat/install/scripts/post.sles11.s390x" ;
} elsif ( $ os =~ m/rhel5/i ) {
$ postScript = "/opt/xcat/share/xcat/install/scripts/post.rhel5.s390x" ;
2010-12-20 17:48:56 +00:00
} elsif ( $ os =~ m/rhel6/i ) {
$ postScript = "/opt/xcat/share/xcat/install/scripts/post.rhel6.s390x" ;
2010-08-23 15:41:08 +00:00
} else {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) No postscript available for $os" ) ;
return ;
}
2010-08-31 19:51:06 +00:00
2010-06-15 21:09:35 +00:00
# SUSE installation
my $ customTmpl ;
2011-10-07 20:09:59 +00:00
my $ pkglist ;
my $ patterns = '' ;
my $ packages = '' ;
2010-06-15 21:09:35 +00:00
if ( $ os =~ m/sles/i ) {
# Create directory in FTP root (/install) to hold template
$ out = `mkdir -p $installDir/custom/install/sles` ;
# Copy autoyast template
2010-10-27 19:27:38 +00:00
$ customTmpl = "$installDir/custom/install/sles/" . $ node . "." . $ profile . ".tmpl" ;
2010-07-07 15:12:44 +00:00
if ( - e "$installDir/custom/install/sles/$tmpl" ) {
$ out = `cp $installDir/custom/install/sles/$tmpl $customTmpl` ;
2010-06-15 21:09:35 +00:00
}
else {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) An autoyast template does not exist for $os in $installDir/custom/install/sles/. Please create one." ) ;
2010-07-07 15:12:44 +00:00
return ;
2010-06-15 21:09:35 +00:00
}
2011-10-07 20:09:59 +00:00
# Get pkglist from /install/custom/install/sles/compute.sles11.s390x.otherpkgs.pkglist
# Original one is in /opt/xcat/share/xcat/install/sles/compute.sles11.s390x.otherpkgs.pkglist
$ pkglist = "/install/custom/install/sles/" . $ profile . "." . $ osBase . "." . $ arch . ".pkglist" ;
if ( ! ( - e $ pkglist ) ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing package list for $os in /install/custom/install/sles/" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Please create one or copy default one from /opt/xcat/share/xcat/install/sles/" ) ;
2011-10-07 20:09:59 +00:00
return ;
}
# Read in each software pattern or package
open ( FILE , $ pkglist ) ;
while ( <FILE> ) {
chomp ;
# Create <xml> tags, e.g.
# <package>apache</package>
# <pattern>directory_server</pattern>
$ _ = xCAT::zvmUtils - > trimStr ( $ _ ) ;
if ( $ _ && $ _ =~ /@/ ) {
$ _ =~ s/@//g ;
$ patterns . = "<pattern>$_</pattern>" ;
} elsif ( $ _ ) {
$ packages . = "<package>$_</package>" ;
}
}
close ( FILE ) ;
# Add appropriate software packages or patterns
$ out = `sed --in-place -e "s,replace_software_packages,$packages,g" \ -e "s,replace_software_patterns,$patterns,g" $customTmpl` ;
2010-08-23 15:41:08 +00:00
# Copy postscript into template
$ out = `sed --in-place -e "/<scripts>/r $postScript" $customTmpl` ;
2010-08-31 19:51:06 +00:00
2010-06-15 21:09:35 +00:00
# Edit template
my $ device ;
my $ chanIds = "$readChannel $writeChannel $dataChannel" ;
# SLES 11
if ( $ os =~ m/sles11/i ) {
$ device = "eth0" ;
2011-10-07 20:09:59 +00:00
} else {
2010-06-15 21:09:35 +00:00
# SLES 10
$ device = "qeth-bus-ccw-$readChannel" ;
}
$ out =
2010-08-23 20:41:41 +00:00
`sed --in-place -e "s,replace_host_address,$hostIP,g" \ -e "s,replace_long_name,$hostname,g" \ -e "s,replace_short_name,$node,g" \ -e "s,replace_domain,$domain,g" \ -e "s,replace_hostname,$node,g" \ -e "s,replace_nameserver,$nameserver,g" \ -e "s,replace_broadcast,$broadcast,g" \ -e "s,replace_device,$device,g" \ -e "s,replace_ipaddr,$hostIP,g" \ -e "s,replace_lladdr,$mac,g" \ -e "s,replace_netmask,$mask,g" \ -e "s,replace_network,$network,g" \ -e "s,replace_ccw_chan_ids,$chanIds,g" \ -e "s,replace_ccw_chan_mode,FOOBAR,g" \ -e "s,replace_gateway,$gateway,g" \ -e "s,replace_root_password,$passwd,g" \ -e "s,replace_nic_addr,$readChannel,g" \ -e "s,replace_master,$master,g" \ -e "s,replace_install_dir,$installDir,g" $customTmpl` ;
2010-06-15 21:09:35 +00:00
# Read sample parmfile in /install/sles10.2/s390x/1/boot/s390x/
$ sampleParm = "$installDir/$os/s390x/1/boot/s390x/parmfile" ;
open ( SAMPLEPARM , "<$sampleParm" ) ;
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Search parmfile for -- ramdisk_size=65536 root=/dev/ram1 ro init=/linuxrc TERM=dumb
while ( <SAMPLEPARM> ) {
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# If the line contains 'ramdisk_size'
if ( $ _ =~ m/ramdisk_size/i ) {
$ parmHeader = xCAT::zvmUtils - > trimStr ( $ _ ) ;
}
}
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Close sample parmfile
close ( SAMPLEPARM ) ;
# Create parmfile -- Limited to 10 lines
# End result should be:
# ramdisk_size=65536 root=/dev/ram1 ro init=/linuxrc TERM=dumb
# HostIP=10.0.0.5 Hostname=gpok5.endicott.ibm.com
# Gateway=10.0.0.1 Netmask=255.255.255.0
# Broadcast=10.0.0.0 Layer2=1 OSAHWaddr=02:00:01:FF:FF:FF
# ReadChannel=0.0.0800 WriteChannel=0.0.0801 DataChannel=0.0.0802
2010-12-17 18:11:05 +00:00
# Nameserver=10.0.0.1 Portname=OSAPORT Portno=0
2010-06-15 21:09:35 +00:00
# Install=ftp://10.0.0.1/sles10.2/s390x/1/
# UseVNC=1 VNCPassword=12345678
# InstNetDev=osa OsaInterface=qdio OsaMedium=eth Manual=0
2010-10-27 19:27:38 +00:00
my $ ay = "ftp://$ftp/custom/install/sles/" . $ node . "." . $ profile . ".tmpl" ;
2010-06-15 21:09:35 +00:00
$ parms = $ parmHeader . "\n" ;
$ parms = $ parms . "AutoYaST=$ay\n" ;
$ parms = $ parms . "HostIP=$hostIP Hostname=$hostname\n" ;
$ parms = $ parms . "Gateway=$gateway Netmask=$mask\n" ;
# Set layer in autoyast profile
if ( $ layer == 2 ) {
2011-02-01 17:39:51 +00:00
$ parms = $ parms . "Broadcast=$broadcast Layer2=1 OSAHWaddr=$mac\n" ;
2010-06-15 21:09:35 +00:00
}
else {
2011-02-01 17:39:51 +00:00
$ parms = $ parms . "Broadcast=$broadcast Layer2=0\n" ;
2010-06-15 21:09:35 +00:00
}
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
$ parms = $ parms . "ReadChannel=$readChannel WriteChannel=$writeChannel DataChannel=$dataChannel\n" ;
$ parms = $ parms . "Nameserver=$nameserver Portname=$portName Portno=0\n" ;
$ parms = $ parms . "Install=ftp://$ftp/$os/s390x/1/\n" ;
$ parms = $ parms . "UseVNC=1 VNCPassword=12345678\n" ;
$ parms = $ parms . "InstNetDev=$instNetDev OsaInterface=$osaInterface OsaMedium=$osaMedium Manual=0\n" ;
2010-08-31 19:51:06 +00:00
2010-06-15 21:09:35 +00:00
# Write to parmfile
$ parmFile = "/tmp/" . $ node . "Parm" ;
open ( PARMFILE , ">$parmFile" ) ;
print PARMFILE "$parms" ;
close ( PARMFILE ) ;
# Send kernel, parmfile, and initrd to reader to HCP
$ kernelFile = "/tmp/" . $ node . "Kernel" ;
$ initFile = "/tmp/" . $ node . "Initrd" ;
$ out = `cp $installDir/$os/s390x/1/boot/s390x/vmrdr.ikr $kernelFile` ;
$ out = `cp $installDir/$os/s390x/1/boot/s390x/initrd $initFile` ;
xCAT::zvmUtils - > sendFile ( $ hcp , $ kernelFile , $ kernelFile ) ;
xCAT::zvmUtils - > sendFile ( $ hcp , $ parmFile , $ parmFile ) ;
xCAT::zvmUtils - > sendFile ( $ hcp , $ initFile , $ initFile ) ;
# Set the virtual unit record devices online on HCP
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-e" , "c" ) ;
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-e" , "d" ) ;
# Purge reader
$ out = xCAT::zvmCPUtils - > purgeReader ( $ hcp , $ userId ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: Purging reader... Done" ) ;
# Punch kernel to reader on HCP
$ out = xCAT::zvmCPUtils - > punch2Reader ( $ hcp , $ userId , $ kernelFile , "sles.kernel" , "" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: Punching kernel to reader... $out" ) ;
if ( $ out =~ m/Failed/i ) {
return ;
}
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Punch parm to reader on HCP
$ out = xCAT::zvmCPUtils - > punch2Reader ( $ hcp , $ userId , $ parmFile , "sles.parm" , "-t" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: Punching parm to reader... $out" ) ;
if ( $ out =~ m/Failed/i ) {
return ;
}
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Punch initrd to reader on HCP
$ out = xCAT::zvmCPUtils - > punch2Reader ( $ hcp , $ userId , $ initFile , "sles.initrd" , "" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: Punching initrd to reader... $out" ) ;
if ( $ out =~ m/Failed/i ) {
return ;
2010-04-12 14:44:14 +00:00
}
2010-06-15 21:09:35 +00:00
# Remove kernel, parmfile, and initrd from /tmp
$ out = `rm $parmFile $kernelFile $initFile` ;
$ out = `ssh -o ConnectTimeout=5 $hcp "rm $parmFile $kernelFile $initFile"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: Kernel, parm, and initrd punched to reader. Ready for boot." ) ;
2010-04-12 14:44:14 +00:00
}
2010-06-15 21:09:35 +00:00
# RHEL installation
elsif ( $ os =~ m/rhel/i ) {
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Create directory in FTP root (/install) to hold template
$ out = `mkdir -p $installDir/custom/install/rh` ;
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
# Copy kickstart template
2010-10-27 19:27:38 +00:00
$ customTmpl = "$installDir/custom/install/rh/" . $ node . "." . $ profile . ".tmpl" ;
2010-07-07 15:12:44 +00:00
if ( - e "$installDir/custom/install/rh/$tmpl" ) {
$ out = `cp $installDir/custom/install/rh/$tmpl $customTmpl` ;
2010-04-12 14:44:14 +00:00
}
else {
2010-08-23 15:41:08 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) An kickstart template does not exist for $os in $installDir/custom/install/rh/" ) ;
2010-07-07 15:12:44 +00:00
return ;
2010-06-15 21:09:35 +00:00
}
2010-08-31 19:51:06 +00:00
2012-02-03 05:23:03 +00:00
# Get pkglist from /install/custom/install/rh/compute.rhel6.s390x.otherpkgs.pkglist
# Original one is in /opt/xcat/share/xcat/install/rh/compute.rhel6.s390x.otherpkgs.pkglist
2011-10-07 20:09:59 +00:00
$ pkglist = "/install/custom/install/rh/" . $ profile . "." . $ osBase . "." . $ arch . ".pkglist" ;
if ( ! ( - e $ pkglist ) ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing package list for $os in /install/custom/install/rh/" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Please create one or copy default one from /opt/xcat/share/xcat/install/rh/" ) ;
2011-10-07 20:09:59 +00:00
return ;
}
# Read in each software pattern or package
open ( FILE , $ pkglist ) ;
while ( <FILE> ) {
chomp ;
$ _ = xCAT::zvmUtils - > trimStr ( $ _ ) ;
$ packages . = "$_\\n" ;
}
close ( FILE ) ;
# Add appropriate software packages or patterns
$ out = `sed --in-place -e "s,replace_software_packages,$packages,g" $customTmpl` ;
2010-08-23 15:41:08 +00:00
# Copy postscript into template
$ out = `sed --in-place -e "/%post/r $postScript" $customTmpl` ;
2010-08-31 19:51:06 +00:00
2010-06-15 21:09:35 +00:00
# Edit template
my $ url = "ftp://$ftp/$os/s390x/" ;
$ out =
2010-08-23 20:41:41 +00:00
`sed --in-place -e "s,replace_url,$url,g" \ -e "s,replace_ip,$hostIP,g" \ -e "s,replace_netmask,$mask,g" \ -e "s,replace_gateway,$gateway,g" \ -e "s,replace_nameserver,$nameserver,g" \ -e "s,replace_hostname,$hostname,g" \ -e "s,replace_rootpw,$passwd,g" \ -e "s,replace_master,$master,g" \ -e "s,replace_install_dir,$installDir,g" $customTmpl` ;
2010-06-15 21:09:35 +00:00
# Read sample parmfile in /install/rhel5.3/s390x/images
$ sampleParm = "$installDir/$os/s390x/images/generic.prm" ;
open ( SAMPLEPARM , "<$sampleParm" ) ;
# Search parmfile for -- root=/dev/ram0 ro ip=off ramdisk_size=40000
while ( <SAMPLEPARM> ) {
# If the line contains 'ramdisk_size'
if ( $ _ =~ m/ramdisk_size/i ) {
$ parmHeader = xCAT::zvmUtils - > trimStr ( $ _ ) ;
2010-12-20 17:48:56 +00:00
2011-09-21 13:58:59 +00:00
# RHEL 6.1 needs cio_ignore in order to install
if ( ! ( $ os =~ m/rhel6.1/i ) ) {
$ parmHeader =~ s/cio_ignore=all,!0.0.0009//g ;
}
2010-06-15 21:09:35 +00:00
}
}
# Close sample parmfile
close ( SAMPLEPARM ) ;
2012-03-27 13:14:11 +00:00
# Get mdisk virtual address
2010-06-15 21:09:35 +00:00
my @ mdisks = xCAT::zvmUtils - > getMdisks ( $ callback , $ node ) ;
my $ dasd = "" ;
my $ i = 0 ;
foreach ( @ mdisks ) {
$ i = $ i + 1 ;
@ words = split ( ' ' , $ _ ) ;
# Do not put a comma at the end of the last disk address
if ( $ i == @ mdisks ) {
$ dasd = $ dasd . "0.0.$words[1]" ;
2012-03-27 13:14:11 +00:00
} else {
$ dasd = $ dasd . "0.0.$words[1]," ;
2010-06-15 21:09:35 +00:00
}
2012-03-27 13:14:11 +00:00
}
# Get dedicated virtual address
my @ dedicates = xCAT::zvmUtils - > getDedicates ( $ callback , $ node ) ;
$ i = 0 ;
foreach ( @ dedicates ) {
$ i = $ i + 1 ;
@ words = split ( ' ' , $ _ ) ;
# Do not put a comma at the end of the last disk address
if ( $ i == @ dedicates ) {
$ dasd = $ dasd . "0.0.$words[1]" ;
} else {
2010-06-15 21:09:35 +00:00
$ dasd = $ dasd . "0.0.$words[1]," ;
}
}
# Create parmfile -- Limited to 80 characters/line, maximum of 11 lines
# End result should be:
# ramdisk_size=40000 root=/dev/ram0 ro ip=off
# ks=ftp://10.0.0.1/rhel5.3/s390x/compute.rhel5.s390x.tmpl
# RUNKS=1 cmdline
# DASD=0.0.0100 HOSTNAME=gpok4.endicott.ibm.com
# NETTYPE=qeth IPADDR=10.0.0.4
# SUBCHANNELS=0.0.0800,0.0.0801,0.0.0800
# NETWORK=10.0.0.0 NETMASK=255.255.255.0
# SEARCHDNS=endicott.ibm.com BROADCAST=10.0.0.255
# GATEWAY=10.0.0.1 DNS=9.0.2.11 MTU=1500
# PORTNAME=UNASSIGNED PORTNO=0 LAYER2=0
# vnc vncpassword=12345678
2010-10-27 19:27:38 +00:00
my $ ks = "ftp://$ftp/custom/install/rh/" . $ node . "." . $ profile . ".tmpl" ;
2010-06-15 21:09:35 +00:00
$ parms = $ parmHeader . "\n" ;
$ parms = $ parms . "ks=$ks\n" ;
$ parms = $ parms . "RUNKS=1 cmdline\n" ;
$ parms = $ parms . "DASD=$dasd HOSTNAME=$hostname\n" ;
$ parms = $ parms . "NETTYPE=$netType IPADDR=$hostIP\n" ;
$ parms = $ parms . "SUBCHANNELS=$readChannel,$writeChannel,$dataChannel\n" ;
$ parms = $ parms . "NETWORK=$network NETMASK=$mask\n" ;
$ parms = $ parms . "SEARCHDNS=$domain BROADCAST=$broadcast\n" ;
$ parms = $ parms . "GATEWAY=$gateway DNS=$nameserver MTU=1500\n" ;
# Set layer in kickstart profile
if ( $ layer == 2 ) {
$ parms = $ parms . "PORTNAME=$portName PORTNO=$portNo LAYER2=1 MACADDR=$mac\n" ;
}
else {
$ parms = $ parms . "PORTNAME=$portName PORTNO=$portNo LAYER2=0\n" ;
}
$ parms = $ parms . "vnc vncpassword=12345678\n" ;
# Write to parmfile
$ parmFile = "/tmp/" . $ node . "Parm" ;
open ( PARMFILE , ">$parmFile" ) ;
print PARMFILE "$parms" ;
close ( PARMFILE ) ;
# Send kernel, parmfile, conf, and initrd to reader to HCP
$ kernelFile = "/tmp/" . $ node . "Kernel" ;
$ initFile = "/tmp/" . $ node . "Initrd" ;
$ out = `cp $installDir/$os/s390x/images/kernel.img $kernelFile` ;
$ out = `cp $installDir/$os/s390x/images/initrd.img $initFile` ;
xCAT::zvmUtils - > sendFile ( $ hcp , $ kernelFile , $ kernelFile ) ;
xCAT::zvmUtils - > sendFile ( $ hcp , $ parmFile , $ parmFile ) ;
xCAT::zvmUtils - > sendFile ( $ hcp , $ initFile , $ initFile ) ;
# Set the virtual unit record devices online
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-e" , "c" ) ;
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-e" , "d" ) ;
# Purge reader
$ out = xCAT::zvmCPUtils - > purgeReader ( $ hcp , $ userId ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: Purging reader... Done" ) ;
# Punch kernel to reader on HCP
$ out = xCAT::zvmCPUtils - > punch2Reader ( $ hcp , $ userId , $ kernelFile , "rhel.kernel" , "" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: Punching kernel to reader... $out" ) ;
if ( $ out =~ m/Failed/i ) {
return ;
}
# Punch parm to reader on HCP
$ out = xCAT::zvmCPUtils - > punch2Reader ( $ hcp , $ userId , $ parmFile , "rhel.parm" , "-t" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: Punching parm to reader... $out" ) ;
if ( $ out =~ m/Failed/i ) {
return ;
}
# Punch initrd to reader on HCP
$ out = xCAT::zvmCPUtils - > punch2Reader ( $ hcp , $ userId , $ initFile , "rhel.initrd" , "" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: Punching initrd to reader... $out" ) ;
if ( $ out =~ m/Failed/i ) {
return ;
}
# Remove kernel, parmfile, and initrd from /tmp
$ out = `rm $parmFile $kernelFile $initFile` ;
$ out = `ssh -o ConnectTimeout=5 $hcp "rm $parmFile $kernelFile $initFile"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: Kernel, parm, and initrd punched to reader. Ready for boot." ) ;
}
}
elsif ( $ action eq "statelite" ) {
# Get node group from 'nodelist' table
@ propNames = ( 'groups' ) ;
$ propVals = xCAT::zvmUtils - > getTabPropsByKey ( 'nodelist' , 'node' , $ node , @ propNames ) ;
my $ group = $ propVals - > { 'groups' } ;
2010-07-07 15:12:44 +00:00
# Get node statemnt (statelite mount point) from 'statelite' table
2010-06-15 21:09:35 +00:00
@ propNames = ( 'statemnt' ) ;
$ propVals = xCAT::zvmUtils - > getTabPropsByKey ( 'statelite' , 'node' , $ node , @ propNames ) ;
my $ stateMnt = $ propVals - > { 'statemnt' } ;
if ( ! $ stateMnt ) {
$ propVals = xCAT::zvmUtils - > getTabPropsByKey ( 'statelite' , 'node' , $ group , @ propNames ) ;
$ stateMnt = $ propVals - > { 'statemnt' } ;
if ( ! $ stateMnt ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing node statemnt in statelite table. Please specify one." ) ;
2010-06-15 21:09:35 +00:00
return ;
}
}
# Netboot directory
my $ netbootDir = "$installDir/netboot/$os/$arch/$profile" ;
my $ kernelFile = "$netbootDir/kernel" ;
2010-10-04 16:12:34 +00:00
my $ parmFile = "$netbootDir/parm-statelite" ;
my $ initFile = "$netbootDir/initrd-statelite.gz" ;
2010-06-15 21:09:35 +00:00
# If parmfile exists
if ( - e $ parmFile ) {
# Do nothing
2010-04-12 14:44:14 +00:00
}
else {
2010-06-15 21:09:35 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: Creating parmfile" ) ;
my $ sampleParm ;
my $ parmHeader ;
my $ parms ;
if ( $ os =~ m/sles/i ) {
2010-07-07 15:12:44 +00:00
if ( - e "$installDir/$os/s390x/1/boot/s390x/parmfile" ) {
# Read sample parmfile in /install/sles11.1/s390x/1/boot/s390x/
$ sampleParm = "$installDir/$os/s390x/1/boot/s390x/parmfile" ;
2012-02-03 05:23:03 +00:00
} else {
2010-07-07 15:12:44 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing $installDir/$os/s390x/1/boot/s390x/parmfile" ) ;
return ;
}
2010-06-15 21:09:35 +00:00
}
elsif ( $ os =~ m/rhel/i ) {
2010-07-07 15:12:44 +00:00
if ( - e "$installDir/$os/s390x/images/generic.prm" ) {
# Read sample parmfile in /install/rhel5.3/s390x/images
$ sampleParm = "$installDir/$os/s390x/images/generic.prm" ;
2012-02-03 05:23:03 +00:00
} else {
2010-07-07 15:12:44 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing $installDir/$os/s390x/images/generic.prm" ) ;
return ;
}
2010-06-15 21:09:35 +00:00
}
open ( SAMPLEPARM , "<$sampleParm" ) ;
# Search parmfile for -- ramdisk_size=65536 root=/dev/ram1 ro init=/linuxrc TERM=dumb
while ( <SAMPLEPARM> ) {
# If the line contains 'ramdisk_size'
if ( $ _ =~ m/ramdisk_size/i ) {
$ parmHeader = xCAT::zvmUtils - > trimStr ( $ _ ) ;
}
}
# Close sample parmfile
close ( SAMPLEPARM ) ;
# Create parmfile
# End result should be:
# ramdisk_size=65536 root=/dev/ram1 ro init=/linuxrc TERM=dumb
# NFSROOT=10.1.100.1:/install/netboot/sles11.1.1/s390x/compute
# STATEMNT=10.1.100.1:/lite/state XCAT=10.1.100.1:3001
$ parms = $ parmHeader . "\n" ;
$ parms = $ parms . "NFSROOT=$master:$netbootDir\n" ;
$ parms = $ parms . "STATEMNT=$stateMnt XCAT=$master:$xcatdPort\n" ;
# Write to parmfile
open ( PARMFILE , ">$parmFile" ) ;
print PARMFILE "$parms" ;
close ( PARMFILE ) ;
2010-04-12 14:44:14 +00:00
}
2010-06-15 21:09:35 +00:00
# Temporary kernel, parmfile, and initrd
my $ tmpKernelFile = "/tmp/$os-kernel" ;
2010-10-04 16:12:34 +00:00
my $ tmpParmFile = "/tmp/$os-parm-statelite" ;
my $ tmpInitFile = "/tmp/$os-initrd-statelite.gz" ;
2010-04-12 14:44:14 +00:00
2010-06-15 21:09:35 +00:00
if ( `ssh -o ConnectTimeout=5 $hcp "ls /tmp" | grep "$os-kernel"` ) {
# Do nothing
2012-02-03 05:23:03 +00:00
} else {
2010-06-15 21:09:35 +00:00
# Send kernel to reader to HCP
xCAT::zvmUtils - > sendFile ( $ hcp , $ kernelFile , $ tmpKernelFile ) ;
}
2010-10-04 16:12:34 +00:00
if ( `ssh -o ConnectTimeout=5 $hcp "ls /tmp" | grep "$os-parm-statelite"` ) {
2010-06-15 21:09:35 +00:00
# Do nothing
2012-02-03 05:23:03 +00:00
} else {
2010-06-15 21:09:35 +00:00
# Send parmfile to reader to HCP
xCAT::zvmUtils - > sendFile ( $ hcp , $ parmFile , $ tmpParmFile ) ;
}
2010-10-04 16:12:34 +00:00
if ( `ssh -o ConnectTimeout=5 $hcp "ls /tmp" | grep "$os-initrd-statelite.gz"` ) {
2010-06-15 21:09:35 +00:00
# Do nothing
2012-02-03 05:23:03 +00:00
} else {
2010-06-15 21:09:35 +00:00
# Send initrd to reader to HCP
xCAT::zvmUtils - > sendFile ( $ hcp , $ initFile , $ tmpInitFile ) ;
}
2010-04-12 14:44:14 +00:00
# Set the virtual unit record devices online
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-e" , "c" ) ;
$ out = xCAT::zvmUtils - > disableEnableDisk ( $ callback , $ hcp , "-e" , "d" ) ;
# Purge reader
$ out = xCAT::zvmCPUtils - > purgeReader ( $ hcp , $ userId ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: Purging reader... Done" ) ;
2010-06-15 21:09:35 +00:00
# Kernel, parm, and initrd are in /install/netboot/<os>/<arch>/<profile>
2010-04-12 14:44:14 +00:00
# Punch kernel to reader on HCP
2010-06-15 21:09:35 +00:00
$ out = xCAT::zvmCPUtils - > punch2Reader ( $ hcp , $ userId , $ tmpKernelFile , "sles.kernel" , "" ) ;
2010-04-12 14:44:14 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: Punching kernel to reader... $out" ) ;
if ( $ out =~ m/Failed/i ) {
return ;
}
# Punch parm to reader on HCP
2010-06-15 21:09:35 +00:00
$ out = xCAT::zvmCPUtils - > punch2Reader ( $ hcp , $ userId , $ tmpParmFile , "sles.parm" , "-t" ) ;
2010-04-12 14:44:14 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: Punching parm to reader... $out" ) ;
if ( $ out =~ m/Failed/i ) {
return ;
}
# Punch initrd to reader on HCP
2010-06-15 21:09:35 +00:00
$ out = xCAT::zvmCPUtils - > punch2Reader ( $ hcp , $ userId , $ tmpInitFile , "sles.initrd" , "" ) ;
2010-04-12 14:44:14 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: Punching initrd to reader... $out" ) ;
if ( $ out =~ m/Failed/i ) {
return ;
}
xCAT::zvmUtils - > printLn ( $ callback , "$node: Kernel, parm, and initrd punched to reader. Ready for boot." ) ;
}
2010-06-15 21:09:35 +00:00
else {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Option not supported" ) ;
return ;
}
2010-04-12 14:44:14 +00:00
return ;
}
#-------------------------------------------------------
= head3 getMacs
Description : Get the MAC address of a given node
2010-07-07 15:12:44 +00:00
* Requires the node be online
* Saves MAC address in 'mac' table
2010-04-12 14:44:14 +00:00
Arguments : Node
Returns : Nothing
Example : getMacs ( $ callback , $ node , $ args ) ;
= cut
#-------------------------------------------------------
sub getMacs {
# Get inputs
my ( $ callback , $ node , $ args ) = @ _ ;
# Get node properties from 'zvm' table
my @ propNames = ( 'hcp' , 'userid' ) ;
my $ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ node , @ propNames ) ;
2012-02-03 05:23:03 +00:00
# Get zHCP
2010-04-12 14:44:14 +00:00
my $ hcp = $ propVals - > { 'hcp' } ;
if ( ! $ hcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing node HCP" ) ;
return ;
}
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-04-12 14:44:14 +00:00
my $ userId = $ propVals - > { 'userid' } ;
if ( ! $ userId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ userId =~ tr /a-z/ A - Z / ;
2010-04-12 14:44:14 +00:00
# Get MAC address in 'mac' table
2010-07-07 15:12:44 +00:00
@ propNames = ( 'mac' ) ;
$ propVals = xCAT::zvmUtils - > getNodeProps ( 'mac' , $ node , @ propNames ) ;
2010-04-12 14:44:14 +00:00
my $ mac ;
2010-08-31 19:51:06 +00:00
if ( $ propVals - > { 'mac' } ) {
2010-04-12 14:44:14 +00:00
# Get MAC address
$ mac = $ propVals - > { 'mac' } ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $mac" ) ;
return ;
}
# If MAC address is not in the 'mac' table, get it using VMCP
xCAT::zvmCPUtils - > loadVmcp ( $ node ) ;
# Get xCat MN Lan/VSwitch name
my $ out = `vmcp q v nic | egrep -i "VSWITCH|LAN"` ;
my @ lines = split ( '\n' , $ out ) ;
my @ words ;
# Go through each line and extract VSwitch and Lan names
# and create search string
my $ searchStr = "" ;
my $ i ;
for ( $ i = 0 ; $ i < @ lines ; $ i + + ) {
# Extract VSwitch name
if ( $ lines [ $ i ] =~ m/VSWITCH/i ) {
@ words = split ( ' ' , $ lines [ $ i ] ) ;
$ searchStr = $ searchStr . "$words[4]" ;
}
# Extract Lan name
elsif ( $ lines [ $ i ] =~ m/LAN/i ) {
@ words = split ( ' ' , $ lines [ $ i ] ) ;
$ searchStr = $ searchStr . "$words[4]" ;
}
if ( $ i != ( @ lines - 1 ) ) {
$ searchStr = $ searchStr . "|" ;
}
}
# Get MAC address of node
2012-02-03 05:23:03 +00:00
# This node should be on only 1 of the networks that the xCAT MN is on
2010-04-12 14:44:14 +00:00
$ out = `ssh -o ConnectTimeout=5 $node "vmcp q v nic" | egrep -i "$searchStr"` ;
if ( ! $ out ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Failed to find MAC address" ) ;
return ;
}
@ lines = split ( '\n' , $ out ) ;
@ words = split ( ' ' , $ lines [ 0 ] ) ;
2010-07-07 15:12:44 +00:00
$ mac = $ words [ 1 ] ;
2010-04-12 14:44:14 +00:00
# Replace - with :
$ mac = xCAT::zvmUtils - > replaceStr ( $ mac , "-" , ":" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $mac" ) ;
# Save MAC address and network interface into 'mac' table
xCAT::zvmUtils - > setNodeProp ( 'mac' , $ node , 'mac' , $ mac ) ;
return ;
}
#-------------------------------------------------------
= head3 netBoot
Description : Boot from network
Arguments : Node
Address to IPL from
Returns : Nothing
Example : netBoot ( $ callback , $ node , $ args ) ;
= cut
#-------------------------------------------------------
sub netBoot {
# Get inputs
my ( $ callback , $ node , $ args ) = @ _ ;
# Get node properties from 'zvm' table
my @ propNames = ( 'hcp' , 'userid' ) ;
my $ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ node , @ propNames ) ;
2012-02-03 05:23:03 +00:00
# Get zHCP
2010-04-12 14:44:14 +00:00
my $ hcp = $ propVals - > { 'hcp' } ;
if ( ! $ hcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing node HCP" ) ;
return ;
}
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-04-12 14:44:14 +00:00
my $ userId = $ propVals - > { 'userid' } ;
if ( ! $ userId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ userId =~ tr /a-z/ A - Z / ;
2010-04-12 14:44:14 +00:00
# Get IPL
my @ ipl = split ( '=' , $ args - > [ 0 ] ) ;
if ( ! ( $ ipl [ 0 ] eq "ipl" ) ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing IPL" ) ;
return ;
}
# Boot node
my $ out = `ssh $hcp "$::DIR/startvs $userId"` ;
my $ rc = xCAT::zvmUtils - > checkOutput ( $ callback , $ out ) ;
if ( $ rc == - 1 ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Boot failed" ) ;
return ;
}
else {
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
}
# IPL when virtual server is online
sleep ( 5 ) ;
$ out = xCAT::zvmCPUtils - > sendCPCmd ( $ hcp , $ userId , "IPL $ipl[1]" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: Booting from $ipl[1]... Done" ) ;
return ;
}
#-------------------------------------------------------
2010-07-07 15:12:44 +00:00
= head3 updateNode ( No longer supported )
2010-04-12 14:44:14 +00:00
Description : Update node
Arguments : Node
Option
Options supported:
2010-07-07 15:12:44 +00:00
* release [ updated version ]
2010-04-12 14:44:14 +00:00
Returns : Nothing
Example : updateNode ( $ callback , $ node , $ args ) ;
= cut
#-------------------------------------------------------
sub updateNode {
# Get inputs
my ( $ callback , $ node , $ args ) = @ _ ;
# Get node properties from 'zvm' table
my @ propNames = ( 'hcp' , 'userid' ) ;
my $ propVals = xCAT::zvmUtils - > getNodeProps ( 'zvm' , $ node , @ propNames ) ;
2012-02-03 05:23:03 +00:00
# Get zHCP
2010-04-12 14:44:14 +00:00
my $ hcp = $ propVals - > { 'hcp' } ;
if ( ! $ hcp ) {
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing node HCP" ) ;
return ;
}
2012-02-03 05:23:03 +00:00
# Get node user ID
2010-04-12 14:44:14 +00:00
my $ userId = $ propVals - > { 'userid' } ;
if ( ! $ userId ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing user ID" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2012-02-03 05:23:03 +00:00
# Capitalize user ID
2012-01-21 12:54:05 +00:00
$ userId =~ tr /a-z/ A - Z / ;
2010-06-15 21:09:35 +00:00
2010-04-14 20:10:26 +00:00
# Get install directory
2010-06-15 21:09:35 +00:00
my $ siteTab = xCAT::Table - > new ( 'site' ) ;
2010-04-14 20:10:26 +00:00
my $ installDirHash = $ siteTab - > getAttribs ( { key = > "installdir" } , 'value' ) ;
2010-06-15 21:09:35 +00:00
my $ installDir = $ installDirHash - > { 'value' } ;
2010-04-12 14:44:14 +00:00
# Get host IP and hostname from /etc/hosts
my $ out = `cat /etc/hosts | grep $node` ;
my @ words = split ( ' ' , $ out ) ;
my $ hostIP = $ words [ 0 ] ;
my $ hostname = $ words [ 2 ] ;
if ( ! $ hostIP || ! $ hostname ) {
2010-06-15 21:09:35 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing IP for $node in /etc/hosts" ) ;
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Verify that the node's IP address is specified in the hosts table and then run makehosts" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
# Get first 3 octets of node IP (IPv4)
@ words = split ( /\./ , $ hostIP ) ;
my $ octets = "$words[0].$words[1].$words[2]" ;
# Get networks in 'networks' table
my $ entries = xCAT::zvmUtils - > getAllTabEntries ( 'networks' ) ;
# Go through each network
my $ network ;
foreach ( @$ entries ) {
# Get network
$ network = $ _ - > { 'net' } ;
# If networks contains the first 3 octets of the node IP
if ( $ network =~ m/$octets/i ) {
# Exit loop
last ;
}
else {
$ network = "" ;
}
}
# If no network found
if ( ! $ network ) {
# Exit
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Node does not belong to any network in the networks table" ) ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Specify the subnet in the networks table. The mask, gateway, tftpserver, and nameservers must be specified for the subnet." ) ;
2010-04-12 14:44:14 +00:00
return ;
}
# Get FTP server
@ propNames = ( 'tftpserver' ) ;
2010-06-15 21:09:35 +00:00
$ propVals = xCAT::zvmUtils - > getTabPropsByKey ( 'networks' , 'net' , $ network , @ propNames ) ;
2010-04-12 14:44:14 +00:00
my $ ftp = $ propVals - > { 'tftpserver' } ;
if ( ! $ ftp ) {
# It is acceptable to not have a gateway
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing FTP server" ) ;
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Solution) Specify the tftpserver for the subnet in the networks table" ) ;
2010-04-12 14:44:14 +00:00
return ;
}
# Update node operating system
2010-06-15 21:09:35 +00:00
if ( $ args - > [ 0 ] eq "--release" ) {
2010-04-12 14:44:14 +00:00
my $ version = $ args - > [ 1 ] ;
if ( ! $ version ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Missing operating system release. Please specify one." ) ;
2010-04-12 14:44:14 +00:00
return ;
}
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Get node operating system
my $ os = xCAT::zvmUtils - > getOs ( $ node ) ;
2010-06-15 21:09:35 +00:00
# Check node OS is the same as the version OS given
2010-04-12 14:44:14 +00:00
# You do not want to update a SLES with a RHEL
2010-06-15 21:09:35 +00:00
if ( ( ( $ os =~ m/SUSE/i ) && ! ( $ version =~ m/sles/i ) ) || ( ( $ os =~ m/Red Hat/i ) && ! ( $ version =~ m/rhel/i ) ) ) {
2012-02-03 05:23:03 +00:00
xCAT::zvmUtils - > printLn ( $ callback , "$node: (Error) Node operating system is different from the operating system given to upgrade to. Please correct." ) ;
2010-04-12 14:44:14 +00:00
return ;
}
# Generate FTP path to operating system image
my $ path ;
2010-06-15 21:09:35 +00:00
if ( $ version =~ m/sles/i ) {
# The following only applies to SLES 10
# SLES 11 requires zypper
2010-04-12 14:44:14 +00:00
# SuSE Enterprise Linux path - ftp://10.0.0.1/sles10.3/s390x/1/
$ path = "ftp://$ftp/$version/s390x/1/" ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Add installation source using rug
$ out = `ssh $node "rug sa -t zypp $path $version"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Subscribe to catalog
$ out = `ssh $node "rug sub $version"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Refresh services
$ out = `ssh $node "rug ref"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Update
$ out = `ssh $node "rug up -y"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
2010-06-15 21:09:35 +00:00
}
else {
2010-04-12 14:44:14 +00:00
# Red Hat Enterprise Linux path - ftp://10.0.0.1/rhel5.4/s390x/Server/
$ path = "ftp://$ftp/$version/s390x/Server/" ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Check if file.repo already has this repository location
$ out = `ssh $node "cat /etc/yum.repos.d/file.repo"` ;
2010-06-15 21:09:35 +00:00
if ( $ out =~ m/[$version]/i ) {
2010-04-12 14:44:14 +00:00
# Send over release key
2010-04-14 20:10:26 +00:00
my $ key = "$installDir/$version/s390x/RPM-GPG-KEY-redhat-release" ;
2010-04-12 14:44:14 +00:00
my $ tmp = "/tmp/RPM-GPG-KEY-redhat-release" ;
2010-06-15 21:09:35 +00:00
xCAT::zvmUtils - > sendFile ( $ node , $ key , $ tmp ) ;
2010-04-12 14:44:14 +00:00
# Import key
$ out = `ssh $node "rpm --import /tmp/$key"` ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Upgrade
$ out = `ssh $node "yum upgrade -y"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
2010-06-15 21:09:35 +00:00
}
else {
2010-04-12 14:44:14 +00:00
# Create repository
$ out = `ssh $node "echo [$version] >> /etc/yum.repos.d/file.repo"` ;
$ out = `ssh $node "echo baseurl=$path >> /etc/yum.repos.d/file.repo"` ;
$ out = `ssh $node "echo enabled=1 >> /etc/yum.repos.d/file.repo"` ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Send over release key
2010-04-14 20:10:26 +00:00
my $ key = "$installDir/$version/s390x/RPM-GPG-KEY-redhat-release" ;
2010-04-12 14:44:14 +00:00
my $ tmp = "/tmp/RPM-GPG-KEY-redhat-release" ;
2010-06-15 21:09:35 +00:00
xCAT::zvmUtils - > sendFile ( $ node , $ key , $ tmp ) ;
2010-04-12 14:44:14 +00:00
# Import key
$ out = `ssh $node "rpm --import $tmp"` ;
2010-06-15 21:09:35 +00:00
2010-04-12 14:44:14 +00:00
# Upgrade
$ out = `ssh $node "yum upgrade -y"` ;
xCAT::zvmUtils - > printLn ( $ callback , "$node: $out" ) ;
}
}
}
# Otherwise, print out error
else {
$ out = "$node: (Error) Option not supported" ;
}
xCAT::zvmUtils - > printLn ( $ callback , "$out" ) ;
return ;
}
2011-05-17 19:57:04 +00:00
#-------------------------------------------------------
= head3 listTree
Description : Show the nodes hierarchy tree
Arguments : Node range ( zHCP )
Returns : Nothing
Example : listHierarchy ( $ callback , $ nodes , $ args ) ;
= cut
#-------------------------------------------------------
sub listTree {
# Get inputs
my ( $ callback , $ nodes , $ args ) = @ _ ;
my @ nodes = @$ nodes ;
my $ option = '' ;
if ( $ args ) {
@ ARGV = @$ args ;
# Parse options
GetOptions ( 'o' = > \ $ option ) ;
}
# In order for this command to work, issue under /opt/xcat/bin:
# ln -s /opt/xcat/bin/xcatclient lstree
my % tree ;
my $ node ;
my $ parent ;
my $ found ;
# Create hierachy structure: CEC -> LPAR -> zVM -> VM
# Get table
my $ tab = xCAT::Table - > new ( 'zvm' , - create = > 1 , - autocommit = > 0 ) ;
# Get CEC entries
2011-05-23 18:49:45 +00:00
# There should be few of these nodes
2011-05-17 19:57:04 +00:00
my @ entries = $ tab - > getAllAttribsWhere ( "nodetype = 'cec'" , 'node' , 'parent' ) ;
foreach ( @ entries ) {
$ node = $ _ - > { 'node' } ;
# Make CEC the tree root
$ tree { $ node } = { } ;
}
# Get LPAR entries
2011-05-23 18:49:45 +00:00
# There should be a couple of these nodes
2011-05-17 19:57:04 +00:00
@ entries = $ tab - > getAllAttribsWhere ( "nodetype = 'lpar'" , 'node' , 'parent' ) ;
foreach ( @ entries ) {
$ node = $ _ - > { 'node' } ; # LPAR
$ parent = $ _ - > { 'parent' } ; # CEC
# Add LPAR branch
$ tree { $ parent } { $ node } = { } ;
}
# Get zVM entries
2011-05-23 18:49:45 +00:00
# There should be a couple of these nodes
2011-05-17 19:57:04 +00:00
$ found = 0 ;
@ entries = $ tab - > getAllAttribsWhere ( "nodetype = 'zvm'" , 'node' , 'parent' ) ;
foreach ( @ entries ) {
$ node = $ _ - > { 'node' } ; # zVM
$ parent = $ _ - > { 'parent' } ; # LPAR
# Find CEC root based on LPAR
# CEC -> LPAR
$ found = 0 ;
foreach my $ cec ( sort keys % tree ) {
foreach my $ lpar ( sort keys % { $ tree { $ cec } } ) {
if ( $ lpar eq $ parent ) {
# Add LPAR branch
$ tree { $ cec } { $ parent } { $ node } = { } ;
$ found = 1 ;
last ;
}
2011-05-17 20:57:40 +00:00
# Handle second level zVM
foreach my $ vm ( sort keys % { $ tree { $ cec } { $ lpar } } ) {
if ( $ vm eq $ parent ) {
# Add VM branch
$ tree { $ cec } { $ lpar } { $ parent } { $ node } = { } ;
$ found = 1 ;
last ;
}
2011-05-23 18:49:45 +00:00
} # End of foreach zVM
} # End of foreach LPAR
2011-05-17 19:57:04 +00:00
# Exit loop if LPAR branch added
if ( $ found ) {
last ;
}
2011-05-23 18:49:45 +00:00
} # End of foreach CEC
2011-05-17 19:57:04 +00:00
}
# Get VM entries
2011-05-23 18:49:45 +00:00
# There should be many of these nodes
2011-05-17 19:57:04 +00:00
$ found = 0 ;
@ entries = $ tab - > getAllAttribsWhere ( "nodetype = 'vm'" , 'node' , 'parent' , 'userid' ) ;
foreach ( @ entries ) {
$ node = $ _ - > { 'node' } ; # VM
$ parent = $ _ - > { 'parent' } ; # zVM
2011-05-23 18:49:45 +00:00
# Skip node if it is not in noderange
if ( ! xCAT::zvmUtils - > inArray ( $ node , @ nodes ) ) {
next ;
}
# Find CEC/LPAR root based on zVM
2011-05-17 19:57:04 +00:00
# CEC -> LPAR -> zVM
$ found = 0 ;
foreach my $ cec ( sort keys % tree ) {
foreach my $ lpar ( sort keys % { $ tree { $ cec } } ) {
foreach my $ zvm ( sort keys % { $ tree { $ cec } { $ lpar } } ) {
if ( $ zvm eq $ parent ) {
# Add zVM branch
$ tree { $ cec } { $ lpar } { $ parent } { $ node } = $ _ - > { 'userid' } ;
$ found = 1 ;
last ;
}
2011-05-17 20:57:40 +00:00
# Handle second level zVM
foreach my $ vm ( sort keys % { $ tree { $ cec } { $ lpar } { $ zvm } } ) {
if ( $ vm eq $ parent ) {
# Add VM branch
$ tree { $ cec } { $ lpar } { $ zvm } { $ parent } { $ node } = $ _ - > { 'userid' } ;
$ found = 1 ;
last ;
}
2011-05-23 18:49:45 +00:00
} # End of foreach VM
} # End of foreach zVM
2011-05-17 19:57:04 +00:00
# Exit loop if zVM branch added
if ( $ found ) {
last ;
}
2011-05-23 18:49:45 +00:00
} # End of foreach LPAR
2011-05-17 19:57:04 +00:00
# Exit loop if zVM branch added
if ( $ found ) {
last ;
}
2011-05-23 18:49:45 +00:00
} # End of foreach CEC
} # End of foreach VM node
2011-05-17 19:57:04 +00:00
# Print tree
# Loop through CECs
foreach my $ cec ( sort keys % tree ) {
xCAT::zvmUtils - > printLn ( $ callback , "CEC: $cec" ) ;
# Loop through LPARs
foreach my $ lpar ( sort keys % { $ tree { $ cec } } ) {
xCAT::zvmUtils - > printLn ( $ callback , "|__LPAR: $lpar" ) ;
# Loop through zVMs
foreach my $ zvm ( sort keys % { $ tree { $ cec } { $ lpar } } ) {
xCAT::zvmUtils - > printLn ( $ callback , " |__zVM: $zvm" ) ;
# Loop through VMs
foreach my $ vm ( sort keys % { $ tree { $ cec } { $ lpar } { $ zvm } } ) {
2011-05-17 20:57:40 +00:00
# Handle second level zVM
if ( ref ( $ tree { $ cec } { $ lpar } { $ zvm } { $ vm } ) eq 'HASH' ) {
xCAT::zvmUtils - > printLn ( $ callback , " |__zVM: $vm" ) ;
foreach my $ vm2 ( sort keys % { $ tree { $ cec } { $ lpar } { $ zvm } { $ vm } } ) {
xCAT::zvmUtils - > printLn ( $ callback , " |__VM: $vm2 ($tree{$cec}{$lpar}{$zvm}{$vm}{$vm2})" ) ;
}
} else {
xCAT::zvmUtils - > printLn ( $ callback , " |__VM: $vm ($tree{$cec}{$lpar}{$zvm}{$vm})" ) ;
}
2011-05-23 18:49:45 +00:00
} # End of foreach VM
} # End of foreach zVM
} # End of foreach LPAR
} # End of foreach CEC
2011-05-17 19:57:04 +00:00
return ;
}