[pve-devel] [PATCH V5 pve-common 2/2] Extend the JSON format schema with pve-base-snapshot.

Wolfgang Link w.link at proxmox.com
Mon Sep 18 11:52:50 CEST 2017


A base snapshot can be a replication snapshot or a normal snapshot.
---
 src/PVE/JSONSchema.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 996aef2..2ed5b9a 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -180,6 +180,19 @@ sub pve_verify_vmid {
     return $vmid;
 }
 
+register_format('pve-base-snapshot', \&pve_base_snapshot);
+sub pve_base_snapshot {
+    my ($base_snapshot, $noerr) = @_;
+
+    if ($base_snapshot !~ m/^__replicate_[1-9]\d\d+\-\d+_\d+__$/i) {
+	$base_snapshot = pve_verify_snapshot_name($base_snapshot, $noerr);
+    }
+    die "value does not look like a valid base snapshot\n"
+	if !defined($base_snapshot) && $noerr;
+
+    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