From b74ef5e5ae32e37272b4135e04eb4e1ffd3fe994 Mon Sep 17 00:00:00 2001 From: tbrehm Date: Wed, 29 Jun 2011 12:27:45 +0000 Subject: [PATCH] First commit for: FS#952 - Module for virtual machine management --- install/sql/incremental/upd_0012.sql | 173 +++++++ install/sql/ispconfig3.sql | 174 +++++++ interface/lib/lang/en.lng | 2 +- interface/web/client/client_edit.php | 2 +- .../web/themes/default/icons/x32/drawer.png | Bin 0 -> 1088 bytes interface/web/vm/form/openvz_ip.tform.php | 112 +++++ .../web/vm/form/openvz_ostemplate.tform.php | 124 +++++ .../web/vm/form/openvz_template.tform.php | 462 ++++++++++++++++++ interface/web/vm/form/openvz_vm.tform.php | 297 +++++++++++ interface/web/vm/lib/admin.conf.php | 2 + interface/web/vm/lib/lang/en_openvz_ip.lng | 6 + .../web/vm/lib/lang/en_openvz_ip_list.lng | 6 + .../web/vm/lib/lang/en_openvz_ostemplate.lng | 8 + .../vm/lib/lang/en_openvz_ostemplate_list.lng | 7 + .../web/vm/lib/lang/en_openvz_template.lng | 60 +++ .../vm/lib/lang/en_openvz_template_list.lng | 5 + interface/web/vm/lib/lang/en_openvz_vm.lng | 25 + .../web/vm/lib/lang/en_openvz_vm_list.lng | 10 + interface/web/vm/lib/module.conf.php | 67 +++ interface/web/vm/list/openvz_ip.list.php | 100 ++++ .../web/vm/list/openvz_ostemplate.list.php | 94 ++++ .../web/vm/list/openvz_template.list.php | 70 +++ interface/web/vm/list/openvz_vm.list.php | 129 +++++ interface/web/vm/openvz_ip_del.php | 58 +++ interface/web/vm/openvz_ip_edit.php | 58 +++ interface/web/vm/openvz_ip_list.php | 54 ++ interface/web/vm/openvz_ostemplate_del.php | 58 +++ interface/web/vm/openvz_ostemplate_edit.php | 58 +++ interface/web/vm/openvz_ostemplate_list.php | 54 ++ interface/web/vm/openvz_template_del.php | 58 +++ interface/web/vm/openvz_template_edit.php | 76 +++ interface/web/vm/openvz_template_list.php | 54 ++ interface/web/vm/openvz_vm_del.php | 58 +++ interface/web/vm/openvz_vm_edit.php | 328 +++++++++++++ interface/web/vm/openvz_vm_list.php | 54 ++ interface/web/vm/templates/openvz.conf.tpl | 48 ++ interface/web/vm/templates/openvz_ip_edit.htm | 40 ++ interface/web/vm/templates/openvz_ip_list.htm | 58 +++ .../vm/templates/openvz_ostemplate_edit.htm | 48 ++ .../vm/templates/openvz_ostemplate_list.htm | 58 +++ .../openvz_template_advanced_edit.htm | 110 +++++ .../web/vm/templates/openvz_template_edit.htm | 74 +++ .../web/vm/templates/openvz_template_list.htm | 52 ++ .../vm/templates/openvz_vm_advanced_edit.htm | 64 +++ interface/web/vm/templates/openvz_vm_edit.htm | 104 ++++ interface/web/vm/templates/openvz_vm_list.htm | 67 +++ server/cron_daily.php | 21 + server/mods-available/vm_module.inc.php | 118 +++++ .../plugins-available/openvz_plugin.inc.php | 154 ++++++ 49 files changed, 3917 insertions(+), 2 deletions(-) create mode 100644 install/sql/incremental/upd_0012.sql create mode 100644 interface/web/themes/default/icons/x32/drawer.png create mode 100644 interface/web/vm/form/openvz_ip.tform.php create mode 100644 interface/web/vm/form/openvz_ostemplate.tform.php create mode 100644 interface/web/vm/form/openvz_template.tform.php create mode 100644 interface/web/vm/form/openvz_vm.tform.php create mode 100644 interface/web/vm/lib/admin.conf.php create mode 100644 interface/web/vm/lib/lang/en_openvz_ip.lng create mode 100644 interface/web/vm/lib/lang/en_openvz_ip_list.lng create mode 100644 interface/web/vm/lib/lang/en_openvz_ostemplate.lng create mode 100644 interface/web/vm/lib/lang/en_openvz_ostemplate_list.lng create mode 100644 interface/web/vm/lib/lang/en_openvz_template.lng create mode 100644 interface/web/vm/lib/lang/en_openvz_template_list.lng create mode 100644 interface/web/vm/lib/lang/en_openvz_vm.lng create mode 100644 interface/web/vm/lib/lang/en_openvz_vm_list.lng create mode 100644 interface/web/vm/lib/module.conf.php create mode 100644 interface/web/vm/list/openvz_ip.list.php create mode 100644 interface/web/vm/list/openvz_ostemplate.list.php create mode 100644 interface/web/vm/list/openvz_template.list.php create mode 100644 interface/web/vm/list/openvz_vm.list.php create mode 100644 interface/web/vm/openvz_ip_del.php create mode 100644 interface/web/vm/openvz_ip_edit.php create mode 100644 interface/web/vm/openvz_ip_list.php create mode 100644 interface/web/vm/openvz_ostemplate_del.php create mode 100644 interface/web/vm/openvz_ostemplate_edit.php create mode 100644 interface/web/vm/openvz_ostemplate_list.php create mode 100644 interface/web/vm/openvz_template_del.php create mode 100644 interface/web/vm/openvz_template_edit.php create mode 100644 interface/web/vm/openvz_template_list.php create mode 100644 interface/web/vm/openvz_vm_del.php create mode 100644 interface/web/vm/openvz_vm_edit.php create mode 100644 interface/web/vm/openvz_vm_list.php create mode 100644 interface/web/vm/templates/openvz.conf.tpl create mode 100644 interface/web/vm/templates/openvz_ip_edit.htm create mode 100644 interface/web/vm/templates/openvz_ip_list.htm create mode 100644 interface/web/vm/templates/openvz_ostemplate_edit.htm create mode 100644 interface/web/vm/templates/openvz_ostemplate_list.htm create mode 100644 interface/web/vm/templates/openvz_template_advanced_edit.htm create mode 100644 interface/web/vm/templates/openvz_template_edit.htm create mode 100644 interface/web/vm/templates/openvz_template_list.htm create mode 100644 interface/web/vm/templates/openvz_vm_advanced_edit.htm create mode 100644 interface/web/vm/templates/openvz_vm_edit.htm create mode 100644 interface/web/vm/templates/openvz_vm_list.htm create mode 100644 server/mods-available/vm_module.inc.php create mode 100644 server/plugins-available/openvz_plugin.inc.php diff --git a/install/sql/incremental/upd_0012.sql b/install/sql/incremental/upd_0012.sql new file mode 100644 index 000000000..2ba957f8d --- /dev/null +++ b/install/sql/incremental/upd_0012.sql @@ -0,0 +1,173 @@ +-- +-- Table structure for table `openvz_ip` +-- + +CREATE TABLE IF NOT EXISTS `openvz_ip` ( + `ip_address_id` bigint(20) NOT NULL AUTO_INCREMENT, + `sys_userid` int(11) NOT NULL DEFAULT '0', + `sys_groupid` int(11) NOT NULL DEFAULT '0', + `sys_perm_user` varchar(5) DEFAULT NULL, + `sys_perm_group` varchar(5) DEFAULT NULL, + `sys_perm_other` varchar(5) DEFAULT NULL, + `server_id` int(11) NOT NULL DEFAULT '0', + `ip_address` varchar(15) DEFAULT NULL, + `vm_id` int(11) NOT NULL DEFAULT '0', + `reserved` varchar(255) NOT NULL DEFAULT 'n', + PRIMARY KEY (`ip_address_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +-- +-- Dumping data for table `openvz_ip` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `openvz_ostemplate` +-- + +CREATE TABLE IF NOT EXISTS `openvz_ostemplate` ( + `ostemplate_id` bigint(20) NOT NULL AUTO_INCREMENT, + `sys_userid` int(11) NOT NULL DEFAULT '0', + `sys_groupid` int(11) NOT NULL DEFAULT '0', + `sys_perm_user` varchar(5) DEFAULT NULL, + `sys_perm_group` varchar(5) DEFAULT NULL, + `sys_perm_other` varchar(5) DEFAULT NULL, + `template_name` varchar(255) DEFAULT NULL, + `template_file` varchar(255) NOT NULL, + `server_id` int(11) NOT NULL DEFAULT '0', + `allservers` varchar(255) NOT NULL DEFAULT 'y', + `active` varchar(255) NOT NULL DEFAULT 'y', + `description` text, + PRIMARY KEY (`ostemplate_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +-- +-- Dumping data for table `openvz_ostemplate` +-- + +INSERT INTO `openvz_ostemplate` (`ostemplate_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `template_name`, `template_file`, `server_id`, `allservers`, `active`, `description`) VALUES(1, 1, 1, 'riud', 'riud', '', 'Debian minimal', 'debian-minimal-x86', 1, 'y', 'y', 'Debain minmal image.'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `openvz_template` +-- + +CREATE TABLE IF NOT EXISTS `openvz_template` ( + `template_id` bigint(20) NOT NULL AUTO_INCREMENT, + `sys_userid` int(11) NOT NULL DEFAULT '0', + `sys_groupid` int(11) NOT NULL DEFAULT '0', + `sys_perm_user` varchar(5) DEFAULT NULL, + `sys_perm_group` varchar(5) DEFAULT NULL, + `sys_perm_other` varchar(5) DEFAULT NULL, + `template_name` varchar(255) DEFAULT NULL, + `diskspace` int(11) NOT NULL DEFAULT '0', + `traffic` int(11) NOT NULL DEFAULT '-1', + `bandwidth` int(11) NOT NULL DEFAULT '-1', + `ram` int(11) NOT NULL DEFAULT '0', + `ram_burst` int(11) NOT NULL DEFAULT '0', + `cpu_units` int(11) NOT NULL DEFAULT '1000', + `cpu_num` int(11) NOT NULL DEFAULT '4', + `cpu_limit` int(11) NOT NULL DEFAULT '400', + `io_priority` int(11) NOT NULL DEFAULT '4', + `active` varchar(255) NOT NULL DEFAULT 'y', + `description` text, + `numproc` varchar(255) DEFAULT NULL, + `numtcpsock` varchar(255) DEFAULT NULL, + `numothersock` varchar(255) DEFAULT NULL, + `vmguarpages` varchar(255) DEFAULT NULL, + `kmemsize` varchar(255) DEFAULT NULL, + `tcpsndbuf` varchar(255) DEFAULT NULL, + `tcprcvbuf` varchar(255) DEFAULT NULL, + `othersockbuf` varchar(255) DEFAULT NULL, + `dgramrcvbuf` varchar(255) DEFAULT NULL, + `oomguarpages` varchar(255) DEFAULT NULL, + `privvmpages` varchar(255) DEFAULT NULL, + `lockedpages` varchar(255) DEFAULT NULL, + `shmpages` varchar(255) DEFAULT NULL, + `physpages` varchar(255) DEFAULT NULL, + `numfile` varchar(255) DEFAULT NULL, + `avnumproc` varchar(255) DEFAULT NULL, + `numflock` varchar(255) DEFAULT NULL, + `numpty` varchar(255) DEFAULT NULL, + `numsiginfo` varchar(255) DEFAULT NULL, + `dcachesize` varchar(255) DEFAULT NULL, + `numiptent` varchar(255) DEFAULT NULL, + `swappages` varchar(255) DEFAULT NULL, + `hostname` varchar(255) DEFAULT NULL, + `nameserver` varchar(255) DEFAULT NULL, + `create_dns` varchar(1) NOT NULL DEFAULT 'n', + `capability` varchar(255) DEFAULT NULL, + PRIMARY KEY (`template_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +-- +-- Dumping data for table `openvz_template` +-- + +INSERT INTO `openvz_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `template_name`, `diskspace`, `traffic`, `bandwidth`, `ram`, `ram_burst`, `cpu_units`, `cpu_num`, `cpu_limit`, `io_priority`, `active`, `description`, `numproc`, `numtcpsock`, `numothersock`, `vmguarpages`, `kmemsize`, `tcpsndbuf`, `tcprcvbuf`, `othersockbuf`, `dgramrcvbuf`, `oomguarpages`, `privvmpages`, `lockedpages`, `shmpages`, `physpages`, `numfile`, `avnumproc`, `numflock`, `numpty`, `numsiginfo`, `dcachesize`, `numiptent`, `swappages`, `hostname`, `nameserver`, `create_dns`, `capability`) VALUES(1, 1, 1, 'riud', 'riud', '', 'small', 10, -1, -1, 256, 512, 1000, 4, 400, 4, 'y', '', '999999:999999', '7999992:7999992', '7999992:7999992', '65536:65536', '2147483646:2147483646', '214748160:396774400', '214748160:396774400', '214748160:396774400', '214748160:396774400', '65536:65536', '131072:131072', '999999:999999', '65536:65536', '0:2147483647', '23999976:23999976', '180:180', '999999:999999', '500000:500000', '999999:999999', '2147483646:2147483646', '999999:999999', '256000:256000', 'v{VEID}.test.tld', '8.8.8.8 8.8.4.4', 'n', ''); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `openvz_traffic` +-- + +CREATE TABLE IF NOT EXISTS `openvz_traffic` ( + `veid` int(11) NOT NULL, + `traffic_date` date NOT NULL, + `traffic_bytes` bigint(32) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`veid`,`traffic_date`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `openvz_traffic` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `openvz_vm` +-- + +CREATE TABLE IF NOT EXISTS `openvz_vm` ( + `vm_id` bigint(20) NOT NULL AUTO_INCREMENT, + `sys_userid` int(11) NOT NULL DEFAULT '0', + `sys_groupid` int(11) NOT NULL DEFAULT '0', + `sys_perm_user` varchar(5) DEFAULT NULL, + `sys_perm_group` varchar(5) DEFAULT NULL, + `sys_perm_other` varchar(5) DEFAULT NULL, + `server_id` int(11) NOT NULL DEFAULT '0', + `veid` int(10) unsigned NOT NULL, + `ostemplate_id` int(11) NOT NULL DEFAULT '0', + `template_id` int(11) NOT NULL DEFAULT '0', + `ip_address` varchar(255) NOT NULL, + `hostname` varchar(255) DEFAULT NULL, + `vm_password` varchar(255) DEFAULT NULL, + `start_boot` varchar(255) NOT NULL DEFAULT 'y', + `active` varchar(255) NOT NULL DEFAULT 'y', + `active_until_date` date NOT NULL, + `description` text, + `diskspace` int(11) NOT NULL DEFAULT '0', + `traffic` int(11) NOT NULL DEFAULT '-1', + `bandwidth` int(11) NOT NULL DEFAULT '-1', + `ram` int(11) NOT NULL DEFAULT '0', + `ram_burst` int(11) NOT NULL DEFAULT '0', + `cpu_units` int(11) NOT NULL DEFAULT '1000', + `cpu_num` int(11) NOT NULL DEFAULT '4', + `cpu_limit` int(11) NOT NULL DEFAULT '400', + `io_priority` int(11) NOT NULL DEFAULT '4', + `nameserver` varchar(255) NOT NULL DEFAULT '8.8.8.8 8.8.4.4', + `create_dns` varchar(1) NOT NULL DEFAULT 'n', + `capability` text NOT NULL, + `config` mediumtext NOT NULL, + PRIMARY KEY (`vm_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +-- +-- Dumping data for table `openvz_vm` +-- + +-- -------------------------------------------------------- diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 69507c0f2..81d61efa3 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -792,6 +792,180 @@ CREATE TABLE `monitor_data` ( -- -------------------------------------------------------- +-- +-- Table structure for table `openvz_ip` +-- + +CREATE TABLE IF NOT EXISTS `openvz_ip` ( + `ip_address_id` bigint(20) NOT NULL AUTO_INCREMENT, + `sys_userid` int(11) NOT NULL DEFAULT '0', + `sys_groupid` int(11) NOT NULL DEFAULT '0', + `sys_perm_user` varchar(5) DEFAULT NULL, + `sys_perm_group` varchar(5) DEFAULT NULL, + `sys_perm_other` varchar(5) DEFAULT NULL, + `server_id` int(11) NOT NULL DEFAULT '0', + `ip_address` varchar(15) DEFAULT NULL, + `vm_id` int(11) NOT NULL DEFAULT '0', + `reserved` varchar(255) NOT NULL DEFAULT 'n', + PRIMARY KEY (`ip_address_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +-- +-- Dumping data for table `openvz_ip` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `openvz_ostemplate` +-- + +CREATE TABLE IF NOT EXISTS `openvz_ostemplate` ( + `ostemplate_id` bigint(20) NOT NULL AUTO_INCREMENT, + `sys_userid` int(11) NOT NULL DEFAULT '0', + `sys_groupid` int(11) NOT NULL DEFAULT '0', + `sys_perm_user` varchar(5) DEFAULT NULL, + `sys_perm_group` varchar(5) DEFAULT NULL, + `sys_perm_other` varchar(5) DEFAULT NULL, + `template_name` varchar(255) DEFAULT NULL, + `template_file` varchar(255) NOT NULL, + `server_id` int(11) NOT NULL DEFAULT '0', + `allservers` varchar(255) NOT NULL DEFAULT 'y', + `active` varchar(255) NOT NULL DEFAULT 'y', + `description` text, + PRIMARY KEY (`ostemplate_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +-- +-- Dumping data for table `openvz_ostemplate` +-- + +INSERT INTO `openvz_ostemplate` (`ostemplate_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `template_name`, `template_file`, `server_id`, `allservers`, `active`, `description`) VALUES(1, 1, 1, 'riud', 'riud', '', 'Debian minimal', 'debian-minimal-x86', 1, 'y', 'y', 'Debain minmal image.'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `openvz_template` +-- + +CREATE TABLE IF NOT EXISTS `openvz_template` ( + `template_id` bigint(20) NOT NULL AUTO_INCREMENT, + `sys_userid` int(11) NOT NULL DEFAULT '0', + `sys_groupid` int(11) NOT NULL DEFAULT '0', + `sys_perm_user` varchar(5) DEFAULT NULL, + `sys_perm_group` varchar(5) DEFAULT NULL, + `sys_perm_other` varchar(5) DEFAULT NULL, + `template_name` varchar(255) DEFAULT NULL, + `diskspace` int(11) NOT NULL DEFAULT '0', + `traffic` int(11) NOT NULL DEFAULT '-1', + `bandwidth` int(11) NOT NULL DEFAULT '-1', + `ram` int(11) NOT NULL DEFAULT '0', + `ram_burst` int(11) NOT NULL DEFAULT '0', + `cpu_units` int(11) NOT NULL DEFAULT '1000', + `cpu_num` int(11) NOT NULL DEFAULT '4', + `cpu_limit` int(11) NOT NULL DEFAULT '400', + `io_priority` int(11) NOT NULL DEFAULT '4', + `active` varchar(255) NOT NULL DEFAULT 'y', + `description` text, + `numproc` varchar(255) DEFAULT NULL, + `numtcpsock` varchar(255) DEFAULT NULL, + `numothersock` varchar(255) DEFAULT NULL, + `vmguarpages` varchar(255) DEFAULT NULL, + `kmemsize` varchar(255) DEFAULT NULL, + `tcpsndbuf` varchar(255) DEFAULT NULL, + `tcprcvbuf` varchar(255) DEFAULT NULL, + `othersockbuf` varchar(255) DEFAULT NULL, + `dgramrcvbuf` varchar(255) DEFAULT NULL, + `oomguarpages` varchar(255) DEFAULT NULL, + `privvmpages` varchar(255) DEFAULT NULL, + `lockedpages` varchar(255) DEFAULT NULL, + `shmpages` varchar(255) DEFAULT NULL, + `physpages` varchar(255) DEFAULT NULL, + `numfile` varchar(255) DEFAULT NULL, + `avnumproc` varchar(255) DEFAULT NULL, + `numflock` varchar(255) DEFAULT NULL, + `numpty` varchar(255) DEFAULT NULL, + `numsiginfo` varchar(255) DEFAULT NULL, + `dcachesize` varchar(255) DEFAULT NULL, + `numiptent` varchar(255) DEFAULT NULL, + `swappages` varchar(255) DEFAULT NULL, + `hostname` varchar(255) DEFAULT NULL, + `nameserver` varchar(255) DEFAULT NULL, + `create_dns` varchar(1) NOT NULL DEFAULT 'n', + `capability` varchar(255) DEFAULT NULL, + PRIMARY KEY (`template_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +-- +-- Dumping data for table `openvz_template` +-- + +INSERT INTO `openvz_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `template_name`, `diskspace`, `traffic`, `bandwidth`, `ram`, `ram_burst`, `cpu_units`, `cpu_num`, `cpu_limit`, `io_priority`, `active`, `description`, `numproc`, `numtcpsock`, `numothersock`, `vmguarpages`, `kmemsize`, `tcpsndbuf`, `tcprcvbuf`, `othersockbuf`, `dgramrcvbuf`, `oomguarpages`, `privvmpages`, `lockedpages`, `shmpages`, `physpages`, `numfile`, `avnumproc`, `numflock`, `numpty`, `numsiginfo`, `dcachesize`, `numiptent`, `swappages`, `hostname`, `nameserver`, `create_dns`, `capability`) VALUES(1, 1, 1, 'riud', 'riud', '', 'small', 10, -1, -1, 256, 512, 1000, 4, 400, 4, 'y', '', '999999:999999', '7999992:7999992', '7999992:7999992', '65536:65536', '2147483646:2147483646', '214748160:396774400', '214748160:396774400', '214748160:396774400', '214748160:396774400', '65536:65536', '131072:131072', '999999:999999', '65536:65536', '0:2147483647', '23999976:23999976', '180:180', '999999:999999', '500000:500000', '999999:999999', '2147483646:2147483646', '999999:999999', '256000:256000', 'v{VEID}.test.tld', '8.8.8.8 8.8.4.4', 'n', ''); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `openvz_traffic` +-- + +CREATE TABLE IF NOT EXISTS `openvz_traffic` ( + `veid` int(11) NOT NULL, + `traffic_date` date NOT NULL, + `traffic_bytes` bigint(32) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`veid`,`traffic_date`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `openvz_traffic` +-- + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `openvz_vm` +-- + +CREATE TABLE IF NOT EXISTS `openvz_vm` ( + `vm_id` bigint(20) NOT NULL AUTO_INCREMENT, + `sys_userid` int(11) NOT NULL DEFAULT '0', + `sys_groupid` int(11) NOT NULL DEFAULT '0', + `sys_perm_user` varchar(5) DEFAULT NULL, + `sys_perm_group` varchar(5) DEFAULT NULL, + `sys_perm_other` varchar(5) DEFAULT NULL, + `server_id` int(11) NOT NULL DEFAULT '0', + `veid` int(10) unsigned NOT NULL, + `ostemplate_id` int(11) NOT NULL DEFAULT '0', + `template_id` int(11) NOT NULL DEFAULT '0', + `ip_address` varchar(255) NOT NULL, + `hostname` varchar(255) DEFAULT NULL, + `vm_password` varchar(255) DEFAULT NULL, + `start_boot` varchar(255) NOT NULL DEFAULT 'y', + `active` varchar(255) NOT NULL DEFAULT 'y', + `active_until_date` date NOT NULL, + `description` text, + `diskspace` int(11) NOT NULL DEFAULT '0', + `traffic` int(11) NOT NULL DEFAULT '-1', + `bandwidth` int(11) NOT NULL DEFAULT '-1', + `ram` int(11) NOT NULL DEFAULT '0', + `ram_burst` int(11) NOT NULL DEFAULT '0', + `cpu_units` int(11) NOT NULL DEFAULT '1000', + `cpu_num` int(11) NOT NULL DEFAULT '4', + `cpu_limit` int(11) NOT NULL DEFAULT '400', + `io_priority` int(11) NOT NULL DEFAULT '4', + `nameserver` varchar(255) NOT NULL DEFAULT '8.8.8.8 8.8.4.4', + `create_dns` varchar(1) NOT NULL DEFAULT 'n', + `capability` text NOT NULL, + `config` mediumtext NOT NULL, + PRIMARY KEY (`vm_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +-- +-- Dumping data for table `openvz_vm` +-- + +-- -------------------------------------------------------- + -- -- Table structure for table `proxy_reverse` -- diff --git a/interface/lib/lang/en.lng b/interface/lib/lang/en.lng index f2969404b..6ea7d9b79 100644 --- a/interface/lib/lang/en.lng +++ b/interface/lib/lang/en.lng @@ -36,7 +36,7 @@ $wb['top_menu_help'] = 'Help'; $wb['top_menu_billing'] = 'Billing'; $wb['top_menu_domain'] = 'Domains'; $wb['top_menu_dashboard'] = 'Home'; -$wb['top_menu_vm'] = 'VM'; +$wb['top_menu_vm'] = 'VServer'; $wb['toolsarea_head_txt'] = 'Tools'; $wb['latest_news_txt'] = 'Latest news'; ?> diff --git a/interface/web/client/client_edit.php b/interface/web/client/client_edit.php index ddeabc47d..458139753 100644 --- a/interface/web/client/client_edit.php +++ b/interface/web/client/client_edit.php @@ -161,7 +161,7 @@ class page_action extends tform_actions { // Create the controlpaneluser for the client //Generate ssh-rsa-keys exec('ssh-keygen -t rsa -C '.$username.'-rsa-key-'.time().' -f /tmp/id_rsa -N ""'); - $app->db->query("UPDATE client SET created_at = ".time().", id_rsa = '".file_get_contents('/tmp/id_rsa')."', ssh_rsa = '".file_get_contents('/tmp/id_rsa.pub')."' WHERE client_id = ".$this->id); + $app->db->query("UPDATE client SET created_at = ".time().", id_rsa = '".$app->db->quote(@file_get_contents('/tmp/id_rsa'))."', ssh_rsa = '".$app->db->quote(@file_get_contents('/tmp/id_rsa.pub'))."' WHERE client_id = ".$this->id); exec('rm -f /tmp/id_rsa /tmp/id_rsa.pub'); // Create the controlpaneluser for the client diff --git a/interface/web/themes/default/icons/x32/drawer.png b/interface/web/themes/default/icons/x32/drawer.png new file mode 100644 index 0000000000000000000000000000000000000000..9a1f2147c8febb182765f9570c24d8c47e5b54b9 GIT binary patch literal 1088 zcmV-G1i$-WdJZaFEThUF)%GE=zRbH z1C>ccK~z|Uy_d~vBt;m;fBiY#84r`aOGrZS=E3a2z3eK)gWy2~Z=PN7>#FP@;2+?s z;9f-Vs;9!e>SqA**rl+x79nOsnbEwc=nWz3&G1>n!ek9%EU?`2UOxAG|d%LP@ff>NLq zRaH?{mHFL#hFs7$*3M&a1{JWD;J1elmoD%;0@o$1FDiX5_)ALivLvg|gh#X48H#YA z28?`-_t$r~%zK192P^MG;XH5r$#Q1=;~Z2;+pJDERg0=zI!j z7wC$1U6=j+{f_(qJ3Bip77G@O#W`HivxN#F5JE7U%>X!h@}%Dd*1kU)jaqs76zICZ z`k*fcUCDT0CZh&?ZxN+w+l2*mq6C;*uHYbw41kL{rJA$ zx)Bvc(Yg)gc}`g$PR+1!e8+Ki0p5J>Uj-(UNo$a{;CMVXR`LeBXjRLyk>u;u0o?$qE`4hV5@zt{cy 0 id must match with id of current user +$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user +$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete + +$form["tabs"]['main'] = array ( + 'title' => "IP address", + 'width' => 100, + 'template' => "templates/openvz_ip_edit.htm", + 'fields' => array ( + ################################## + # Begin Datatable fields + ################################## + 'server_id' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'value' => '' + ), + 'ip_address' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISIPV4', + 'errmsg'=> 'ip_error_wrong'), + 1 => array ( 'type' => 'UNIQUE', + 'errmsg'=> 'ip_error_unique'), + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '15', + 'maxlength' => '15', + 'rows' => '', + 'cols' => '' + ), + 'vm_id' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT vm_id,hostname FROM openvz_vm WHERE {AUTHSQL} ORDER BY hostname', + 'keyfield'=> 'vm_id', + 'valuefield'=> 'hostname' + ), + 'value' => array(0 => '- Not assigned -') + ), + 'reserved' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n',1 => 'y') + ), + ################################## + # ENDE Datatable fields + ################################## + ) +); + + +?> \ No newline at end of file diff --git a/interface/web/vm/form/openvz_ostemplate.tform.php b/interface/web/vm/form/openvz_ostemplate.tform.php new file mode 100644 index 000000000..279a9a5de --- /dev/null +++ b/interface/web/vm/form/openvz_ostemplate.tform.php @@ -0,0 +1,124 @@ + 0 id must match with id of current user +$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user +$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete + +$form["tabs"]['main'] = array ( + 'title' => "Template", + 'width' => 100, + 'template' => "templates/openvz_ostemplate_edit.htm", + 'fields' => array ( + ################################## + # Begin Datatable fields + ################################## + 'template_name' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'template_name_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'template_file' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'template_file_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'server_id' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'value' => '' + ), + 'allservers' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n',1 => 'y') + ), + 'active' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n',1 => 'y') + ), + 'description' => array ( + 'datatype' => 'TEXT', + 'formtype' => 'TEXTAREA', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '', + 'maxlength' => '', + 'rows' => '10', + 'cols' => '30' + ), + ################################## + # ENDE Datatable fields + ################################## + ) +); + + +?> \ No newline at end of file diff --git a/interface/web/vm/form/openvz_template.tform.php b/interface/web/vm/form/openvz_template.tform.php new file mode 100644 index 000000000..845d2bcfe --- /dev/null +++ b/interface/web/vm/form/openvz_template.tform.php @@ -0,0 +1,462 @@ + 0 id must match with id of current user +$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user +$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete + +$form["tabs"]['main'] = array ( + 'title' => "Template", + 'width' => 100, + 'template' => "templates/openvz_template_edit.htm", + 'fields' => array ( + ################################## + # Begin Datatable fields + ################################## + 'template_name' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'template_name_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'diskspace' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'diskspace_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'ram' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'ram_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'ram_burst' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'ram_burst_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'cpu_units' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'cpu_units_error_empty'), + ), + 'default' => '1000', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'cpu_num' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'cpu_num_error_empty'), + ), + 'default' => '4', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'cpu_limit' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'cpu_limit_error_empty'), + ), + 'default' => '400', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'io_priority' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'io_priority_error_empty'), + ), + 'default' => '4', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'hostname' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'create_dns' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n',1 => 'y') + ), + 'nameserver' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'template_nameserver_error_empty'), + ), + 'default' => '8.8.8.8 8.8.4.4', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'active' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n',1 => 'y') + ), + 'description' => array ( + 'datatype' => 'TEXT', + 'formtype' => 'TEXTAREA', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '', + 'maxlength' => '', + 'rows' => '10', + 'cols' => '30' + ), + ################################## + # ENDE Datatable fields + ################################## + ) +); + +$form["tabs"]['advanced'] = array ( + 'title' => "Advanced", + 'width' => 100, + 'template' => "templates/openvz_template_advanced_edit.htm", + 'fields' => array ( + ################################## + # Begin Datatable fields + ################################## + 'numproc' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'numproc_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'numtcpsock' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'numtcpsock_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'numothersock' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'numothersock_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'vmguarpages' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'vmguarpages_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'kmemsize' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'kmemsize_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'tcpsndbuf' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'tcpsndbuf_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'tcprcvbuf' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'tcprcvbuf_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'othersockbuf' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'othersockbuf_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'dgramrcvbuf' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'dgramrcvbuf_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'oomguarpages' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'oomguarpages_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'privvmpages' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'privvmpages_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'lockedpages' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'lockedpages_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'shmpages' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'shmpages_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'physpages' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'physpages_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'numfile' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'numfile_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'avnumproc' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'avnumproc_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'numflock' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'numflock_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'numpty' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'numpty_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'numsiginfo' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'numsiginfo_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'dcachesize' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'dcachesize_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'numiptent' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'numiptent_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'swappages' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'swappages_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'capability' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + ################################## + # ENDE Datatable fields + ################################## + ) +); + + +?> \ No newline at end of file diff --git a/interface/web/vm/form/openvz_vm.tform.php b/interface/web/vm/form/openvz_vm.tform.php new file mode 100644 index 000000000..75b36c1ca --- /dev/null +++ b/interface/web/vm/form/openvz_vm.tform.php @@ -0,0 +1,297 @@ + 0 id must match with id of current user +$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user +$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete + +$form["tabs"]['main'] = array ( + 'title' => "Virtual server", + 'width' => 100, + 'template' => "templates/openvz_vm_edit.htm", + 'fields' => array ( + ################################## + # Begin Datatable fields + ################################## + 'server_id' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'value' => '' + ), + 'ostemplate_id' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT ostemplate_id,template_name FROM openvz_ostemplate WHERE {AUTHSQL} ORDER BY template_name', + 'keyfield'=> 'ostemplate_id', + 'valuefield'=> 'template_name' + ), + 'value' => '' + ), + 'template_id' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE {AUTHSQL} ORDER BY template_name', + 'keyfield'=> 'template_id', + 'valuefield'=> 'template_name' + ), + 'value' => '' + ), + 'ip_address' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'ip_address_error_empty'), + ), + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => "SELECT ip_address FROM openvz_ip WHERE reserved = 'n' AND (vm_id = 0 or vm_id = '{RECORDID}') AND {AUTHSQL} ORDER BY ip_address", + 'keyfield'=> 'ip_address', + 'valuefield'=> 'ip_address' + ), + 'value' => '' + ), + 'hostname' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'hostname_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'vm_password' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'vm_password_error_empty'), + ), + 'default' => $app->auth->get_random_password(10), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'start_boot' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n',1 => 'y') + ), + 'active' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n',1 => 'y') + ), + 'active_until_date' => array ( + 'datatype' => 'DATE', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'description' => array ( + 'datatype' => 'TEXT', + 'formtype' => 'TEXTAREA', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '', + 'maxlength' => '', + 'rows' => '10', + 'cols' => '30' + ), + ################################## + # ENDE Datatable fields + ################################## + ) +); + +$form["tabs"]['advanced'] = array ( + 'title' => "Advanced", + 'width' => 100, + 'template' => "templates/openvz_vm_advanced_edit.htm", + 'fields' => array ( + ################################## + # Begin Datatable fields + ################################## + 'veid' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'veid_error_empty'), + 1 => array ( 'type' => 'UNIQUE', + 'errmsg'=> 'veid_error_unique'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'create_dns' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n',1 => 'y') + ), + 'diskspace' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'diskspace_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'ram' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'ram_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'ram_burst' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'ram_burst_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'cpu_units' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'cpu_units_error_empty'), + ), + 'default' => '1000', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'cpu_num' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'cpu_num_error_empty'), + ), + 'default' => '4', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'cpu_limit' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'cpu_limit_error_empty'), + ), + 'default' => '400', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'io_priority' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'io_priority_error_empty'), + ), + 'default' => '4', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'nameserver' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'template_nameserver_error_empty'), + ), + 'default' => '8.8.8.8 8.8.4.4', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'capability' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + ################################## + # ENDE Datatable fields + ################################## + ) +); + + +?> \ No newline at end of file diff --git a/interface/web/vm/lib/admin.conf.php b/interface/web/vm/lib/admin.conf.php new file mode 100644 index 000000000..a45d44034 --- /dev/null +++ b/interface/web/vm/lib/admin.conf.php @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/interface/web/vm/lib/lang/en_openvz_ip.lng b/interface/web/vm/lib/lang/en_openvz_ip.lng new file mode 100644 index 000000000..98d5c98e8 --- /dev/null +++ b/interface/web/vm/lib/lang/en_openvz_ip.lng @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/interface/web/vm/lib/lang/en_openvz_ip_list.lng b/interface/web/vm/lib/lang/en_openvz_ip_list.lng new file mode 100644 index 000000000..e326e69b0 --- /dev/null +++ b/interface/web/vm/lib/lang/en_openvz_ip_list.lng @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/interface/web/vm/lib/lang/en_openvz_ostemplate.lng b/interface/web/vm/lib/lang/en_openvz_ostemplate.lng new file mode 100644 index 000000000..3e31fc3bb --- /dev/null +++ b/interface/web/vm/lib/lang/en_openvz_ostemplate.lng @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/interface/web/vm/lib/lang/en_openvz_ostemplate_list.lng b/interface/web/vm/lib/lang/en_openvz_ostemplate_list.lng new file mode 100644 index 000000000..93dafbe63 --- /dev/null +++ b/interface/web/vm/lib/lang/en_openvz_ostemplate_list.lng @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/interface/web/vm/lib/lang/en_openvz_template.lng b/interface/web/vm/lib/lang/en_openvz_template.lng new file mode 100644 index 000000000..a2619f192 --- /dev/null +++ b/interface/web/vm/lib/lang/en_openvz_template.lng @@ -0,0 +1,60 @@ + \ No newline at end of file diff --git a/interface/web/vm/lib/lang/en_openvz_template_list.lng b/interface/web/vm/lib/lang/en_openvz_template_list.lng new file mode 100644 index 000000000..28a149ae4 --- /dev/null +++ b/interface/web/vm/lib/lang/en_openvz_template_list.lng @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/interface/web/vm/lib/lang/en_openvz_vm.lng b/interface/web/vm/lib/lang/en_openvz_vm.lng new file mode 100644 index 000000000..ac350b0b2 --- /dev/null +++ b/interface/web/vm/lib/lang/en_openvz_vm.lng @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/interface/web/vm/lib/lang/en_openvz_vm_list.lng b/interface/web/vm/lib/lang/en_openvz_vm_list.lng new file mode 100644 index 000000000..f0f133625 --- /dev/null +++ b/interface/web/vm/lib/lang/en_openvz_vm_list.lng @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/interface/web/vm/lib/module.conf.php b/interface/web/vm/lib/module.conf.php new file mode 100644 index 000000000..5d0e2c80a --- /dev/null +++ b/interface/web/vm/lib/module.conf.php @@ -0,0 +1,67 @@ + 'Virtual Servers', + 'target' => 'content', + 'link' => 'vm/openvz_vm_list.php', + 'html_id' => 'openvz_vm_list'); + +$items[] = array( 'title' => 'OS Templates', + 'target' => 'content', + 'link' => 'vm/openvz_ostemplate_list.php', + 'html_id' => 'openvz_ostemplate_list'); + +$items[] = array( 'title' => 'VM Templates', + 'target' => 'content', + 'link' => 'vm/openvz_template_list.php', + 'html_id' => 'openvz_template_list'); + +$items[] = array( 'title' => 'IP addresses', + 'target' => 'content', + 'link' => 'vm/openvz_ip_list.php', + 'html_id' => 'openvz_ip_list'); + +if(count($items)) +{ + $module['nav'][] = array( 'title' => 'OpenVZ', + 'open' => 1, + 'items' => $items); +} + + +//**** Statistics menu +/* +$items = array(); + +$items[] = array( 'title' => 'Traffic', + 'target' => 'content', + 'link' => 'vm/traffic_stats.php', + 'html_id' => 'vm_traffic_stats'); + +$items[] = array( 'title' => 'Vserver monitor', + 'target' => 'content', + 'link' => 'vm/traffic_stats.php', + 'html_id' => 'vm_traffic_stats'); + +if(count($items)) +{ + $module['nav'][] = array( 'title' => 'Statistics', + 'open' => 1, + 'items' => $items); +} +*/ + + + + + + +?> \ No newline at end of file diff --git a/interface/web/vm/list/openvz_ip.list.php b/interface/web/vm/list/openvz_ip.list.php new file mode 100644 index 000000000..09a21faec --- /dev/null +++ b/interface/web/vm/list/openvz_ip.list.php @@ -0,0 +1,100 @@ + "server_id", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "", + 'suffix' => "", + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id, server_name FROM server WHERE vserver_server = 1 ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "vm_id", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "", + 'suffix' => "", + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT vm_id,hostname FROM openvz_vm WHERE {AUTHSQL} ORDER BY hostname', + 'keyfield'=> 'vm_id', + 'valuefield'=> 'hostname' + ), + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "ip_address", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "reserved", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('y' => "
Yes
", 'n' => "
No
")); + + + + + +?> \ No newline at end of file diff --git a/interface/web/vm/list/openvz_ostemplate.list.php b/interface/web/vm/list/openvz_ostemplate.list.php new file mode 100644 index 000000000..721885ed0 --- /dev/null +++ b/interface/web/vm/list/openvz_ostemplate.list.php @@ -0,0 +1,94 @@ + "active", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('y' => "
Yes
", 'n' => "
No
")); + + +$liste["item"][] = array( 'field' => "template_name", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "server_id", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "", + 'suffix' => "", + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id, server_name FROM server WHERE vserver_server = 1 ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "allservers", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('y' => "
Yes
", 'n' => "
No
")); + + + +?> \ No newline at end of file diff --git a/interface/web/vm/list/openvz_template.list.php b/interface/web/vm/list/openvz_template.list.php new file mode 100644 index 000000000..48d13eda2 --- /dev/null +++ b/interface/web/vm/list/openvz_template.list.php @@ -0,0 +1,70 @@ + "active", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('y' => "
Yes
", 'n' => "
No
")); + + +$liste["item"][] = array( 'field' => "template_name", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + + +?> \ No newline at end of file diff --git a/interface/web/vm/list/openvz_vm.list.php b/interface/web/vm/list/openvz_vm.list.php new file mode 100644 index 000000000..0d9c5e628 --- /dev/null +++ b/interface/web/vm/list/openvz_vm.list.php @@ -0,0 +1,129 @@ + "active", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('y' => "
Yes
", 'n' => "
No
")); + +$liste["item"][] = array( 'field' => "veid", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "==", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "server_id", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "", + 'suffix' => "", + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id, server_name FROM server WHERE vserver_server = 1 ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "ostemplate_id", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "", + 'suffix' => "", + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT ostemplate_id,template_name FROM openvz_ostemplate WHERE {AUTHSQL} ORDER BY template_name', + 'keyfield'=> 'ostemplate_id', + 'valuefield'=> 'template_name' + ), + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "template_id", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "", + 'suffix' => "", + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE {AUTHSQL} ORDER BY template_name', + 'keyfield'=> 'template_id', + 'valuefield'=> 'template_name' + ), + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "hostname", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "ip_address", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + + +?> \ No newline at end of file diff --git a/interface/web/vm/openvz_ip_del.php b/interface/web/vm/openvz_ip_del.php new file mode 100644 index 000000000..ce4ce276e --- /dev/null +++ b/interface/web/vm/openvz_ip_del.php @@ -0,0 +1,58 @@ +auth->check_module_permissions('vm'); + +$app->uses('tpl,tform'); +$app->load('tform_actions'); + +class page_action extends tform_actions { + +} + +$page = new page_action; +$page->onDelete() + +?> diff --git a/interface/web/vm/openvz_ip_edit.php b/interface/web/vm/openvz_ip_edit.php new file mode 100644 index 000000000..7a792448e --- /dev/null +++ b/interface/web/vm/openvz_ip_edit.php @@ -0,0 +1,58 @@ +auth->check_module_permissions('vm'); + +// Loading classes +$app->uses('tpl,tform'); +$app->load('tform_actions'); + +class page_action extends tform_actions { + +} + +$page = new page_action; +$page->onLoad(); + +?> \ No newline at end of file diff --git a/interface/web/vm/openvz_ip_list.php b/interface/web/vm/openvz_ip_list.php new file mode 100644 index 000000000..7f67ceca4 --- /dev/null +++ b/interface/web/vm/openvz_ip_list.php @@ -0,0 +1,54 @@ +auth->check_module_permissions('vm'); + +$app->uses('listform_actions'); + +// $app->listform_actions->SQLOrderBy = 'ORDER BY company_name, contact_name, client_id'; +// $app->listform_actions->SQLExtWhere = "limit_client = 0"; +$app->listform_actions->onLoad(); + + +?> \ No newline at end of file diff --git a/interface/web/vm/openvz_ostemplate_del.php b/interface/web/vm/openvz_ostemplate_del.php new file mode 100644 index 000000000..dec96f541 --- /dev/null +++ b/interface/web/vm/openvz_ostemplate_del.php @@ -0,0 +1,58 @@ +auth->check_module_permissions('vm'); + +$app->uses('tpl,tform'); +$app->load('tform_actions'); + +class page_action extends tform_actions { + +} + +$page = new page_action; +$page->onDelete() + +?> diff --git a/interface/web/vm/openvz_ostemplate_edit.php b/interface/web/vm/openvz_ostemplate_edit.php new file mode 100644 index 000000000..09a959811 --- /dev/null +++ b/interface/web/vm/openvz_ostemplate_edit.php @@ -0,0 +1,58 @@ +auth->check_module_permissions('vm'); + +// Loading classes +$app->uses('tpl,tform'); +$app->load('tform_actions'); + +class page_action extends tform_actions { + +} + +$page = new page_action; +$page->onLoad(); + +?> \ No newline at end of file diff --git a/interface/web/vm/openvz_ostemplate_list.php b/interface/web/vm/openvz_ostemplate_list.php new file mode 100644 index 000000000..f6f2a7062 --- /dev/null +++ b/interface/web/vm/openvz_ostemplate_list.php @@ -0,0 +1,54 @@ +auth->check_module_permissions('vm'); + +$app->uses('listform_actions'); + +// $app->listform_actions->SQLOrderBy = 'ORDER BY company_name, contact_name, client_id'; +// $app->listform_actions->SQLExtWhere = "limit_client = 0"; +$app->listform_actions->onLoad(); + + +?> \ No newline at end of file diff --git a/interface/web/vm/openvz_template_del.php b/interface/web/vm/openvz_template_del.php new file mode 100644 index 000000000..3b672e7dd --- /dev/null +++ b/interface/web/vm/openvz_template_del.php @@ -0,0 +1,58 @@ +auth->check_module_permissions('vm'); + +$app->uses('tpl,tform'); +$app->load('tform_actions'); + +class page_action extends tform_actions { + +} + +$page = new page_action; +$page->onDelete() + +?> diff --git a/interface/web/vm/openvz_template_edit.php b/interface/web/vm/openvz_template_edit.php new file mode 100644 index 000000000..2c1247a29 --- /dev/null +++ b/interface/web/vm/openvz_template_edit.php @@ -0,0 +1,76 @@ +auth->check_module_permissions('vm'); + +// Loading classes +$app->uses('tpl,tform'); +$app->load('tform_actions'); + +class page_action extends tform_actions { + + function onAfterInsert() { + global $app,$conf; + + $guar_ram = $this->dataRecord['ram']*256; + $burst_ram = $this->dataRecord['ram_burst']*256; + $sql = "UPDATE openvz_template SET shmpages = '$guar_ram:$guar_ram',vmguarpages = '$guar_ram:$guar_ram', oomguarpages = '$guar_ram:$guar_ram',privvmpages = '$burst_ram:$burst_ram' WHERE template_id = $this->id"; + $app->db->query($sql); + } + + function onAfterUpdate() { + global $app,$conf; + + $guar_ram = $this->dataRecord['ram']*256; + $burst_ram = $this->dataRecord['ram_burst']*256; + $sql = "UPDATE openvz_template SET shmpages = '$guar_ram:$guar_ram',vmguarpages = '$guar_ram:$guar_ram', oomguarpages = '$guar_ram:$guar_ram',privvmpages = '$burst_ram:$burst_ram' WHERE template_id = $this->id"; + $app->db->query($sql); + } + +} + +$page = new page_action; +$page->onLoad(); + +?> \ No newline at end of file diff --git a/interface/web/vm/openvz_template_list.php b/interface/web/vm/openvz_template_list.php new file mode 100644 index 000000000..0f4776431 --- /dev/null +++ b/interface/web/vm/openvz_template_list.php @@ -0,0 +1,54 @@ +auth->check_module_permissions('vm'); + +$app->uses('listform_actions'); + +// $app->listform_actions->SQLOrderBy = 'ORDER BY company_name, contact_name, client_id'; +// $app->listform_actions->SQLExtWhere = "limit_client = 0"; +$app->listform_actions->onLoad(); + + +?> \ No newline at end of file diff --git a/interface/web/vm/openvz_vm_del.php b/interface/web/vm/openvz_vm_del.php new file mode 100644 index 000000000..c8d8e196a --- /dev/null +++ b/interface/web/vm/openvz_vm_del.php @@ -0,0 +1,58 @@ +auth->check_module_permissions('vm'); + +$app->uses('tpl,tform'); +$app->load('tform_actions'); + +class page_action extends tform_actions { + +} + +$page = new page_action; +$page->onDelete() + +?> diff --git a/interface/web/vm/openvz_vm_edit.php b/interface/web/vm/openvz_vm_edit.php new file mode 100644 index 000000000..451bc01ee --- /dev/null +++ b/interface/web/vm/openvz_vm_edit.php @@ -0,0 +1,328 @@ +auth->check_module_permissions('vm'); + +// Loading classes +$app->uses('tpl,tform'); +$app->load('tform_actions'); + +class page_action extends tform_actions { + + function onShowEnd() { + global $app, $conf; + + //* Client: If the logged in user is not admin and has no sub clients (no rseller) + if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { + + //* Reseller: If the logged in user is not admin and has sub clients (is a rseller) + } elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { + + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + + + // Fill the client select field + $sql = "SELECT groupid, name FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id']." ORDER BY name"; + $records = $app->db->queryAllRecords($sql); + $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client['client_id']); + $client_select = ''; + $tmp_data_record = $app->tform->getDataRecord($this->id); + if(is_array($records)) { + foreach( $records as $rec) { + $selected = @($rec["groupid"] == $tmp_data_record["sys_groupid"])?'SELECTED':''; + $client_select .= "\r\n"; + } + } + $app->tpl->setVar("client_group_id",$client_select); + + //* Admin: If the logged in user is admin + } else { + + // Fill the client select field + $sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER BY name"; + $clients = $app->db->queryAllRecords($sql); + $client_select = ""; + $tmp_data_record = $app->tform->getDataRecord($this->id); + if(is_array($clients)) { + foreach( $clients as $client) { + $selected = @($client["groupid"] == $tmp_data_record["sys_groupid"])?'SELECTED':''; + $client_select .= "\r\n"; + } + } + $app->tpl->setVar("client_group_id",$client_select); + + } + + if($this->id > 0) { + //* we are editing a existing record + $app->tpl->setVar("edit_disabled", 1); + $app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]); + $app->tpl->setVar("ostemplate_id_value", $this->dataRecord["ostemplate_id"]); + } else { + $app->tpl->setVar("edit_disabled", 0); + } + + parent::onShowEnd(); + } + + function onSubmit() { + global $app, $conf; + + // Clients may not set the client_group_id, so we unset them if user is not a admin and the client is not a reseller + if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) unset($this->dataRecord["client_group_id"]); + + parent::onSubmit(); + } + + function onAfterInsert() { + global $app, $conf; + + // make sure that the record belongs to the clinet group and not the admin group when admin inserts it + // also make sure that the user can not delete domain created by a admin + if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { + $client_group_id = intval($this->dataRecord["client_group_id"]); + $app->db->query("UPDATE openvz_vm SET sys_groupid = $client_group_id WHERE vm_id = ".$this->id); + } + if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) { + $client_group_id = intval($this->dataRecord["client_group_id"]); + $app->db->query("UPDATE openvz_vm SET sys_groupid = $client_group_id WHERE vm_id = ".$this->id); + } + + // Set the VEID + $tmp = $app->db->queryOneRecord('SELECT MAX(veid) + 1 as newveid FROM openvz_vm'); + $veid = ($tmp['newveid'] > 100)?$tmp['newveid']:101; + $app->db->query("UPDATE openvz_vm SET veid = ".$veid." WHERE vm_id = ".$this->id); + unset($tmp); + + // Apply template values to the advanced tab settings + $this->applyTemplate(); + + // Set the IP address + $app->db->query("UPDATE openvz_ip SET vm_id = ".$this->id." WHERE ip_address = '".$this->dataRecord['ip_address']."'"); + + // Create the OpenVZ config file and store it in config field + $this->makeOpenVZConfig(); + + // Create the DNS record + $this->createDNS(); + + } + + function onAfterUpdate() { + global $app, $conf; + + // make sure that the record belongs to the clinet group and not the admin group when a admin inserts it + // also make sure that the user can not delete domain created by a admin + if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { + $client_group_id = intval($this->dataRecord["client_group_id"]); + $app->db->query("UPDATE openvz_vm SET sys_groupid = $client_group_id WHERE vm_id = ".$this->id); + } + if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) { + $client_group_id = intval($this->dataRecord["client_group_id"]); + $app->db->query("UPDATE openvz_vm SET sys_groupid = $client_group_id WHERE vm_id = ".$this->id); + } + + if(isset($this->dataRecord["ostemplate_id"]) && $this->oldDataRecord["ostemplate_id"] != $this->dataRecord["ostemplate_id"]) { + $this->applyTemplate(); + } + + // Set the IP address + if(isset($this->dataRecord['ip_address'])) $app->db->query("UPDATE openvz_ip SET vm_id = ".$this->id." WHERE ip_address = '".$this->dataRecord['ip_address']."'"); + + // Create the OpenVZ config file and store it in config field + $this->makeOpenVZConfig(); + + // Create the DNS record + if((isset($this->dataRecord['hostname']) && $this->dataRecord['hostname'] != $this->oldDataRecord['hostname']) + or (isset($this->dataRecord['create_dns']) && $this->dataRecord['create_dns'] != $this->oldDataRecord['create_dns'])) { + $this->createDNS(); + } + + } + + function onAfterDelete() { + global $app, $conf; + + //* Release all IP addresses which are assigned to this VM + $app->db->query("UPDATE openvz_ip SET vm_id = 0 WHERE vm_id = '".$this->id."'"); + + } + + function applyTemplate() { + global $app, $conf; + + $tpl = $app->db->queryOneRecord("SELECT * FROM openvz_template WHERE template_id = ".$this->dataRecord["template_id"]); + + $sql = "UPDATE openvz_vm SET "; + $sql .= "diskspace = '".$tpl['diskspace']."', "; + $sql .= "ram = '".$tpl['ram']."', "; + $sql .= "ram_burst = '".$tpl['ram_burst']."', "; + $sql .= "cpu_units = '".$tpl['cpu_units']."', "; + $sql .= "cpu_num = '".$tpl['cpu_num']."', "; + $sql .= "cpu_limit = '".$tpl['cpu_limit']."', "; + $sql .= "io_priority = '".$tpl['io_priority']."', "; + $sql .= "nameserver = '".$tpl['nameserver']."', "; + $sql .= "create_dns = '".$tpl['create_dns']."', "; + $sql .= "capability = '".$tpl['capability']."' "; + $sql .= "WHERE vm_id = ".$this->id; + $app->db->query($sql); + + } + + function makeOpenVZConfig() { + global $app, $conf; + + $vm = $app->tform->getDataRecord($this->id); + $vm_template = $app->db->queryOneRecord("SELECT * FROM openvz_template WHERE template_id = ".$vm['template_id']); + $burst_ram = $vm['ram_burst']*256; + $guar_ram = $vm['ram']*256; + + $tpl = new tpl(); + $tpl->newTemplate('templates/openvz.conf.tpl'); + + $onboot = ($vm['start_boot'] == 'y')?'yes':'no'; + $tpl->setVar('onboot',$onboot); + + $tpl->setVar('kmemsize',$vm_template['kmemsize']); + $tpl->setVar('lockedpages',$vm_template['lockedpages']); + $tpl->setVar('privvmpages',$burst_ram.':'.$burst_ram); + $tpl->setVar('shmpages',$guar_ram.':'.$guar_ram); + $tpl->setVar('numproc',$vm_template['numproc']); + $tpl->setVar('physpages',$vm_template['physpages']); + $tpl->setVar('vmguarpages',$guar_ram.':'.$guar_ram); + $tpl->setVar('oomguarpages',$guar_ram.':'.$guar_ram); + $tpl->setVar('numtcpsock',$vm_template['numtcpsock']); + $tpl->setVar('numflock',$vm_template['numflock']); + $tpl->setVar('numpty',$vm_template['numpty']); + $tpl->setVar('numsiginfo',$vm_template['numsiginfo']); + $tpl->setVar('tcpsndbuf',$vm_template['tcpsndbuf']); + $tpl->setVar('tcprcvbuf',$vm_template['tcprcvbuf']); + $tpl->setVar('othersockbuf',$vm_template['othersockbuf']); + $tpl->setVar('dgramrcvbuf',$vm_template['dgramrcvbuf']); + $tpl->setVar('numothersock',$vm_template['numothersock']); + $tpl->setVar('dcachesize',$vm_template['dcachesize']); + $tpl->setVar('numfile',$vm_template['numfile']); + $tpl->setVar('avnumproc',$vm_template['avnumproc']); + $tpl->setVar('numiptent',$vm_template['numiptent']); + + $diskspace = $vm['diskspace']*1048576; + $diskinodes = $vm['diskspace']*524288; + + $tpl->setVar('diskspace',$diskspace.":".$diskspace); + $tpl->setVar('diskinodes',$diskinodes.":".$diskinodes); + $tpl->setVar('io_priority',$vm['io_priority']); + + $tpl->setVar('cpu_num',$vm['cpu_num']); + $tpl->setVar('cpu_units',$vm['cpu_units']); + $tpl->setVar('cpu_limit',$vm['cpu_limit']); + + $hostname = str_replace('{VEID}',$vm['veid'],$vm['hostname']); + + $tpl->setVar('hostname',$hostname); + $tpl->setVar('ip_address',$vm['ip_address']); + $tpl->setVar('nameserver',$vm['nameserver']); + $tpl->setVar('capability',$vm['capability']); + + $tmp = $app->db->queryOneRecord("SELECT template_file FROM openvz_ostemplate WHERE ostemplate_id = ".$vm['ostemplate_id']); + $tpl->setVar('ostemplate',$tmp['template_file']); + unset($tmp); + + $openvz_config = $app->db->quote($tpl->grab()); + $app->db->query("UPDATE openvz_vm SET config = '".$openvz_config."' WHERE vm_id = ".$this->id); + + unset($tpl); + + } + + function createDNS() { + global $app, $conf; + + $vm = $app->tform->getDataRecord($this->id); + + if($vm['create_dns'] != 'y') return; + + $full_hostname = str_replace('{VEID}',$vm['veid'],$vm['hostname']); + $hostname_parts = explode('.',$full_hostname); + $hostname = $hostname_parts[0]; + unset($hostname_parts[0]); + $zone = implode('.',$hostname_parts); + unset($hostname_parts); + + // Find the dns zone + $zone_rec = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE origin = '$zone.'"); + $rr_rec = $app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = '".$zone_rec['id']."' AND name = '$hostname'"); + + if($zone_rec['id'] > 0) { + $ip_address = $vm['ip_address']; + $sys_userid = $zone_rec['sys_userid']; + $sys_groupid = $zone_rec['sys_groupid']; + $server_id = $zone_rec['server_id']; + $dns_soa_id = $zone_rec['id']; + + if($rr_rec['id'] > 0) { + $app->uses('validate_dns'); + $app->db->datalogUpdate('dns_rr', "data = '$ip_address'", 'id', $rr_rec['id']); + $serial = $app->validate_dns->increase_serial($zone_rec['serial']); + $app->db->datalogUpdate('dns_soa', "serial = '$serial'", 'id', $zone_rec['id']); + } else { + $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `zone`, `name`, `type`, `data`, `aux`, `ttl`, `active`) VALUES + ('$sys_userid', '$sys_groupid', 'riud', 'riud', '', '$server_id', '$dns_soa_id', '$hostname', 'A', '$ip_address', '0', '3600', 'Y')"; + $dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id'); + } + + } + + + + + } + +} + +$page = new page_action; +$page->onLoad(); + +?> \ No newline at end of file diff --git a/interface/web/vm/openvz_vm_list.php b/interface/web/vm/openvz_vm_list.php new file mode 100644 index 000000000..874feabbf --- /dev/null +++ b/interface/web/vm/openvz_vm_list.php @@ -0,0 +1,54 @@ +auth->check_module_permissions('vm'); + +$app->uses('listform_actions'); + +// $app->listform_actions->SQLOrderBy = 'ORDER BY company_name, contact_name, client_id'; +// $app->listform_actions->SQLExtWhere = "limit_client = 0"; +$app->listform_actions->onLoad(); + + +?> \ No newline at end of file diff --git a/interface/web/vm/templates/openvz.conf.tpl b/interface/web/vm/templates/openvz.conf.tpl new file mode 100644 index 000000000..c4c82c00c --- /dev/null +++ b/interface/web/vm/templates/openvz.conf.tpl @@ -0,0 +1,48 @@ + +# Template version +VERSION="2" + +# Parameters +ONBOOT="{tmpl_var name='onboot'}" +KMEMSIZE="{tmpl_var name='kmemsize'}" +LOCKEDPAGES="{tmpl_var name='lockedpages'}" +PRIVVMPAGES="{tmpl_var name='privvmpages'}" +SHMPAGES="{tmpl_var name='shmpages'}" +NUMPROC="{tmpl_var name='numproc'}" +PHYSPAGES="{tmpl_var name='physpages'}" +VMGUARPAGES="{tmpl_var name='vmguarpages'}" +OOMGUARPAGES="{tmpl_var name='oomguarpages'}" +NUMTCPSOCK="{tmpl_var name='numtcpsock'}" +NUMFLOCK="{tmpl_var name='numflock'}" +NUMPTY="{tmpl_var name='numpty'}" +NUMSIGINFO="{tmpl_var name='numsiginfo'}" +TCPSNDBUF="{tmpl_var name='tcpsndbuf'}" +TCPRCVBUF="{tmpl_var name='tcprcvbuf'}" +OTHERSOCKBUF="{tmpl_var name='othersockbuf'}" +DGRAMRCVBUF="{tmpl_var name='dgramrcvbuf'}" +NUMOTHERSOCK="{tmpl_var name='numothersock'}" +DCACHESIZE="{tmpl_var name='dcachesize'}" +NUMFILE="{tmpl_var name='numfile'}" +AVNUMPROC="{tmpl_var name='avnumproc'}" +NUMIPTENT="{tmpl_var name='numiptent'}" + +DISKSPACE="{tmpl_var name='diskspace'}" +DISKINODES="{tmpl_var name='diskinodes'}" +QUOTAUGIDLIMIT="10000" +IOPRIO="{tmpl_var name='io_priority'}" +QUOTATIME="0" + +CPUS="{tmpl_var name='cpu_num'}" +CPUUNITS="{tmpl_var name='cpu_units'}" +CPULIMIT="{tmpl_var name='cpu_limit'}" + +VE_ROOT="/vz/root/$VEID" +VE_PRIVATE="/vz/private/$VEID" +OSTEMPLATE="{tmpl_var name='ostemplate'}" +ORIGIN_SAMPLE="vps.basic" +HOSTNAME="{tmpl_var name='hostname'}" +IP_ADDRESS="{tmpl_var name='ip_address'}" +NAMESERVER="{tmpl_var name='nameserver'}" +MEMINFO="pages:256000" + +CAPABILITY="{tmpl_var name='capability'}" diff --git a/interface/web/vm/templates/openvz_ip_edit.htm b/interface/web/vm/templates/openvz_ip_edit.htm new file mode 100644 index 000000000..97ce3893b --- /dev/null +++ b/interface/web/vm/templates/openvz_ip_edit.htm @@ -0,0 +1,40 @@ +

