]> git.proxmox.com Git - pve-common.git/commitdiff
moved format definition from pve-storage
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 26 Jan 2012 10:54:42 +0000 (11:54 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 26 Jan 2012 10:54:42 +0000 (11:54 +0100)
data/PVE/JSONSchema.pm

index 45f02c537f360ccdef79e749a5653bed1af1e83d..ef89fb58d55963deef9219827bda6da131acd10f 100644 (file)
@@ -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) = @_;