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
Merge requests
!91
"Overhaul Architecture"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
"Overhaul Architecture"
67-overhaul-architecture
into
develop
Overview
0
Commits
69
Pipelines
25
Changes
2
Merged
Ghost User
requested to merge
67-overhaul-architecture
into
develop
4 years ago
Overview
0
Commits
69
Pipelines
25
Changes
2
Expand
Closes
#67 (closed)
Edited
4 years ago
by
Ghost User
0
0
Merge request reports
Viewing commit
2692f73d
Prev
Next
Show latest version
2 files
+
90
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
2692f73d
added telemetry concept
· 2692f73d
Manuel Kieweg
authored
4 years ago
cmd/gnmi-telemetry/telemetry.go
0 → 100644
+
74
−
0
Options
package
main
import
(
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
schema
"code.fbi.h-da.de/cocsn/yang-models/generated/arista"
"context"
"fmt"
"github.com/google/uuid"
gpb
"github.com/openconfig/gnmi/proto/gnmi"
log
"github.com/sirupsen/logrus"
"os"
"os/signal"
"syscall"
"time"
)
func
main
()
{
log
.
SetLevel
(
log
.
DebugLevel
)
sbi
:=
&
nucleus
.
AristaOC
{}
transport
:=
&
nucleus
.
Gnmi
{
SetNode
:
sbi
.
SetNode
(),
RespChan
:
make
(
chan
*
gpb
.
SubscribeResponse
),
}
device
:=
nucleus
.
Device
{
Device
:
&
schema
.
Device
{},
SBI
:
sbi
,
Config
:
nucleus
.
DeviceConfig
{
Uuid
:
uuid
.
New
(),
Address
:
"[fdfd::ce05]:6030"
,
Username
:
"admin"
,
Password
:
"arista"
,
},
Transport
:
transport
,
}
pnd
:=
nucleus
.
NewPND
(
"openconfig"
,
sbi
)
if
err
:=
pnd
.
AddDevice
(
device
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
cfg
:=
&
gnmi
.
Config
{
Addr
:
device
.
Config
.
Address
,
Password
:
device
.
Config
.
Password
,
Username
:
device
.
Config
.
Username
,
}
ctx
:=
gnmi
.
NewContext
(
context
.
Background
(),
cfg
)
ctx
=
context
.
WithValue
(
ctx
,
"config"
,
cfg
)
paths
:=
[]
string
{
"/interfaces/interface/name"
}
opts
:=
&
gnmi
.
SubscribeOptions
{
UpdatesOnly
:
false
,
Prefix
:
""
,
Mode
:
"stream"
,
StreamMode
:
"sample"
,
SampleInterval
:
uint64
(
10
*
time
.
Second
.
Nanoseconds
()),
SuppressRedundant
:
false
,
HeartbeatInterval
:
uint64
(
time
.
Second
.
Nanoseconds
()),
Paths
:
gnmi
.
SplitPaths
(
paths
),
Origin
:
""
,
Target
:
device
.
Config
.
Address
,
}
done
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
done
,
syscall
.
SIGILL
,
syscall
.
SIGTERM
)
ctx
=
context
.
WithValue
(
ctx
,
"opts"
,
opts
)
go
func
()
{
if
err
:=
transport
.
Subscribe
(
ctx
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
}()
fmt
.
Println
(
"awaiting signal"
)
<-
done
fmt
.
Println
(
"exiting"
)
}
\ No newline at end of file
Loading