+

+ +
+ +
+
IP address +
+ + +
+
+ + +
+
+ + +
+
+

{tmpl_var name='reserved_txt'}

+
+ {tmpl_var name='reserved'} +
+
+
+ + + +
+ + +
+
+ +
diff --git a/interface/web/vm/templates/openvz_ip_list.htm b/interface/web/vm/templates/openvz_ip_list.htm new file mode 100644 index 000000000..5c7c567a0 --- /dev/null +++ b/interface/web/vm/templates/openvz_ip_list.htm @@ -0,0 +1,58 @@ +

+ +
+ +
+
{tmpl_var name="toolsarea_head_txt"} +
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
{tmpl_var name="server_id"}{tmpl_var name="vm_id"}{tmpl_var name="ip_address"}{tmpl_var name="reserved"} + +
+
+
+ +
diff --git a/interface/web/vm/templates/openvz_ostemplate_edit.htm b/interface/web/vm/templates/openvz_ostemplate_edit.htm new file mode 100644 index 000000000..a0e070c51 --- /dev/null +++ b/interface/web/vm/templates/openvz_ostemplate_edit.htm @@ -0,0 +1,48 @@ +

+

+ +
+ +
+
Domain +
+ + +
+
+ + +
+
+ + +
+
+

{tmpl_var name='allservers_txt'}

