From 05e787c503b1a2c4d09d674b8f3f382becf4641d Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 26 Jan 2012 11:54:42 +0100 Subject: [PATCH] moved format definition from pve-storage --- data/PVE/JSONSchema.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/data/PVE/JSONSchema.pm b/data/PVE/JSONSchema.pm index 45f02c5..ef89fb5 100644 --- a/data/PVE/JSONSchema.pm +++ b/data/PVE/JSONSchema.pm @@ -70,6 +70,12 @@ register_standard_option('pve-iface', { minLength => 2, maxLength => 20, }); +PVE::JSONSchema::register_standard_option('pve-storage-id', { + description => "The storage identifier.", + type => 'string', format => 'pve-storage-id', +}); + + my $format_list = {}; sub register_format { @@ -96,6 +102,18 @@ sub pve_verify_configid { return $id; } +PVE::JSONSchema::register_format('pve-storage-id', \&parse_storage_id); +sub parse_storage_id { + my ($storeid, $noerr) = @_; + + if ($storeid !~ m/^[a-z][a-z0-9\-\_\.]*[a-z0-9]$/i) { + return undef if $noerr; + die "storage ID '$storeid' contains illegal characters\n"; + } + return $storeid; +} + + register_format('pve-vmid', \&pve_verify_vmid); sub pve_verify_vmid { my ($vmid, $noerr) = @_; -- 2.39.2