Skip to content
Snippets Groups Projects
Commit 7e7cd100 authored by Malte Bauch's avatar Malte Bauch
Browse files

Filter read-only fields for a SET

parent 1f8c21d4
No related branches found
No related tags found
2 merge requests!404Enable export and import of SDN configuration,!403Draft: Resolve "Deal with read-only fields in YANG"
Pipeline #122962 failed
......@@ -130,23 +130,32 @@ func (g *Gnmi) applyDiff(ctx context.Context, payload change.Payload, path *gpb.
return err
}
setNodeOpts := []ytypes.SetNodeOpt{&ytypes.InitMissingElements{}, &ytypes.TolerateJSONInconsistencies{}}
for _, u := range diff.Update {
opts := []ytypes.SetNodeOpt{&ytypes.InitMissingElements{}, &ytypes.TolerateJSONInconsistencies{}}
if err := g.SetNode(schema.RootSchema(), rootCopy, u.GetPath(), u.GetVal(), opts...); err != nil {
rootSchema := schema.RootSchema()
pathString, err := ygot.PathToString(u.GetPath())
if err != nil {
return err
}
entry := rootSchema.Find(pathString)
if !entry.ReadOnly() {
if err := g.SetNode(rootSchema, rootCopy, u.GetPath(), u.GetVal(), setNodeOpts...); err != nil {
return err
}
}
}
ygot.PruneEmptyBranches(rootCopy)
opts := []ytypes.GetNodeOpt{
getNodeOpts := []ytypes.GetNodeOpt{
&ytypes.GetHandleWildcards{},
}
nodes, err := ytypes.GetNode(schema.RootSchema(), rootCopy, path, opts...)
nodes, err := ytypes.GetNode(schema.RootSchema(), rootCopy, path, getNodeOpts...)
if err != nil {
return err
}
// TODO: error handling if get nodes[0] returns a nil value
if len(nodes) == 0 || err != nil || util.IsValueNil(nodes[0].Data) {
return customerrs.PathNotFoundError{Path: path, Err: err}
}
......
......@@ -349,7 +349,7 @@ func (pnd *pndImplementation) addNetworkElement(mne networkelement.NetworkElemen
}
if mne.IsTransportValid() {
_, err = pnd.Request(mne.ID(), "/interfaces")
_, err = pnd.Request(mne.ID(), "/")
if err != nil {
return uuid.Nil, err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment