Skip to content

Commit 825d6b2

Browse files
authored
PCP-5197: added resourcePool as filter when composing lxd vm (#222)
* add resourcePool as filter when composing lxd vm * error out when selecting default resource pool
1 parent 9a599b6 commit 825d6b2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/maas/machine/machine.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,13 +418,19 @@ func (s *Service) PrepareLXDVM(ctx context.Context) (*infrav1beta1.Machine, erro
418418
s.scope.Info("Selected LXD host for VM", "host-name", selectedHost.Name(), "host-id", selectedHost.SystemID(), "zone", zone, "resource-pool", resourcePool)
419419

420420
zoneID := selectedHost.Zone().ID()
421+
rp := selectedHost.ResourcePool()
422+
if rp == nil {
423+
return nil, errors.New("selected LXD host has no resource pool; shouldn't use default resource pool")
424+
}
425+
poolID := rp.ID()
421426

422427
params := maasclient.ParamsBuilder().
423428
Set("hostname", vmName).
424429
Set("cores", fmt.Sprintf("%d", cpu)).
425430
Set("memory", fmt.Sprintf("%d", mem)).
426431
Set("storage", fmt.Sprintf("%d", diskSizeGB)).
427-
Set("zone", fmt.Sprintf("%d", zoneID))
432+
Set("zone", fmt.Sprintf("%d", zoneID)).
433+
Set("pool", fmt.Sprintf("%d", poolID))
428434

429435
// Create the VM on the selected host
430436
m, err := selectedHost.Composer().Compose(ctx, params)

0 commit comments

Comments
 (0)