Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,12 @@ resources:
kind: InterfaceConfig
path: github.com/ironcore-dev/network-operator/api/cisco/nx/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: networking.metal.ironcore.dev
kind: LLDP
path: github.com/ironcore-dev/network-operator/api/core/v1alpha1
version: v1alpha1
version: "3"
6 changes: 6 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ k8s_resource(new_name='nve1', objects=['nve1:networkvirtualizationedge'], trigge
# k8s_yaml('./config/samples/cisco/nx/v1alpha1_nveconfig.yaml')
# k8s_resource(new_name='nve1-cfg', objects=['nve1-cfg:networkvirtualizationedgeconfig'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)

k8s_yaml('./config/samples/v1alpha1_lldp.yaml')
k8s_resource(new_name='lldp', objects=['leaf1-lldp:lldp'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
# Uncomment the following lines for NXOS specific LLDP config
# k8s_yaml('./config/samples/cisco/nx/v1alpha1_lldpconfig.yaml')
# k8s_resource(new_name='lldpconfig', objects=['leaf1-lldpconfig:lldpconfig'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)

print('🚀 network-operator development environment')
print('👉 Edit the code inside the api/, cmd/, or internal/ directories')
print('👉 Tilt will automatically rebuild and redeploy when changes are detected')
Expand Down
59 changes: 59 additions & 0 deletions api/cisco/nx/v1alpha1/lldpconfig_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

v1alpha1 "github.com/ironcore-dev/network-operator/api/core/v1alpha1"
)

// +kubebuilder:rbac:groups=nx.cisco.networking.metal.ironcore.dev,resources=lldpconfigs,verbs=get;list;watch

// LLDPConfig defines the Cisco-specific configuration of an LLDP object.
type LLDPConfigSpec struct {
// InitDelay defines the delay in seconds before LLDP starts sending packets after interface comes up.
// +optional
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=10
// +kubebuilder:default=2
InitDelay int16 `json:"initDelay,omitempty"`

// HoldTime defines the time in seconds that the receiving device should hold the LLDP information before discarding it.
// +optional
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=255
// +kubebuilder:default=120
HoldTime int16 `json:"holdTime,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=lldpconfigs
// +kubebuilder:resource:singular=lldpconfig

// LLDPConfig is the Schema for the LLDPConfig API
type LLDPConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`

// spec defines the desired state of LLDP
// +required
Spec LLDPConfigSpec `json:"spec"`
}

// +kubebuilder:object:root=true

// LLDPConfigList contains a list of LLDPConfigs
type LLDPConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []LLDPConfig `json:"items"`
}

// init registers the LLDPConfig type with the scheme and sets
// itself as a dependency for the LLDP core type.
func init() {
v1alpha1.RegisterLLDPDependency(GroupVersion.WithKind("LLDPConfig"))
SchemeBuilder.Register(&LLDPConfig{}, &LLDPConfigList{})
}
73 changes: 73 additions & 0 deletions api/cisco/nx/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 3 additions & 0 deletions api/core/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ const (

// IncompatibleProviderConfigRef indicates that the referenced provider configuration is not compatible with the target platform.
IncompatibleProviderConfigRef = "IncompatibleProviderConfigRef"

// DuplicateResourceOnDevice indicates that a resource of the same type as the one being created already exists on the target device.
DuplicateResourceOnDevice = "DuplicateResourceOnDevice"
)

// Reasons that are specific to [Interface] objects.
Expand Down
123 changes: 123 additions & 0 deletions api/core/v1alpha1/lldp_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import (
"sync"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// LLDPSpec defines the desired state of LLDP
type LLDPSpec struct {
// DeviceName is the name of the Device this object belongs to. The Device object must exist in the same namespace.
// Immutable.
// +required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="DeviceRef is immutable"
DeviceRef LocalObjectReference `json:"deviceRef"`

// ProviderConfigRef is a reference to a resource holding the provider-specific configuration for this LLDP.
// If not specified the provider applies the target platform's default settings.
// +optional
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`

// AdminState indicates whether LLDP is system-wide administratively up or down.
// +required
AdminState AdminState `json:"adminState"`

// InterfaceRefs is a list of interfaces and their LLDP configuration.
// +optional
// +listType=atomic
InterfaceRefs []LLDPInterface `json:"interfaceRefs,omitempty"`
}

type LLDPInterface struct {
LocalObjectReference `json:",inline"`

// AdminState indicates whether LLDP is administratively up or down on this interface.
// This will be ignored if LLDP is configured to be administratively down system-wide.
// +optional
// +kubebuilder:default=Up
AdminState AdminState `json:"adminState"`
}

// LLDPStatus defines the observed state of LLDP.
type LLDPStatus struct {
// For Kubernetes API conventions, see:
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties

Check warning on line 49 in api/core/v1alpha1/lldp_types.go

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/master/gi

// conditions represent the current state of the LLDP resource.
// Each condition has a unique type and reflects the status of a specific aspect of the resource.
//
// Standard condition types include:
// - "Available": the resource is fully functional
// - "Progressing": the resource is being created or updated
// - "Degraded": the resource failed to reach or maintain its desired state
//
// The status of each condition is one of True, False, or Unknown.
// +listType=map
// +listMapKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=lldps
// +kubebuilder:resource:singular=lldp
// +kubebuilder:printcolumn:name="Device",type=string,JSONPath=`.spec.deviceRef.name`
// +kubebuilder:printcolumn:name="Admin State",type=string,JSONPath=`.spec.adminState`
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
// +kubebuilder:printcolumn:name="Configured",type=string,JSONPath=`.status.conditions[?(@.type=="Configured")].status`,priority=1
// +kubebuilder:printcolumn:name="Operational",type=string,JSONPath=`.status.conditions[?(@.type=="Operational")].status`,priority=1
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

// LLDP is the Schema for the lldps API
type LLDP struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitzero"`

// +required
Spec LLDPSpec `json:"spec"`

// +optional
Status LLDPStatus `json:"status,omitzero"`
}

// GetConditions implements conditions.Getter.
func (l *LLDP) GetConditions() []metav1.Condition {
return l.Status.Conditions
}

// SetConditions implements conditions.Setter.
func (l *LLDP) SetConditions(conditions []metav1.Condition) {
l.Status.Conditions = conditions
}

// +kubebuilder:object:root=true

// LLDPList contains a list of LLDP
type LLDPList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitzero"`
Items []LLDP `json:"items"`
}

var (
LLDPDependencies []schema.GroupVersionKind
lldpDependenciesMu sync.Mutex
)

// RegisterLLDPDependency registers a provider-specific GVK as a dependency of LLDP.
// ProviderConfigs should call this in their init() function to ensure the dependency is registered.
func RegisterLLDPDependency(gvk schema.GroupVersionKind) {
lldpDependenciesMu.Lock()
defer lldpDependenciesMu.Unlock()
LLDPDependencies = append(LLDPDependencies, gvk)
}

func init() {
SchemeBuilder.Register(&LLDP{}, &LLDPList{})
}
Loading