Skip to content
Open
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 @@ -285,6 +285,14 @@ resources:
kind: BGPConfig
path: github.com/ironcore-dev/network-operator/api/cisco/nx/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
domain: cisco.networking.metal.ironcore.dev
group: nx
kind: PIMConfig
path: github.com/ironcore-dev/network-operator/api/cisco/nx/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
Expand Down
53 changes: 53 additions & 0 deletions api/cisco/nx/v1alpha1/pim_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-FileCopyrightText: 2026 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"
"k8s.io/apimachinery/pkg/runtime"

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

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

// PIMConfigSpec defines the Cisco NX-OS specific PIM configuration.
type PIMConfigSpec struct {
// LogNeighborChanges enables logging when a PIM neighbor is added or removed.
// +optional
LogNeighborChanges *bool `json:"logNeighborChanges,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=pimconfigs
// +kubebuilder:resource:singular=pimconfig

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

// spec defines the desired state of PIMConfig
// +required
Spec PIMConfigSpec `json:"spec"`
}

// +kubebuilder:object:root=true

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

// init registers the PIMConfig type with the scheme and sets
// itself as a dependency for the PIM core type.
func init() {
v1alpha1.RegisterPIMDependency(GroupVersion.WithKind("PIMConfig"))
SchemeBuilder.Register(func(s *runtime.Scheme) error {
s.AddKnownTypes(GroupVersion, &PIMConfig{}, &PIMConfigList{})
return nil
})
}
78 changes: 78 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.

1 change: 1 addition & 0 deletions charts/network-operator/templates/rbac/manager-role.yaml

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

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

1 change: 1 addition & 0 deletions config/rbac/role.yaml

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

9 changes: 9 additions & 0 deletions config/samples/cisco/nx/v1alpha1_pimconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: nx.cisco.networking.metal.ironcore.dev/v1alpha1
kind: PIMConfig
metadata:
labels:
app.kubernetes.io/name: network-operator
app.kubernetes.io/managed-by: kustomize
name: leaf1-pimconfig
spec:
logNeighborChanges: true
6 changes: 6 additions & 0 deletions config/samples/v1alpha1_pim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ metadata:
spec:
deviceRef:
name: leaf1
# Uncomment to add NXOS provider-specific config
# See: ./cisco/nx/v1alpha1_pimconfig.yaml
# providerConfigRef:
# apiVersion: nx.cisco.networking.metal.ironcore.dev/v1alpha1
# kind: PIMConfig
# name: leaf1-pimconfig
rendezvousPoints:
- address: 10.0.0.100
multicastGroups:
Expand Down
35 changes: 35 additions & 0 deletions docs/api-reference/index.md

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

5 changes: 3 additions & 2 deletions internal/provider/cisco/nxos/pim.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ func (*PIM) XPath() string {
}

type PIMDom struct {
Name string `json:"name"`
AdminSt AdminSt `json:"adminSt"`
Name string `json:"name"`
AdminSt AdminSt `json:"adminSt"`
LogNbhChng *bool `json:"logNbhChng,omitempty"`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LogNbhChng *bool `json:"logNbhChng,omitempty"`
LogNbhChng bool `json:"logNbhChng"`

This field seems to always be present, with a default value of false.

Also, please pay special attention when using "omitempty". ref/ https://github.com/ironcore-dev/network-operator/blob/main/AGENTS.md?plain=1#L148-L164

}

func (*PIMDom) IsListItem() {}
Expand Down
7 changes: 7 additions & 0 deletions internal/provider/cisco/nxos/pim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ func init() {
rp := &StaticRP{Addr: "10.0.0.100/32"}
rp.RpgrplistItems.RPGrpListList.Set(&StaticRPGrp{GrpListName: "224.0.0.0/4"})
Register("pim_rp", rp)

logEnabled := true
Register("pim_dom_log", &PIMDom{
Name: "default",
AdminSt: AdminStEnabled,
LogNbhChng: &logEnabled,
})
}
8 changes: 8 additions & 0 deletions internal/provider/cisco/nxos/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,13 @@ func (p *Provider) EnsurePIM(ctx context.Context, req *provider.EnsurePIMRequest
f.AdminSt = AdminStEnabled
sb.Update(f)

var cfg nxv1alpha1.PIMConfig
if req.ProviderConfig != nil {
if err := req.ProviderConfig.Into(&cfg); err != nil {
return err
}
}

pim := new(PIM)
pim.AdminSt = AdminStEnabled
pim.InstItems.AdminSt = AdminStEnabled
Expand All @@ -2444,6 +2451,7 @@ func (p *Provider) EnsurePIM(ctx context.Context, req *provider.EnsurePIMRequest
if req.PIM.Spec.AdminState == v1alpha1.AdminStateDown {
dom.AdminSt = AdminStDisabled
}
dom.LogNbhChng = cfg.Spec.LogNeighborChanges

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dom.LogNbhChng = cfg.Spec.LogNeighborChanges
dom.LogNbhChng = false
if cfg.Spec.LogNeighborChanges != nil {
dom.LogNbhChng = *cfg.Spec.LogNeighborChanges
}

sb.Patch(dom)

rpItems := new(StaticRPItems)
Expand Down
15 changes: 15 additions & 0 deletions internal/provider/cisco/nxos/testdata/pim_dom_log.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"pim-items": {
"inst-items": {
"dom-items": {
"Dom-list": [
{
"name": "default",
"adminSt": "enabled",
"logNbhChng": true
}
]
}
}
}
}
1 change: 1 addition & 0 deletions internal/provider/cisco/nxos/testdata/pim_dom_log.json.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ip pim log-neighbor-changes
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ spec:
addresses:
- 10.255.255.20/32

-- pimconfigs/log-neighbor --
apiVersion: nx.cisco.networking.metal.ironcore.dev/v1alpha1
kind: PIMConfig
metadata:
name: log-neighbor
namespace: default
spec:
logNeighborChanges: true

-- pims/multicast --
apiVersion: networking.metal.ironcore.dev/v1alpha1
kind: PIM
Expand All @@ -24,6 +33,10 @@ spec:
deviceRef:
name: device
adminState: Up
providerConfigRef:
apiVersion: nx.cisco.networking.metal.ironcore.dev/v1alpha1
kind: PIMConfig
name: log-neighbor
interfaceRefs:
- name: lo-pim
mode: Sparse
Expand Down Expand Up @@ -119,6 +132,7 @@ spec:
{
"name": "default",
"adminSt": "enabled",
"logNbhChng": true,
"if-items": {
"If-list": [
{
Expand Down
Loading