]> git.proxmox.com Git - pve-firewall.git/commitdiff
subroutine for cloning vm's firewall config file
authorAlen Grizonic <a.grizonic@proxmox.com>
Mon, 24 Aug 2015 09:32:37 +0000 (11:32 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 25 Aug 2015 04:47:03 +0000 (06:47 +0200)
src/PVE/Firewall.pm

index 5962a4f6919a379f0d28cbbc7664bdf763018343..c1f871dc7cb4ae3192e067d0e5a612297b4f0b48 100644 (file)
@@ -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) = @_;