+
+ {tmpl_var name='allservers'} +
+
+
+

{tmpl_var name='active_txt'}

+
+ {tmpl_var name='active'} +
+
+
+ + +
+
+ + + +
+ + +
+
+ +
diff --git a/interface/web/vm/templates/openvz_ostemplate_list.htm b/interface/web/vm/templates/openvz_ostemplate_list.htm new file mode 100644 index 000000000..10b83d508 --- /dev/null +++ b/interface/web/vm/templates/openvz_ostemplate_list.htm @@ -0,0 +1,58 @@ +

+ +
+ +
+
{tmpl_var name="toolsarea_head_txt"} +
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
{tmpl_var name="active"}{tmpl_var name="template_name"}{tmpl_var name="server_id"}{tmpl_var name="allservers"} + +
+
+
+ +
diff --git a/interface/web/vm/templates/openvz_template_advanced_edit.htm b/interface/web/vm/templates/openvz_template_advanced_edit.htm new file mode 100644 index 000000000..1f7e19d00 --- /dev/null +++ b/interface/web/vm/templates/openvz_template_advanced_edit.htm @@ -0,0 +1,110 @@ +

+

+ +
+ +
+
Advanced +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+ + +
+
+ +
diff --git a/interface/web/vm/templates/openvz_template_edit.htm b/interface/web/vm/templates/openvz_template_edit.htm new file mode 100644 index 000000000..09d49e458 --- /dev/null +++ b/interface/web/vm/templates/openvz_template_edit.htm @@ -0,0 +1,74 @@ +

