Skip to content

Commit 705e542

Browse files
authored
Extend NetworkInterface status with LLDP neighbor information (#492)
* internal/probe: update to report all network interfaces * api: update networkInterfaces, add Lldp * internal: update networkInterfaces, add carrierState, ipv6 and neighbors - add fields to registry - handle new registry fields and update crd * add generated files, fix linter * update IPAddresses, set IPAddress to nil * update lldp parser * address review comments
1 parent ab7d178 commit 705e542

File tree

12 files changed

+387
-47
lines changed

12 files changed

+387
-47
lines changed

api/v1alpha1/common_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
)
1313

1414
// IP is an IP address.
15+
// +kubebuilder:validation:Type=string
16+
// +kubebuilder:validation:Format=ip
1517
type IP struct {
1618
netip.Addr `json:"-"`
1719
}

api/v1alpha1/server_types.go

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,50 @@ type NetworkInterface struct {
291291
Name string `json:"name"`
292292

293293
// IP is the IP address assigned to the network interface.
294-
// The type is specified as string and is schemaless.
294+
// Deprecated: Use IPs instead. Kept for backward compatibility, always nil.
295295
// +kubebuilder:validation:Type=string
296296
// +kubebuilder:validation:Schemaless
297-
// +required
298-
IP IP `json:"ip"`
297+
// +optional
298+
IP *IP `json:"ip,omitempty"`
299+
300+
// IPs is a list of IP addresses (both IPv4 and IPv6) assigned to the network interface.
301+
// +optional
302+
IPs []IP `json:"ips,omitempty"`
299303

300304
// MACAddress is the MAC address of the network interface.
301305
// +required
302306
MACAddress string `json:"macAddress"`
307+
308+
// CarrierStatus is the operational carrier status of the network interface.
309+
// +optional
310+
CarrierStatus string `json:"carrierStatus,omitempty"`
311+
312+
// Neighbors contains the LLDP neighbors discovered on this interface.
313+
// +optional
314+
Neighbors []LLDPNeighbor `json:"neighbors,omitempty"`
315+
}
316+
317+
// LLDPNeighbor defines the details of an LLDP neighbor.
318+
type LLDPNeighbor struct {
319+
// MACAddress is the MAC address of the LLDP neighbor.
320+
// +optional
321+
MACAddress string `json:"macAddress,omitempty"`
322+
323+
// PortID is the port identifier of the LLDP neighbor.
324+
// +optional
325+
PortID string `json:"portID,omitempty"`
326+
327+
// PortDescription is the port description of the LLDP neighbor.
328+
// +optional
329+
PortDescription string `json:"portDescription,omitempty"`
330+
331+
// SystemName is the system name of the LLDP neighbor.
332+
// +optional
333+
SystemName string `json:"systemName,omitempty"`
334+
335+
// SystemDescription is the system description of the LLDP neighbor.
336+
// +optional
337+
SystemDescription string `json:"systemDescription,omitempty"`
303338
}
304339

