From 4c64d0dbbb0e02a332ca6881ac422ed3df510d6b Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Mon, 23 Mar 2020 12:18:52 +0100 Subject: [PATCH] Rely on template_create to check whether creating a template is possible Signed-off-by: Fabian Ebner --- src/PVE/API2/LXC.pm | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm index ddf417b..c724118 100644 --- a/src/PVE/API2/LXC.pm +++ b/src/PVE/API2/LXC.pm @@ -440,13 +440,8 @@ __PACKAGE__->register_method({ # If the template flag was set, we try to convert again to template after restore if ($was_template) { print STDERR "Convert restored container to template...\n"; - if (my $err = check_storage_supports_templates($conf)) { - warn $err; - warn "Leave restored backup as container instead of converting to template.\n" - } else { - PVE::LXC::template_create($vmid, $conf); - $conf->{template} = 1; - } + PVE::LXC::template_create($vmid, $conf); + $conf->{template} = 1; } PVE::LXC::Config->write_config($vmid, $conf); }; @@ -468,22 +463,6 @@ __PACKAGE__->register_method({ return $rpcenv->fork_worker($workername, $vmid, $authuser, $realcmd); }}); -sub check_storage_supports_templates { - my ($conf) = @_; - - my $scfg = PVE::Storage::config(); - eval { - PVE::LXC::Config->foreach_mountpoint($conf, sub { - my ($ms, $mp) = @_; - - my ($sid) = PVE::Storage::parse_volume_id($mp->{volume}, 0); - die "Warning: Directory storage '$sid' does not support container templates!\n" - if $scfg->{ids}->{$sid}->{path}; - }); - }; - return $@ -} - __PACKAGE__->register_method({ name => 'vmdiridx', path => '{vmid}', @@ -1238,10 +1217,6 @@ __PACKAGE__->register_method({ die "you can't convert a CT to template if the CT is running\n" if PVE::LXC::check_running($vmid); - if (my $err = check_storage_supports_templates($conf)) { - die $err; - } - my $realcmd = sub { PVE::LXC::template_create($vmid, $conf); -- 2.39.5