Skip to content

Commit

Permalink
feat(hatchery:openstack): set security groups (#6573)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlt committed Jun 19, 2023
1 parent 058d9af commit 8ba2137
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions engine/hatchery/openstack/spawn.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,18 @@ func (h *HatcheryOpenstack) SpawnWorker(ctx context.Context, spawnArgs hatchery.
}

networks := []servers.Network{{UUID: h.networkID, FixedIP: ip}}
r := servers.Create(h.openstackClient, servers.CreateOpts{
opts := servers.CreateOpts{
Name: spawnArgs.WorkerName,
FlavorRef: flavor.ID,
ImageRef: imageID,
Metadata: meta,
UserData: []byte(udata64),
Networks: networks,
})
}
r := servers.Create(h.openstackClient, opts)
if len(h.Config.DefaultSecurityGroups) > 0 {
opts.SecurityGroups = h.Config.DefaultSecurityGroups
}

server, err := r.Extract()
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions engine/hatchery/openstack/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ type HatcheryConfiguration struct {

// DefaultFlavor, if set the hatchery will use a model with the default flavor in priority to start jobs without model requirement
DefaultFlavor string `mapstructure:"defaultFlavor" toml:"defaultFlavor" default:"" commented:"true" comment:"If set the hatchery will use a model with the default flavor in priority to start jobs without model requirement" json:"defaultFlavor"`

// DefaultSecurityGroups, if set the VMs spawned by the hatchery will have the given security groups
DefaultSecurityGroups []string `mapstructure:"defaultSecurityGroups" toml:"defaultSecurityGroups" default:"" commented:"true" comment:"If set the hatchery will add given groups on spawned VMs" json:"defaultSecurityGroups"`
}

// HatcheryOpenstack spawns instances of worker model with type 'ISO'
Expand Down

0 comments on commit 8ba2137

Please sign in to comment.