@@ -825,14 +825,61 @@ func (r *ServerReconciler) extractServerDetailsFromRegistry(ctx context.Context,
825825 // update network interfaces
826826 nics := make ([]metalv1alpha1.NetworkInterface , 0 , len (serverDetails .NetworkInterfaces ))
827827 for _ , s := range serverDetails .NetworkInterfaces {
828- nics = append (nics , metalv1alpha1.NetworkInterface {
829- Name : s .Name ,
830- IP : metalv1alpha1 .MustParseIP (s .IPAddress ),
831- MACAddress : s .MACAddress ,
832- })
828+ nic := metalv1alpha1.NetworkInterface {
829+ Name : s .Name ,
830+ MACAddress : s .MACAddress ,
831+ CarrierStatus : s .CarrierStatus ,
832+ }
833+
834+ // Process all IP addresses from the single IpAddresses slice
835+ var allIPs []metalv1alpha1.IP
836+ for _ , ipAddr := range s .IpAddresses {
837+ if ipAddr != "" {
838+ // Parse and validate the IP address
839+ ip , err := metalv1alpha1 .ParseIP (ipAddr )
840+ if err != nil {
841+ log .V (1 ).Info ("Invalid IP address, skipping" , "interface" , s .Name , "ip" , ipAddr , "error" , err )
842+ continue
843+ }
844+
845+ // Add all valid IP addresses (both IPv4 and IPv6) to the slice
846+ allIPs = append (allIPs , ip )
847+ }
848+ }
849+
850+ // Set the IPs field with all collected IP addresses
851+ if len (allIPs ) > 0 {
852+ nic .IPs = allIPs
853+ }
854+
855+ nics = append (nics , nic )
856+ }
857+
858+ // Merge LLDP neighbors into corresponding network interfaces
859+ for _ , lldpIface := range serverDetails .LLDP {
860+ // Find the matching network interface by name
861+ for i := range nics {
862+ if nics [i ].Name == lldpIface .InterfaceName {
863+ // Convert LLDP neighbors to the CRD format
864+ neighbors := make ([]metalv1alpha1.LLDPNeighbor , 0 , len (lldpIface .Neighbors ))
865+ for _ , neighbor := range lldpIface .Neighbors {
866+ neighbors = append (neighbors , metalv1alpha1.LLDPNeighbor {
867+ MACAddress : neighbor .ChassisID ,
868+ PortID : neighbor .PortID ,
869+ PortDescription : neighbor .PortDescription ,
870+ SystemName : neighbor .SystemName ,
871+ SystemDescription : neighbor .SystemDescription ,
872+ })
873+ }
874+ nics [i ].Neighbors = neighbors
875+ break
876+ }
877+ }
833878 }
879+
834880 server .Status .NetworkInterfaces = nics
835881
882+ log .V (1 ).Info ("Found server information in registry" , "nics" , nics )
836883 if err := r .Status ().Patch (ctx , server , client .MergeFrom (serverBase )); err != nil {
837884 return false , fmt .Errorf ("failed to patch server status: %w" , err )
838885 }
0 commit comments