Signed-off-by: Fabian Ebner <f.eb...@proxmox.com>
---
 PVE/AbstractConfig.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/PVE/AbstractConfig.pm b/PVE/AbstractConfig.pm
index 6148271..5b1683b 100644
--- a/PVE/AbstractConfig.pm
+++ b/PVE/AbstractConfig.pm
@@ -419,6 +419,19 @@ sub add_unused_volume {
     return $key;
 }
 
+# Iterate over all unused volumes, calling $func for each key/value pair
+# with additional parameters @param.
+sub foreach_unused_volume {
+    my ($class, $conf, $func, @param) = @_;
+
+    foreach my $key (keys %{$conf}) {
+       if ($key =~ m/^unused\d+$/) {
+           my $volume = $class->parse_volume($key, $conf->{$key});
+           $func->($key, $volume, @param);
+       }
+    }
+}
+
 # Returns whether the template parameter is set in $conf.
 sub is_template {
     my ($class, $conf) = @_;
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to