summaryrefslogtreecommitdiffstats
path: root/config-db/OpenSLX/DBSchema.pm
blob: 467a88cd8b4a74f5c0f741fdd5dd455c55f37f3d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# DBSchema.pm - provides database schema of the OpenSLX config-db.
#
# (c) 2006 - OpenSLX.com
#
# Oliver Tappe <ot@openslx.com>
#
package OpenSLX::DBSchema;

use strict;
use vars qw(@ISA @EXPORT $VERSION);

use Exporter;
$VERSION = 0.01;
@ISA = qw(Exporter);

@EXPORT = qw(
	$DbSchema %DbSchemaHistory
);

use vars qw($DbSchema %DbSchemaHistory);

# configurable attributes for system, client and group:
my @sharedAttributes = (
	'attr_desktop_session:s.128',
	'attr_hw_graphic:s.64',
	'attr_hw_monitor:s.64',
	'attr_hw_mouse:s.64',
	'attr_language:s.64',
	'attr_netbios_workgroup:s.64',
	'attr_start_rwhod:b',
	'attr_start_snmp:b',
	'attr_start_x:s.64',
	'attr_start_xdmcp:s.64',
	'attr_auth_type:s.64'
	'attr_home_type:s.64'
	'attr_tex_enable:b',
	'attr_vmware:b',
);

################################################################################
### DB-schema definition
### 	This hash-ref describes the current OpenSLX configuration database schema.
### 	Each table is defined by a list of column descriptions.
### 	A column description is simply the name of the column followed by ':'
### 	followed by the data type description. The following data types are
### 	currently supported:
### 		b		=> boolean (providing the values 1 and 0 only)
### 		i		=> integer (32-bit, signed)
### 		s.20	=> string, followed by length argument (in this case: 20)
### 		pk		=> primary key (integer)
### 		fk		=> foreign key (integer)
################################################################################

$DbSchema = {
	'version' => $VERSION,
	'tables' => {
		'meta' => [
			# information about the database as such
			'schema_version:s.5',	# schema-version currently implemented by DB
		],
		'vendor_os' => [
			# a vendor os describes a folder containing an operating system as
			# provided by the vendor (a.k.a. unchanged and thus updatable)
			'id:pk',			# primary key
			'name:s.48',		# structured name of OS installation
								# (e.g. suse-9.3-minimal, suse-9.3-kde,
								# debian-3.1-ppc)
			'comment:s.1024',	# internal comment (optional, for admins)
			'path:s.256',		# path to os filesystem root
		],
		'system' => [
			# a system describes one bootable instance of a vendor os
			'id:pk',				# primary key
			'vendor_os_id:fk',		# foreign key
			'name:s.48',			# name used in filesystem and passed to
									# kernel via cmdline arg (e.g.:
									# suse-9.3-minimal, suse-9.3-minimal-nbd...)
			'label:s.128',			# name visible to user (pxe-label)
			'comment:s.1024',		# internal comment (optional, for admins)
			'export_type:s.10',		# 'nbd', 'nbd-squash', 'nfs', ...
			'export_uri:s.256',		# path to export (NDB-image or NFS-path), if
									# empty it will be auto-generated by
									# config-demuxer
			'kernel:s.128',			# path to kernel file, relative to OS root
			'kernel_params:s.512',	# kernel-param string for pxe
			'ramfs_debug_level:i',	# debug level for initramfs-generator-script
			'ramfs_use_glibc:b',	# use glibc in ramfs
			'ramfs_use_busybox:b',	# use busybox in ramfs
			'ramfs_nicmods:s.128',	# list of network interface card modules
			'ramfs_fsmods:s.128',	# list of filesystem modules
			'ramfs_screen:s.10',	# screen size for splash
			'hidden:b',				# hidden systems won't be offered for booting
			@sharedAttributes,
		],
		'system_variant' => [
			# a system_variant describes an alternative boot setup for a system
			# which will always be offered if the systems itself is offered by
			# a client
			'id:pk',				# primary key
			'name_addition:s.48',	# string added to system name in order to
									# get a unique system name
			'system_id:fk',			# foreign key
			'label_addition:s.64',	# visible name part (added to pxe-label)
			'comment:s.1024',		# internal comment (optional, for admins)
			'kernel:s.128',			# name of kernel file
			'kernel_params:s.512',	# kernel-param string for pxe
			'ramfs_debug_level:i',	# debug level for initramfs-generator-script
			'ramfs_use_glibc:b',	# use glibc in ramfs
			'ramfs_use_busybox:b',	# use busybox in ramfs
			'ramfs_nicmods:s.128',	# list of network interface card modules
			'ramfs_fsmods:s.128',	# list of filesystem modules
			'ramfs_screen:s.10',	# screen size for splash
		],
		'client' => [
			# a client is a PC booting via network
			'id:pk',			# primary key
			'name:s.128',		# official name of PC (e.g. as given by sticker
								# on case)
			'mac:s.20',			# MAC of NIC used for booting
			'comment:s.1024',	# internal comment (optional, for admins)
			'boot_type:s.20',	# type of remote boot procedure (PXE, ...)
			'unbootable:b',		# unbootable clients simply won't boot
			'kernel_params:s.128',	# client-specific kernel-args (e.g. console)
			@sharedAttributes,
		],
		'client_system_ref' => [
			# clients referring to the systems they should offer for booting
			'client_id:fk',		# foreign key
			'system_id:fk',		# foreign key
		],
		'groups' => [
			# a group encapsulates a set of clients as one entity, managing
			# a group-specific attribute set. All the different attribute
			# sets a client inherits via group membership are folded into
			# one resulting attribute set with respect to each group's priority.
			'id:pk',			# primary key
			'name:s.128',		# name of group
			'comment:s.1024',	# internal comment (optional, for admins)
			'priority:i',		# priority, used for order in group-list
								# (from 0-lowest to 10-highest)
			@sharedAttributes,
		],
		'group_client_ref' => [
			# groups referring to their clients
			'group_id:fk',		# foreign key
			'client_id:fk',		# foreign key
		],
		'group_system_ref' => [
			# groups referring to the systems each of their clients should
			# offer for booting
			'group_id:fk',		# foreign key
			'system_id:fk',		# foreign key
		],
		'settings' => [
			# system-wide settings
			'use_absolute_tftp:b',
								# whether or not the TFTP-server requires the
								# use of absolute path names
			'default_nicmods:s.256',
								# list of default network modules
		],
	},
};

