Skip to content

Commit

Permalink
Add machine ids of faulty and other machines in partition capacity re…
Browse files Browse the repository at this point in the history
…sponse (#117)
  • Loading branch information
majst01 authored Oct 12, 2020
1 parent 42d4eaa commit d9261e8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions cmd/metal-api/internal/service/partition-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,12 @@ func (r partitionResource) calcPartitionCapacity() ([]v1.PartitionCapacity, erro
cap.Allocated++
} else if machineHasIssues(m) {
cap.Faulty++
cap.FaultyMachines = append(cap.FaultyMachines, m.ID)
} else if available {
cap.Free++
} else {
cap.Other++
cap.OtherMachines = append(cap.OtherMachines, m.ID)
}

cap.Total++
Expand Down
14 changes: 8 additions & 6 deletions cmd/metal-api/internal/service/v1/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ type PartitionCapacity struct {
}

type ServerCapacity struct {
Size string `json:"size" description:"the size of the server"`
Total int `json:"total" description:"total amount of servers with this size"`
Free int `json:"free" description:"free servers with this size"`
Allocated int `json:"allocated" description:"allocated servers with this size"`
Faulty int `json:"faulty" description:"servers with issues with this size"`
Other int `json:"other" description:"servers neither free, allocated or faulty with this size"`
Size string `json:"size" description:"the size of the server"`
Total int `json:"total" description:"total amount of servers with this size"`
Free int `json:"free" description:"free servers with this size"`
Allocated int `json:"allocated" description:"allocated servers with this size"`
Faulty int `json:"faulty" description:"servers with issues with this size"`
FaultyMachines []string `json:"faultymachines" description:"servers with issues with this size"`
Other int `json:"other" description:"servers neither free, allocated or faulty with this size"`
OtherMachines []string `json:"othermachines" description:"servers neither free, allocated or faulty with this size"`
}

func NewPartitionResponse(p *metal.Partition) *PartitionResponse {
Expand Down
16 changes: 16 additions & 0 deletions spec/metal-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -2558,6 +2558,13 @@
"format": "int32",
"type": "integer"
},
"faultymachines": {
"description": "servers with issues with this size",
"items": {
"type": "string"
},
"type": "array"
},
"free": {
"description": "free servers with this size",
"format": "int32",
Expand All @@ -2568,6 +2575,13 @@
"format": "int32",
"type": "integer"
},
"othermachines": {
"description": "servers neither free, allocated or faulty with this size",
"items": {
"type": "string"
},
"type": "array"
},
"size": {
"description": "the size of the server",
"type": "string"
Expand All @@ -2581,8 +2595,10 @@
"required": [
"allocated",
"faulty",
"faultymachines",
"free",
"other",
"othermachines",
"size",
"total"
]
Expand Down

0 comments on commit d9261e8

Please sign in to comment.