2009-01-09 22:25:35 +00:00
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
package xCAT_schema::Sample ;
#################################################################################
# This is a sample code that contains the user defined user database schema defination.
# Here is a list of things you can do to add DB tables to xCAT database.
2010-08-04 12:44:28 +00:00
# 1 Copy this file to /opt/xcat/lib/perl/xCAT_schema directory, rename it
# to your chosen schema name.
# 2 Change the word Sample above to be the same as the file name you chose.
2009-01-09 22:25:35 +00:00
# 3 Do NOT change the variable name "%tabspec".
2010-08-04 12:44:28 +00:00
# 4 x_lljob and x_llnode are the sample table names.
# jobid, status, node, jobstatus are the sample column names.
2009-01-22 00:55:55 +00:00
# Change them to your like. Please make sure all table names start with "x_".
2010-08-04 12:44:28 +00:00
# Each table must have a 'disable' and comments column.
2009-01-14 15:26:04 +00:00
# Please do not use SQL reserved words for your table names and column names.
# Use this site to check the reserved words:
# http://www.petefreitag.com/tools/sql_reserved_words_checker/
2010-08-18 16:24:07 +00:00
# 5 Change the keys.
2010-08-04 12:44:28 +00:00
# 6 Change the data types. For SQLite
# the default data type is TEXT if not specified.
2009-01-12 22:12:25 +00:00
# The supported data types are:
# REAL,CHAR,TEXT,DATE,TIME,FLOAT,BIGINT,DOUBLE,STRING,
2009-01-14 19:03:37 +00:00
# BINARY,DECIMAL,BOOLEAN,INTEGER,VARCHAR,SMALLINT,TIMESTAMP
# Please note that SQLight only supports: INTEGER, REAL, TEXT, BLOB.
2010-08-04 12:44:28 +00:00
# xCAT support MySQL, PostgreSQL and DB2 also, supported data types
# depend on the database you are using.
# 7 Change the table descriptions and column descriptions to your like.
# 8 Restart the the xcatd, the tables will be automatically generated.
# 9 If you have service nodes, copy all the files to those also and restart
# the daemon.
2010-08-19 11:40:51 +00:00
#
2009-01-09 22:25:35 +00:00
#
###############################################################################
% tabspec = (
2009-01-22 00:55:55 +00:00
x_lljob = > { #your table name should start with "x_".
2009-01-14 15:26:04 +00:00
cols = > [ qw( jobid status comments disable ) ] , #do not change 'disable' and 'comments', it is required by xCAT
2009-01-09 22:25:35 +00:00
keys = > [ qw( jobid ) ] ,
2010-08-16 20:08:47 +00:00
keys = > [ qw( jobid ) ] ,
2009-01-12 22:12:25 +00:00
required = > [ qw( jobid ) ] ,
types = > {
jobid = > 'INTEGER' ,
} ,
2009-01-09 22:25:35 +00:00
table_desc = > 'Stores jobs.' ,
descriptions = > {
jobid = > 'The job id.' ,
status = > 'The status of the job.' ,
2009-01-14 19:03:37 +00:00
comments = > 'Any user-written notes.' ,
2009-01-09 22:25:35 +00:00
disable = > "Set to 'yes' or '1' to comment out this row." ,
} ,
} ,
2009-01-22 00:55:55 +00:00
x_llnode = > {
2009-01-14 15:26:04 +00:00
cols = > [ qw( node jobid jobstatus cpu_usage comments disable ) ] ,
2009-01-09 22:25:35 +00:00
keys = > [ qw( node ) ] ,
2010-08-19 11:40:51 +00:00
foreignkeys = > [ qw( ( "node" ) REFERENCES x_lljob ( "node" ) ON DELETE CASCADE ) ] , # double quote are for db2, use backtics for mysql, noquotes for postgresal and sqlite. Tables with a Foreign key must not point to tables with a Foreign key or the tables may not be created in the correct order. Only one Foreign key per table is supported.
2009-01-12 22:12:25 +00:00
required = > [ qw( node jobid ) ] ,
types = > {
jobid = > 'INTEGER' ,
cpu_usage = > 'FLOAT' ,
} ,
2009-01-09 22:25:35 +00:00
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.' ,
2009-01-12 22:12:25 +00:00
cpu_usage = > 'The percent of cpu usage on the node.' ,
2009-01-14 19:03:37 +00:00
comments = > 'Any user-written notes.' ,
2009-01-09 22:25:35 +00:00
disable = > "Set to 'yes' or '1' to comment out this row." ,
} ,
} ,
) ; # end of tabspec definition
##################################################################
# The following %defspec is OPTIONAL. You only need to define it
# if you want your tables to work with xCAT object abstraction layer
# commands such as lsdef, mkdef, chdef and rmdef.
#
# Note: The xCAT database accessting commands such as
# tabdump, chtab, gettab, nodels, nodeadd, nodech, etc.
# still work without it.
2009-01-22 00:55:55 +00:00
#
# Please make sure that any new object name and attribute name
# should start with "x_".
2009-01-09 22:25:35 +00:00
##################################################################
% defspec = (
2009-01-22 00:55:55 +00:00
x_job = > { attrs = > [] , attrhash = > { } , objkey = > 'x_jobid' } , #create a new object called 'x_job',
2009-01-09 22:25:35 +00:00
) ;
2009-01-22 00:55:55 +00:00
#define the attribtues in the 'x_job' object using the x_lljob talbe columns.
@ { $ defspec { x_job } - > { 'attrs' } } =
2009-01-09 22:25:35 +00:00
(
2009-01-22 00:55:55 +00:00
{ attr_name = > 'x_jobid' ,
tabentry = > 'x_lljob.jobid' ,
access_tabentry = > 'x_lljob.jobid=attr:x_jobid' ,
2009-01-09 22:25:35 +00:00
} ,
2009-01-22 00:55:55 +00:00
{ attr_name = > 'x_status' ,
tabentry = > 'x_lljob.status' ,
access_tabentry = > 'x_lljob.jobid=attr:x_jobid' ,
2009-01-09 22:25:35 +00:00
} ,
) ;
#object 'node' already defined in /opt/xcat/lib/perl/xCAT/Schema.pm.
2009-01-22 00:55:55 +00:00
#Here we just add x_jobid and x_jobstatus attributes to the node object
2009-01-09 22:25:35 +00:00
@ { $ defspec { node } - > { 'attrs' } } =
(
2009-01-22 00:55:55 +00:00
{ attr_name = > 'x_jobid' ,
tabentry = > 'x_llnode.jobid' ,
access_tabentry = > 'x_llnode.node=attr:node' ,
2009-01-09 22:25:35 +00:00
} ,
2009-01-22 00:55:55 +00:00
{ attr_name = > 'x_jobstatus' ,
tabentry = > 'x_llnode.jobstatus' ,
access_tabentry = > 'x_llnode.node=attr:node' ,
2009-01-09 22:25:35 +00:00
} ,
2009-01-22 00:55:55 +00:00
{ attr_name = > 'x_cpu' ,
tabentry = > 'x_llnode.cpu_usage' ,
access_tabentry = > 'x_llnode.node=attr:node' ,
2009-01-12 22:12:25 +00:00
} ,
2009-01-09 22:25:35 +00:00
) ;
1 ;