diff --git a/lxc/init.go b/lxc/init.go index 9522c8b45179..84c3dd03788e 100644 --- a/lxc/init.go +++ b/lxc/init.go @@ -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 @@ -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, diff --git a/test/suites/clustering.sh b/test/suites/clustering.sh index 523829796af1..4e2aeb7f8ff6 100644 --- a/test/suites/clustering.sh +++ b/test/suites/clustering.sh @@ -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