Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gNMI Target
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
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
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
gNMI Target
Commits
395ed59e
Commit
395ed59e
authored
3 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
Adding a callback function for `Set`
parent
ec76b14a
Branches
Branches containing commit
No related tags found
4 merge requests
!17
Build basic ci
,
!10
Add simple modem support on linux through modemmanager
,
!8
General refactoring
,
!5
Draft: Add basic set support for ip/routing via gnmi
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+2
-0
2 additions, 0 deletions
.gitignore
gnmitarget/target.go
+2
-2
2 additions, 2 deletions
gnmitarget/target.go
os_clients/ubuntu/ubuntu.go
+42
-17
42 additions, 17 deletions
os_clients/ubuntu/ubuntu.go
with
46 additions
and
19 deletions
.gitignore
+
2
−
0
View file @
395ed59e
# tooling
# tooling
build-tools/
build-tools/
artifacts/
# non vimmers
# non vimmers
.devcontainer/
.vscode/
.vscode/
.idea/
.idea/
...
...
This diff is collapsed.
Click to expand it.
gnmitarget/target.go
+
2
−
2
View file @
395ed59e
...
@@ -27,7 +27,7 @@ var GnmiTargetYgot ygot.ValidatedGoStruct
...
@@ -27,7 +27,7 @@ var GnmiTargetYgot ygot.ValidatedGoStruct
func
scheduler
(
server
*
gnmiserver
.
Server
,
osclient
os_clients
.
Osclient
)
{
func
scheduler
(
server
*
gnmiserver
.
Server
,
osclient
os_clients
.
Osclient
)
{
for
{
for
{
<-
time
.
After
(
5
*
time
.
Second
)
<-
time
.
After
(
30
*
time
.
Second
)
log
.
Info
(
"Update config..."
)
log
.
Info
(
"Update config..."
)
go
server
.
InternalUpdate
(
currentosclient
.
UpdateConfig
)
go
server
.
InternalUpdate
(
currentosclient
.
UpdateConfig
)
}
}
...
@@ -66,7 +66,7 @@ func StartGNMITarget(bindAddress string, configFile string, osclient string) err
...
@@ -66,7 +66,7 @@ func StartGNMITarget(bindAddress string, configFile string, osclient string) err
}
}
}
}
gnmiServer
,
err
:=
gnmiserver
.
NewServer
(
model
,
GnmiTargetYgot
,
nil
)
gnmiServer
,
err
:=
gnmiserver
.
NewServer
(
model
,
GnmiTargetYgot
,
currentosclient
.
GetCallbackFunc
()
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"error in creating GNMI target: %v"
,
err
)
log
.
Fatalf
(
"error in creating GNMI target: %v"
,
err
)
}
}
...
...
This diff is collapsed.
Click to expand it.
os_clients/ubuntu/ubuntu.go
+
42
−
17
View file @
395ed59e
package
ubuntu
package
ubuntu
import
(
import
(
"fmt"
"net"
"net"
"os"
"os"
"os/exec"
"os/exec"
"strings"
"strings"
"syscall"
"time"
"time"
"code.fbi.h-da.de/danet/gnmi-target/modeldata/gnmitargetygot"
"code.fbi.h-da.de/danet/gnmi-target/modeldata/gnmitargetygot"
gnmiv
"github.com/openconfig/gnmi/value"
"github.com/openconfig/ygot/ygot"
"github.com/openconfig/ygot/ygot"
log
"github.com/sirupsen/logrus"
log
"github.com/sirupsen/logrus"
"github.com/vishvananda/netlink"
"github.com/vishvananda/netlink"
...
@@ -32,19 +33,19 @@ func (ou OsclientUbuntu) UpdateConfig(config *ygot.ValidatedGoStruct) error {
...
@@ -32,19 +33,19 @@ func (ou OsclientUbuntu) UpdateConfig(config *ygot.ValidatedGoStruct) error {
func
(
ou
*
OsclientUbuntu
)
GetConfig
()
*
gnmitargetygot
.
Gnmitarget
{
func
(
ou
*
OsclientUbuntu
)
GetConfig
()
*
gnmitargetygot
.
Gnmitarget
{
ou
.
gt
=
&
gnmitargetygot
.
Gnmitarget
{}
ou
.
gt
=
&
gnmitargetygot
.
Gnmitarget
{}
// Create Interfaces
//
// Create Interfaces
h
,
err
:=
netlink
.
NewHandle
()
//
h, err := netlink.NewHandle()
if
err
!=
nil
{
//
if err != nil {
log
.
WithFields
(
log
.
Fields
{})
.
Error
(
err
)
//
log.WithFields(log.Fields{}).Error(err)
}
//
}
// defer h.Delete()
//
// defer h.Delete()
localIfaces
,
err
:=
h
.
LinkList
()
//
localIfaces, err := h.LinkList()
if
err
!=
nil
{
//
if err != nil {
log
.
WithFields
(
log
.
Fields
{})
.
Error
(
err
)
//
log.WithFields(log.Fields{}).Error(err)
}
//
}
for
_
,
localIface
:=
range
localIfaces
{
//
for _, localIface := range localIfaces {
ou
.
createInterfaces
(
localIface
,
ou
.
gt
)
//
ou.createInterfaces(localIface, ou.gt)
}
//
}
ou
.
getSystem
(
ou
.
gt
)
ou
.
getSystem
(
ou
.
gt
)
...
@@ -52,11 +53,35 @@ func (ou *OsclientUbuntu) GetConfig() *gnmitargetygot.Gnmitarget {
...
@@ -52,11 +53,35 @@ func (ou *OsclientUbuntu) GetConfig() *gnmitargetygot.Gnmitarget {
}
}
func
(
ou
*
OsclientUbuntu
)
GetCallbackFunc
()
func
(
ygot
.
ValidatedGoStruct
)
error
{
func
(
ou
*
OsclientUbuntu
)
GetCallbackFunc
()
func
(
ygot
.
ValidatedGoStruct
)
error
{
return
callbackFunc
return
ou
.
callbackFunc
}
}
func
callbackFunc
(
config
ygot
.
ValidatedGoStruct
)
error
{
func
(
ou
*
OsclientUbuntu
)
callbackFunc
(
config
ygot
.
ValidatedGoStruct
)
error
{
fmt
.
Printf
(
"config: %v
\n
"
,
config
)
diffs
,
err
:=
ygot
.
Diff
(
ou
.
GetConfig
(),
config
)
if
err
!=
nil
{
return
err
}
for
_
,
diff
:=
range
diffs
.
GetUpdate
()
{
path
,
err
:=
ygot
.
PathToString
(
diff
.
GetPath
())
if
err
!=
nil
{
return
err
}
log
.
Info
(
path
)
switch
path
{
case
"/system/config/hostname"
:
value
,
err
:=
gnmiv
.
ToScalar
(
diff
.
GetVal
())
if
err
!=
nil
{
return
err
}
err
=
syscall
.
Sethostname
([]
byte
(
value
.
(
string
)))
if
err
!=
nil
{
return
err
}
default
:
//INFO: currently this case is ignored
}
}
return
nil
return
nil
}
}
...
...
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