################################################################################
### DB-schema history
### 	This hash contains a description of all the different changes that have
### 	taken place on the schema. Each version contains a changeset (array)
### 	with the commands that take the schema from the last version to the
### 	current.
### 	The following 'cmd'-types are supported:
### 		add-table => creates a new table
### 			'table' => contains the name of the new table
### 			'cols'	=> contains a list of column descriptions
### 			'vals'	=> optional, contains list of data hashes to be inserted
### 					   into new table
### 		drop-table => drops an existing table
### 			'table	=> contains the name of the table to be dropped
### 		rename-table => renames a table
### 			'old-table' => contains the old name of the table
### 			'new-table' => contains the new name of the table
### 		add-columns => adds columns to a table
### 			'table' => the name of the table the columns should be added to
### 			'new-cols' => contains a list of new column descriptions
### 			'new-default-vals' => optional, a list of data hashes to be used
###							 		  as default values for the new columns
### 			'cols' => contains a list of column descriptions
### 		drop-columns => drops columns from a table
### 			'table' => the name of the table the columns should be dropped from
### 			'col-changes' => a hash with changed column descriptions
### 			'cols'	=> contains a full list of resulting column descriptions
################################################################################

%DbSchemaHistory = (
	'0.01' => [
		# the initial schema version simply adds a couple of tables:
		{
			'cmd' => 'add-table',
			'table' => 'meta',
			'cols' => $DbSchema->{'tables'}->{'meta'},
			'vals' => [
				{	# add initial meta info
					'schema_version' => $DbSchema->{'version'},
				},
			],
		},
		{
			'cmd' => 'add-table',
			'table' => 'vendor_os',
			'cols' => $DbSchema->{'tables'}->{'vendor_os'},
		},
		{
			'cmd' => 'add-table',
			'table' => 'system',
			'cols' => $DbSchema->{'tables'}->{'system'},
			'vals' => [
				{	# add default system
					'id' => 0,
					'name' => '<<<default>>>',
					'comment' => 'internal system that holds default values',
				},
			],
		},
		{
			'cmd' => 'add-table',
			'table' => 'system_variant',
			'cols' => $DbSchema->{'tables'}->{'system_variant'},
		},
		{
			'cmd' => 'add-table',
			'table' => 'client',
			'cols' => $DbSchema->{'tables'}->{'client'},
			'vals' => [
				{	# add default client
					'id' => 0,
					'name' => '<<<default>>>',
					'comment' => 'internal client that holds default values',
				},
			],
		},
		{
			'cmd' => 'add-table',
			'table' => 'client_system_ref',
			'cols' => $DbSchema->{'tables'}->{'client_system_ref'},
		},
		{
			'cmd' => 'add-table',
			'table' => 'groups',
			'cols' => $DbSchema->{'tables'}->{'groups'},
		},
		{
			'cmd' => 'add-table',
			'table' => 'group_client_ref',
			'cols' => $DbSchema->{'tables'}->{'group_client_ref'},
		},
		{
			'cmd' => 'add-table',
			'table' => 'group_system_ref',
			'cols' => $DbSchema->{'tables'}->{'group_system_ref'},
		},
		{
			'cmd' => 'add-table',
			'table' => 'settings',
			'cols' => $DbSchema->{'tables'}->{'settings'},
			'vals' => [
				{	# add default configuration
					'use_absolute_tftp' => '0',
					'default_nicmods'
						=> 'forcedeth e1000 e100 tg3 via-rhine r8169 pcnet32',
				},
			],
		},
	],
);