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

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


This format was two time declared in PVE::LXC::Config and PVE::QemuServer.
It is necessary to call the new option different to avoid upgrade problems.
---
 src/PVE/JSONSchema.pm | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 3295599..996aef2 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-snapshotname', {
+    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





More information about the pve-devel mailing list