]> git.proxmox.com Git - pve-common.git/commitdiff
JSONSchema: added disk-size format
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 1 Oct 2015 08:36:28 +0000 (10:36 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 1 Oct 2015 09:24:00 +0000 (11:24 +0200)
It's a special case in some output functions as it needs
to use format_size(), so it'll be its own type and handled
in the upcoming print_property_string() function.

src/PVE/JSONSchema.pm

index 5beebd80139a1aacbb8ce6dfc34b9bfa50417eb2..b9ef26a5dcccf0172e9e97590acb15e6b9520d6a 100644 (file)
@@ -341,6 +341,16 @@ sub pve_verify_address {
     return $addr;
 }
 
     return $addr;
 }
 
+register_format('disk-size', \&pve_verify_disk_size);
+sub pve_verify_disk_size {
+    my ($size, $noerr) = @_;
+    if (!defined(parse_size($size))) {
+       return undef if $noerr;
+       die "value does not look like a valid disk size: $size\n";
+    }
+    return $size;
+}
+
 register_standard_option('spice-proxy', {
     description => "SPICE proxy server. This can be used by the client to specify the proxy server. All nodes in a cluster runs 'spiceproxy', so it is up to the client to choose one. By default, we return the node where the VM is currently running. As resonable setting is to use same node you use to connect to the API (This is window.location.hostname for the JS GUI).",
     type => 'string', format => 'address',
 register_standard_option('spice-proxy', {
     description => "SPICE proxy server. This can be used by the client to specify the proxy server. All nodes in a cluster runs 'spiceproxy', so it is up to the client to choose one. By default, we return the node where the VM is currently running. As resonable setting is to use same node you use to connect to the API (This is window.location.hostname for the JS GUI).",
     type => 'string', format => 'address',