X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=blobdiff_plain;f=data%2FPVE%2FJSONSchema.pm;h=3e0fd52c13f54d0eab19e49dac5eece2129c7c5b;hp=bb00c69cb5fd5125b3cbf1410cda29907aa5394e;hb=dc5eae7dbdfe5df7e4189e038945910c035715aa;hpb=c36f332e32c91a66401b1b2a5005fff8168212df diff --git a/data/PVE/JSONSchema.pm b/data/PVE/JSONSchema.pm index bb00c69..3e0fd52 100644 --- a/data/PVE/JSONSchema.pm +++ b/data/PVE/JSONSchema.pm @@ -5,7 +5,7 @@ use warnings; use Storable; # for dclone use Getopt::Long; use Devel::Cycle -quiet; # todo: remove? -use PVE::Tools qw(split_list); +use PVE::Tools qw(split_list $IPV6RE $IPV4RE); use PVE::Exception qw(raise); use HTTP::Status qw(:constants); use Net::IP qw(:PROC); @@ -76,6 +76,12 @@ PVE::JSONSchema::register_standard_option('pve-storage-id', { type => 'string', format => 'pve-storage-id', }); +PVE::JSONSchema::register_standard_option('pve-config-digest', { + description => 'Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.', + type => 'string', + optional => 1, + maxLength => 40, # sha1 hex digest lenght is 40 +}); my $format_list = {}; @@ -192,6 +198,20 @@ sub pve_verify_ipv4mask { return $mask; } +register_format('CIDR', \&pve_verify_cidr); +sub pve_verify_cidr { + my ($cidr, $noerr) = @_; + + if ($cidr =~ m!^(?:$IPV4RE)(?:/(\d+))$! && ($1 > 7) && ($1 < 32)) { + return $cidr; + } elsif ($cidr =~ m!^(?:$IPV6RE)(?:/(\d+))$! && ($1 > 7) && ($1 <= 120)) { + return $cidr; + } + + return undef if $noerr; + die "value does not look like a valid CIDR network\n"; +} + register_format('email', \&pve_verify_email); sub pve_verify_email { my ($email, $noerr) = @_; @@ -229,6 +249,23 @@ sub pve_verify_iface { return $id; } +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 => 'dns-name', +}); + +register_standard_option('remote-viewer-config', { + description => "Returned values can be directly passed to the 'remote-viewer' application.", + additionalProperties => 1, + properties => { + type => { type => 'string' }, + password => { type => 'string' }, + proxy => { type => 'string' }, + host => { type => 'string' }, + 'tls-port' => { type => 'integer' }, + }, +}); + sub check_format { my ($format, $value) = @_;