Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Target after network/storage lookup (from Incus) #14420

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lxc/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ func (c *cmdInit) create(conf *config.Config, args []string, launch bool) (lxd.I
return nil, "", err
}

if c.flagTarget != "" {
d = d.UseTarget(c.flagTarget)
}

// Overwrite profiles.
if c.flagProfile != nil {
profiles = c.flagProfile
Expand Down Expand Up @@ -264,6 +260,11 @@ func (c *cmdInit) create(conf *config.Config, args []string, launch bool) (lxd.I
instanceDBType = api.InstanceTypeVM
}

// Set the target if provided.
if c.flagTarget != "" {
d = d.UseTarget(c.flagTarget)
}

// Setup instance creation request
req := api.InstancesPost{
Name: name,
Expand Down
8 changes: 4 additions & 4 deletions test/suites/clustering.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3660,12 +3660,12 @@ EOF
lxc init testimage cluster:c1
lxc info cluster:c1 | grep -q "Location: node1"

# c2 should go to node2
lxc init testimage cluster:c2 --target=@blah
# c2 should go to node2. Additionally it should be possible to specify the network.
lxc init testimage cluster:c2 --target=@blah --network "${bridge}"
lxc info cluster:c2 | grep -q "Location: node2"

# c3 should go to node2 again
lxc init testimage cluster:c3 --target=@blah
# c3 should go to node2 again. Additionally it should be possible to specify the storage pool.
lxc init testimage cluster:c3 --target=@blah --storage data
lxc info cluster:c3 | grep -q "Location: node2"

# Direct targeting of node2 should work
Expand Down
Loading