[pve-devel] [common 1/2] merge pve-snapshot-name and pve-lxc-snapshot-name to pve-snapshot-id.

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


This format was two time declared in PVE::LXC::Config and PVE::QemuServer.
---
 src/PVE/JSONSchema.pm | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index fb58ad3..3f14875 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -52,6 +52,12 @@ sub get_standard_option {
     return $res;
 };
 
+register_standard_option('pve-snapshot-id', {
+    description => "The name of the snapshot.",
+    type => 'string', format => 'pve-snapshot-id',
+    maxLength => 40,
+});
+
 register_standard_option('pve-vmid', {
     description => "The (unique) ID of the VM.",
     type => 'integer', format => 'pve-vmid',
@@ -149,6 +155,17 @@ sub get_renderer {
 
 register_format('string', sub {}); # allow format => 'string-list'
 
+register_format('pve-snapshot-id', \&pve_verify_snapshot_name);
+sub pve_verify_snapshot_id {
+    my ($name, $noerr) = @_;
+
+    if ($name !~ m/^[a-z][a-z0-9_]+$/i) {
+	return undef if $noerr;
+	die "invalid snapshot-name '$name'\n";
+    }
+    return $name;
+}
+
 register_format('urlencoded', \&pve_verify_urlencoded);
 sub pve_verify_urlencoded {
     my ($text, $noerr) = @_;
-- 
2.11.0





More information about the pve-devel mailing list