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

Wolfgang Link w.link at proxmox.com
Fri Aug 25 09:09:40 CEST 2017


---
 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;
+}
+
 register_format('pve-node', \&pve_verify_node_name);
 sub pve_verify_node_name {
     my ($node, $noerr) = @_;
-- 
2.11.0





More information about the pve-devel mailing list