+

+ +
+ +
+
Template +
+ + +
+
+ +  GB +
+
+ +  MB +
+
+ +  MB +
+
+ +  (8 - 500000) +
+
+ +  (1 - 64) +
+
+ +  (10 - 6400) +
+
+ +  (0 - 7) +
+
+ + +
+
+

{tmpl_var name='create_dns_txt'}

+
+ {tmpl_var name='create_dns'} +
+
+
+ +  {tmpl_var name='nameserver_desc_txt'} +
+
+

{tmpl_var name='active_txt'}

+
+ {tmpl_var name='active'} +
+
+
+ + +
+
+ + + +
+ + +
+
+ +
diff --git a/interface/web/vm/templates/openvz_template_list.htm b/interface/web/vm/templates/openvz_template_list.htm new file mode 100644 index 000000000..b6ffe2bb1 --- /dev/null +++ b/interface/web/vm/templates/openvz_template_list.htm @@ -0,0 +1,52 @@ +

+ +
+ +
+
{tmpl_var name="toolsarea_head_txt"} +
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
{tmpl_var name="active"}{tmpl_var name="template_name"} + +
+
+
+ +
diff --git a/interface/web/vm/templates/openvz_vm_advanced_edit.htm b/interface/web/vm/templates/openvz_vm_advanced_edit.htm new file mode 100644 index 000000000..36981a882 --- /dev/null +++ b/interface/web/vm/templates/openvz_vm_advanced_edit.htm @@ -0,0 +1,64 @@ +

