From d6cd11df635941a4e7d35e6e45b4e59cb8bd4469 Mon Sep 17 00:00:00 2001
From: Florian Schaal <florian@schaal-24.de>
Date: Fri, 04 Sep 2015 07:57:19 -0400
Subject: [PATCH] default for mount backup_dir set to no
---
interface/lib/plugins/vm_openvz_plugin.inc.php | 40 ++++++++++++++++++++++++++++++++++++----
1 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/interface/lib/plugins/vm_openvz_plugin.inc.php b/interface/lib/plugins/vm_openvz_plugin.inc.php
index 7cf46e6..305118d 100644
--- a/interface/lib/plugins/vm_openvz_plugin.inc.php
+++ b/interface/lib/plugins/vm_openvz_plugin.inc.php
@@ -60,6 +60,14 @@
// Set the IP address
$app->db->query("UPDATE openvz_ip SET vm_id = ? WHERE ip_address = ?", $this->id, $this->dataRecord['ip_address']);
+ // Set additional IPs
+ if (isset($this->dataRecord['additional_ip'])) {
+ $app->db->query("UPDATE openvz_ip SET vm_id = 0, additional = 'n' WHERE vm_id = ? AND additional='y'", $this->id);
+ foreach ($this->dataRecord['additional_ip'] as $idx => $rec) {
+ $app->db->query("UPDATE openvz_ip SET vm_id = ?, additional = 'y' WHERE ip_address = ?", $this->id, $rec);
+ }
+ }
+
// Create the OpenVZ config file and store it in config field
$this->makeOpenVZConfig();
@@ -94,7 +102,18 @@
}
// Set the IP address
- if(isset($this->dataRecord['ip_address'])) $app->db->query("UPDATE openvz_ip SET vm_id = ? WHERE ip_address = ?", $this->id, $this->dataRecord['ip_address']);
+ if(isset($this->dataRecord['ip_address'])) {
+ $app->db->query("UPDATE openvz_ip SET vm_id = 0 WHERE vm_id = ? AND additional='n'", $this->id);
+ $app->db->query("UPDATE openvz_ip SET vm_id = ?, additional = 'n' WHERE ip_address = ?", $this->id, $this->dataRecord['ip_address']);
+ }
+
+ // Set additional IPs
+ if (isset($this->dataRecord['additional_ip'])) {
+ $app->db->query("UPDATE openvz_ip SET vm_id = 0, additional = 'n' WHERE (vm_id = ? AND additional='y')", $this->id);
+ foreach ($this->dataRecord['additional_ip'] as $idx => $rec) {
+ $app->db->query("UPDATE openvz_ip SET vm_id = ?, additional = 'y' WHERE ip_address = ?", $this->id, $rec);
+ }
+ }
// Create the OpenVZ config file and store it in config field
$this->makeOpenVZConfig();
@@ -133,9 +152,10 @@
$sql .= "nameserver = ?, ";
$sql .= "create_dns = ?, ";
$sql .= "capability = ?, ";
- $sql .= "features = ? ";
+ $sql .= "features = ?, ";
+ $sql .= "iptables = ? ";
$sql .= "WHERE vm_id = ?";
- $app->db->query($sql, $tpl['diskspace'], $tpl['ram'], $tpl['ram_burst'], $tpl['cpu_units'], $tpl['cpu_num'], $tpl['cpu_limit'], $tpl['io_priority'], $tpl['nameserver'], $tpl['create_dns'], $tpl['capability'], $tpl['features'], $this->id);
+ $app->db->query($sql, $tpl['diskspace'], $tpl['ram'], $tpl['ram_burst'], $tpl['cpu_units'], $tpl['cpu_num'], $tpl['cpu_limit'], $tpl['io_priority'], $tpl['nameserver'], $tpl['create_dns'], $tpl['capability'], $tpl['features'], $tpl['iptables'], $this->id);
}
@@ -191,10 +211,22 @@
$hostname = str_replace('{VEID}', $vm['veid'], $vm['hostname']);
$tpl->setVar('hostname', $hostname);
+
+ $additional_ips = $app->db->queryAllRecords("SELECT * FROM openvz_ip WHERE vm_id = ?",$this->id);
+ if (isset($additional_ips)) {
+ $vm['ip_address']='';
+ foreach ($additional_ips as $ip) {
+ $vm['ip_address'] .= " ".$ip['ip_address'];
+ }
+ $vm['ip_address'] = substr($vm['ip_address'],1);
+ }
+ $tpl->setVar('ip_address', $vm['ip_address']);
+
$tpl->setVar('ip_address', $vm['ip_address']);
$tpl->setVar('nameserver', $vm['nameserver']);
$tpl->setVar('capability', $vm['capability']);
$tpl->setVar('features', $vm['features']);
+ $tpl->setVar('iptables', $vm['iptables']);
$tmp = $app->db->queryOneRecord("SELECT template_file FROM openvz_ostemplate WHERE ostemplate_id = ?", $app->functions->intval($vm['ostemplate_id']));
$tpl->setVar('ostemplate', $tmp['template_file']);
@@ -247,7 +279,7 @@
"server_id" => $server_id,
"zone" => $dns_soa_id,
"name" => $hostname,
- "type" => 'A',
+ "type" => @(preg_match("/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/", $ip_address))?'A':'AAAA',
"data" => $ip_address,
"aux" => '0',
"ttl" => '3600',
--
Gitblit v1.9.1