Added caching for disk pools and user profiles.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8241 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
54ff385d28
commit
07b23287c3
@ -743,12 +743,12 @@ sub getDeviceNode {
|
||||
my $out = `ssh $node "cat /proc/dasd/devices" | grep ".$tgtAddr("`;
|
||||
my @words = split( ' ', $out );
|
||||
my $tgtDevNode;
|
||||
|
||||
|
||||
# /proc/dasd/devices look similar to this:
|
||||
# 0.0.0100(ECKD) at ( 94: 0) is dasda : active at blocksize: 4096, 1802880 blocks, 7042 MB
|
||||
# Look for the string 'is'
|
||||
my $i = 0;
|
||||
while ($tgtDevNode ne 'is') {
|
||||
while ( $tgtDevNode ne 'is' ) {
|
||||
$tgtDevNode = $words[$i];
|
||||
$i++;
|
||||
}
|
||||
@ -993,3 +993,58 @@ sub getArch {
|
||||
|
||||
return ( xCAT::zvmUtils->trimStr($arch) );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 getUserProfile
|
||||
|
||||
Description : Get the user profile
|
||||
Arguments : Profile name
|
||||
Returns : User profile
|
||||
Example : my $profile = xCAT::zvmUtils->getUserProfile($hcp, $name);
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub getUserProfile {
|
||||
|
||||
# Get inputs
|
||||
my ( $class, $hcp, $profile ) = @_;
|
||||
|
||||
# Set directory where executables are on zHCP
|
||||
my $hcpDir = "/opt/zhcp/bin";
|
||||
|
||||
# Set directory for cache
|
||||
my $cache = '/var/opt/zhcp/.vmapi/.cache';
|
||||
|
||||
# Set output file name
|
||||
my $file = "$cache/$profile.profile";
|
||||
|
||||
# If a cache for the user profile exists
|
||||
my $out;
|
||||
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 user profiles and save it in a file
|
||||
$out = `ssh $hcp "$hcpDir/getuserprofile $profile > $file"`;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
# Get user profiles and save it in a file
|
||||
$out = `ssh $hcp "$hcpDir/getuserprofile $profile > $file"`;
|
||||
}
|
||||
|
||||
# Return the file contents
|
||||
$out = `ssh $hcp "cat $file"`;
|
||||
return $out;
|
||||
}
|
@ -1487,6 +1487,9 @@ sub listVM {
|
||||
# Get inputs
|
||||
my ( $callback, $node, $args ) = @_;
|
||||
|
||||
# Set cache directory
|
||||
my $cache = '/var/opt/zhcp/.vmapi/.cache';
|
||||
|
||||
# Get node properties from 'zvm' table
|
||||
my @propNames = ( 'hcp', 'userid' );
|
||||
my $propVals = xCAT::zvmUtils->getNodeProps( 'zvm', $node, @propNames );
|
||||
@ -1509,7 +1512,28 @@ sub listVM {
|
||||
|
||||
# Get disk pool names
|
||||
if ( $args->[0] eq "--diskpoolnames" ) {
|
||||
$out = `ssh $hcp "$::DIR/getdiskpoolnames $userId"`;
|
||||
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"`;
|
||||
}
|
||||
|
||||
# Get disk pool configuration
|
||||
@ -2935,10 +2959,14 @@ sub nodeSet {
|
||||
$out = `echo "$userEntry" | grep "NICDEF" | grep "$hcpNetName"`;
|
||||
if (!$out) {
|
||||
# Check for user profile
|
||||
my $userProfile = `echo "$userEntry" | grep "INCLUDE"`;
|
||||
if ($userProfile) {
|
||||
@words = split( ' ', xCAT::zvmUtils->trimStr($userProfile) );
|
||||
$out = `ssh $hcp "$::DIR/getuserprofile $words[1]" | grep "NICDEF" | grep "$hcpNetName"`;
|
||||
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]);
|
||||
# Get the NICDEF statement containing the HCP network
|
||||
$out = `echo "$userProfile" | grep "NICDEF" | grep "$hcpNetName"`;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user