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 {
if ($id !~ m/^[a-z][a-z0-9_]+$/i) {
return undef if $noerr;
- die "invalid cofiguration ID '$id'\n";
+ die "invalid configuration ID '$id'\n";
}
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) = @_;
sub pve_verify_node_name {
my ($node, $noerr) = @_;
- # todo: use better regex ?
- if ($node !~ m/^[A-Za-z][[:alnum:]\-]*[[:alnum:]]+$/) {
+ if ($node !~ m/^([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)$/) {
return undef if $noerr;
die "value does not look like a valid node name\n";
}
return $email;
}
+register_format('dns-name', \&pve_verify_dns_name);
+sub pve_verify_dns_name {
+ my ($name, $noerr) = @_;
+
+ my $namere = "([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)";
+
+ if ($name !~ /^(${namere}\.)*${namere}$/) {
+ return undef if $noerr;
+ die "value does not look like a valid DNS name\n";
+ }
+ return $name;
+}
+
# network interface name
register_format('pve-iface', \&pve_verify_iface);
sub pve_verify_iface {
optional => 1,
additionalProperties => 0,
properties => {
+ description => {
+ description => "Describe access permissions.",
+ optional => 1,
+ },
user => {
- description => "A simply way to allow access for 'all' users. The special value 'arg' allows access for the user specified in the 'username' parameter. This is useful to allow access to things owned by a user, like changing the user password. Value 'world' is used to allow access without credentials.",
+ description => "A simply way to allow access for 'all' authenticated users. Value 'world' is used to allow access without credentials.",
type => 'string',
- enum => ['all', 'arg', 'world'],
+ enum => ['all', 'world'],
optional => 1,
},
- path => { type => 'string', optional => 1, requires => 'privs' },
- privs => { type => 'array', optional => 1, requires => 'path' },
+ check => {
+ description => "Array of permission checks (prefix notation).",
+ type => 'array',
+ optional => 1
+ },
},
},
match_name => {
}
$opts = PVE::Tools::decode_utf8_parameters($opts);
- if ($opts->{description}) {
- print "TEST: " . PVE::Tools::encode_text($opts->{description}) . "\n";
- }
foreach my $p (keys %$opts) {
if (my $pd = $schema->{properties}->{$p}) {