[pve-devel] [common 2/2] Extend the JSON format schema with pve_base_snapshot.

Wolfgang Link w.link at proxmox.com
Tue Oct 23 13:25:46 CEST 2018


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

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 3f14875..d9e4f3d 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -210,6 +210,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_id($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