[pve-devel] r5440 - in pve-common/trunk/data: . PVE
svn-commits at proxmox.com
svn-commits at proxmox.com
Tue Jan 25 12:01:09 CET 2011
Author: dietmar
Date: 2011-01-25 12:01:09 +0100 (Tue, 25 Jan 2011)
New Revision: 5440
Modified:
pve-common/trunk/data/ChangeLog
pve-common/trunk/data/PVE/JSONSchema.pm
Log:
* PVE/JSONSchema.pm (get_options): make boolean arguments
optional, allow "true|yes|on|false|no|off|0|1"
Modified: pve-common/trunk/data/ChangeLog
===================================================================
--- pve-common/trunk/data/ChangeLog 2011-01-25 10:28:18 UTC (rev 5439)
+++ pve-common/trunk/data/ChangeLog 2011-01-25 11:01:09 UTC (rev 5440)
@@ -1,3 +1,8 @@
+2011-01-25 Proxmox Support Team <support at proxmox.com>
+
+ * PVE/JSONSchema.pm (get_options): make boolean arguments
+ optional, allow "true|yes|on|false|no|off|0|1"
+
2011-01-19 root <root at maui.maurer-it.com>
* PVE/SafeSyslog.pm (tag): a way to read the log tag
Modified: pve-common/trunk/data/PVE/JSONSchema.pm
===================================================================
--- pve-common/trunk/data/PVE/JSONSchema.pm 2011-01-25 10:28:18 UTC (rev 5439)
+++ pve-common/trunk/data/PVE/JSONSchema.pm 2011-01-25 11:01:09 UTC (rev 5440)
@@ -772,6 +772,8 @@
# we turn this into a boolean option and ask for password below
# using $pwcallback() (for security reasons).
push @getopt, "$prop";
+ } elsif ($pd->{type} eq 'boolean') {
+ push @getopt, "$prop:s";
} else {
push @getopt, "$prop=s";
}
@@ -791,6 +793,22 @@
}
}
}
+
+ foreach my $p (keys %$opts) {
+ if (my $pd = $schema->{properties}->{$p}) {
+ if ($pd->{type} eq 'boolean') {
+ if ($opts->{$p} eq '') {
+ $opts->{$p} = 1;
+ } elsif ($opts->{$p} =~ m/^(1|true|yes|on)$/i) {
+ $opts->{$p} = 1;
+ } elsif ($opts->{$p} =~ m/^(0|false|no|off)$/i) {
+ $opts->{$p} = 0;
+ } else {
+ raise("unable to parse boolean option\n", code => HTTP_BAD_REQUEST);
+ }
+ }
+ }
+ }
foreach my $p (keys %$uri_param) {
$opts->{$p} = $uri_param->{$p};
More information about the pve-devel
mailing list