added capacity table to store cpu, memory and disk sizes for nodes

This commit is contained in:
linggao 2013-12-19 08:25:41 -05:00
parent c4170ce728
commit 2f17a10f92
3 changed files with 67 additions and 2 deletions

View File

@ -1500,6 +1500,20 @@ mic => {
disable => "Do not use. tabprune will not work if set to yes or 1",
},
},
capacity => {
cols => [qw(node cputype cpucount memory disksize comments disable)],
keys => [qw(node)],
table_desc => 'The basic node capacity.',
descriptions => {
node => 'The node name or group name.',
cputype => 'The cpu model name for the node.',
cpucount => 'The number of cpus for the node.',
memory => 'The size of the memory for the node.',
disksize => 'The size of the disks for the node.',
comments => 'Any user-provided notes.',
disable => "Set to 'yes' or '1' to comment out this row.",
},
},
); # end of tabspec definition
@ -2478,7 +2492,26 @@ my @nodeattrs = (
tabentry => 'mic.powermgt',
access_tabentry => 'mic.node=attr:node',
},
#####################
## capacity table #
#####################
{attr_name => 'cputype',
tabentry => 'capacity.cputype',
access_tabentry => 'capacity.node=attr:node',
},
{attr_name => 'cpucount',
tabentry => 'capacity.cpucount',
access_tabentry => 'capacity.node=attr:node',
},
{attr_name => 'memory',
tabentry => 'capacity.memory',
access_tabentry => 'capacity.node=attr:node',
},
{attr_name => 'disksize',
tabentry => 'capacity.disksize',
access_tabentry => 'capacity.node=attr:node',
},
); # end of @nodeattrs that applies to both nodes and groups

View File

@ -75,7 +75,17 @@ elif [ -r /proc/device-tree/model ]; then #POWER
MTM=`cat /proc/device-tree/model |awk -F, '{print $2}'`
fi
CPUCOUNT=`cat /proc/cpuinfo |grep "model name"|wc -l`
MEMORY=`cat /proc/meminfo |grep MemTotal|awk '{print $2}'`
# The MEMORY will look like this: 32868920
MEMORY=`cat /proc/meminfo |grep MemTotal|awk '{printf "%.0fMB\n", $2/1024}'`
# The MEMORY will look like this: 32GiB
#MEMORY=`lshw -C memory -short |grep "System Memory"|awk -F' ' '{print $3}'`
# The DISKSIZE will look like this: /dev/sda:250GB,/dev/sdb:250GB
#DISKSIZE=`lshw -C disk -short |grep disk |awk -F' ' '{print $2":"$4}'|sed 'N;s/\n/,/'`
# The DISKSIZE will look like this: sdb:250GB,sda:250GB
DISKSIZE=`cat /proc/partitions |grep -e "sd.\>" |awk -F' ' '{printf "%s:%.0fGB\n", $4, $3*0.000001024}' |sed 'N;s/\n/,/'`
UUID=`sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/' /sys/devices/virtual/dmi/id/product_uuid`
grep "model name" /proc/cpuinfo | while read line; do #to avoid pulling in tail, we do a goofy thing
echo $line > /tmp/cpumod
@ -90,6 +100,7 @@ fi
echo "<cpucount>$CPUCOUNT</cpucount>" >> /tmp/discopacket
echo "<cputype>$CPUTYPE</cputype>" >> /tmp/discopacket
echo "<memory>$MEMORY</memory>" >> /tmp/discopacket
echo "<disksize>$DISKSIZE</disksize>" >> /tmp/discopacket
echo "<uuid>$UUID</uuid>" >> /tmp/discopacket
if [ "$MTM" != "unknown" ]; then
echo "<mtm>$MTM</mtm>" >> /tmp/discopacket

View File

@ -153,6 +153,27 @@ sub process_request {
$vpdtab->setNodeAttribs($node,{serial=>$request->{serial}->[0]});
}
}
# save basic capacities in the capacity table
if (defined($request->{cpucount}) or defined($request->{cputype}) or defined($request->{memory}) or defined($request->{disksize})) {
my $basicdata;
my $cap_tab = xCAT::Table->new("capacity",-create=>1);
if ($request->{memory}->[0]) {
$basicdata->{memory} = $request->{memory}->[0];
}
if ($request->{disksize}->[0]) {
$basicdata->{disksize} = $request->{disksize}->[0];
}
if ($request->{cpucount}->[0]) {
$basicdata->{cpucount} = $request->{cpucount}->[0];
}
if ($request->{cputype}->[0]) {
$basicdata->{cputype} = $request->{cputype}->[0];
}
$cap_tab->setNodeAttribs($node, $basicdata);
}
my $nrtab;
my @discoverynics;
my @forcenics; #list of 'eth' style interface names to require to come up on post-discovery client dhcp restart