Skip to content
Snippets Groups Projects
Commit a14f90aa authored by Malte Bauch's avatar Malte Bauch
Browse files

WIP

parent 395ed59e
No related branches found
No related tags found
4 merge requests!17Build basic ci,!10Add simple modem support on linux through modemmanager,!8General refactoring,!5Draft: Add basic set support for ip/routing via gnmi
package ubuntu
import (
"fmt"
"github.com/openconfig/gnmi/proto/gnmi"
)
type PathFunc func(path *gnmi.Path, val *gnmi.TypedValue) error
type PathMap map[string]PathFunc
func (pm PathMap) Register(s string, fn PathFunc) error {
if _, found := pm[s]; found {
return fmt.Errorf("a function is already registered for path: '%s'", s)
}
pm[s] = fn
return nil
}
func (pm PathMap) Execute(s string) error {
return execute(pm, s)
}
func execute(pm PathMap, p string) error {
if _, found := pm[p]; found {
//return fn()
}
return fmt.Errorf("The given path: '%s' is not supported", p)
}
package ubuntu package ubuntu
import ( import (
"fmt"
"net" "net"
"os" "os"
"os/exec" "os/exec"
...@@ -62,12 +63,12 @@ func (ou *OsclientUbuntu) callbackFunc(config ygot.ValidatedGoStruct) error { ...@@ -62,12 +63,12 @@ func (ou *OsclientUbuntu) callbackFunc(config ygot.ValidatedGoStruct) error {
return err return err
} }
for _, diff := range diffs.GetUpdate() { for _, diff := range diffs.GetUpdate() {
path, err := ygot.PathToString(diff.GetPath()) schemaPath, err := ygot.PathToSchemaPath(diff.GetPath())
if err != nil { if err != nil {
return err return err
} }
log.Info(path) log.Info(schemaPath)
switch path { switch schemaPath {
case "/system/config/hostname": case "/system/config/hostname":
value, err := gnmiv.ToScalar(diff.GetVal()) value, err := gnmiv.ToScalar(diff.GetVal())
if err != nil { if err != nil {
...@@ -78,7 +79,7 @@ func (ou *OsclientUbuntu) callbackFunc(config ygot.ValidatedGoStruct) error { ...@@ -78,7 +79,7 @@ func (ou *OsclientUbuntu) callbackFunc(config ygot.ValidatedGoStruct) error {
return err return err
} }
default: default:
//INFO: currently this case is ignored return fmt.Errorf("this path is not supported")
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment