]> git.proxmox.com Git - pmg-api.git/commitdiff
pmgdb: add active parameter to dump
authorStoiko Ivanov <s.ivanov@proxmox.com>
Thu, 22 Feb 2024 21:06:20 +0000 (22:06 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 23 Feb 2024 10:53:51 +0000 (11:53 +0100)
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-by:  Friedrich Weber <f.weber@proxmox.com>
Tested-by:  Alexander Zeidler <a.zeidler@proxmox.com>
src/PMG/CLI/pmgdb.pm

index 28e9583de3173cf829c77e162db6759227f54b63..0ac3f824ecb749e9c31e15b085e98e4e035a277b 100644 (file)
@@ -39,10 +39,11 @@ sub print_objects {
 }
 
 sub print_rule {
-    my ($ruledb, $rule) = @_;
+    my ($ruledb, $rule, $active_only) = @_;
 
     $ruledb->load_rule_attributes($rule);
 
+    return if !$rule->{active} && $active_only;
     my $direction = {
        0 => 'in',
        1 => 'out',
@@ -112,7 +113,14 @@ __PACKAGE__->register_method ({
     description => "Print the PMG rule database.",
     parameters => {
        additionalProperties => 0,
-       properties => {},
+       properties => {
+           active => {
+               type => 'boolean',
+               description => "Print only active rules",
+               optional => 1,
+               default => 0,
+           },
+       },
     },
     returns => { type => 'null'},
     code => sub {
@@ -124,7 +132,7 @@ __PACKAGE__->register_method ({
        my $rules = $ruledb->load_rules();
 
        foreach my $rule (@$rules) {
-           print_rule($ruledb, $rule);
+           print_rule($ruledb, $rule, $param->{active});
        }
 
        $ruledb->close();