Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
goSDN
Commits
53d9eaf9
Commit
53d9eaf9
authored
2 years ago
by
Neil Schark
Browse files
Options
Downloads
Plain Diff
Merge branch '258-deal-with-read-only-fields-in-yang' into export-import-sdn-config
parents
5c1ee61f
0ee1cd75
No related branches found
No related tags found
1 merge request
!404
Enable export and import of SDN configuration
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controller/nucleus/gnmi_transport.go
+13
-40
13 additions, 40 deletions
controller/nucleus/gnmi_transport.go
controller/nucleus/principalNetworkDomain.go
+1
-1
1 addition, 1 deletion
controller/nucleus/principalNetworkDomain.go
with
14 additions
and
41 deletions
controller/nucleus/gnmi_transport.go
+
13
−
40
View file @
53d9eaf9
...
...
@@ -16,7 +16,6 @@ import (
"code.fbi.h-da.de/danet/gosdn/forks/goarista/gnmi"
gpb
"github.com/openconfig/gnmi/proto/gnmi"
"github.com/openconfig/goyang/pkg/yang"
"github.com/openconfig/ygot/util"
"github.com/openconfig/ygot/ygot"
"github.com/openconfig/ygot/ytypes"
log
"github.com/sirupsen/logrus"
...
...
@@ -123,41 +122,25 @@ func (g *Gnmi) applyDiff(ctx context.Context, payload change.Payload, path *gpb.
return
customerrs
.
NoNewChangesError
{
Original
:
payload
.
Original
,
Modified
:
payload
.
Modified
}
}
var
json
[]
byte
if
op
:=
ctx
.
Value
(
types
.
CtxKeyOperation
);
op
==
ppb
.
ApiOperation_API_OPERATION_UPDATE
||
op
==
ppb
.
ApiOperation_API_OPERATION_REPLACE
{
rootCopy
,
err
:=
ygot
.
DeepCopy
(
schema
.
Root
)
if
err
!=
nil
{
return
err
}
filteredUpdates
:=
make
([]
*
gpb
.
Update
,
0
)
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
()
{
filteredUpdates
=
append
(
filteredUpdates
,
u
)
}
}
ygot
.
PruneEmptyBranches
(
rootCopy
)
opts
:=
[]
ytypes
.
GetNodeOpt
{
&
ytypes
.
GetHandleWildcards
{},
}
nodes
,
err
:=
ytypes
.
GetNode
(
schema
.
RootSchema
(),
rootCopy
,
path
,
opts
...
)
if
err
!=
nil
{
return
err
}
if
len
(
nodes
)
==
0
||
err
!=
nil
||
util
.
IsValueNil
(
nodes
[
0
]
.
Data
)
{
return
customerrs
.
PathNotFoundError
{
Path
:
path
,
Err
:
err
}
}
json
,
err
=
ygot
.
Marshal7951
(
nodes
[
0
]
.
Data
,
&
ygot
.
RFC7951JSONConfig
{
AppendModuleName
:
true
})
if
err
!=
nil
{
return
err
}
diff
.
Update
=
filteredUpdates
}
req
,
err
:=
createSetRequest
(
ctx
,
diff
,
json
,
path
)
req
,
err
:=
createSetRequest
(
ctx
,
diff
)
if
err
!=
nil
{
return
err
}
...
...
@@ -167,25 +150,15 @@ func (g *Gnmi) applyDiff(ctx context.Context, payload change.Payload, path *gpb.
return
err
}
func
createSetRequest
(
ctx
context
.
Context
,
diff
*
gpb
.
Notification
,
json
[]
byte
,
path
*
gpb
.
Path
)
(
*
gpb
.
SetRequest
,
error
)
{
func
createSetRequest
(
ctx
context
.
Context
,
diff
*
gpb
.
Notification
)
(
*
gpb
.
SetRequest
,
error
)
{
op
:=
ctx
.
Value
(
types
.
CtxKeyOperation
)
req
:=
&
gpb
.
SetRequest
{}
if
diff
.
Update
!=
nil
{
switch
op
{
case
ppb
.
ApiOperation_API_OPERATION_UPDATE
:
req
.
Update
=
[]
*
gpb
.
Update
{{
Path
:
path
,
Val
:
&
gpb
.
TypedValue
{
Value
:
&
gpb
.
TypedValue_JsonIetfVal
{
JsonIetfVal
:
json
},
},
}}
req
.
Update
=
diff
.
Update
case
ppb
.
ApiOperation_API_OPERATION_REPLACE
:
req
.
Replace
=
[]
*
gpb
.
Update
{{
Path
:
path
,
Val
:
&
gpb
.
TypedValue
{
Value
:
&
gpb
.
TypedValue_JsonIetfVal
{
JsonIetfVal
:
json
},
},
}}
req
.
Replace
=
diff
.
Update
default
:
return
nil
,
&
customerrs
.
OperationNotSupportedError
{
Op
:
op
}
}
...
...
This diff is collapsed.
Click to expand it.
controller/nucleus/principalNetworkDomain.go
+
1
−
1
View file @
53d9eaf9
...
...
@@ -354,7 +354,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
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment