Add OS version to rscan() output.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9675 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
phamt 2011-05-24 18:26:13 +00:00
parent 7abed255d4
commit 1d2e255494
2 changed files with 61 additions and 4 deletions

View File

@ -1104,4 +1104,50 @@ sub inArray {
# Get inputs
my ( $class, $needle, @haystack ) = @_;
return grep{ $_ eq $needle } @haystack;
}
#-------------------------------------------------------
=head3 getOsVersion
Description : Get the operating system of a given node
Arguments : Node
Returns : Operating system name
Example : my $os = xCAT::zvmUtils->getOsVersion($node);
=cut
#-------------------------------------------------------
sub getOsVersion {
# Get inputs
my ( $class, $node ) = @_;
my $os = '';
my $version = '';
# Get operating system
my $release = `ssh -o ConnectTimeout=2 $node "cat /etc/*release"`;
my @lines = split('\n', $release);
if (grep(/SLES|Enterprise Server/, @lines)) {
$os = 'sles';
$version = $lines[0];
$version =~ tr/\.//;
$version =~ s/[^0-9]*([0-9]+).*/$1/;
$os = $os . $version;
# Append service level
$version = `echo "$release" | grep "LEVEL"`;
$version =~ tr/\.//;
$version =~ s/[^0-9]*([0-9]+).*/$1/;
$os = $os . 'sp' . $version;
} elsif (grep(/Red Hat Enterprise Linux Server/, @lines)) {
$os = 'rhel';
$version = $lines[0];
$version =~ tr/\.//;
$version =~ s/([A-Za-z\s\(\)]+)//g;
$os = $os . $version;
}
return xCAT::zvmUtils->trimStr($os);
}

View File

@ -1312,7 +1312,7 @@ sub scanVM {
# Parse options
GetOptions( 'w' => \$write2db );
}
# Get node properties from 'zvm' table
my @propNames = ( 'hcp', 'userid' );
my $propVals = xCAT::zvmUtils->getNodeProps( 'zvm', $node, @propNames );
@ -1441,22 +1441,33 @@ sub scanVM {
$arch = 's390x';
}
# Save to 'zvm' table
# Get OS
$os = xCAT::zvmUtils->getOsVersion($node);
# Save node attributes
if ($write2db) {
# Save to 'zvm' table
%propHash = (
'hcp' => $hcp,
'userid' => $id,
'nodetype' => 'vm',
'parent' => $host
);
);
xCAT::zvmUtils->setNodeProps( 'zvm', $node, \%propHash );
# Save to 'nodetype' table
%propHash = (
'arch' => $arch,
'os' => $os
);
xCAT::zvmUtils->setNodeProps( 'nodetype', $node, \%propHash );
}
# Create output string
$str .= "$node:\n";
$str .= " objtype=node\n";
$str .= " arch=$arch\n";
$str .= " os=$os\n";
$str .= " hcp=$hcp\n";
$str .= " userid=$id\n";
$str .= " nodetype=vm\n";