+

+ +
+ +
+
Advanced +
+ + +
+
+

{tmpl_var name='create_dns_txt'}

+
+ {tmpl_var name='create_dns'} +
+
+
+ +  GB +
+
+ +  MB +
+
+ +  MB +
+
+ +  (8 - 500000) +
+
+ +  (1 - 64) +
+
+ +  (10 - 6400) +
+
+ +  (0 - 7) +
+
+ +  {tmpl_var name='nameserver_desc_txt'} +
+
+ + +
+
+ + + +
+ + +
+
+ +
diff --git a/interface/web/vm/templates/openvz_vm_edit.htm b/interface/web/vm/templates/openvz_vm_edit.htm new file mode 100644 index 000000000..2f8ac77a6 --- /dev/null +++ b/interface/web/vm/templates/openvz_vm_edit.htm @@ -0,0 +1,104 @@ +

+

+ +
+ +
+
Settings + +
+ + + + + + + + +
+
+ + +
+
+ +
+ + +
+
+ +
+ + +
+ + +
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+

{tmpl_var name='start_boot_txt'}

+
+ {tmpl_var name='start_boot'} +
+
+
+

{tmpl_var name='active_txt'}

+
+ {tmpl_var name='active'} +
+
+
+ + +
+
+ + +
+
+ + + +
+ + +
+
+ +
diff --git a/interface/web/vm/templates/openvz_vm_list.htm b/interface/web/vm/templates/openvz_vm_list.htm new file mode 100644 index 000000000..6c08b31e5 --- /dev/null +++ b/interface/web/vm/templates/openvz_vm_list.htm @@ -0,0 +1,67 @@ +

