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
10 changes: 10 additions & 0 deletions internal/provider/cisco/nxos/pim.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ var (
_ gnmiext.Configurable = (*PIM)(nil)
_ gnmiext.Configurable = (*PIMDom)(nil)
_ gnmiext.Configurable = (*StaticRPItems)(nil)
_ gnmiext.Configurable = (*StaticRP)(nil)
_ gnmiext.Configurable = (*StaticRPGrp)(nil)
_ gnmiext.Configurable = (*AnycastPeerItems)(nil)
_ gnmiext.Configurable = (*PIMIfItems)(nil)
)
Expand Down Expand Up @@ -63,10 +65,18 @@ type StaticRPGrp struct {
Bidir bool `json:"bidir"`
GrpListName string `json:"grpListName"`
Override bool `json:"override"`

// RpAddr is the parent StaticRP address, used to construct the XPath.
// It is not serialized to JSON.
RpAddr string `json:"-"`
}

func (g *StaticRPGrp) Key() string { return g.GrpListName }

func (g *StaticRPGrp) XPath() string {
return "System/pim-items/inst-items/dom-items/Dom-list[name=default]/staticrp-items/rp-items/StaticRP-list[addr=" + g.RpAddr + "]/rpgrplist-items/RPGrpList-list[grpListName=" + g.GrpListName + "]"
}

type AnycastPeerItems struct {
AcastRPPeerList gnmiext.List[AnycastPeerAddr, *AnycastPeerAddr] `json:"AcastRPPeer-list,omitzero"`
}
Expand Down
34 changes: 33 additions & 1 deletion internal/provider/cisco/nxos/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1705,7 +1705,39 @@ func (p *Provider) EnsurePIM(ctx context.Context, req *provider.EnsurePIMRequest
del := make([]gnmiext.Configurable, 0, 3)

if len(rpItems.StaticRPList) > 0 {
conf = append(conf, rpItems)
// Diff group-to-RP bindings individually; replacing entire StaticRP entries fails on NX-OS
// with "child (Rn) cannot be added to deleted object Rn=rpgrplist-[...], Commit Failed".
current := new(StaticRPItems)
if err := p.client.GetConfig(ctx, current); err != nil && !errors.Is(err, gnmiext.ErrNil) {
return err
}
for _, rp := range rpItems.StaticRPList {
got, ok := current.StaticRPList.Get(rp.Key())
if !ok {
// StaticRP does not exist yet — add the entire entry.
conf = append(conf, rp)
continue
}
for _, grp := range rp.RpgrplistItems.RPGrpListList {
if gotGrp, ok := got.RpgrplistItems.RPGrpListList.Get(grp.Key()); !ok || !reflect.DeepEqual(gotGrp, grp) {
g := *grp
g.RpAddr = rp.Addr
conf = append(conf, &g)
}
}
for _, grp := range got.RpgrplistItems.RPGrpListList {
if _, ok := rp.RpgrplistItems.RPGrpListList.Get(grp.Key()); !ok {
g := *grp
g.RpAddr = rp.Addr
del = append(del, &g)
}
}
}
for _, rp := range current.StaticRPList {
if _, ok := rpItems.StaticRPList.Get(rp.Key()); !ok {
del = append(del, rp)
}
}
} else {
del = append(del, rpItems)
}
Expand Down
Loading