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
c9e49137
Commit
c9e49137
authored
4 years ago
by
Manuel Kieweg
Browse files
Options
Downloads
Patches
Plain Diff
parse notification
parent
09b42989
No related branches found
No related tags found
2 merge requests
!91
"Overhaul Architecture"
,
!90
Develop
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/gnmi/gnmi.go
+8
-2
8 additions, 2 deletions
cmd/gnmi/gnmi.go
nucleus/device.go
+10
-23
10 additions, 23 deletions
nucleus/device.go
with
18 additions
and
25 deletions
cmd/gnmi/gnmi.go
+
8
−
2
View file @
c9e49137
...
@@ -3,6 +3,7 @@ package main
...
@@ -3,6 +3,7 @@ package main
import
(
import
(
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"code.fbi.h-da.de/cocsn/yang-models/generated/openconfig"
"context"
"context"
"fmt"
"fmt"
"github.com/google/uuid"
"github.com/google/uuid"
...
@@ -12,6 +13,7 @@ import (
...
@@ -12,6 +13,7 @@ import (
func
main
()
{
func
main
()
{
sbi
:=
&
nucleus
.
OpenConfig
{}
sbi
:=
&
nucleus
.
OpenConfig
{}
device
:=
nucleus
.
Device
{
device
:=
nucleus
.
Device
{
Device
:
&
openconfig
.
Device
{},
SBI
:
sbi
,
SBI
:
sbi
,
Config
:
nucleus
.
DeviceConfig
{
Config
:
nucleus
.
DeviceConfig
{
Uuid
:
uuid
.
New
(),
Uuid
:
uuid
.
New
(),
...
@@ -33,11 +35,15 @@ func main() {
...
@@ -33,11 +35,15 @@ func main() {
ctx
:=
gnmi
.
NewContext
(
context
.
Background
(),
cfg
)
ctx
:=
gnmi
.
NewContext
(
context
.
Background
(),
cfg
)
ctx
=
context
.
WithValue
(
ctx
,
"config"
,
cfg
)
ctx
=
context
.
WithValue
(
ctx
,
"config"
,
cfg
)
paths
:=
[]
string
{
"
interfaces/interface
"
}
paths
:=
[]
string
{
""
}
req
,
err
:=
gnmi
.
NewGetRequest
(
gnmi
.
SplitPaths
(
paths
),
""
)
req
,
err
:=
gnmi
.
NewGetRequest
(
gnmi
.
SplitPaths
(
paths
),
""
)
resp
,
err
:=
nucleus
.
GetWithRequest
(
ctx
,
req
)
resp
,
err
:=
nucleus
.
GetWithRequest
(
ctx
,
req
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
fmt
.
Printf
(
"%v"
,
resp
)
fmt
.
Println
(
resp
)
if
err
:=
device
.
Add
(
resp
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
fmt
.
Println
(
device
.
Config
)
}
}
This diff is collapsed.
Click to expand it.
nucleus/device.go
+
10
−
23
View file @
c9e49137
package
nucleus
package
nucleus
import
(
import
(
"code.fbi.h-da.de/cocsn/yang-models/generated/openconfig"
"github.com/google/uuid"
"github.com/google/uuid"
"github.com/openconfig/gnmi/proto/gnmi"
pb
"github.com/openconfig/gnmi/proto/gnmi"
"github.com/openconfig/ygot/ygot"
"github.com/openconfig/ygot/ygot"
log
"github.com/
sirupsen/logru
s"
"github.com/
openconfig/ygot/ytype
s"
)
)
type
Device
struct
{
type
Device
struct
{
...
@@ -18,27 +17,15 @@ type Device struct {
...
@@ -18,27 +17,15 @@ type Device struct {
// Add adds a property to a device. Please
// Add adds a property to a device. Please
// use better naming in further develop
// use better naming in further develop
// Also all that Interface Call specific logic belongs to SBI!
// Also all that Interface Call specific logic belongs to SBI!
func
(
d
Device
)
Add
(
resp
interface
{})
{
func
(
d
Device
)
Add
(
resp
interface
{})
error
{
r
:=
resp
.
(
*
gnmi
.
GetResponse
)
r
:=
resp
.
(
*
pb
.
GetResponse
)
log
.
Debug
(
r
)
rn
:=
r
.
Notification
device
:=
d
.
Device
.
(
*
openconfig
.
Device
)
for
_
,
msg
:=
range
rn
{
ifaces
:=
make
(
map
[
string
]
*
openconfig
.
OpenconfigInterfaces_Interfaces_Interface
)
if
err
:=
ytypes
.
SetNode
(
nil
,
d
.
Device
,
msg
.
Prefix
,
msg
);
err
!=
nil
{
ifaces
[
"test"
]
=
&
openconfig
.
OpenconfigInterfaces_Interfaces_Interface
{
return
err
Aggregation
:
nil
,
}
Config
:
nil
,
Ethernet
:
nil
,
HoldTime
:
nil
,
Name
:
nil
,
RoutedVlan
:
nil
,
State
:
nil
,
Subinterfaces
:
nil
,
}
}
// It's possible that the gnmi response already is too Arista-fied to be used w/YGOT
return
nil
ifs
:=
&
openconfig
.
OpenconfigInterfaces_Interfaces
{
Interface
:
ifaces
,
}
device
.
Interfaces
=
ifs
d
.
Device
=
device
}
}
type
DeviceConfig
struct
{
type
DeviceConfig
struct
{
...
...
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