From 5471ff7cdeb055e8dcb6631b6b154c0dc0b61958 Mon Sep 17 00:00:00 2001 From: Alen Grizonic Date: Mon, 24 Aug 2015 11:32:37 +0200 Subject: [PATCH] subroutine for cloning vm's firewall config file --- 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.39.2