[pve-devel] [PATCH pve-common] Extend JSON format schema with pve_base_snapshot.

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Sep 1 13:56:40 CEST 2017


On Fri, Aug 25, 2017 at 09:09:40AM +0200, Wolfgang Link wrote:
> ---
>  src/PVE/JSONSchema.pm | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
> index 3295599..92d60b9 100644
> --- a/src/PVE/JSONSchema.pm
> +++ b/src/PVE/JSONSchema.pm
> @@ -163,6 +163,17 @@ sub pve_verify_vmid {
>      return $vmid;
>  }
>  
> +register_format('pve-base-snapshot', \&pve_base_snaphot);
> +sub pve_base_snaphot {
> +    my ($base_snapshot, $noerr) = @_;
> +
> +    if ($base_snapshot !~ m/^[a-z0-9_\-]{2,40}$/i) {
> +	return undef if $noerr;
> +	die "value does not look like a valid base snapshot\n";
> +    }
> +    return $base_snapshot;
> +}
> +

I actually really meant a new option, not a new format ;) but either way
is fine I guess.

BUT, I'd really like this to be less vague, and only accept the regular
snapshot format, and the explicit PVE-internal naming schemes..

>  register_format('pve-node', \&pve_verify_node_name);
>  sub pve_verify_node_name {
>      my ($node, $noerr) = @_;
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list