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

Unique uuid for machine allocation #225

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions cmd/metal-api/internal/metal/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func (m *Machine) IsFirewall() bool {

// A MachineAllocation stores the data which are only present for allocated machines.
type MachineAllocation struct {
ID string `rethinkdb:"id,omitempty" json:"id,omitempty"`
Creator string `rethinkdb:"creator" json:"creator"`
Created time.Time `rethinkdb:"created" json:"created"`
Name string `rethinkdb:"name" json:"name"`
Expand Down
2 changes: 2 additions & 0 deletions cmd/metal-api/internal/service/machine-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/avast/retry-go"
"github.com/google/uuid"
s3server "github.com/metal-stack/metal-api/cmd/metal-api/internal/service/s3client"
"github.com/metal-stack/security"

Expand Down Expand Up @@ -1066,6 +1067,7 @@ func allocateMachine(logger *zap.SugaredLogger, ds *datastore.RethinkStore, ipam
allocationSpec.UUID = machineCandidate.ID

alloc := &metal.MachineAllocation{
ID: uuid.NewString(),
Creator: allocationSpec.Creator,
Created: time.Now(),
Name: allocationSpec.Name,
Expand Down
2 changes: 2 additions & 0 deletions cmd/metal-api/internal/service/v1/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type MachineBase struct {
}

type MachineAllocation struct {
ID string `json:"id" description:"unique id of this allocation"`
Creator string `json:"creator" description:"email of machine creator"`
Created time.Time `json:"created" description:"the time when the machine was created"`
Name string `json:"name" description:"the name of the machine"`
Expand Down Expand Up @@ -427,6 +428,7 @@ func NewMachineResponse(m *metal.Machine, s *metal.Size, p *metal.Partition, i *
}

allocation = &MachineAllocation{
ID: m.Allocation.ID,
Creator: m.Allocation.Creator,
Created: m.Allocation.Created,
Name: m.Allocation.Name,
Expand Down
5 changes: 5 additions & 0 deletions spec/metal-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -1803,6 +1803,10 @@
"description": "the hostname which will be used when creating the machine",
"type": "string"
},
"id": {
"description": "unique id of this allocation",
"type": "string"
},
"image": {
"$ref": "#/definitions/v1.ImageResponse",
"description": "the image assigned to this machine",
Expand Down Expand Up @@ -1855,6 +1859,7 @@
"created",
"creator",
"hostname",
"id",
"name",
"networks",
"project",
Expand Down