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 3295599..5b1d59e 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-name', {
+    description => "The name of the snapshot.",
+    type => 'string', format => 'pve-snapshot-name',
+    maxLength => 40,
+});
+
 register_standard_option('pve-vmid', {
     description => "The (unique) ID of the VM.",
     type => 'integer', format => 'pve-vmid',
@@ -119,6 +125,17 @@ sub get_format {
 
 register_format('string', sub {}); # allow format => 'string-list'
 
+register_format('pve-snapshot-name', \&pve_verify_snapshot_name);
+sub pve_verify_snapshot_name {
+    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


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to