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

Wolfgang Link w.link at proxmox.com
Tue Sep 12 08:41:54 CEST 2017


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

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 3295599..501f0fa 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -163,6 +163,20 @@ 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) {
+	# We use configid as snapshot name in qemu and lxc.
+	$base_snapshot = PVE::JSONSchema::pve_verify_configid($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