3 # This file is a part of RackTables, a datacenter and server room management
4 # framework. See accompanying file "COPYING" for the full copyright and
5 # licensing information.
7 function renderInstallerHTML()
9 $stepfunc[1] = 'not_already_installed';
10 $stepfunc[2] = 'platform_is_ok';
11 $stepfunc[3] = 'init_config';
12 $stepfunc[4] = 'init_database_static';
13 $stepfunc[5] = 'init_database_dynamic';
14 $stepfunc[6] = 'congrats';
16 if (isset ($_REQUEST['step']))
17 $step = $_REQUEST['step'];
21 if ($step > count ($stepfunc))
23 $root = (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] == 'off') ?
'http://' : 'https://';
24 $root .= isset ($_SERVER['HTTP_HOST']) ?
$_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].($_SERVER['SERVER_PORT']=='80'?
'':$_SERVER['SERVER_PORT']));
25 // "Since PHP 4.3.0, you will often get a slash or a dot back from
26 // dirname() in situations where the older functionality would have given
27 // you the empty string."
28 // "On Windows, both slash (/) and backslash (\) are used as directory
29 // separator character."
30 $root .= strtr (dirname ($_SERVER['PHP_SELF']), '\\', '/');
31 if (substr ($root, -1) != '/')
33 header ("Location: ${root}");
36 $title = "RackTables installation: step ${step} of " . count ($stepfunc);
37 header ('Content-Type: text/html; charset=UTF-8');
38 ?
><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
39 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en">
40 <head
><title
><?php
echo $title; ?
></title
>
41 <style type
="text/css">
47 background
-color
: #80FF80;
51 background
-color
: #FFFF80;
55 background
-color
: #FF8080;
62 echo "<h1>${title}</h1><p>";
64 echo "</p><form method=post>\n";
65 $testres = $stepfunc[$step] ();
68 $next_step = $step +
1;
69 echo "<br><input type=submit value='proceed'>";
74 echo "<br><input type=submit value='retry'>";
76 echo "<input type=hidden name=step value='${next_step}'>\n";
87 // Check if the software is already installed.
88 function not_already_installed()
90 global $found_secret_file, $pdo_dsn;
91 if ($found_secret_file and isset ($pdo_dsn))
93 echo 'Your configuration file exists and seems to hold necessary data already.<br>';
98 echo 'There seem to be no existing installation here, I am going to setup one now.<br>';
103 // Check that we can write to configuration file.
104 // If so, ask for DB connection paramaters and test
105 // the connection. Neither save the parameters nor allow
106 // going further until we succeed with the given
108 function init_config ()
113 $tcp_host = 'localhost',
115 $unix_socket = '/var/lib/mysql/mysql.sock',
116 $database = 'racktables_db',
117 $username = 'racktables_user',
121 echo "<input type=hidden name=save_config value=1>\n";
122 echo '<h3>Server-side MySQL setup of the database:</h3><div align=left><pre class=trok>';
123 echo "mysql>\nCREATE DATABASE racktables_db CHARACTER SET utf8 COLLATE utf8_general_ci;\n";
124 echo "GRANT ALL PRIVILEGES ON racktables_db.* TO racktables_user@localhost IDENTIFIED BY 'MY_SECRET_PASSWORD';\n</pre></div>";
126 echo '<tr><td><label for=conn_tcp>TCP connection</label></td>';
127 echo '<td><input type=radio name=conn value=conn_tcp id=conn_tcp' . ($use_tcp ?
' checked' : '') . '></td></tr>';
128 echo '<tr><td><label for=conn_unix>UNIX socket</label></td>';
129 echo '<td><input type=radio name=conn value=conn_unix id=conn_unix' . ($use_tcp ?
'' : ' checked') . '></td></tr>';
130 echo "<tr><td><label for=mysql_host>TCP host:</label></td>";
131 echo "<td><input type=text name=mysql_host id=mysql_host value='${tcp_host}'></td></tr>\n";
132 echo "<tr><td><label for=mysql_port>TCP port (if not 3306):</label></td>";
133 echo "<td><input type=text name=mysql_port id=mysql_port value='${tcp_port}'></td></tr>\n";
134 echo "<tr><td><label for=mysql_socket>UNIX socket:</label></td>";
135 echo "<td><input type=text name=mysql_socket id=mysql_socket value='${unix_socket}'></td></tr>\n";
136 echo "<tr><td><label for=mysql_db>database:</label></td>";
137 echo "<td><input type=text name=mysql_db id=mysql_db value='${database}'></td></tr>\n";
138 echo "<tr><td><label for=mysql_username>username:</label></td>";
139 echo "<td><input type=text name=mysql_username id=mysql_username value='${username}'></td></tr>\n";
140 echo "<tr><td><label for=mysql_password>password:</label></td>";
141 echo "<td><input type=password name=mysql_password id=mysql_password value='${password}'></td></tr>\n";
144 global $path_to_secret_php;
145 if (!is_writable ($path_to_secret_php))
147 echo "The $path_to_secret_php file is not writable by web-server. Make sure it is.";
148 echo "The following commands should suffice:<pre>touch '$path_to_secret_php'; chmod 666 '$path_to_secret_php'</pre>";
149 echo 'Fedora Linux with SELinux may require this file to be owned by specific user (apache) and/or executing "setenforce 0" for the time of installation. ';
150 echo 'SELinux may be turned back on with "setenforce 1" command.<br>';
153 if (! array_key_exists ('save_config', $_REQUEST))
158 if (empty ($_REQUEST['mysql_db']) or empty ($_REQUEST['mysql_username']))
162 $_REQUEST['conn'] == 'conn_tcp',
163 $_REQUEST['mysql_host'],
164 $_REQUEST['mysql_port'],
165 $_REQUEST['mysql_socket'],
166 $_REQUEST['mysql_db'],
167 $_REQUEST['mysql_username'],
168 $_REQUEST['mysql_password']
170 echo '<h2 class=trerror>Missing database/username parameter!</h2>';
173 if ($_REQUEST['conn'] == 'conn_tcp' and empty ($_REQUEST['mysql_host']))
177 $_REQUEST['conn'] == 'conn_tcp',
178 $_REQUEST['mysql_host'],
179 $_REQUEST['mysql_port'],
180 $_REQUEST['mysql_socket'],
181 $_REQUEST['mysql_db'],
182 $_REQUEST['mysql_username'],
183 $_REQUEST['mysql_password']
185 echo '<h2 class=trerror>Missing TCP hostname parameter!</h2>';
188 if ($_REQUEST['conn'] == 'conn_unix' and empty ($_REQUEST['mysql_socket']))
192 $_REQUEST['conn'] == 'conn_tcp',
193 $_REQUEST['mysql_host'],
194 $_REQUEST['mysql_port'],
195 $_REQUEST['mysql_socket'],
196 $_REQUEST['mysql_db'],
197 $_REQUEST['mysql_username'],
198 $_REQUEST['mysql_password']
200 echo '<h2 class=trerror>Missing UNIX socket parameter!</h2>';
203 # finally OK to make a connection attempt
205 switch ($_REQUEST['conn'])
208 $pdo_dsn .= 'host=' . $_REQUEST['mysql_host'];
209 if (!empty ($_REQUEST['mysql_port']) and $_REQUEST['mysql_port'] != '3306')
210 $pdo_dsn .= ';port=' . $_REQUEST['mysql_port'];
213 $pdo_dsn .= 'unix_socket=' . $_REQUEST['mysql_socket'];
217 echo '<h2 class=trerror>form error</h2>';
220 $pdo_dsn .= ';dbname=' . $_REQUEST['mysql_db'];
223 $dbxlink = new PDO ($pdo_dsn, $_REQUEST['mysql_username'], $_REQUEST['mysql_password']);
225 catch (PDOException
$e)
229 $_REQUEST['conn'] == 'conn_tcp',
230 $_REQUEST['mysql_host'],
231 $_REQUEST['mysql_port'],
232 $_REQUEST['mysql_socket'],
233 $_REQUEST['mysql_db'],
234 $_REQUEST['mysql_username'],
235 $_REQUEST['mysql_password']
237 echo "<h2 class=trerror>Datase connection failed. Check parameters and try again.</h2>\n";
238 echo "PDO DSN: <tt class=trwarning>${pdo_dsn}</tt><br>";
242 $conf = fopen ($path_to_secret_php, 'w+');
245 echo "Error: failed to open $path_to_secret_php for writing";
248 fwrite ($conf, "<?php\n# This file has been generated automatically by RackTables installer.\n");
249 fwrite ($conf, "\$pdo_dsn = '${pdo_dsn}';\n");
250 fwrite ($conf, "\$db_username = '" . $_REQUEST['mysql_username'] . "';\n");
251 fwrite ($conf, "\$db_password = '" . $_REQUEST['mysql_password'] . "';\n\n");
252 fwrite ($conf, <<<ENDOFTEXT
254 \$user_auth_src = 'database';
255 \$require_local_account = TRUE;
256 # Default setting is to authenticate users locally, but it is possible to
257 # employ existing LDAP or Apache user accounts. Check RackTables wiki for
258 # more information, in particular, this page for LDAP configuration details:
259 # http://sourceforge.net/apps/mediawiki/racktables/index.php?title=LDAP
261 #\$LDAP_options = array
263 # 'server' => 'localhost',
264 # 'domain' => 'example.com',
265 # 'search_attr' => '',
267 # // The following credentials will be used when searching for the user's DN:
268 # 'search_bind_rdn' => NULL,
269 # 'search_bind_password' => NULL,
270 # 'displayname_attrs' => '',
271 # 'options' => array (LDAP_OPT_PROTOCOL_VERSION => 3),
272 # 'use_tls' => 2, // 0 == don't attempt, 1 == attempt, 2 == require
275 # This HTML banner is intended to assist users in dispatching their issues
276 # to the local tech support service. Its text (in its verbatim form) will
277 # be appended to assorted error messages visible in user's browser (including
278 # "not authenticated" message). Beware of placing any sensitive information
279 # here, it will be readable by unauthorized visitors.
280 #\$helpdesk_banner = '<B>This RackTables instance is supported by Example Inc. IT helpdesk, dial ext. 1234 to report a problem.</B>';
285 fwrite ($conf, "?>\n");
287 echo "The configuration file has been written successfully.<br>";
291 function connect_to_db_or_die ()
297 catch (RackTablesError
$e)
299 die ('Error connecting to the database');
303 function init_database_static ()
305 connect_to_db_or_die();
307 if (!isInnoDBSupported())
309 echo 'InnoDB test failed! Please configure MySQL server properly and retry.';
312 $result = $dbxlink->query ('show tables');
313 $tables = $result->fetchAll (PDO
::FETCH_NUM
);
314 $result->closeCursor();
318 echo 'Your database is already holding ' . count ($tables);
319 echo ' tables, so I will stop here and let you check it yourself.<br>';
320 echo 'There is some important data there probably.<br>';
323 echo 'Initializing the database...<br>';
324 echo '<table border=1>';
325 echo "<tr><th>section</th><th>queries</th><th>errors</th></tr>";
327 foreach (array ('structure', 'dictbase') as $part)
329 echo "<tr><td>${part}</td>";
331 foreach (preg_split ("/;\s*\n/", get_pseudo_file ($part)) as $query)
333 $query = trim($query);
334 if (empty ($query) or '--' == substr ($query, 0, 2))
337 if ($dbxlink->exec ($query) === FALSE)
343 echo "<td>${nq}</td><td>${nerrs}</td></tr>\n";
345 // (re)load dictionary by pure PHP means w/o any external file
346 echo "<tr><td>dictionary</td>";
349 foreach (reloadDictionary() as $query)
352 if ($dbxlink->exec ($query) === FALSE)
358 echo "<td>${nq}</td><td>${nerrs}</td></tr>\n";
361 if (count ($errlist))
363 echo '<pre>The following queries failed:\n';
364 foreach ($errlist as $q)
372 function init_database_dynamic ()
374 connect_to_db_or_die();
376 if (!isset ($_REQUEST['password']) or empty ($_REQUEST['password']))
378 $result = $dbxlink->query ('select count(user_id) from UserAccount where user_id = 1');
379 $row = $result->fetch (PDO
::FETCH_NUM
);
381 $result->closeCursor();
384 echo '<table border=1>';
385 echo '<caption>Administrator password not set</caption>';
386 echo '<tr><td><input type=password name=password></td></tr>';
393 // Never send cleartext password over the wire.
394 $hash = sha1 ($_REQUEST['password']);
395 $query = "INSERT INTO `UserAccount` (`user_id`, `user_name`, `user_password_hash`, `user_realname`) " .
396 "VALUES (1,'admin','${hash}','RackTables Administrator')";
397 $result = $dbxlink->exec ($query);
398 echo "Administrator password has been set successfully.<br>";
405 echo 'Congratulations! RackTables installation is complete. After pressing Proceed you will ';
406 echo 'enter the system. Authenticate with <strong>admin</strong> username.<br>RackTables project has a ';
407 echo "<a href='http://sourceforge.net/apps/mediawiki/racktables/index.php?title=RackTablesAdminGuide'>";
408 echo "wiki</a> and a ";
409 echo "<a href='http://www.freelists.org/list/racktables-users'>mailing list</a> for users. Have fun.<br>";
413 function get_pseudo_file ($name)
418 return <<<END_OF_FILE
419 alter database character set utf8;
421 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
423 CREATE TABLE `Atom` (
424 `molecule_id` int(10) unsigned default NULL,
425 `rack_id` int(10) unsigned default NULL,
426 `unit_no` int(10) unsigned default NULL,
427 `atom` enum('front','interior','rear') default NULL
430 CREATE TABLE `Attribute` (
431 `id` int(10) unsigned NOT NULL auto_increment,
432 `type` enum('string','uint','float','dict','date') default NULL,
433 `name` char(64) default NULL,
435 UNIQUE KEY `name` (`name`)
438 CREATE TABLE `AttributeMap` (
439 `objtype_id` int(10) unsigned NOT NULL default '1',
440 `attr_id` int(10) unsigned NOT NULL default '1',
441 `chapter_id` int(10) unsigned default NULL,
442 UNIQUE KEY `objtype_id` (`objtype_id`,`attr_id`),
443 KEY `attr_id` (`attr_id`),
444 KEY `chapter_id` (`chapter_id`),
445 CONSTRAINT `AttributeMap-FK-chapter_id` FOREIGN KEY (`chapter_id`) REFERENCES `Chapter` (`id`),
446 CONSTRAINT `AttributeMap-FK-attr_id` FOREIGN KEY (`attr_id`) REFERENCES `Attribute` (`id`)
449 CREATE TABLE `AttributeValue` (
450 `object_id` int(10) unsigned default NULL,
451 -- Default value intentionally breaks the constraint, this blocks
452 -- any insertion, which doesn't have 'object_tid' on the column list.
453 `object_tid` int(10) unsigned NOT NULL default '0',
454 `attr_id` int(10) unsigned default NULL,
455 `string_value` char(255) default NULL,
456 `uint_value` int(10) unsigned default NULL,
457 `float_value` float default NULL,
458 UNIQUE KEY `object_id` (`object_id`,`attr_id`),
459 KEY `attr_id-uint_value` (`attr_id`,`uint_value`),
460 KEY `attr_id-string_value` (`attr_id`,`string_value`(12)),
461 KEY `id-tid` (`object_id`,`object_tid`),
462 KEY `object_tid-attr_id` (`object_tid`,`attr_id`),
463 CONSTRAINT `AttributeValue-FK-map` FOREIGN KEY (`object_tid`, `attr_id`) REFERENCES `AttributeMap` (`objtype_id`, `attr_id`),
464 CONSTRAINT `AttributeValue-FK-object` FOREIGN KEY (`object_id`, `object_tid`) REFERENCES `Object` (`id`, `objtype_id`) ON DELETE CASCADE ON UPDATE CASCADE
467 CREATE TABLE `CachedPAV` (
468 `object_id` int(10) unsigned NOT NULL,
469 `port_name` char(255) NOT NULL,
470 `vlan_id` int(10) unsigned NOT NULL default '0',
471 PRIMARY KEY (`object_id`,`port_name`,`vlan_id`),
472 KEY `vlan_id` (`vlan_id`),
473 CONSTRAINT `CachedPAV-FK-object-port` FOREIGN KEY (`object_id`, `port_name`) REFERENCES `CachedPVM` (`object_id`, `port_name`) ON DELETE CASCADE,
474 CONSTRAINT `CachedPAV-FK-vlan_id` FOREIGN KEY (`vlan_id`) REFERENCES `VLANValidID` (`vlan_id`)
477 CREATE TABLE `CachedPNV` (
478 `object_id` int(10) unsigned NOT NULL,
479 `port_name` char(255) NOT NULL,
480 `vlan_id` int(10) unsigned NOT NULL default '0',
481 PRIMARY KEY (`object_id`,`port_name`,`vlan_id`),
482 UNIQUE KEY `port_id` (`object_id`,`port_name`),
483 CONSTRAINT `CachedPNV-FK-compound` FOREIGN KEY (`object_id`, `port_name`, `vlan_id`) REFERENCES `CachedPAV` (`object_id`, `port_name`, `vlan_id`) ON DELETE CASCADE
486 CREATE TABLE `CachedPVM` (
487 `object_id` int(10) unsigned NOT NULL,
488 `port_name` char(255) NOT NULL,
489 `vlan_mode` enum('access','trunk') NOT NULL default 'access',
490 PRIMARY KEY (`object_id`,`port_name`),
491 CONSTRAINT `CachedPVM-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `Object` (`id`) ON DELETE CASCADE
494 CREATE TABLE `CactiGraph` (
495 `object_id` int(10) unsigned NOT NULL,
496 `graph_id` int(10) unsigned NOT NULL,
497 `caption` char(255) DEFAULT NULL,
498 PRIMARY KEY (`graph_id`),
499 KEY `object_id` (`object_id`),
500 CONSTRAINT `CactiGraph-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `Object` (`id`) ON DELETE CASCADE
503 CREATE TABLE `Chapter` (
504 `id` int(10) unsigned NOT NULL auto_increment,
505 `sticky` enum('yes','no') default 'no',
506 `name` char(128) NOT NULL,
508 UNIQUE KEY `name` (`name`)
511 CREATE TABLE `Config` (
512 `varname` char(32) NOT NULL,
513 `varvalue` text NOT NULL,
514 `vartype` enum('string','uint') NOT NULL default 'string',
515 `emptyok` enum('yes','no') NOT NULL default 'no',
516 `is_hidden` enum('yes','no') NOT NULL default 'yes',
517 `is_userdefined` enum('yes','no') NOT NULL default 'no',
519 PRIMARY KEY (`varname`)
522 CREATE TABLE `Dictionary` (
523 `chapter_id` int(10) unsigned NOT NULL,
524 `dict_key` int(10) unsigned NOT NULL auto_increment,
525 `dict_value` char(255) default NULL,
526 PRIMARY KEY (`dict_key`),
527 UNIQUE KEY `chap_to_val` (`chapter_id`,`dict_value`),
528 CONSTRAINT `Dictionary-FK-chapter_id` FOREIGN KEY (`chapter_id`) REFERENCES `Chapter` (`id`)
531 CREATE TABLE `EntityLink` (
532 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
533 `parent_entity_type` enum('ipv4net','ipv4rspool','ipv4vs','ipv6net','location','object','rack','row','user') NOT NULL,
534 `parent_entity_id` int(10) unsigned NOT NULL,
535 `child_entity_type` enum('file','location','object','rack','row') NOT NULL,
536 `child_entity_id` int(10) unsigned NOT NULL,
538 UNIQUE KEY `EntityLink-unique` (`parent_entity_type`,`parent_entity_id`,`child_entity_type`,`child_entity_id`),
539 KEY `EntityLink-compound` (`parent_entity_type`,`child_entity_type`,`child_entity_id`)
542 CREATE TABLE `File` (
543 `id` int(10) unsigned NOT NULL auto_increment,
544 `name` char(255) NOT NULL,
545 `type` char(255) NOT NULL,
546 `size` int(10) unsigned NOT NULL,
547 `ctime` datetime NOT NULL,
548 `mtime` datetime NOT NULL,
549 `atime` datetime NOT NULL,
550 `thumbnail` longblob,
551 `contents` longblob NOT NULL,
554 UNIQUE KEY `name` (`name`)
557 CREATE TABLE `FileLink` (
558 `id` int(10) unsigned NOT NULL auto_increment,
559 `file_id` int(10) unsigned NOT NULL,
560 `entity_type` enum('ipv4net','ipv4rspool','ipv4vs','ipv6net','location','object','rack','user') NOT NULL default 'object',
561 `entity_id` int(10) NOT NULL,
563 KEY `FileLink-file_id` (`file_id`),
564 UNIQUE KEY `FileLink-unique` (`file_id`,`entity_type`,`entity_id`),
565 CONSTRAINT `FileLink-File_fkey` FOREIGN KEY (`file_id`) REFERENCES `File` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
568 CREATE TABLE `IPv4Address` (
569 `ip` int(10) unsigned NOT NULL default '0',
570 `name` char(255) NOT NULL default '',
571 `reserved` enum('yes','no') default NULL,
575 CREATE TABLE `IPv4Allocation` (
576 `object_id` int(10) unsigned NOT NULL default '0',
577 `ip` int(10) unsigned NOT NULL default '0',
578 `name` char(255) NOT NULL default '',
579 `type` enum('regular','shared','virtual','router') NOT NULL DEFAULT 'regular',
580 PRIMARY KEY (`object_id`,`ip`),
582 CONSTRAINT `IPv4Allocation-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `Object` (`id`) ON DELETE CASCADE
585 CREATE TABLE `IPv4LB` (
586 `object_id` int(10) unsigned default NULL,
587 `rspool_id` int(10) unsigned default NULL,
588 `vs_id` int(10) unsigned default NULL,
589 `prio` varchar(255) default NULL,
592 UNIQUE KEY `LB-VS` (`object_id`,`vs_id`),
593 KEY `IPv4LB-FK-rspool_id` (`rspool_id`),
594 KEY `IPv4LB-FK-vs_id` (`vs_id`),
595 CONSTRAINT `IPv4LB-FK-vs_id` FOREIGN KEY (`vs_id`) REFERENCES `IPv4VS` (`id`),
596 CONSTRAINT `IPv4LB-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `Object` (`id`),
597 CONSTRAINT `IPv4LB-FK-rspool_id` FOREIGN KEY (`rspool_id`) REFERENCES `IPv4RSPool` (`id`)
600 CREATE TABLE `IPv4Log` (
601 `id` int(10) NOT NULL AUTO_INCREMENT,
602 `ip` int(10) unsigned NOT NULL,
603 `date` datetime NOT NULL,
604 `user` varchar(64) NOT NULL,
605 `message` text NOT NULL,
607 KEY `ip-date` (`ip`,`date`)
610 CREATE TABLE `IPv6Log` (
611 `id` int(10) NOT NULL AUTO_INCREMENT,
612 `ip` binary(16) NOT NULL,
613 `date` datetime NOT NULL,
614 `user` varchar(64) NOT NULL,
615 `message` text NOT NULL,
617 KEY `ip-date` (`ip`,`date`)
620 CREATE TABLE `IPv4NAT` (
621 `object_id` int(10) unsigned NOT NULL default '0',
622 `proto` enum('TCP','UDP') NOT NULL default 'TCP',
623 `localip` int(10) unsigned NOT NULL default '0',
624 `localport` smallint(5) unsigned NOT NULL default '0',
625 `remoteip` int(10) unsigned NOT NULL default '0',
626 `remoteport` smallint(5) unsigned NOT NULL default '0',
627 `description` char(255) default NULL,
628 PRIMARY KEY (`object_id`,`proto`,`localip`,`localport`,`remoteip`,`remoteport`),
629 KEY `localip` (`localip`),
630 KEY `remoteip` (`remoteip`),
631 KEY `object_id` (`object_id`),
632 CONSTRAINT `IPv4NAT-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `Object` (`id`)
635 CREATE TABLE `IPv4Network` (
636 `id` int(10) unsigned NOT NULL auto_increment,
637 `ip` int(10) unsigned NOT NULL default '0',
638 `mask` int(10) unsigned NOT NULL default '0',
639 `name` char(255) default NULL,
642 UNIQUE KEY `base-len` (`ip`,`mask`)
645 CREATE TABLE `IPv4RS` (
646 `id` int(10) unsigned NOT NULL auto_increment,
647 `inservice` enum('yes','no') NOT NULL default 'no',
648 `rsip` varbinary(16) NOT NULL,
649 `rsport` smallint(5) unsigned default NULL,
650 `rspool_id` int(10) unsigned default NULL,
652 `comment` varchar(255) DEFAULT NULL,
655 UNIQUE KEY `pool-endpoint` (`rspool_id`,`rsip`,`rsport`),
656 CONSTRAINT `IPv4RS-FK` FOREIGN KEY (`rspool_id`) REFERENCES `IPv4RSPool` (`id`) ON DELETE CASCADE
659 CREATE TABLE `IPv4RSPool` (
660 `id` int(10) unsigned NOT NULL auto_increment,
661 `name` char(255) default NULL,
667 CREATE TABLE `IPv4VS` (
668 `id` int(10) unsigned NOT NULL auto_increment,
669 `vip` varbinary(16) NOT NULL,
670 `vport` smallint(5) unsigned default NULL,
671 `proto` enum('TCP','UDP','MARK') NOT NULL default 'TCP',
672 `name` char(255) default NULL,
679 CREATE TABLE `IPv6Address` (
680 `ip` binary(16) NOT NULL,
681 `name` char(255) NOT NULL default '',
682 `reserved` enum('yes','no') default NULL,
686 CREATE TABLE `IPv6Allocation` (
687 `object_id` int(10) unsigned NOT NULL default '0',
688 `ip` binary(16) NOT NULL,
689 `name` char(255) NOT NULL default '',
690 `type` enum('regular','shared','virtual','router') NOT NULL DEFAULT 'regular',
691 PRIMARY KEY (`object_id`,`ip`),
693 CONSTRAINT `IPv6Allocation-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `Object` (`id`) ON DELETE CASCADE
696 CREATE TABLE `IPv6Network` (
697 `id` int(10) unsigned NOT NULL auto_increment,
698 `ip` binary(16) NOT NULL,
699 `mask` int(10) unsigned NOT NULL,
700 `last_ip` binary(16) NOT NULL,
701 `name` char(255) default NULL,
704 UNIQUE KEY `ip` (`ip`,`mask`)
707 CREATE TABLE `LDAPCache` (
708 `presented_username` char(64) NOT NULL,
709 `successful_hash` char(40) NOT NULL,
710 `first_success` timestamp NOT NULL default CURRENT_TIMESTAMP,
711 `last_retry` timestamp NOT NULL default '0000-00-00 00:00:00',
712 `displayed_name` char(128) default NULL,
714 UNIQUE KEY `presented_username` (`presented_username`),
715 KEY `scanidx` (`presented_username`,`successful_hash`)
718 CREATE TABLE `Link` (
719 `porta` int(10) unsigned NOT NULL default '0',
720 `portb` int(10) unsigned NOT NULL default '0',
721 `cable` char(64) DEFAULT NULL,
722 PRIMARY KEY (`porta`,`portb`),
723 UNIQUE KEY `porta` (`porta`),
724 UNIQUE KEY `portb` (`portb`),
725 CONSTRAINT `Link-FK-a` FOREIGN KEY (`porta`) REFERENCES `Port` (`id`) ON DELETE CASCADE,
726 CONSTRAINT `Link-FK-b` FOREIGN KEY (`portb`) REFERENCES `Port` (`id`) ON DELETE CASCADE
729 CREATE TABLE `Molecule` (
730 `id` int(10) unsigned NOT NULL auto_increment,
734 CREATE TABLE `MountOperation` (
735 `id` int(10) unsigned NOT NULL auto_increment,
736 `object_id` int(10) unsigned NOT NULL default '0',
737 `ctime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
738 `user_name` char(64) default NULL,
739 `old_molecule_id` int(10) unsigned default NULL,
740 `new_molecule_id` int(10) unsigned default NULL,
743 KEY `object_id` (`object_id`),
744 CONSTRAINT `MountOperation-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `Object` (`id`) ON DELETE CASCADE
747 CREATE TABLE `ObjectLog` (
748 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
749 `object_id` int(10) unsigned NOT NULL,
750 `user` char(64) NOT NULL,
751 `date` datetime NOT NULL,
752 `content` text NOT NULL,
754 KEY `object_id` (`object_id`),
756 CONSTRAINT `ObjectLog-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `Object` (`id`) ON DELETE CASCADE
759 CREATE TABLE `ObjectParentCompat` (
760 `parent_objtype_id` int(10) unsigned NOT NULL,
761 `child_objtype_id` int(10) unsigned NOT NULL,
762 UNIQUE KEY `parent_child` (`parent_objtype_id`,`child_objtype_id`)
765 CREATE TABLE `Port` (
766 `id` int(10) unsigned NOT NULL auto_increment,
767 `object_id` int(10) unsigned NOT NULL default '0',
768 `name` char(255) NOT NULL default '',
769 `iif_id` int(10) unsigned NOT NULL,
770 `type` int(10) unsigned NOT NULL default '0',
771 `l2address` char(64) default NULL,
772 `reservation_comment` char(255) default NULL,
773 `label` char(255) default NULL,
775 UNIQUE KEY `object_iif_oif_name` (`object_id`,`iif_id`,`type`,`name`),
777 KEY `comment` (`reservation_comment`),
778 KEY `l2address` (`l2address`),
779 KEY `Port-FK-iif-oif` (`iif_id`,`type`),
780 CONSTRAINT `Port-FK-iif-oif` FOREIGN KEY (`iif_id`, `type`) REFERENCES `PortInterfaceCompat` (`iif_id`, `oif_id`),
781 CONSTRAINT `Port-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `Object` (`id`) ON DELETE CASCADE
784 CREATE TABLE `PortAllowedVLAN` (
785 `object_id` int(10) unsigned NOT NULL,
786 `port_name` char(255) NOT NULL,
787 `vlan_id` int(10) unsigned NOT NULL default '0',
788 PRIMARY KEY (`object_id`,`port_name`,`vlan_id`),
789 KEY `vlan_id` (`vlan_id`),
790 CONSTRAINT `PortAllowedVLAN-FK-object-port` FOREIGN KEY (`object_id`, `port_name`) REFERENCES `PortVLANMode` (`object_id`, `port_name`) ON DELETE CASCADE,
791 CONSTRAINT `PortAllowedVLAN-FK-vlan_id` FOREIGN KEY (`vlan_id`) REFERENCES `VLANValidID` (`vlan_id`)
794 CREATE TABLE `PortCompat` (
795 `type1` int(10) unsigned NOT NULL default '0',
796 `type2` int(10) unsigned NOT NULL default '0',
797 UNIQUE KEY `type1_2` (`type1`,`type2`),
798 KEY `type2` (`type2`)
801 CREATE TABLE `PortInnerInterface` (
802 `id` int(10) unsigned NOT NULL,
803 `iif_name` char(16) NOT NULL,
805 UNIQUE KEY `iif_name` (`iif_name`)
808 CREATE TABLE `PortInterfaceCompat` (
809 `iif_id` int(10) unsigned NOT NULL,
810 `oif_id` int(10) unsigned NOT NULL,
811 UNIQUE KEY `pair` (`iif_id`,`oif_id`),
812 CONSTRAINT `PortInterfaceCompat-FK-iif_id` FOREIGN KEY (`iif_id`) REFERENCES `PortInnerInterface` (`id`)
815 CREATE TABLE `PortLog` (
816 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
817 `port_id` int(10) unsigned NOT NULL,
818 `date` datetime NOT NULL,
819 `user` varchar(64) NOT NULL,
820 `message` text NOT NULL,
822 KEY `port_id-date` (`port_id`,`date`),
823 CONSTRAINT `PortLog_ibfk_1` FOREIGN KEY (`port_id`) REFERENCES `Port` (`id`) ON DELETE CASCADE
826 CREATE TABLE `PortNativeVLAN` (
827 `object_id` int(10) unsigned NOT NULL,
828 `port_name` char(255) NOT NULL,
829 `vlan_id` int(10) unsigned NOT NULL default '0',
830 PRIMARY KEY (`object_id`,`port_name`,`vlan_id`),
831 UNIQUE KEY `port_id` (`object_id`,`port_name`),
832 CONSTRAINT `PortNativeVLAN-FK-compound` FOREIGN KEY (`object_id`, `port_name`, `vlan_id`) REFERENCES `PortAllowedVLAN` (`object_id`, `port_name`, `vlan_id`) ON DELETE CASCADE
835 CREATE TABLE `PortVLANMode` (
836 `object_id` int(10) unsigned NOT NULL,
837 `port_name` char(255) NOT NULL,
838 `vlan_mode` enum('access','trunk') NOT NULL default 'access',
839 PRIMARY KEY (`object_id`,`port_name`),
840 CONSTRAINT `PortVLANMode-FK-object-port` FOREIGN KEY (`object_id`, `port_name`) REFERENCES `CachedPVM` (`object_id`, `port_name`)
843 CREATE TABLE `Object` (
844 `id` int(10) unsigned NOT NULL auto_increment,
845 `name` char(255) default NULL,
846 `label` char(255) default NULL,
847 `objtype_id` int(10) unsigned NOT NULL default '1',
848 `asset_no` char(64) default NULL,
849 `has_problems` enum('yes','no') NOT NULL default 'no',
852 UNIQUE KEY `asset_no` (`asset_no`),
853 KEY `id-tid` (`id`,`objtype_id`),
854 KEY `type_id` (`objtype_id`,`id`)
857 CREATE TABLE `ObjectHistory` (
858 `id` int(10) unsigned default NULL,
859 `name` char(255) default NULL,
860 `label` char(255) default NULL,
861 `objtype_id` int(10) unsigned default NULL,
862 `asset_no` char(64) default NULL,
863 `has_problems` enum('yes','no') NOT NULL default 'no',
865 `ctime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
866 `user_name` char(64) default NULL,
868 CONSTRAINT `ObjectHistory-FK-object_id` FOREIGN KEY (`id`) REFERENCES `Object` (`id`) ON DELETE CASCADE
871 CREATE TABLE `RackSpace` (
872 `rack_id` int(10) unsigned NOT NULL default '0',
873 `unit_no` int(10) unsigned NOT NULL default '0',
874 `atom` enum('front','interior','rear') NOT NULL default 'interior',
875 `state` enum('A','U','T','W') NOT NULL default 'A',
876 `object_id` int(10) unsigned default NULL,
877 PRIMARY KEY (`rack_id`,`unit_no`,`atom`),
878 KEY `RackSpace_object_id` (`object_id`),
879 CONSTRAINT `RackSpace-FK-rack_id` FOREIGN KEY (`rack_id`) REFERENCES `Object` (`id`),
880 CONSTRAINT `RackSpace-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `Object` (`id`) ON DELETE CASCADE
883 CREATE TABLE `RackThumbnail` (
884 `rack_id` int(10) unsigned NOT NULL,
886 UNIQUE KEY `rack_id` (`rack_id`),
887 CONSTRAINT `RackThumbnail-FK-rack_id` FOREIGN KEY (`rack_id`) REFERENCES `Object` (`id`) ON DELETE CASCADE
890 CREATE TABLE `Script` (
891 `script_name` char(64) NOT NULL,
892 `script_text` longtext,
893 PRIMARY KEY (`script_name`)
896 CREATE TABLE `TagStorage` (
897 `entity_realm` enum('file','ipv4net','ipv4rspool','ipv4vs','ipv6net','location','object','rack','user','vst') NOT NULL default 'object',
898 `entity_id` int(10) unsigned NOT NULL,
899 `tag_id` int(10) unsigned NOT NULL default '0',
900 `user` char(64) DEFAULT NULL,
901 `date` datetime DEFAULT NULL,
902 UNIQUE KEY `entity_tag` (`entity_realm`,`entity_id`,`tag_id`),
903 KEY `entity_id` (`entity_id`),
904 KEY `TagStorage-FK-tag_id` (`tag_id`),
905 CONSTRAINT `TagStorage-FK-tag_id` FOREIGN KEY (`tag_id`) REFERENCES `TagTree` (`id`)
908 CREATE TABLE `TagTree` (
909 `id` int(10) unsigned NOT NULL auto_increment,
910 `parent_id` int(10) unsigned default NULL,
911 `tag` char(255) default NULL,
913 UNIQUE KEY `tag` (`tag`),
914 KEY `TagTree-K-parent_id` (`parent_id`),
915 CONSTRAINT `TagTree-K-parent_id` FOREIGN KEY (`parent_id`) REFERENCES `TagTree` (`id`)
918 CREATE TABLE `UserAccount` (
919 `user_id` int(10) unsigned NOT NULL auto_increment,
920 `user_name` char(64) NOT NULL default '',
921 `user_password_hash` char(40) default NULL,
922 `user_realname` char(64) default NULL,
923 PRIMARY KEY (`user_id`),
924 UNIQUE KEY `user_name` (`user_name`)
927 CREATE TABLE `UserConfig` (
928 `varname` char(32) NOT NULL,
929 `varvalue` text NOT NULL,
930 `user` char(64) NOT NULL,
931 UNIQUE KEY `user_varname` (`user`,`varname`),
932 KEY `varname` (`varname`),
933 CONSTRAINT `UserConfig-FK-varname` FOREIGN KEY (`varname`) REFERENCES `Config` (`varname`) ON DELETE CASCADE,
934 CONSTRAINT `UserConfig-FK-user` FOREIGN KEY (`user`) REFERENCES `UserAccount` (`user_name`) ON DELETE CASCADE
937 CREATE TABLE `VLANDescription` (
938 `domain_id` int(10) unsigned NOT NULL,
939 `vlan_id` int(10) unsigned NOT NULL default '0',
940 `vlan_type` enum('ondemand','compulsory','alien') NOT NULL default 'ondemand',
941 `vlan_descr` char(255) default NULL,
942 PRIMARY KEY (`domain_id`,`vlan_id`),
943 KEY `vlan_id` (`vlan_id`),
944 CONSTRAINT `VLANDescription-FK-domain_id` FOREIGN KEY (`domain_id`) REFERENCES `VLANDomain` (`id`) ON DELETE CASCADE,
945 CONSTRAINT `VLANDescription-FK-vlan_id` FOREIGN KEY (`vlan_id`) REFERENCES `VLANValidID` (`vlan_id`)
948 CREATE TABLE `VLANDomain` (
949 `id` int(10) unsigned NOT NULL auto_increment,
950 `description` char(255) default NULL,
952 UNIQUE KEY `description` (`description`)
955 CREATE TABLE `VLANIPv4` (
956 `domain_id` int(10) unsigned NOT NULL,
957 `vlan_id` int(10) unsigned NOT NULL,
958 `ipv4net_id` int(10) unsigned NOT NULL,
959 UNIQUE KEY `network-domain` (`ipv4net_id`,`domain_id`),
960 KEY `VLANIPv4-FK-compound` (`domain_id`,`vlan_id`),
961 CONSTRAINT `VLANIPv4-FK-compound` FOREIGN KEY (`domain_id`, `vlan_id`) REFERENCES `VLANDescription` (`domain_id`, `vlan_id`) ON DELETE CASCADE,
962 CONSTRAINT `VLANIPv4-FK-ipv4net_id` FOREIGN KEY (`ipv4net_id`) REFERENCES `IPv4Network` (`id`) ON DELETE CASCADE
965 CREATE TABLE `VLANIPv6` (
966 `domain_id` int(10) unsigned NOT NULL,
967 `vlan_id` int(10) unsigned NOT NULL,
968 `ipv6net_id` int(10) unsigned NOT NULL,
969 UNIQUE KEY `network-domain` (`ipv6net_id`,`domain_id`),
970 KEY `VLANIPv6-FK-compound` (`domain_id`,`vlan_id`),
971 CONSTRAINT `VLANIPv6-FK-compound` FOREIGN KEY (`domain_id`, `vlan_id`) REFERENCES `VLANDescription` (`domain_id`, `vlan_id`) ON DELETE CASCADE,
972 CONSTRAINT `VLANIPv6-FK-ipv6net_id` FOREIGN KEY (`ipv6net_id`) REFERENCES `IPv6Network` (`id`) ON DELETE CASCADE
975 CREATE TABLE `VLANSTRule` (
976 `vst_id` int(10) unsigned NOT NULL,
977 `rule_no` int(10) unsigned NOT NULL,
978 `port_pcre` char(255) NOT NULL,
979 `port_role` enum('access','trunk','anymode','uplink','downlink','none') NOT NULL default 'none',
980 `wrt_vlans` char(255) default NULL,
981 `description` char(255) default NULL,
982 UNIQUE KEY `vst-rule` (`vst_id`,`rule_no`),
983 CONSTRAINT `VLANSTRule-FK-vst_id` FOREIGN KEY (`vst_id`) REFERENCES `VLANSwitchTemplate` (`id`) ON DELETE CASCADE
986 CREATE TABLE `VLANSwitch` (
987 `object_id` int(10) unsigned NOT NULL,
988 `domain_id` int(10) unsigned NOT NULL,
989 `template_id` int(10) unsigned NOT NULL,
990 `mutex_rev` int(10) unsigned NOT NULL default '0',
991 `out_of_sync` enum('yes','no') NOT NULL default 'yes',
992 `last_errno` int(10) unsigned NOT NULL default '0',
993 `last_change` timestamp NOT NULL default '0000-00-00 00:00:00',
994 `last_push_started` timestamp NOT NULL default '0000-00-00 00:00:00',
995 `last_push_finished` timestamp NOT NULL default '0000-00-00 00:00:00',
996 `last_error_ts` timestamp NOT NULL default '0000-00-00 00:00:00',
997 UNIQUE KEY `object_id` (`object_id`),
998 KEY `domain_id` (`domain_id`),
999 KEY `template_id` (`template_id`),
1000 KEY `out_of_sync` (`out_of_sync`),
1001 KEY `last_errno` (`last_errno`),
1002 CONSTRAINT `VLANSwitch-FK-domain_id` FOREIGN KEY (`domain_id`) REFERENCES `VLANDomain` (`id`),
1003 CONSTRAINT `VLANSwitch-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `Object` (`id`),
1004 CONSTRAINT `VLANSwitch-FK-template_id` FOREIGN KEY (`template_id`) REFERENCES `VLANSwitchTemplate` (`id`)
1007 CREATE TABLE `VLANSwitchTemplate` (
1008 `id` int(10) unsigned NOT NULL auto_increment,
1009 `mutex_rev` int(10) NOT NULL,
1010 `description` char(255) default NULL,
1011 `saved_by` char(64) NOT NULL,
1013 UNIQUE KEY `description` (`description`)
1016 CREATE TABLE `VLANValidID` (
1017 `vlan_id` int(10) unsigned NOT NULL default '1',
1018 PRIMARY KEY (`vlan_id`)
1021 CREATE VIEW `Location` AS SELECT O.id, O.name, O.has_problems, O.comment, P.id AS parent_id, P.name AS parent_name
1023 LEFT JOIN `EntityLink` EL ON O.id = EL.child_entity_id
1024 LEFT JOIN `Object` P ON (EL.parent_entity_id = P.id AND P.objtype_id = 1562 AND EL.parent_entity_type = 'location' AND EL.child_entity_type = 'location')
1025 WHERE O.objtype_id = 1562;
1027 CREATE VIEW `Row` AS SELECT O.id, O.name, L.id AS location_id, L.name AS location_name
1029 LEFT JOIN `EntityLink` EL ON O.id = EL.child_entity_id AND EL.parent_entity_type = 'location' AND EL.child_entity_type = 'row'
1030 LEFT JOIN `Object` L ON EL.parent_entity_id = L.id AND L.objtype_id = 1562
1031 WHERE O.objtype_id = 1561;
1033 CREATE VIEW `Rack` AS SELECT O.id, O.name AS name, O.asset_no, O.has_problems, O.comment,
1034 AV.uint_value AS height,
1039 LEFT JOIN `AttributeValue` AV ON O.id = AV.object_id AND AV.attr_id = 27
1040 LEFT JOIN `RackThumbnail` RT ON O.id = RT.rack_id
1041 LEFT JOIN `EntityLink` EL ON O.id = EL.child_entity_id AND EL.parent_entity_type = 'row' AND EL.child_entity_type = 'rack'
1042 INNER JOIN `Object` R ON R.id = EL.parent_entity_id
1043 WHERE O.objtype_id = 1560;
1045 CREATE VIEW `RackObject` AS SELECT id, name, label, objtype_id, asset_no, has_problems, comment FROM `Object`
1046 WHERE `objtype_id` NOT IN (1560, 1561, 1562);
1048 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
1050 ##########################################################################
1052 $db_version = CODE_VERSION;
1053 return <<<END_OF_FILE
1054 INSERT INTO `Attribute` (`id`, `type`, `name`) VALUES
1055 (1,'string','OEM S/N 1'),
1056 (2,'dict','HW type'),
1057 (3,'string','FQDN'),
1058 (4,'dict','SW type'),
1059 (5,'string','SW version'),
1060 (6,'uint','number of ports'),
1061 (7,'float','max. current, Ampers'),
1062 (8,'float','power load, percents'),
1063 (14,'string','contact person'),
1064 (13,'float','max power, Watts'),
1065 (16,'uint','flash memory, MB'),
1066 (17,'uint','DRAM, MB'),
1067 (18,'uint','CPU, MHz'),
1068 (20,'string','OEM S/N 2'),
1069 (21,'date','support contract expiration'),
1070 (22,'date','HW warranty expiration'),
1071 (24,'date','SW warranty expiration'),
1072 (25,'string','UUID'),
1073 (26,'dict','Hypervisor'),
1074 (27,'uint','Height, units'),
1075 (28,'string','Slot number'),
1076 -- ^^^^^ Any new "default" attributes must go above this line! ^^^^^
1077 -- Primary key value 9999 makes sure, that AUTO_INCREMENT on server restart
1078 -- doesn't drop below 10000 (other code relies on this, site-specific
1079 -- attributes are assigned IDs starting from 10000).
1080 (9999,'string','base MAC address');
1082 INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES
1083 (1,'yes','ObjectType'),
1084 (2,'yes','PortOuterInterface'),
1085 (11,'no','server models'),
1086 (12,'no','network switch models'),
1087 (13,'no','server OS type'),
1088 (14,'no','switch OS type'),
1089 (16,'no','router OS type'),
1090 (17,'no','router models'),
1091 (18,'no','disk array models'),
1092 (19,'no','tape library models'),
1093 (21,'no','KVM switch models'),
1094 (23,'no','console models'),
1095 (24,'no','network security models'),
1096 (25,'no','wireless models'),
1097 (26,'no','fibre channel switch models'),
1098 (27,'no','PDU models'),
1099 (28,'no','Voice/video hardware'),
1101 (30,'no','network chassis models'),
1102 (31,'no','server chassis models'),
1103 (32,'no','virtual switch models'),
1104 (33,'no','virtual switch OS type'),
1105 (34,'no','power supply chassis models'),
1106 (35,'no','power supply models'),
1107 (36,'no','serial console server models'),
1108 (37,'no','wireless OS type'),
1109 -- Default chapters must have ID less than 10000, add them above this line.
1110 (9999,'no','multiplexer models');
1112 INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES
1255 INSERT INTO `PortInnerInterface` VALUES
1268 INSERT INTO `ObjectParentCompat` VALUES
1282 INSERT INTO `PortInterfaceCompat` VALUES
1283 (2,1208),(2,1195),(2,1196),(2,1197),(2,1198),(2,1199),(2,1200),(2,1201),
1284 (3,1078),(3,24),(3,34),(3,1202),(3,1203),(3,1204),(3,1205),(3,1206),(3,1207),
1285 (4,1077),(4,24),(4,34),(4,1202),(4,1203),(4,1204),(4,1205),(4,1206),(4,1207),
1286 (5,1079),(5,30),(5,35),(5,36),(5,37),(5,38),(5,39),(5,40),
1287 (6,1080),(6,30),(6,35),(6,36),(6,37),(6,38),(6,39),(6,40),
1288 (7,1081),(7,30),(7,35),(7,36),(7,37),(7,38),(7,39),(7,40),
1289 (8,1082),(8,30),(8,35),(8,36),(8,37),(8,38),(8,39),(8,40),
1290 (9,1084),(9,30),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),
1291 (10,1588),(10,1663),(10,1664),
1292 (11,1668),(11,1669),(11,1670),(11,1671),
1293 (1,16),(1,19),(1,24),(1,29),(1,31),(1,33),(1,446),(1,681),(1,682),(1,1322),(1,1399),(1,1469);
1295 INSERT INTO `PortCompat` (`type1`, `type2`) VALUES
1495 INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, is_userdefined, description) VALUES
1496 ('MASSCOUNT','8','uint','no','no','yes','"Fast" form is this many records tall'),
1497 ('MAXSELSIZE','30','uint','no','no','yes','<SELECT> lists height'),
1498 ('enterprise','MyCompanyName','string','no','no','no','Organization name'),
1499 ('ROW_SCALE','2','uint','no','no','yes','Picture scale for rack row display'),
1500 ('PORTS_PER_ROW','12','uint','no','no','yes','Ports per row in VLANs tab'),
1501 ('IPV4_ADDRS_PER_PAGE','256','uint','no','no','yes','IPv4 addresses per page'),
1502 ('DEFAULT_RACK_HEIGHT','42','uint','yes','no','yes','Default rack height'),
1503 ('DEFAULT_SLB_VS_PORT','','uint','yes','no','yes','Default port of SLB virtual service'),
1504 ('DEFAULT_SLB_RS_PORT','','uint','yes','no','yes','Default port of SLB real server'),
1505 ('DETECT_URLS','no','string','yes','no','yes','Detect URLs in text fields'),
1506 ('RACK_PRESELECT_THRESHOLD','1','uint','no','no','yes','Rack pre-selection threshold'),
1507 ('DEFAULT_IPV4_RS_INSERVICE','no','string','no','no','yes','Inservice status for new SLB real servers'),
1508 ('AUTOPORTS_CONFIG','4 = 1*33*kvm + 2*24*eth%u;15 = 1*446*kvm','string','yes','no','no','AutoPorts configuration'),
1509 ('DEFAULT_OBJECT_TYPE','4','uint','yes','no','yes','Default object type for new objects'),
1510 ('SHOW_EXPLICIT_TAGS','yes','string','no','no','yes','Show explicit tags'),
1511 ('SHOW_IMPLICIT_TAGS','yes','string','no','no','yes','Show implicit tags'),
1512 ('SHOW_AUTOMATIC_TAGS','no','string','no','no','yes','Show automatic tags'),
1513 ('IPV4_AUTO_RELEASE','1','uint','no','no','yes','Auto-release IPv4 addresses on allocation'),
1514 ('SHOW_LAST_TAB','no','string','yes','no','yes','Remember last tab shown for each page'),
1515 ('EXT_IPV4_VIEW','yes','string','no','no','yes','Extended IPv4 view'),
1516 ('TREE_THRESHOLD','25','uint','yes','no','yes','Tree view auto-collapse threshold'),
1517 ('IPV4_JAYWALK','no','string','no','no','no','Enable IPv4 address allocations w/o covering network'),
1518 ('ADDNEW_AT_TOP','yes','string','no','no','yes','Render "add new" line at top of the list'),
1519 ('IPV4_TREE_SHOW_USAGE','yes','string','no','no','yes','Show address usage in IPv4 tree'),
1520 ('PREVIEW_TEXT_MAXCHARS','10240','uint','yes','no','yes','Max chars for text file preview'),
1521 ('PREVIEW_TEXT_ROWS','25','uint','yes','no','yes','Rows for text file preview'),
1522 ('PREVIEW_TEXT_COLS','80','uint','yes','no','yes','Columns for text file preview'),
1523 ('PREVIEW_IMAGE_MAXPXS','320','uint','yes','no','yes','Max pixels per axis for image file preview'),
1524 ('VENDOR_SIEVE','','string','yes','no','yes','Vendor sieve configuration'),
1525 ('IPV4LB_LISTSRC','{\$typeid_4}','string','yes','no','no','List source: IPv4 load balancers'),
1526 ('IPV4OBJ_LISTSRC','{\$typeid_4} or {\$typeid_7} or {\$typeid_8} or {\$typeid_12} or {\$typeid_445} or {\$typeid_447} or {\$typeid_798} or {\$typeid_1397} or {\$typeid_1502} or {\$typeid_1503} or {\$typeid_1504} or {\$typeid_1507}','string','yes','no','no','List source: IPv4-enabled objects'),
1527 ('IPV4NAT_LISTSRC','{\$typeid_4} or {\$typeid_7} or {\$typeid_8} or {\$typeid_798}','string','yes','no','no','List source: IPv4 NAT performers'),
1528 ('ASSETWARN_LISTSRC','{\$typeid_4} or {\$typeid_7} or {\$typeid_8}','string','yes','no','no','List source: object, for which asset tag should be set'),
1529 ('NAMEWARN_LISTSRC','{\$typeid_4} or {\$typeid_7} or {\$typeid_8}','string','yes','no','no','List source: object, for which common name should be set'),
1530 ('RACKS_PER_ROW','12','uint','yes','no','yes','Racks per row'),
1531 ('FILTER_PREDICATE_SIEVE','','string','yes','no','yes','Predicate sieve regex(7)'),
1532 ('FILTER_DEFAULT_ANDOR','or','string','no','no','yes','Default list filter boolean operation (or/and)'),
1533 ('FILTER_SUGGEST_ANDOR','yes','string','no','no','yes','Suggest and/or selector in list filter'),
1534 ('FILTER_SUGGEST_TAGS','yes','string','no','no','yes','Suggest tags in list filter'),
1535 ('FILTER_SUGGEST_PREDICATES','yes','string','no','no','yes','Suggest predicates in list filter'),
1536 ('FILTER_SUGGEST_EXTRA','no','string','no','no','yes','Suggest extra expression in list filter'),
1537 ('DEFAULT_SNMP_COMMUNITY','public','string','no','no','no','Default SNMP Community string'),
1538 ('IPV4_ENABLE_KNIGHT','yes','string','no','no','yes','Enable IPv4 knight feature'),
1539 ('TAGS_TOPLIST_SIZE','50','uint','yes','no','yes','Tags top list size'),
1540 ('TAGS_QUICKLIST_SIZE','20','uint','no','no','yes','Tags quick list size'),
1541 ('TAGS_QUICKLIST_THRESHOLD','50','uint','yes','no','yes','Tags quick list threshold'),
1542 ('ENABLE_MULTIPORT_FORM','no','string','no','no','yes','Enable "Add/update multiple ports" form'),
1543 ('DEFAULT_PORT_IIF_ID','1','uint','no','no','no','Default port inner interface ID'),
1544 ('DEFAULT_PORT_OIF_IDS','1=24; 3=1078; 4=1077; 5=1079; 6=1080; 8=1082; 9=1084; 10=1588; 11=1668','string','no','no','no','Default port outer interface IDs'),
1545 ('IPV4_TREE_RTR_AS_CELL','yes','string','no','no','yes','Show full router info for each network in IPv4 tree view'),
1546 ('PROXIMITY_RANGE','0','uint','yes','no','yes','Proximity range (0 is current rack only)'),
1547 ('VLANSWITCH_LISTSRC', '', 'string', 'yes', 'no', 'yes', 'List of VLAN running switches'),
1548 ('VLANIPV4NET_LISTSRC', '', 'string', 'yes', 'no', 'yes', 'List of VLAN-based IPv4 networks'),
1549 ('IPV4_TREE_SHOW_VLAN','yes','string','no','no','yes','Show VLAN for each network in IPv4 tree'),
1550 ('DEFAULT_VDOM_ID','','uint','yes','no','yes','Default VLAN domain ID'),
1551 ('DEFAULT_VST_ID','','uint','yes','no','yes','Default VLAN switch template ID'),
1552 ('8021Q_DEPLOY_MINAGE','300','uint','no','no','no','802.1Q deploy minimum age'),
1553 ('8021Q_DEPLOY_MAXAGE','3600','uint','no','no','no','802.1Q deploy maximum age'),
1554 ('8021Q_DEPLOY_RETRY','10800','uint','no','no','no','802.1Q deploy retry timer'),
1555 ('8021Q_WRI_AFTER_CONFT_LISTSRC','false','string','no','no','no','802.1Q: save device configuration after deploy (RackCode)'),
1556 ('8021Q_INSTANT_DEPLOY','no','string','no','no','yes','802.1Q: instant deploy'),
1557 ('STATIC_FILTER','yes','string','no','no','yes','Enable Filter Caching'),
1558 ('ENABLE_BULKPORT_FORM','yes','string','no','no','yes','Enable "Bulk Port" form'),
1559 ('CDP_RUNNERS_LISTSRC', '', 'string', 'yes', 'no', 'no', 'List of devices running CDP'),
1560 ('LLDP_RUNNERS_LISTSRC', '', 'string', 'yes', 'no', 'no', 'List of devices running LLDP'),
1561 ('SHRINK_TAG_TREE_ON_CLICK','yes','string','no','no','yes','Dynamically hide useless tags in tagtree'),
1562 ('MAX_UNFILTERED_ENTITIES','0','uint','no','no','yes','Max item count to display on unfiltered result page'),
1563 ('SYNCDOMAIN_MAX_PROCESSES','0','uint','yes','no', 'no', 'How many worker proceses syncdomain cron script should create'),
1564 ('PORT_EXCLUSION_LISTSRC','{\$typeid_3} or {\$typeid_10} or {\$typeid_11} or {\$typeid_1505} or {\$typeid_1506}','string','yes','no','no','List source: objects without ports'),
1565 ('FILTER_RACKLIST_BY_TAGS','yes','string','yes','no','yes','Rackspace: show only racks matching the current object\'s tags'),
1566 ('SSH_OBJS_LISTSRC','none','string','yes','no','yes','Rackcode filter for SSH-managed objects'),
1567 ('TELNET_OBJS_LISTSRC','none','string','yes','no','yes','Rackcode filter for telnet-managed objects'),
1568 ('SYNC_802Q_LISTSRC','','string','yes','no','no','List of VLAN switches sync is enabled on'),
1569 ('QUICK_LINK_PAGES','','string','yes','no','yes','List of pages to dislay in quick links'),
1570 ('CACTI_LISTSRC','false','string','yes','no','no','List of object with Cacti graphs'),
1571 ('CACTI_URL','','string','yes','no','no','Cacti server base URL'),
1572 ('CACTI_USERNAME','','string','yes','no','no','Cacti user account'),
1573 ('CACTI_USERPASS','','string','yes','no','no','Cacti user password'),
1574 ('VIRTUAL_OBJ_LISTSRC','1504,1505,1506,1507','string','no','no','no','List source: virtual objects'),
1575 ('DATETIME_ZONE','UTC','string','yes','no','yes','Timezone to use for displaying/calculating dates'),
1576 ('DATETIME_FORMAT','m/d/Y','string','no','no','yes','PHP date() format to use for date output'),
1577 ('DB_VERSION','${db_version}','string','no','yes','no','Database version.');
1579 INSERT INTO `Script` VALUES ('RackCode','allow {\$userid_1}');
1581 INSERT INTO VLANValidID (vlan_id) VALUES