]> git.proxmox.com Git - pve-container.git/commitdiff
Rely on template_create to check whether creating a template is possible
authorFabian Ebner <f.ebner@proxmox.com>
Mon, 23 Mar 2020 11:18:52 +0000 (12:18 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 27 Mar 2020 07:50:46 +0000 (08:50 +0100)
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
src/PVE/API2/LXC.pm

index ddf417bf3f104b8ffe35237b6c8a4499ec869d22..c7241185c6f01b1c335ed574cd20c2ea1096a56e 100644 (file)
@@ -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);