增强API集成能力,划分KEY功能权限

This commit is contained in:
MengMengCode
2026-06-08 19:25:55 +08:00
parent 2fa130a2b6
commit e79609281f
20 changed files with 1596 additions and 425 deletions
+6 -4
View File
@@ -2258,13 +2258,15 @@ func (m *Manager) ReinstallContainer(id int, templateID string) error {
// Clean port mappings temporarily
m.CleanPortMappings(id)
// Destroy old LXC but keep config
// Destroy old LXC but keep config. lxc-destroy can leave the config
// directory behind when rootfs mounts are still present, which makes the
// following lxc-create fail with "Container already exists".
exec.Command("lxc-stop", "-n", lxcName, "-k").Run()
exec.Command("lxc-destroy", "-n", lxcName, "-f").Run()
rootfs := filepath.Join(m.LxcPath, lxcName, "rootfs")
exec.Command("umount", "-R", "-l", rootfs).Run()
os.RemoveAll(rootfs)
os.Remove(filepath.Join(m.LxcPath, lxcName, "rootfs.img"))
exec.Command("lxc-destroy", "-n", lxcName, "-f").Run()
exec.Command("umount", "-R", "-l", rootfs).Run()
os.RemoveAll(filepath.Join(m.LxcPath, lxcName))
// Create new container with same LXC name (preserves ID)
cmd := exec.Command("lxc-create",