Skip to content

Commit

Permalink
cmd/lxd-to-incus: Validate storage tools are present
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
  • Loading branch information
stgraber committed Oct 26, 2023
1 parent f1dda2e commit a30da80
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions cmd/lxd-to-incus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"

Expand Down Expand Up @@ -349,6 +350,35 @@ func (c *cmdMigrate) Run(app *cobra.Command, args []string) error {
}
}

storagePools, err := srcClient.GetStoragePools()
if err != nil {
return fmt.Errorf("Couldn't list storage pools: %w", err)
}

for _, pool := range storagePools {
if pool.Driver == "zfs" {
_, err = exec.LookPath("zfs")
if err != nil {
errors = append(errors, fmt.Errorf("Required command %q is missing for storage pool %q", "zfs", pool.Name))
}
} else if pool.Driver == "btrfs" {
_, err = exec.LookPath("btrfs")
if err != nil {
errors = append(errors, fmt.Errorf("Required command %q is missing for storage pool %q", "btrfs", pool.Name))
}
} else if pool.Driver == "ceph" || pool.Driver == "cephfs" || pool.Driver == "cephobject" {
_, err = exec.LookPath("ceph")
if err != nil {
errors = append(errors, fmt.Errorf("Required command %q is missing for storage pool %q", "ceph", pool.Name))
}
} else if pool.Driver == "lvm" {
_, err = exec.LookPath("lvm")
if err != nil {
errors = append(errors, fmt.Errorf("Required command %q is missing for storage pool %q", "lvm", pool.Name))
}
}
}

deprecatedInstanceConfigs := []string{
"limits.network.priority",
}
Expand Down Expand Up @@ -436,10 +466,6 @@ func (c *cmdMigrate) Run(app *cobra.Command, args []string) error {

// Mangle storage pool sources.
rewriteStatements := []string{}
storagePools, err := srcClient.GetStoragePools()
if err != nil {
return fmt.Errorf("Failed to get list of source storage pools: %w", err)
}

for _, pool := range storagePools {
source := pool.Config["source"]
Expand Down

0 comments on commit a30da80

Please sign in to comment.