Renames mountpoint_names to avoid the need to create a wrapper. Signed-off-by: Fabian Ebner <f.eb...@proxmox.com> --- src/PVE/API2/LXC.pm | 4 ++-- src/PVE/CLI/pct.pm | 2 +- src/PVE/LXC/Config.pm | 38 ++++++++++++++++++++++++++++---------- 3 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm index a5aa5fc..556fd33 100644 --- a/src/PVE/API2/LXC.pm +++ b/src/PVE/API2/LXC.pm @@ -1595,7 +1595,7 @@ __PACKAGE__->register_method({ disk => { type => 'string', description => "The disk you want to resize.", - enum => [PVE::LXC::Config->mountpoint_names()], + enum => [PVE::LXC::Config->valid_volume_keys()], }, size => { type => 'string', @@ -1757,7 +1757,7 @@ __PACKAGE__->register_method({ vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid }), volume => { type => 'string', - enum => [ PVE::LXC::Config->mountpoint_names() ], + enum => [ PVE::LXC::Config->valid_volume_keys() ], description => "Volume which will be moved.", }, storage => get_standard_option('pve-storage-id', { diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm index 5c36669..934d9aa 100755 --- a/src/PVE/CLI/pct.pm +++ b/src/PVE/CLI/pct.pm @@ -210,7 +210,7 @@ __PACKAGE__->register_method ({ optional => 1, type => 'string', description => "A volume on which to run the filesystem check", - enum => [PVE::LXC::Config->mountpoint_names()], + enum => [PVE::LXC::Config->valid_volume_keys()], }, }, }, diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm index 0909773..9f68ac1 100644 --- a/src/PVE/LXC/Config.pm +++ b/src/PVE/LXC/Config.pm @@ -181,7 +181,7 @@ sub __snapshot_rollback_get_unused { my $unused = []; - $class->__snapshot_foreach_volume($conf, sub { + $class->foreach_volume($conf, sub { my ($vs, $volume) = @_; return if $volume->{type} ne 'volume'; @@ -189,7 +189,7 @@ sub __snapshot_rollback_get_unused { my $found = 0; my $volid = $volume->{volume}; - $class->__snapshot_foreach_volume($snap, sub { + $class->foreach_volume($snap, sub { my ($ms, $mountpoint) = @_; return if $found; @@ -205,12 +205,6 @@ sub __snapshot_rollback_get_unused { return $unused; } -sub __snapshot_foreach_volume { - my ($class, $conf, $func) = @_; - - $class->foreach_mountpoint($conf, $func); -} - # END implemented abstract methods from PVE::AbstractConfig # BEGIN JSON config code @@ -1083,6 +1077,30 @@ sub print_ct_mountpoint { return PVE::JSONSchema::print_property_string($info, $mp_desc, $skip); } +sub parse_volume { + my ($class, $key, $volume_string, $noerr) = @_; + + if ($key eq 'rootfs') { + return $class->parse_ct_rootfs($volume_string, $noerr); + } elsif ($key =~ m/^mp\d+$/ || $key =~ m/^unused\d+$/) { + return $class->parse_ct_mountpoint($volume_string, $noerr); + } + + die "parse_volume - unknown type: $key\n"; +} + +sub print_volume { + my ($class, $key, $volume) = @_; + + return $class->print_ct_mountpoint($volume, $key eq 'rootfs'); +} + +sub volid_key { + my ($class) = @_; + + return 'volume'; +} + sub print_lxc_network { my ($class, $net) = @_; return PVE::JSONSchema::print_property_string($net, $netconf_desc); @@ -1450,7 +1468,7 @@ sub get_cmode { return $conf->{cmode} // $confdesc->{cmode}->{default}; } -sub mountpoint_names { +sub valid_volume_keys { my ($class, $reverse) = @_; my @names = ('rootfs'); @@ -1465,7 +1483,7 @@ sub mountpoint_names { sub foreach_mountpoint_full { my ($class, $conf, $reverse, $func, @param) = @_; - my $mps = [ grep { defined($conf->{$_}) } $class->mountpoint_names($reverse) ]; + my $mps = [ grep { defined($conf->{$_}) } $class->valid_volume_keys($reverse) ]; foreach my $key (@$mps) { my $value = $conf->{$key}; my $mountpoint = $key eq 'rootfs' ? $class->parse_ct_rootfs($value, 1) : $class->parse_ct_mountpoint($value, 1); -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel