From e5a0e046f12e849ee775c33485ce6591691322ea Mon Sep 17 00:00:00 2001 From: Malte Bauch <malte.bauch@extern.h-da.de> Date: Tue, 7 Jun 2022 21:05:00 +0200 Subject: [PATCH] WIP --- os_clients/ubuntu/ubuntu.go | 34 +++++++++++-------- .../{ubuntu/pathHandling.go => utils.go} | 2 +- 2 files changed, 20 insertions(+), 16 deletions(-) rename os_clients/{ubuntu/pathHandling.go => utils.go} (96%) diff --git a/os_clients/ubuntu/ubuntu.go b/os_clients/ubuntu/ubuntu.go index 70ad2d8..b6dd682 100644 --- a/os_clients/ubuntu/ubuntu.go +++ b/os_clients/ubuntu/ubuntu.go @@ -9,6 +9,7 @@ import ( "time" "code.fbi.h-da.de/danet/gnmi-target/modeldata/gnmitargetygot" + osc "code.fbi.h-da.de/danet/gnmi-target/os_clients" "github.com/openconfig/gnmi/proto/gnmi" gnmiv "github.com/openconfig/gnmi/value" @@ -17,7 +18,7 @@ import ( "github.com/vishvananda/netlink" ) -var supportedPaths = map[string]PathFunc{ +var supportedPaths = map[string]osc.PathFunc{ "/system/config/hostname": func(path *gnmi.Path, val *gnmi.TypedValue) error { value, err := gnmiv.ToScalar(val) if err != nil { @@ -29,11 +30,14 @@ var supportedPaths = map[string]PathFunc{ } return nil }, + "/interfaces/interface/name": func(path *gnmi.Path, val *gnmi.TypedValue) error { + return nil + }, } type OsclientUbuntu struct { gt *gnmitargetygot.Gnmitarget - pm PathMap + pm osc.PathMap } func NewOsclientUbuntu() *OsclientUbuntu { @@ -51,19 +55,19 @@ func (ou OsclientUbuntu) UpdateConfig(config *ygot.ValidatedGoStruct) error { func (ou *OsclientUbuntu) GetConfig() *gnmitargetygot.Gnmitarget { ou.gt = &gnmitargetygot.Gnmitarget{} - // // Create Interfaces - // h, err := netlink.NewHandle() - // if err != nil { - // log.WithFields(log.Fields{}).Error(err) - // } - // //defer h.Delete() - // localIfaces, err := h.LinkList() - // if err != nil { - // log.WithFields(log.Fields{}).Error(err) - // } - // for _, localIface := range localIfaces { - // ou.createInterfaces(localIface, ou.gt) - // } + // Create Interfaces + h, err := netlink.NewHandle() + if err != nil { + log.WithFields(log.Fields{}).Error(err) + } + //defer h.Delete() + localIfaces, err := h.LinkList() + if err != nil { + log.WithFields(log.Fields{}).Error(err) + } + for _, localIface := range localIfaces { + ou.createInterfaces(localIface, ou.gt) + } ou.getSystem(ou.gt) diff --git a/os_clients/ubuntu/pathHandling.go b/os_clients/utils.go similarity index 96% rename from os_clients/ubuntu/pathHandling.go rename to os_clients/utils.go index 1f93774..01beeec 100644 --- a/os_clients/ubuntu/pathHandling.go +++ b/os_clients/utils.go @@ -1,4 +1,4 @@ -package ubuntu +package os_clients import ( "fmt" -- GitLab