+ +
+ +
+
{tmpl_var name="toolsarea_head_txt"} +
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
{tmpl_var name="active"}{tmpl_var name="veid"}{tmpl_var name="server_id"}{tmpl_var name="ostemplate_id"}{tmpl_var name="template_id"}{tmpl_var name="hostname"}{tmpl_var name="ip_address"} + +
+
+
+ +
diff --git a/server/cron_daily.php b/server/cron_daily.php index 8ea43956e..2d12f2ce8 100644 --- a/server/cron_daily.php +++ b/server/cron_daily.php @@ -392,6 +392,27 @@ if ($app->dbmaster == $app->db) { } +} + + +####################################################################################################### +// deactivate virtual servers (run only on the "master-server") +####################################################################################################### + +if ($app->dbmaster == $app->db) { + $current_date = date('Y-m-d'); + + //* Check which virtual machines have to be deactivated + $sql = "SELECT * FROM openvz_vm WHERE active = 'y' AND active_until_date != '0000-00-00' AND active_until_date < '$current_date'"; + $records = $app->db->queryAllRecords($sql); + if(is_array($records)) { + foreach($records as $rec) { + $app->dbmaster->datalogUpdate('openvz_vm', "active = 'n'", 'vm_id', $rec['vm_id']); + $app->log('Virtual machine active date expired. Disabling VM '.$rec['veid'],LOGLEVEL_DEBUG); + } + } + + } ####################################################################################################### diff --git a/server/mods-available/vm_module.inc.php b/server/mods-available/vm_module.inc.php new file mode 100644 index 000000000..9a7fc371d --- /dev/null +++ b/server/mods-available/vm_module.inc.php @@ -0,0 +1,118 @@ +plugins->announceEvents($this->module_name,$this->actions_available); + + /* + As we want to get notified of any changes on several database tables, + we register for them. + + The following function registers the function "functionname" + to be executed when a record for the table "dbtable" is + processed in the sys_datalog. "classname" is the name of the + class that contains the function functionname. + */ + + $app->modules->registerTableHook('openvz_vm',$this->module_name,'process'); + $app->modules->registerTableHook('openvz_ip',$this->module_name,'process'); + $app->modules->registerTableHook('openvz_ostemplate',$this->module_name,'process'); + + } + + /* + This function is called when a change in one of the registered tables is detected. + The function then raises the events for the plugins. + */ + + function process($tablename,$action,$data) { + global $app; + + switch ($tablename) { + case 'openvz_vm': + if($action == 'i') $app->plugins->raiseEvent('openvz_vm_insert',$data); + if($action == 'u') $app->plugins->raiseEvent('openvz_vm_update',$data); + if($action == 'd') $app->plugins->raiseEvent('openvz_vm_delete',$data); + break; + case 'openvz_ip': + if($action == 'i') $app->plugins->raiseEvent('openvz_ip_insert',$data); + if($action == 'u') $app->plugins->raiseEvent('openvz_ip_update',$data); + if($action == 'd') $app->plugins->raiseEvent('openvz_ip_delete',$data); + break; + case 'openvz_ostemplate': + if($action == 'i') $app->plugins->raiseEvent('openvz_ostemplate_insert',$data); + if($action == 'u') $app->plugins->raiseEvent('openvz_ostemplate_update',$data); + if($action == 'd') $app->plugins->raiseEvent('openvz_ostemplate_delete',$data); + break; + } // end switch + } // end function + + +} // end class + +?> diff --git a/server/plugins-available/openvz_plugin.inc.php b/server/plugins-available/openvz_plugin.inc.php new file mode 100644 index 000000000..a9c630e5a --- /dev/null +++ b/server/plugins-available/openvz_plugin.inc.php @@ -0,0 +1,154 @@ +plugins->registerEvent('openvz_vm_insert',$this->plugin_name,'vm_insert'); + $app->plugins->registerEvent('openvz_vm_update',$this->plugin_name,'vm_update'); + $app->plugins->registerEvent('openvz_vm_delete',$this->plugin_name,'vm_delete'); + + } + + + function vm_insert($event_name,$data) { + global $app, $conf; + + $veid = intval($data['new']['veid']); + + if($veid == 0) { + $app->log("VEID = 0, we stop here.",LOGLEVEL_WARN); + return; + } + + $tmp = $app->db->queryOneRecord("SELECT template_file FROM openvz_ostemplate WHERE ostemplate_id = ".$vm['ostemplate_id']); + $ostemplate = escapeshellcmd($tmp['template_file']); + unset($tmp); + + //* Create the virtual machine + exec("vzctl create $veid --ostemplate $ostemplate"); + $app->log("Create OpenVZ VM: vzctl create $veid --ostemplate $ostemplate",LOGLEVEL_DEBUG); + + //* Write the configuration of the VM + file_put_contents('/etc/vz/conf/'.$veid.'.conf',$data['new']['config']); + + //* Start the VM + if($data['new']['active'] == 'y') { + exec("vzctl start $veid"); + $app->log("Starting OpenVZ VM: vzctl start $veid",LOGLEVEL_DEBUG); + } + + //* Set the root password in the virtual machine + exec("vzctl set $veid --userpasswd root:".escapeshellcmd($data['new']['vm_password'])); + + } + + function vm_update($event_name,$data) { + global $app, $conf; + + $veid = intval($data['new']['veid']); + + if($veid == 0) { + $app->log("VEID = 0, we stop here.",LOGLEVEL_WARN); + return; + } + + //* Write the configuration of the VM + file_put_contents('/etc/vz/conf/'.$veid.'.conf',$data['new']['config']); + $app->log("Writing new configuration for $veid",LOGLEVEL_DEBUG); + + //* Apply config changes to the VM + if($data['new']['active'] == 'y' && $data['old']['active'] == 'y') { + exec("vzctl restart $veid"); + $app->log("Restarting OpenVZ VM: vzctl restart $veid",LOGLEVEL_DEBUG); + } elseif ($data['new']['active'] == 'y' && $data['old']['active'] == 'n') { + exec("vzctl start $veid"); + $app->log("Starting OpenVZ VM: vzctl start $veid",LOGLEVEL_DEBUG); + } elseif ($data['new']['active'] == 'n' && $data['old']['active'] == 'y') { + exec("vzctl stop $veid"); + $app->log("Stopping OpenVZ VM: vzctl stop $veid",LOGLEVEL_DEBUG); + } + + //* Set the root password in the virtual machine + if($data['new']['vm_password'] != $data['old']['vm_password']) { + exec("vzctl set $veid --userpasswd root:".escapeshellcmd($data['new']['vm_password'])); + } + + + } + + function vm_delete($event_name,$data) { + global $app, $conf; + + $veid = intval($data['old']['veid']); + + if($veid == 0) { + $app->log("VEID = 0, we stop here.",LOGLEVEL_WARN); + return; + } + + exec("vzctl destroy $veid"); + $app->log("Destroying OpenVZ VM: vzctl destroy $veid",LOGLEVEL_DEBUG); + + } + + +} // end class + +?> -- GitLab