From dd9da780a0234ea9c77a46e4a33ae6085d25007e Mon Sep 17 00:00:00 2001 From: linggao Date: Mon, 12 Jan 2009 22:12:25 +0000 Subject: [PATCH] added support for user plugable database table. Phase 2 git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2595 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Table.pm | 16 ++++++++---- xCAT-server/lib/xcat/schema/samples/Sample.pm | 26 ++++++++++++++++--- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index 9fe1abc5c..4ed6247b8 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -103,13 +103,19 @@ sub buildcreatestmt my $descr = shift; my $retv = "CREATE TABLE $tabn (\n "; my $col; + my $types=$descr->{types}; foreach $col (@{$descr->{cols}}) { - if (isAKey(\@{$descr->{keys}},$col)) { # keys need defined length - $retv .= "\"$col\" VARCHAR(128)"; - } else { - $retv .= "\"$col\" TEXT"; - } + if (($types) && ($types->{$col})) { + $retv .= "\"$col\"" . $types->{$col}; + } else { + if (isAKey(\@{$descr->{keys}},$col)) { # keys need defined length + $retv .= "\"$col\" VARCHAR(128)"; + } else { + $retv .= "\"$col\" TEXT"; + } + } + if (grep /^$col$/, @{$descr->{required}}) { $retv .= " NOT NULL"; diff --git a/xCAT-server/lib/xcat/schema/samples/Sample.pm b/xCAT-server/lib/xcat/schema/samples/Sample.pm index 97601a18d..be8c7101c 100644 --- a/xCAT-server/lib/xcat/schema/samples/Sample.pm +++ b/xCAT-server/lib/xcat/schema/samples/Sample.pm @@ -11,15 +11,23 @@ package xCAT_schema::Sample; # jobid, status, node, jobstatus are the column names. Change them to your like. # Each table must have a 'disable' column. # 5 change the keys -# 6 change the table descriptions and column descriptions to your like. -# 7 restart the the xcatd, the tables will be automatically generated. -# 8 do above steps on all the service nodes. +# 6 change the data types. The default data type is TEXT if not specified. +# The supported data types are: +# REAL,CHAR,TEXT,DATE,TIME,FLOAT,BIGINT,DOUBLE,STRING, +# BINARY,DECIMAL,BOOLEAN,INTEGER,VARCHAR,SMALLINT,TIMESTAMP +# 7 change the table descriptions and column descriptions to your like. +# 8 restart the the xcatd, the tables will be automatically generated. +# 9 copy the file to all the service nodes and restart the xcatd on all the service node. # ############################################################################### %tabspec = ( lljob => { cols => [qw(jobid status disable)], #do not change 'disable, it is required by xCAT keys => [qw(jobid)], + required => [qw(jobid)], + types => { + jobid => 'INTEGER', + }, table_desc => 'Stores jobs.', descriptions => { jobid => 'The job id.', @@ -28,13 +36,19 @@ package xCAT_schema::Sample; }, }, llnode => { - cols => [qw(node jobid jobstatus disable)], + cols => [qw(node jobid jobstatus cpu_usage disable)], keys => [qw(node)], + required => [qw(node jobid)], + types => { + jobid => 'INTEGER', + cpu_usage => 'FLOAT', + }, table_desc => 'Stores the node status.', descriptions => { node=> 'The node.', jobid => 'The job that runs on the node.', jobstatus => 'The status of the job on the node.', + cpu_usage => 'The percent of cpu usage on the node.', disable => "Set to 'yes' or '1' to comment out this row.", }, }, @@ -85,6 +99,10 @@ package xCAT_schema::Sample; tabentry => 'llnode.jobstatus', access_tabentry => 'llnode.node=attr:node', }, + { attr_name => 'cpu', + tabentry => 'llnode.cpu_usage', + access_tabentry => 'llnode.node=attr:node', + }, ); 1;