Skip to content

Commit

Permalink
Add metal-core version to switch OS details (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Jul 5, 2023
1 parent 8a8d1d5 commit 7974647
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
5 changes: 3 additions & 2 deletions cmd/metal-api/internal/metal/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ type Switch struct {
type Switches []Switch

type SwitchOS struct {
Vendor string `rethinkdb:"vendor" json:"vendor"`
Version string `rethinkdb:"version" json:"version"`
Vendor string `rethinkdb:"vendor" json:"vendor"`
Version string `rethinkdb:"version" json:"version"`
MetalCoreVersion string `rethinkdb:"metal_core_version" json:"metal_core_version"`
}

// Connection between switch port and machine.
Expand Down
1 change: 1 addition & 0 deletions cmd/metal-api/internal/service/switch-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ func (r *switchResource) registerSwitch(request *restful.Request, response *rest
}
s.OS.Vendor = spec.OS.Vendor
s.OS.Version = spec.OS.Version
s.OS.MetalCoreVersion = spec.OS.MetalCoreVersion
}
s.ManagementIP = spec.ManagementIP
s.ManagementUser = spec.ManagementUser
Expand Down
15 changes: 9 additions & 6 deletions cmd/metal-api/internal/service/v1/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ type SwitchBase struct {
}

type SwitchOS struct {
Vendor string `json:"vendor" description:"the operating system vendor the switch currently has" optional:"true"`
Version string `json:"version" description:"the operating system version the switch currently has" optional:"true"`
Vendor string `json:"vendor" description:"the operating system vendor the switch currently has" optional:"true"`
Version string `json:"version" description:"the operating system version the switch currently has" optional:"true"`
MetalCoreVersion string `json:"metal_core_version" description:"the version of metal-core running" optional:"true"`
}

type SwitchNics []SwitchNic
Expand Down Expand Up @@ -115,8 +116,9 @@ func NewSwitchResponse(s *metal.Switch, p *metal.Partition, nics SwitchNics, con
var os *SwitchOS
if s.OS != nil {
os = &SwitchOS{
Vendor: s.OS.Vendor,
Version: s.OS.Version,
Vendor: s.OS.Vendor,
Version: s.OS.Version,
MetalCoreVersion: s.OS.MetalCoreVersion,
}
}

Expand Down Expand Up @@ -174,8 +176,9 @@ func NewSwitch(r SwitchRegisterRequest) *metal.Switch {
var os *metal.SwitchOS
if r.OS != nil {
os = &metal.SwitchOS{
Vendor: r.OS.Vendor,
Version: r.OS.Version,
Vendor: r.OS.Vendor,
Version: r.OS.Version,
MetalCoreVersion: r.OS.MetalCoreVersion,
}
}

Expand Down
4 changes: 4 additions & 0 deletions spec/metal-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -4360,6 +4360,10 @@
},
"v1.SwitchOS": {
"properties": {
"metal_core_version": {
"description": "the version of metal-core running",
"type": "string"
},
"vendor": {
"description": "the operating system vendor the switch currently has",
"type": "string"
Expand Down

0 comments on commit 7974647

Please sign in to comment.