Skip to content

Commit f8cdc24

Browse files
committed
Add ServerMetadata type for persistent discovery data and status restoration
1 parent 52d7860 commit f8cdc24

21 files changed

+2187
-6
lines changed

api/v1alpha1/constants.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ const (
5151

5252
// OperationAnnotationRotateCredentials is used to indicate that credentials should be rotated.
5353
OperationAnnotationRotateCredentials = "rotate-credentials"
54+
55+
// OperationAnnotationRediscover deletes the ServerMetadata and re-triggers discovery.
56+
OperationAnnotationRediscover = "rediscover"
5457
)
5558

5659
const (
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package v1alpha1
5+
6+
import (
7+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
8+
)
9+
10+
// +kubebuilder:object:root=true
11+
// +kubebuilder:resource:scope=Cluster,shortName=smd
12+
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
13+
14+
// ServerMetadata is a flat data object (no spec/status) that persists the full
15+
// probe agent discovery payload. Similar to how Endpoints or ConfigMap store
16+
// data directly at the root level. The relationship to its Server is
17+
// established by using the same name and an owner reference.
18+
type ServerMetadata struct {
19+
metav1.TypeMeta `json:",inline"`
20+
metav1.ObjectMeta `json:"metadata,omitempty"`
21+
22+
// SystemInfo contains BIOS, system, and board information from DMI/SMBIOS.
23+
SystemInfo MetaDataSystemInfo `json:"systemInfo,omitempty"`
24+
25+
// CPU is a list of CPUs discovered on the server.
26+
CPU []MetaDataCPU `json:"cpu,omitempty"`
27+
28+
// NetworkInterfaces is a list of network interfaces discovered on the server.
29+
NetworkInterfaces []MetaDataNetworkInterface `json:"networkInterfaces,omitempty"`
30+
31+
// LLDP contains LLDP neighbor information per interface.
32+
LLDP []MetaDataLLDPInterface `json:"lldp,omitempty"`
33+
34+
// Storage is a list of block devices discovered on the server.
35+
Storage []MetaDataBlockDevice `json:"storage,omitempty"`
36+
37+
// Memory is a list of memory devices discovered on the server.
38+
Memory []MetaDataMemoryDevice `json:"memory,omitempty"`
39+
40+
// NICs is a list of raw NIC details (PCI address, speed, firmware).
41+
NICs []MetaDataNIC `json:"nics,omitempty"`
42+
43+
// PCIDevices is a list of PCI devices discovered on the server.
44+
PCIDevices []MetaDataPCIDevice `json:"pciDevices,omitempty"`
45+
}
46+
47+
// +kubebuilder:object:root=true
48+
49+
// ServerMetadataList contains a list of ServerMetadata.
50+
type ServerMetadataList struct {
51+
metav1.TypeMeta `json:",inline"`
52+
metav1.ListMeta `json:"metadata,omitempty"`
53+
Items []ServerMetadata `json:"items"`
54+
}
55+
56+
type MetaDataSystemInfo struct {
57+
BIOSInformation MetaDataBIOSInformation `json:"biosInformation,omitempty"`
58+
SystemInformation MetaDataServerInformation `json:"systemInformation,omitempty"`
59+
BoardInformation MetaDataBoardInformation `json:"boardInformation,omitempty"`
60+
}
61+
62+
type MetaDataBIOSInformation struct {
63+
Vendor string `json:"vendor,omitempty"`
64+
Version string `json:"version,omitempty"`
65+
Date string `json:"date,omitempty"`
66+
}
67+
68+
type MetaDataServerInformation struct {
69+
Manufacturer string `json:"manufacturer,omitempty"`
70+
ProductName string `json:"productName,omitempty"`
71+
Version string `json:"version,omitempty"`
72+
SerialNumber string `json:"serialNumber,omitempty"`
73+
UUID string `json:"uuid,omitempty"`
74+
SKUNumber string `json:"skuNumber,omitempty"`
75+
Family string `json:"family,omitempty"`
76+
}
77+
78+
type MetaDataBoardInformation struct {
79+
Manufacturer string `json:"manufacturer,omitempty"`
80+
Product string `json:"product,omitempty"`
81+
Version string `json:"version,omitempty"`
82+
SerialNumber string `json:"serialNumber,omitempty"`
83+
AssetTag string `json:"assetTag,omitempty"`
84+
}
85+
86+
type MetaDataCPU struct {
87+
ID int `json:"id"`
88+
TotalCores uint32 `json:"totalCores,omitempty"`
89+
TotalHardwareThreads uint32 `json:"totalHardwareThreads,omitempty"`
90+
Vendor string `json:"vendor,omitempty"`
91+
Model string `json:"model,omitempty"`
92+
Capabilities []string `json:"capabilities,omitempty"`
93+
}
94+
95+
type MetaDataNetworkInterface struct {
96+
Name string `json:"name"`
97+
IPAddresses []string `json:"ipAddresses,omitempty"`
98+
MACAddress string `json:"macAddress"`
99+
CarrierStatus string `json:"carrierStatus,omitempty"`
100+
}
101+
102+
type MetaDataLLDPInterface struct {
103+
Name string `json:"name"`
104+
Neighbors []MetaDataLLDPNeighbor `json:"neighbors,omitempty"`
105+
}
106+
107+
type MetaDataLLDPNeighbor struct {
108+
ChassisID string `json:"chassisId,omitempty"`
109+
PortID string `json:"portId,omitempty"`
110+
PortDescription string `json:"portDescription,omitempty"`
111+
SystemName string `json:"systemName,omitempty"`
112+
SystemDescription string `json:"systemDescription,omitempty"`
113+
MgmtIP string `json:"mgmtIp,omitempty"`
114+
Capabilities []string `json:"capabilities,omitempty"`
115+
VlanID string `json:"vlanId,omitempty"`
116+
}
117+
118+
type MetaDataBlockDevice struct {
119+
Path string `json:"path,omitempty"`
120+
Name string `json:"name,omitempty"`
121+
Rotational bool `json:"rotational,omitempty"`
122+
Removable bool `json:"removable,omitempty"`
123+
ReadOnly bool `json:"readOnly,omitempty"`
124+
Vendor string `json:"vendor,omitempty"`
125+
Model string `json:"model,omitempty"`
126+
Serial string `json:"serial,omitempty"`
127+
WWID string `json:"wwid,omitempty"`
128+
PhysicalBlockSize uint64 `json:"physicalBlockSize,omitempty"`
129+
LogicalBlockSize uint64 `json:"logicalBlockSize,omitempty"`
130+
HWSectorSize uint64 `json:"hWSectorSize,omitempty"`
131+
SizeBytes uint64 `json:"sizeBytes,omitempty"`
132+
NUMANodeID int `json:"numaNodeID,omitempty"`
133+
}
134+
135+
type MetaDataMemoryDevice struct {
136+
SizeBytes int64 `json:"size,omitempty"`
137+
DeviceSet string `json:"deviceSet,omitempty"`
138+
DeviceLocator string `json:"deviceLocator,omitempty"`
139+
BankLocator string `json:"bankLocator,omitempty"`
140+
MemoryType string `json:"memoryType,omitempty"`
141+
Speed string `json:"speed,omitempty"`
142+
Vendor string `json:"vendor,omitempty"`
143+
SerialNumber string `json:"serialNumber,omitempty"`
144+
AssetTag string `json:"assetTag,omitempty"`
145+
PartNumber string `json:"partNumber,omitempty"`
146+
ConfiguredMemorySpeed string `json:"configuredMemorySpeed,omitempty"`
147+
MinimumVoltage string `json:"minimumVoltage,omitempty"`
148+
MaximumVoltage string `json:"maximumVoltage,omitempty"`
149+
ConfiguredVoltage string `json:"configuredVoltage,omitempty"`
150+
}
151+
152+
type MetaDataNIC struct {
153+
Name string `json:"name,omitempty"`
154+
MAC string `json:"mac,omitempty"`
155+
PCIAddress string `json:"pciAddress,omitempty"`
156+
Speed string `json:"speed,omitempty"`
157+
LinkModes []string `json:"linkModes,omitempty"`
158+
SupportedPorts []string `json:"supportedPorts,omitempty"`
159+
FirmwareVersion string `json:"firmwareVersion,omitempty"`
160+
}
161+
162+
type MetaDataPCIDevice struct {
163+
Address string `json:"address,omitempty"`
164+
Vendor string `json:"vendor,omitempty"`
165+
VendorID string `json:"vendorID,omitempty"`
166+
Product string `json:"product,omitempty"`
167+
ProductID string `json:"productID,omitempty"`
168+
NumaNodeID int `json:"numaNodeID,omitempty"`
169+
}
170+
171+
func init() {
172+
SchemeBuilder.Register(&ServerMetadata{}, &ServerMetadataList{})
173+
}

0 commit comments

Comments
 (0)