[pve-devel] [PATCH] subroutine for cloning vm's firewall config file

Alen Grizonic a.grizonic at proxmox.com
Mon Aug 24 11:32:37 CEST 2015


---
 src/PVE/Firewall.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm
index 5962a4f..c1f871d 100644
--- a/src/PVE/Firewall.pm
+++ b/src/PVE/Firewall.pm
@@ -2827,6 +2827,21 @@ sub remove_vmfw_conf {
     unlink $vmfw_conffile;
 }
 
+sub clone_vmfw_conf {
+    my ($vmid, $newid) = @_;
+
+    my $sourcevm_conffile = "$pvefw_conf_dir/$vmid.fw";
+    my $clonevm_conffile = "$pvefw_conf_dir/$newid.fw";
+
+    if (-f $clonevm_conffile) {
+	unlink $clonevm_conffile;
+    }
+    if (-f $sourcevm_conffile) {
+	my $data = PVE::Tools::file_get_contents($sourcevm_conffile);
+	PVE::Tools::file_set_contents($clonevm_conffile, $data);
+    }
+}
+
 sub read_vm_firewall_configs {
     my ($cluster_conf, $vmdata, $dir, $verbose) = @_;
 
-- 
2.1.4





More information about the pve-devel mailing list