Skip to content

Commit

Permalink
incus-migrate: Support using the local server
Browse files Browse the repository at this point in the history
Closes #660

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
  • Loading branch information
stgraber committed Mar 25, 2024
1 parent 21d8d42 commit 09e4119
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/incus-migrate/main_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ func (c *cmdMigrateData) Render() string {
}

func (c *cmdMigrate) askServer() (incus.InstanceServer, string, error) {
// Detect local server.
local, err := c.connectLocal()
if err == nil {
useLocal, err := c.global.asker.AskBool("The local Incus server is the target [default=yes]: ", "yes")
if err != nil {
return nil, "", err
}

if useLocal {
return local, "", nil
}
}

// Server address
serverURL, err := c.global.asker.AskString("Please provide Incus server URL: ", "", nil)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions cmd/incus-migrate/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ func transferRootfs(ctx context.Context, dst incus.InstanceServer, op incus.Oper
return nil
}

func (m *cmdMigrate) connectLocal() (incus.InstanceServer, error) {
args := incus.ConnectionArgs{}
args.UserAgent = fmt.Sprintf("LXC-MIGRATE %s", version.Version)

return incus.ConnectIncusUnix("", &args)
}

func (m *cmdMigrate) connectTarget(url string, certPath string, keyPath string, authType string, token string) (incus.InstanceServer, string, error) {
args := incus.ConnectionArgs{
AuthType: authType,
Expand Down

0 comments on commit 09e4119

Please sign in to comment.