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
7021e873
Commit
7021e873
authored
2 years ago
by
Neil Schark
Browse files
Options
Downloads
Patches
Plain Diff
test commit
parent
4b1e153c
No related branches found
No related tags found
No related merge requests found
Pipeline
#125392
failed
2 years ago
Stage: build
Stage: test
Stage: analyze
Stage: integration-test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
controller/nucleus/southbound.go
+29
-15
29 additions, 15 deletions
controller/nucleus/southbound.go
with
29 additions
and
15 deletions
controller/nucleus/southbound.go
+
29
−
15
View file @
7021e873
...
@@ -122,42 +122,56 @@ func (oc *OpenConfig) Unmarshal(bytes []byte, path *gpb.Path, goStruct ygot.GoSt
...
@@ -122,42 +122,56 @@ func (oc *OpenConfig) Unmarshal(bytes []byte, path *gpb.Path, goStruct ygot.GoSt
return
unmarshal
(
oc
.
Schema
(),
bytes
,
path
,
goStruct
,
opt
...
)
return
unmarshal
(
oc
.
Schema
(),
bytes
,
path
,
goStruct
,
opt
...
)
}
}
// unmarshal parses a gNMI response to a go struct.
// Generates an empty validated struct from a given schema and path
func
unmarshal
(
schema
*
ytypes
.
Schema
,
bytes
[]
byte
,
path
*
gpb
.
Path
,
goStruct
ygot
.
GoStruct
,
opt
...
ytypes
.
UnmarshalOpt
)
error
{
func
generateEmptyValidatedStructs
(
schema
*
ytypes
.
Schema
,
path
*
gpb
.
Path
)
(
ygot
.
ValidatedGoStruct
,
ygot
.
ValidatedGoStruct
,
error
)
{
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
log
.
Error
(
r
.
(
error
))
}
}()
// Load SBI definition
// Load SBI definition
root
,
err
:=
ygot
.
DeepCopy
(
schema
.
Root
)
root
,
err
:=
ygot
.
DeepCopy
(
schema
.
Root
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
nil
,
nil
,
err
}
}
validatedDeepCopy
,
ok
:=
root
.
(
ygot
.
ValidatedGoStruct
)
validatedDeepCopy
,
ok
:=
root
.
(
ygot
.
ValidatedGoStruct
)
if
!
ok
{
if
!
ok
{
return
&
customerrs
.
InvalidTypeAssertionError
{
return
nil
,
nil
,
&
customerrs
.
InvalidTypeAssertionError
{
Value
:
root
,
Value
:
root
,
Type
:
(
*
ygot
.
ValidatedGoStruct
)(
nil
),
Type
:
(
*
ygot
.
ValidatedGoStruct
)(
nil
),
}
}
}
}
// returns the node we want to fill with the data contained in 'bytes',
// returns the node we want to fill with the data contained in 'bytes', using the specified 'path'.
// using the specified 'path'.
createdNode
,
_
,
err
:=
ytypes
.
GetOrCreateNode
(
schema
.
RootSchema
(),
validatedDeepCopy
,
path
)
createdNode
,
_
,
err
:=
ytypes
.
GetOrCreateNode
(
schema
.
RootSchema
(),
validatedDeepCopy
,
path
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
nil
,
nil
,
err
}
}
validatedCreatedNode
,
ok
:=
createdNode
.
(
ygot
.
ValidatedGoStruct
)
validatedCreatedNode
,
ok
:=
createdNode
.
(
ygot
.
ValidatedGoStruct
)
if
!
ok
{
if
!
ok
{
return
&
customerrs
.
InvalidTypeAssertionError
{
return
nil
,
nil
,
&
customerrs
.
InvalidTypeAssertionError
{
Value
:
createdNode
,
Value
:
createdNode
,
Type
:
(
*
ygot
.
ValidatedGoStruct
)(
nil
),
Type
:
(
*
ygot
.
ValidatedGoStruct
)(
nil
),
}
}
}
}
if
err
:=
openconfig
.
Unmarshal
(
bytes
,
validatedCreatedNode
,
opt
...
);
err
!=
nil
{
return
validatedDeepCopy
,
validatedCreatedNode
,
nil
}
// unmarshal parses a gNMI response to a go struct.
func
unmarshal
(
schema
*
ytypes
.
Schema
,
bytes
[]
byte
,
path
*
gpb
.
Path
,
goStruct
ygot
.
GoStruct
,
opt
...
ytypes
.
UnmarshalOpt
)
error
{
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
log
.
Error
(
r
.
(
error
))
}
}()
validatedDeepCopy
,
emptyValidatedCreatedNode
,
err
:=
generateEmptyValidatedStructs
(
schema
,
path
)
if
err
!=
nil
{
return
err
}
_
,
emptyValidatedCreatedNodeForDiff
,
err
:=
generateEmptyValidatedStructs
(
schema
,
path
)
if
err
!=
nil
{
return
err
}
if
err
:=
openconfig
.
Unmarshal
(
bytes
,
emptyValidatedCreatedNode
,
opt
...
);
err
!=
nil
{
return
err
return
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