]> git.proxmox.com Git - pve-manager.git/commitdiff
vzdump: refactor parsing mailto so it can be mocked
authorFabian Ebner <f.ebner@proxmox.com>
Mon, 15 Feb 2021 12:25:00 +0000 (13:25 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 19 Feb 2021 15:33:33 +0000 (16:33 +0100)
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/VZDump.pm
PVE/VZDump.pm

index 806ac7fd75bd0d5d4dd73f4b0083df9fe3b5c57c..44376106d49b129dc07607e3864b9151aa499b9a 100644 (file)
@@ -88,16 +88,7 @@ __PACKAGE__->register_method ({
        # silent exit if specified VMs run on other nodes
        return "OK" if !scalar(@{$local_vmids}) && !$param->{all};
 
-       # exclude-path list need to be 0 separated
-       if (defined($param->{'exclude-path'})) {
-           my @expaths = split(/\0/, $param->{'exclude-path'} || '');
-           $param->{'exclude-path'} = [ @expaths ];
-       }
-
-       if (defined($param->{mailto})) {
-           my @mailto = PVE::Tools::split_list(extract_param($param, 'mailto'));
-           $param->{mailto} = [ @mailto ];
-       }
+       PVE::VZDump::parse_mailto_exclude_path($param);
 
        die "you can only backup a single VM with option --stdout\n"
            if $param->{stdout} && scalar(@{$local_vmids}) != 1;
index a99d05657bda092c2f4aa5434c25f011c853f8c3..2ddfa851b02aa3e4b33979da9bebd2524fd279ce 100644 (file)
@@ -1177,6 +1177,27 @@ sub option_exists {
     return defined($confdesc->{$key});
 }
 
+# NOTE it might make sense to merge this and verify_vzdump_parameters(), but one
+# needs to adapt command_line() in guest-common's PVE/VZDump/Common.pm and detect
+# a second parsing attempt, because verify_vzdump_parameters() is called twice
+# during the update_job API call.
+sub parse_mailto_exclude_path {
+    my ($param) = @_;
+
+    # exclude-path list need to be 0 separated
+    if (defined($param->{'exclude-path'})) {
+       my @expaths = split(/\0/, $param->{'exclude-path'} || '');
+       $param->{'exclude-path'} = [ @expaths ];
+    }
+
+    if (defined($param->{mailto})) {
+       my @mailto = PVE::Tools::split_list(extract_param($param, 'mailto'));
+       $param->{mailto} = [ @mailto ];
+    }
+
+    return;
+}
+
 sub verify_vzdump_parameters {
     my ($param, $check_missing) = @_;