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
e9316e4c
Commit
e9316e4c
authored
3 years ago
by
Manuel Kieweg
Browse files
Options
Downloads
Patches
Plain Diff
change southbound interface
parent
8741b88f
No related branches found
No related tags found
1 merge request
!173
Process response overhaul
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
interfaces/southbound/sbi.go
+2
-1
2 additions, 1 deletion
interfaces/southbound/sbi.go
nucleus/southbound.go
+5
-30
5 additions, 30 deletions
nucleus/southbound.go
with
7 additions
and
31 deletions
interfaces/southbound/sbi.go
+
2
−
1
View file @
e9316e4c
...
@@ -2,6 +2,7 @@ package southbound
...
@@ -2,6 +2,7 @@ package southbound
import
(
import
(
spb
"code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
spb
"code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
"github.com/openconfig/ygot/ygot"
"github.com/google/uuid"
"github.com/google/uuid"
gpb
"github.com/openconfig/gnmi/proto/gnmi"
gpb
"github.com/openconfig/gnmi/proto/gnmi"
...
@@ -22,5 +23,5 @@ type SouthboundInterface interface { // nolint
...
@@ -22,5 +23,5 @@ type SouthboundInterface interface { // nolint
Schema
()
*
ytypes
.
Schema
Schema
()
*
ytypes
.
Schema
ID
()
uuid
.
UUID
ID
()
uuid
.
UUID
Type
()
spb
.
Type
Type
()
spb
.
Type
Unmarshal
()
func
([]
byte
,
[]
string
,
interface
{}
,
...
ytypes
.
UnmarshalOpt
)
error
Unmarshal
()
func
([]
byte
,
[]
string
,
ygot
.
GoStruct
,
...
ytypes
.
UnmarshalOpt
)
error
}
}
This diff is collapsed.
Click to expand it.
nucleus/southbound.go
+
5
−
30
View file @
e9316e4c
...
@@ -5,7 +5,6 @@ import (
...
@@ -5,7 +5,6 @@ import (
spb
"code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
spb
"code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
"code.fbi.h-da.de/cocsn/gosdn/interfaces/southbound"
"code.fbi.h-da.de/cocsn/gosdn/interfaces/southbound"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/errors"
"code.fbi.h-da.de/cocsn/yang-models/generated/openconfig"
"code.fbi.h-da.de/cocsn/yang-models/generated/openconfig"
"github.com/google/uuid"
"github.com/google/uuid"
...
@@ -68,39 +67,15 @@ func (oc *OpenConfig) SetNode() func(schema *yang.Entry, root interface{}, path
...
@@ -68,39 +67,15 @@ func (oc *OpenConfig) SetNode() func(schema *yang.Entry, root interface{}, path
// Unmarshal injects OpenConfig specific model representation to the transport.
// Unmarshal injects OpenConfig specific model representation to the transport.
// Needed for type assertion.
// Needed for type assertion.
func
(
oc
*
OpenConfig
)
Unmarshal
()
func
([]
byte
,
[]
string
,
interface
{}
,
...
ytypes
.
UnmarshalOpt
)
error
{
func
(
oc
*
OpenConfig
)
Unmarshal
()
func
([]
byte
,
[]
string
,
ygot
.
GoStruct
,
...
ytypes
.
UnmarshalOpt
)
error
{
return
unmarshal
return
unmarshal
}
}
// unmarshal parses a root or 1st level gNMI response to a go struct
// unmarshal parses a root or 1st level gNMI response to a go struct
// Named return to return appropriate recover error
// Named return to return appropriate recover error
func
unmarshal
(
bytes
[]
byte
,
fields
[]
string
,
goStruct
interface
{},
opt
...
ytypes
.
UnmarshalOpt
)
(
err
error
)
{
func
unmarshal
(
bytes
[]
byte
,
fields
[]
string
,
goStruct
ygot
.
GoStruct
,
opt
...
ytypes
.
UnmarshalOpt
)
(
err
error
)
{
defer
func
()
{
ygot
.
BuildEmptyTree
(
goStruct
)
if
r
:=
recover
();
r
!=
nil
{
return
openconfig
.
Unmarshal
(
bytes
,
goStruct
.
(
*
openconfig
.
Device
),
opt
...
)
err
=
r
.
(
error
)
}
}()
switch
l
:=
len
(
fields
);
l
{
case
0
:
return
openconfig
.
Unmarshal
(
bytes
,
goStruct
.
(
*
openconfig
.
Device
),
opt
...
)
case
1
:
default
:
return
&
errors
.
ErrUnsupportedPath
{
Path
:
fields
}
}
var
c
ygot
.
GoStruct
var
field
string
// Load SBI definition
d
:=
openconfig
.
Device
{}
c
,
field
,
err
=
iter
(
&
d
,
fields
)
if
err
!=
nil
{
return
}
if
err
=
openconfig
.
Unmarshal
(
bytes
,
c
,
opt
...
);
err
!=
nil
{
return
}
reflect
.
ValueOf
(
goStruct
.
(
*
openconfig
.
Device
))
.
Elem
()
.
FieldByName
(
field
)
.
Set
(
reflect
.
ValueOf
(
c
))
return
nil
}
}
// iter walks down the provided paths and initializes the ygot.GoStruct. It only works for
// iter walks down the provided paths and initializes the ygot.GoStruct. It only works for
...
@@ -170,7 +145,7 @@ func (csbi *Csbi) SetNode() func(schema *yang.Entry, root interface{}, path *gpb
...
@@ -170,7 +145,7 @@ func (csbi *Csbi) SetNode() func(schema *yang.Entry, root interface{}, path *gpb
// Unmarshal injects OpenConfig specific model representation to the transport.
// Unmarshal injects OpenConfig specific model representation to the transport.
// Needed for type assertion.
// Needed for type assertion.
func
(
csbi
*
Csbi
)
Unmarshal
()
func
([]
byte
,
[]
string
,
interface
{}
,
...
ytypes
.
UnmarshalOpt
)
error
{
func
(
csbi
*
Csbi
)
Unmarshal
()
func
([]
byte
,
[]
string
,
ygot
.
GoStruct
,
...
ytypes
.
UnmarshalOpt
)
error
{
return
unmarshal
return
unmarshal
}
}
...
...
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