This turns is_mountpoint more into export(5)'s `mountpoint`
property.
Given the directory storage with the properties:
path /a/b/c
is_mountpoint $value
$value = yes
Same as before, /a/b/c must be mounted.
$value = no (or not set)
Same as before, no effect.
$value = /a/b
New: /a/b must be mounted (as opposed to /a/b/c)
},
is_mountpoint => {
description =>
},
is_mountpoint => {
description =>
- "Assume the directory is an externally managed mountpoint. " .
- "If nothing is mounted the storage will be considered offline.",
- type => 'boolean',
+ "Assume the given path is an externally managed mountpoint " .
+ "and consider the storage offline if it is not mounted. ".
+ "Using a boolean (yes/no) value serves as a shortcut to using the target path in this field.",
+ type => 'string',
+sub parse_is_mountpoint {
+ my ($scfg) = @_;
+ my $is_mp = $scfg->{is_mountpoint};
+ return undef if !defined $is_mp;
+ if (defined(my $bool = PVE::JSONSchema::parse_boolean($is_mp))) {
+ return $bool ? $scfg->{path} : undef;
+ }
+ return $is_mp; # contains a path
+}
+
sub status {
my ($class, $storeid, $scfg, $cache) = @_;
sub status {
my ($class, $storeid, $scfg, $cache) = @_;
- if ($scfg->{is_mountpoint}) {
+ if (defined(my $mp = parse_is_mountpoint($scfg))) {
$cache->{mountdata} = PVE::ProcFSTools::parse_proc_mounts()
if !$cache->{mountdata};
$cache->{mountdata} = PVE::ProcFSTools::parse_proc_mounts()
if !$cache->{mountdata};
- my $path = $scfg->{path};
-
- return undef if !path_is_mounted($path, $cache->{mountdata});
+ return undef if !path_is_mounted($mp, $cache->{mountdata});
}
return $class->SUPER::status($storeid, $scfg, $cache);
}
return $class->SUPER::status($storeid, $scfg, $cache);
- if ($scfg->{is_mountpoint} && !path_is_mounted($path, $cache->{mountdata})) {
+ my $mp = parse_is_mountpoint($scfg);
+ if (defined($mp) && !path_is_mounted($mp, $cache->{mountdata})) {
die "unable to activate storage '$storeid' - " .
die "unable to activate storage '$storeid' - " .
- "directory is expected to be a mount point but is not mounted: '$path'\n";
+ "directory is expected to be a mount point but is not mounted: '$mp'\n";
}
$class->SUPER::activate_storage($storeid, $scfg, $cache);
}
$class->SUPER::activate_storage($storeid, $scfg, $cache);