Skip to content

Commit

Permalink
refactor: inventory API
Browse files Browse the repository at this point in the history
add service to query cluster

Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Jan 7, 2024
1 parent 5b77921 commit 6b0842b
Show file tree
Hide file tree
Showing 22 changed files with 657 additions and 365 deletions.
10 changes: 10 additions & 0 deletions go/inventory/v1/cluster.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package v1

func (cl *Cluster) Dup() *Cluster {
res := &Cluster{
Nodes: nil,
Storage: nil,
}

return res
}
29 changes: 29 additions & 0 deletions go/inventory/v1/cpu.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package v1

func (r *CPU) Dup() CPU {
res := CPU{
Quantity: r.Quantity.Dup(),
Info: r.Info.Dup(),
}

return res
}

func (s CPUInfoS) Dup() CPUInfoS {
if len(s) == 0 {
return nil
}

res := make(CPUInfoS, 0, len(s))

for _, n := range s {
res = append(res, CPUInfo{
ID: n.ID,
Vendor: n.Vendor,
Model: n.Model,
Vcores: n.Vcores,
})
}

return res
}
64 changes: 32 additions & 32 deletions go/inventory/v1/cpu.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions go/inventory/v1/gpu.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package v1

func (s GPUs) Dup() GPUs {
if len(s) == 0 {
return nil
}

res := make(GPUs, 0, len(s))

for _, g := range s {
res = append(res, g.Dup())
}

return res
}

func (r *GPU) Dup() GPU {
res := GPU{
Quantity: r.Quantity.Dup(),
Info: r.Info.Dup(),
}

return res
}

func (s *GPUInfo) Dup() GPUInfo {
res := GPUInfo{
Vendor: s.Vendor,
Name: s.Name,
ModelID: s.ModelID,
Interface: s.Interface,
MemorySize: s.MemorySize,
}

return res
}

func (s GPUInfoS) Dup() GPUInfoS {
if len(s) == 0 {
return nil
}

res := make(GPUInfoS, 0, len(s))

for _, n := range s {
res = append(res, GPUInfo{
Vendor: n.Vendor,
Name: n.Name,
ModelID: n.ModelID,
Interface: n.Interface,
MemorySize: n.MemorySize,
})
}

return res
}
103 changes: 56 additions & 47 deletions go/inventory/v1/gpu.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions go/inventory/v1/memory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package v1

func (r *Memory) Dup() Memory {
res := Memory{
Quantity: r.Quantity.Dup(),
Info: r.Info.Dup(),
}

return res
}

func (s MemoryInfoS) Dup() MemoryInfoS {
if len(s) == 0 {
return nil
}

res := make(MemoryInfoS, 0, len(s))

for _, n := range s {
res = append(res, MemoryInfo{
Vendor: n.Vendor,
Type: n.Type,
TotalSize: n.TotalSize,
Speed: n.Speed,
})
}

return res
}
Loading

0 comments on commit 6b0842b

Please sign in to comment.