]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/JSONSchema.pm
Add run_fork_with_timeout utility
[pve-common.git] / src / PVE / JSONSchema.pm
index 9c624f694c6f423ee643ef025620c369b713f5bb..4278f7356d504914f04c6710c51df1f147eb511e 100644 (file)
@@ -1153,6 +1153,11 @@ my $method_schema = {
            description => "A parameter name. If specified, all calls to this method are proxied to the host contained in that parameter.",
            optional => 1,
        },
+       proxyto_callback => {
+           type =>  'coderef',
+           description => "A function which is called to resolve the proxyto attribute. The default implementaion returns the value of the 'proxyto' parameter.",
+           optional => 1,
+       },
         permissions => {
            type => 'object',
            description => "Required access permissions. By default only 'root' is allowed to access this method.",
@@ -1351,8 +1356,21 @@ sub get_options {
        }
     }
 
+    # decode after Getopt as we are not sure how well it handles unicode
     foreach my $p (keys %$opts) {
-       $opts->{$p} = decode('locale', $opts->{$p});
+       if (!ref($opts->{$p})) {
+           $opts->{$p} = decode('locale', $opts->{$p});
+       } elsif (ref($opts->{$p}) eq 'ARRAY') {
+           my $tmp = [];
+           foreach my $v (@{$opts->{$p}}) {
+               push @$tmp, decode('locale', $v);
+           }
+           $opts->{$p} = $tmp;
+       } elsif (ref($opts->{$p}) eq 'SCALAR') {
+           $opts->{$p} = decode('locale', $$opts->{$p});
+       } else {
+           raise("decoding options failed, unknown reference\n", code => HTTP_BAD_REQUEST);
+       }
     }
 
     foreach my $p (keys %$opts) {