305340
// StorageDrive defines the details of one storage drive

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 31 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bmc/redfish_kube.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func (r *RedfishKubeBMC) SetPXEBootOnce(ctx context.Context, systemURI string) e
383383
if err := system.SetBoot(setBoot); err != nil {
384384
return fmt.Errorf("failed to set the boot order: %w", err)
385385
}
386-
netData := `{"networkInterfaces":[{"name":"dummy0","ipAddress":"127.0.0.2","macAddress":"aa:bb:cc:dd:ee:ff"}]`
386+
netData := `{"networkInterfaces":[{"name":"dummy0","ipAddresses":["127.0.0.2"],"macAddress":"aa:bb:cc:dd:ee:ff"}]`
387387
curlCmd := fmt.Sprintf(
388388
`apk add curl && curl -H 'Content-Type: application/json' \
389389
-d '{"SystemUUID":"%s","data":%s}}' \

config/crd/bases/metal.ironcore.dev_servers.yaml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,19 +461,57 @@ spec:
461461
items:
462462
description: NetworkInterface defines the details of a network interface.
463463
properties:
464+
carrierStatus:
465+
description: CarrierStatus is the operational carrier status
466+
of the network interface.
467+
type: string
464468
ip:
465469
description: |-
466470
IP is the IP address assigned to the network interface.
467-
The type is specified as string and is schemaless.
471+
Deprecated: Use IPs instead. Kept for backward compatibility, always nil.
468472
type: string
473+
ips:
474+
description: IPs is a list of IP addresses (both IPv4 and IPv6)
475+
assigned to the network interface.
476+
items:
477+
format: ip
478+
type: string
479+
type: array
469480
macAddress:
470481
description: MACAddress is the MAC address of the network interface.
471482
type: string
472483
name:
473484
description: Name is the name of the network interface.
474485
type: string
486+
neighbors:
487+
description: Neighbors contains the LLDP neighbors discovered
488+
on this interface.
489+
items:
490+
description: LLDPNeighbor defines the details of an LLDP neighbor.
491+
properties:
492+
macAddress:
493+
description: MACAddress is the MAC address of the LLDP
494+
neighbor.
495+
type: string
496+
portDescription:
497+
description: PortDescription is the port description of
498+
the LLDP neighbor.
499+
type: string
500+
portID:
501+
description: PortID is the port identifier of the LLDP
502+
neighbor.
503+
type: string
504+
systemDescription:
505+
description: SystemDescription is the system description
506+
of the LLDP neighbor.
507+
type: string
508+
systemName:
509+
description: SystemName is the system name of the LLDP
510+
neighbor.
511+
type: string
512+
type: object
513+
type: array
475514
required:
476-
- ip
477515
- macAddress
478516
- name
479517
type: object

dist/chart/templates/crd/metal.ironcore.dev_servers.yaml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,19 +467,57 @@ spec:
467467
items:
468468
description: NetworkInterface defines the details of a network interface.
469469
properties:
470+
carrierStatus:
471+
description: CarrierStatus is the operational carrier status
472+
of the network interface.
473+
type: string
470474
ip:
471475
description: |-
472476
IP is the IP address assigned to the network interface.
473-
The type is specified as string and is schemaless.
477+
Deprecated: Use IPs instead. Kept for backward compatibility, always nil.
474478
type: string
479+
ips:
480+
description: IPs is a list of IP addresses (both IPv4 and IPv6)
481+
assigned to the network interface.
482+
items:
483+
format: ip
484+
type: string
485+
type: array
475486
macAddress:
476487
description: MACAddress is the MAC address of the network interface.
477488
type: string
478489
name:
479490
description: Name is the name of the network interface.
480491
type: string
492+
neighbors:
493+
description: Neighbors contains the LLDP neighbors discovered
494+
on this interface.
495+
items:
496+
description: LLDPNeighbor defines the details of an LLDP neighbor.
497+
properties:
498+
macAddress:
499+
description: MACAddress is the MAC address of the LLDP
500+
neighbor.
501+
type: string
502+
portDescription:
503+
description: PortDescription is the port description of
504+
the LLDP neighbor.
505+
type: string
506+
portID:
507+
description: PortID is the port identifier of the LLDP
508+
neighbor.
509+
type: string
510+
systemDescription:
511+
description: SystemDescription is the system description
512+
of the LLDP neighbor.
513+
type: string
514+
systemName:
515+
description: SystemName is the system name of the LLDP
516+
neighbor.
517+
type: string
518+
type: object
519+
type: array
481520
required:
482-
- ip
483521
- macAddress
484522
- name
485523
type: object

docs/api-reference/api.md

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3037,6 +3037,84 @@ IP
30373037
</tr>
30383038
</tbody>
30393039
</table>
3040+
<h3 id="metal.ironcore.dev/v1alpha1.LLDPNeighbor">LLDPNeighbor
3041+
</h3>
3042+
<p>
3043+
(<em>Appears on:</em><a href="#metal.ironcore.dev/v1alpha1.NetworkInterface">NetworkInterface</a>)
3044+
</p>
3045+
<div>
3046+
<p>LLDPNeighbor defines the details of an LLDP neighbor.</p>
3047+
</div>
3048+
<table>
3049+
<thead>
3050+
<tr>
3051+
<th>Field</th>
3052+
<th>Description</th>
3053+
</tr>
3054+
</thead>
3055+
<tbody>
3056+
<tr>
3057+
<td>
3058+
<code>macAddress</code><br/>
3059+
<em>
3060+
string
3061+
</em>
3062+
</td>
3063+
<td>
3064+
<em>(Optional)</em>
3065+
<p>MACAddress is the MAC address of the LLDP neighbor.</p>
3066+
</td>
3067+
</tr>
3068+
<tr>
3069+
<td>
3070+
<code>portID</code><br/>
3071+
<em>
3072+
string
3073+
</em>
3074+
</td>
3075+
<td>
3076+
<em>(Optional)</em>
3077+
<p>PortID is the port identifier of the LLDP neighbor.</p>
3078+
</td>
3079+
</tr>
3080+
<tr>
3081+
<td>
3082+
<code>portDescription</code><br/>
3083+
<em>
3084+
string
3085+
</em>
3086+
</td>
3087+
<td>
3088+
<em>(Optional)</em>
3089+
<p>PortDescription is the port description of the LLDP neighbor.</p>
3090+
</td>
3091+
</tr>
3092+
<tr>
3093+
<td>
3094+
<code>systemName</code><br/>
3095+
<em>
3096+
string
3097+
</em>
3098+
</td>
3099+
<td>
3100+
<em>(Optional)</em>
3101+
<p>SystemName is the system name of the LLDP neighbor.</p>
3102+
</td>
3103+
</tr>
3104+
<tr>
3105+
<td>
3106+
<code>systemDescription</code><br/>
3107+
<em>
3108+
string
3109+
</em>
3110+
</td>
3111+
<td>
3112+
<em>(Optional)</em>
3113+
<p>SystemDescription is the system description of the LLDP neighbor.</p>
3114+
</td>
3115+
</tr>
3116+
</tbody>
3117+
</table>
30403118
<h3 id="metal.ironcore.dev/v1alpha1.NetworkInterface">NetworkInterface
30413119
</h3>
30423120
<p>
@@ -3074,8 +3152,23 @@ IP
30743152
</em>
30753153
</td>
30763154
<td>
3155+
<em>(Optional)</em>
30773156
<p>IP is the IP address assigned to the network interface.
3078-
The type is specified as string and is schemaless.</p>
3157+
Deprecated: Use IPs instead. Kept for backward compatibility, always nil.</p>
3158+
</td>
3159+
</tr>
3160+
<tr>
3161+
<td>
3162+
<code>ips</code><br/>
3163+
<em>
3164+
<a href="#metal.ironcore.dev/v1alpha1.IP">
3165+
[]IP
3166+
</a>
3167+
</em>
3168+
</td>
3169+
<td>
3170+
<em>(Optional)</em>
3171+
<p>IPs is a list of IP addresses (both IPv4 and IPv6) assigned to the network interface.</p>
30793172
</td>
30803173
</tr>
30813174
<tr>
@@ -3089,6 +3182,32 @@ string
30893182
<p>MACAddress is the MAC address of the network interface.</p>
30903183
</td>
30913184
</tr>
3185+
<tr>
3186+
<td>
3187+
<code>carrierStatus</code><br/>
3188+
<em>
3189+
string
3190+
</em>
3191+
</td>
3192+
<td>
3193+
<em>(Optional)</em>
3194+
<p>CarrierStatus is the operational carrier status of the network interface.</p>
3195+
</td>
3196+
</tr>
3197+
<tr>
3198+
<td>
3199+
<code>neighbors</code><br/>
3200+
<em>
3201+
<a href="#metal.ironcore.dev/v1alpha1.LLDPNeighbor">
3202+
[]LLDPNeighbor
3203+
</a>
3204+
</em>
3205+
</td>
3206+
<td>
3207+
<em>(Optional)</em>
3208+
<p>Neighbors contains the LLDP neighbors discovered on this interface.</p>
3209+
</td>
3210+
</tr>
30923211
</tbody>
30933212
</table>
30943213
<h3 id="metal.ironcore.dev/v1alpha1.Phase">Phase

0 commit comments

Comments
 (0)