Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 372 lines (341 sloc) 10.309 kb
a3a7c2b @lattera Initial commit
authored
1 <?php
2
3 function jailadmin_schema() {
4 $schema['jailadmin_jails'] = array(
5 'description' => 'Configured jails',
6 'fields' => array(
7 'name' => array(
8 'type' => 'varchar',
9 'length' => 100,
10 'not null' => TRUE
11 ),
12 'dataset' => array(
13 'type' => 'varchar',
14 'length' => 500,
15 'not null' => TRUE,
16 ),
5895b35 @lattera Add autoboot schema
authored
17 'autoboot' => array(
18 'type' => 'int',
19 'not null' => TRUE,
20 'default' => 0,
21 ),
2e5e974 @lattera Properly set jail hostname
authored
22 'hostname' => array(
23 'type' => 'varchar',
24 'length' => 253,
25 'not null' => TRUE,
26 ),
a3a7c2b @lattera Initial commit
authored
27 ),
28 'primary key' => array('name'),
29 );
30
1eae741 @lattera Grab the jail's path via ZFS
authored
31 $schema['jailadmin_host_cmds'] = array(
32 'description' => 'Commands to run in the host after the jail is online',
33 'fields' => array(
34 'jail' => array(
35 'type' => 'varchar',
36 'length' => 100,
37 'not null' => TRUE,
38 ),
39 'command' => array(
40 'type' => 'varchar',
41 'length' => 500,
42 'not null' => TRUE,
43 ),
44 ),
45 );
46
a3a7c2b @lattera Initial commit
authored
47 $schema['jailadmin_bridges'] = array(
48 'description' => 'Configured bridges',
49 'fields' => array(
50 'name' => array(
51 'type' => 'varchar',
52 'length' => 100,
53 'not null' => TRUE,
54 ),
55 'device' => array(
56 'type' => 'varchar',
57 'length' => 20,
58 'not null' => TRUE,
59 ),
60 ),
61 'primary key' => array('name'),
62 );
63
913284d @lattera Fix bug when selecting network. Add support for adding physical devices ...
authored
64 $schema['jailadmin_bridge_physicals'] = array(
65 'description' => 'Physical devices to include in the bridge',
66 'fields' => array(
67 'bridge' => array(
68 'type' => 'varchar',
69 'length' => 100,
70 'not null' => TRUE,
71 ),
72 'device' => array(
73 'type' => 'varchar',
74 'length' => 20,
75 'not null' => TRUE
76 ),
77 ),
78 'primary key' => array('bridge', 'device'),
79 );
80
a3a7c2b @lattera Initial commit
authored
81 $schema['jailadmin_services'] = array(
82 'description' => 'Services to start when starting the jail',
83 'fields' => array(
84 'id' => array(
85 'type' => 'serial',
86 'not null' => TRUE,
87 ),
88 'path' => array(
89 'type' => 'varchar',
90 'length' => 500,
91 'not null' => TRUE,
92 ),
93 'jail' => array(
94 'type' => 'varchar',
95 'length' => 100,
96 'not null' => TRUE,
97 ),
98 ),
99 'primary key' => array('id'),
100 'indexes' => array(
101 'jail_index' => array('jail'),
102 ),
103 );
104
105 $schema['jailadmin_epairs'] = array(
106 'description' => 'Virtual NICs assigned to configured jails',
107 'fields' => array(
108 'device' => array(
109 'type' => 'varchar',
110 'length' => 20,
111 'not null' => TRUE,
112 ),
113 'jail' => array(
114 'type' => 'varchar',
115 'length' => 100,
116 'not null' => TRUE,
117 ),
118 'bridge' => array(
119 'type' => 'varchar',
120 'length' => 100,
121 'not null' => TRUE,
122 ),
df14a24 @lattera Add support for DHCP
authored
123 'is_span' => array(
124 'type' => 'int',
a3a7c2b @lattera Initial commit
authored
125 'not null' => TRUE,
df14a24 @lattera Add support for DHCP
authored
126 'default' => 0,
a3a7c2b @lattera Initial commit
authored
127 ),
df14a24 @lattera Add support for DHCP
authored
128 'dhcp' => array(
3db2b6d @lattera Add ability to set epair devices as span devices inside the bridged netw...
authored
129 'type' => 'int',
130 'not null' => TRUE,
131 'default' => 0,
132 ),
a3a7c2b @lattera Initial commit
authored
133 ),
134 'primary key' => array('device'),
135 'indexes' => array(
136 'jail_index' => array('jail'),
137 'bridge_index' => array('bridge'),
138 ),
139 );
140
abfe2c8 @lattera Add basic support for IP aliases and IPv6. Jail epair device config is r...
authored
141 $schema['jailadmin_epair_aliases'] = array(
142 'description' => 'IP aliases for an epair device',
143 'fields' => array(
144 'device' => array(
145 'type' => 'varchar',
146 'length' => 20,
147 'not null' => TRUE,
148 ),
149 'ip' => array(
150 'type' => 'varchar',
151 'length' => 45,
152 'not null' => TRUE,
153 ),
154 ),
155 );
156
157 $schema['jailadmin_bridge_aliases'] = array(
158 'description' => 'IP aliases for an epair device',
159 'fields' => array(
160 'device' => array(
161 'type' => 'varchar',
162 'length' => 20,
163 'not null' => TRUE,
164 ),
165 'ip' => array(
166 'type' => 'varchar',
167 'length' => 45,
168 'not null' => TRUE,
169 ),
170 ),
171 );
172
173 $schema['jailadmin_routes'] = array(
174 'description' => 'IPv4 and IPv6 routes to add upon jail bootup',
175 'fields' => array(
176 'jail' => array(
177 'type' => 'varchar',
178 'length' => '100',
179 'not null' => TRUE,
180 ),
181 'source' => array(
182 'type' => 'varchar',
183 'length' => 45,
184 'not null' => TRUE,
185 ),
186 'destination' => array(
187 'type' => 'varchar',
188 'length' => 45,
189 'not null' => TRUE,
190 ),
191 ),
192 );
193
e390e79 @lattera Add support for registering templates
authored
194 $schema['jailadmin_templates'] = array(
195 'description' => 'ZFS Templates',
196 'fields' => array(
197 'name' => array(
198 'type' => 'varchar',
199 'length' => 100,
200 'not null' => TRUE,
201 ),
202 'snapshot' => array(
203 'type' => 'varchar',
204 'length' => 500,
205 'not null' => TRUE,
206 ),
207 ),
208 'primary key' => array('name'),
209 );
210
7683128 @lattera Add support for custom mounts
authored
211 $schema['jailadmin_mounts'] = array(
212 'description' => 'Custom mounts',
213 'fields' => array(
214 'id' => array(
215 'type' => 'serial',
216 'not null' => TRUE,
217 ),
218 'jail' => array(
219 'type' => 'varchar',
220 'length' => 100,
221 'not null' => TRUE,
222 ),
223 'target' => array(
224 'type' => 'varchar',
225 'length' => 500,
226 'not null' => TRUE,
227 ),
228 'source' => array(
229 'type' => 'varchar',
230 'length' => 500,
231 'not null' => TRUE,
232 ),
233 'driver' => array(
234 'type' => 'varchar',
235 'length' => 50,
236 ),
237 'options' => array(
238 'type' => 'varchar',
239 'length' => 200,
240 ),
241 ),
242 'primary key' => array('id'),
243 );
244
a3a7c2b @lattera Initial commit
authored
245 return $schema;
246 }
3db2b6d @lattera Add ability to set epair devices as span devices inside the bridged netw...
authored
247
248 function jailadmin_update_7001() {
249 $spec = array(
250 'type' => 'int',
251 'not null' => TRUE,
252 'default' => 0,
253 );
254
255 db_add_field('jailadmin_epairs', 'is_span', $spec);
256 }
1037f37 @lattera Add jailadmin_host_cmds table creation for updates
authored
257
258 function jailadmin_update_7002() {
259 $schema['jailadmin_host_cmds'] = array(
260 'description' => 'Commands to run in the host after the jail is online',
261 'fields' => array(
262 'jail' => array(
263 'type' => 'varchar',
264 'length' => 100,
265 'not null' => TRUE,
266 ),
267 'command' => array(
268 'type' => 'varchar',
269 'length' => 500,
270 'not null' => TRUE,
271 ),
272 ),
273 );
274
275 db_create_table('jailadmin_host_cmds', $schema['jailadmin_host_cmds']);
276 }
abfe2c8 @lattera Add basic support for IP aliases and IPv6. Jail epair device config is r...
authored
277
278 /**
279 * Add support for IP aliases and custom routes
280 */
281 function jailadmin_update_7003() {
282 db_create_table('jailadmin_routes', drupal_get_schema_unprocessed('jailadmin', 'jailadmin_routes'));
283 db_create_table('jailadmin_epair_aliases', drupal_get_schema_unprocessed('jailadmin', 'jailadmin_epair_aliases'));
284 db_create_table('jailadmin_bridge_aliases', drupal_get_schema_unprocessed('jailadmin', 'jailadmin_bridge_aliases'));
285
286 /* Port existing records over to new tables */
287 $result = db_select('jailadmin_epairs', 'je')
288 ->fields('je', array('ip', 'device'))
289 ->execute();
290
291 foreach ($result as $record) {
292 db_insert('jailadmin_epair_aliases')
293 ->fields(array(
294 'device' => $record->device,
295 'ip' => $record->ip,
296 ))->execute();
297 }
298
299 $result = db_select('jailadmin_bridges', 'je')
300 ->fields('je', array('ip', 'device'))
301 ->execute();
302
303 foreach ($result as $record) {
304 db_insert('jailadmin_bridge_aliases')
305 ->fields(array(
306 'device' => $record->device,
307 'ip' => $record->ip,
308 ))->execute();
309 }
310
311 $result = db_select('jailadmin_jails', 'j')
312 ->fields('j', array('name', 'route'))
313 ->execute();
314
315 foreach ($result as $record) {
316 db_insert('jailadmin_routes')
317 ->fields(array(
318 'jail' => $record->name,
319 'source' => 'default',
320 'destination' => $record->route,
321 ))->execute();
322 }
323 }
4d45148 @lattera Fix a couple bugs. Add ability to change SPAN settings.
authored
324
325 /**
326 * Drop unneeded fields
327 */
328 function jailadmin_update_7004() {
329 db_drop_field('jailadmin_epairs', 'ip');
330 db_drop_field('jailadmin_bridges', 'ip');
331 db_drop_field('jailadmin_jails', 'route');
332 }
df14a24 @lattera Add support for DHCP
authored
333
334 /**
335 * Add DHCP support
336 */
337 function jailadmin_update_7005() {
338 $spec = array(
339 'type' => 'int',
340 'not null' => TRUE,
341 'default' => 0,
342 );
343
344 db_add_field('jailadmin_epairs', 'dhcp', $spec);
345 }
5895b35 @lattera Add autoboot schema
authored
346
347 /**
348 * Add support for autobooting jails via jail daemon
349 */
350 function jailadmin_update_7006() {
351 $spec = array(
352 'type' => 'int',
353 'not null' => TRUE,
354 'default' => 0,
355 );
356
357 db_add_field('jailadmin_jails', 'autoboot', $spec);
358 }
2e5e974 @lattera Properly set jail hostname
authored
359
360 /**
361 * Properly set the hostname
362 */
363 function jailadmin_update_7007() {
364 $spec = array(
365 'type' => 'varchar',
366 'length' => 253,
367 'not null' => TRUE,
368 );
369
370 db_add_field('jailadmin_jails', 'hostname', $spec);
371 }
Something went wrong with that request. Please try again.