Skip to content

Commit 97f4883

Browse files
committed
Initial inventory
1 parent 3c35eb2 commit 97f4883

File tree

17 files changed

+409
-17
lines changed

17 files changed

+409
-17
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*.dylib
88
bin/*
99
Dockerfile.cross
10+
.DS_Store
1011

1112
# Test binary, built with `go test -c`
1213
*.test
@@ -31,4 +32,4 @@ node_modules/
3132
docs/.vitepress/cache/*
3233
docs/.vitepress/dist/*
3334
.vitepress/
34-
.cache
35+
.cache

cmd/metalprobe/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ func main() {
2121
var registryURL string
2222
var serverUUID string
2323
var duration time.Duration
24+
var LLDPSyncInterval time.Duration
25+
var LLDPSyncDuration time.Duration
2426

2527
flag.StringVar(&registryURL, "registry-url", "", "Registry URL where the probe will register itself.")
2628
flag.StringVar(&serverUUID, "server-uuid", "", "Agent UUID to register with the registry.")
2729
flag.DurationVar(&duration, "duration", 5*time.Second, "Duration of time to wait between checks.")
30+
flag.DurationVar(&LLDPSyncInterval, "lldp-sync-interval", 5*time.Second, "Duration of time to wait between networkctl lldp runs.")
31+
flag.DurationVar(&LLDPSyncDuration, "lldp-sync-duration", 30*time.Second, "Timeout for the networkctl lldp run.")
2832

2933
opts := zap.Options{
3034
Development: true,
@@ -47,7 +51,7 @@ func main() {
4751
ctx := ctrl.SetupSignalHandler()
4852

4953
setupLog.Info("starting registry agent")
50-
agent := probe.NewAgent(serverUUID, registryURL, duration)
54+
agent := probe.NewAgent(serverUUID, registryURL, duration, LLDPSyncInterval, LLDPSyncDuration)
5155
if err := agent.Start(ctx); err != nil {
5256
setupLog.Error(err, "problem running probe agent")
5357
os.Exit(1)

go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ module github.com/ironcore-dev/metal-operator
33
go 1.24.0
44

55
require (
6+
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e
67
github.com/go-logr/logr v1.4.3
78
github.com/ironcore-dev/controller-utils v0.10.0
9+
github.com/jaypipes/ghw v0.17.0
810
github.com/onsi/ginkgo/v2 v2.23.4
911
github.com/onsi/gomega v1.37.0
1012
github.com/spf13/cobra v1.9.1
@@ -22,6 +24,7 @@ require (
2224

2325
require (
2426
cel.dev/expr v0.20.0 // indirect
27+
github.com/StackExchange/wmi v1.2.1 // indirect
2528
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
2629
github.com/beorn7/perks v1.0.1 // indirect
2730
github.com/blang/semver/v4 v4.0.0 // indirect
@@ -35,6 +38,7 @@ require (
3538
github.com/fxamacker/cbor/v2 v2.8.0 // indirect
3639
github.com/go-logr/stdr v1.2.2 // indirect
3740
github.com/go-logr/zapr v1.3.0 // indirect
41+
github.com/go-ole/go-ole v1.2.6 // indirect
3842
github.com/go-openapi/jsonpointer v0.21.1 // indirect
3943
github.com/go-openapi/jsonreference v0.21.0 // indirect
4044
github.com/go-openapi/swag v0.23.1 // indirect
@@ -48,9 +52,11 @@ require (
4852
github.com/google/uuid v1.6.0 // indirect
4953
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
5054
github.com/inconshreveable/mousetrap v1.1.0 // indirect
55+
github.com/jaypipes/pcidb v1.0.1 // indirect
5156
github.com/josharian/intern v1.0.0 // indirect
5257
github.com/json-iterator/go v1.1.12 // indirect
5358
github.com/mailru/easyjson v0.9.0 // indirect
59+
github.com/mitchellh/go-homedir v1.1.0 // indirect
5460
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5561
github.com/modern-go/reflect2 v1.0.2 // indirect
5662
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
@@ -91,6 +97,7 @@ require (
9197
google.golang.org/protobuf v1.36.6 // indirect
9298
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
9399
gopkg.in/inf.v0 v0.9.1 // indirect
100+
howett.net/plist v1.0.0 // indirect
94101
k8s.io/apiserver v0.33.3 // indirect
95102
k8s.io/component-base v0.33.3 // indirect
96103
k8s.io/klog/v2 v2.130.1 // indirect

go.sum

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cel.dev/expr v0.20.0 h1:OunBvVCfvpWlt4dN7zg3FM6TDkzOePe1+foGJ9AXeeI=
22
cel.dev/expr v0.20.0/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
3+
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
4+
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
35
github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
46
github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw=
57
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -15,6 +17,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
1517
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1618
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
1719
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
20+
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e h1:vUmf0yezR0y7jJ5pceLHthLaYf4bA5T14B6q39S4q2Q=
21+
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e/go.mod h1:YTIHhz/QFSYnu/EhlF2SpU2Uk+32abacUYA5ZPljz1A=
1822
github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU=
1923
github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
2024
github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8P3k=
@@ -34,6 +38,9 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
3438
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
3539
github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=
3640
github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg=
41+
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
42+
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
43+
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
3744
github.com/go-openapi/jsonpointer v0.21.1 h1:whnzv/pNXtK2FbX/W9yJfRmE2gsmkfahjMKB0fZvcic=
3845
github.com/go-openapi/jsonpointer v0.21.1/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk=
3946
github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ=
@@ -68,6 +75,11 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
6875
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
6976
github.com/ironcore-dev/controller-utils v0.10.0 h1:nG+TsVMtxt6PLJrlLr2LePYd8cOxud+z76rhuy5gCOs=
7077
github.com/ironcore-dev/controller-utils v0.10.0/go.mod h1:ZGv1A78M0X2G20ex/7F5BbyHoG0+7U2IWfqvzHh8T+4=
78+
github.com/jaypipes/ghw v0.17.0 h1:EVLJeNcy5z6GK/Lqby0EhBpynZo+ayl8iJWY0kbEUJA=
79+
github.com/jaypipes/ghw v0.17.0/go.mod h1:In8SsaDqlb1oTyrbmTC14uy+fbBMvp+xdqX51MidlD8=
80+
github.com/jaypipes/pcidb v1.0.1 h1:WB2zh27T3nwg8AE8ei81sNRb9yWBii3JGNJtT7K9Oic=
81+
github.com/jaypipes/pcidb v1.0.1/go.mod h1:6xYUz/yYEyOkIkUt2t2J2folIuZ4Yg6uByCGFXMCeE4=
82+
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
7183
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
7284
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
7385
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
@@ -84,6 +96,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
8496
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
8597
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
8698
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
99+
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
100+
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
87101
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
88102
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
89103
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -195,6 +209,7 @@ golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
195209
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
196210
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
197211
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
212+
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
198213
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
199214
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
200215
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
@@ -233,9 +248,12 @@ gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSP
233248
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
234249
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
235250
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
251+
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
236252
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
237253
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
238254
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
255+
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
256+
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
239257
k8s.io/api v0.33.3 h1:SRd5t//hhkI1buzxb288fy2xvjubstenEKL9K51KBI8=
240258
k8s.io/api v0.33.3/go.mod h1:01Y/iLUjNBM3TAvypct7DIj0M0NIZc+PzAHCIo0CYGE=
241259
k8s.io/apiextensions-apiserver v0.33.3 h1:qmOcAHN6DjfD0v9kxL5udB27SRP6SG/MTopmge3MwEs=

internal/api/registry/block.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package registry
2+
3+
type BlockDevice struct {
4+
Path string
5+
Name string
6+
//Type string
7+
Rotational bool
8+
Removable bool
9+
ReadOnly bool
10+
Vendor string
11+
Model string
12+
Serial string
13+
WWID string
14+
//FirmwareRevision string
15+
//State string
16+
PhysicalBlockSize uint64
17+
LogicalBlockSize uint64
18+
HWSectorSize uint64
19+
Size uint64
20+
NUMANodeID uint64
21+
// TODO: do we need to gather health info and other stats?
22+
}

internal/api/registry/cpu.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package registry
2+
3+
type CPUInfo struct {
4+
ID int `json:"id"`
5+
TotalCores uint32 `json:"totalCores"`
6+
TotalHardwareThreads uint32 `json:"totalHardwareThreads"`
7+
Vendor string `json:"vendor"`
8+
Model string `json:"model"`
9+
Capabilities []string `json:"capabilities"`
10+
}

internal/api/registry/lldp.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package registry
2+
3+
type LLDP struct {
4+
Interfaces []LLDPInterface `json:"Neighbors"`
5+
}
6+
7+
type LLDPInterface struct {
8+
InterfaceIndex int `json:"InterfaceIndex"`
9+
InterfaceName string `json:"InterfaceName"`
10+
InterfaceAlternativeNames []string `json:"InterfaceAlternativeNames"`
11+
Neighbors []struct {
12+
ChassisID string `json:"ChassisID"`
13+
RawChassisID []int `json:"RawChassisID"`
14+
PortID string `json:"PortID"`
15+
RawPortID []int `json:"RawPortID"`
16+
PortDescription string `json:"PortDescription"`
17+
SystemName string `json:"SystemName"`
18+
SystemDescription string `json:"SystemDescription"`
19+
EnabledCapabilities int `json:"EnabledCapabilities"`
20+
} `json:"Neighbors"`
21+
}

internal/api/registry/server.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,41 @@ type NetworkInterface struct {
1111
MACAddress string `json:"macAddress"`
1212
}
1313

14+
type DMI struct {
15+
BIOSInformation BIOSInformation
16+
SystemInformation ServerInformation
17+
BoardInformation BoardInformation
18+
}
19+
20+
type BIOSInformation struct {
21+
Vendor string
22+
Version string
23+
Date string
24+
}
25+
26+
type ServerInformation struct {
27+
Manufacturer string
28+
ProductName string
29+
Version string
30+
SerialNumber string
31+
UUID string
32+
SKUNumber string
33+
Family string
34+
}
35+
36+
type BoardInformation struct {
37+
Manufacturer string
38+
Product string
39+
Version string
40+
SerialNumber string
41+
AssetTag string
42+
}
43+
1444
// Server represents a server with a list of network interfaces.
1545
type Server struct {
46+
SystemInfo DMI `json:"systemInfo,omitempty"`
47+
CPU []CPUInfo `json:"cpu,omitempty"`
1648
NetworkInterfaces []NetworkInterface `json:"networkInterfaces,omitempty"`
49+
LLDP LLDP `json:"lldp,omitempty"`
50+
Storage []BlockDevice `json:"storage,omitempty"`
1751
}

internal/controller/common_test_helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TransistionServerFromInitialToAvailableState(
101101
), fmt.Sprintf("Expected Server to be in PowerState 'on' in discovery state %v", server))
102102

103103
By("Starting the probe agent")
104-
probeAgent := probe.NewAgent(server.Spec.SystemUUID, "http://localhost:30000", 50*time.Millisecond)
104+
probeAgent := probe.NewAgent(server.Spec.SystemUUID, "http://localhost:30000", 100*time.Millisecond, 50*time.Millisecond, 250*time.Millisecond)
105105
go func() {
106106
defer GinkgoRecover()
107107
Expect(probeAgent.Start(ctx)).To(Succeed(), "failed to start probe agent")

internal/controller/server_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ var _ = Describe("Server Controller", func() {
242242
))
243243

244244
By("Starting the probe agent")
245-
probeAgent := probe.NewAgent(server.Spec.SystemUUID, registryURL, 100*time.Millisecond)
245+
probeAgent := probe.NewAgent(server.Spec.SystemUUID, registryURL, 100*time.Millisecond, 50*time.Millisecond, 250*time.Millisecond)
246246
go func() {
247247
defer GinkgoRecover()
248248
Expect(probeAgent.Start(ctx)).To(Succeed(), "failed to start probe agent")
@@ -435,7 +435,7 @@ var _ = Describe("Server Controller", func() {
435435
))
436436

437437
By("Starting the probe agent")
438-
probeAgent := probe.NewAgent(server.Spec.SystemUUID, registryURL, 50*time.Millisecond)
438+
probeAgent := probe.NewAgent(server.Spec.SystemUUID, registryURL, 50*time.Millisecond, 50*time.Millisecond, 250*time.Millisecond)
439439
go func() {
440440
defer GinkgoRecover()
441441
Expect(probeAgent.Start(ctx)).To(Succeed(), "failed to start probe agent")

0 commit comments

Comments
 (0)