[pmg-devel] [PATCH pmg-api v2 08/10] ModGroup: add possibility to explode to all targets

Dominik Csapak d.csapak at proxmox.com
Wed Feb 21 13:24:34 CET 2024


we will need that for the remove action + and/invert
It's probably not the most efficient way to to that, but it's easy to
understand.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
promoted to normal commit instead of WIP, since the only way i'd found
to make it more 'efficient' is to copy/paste the subgroups code
and instead of looping inside the innermost loop about the targets,
do it on the outside, which is basically the same as we do here
(but the innermost loop is always 1 long)

 src/PMG/ModGroup.pm | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/PMG/ModGroup.pm b/src/PMG/ModGroup.pm
index b0fa9a6..d4e1cd5 100644
--- a/src/PMG/ModGroup.pm
+++ b/src/PMG/ModGroup.pm
@@ -81,6 +81,23 @@ sub subgroups {
     return $res;
 }
 
+# explode the groups, so we have one for each target we need
+# only to be used by the rRemove action when there was a spaminfo
+sub explode {
+    my ($self, $targets) = @_;
+
+    my $groups = $self->{groups};
+    my $ea = $self->{ea};
+    my $res;
+
+    # TODO: implment it more direclty with less overhead!
+    for my $target ($targets->@*) {
+	$self->subgroups([$target]);
+    }
+
+    return $self->subgroups($targets);
+}
+
 1;
 
 __END__
-- 
2.30.2





More information about the pmg-devel mailing list