VOL-3677 - move to v4 of protos and lib
Change-Id: Ie9d215f69b798dbf2b879d8e7d041c0d671f84c0
diff --git a/VERSION b/VERSION
index e515aee..f298681 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.15-dev147
+0.1.15-dev148
diff --git a/cmd/openonu-adapter/common.go b/cmd/openonu-adapter/common.go
index 7507288..9c871ef 100644
--- a/cmd/openonu-adapter/common.go
+++ b/cmd/openonu-adapter/common.go
@@ -18,15 +18,15 @@
package main
import (
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
)
-var logger log.Logger
+var logger log.CLogger
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "main"})
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "main"})
// previously log.DebugLevel was set !?
if err != nil {
panic(err)
diff --git a/cmd/openonu-adapter/main.go b/cmd/openonu-adapter/main.go
index df7c327..e82c155 100644
--- a/cmd/openonu-adapter/main.go
+++ b/cmd/openonu-adapter/main.go
@@ -28,17 +28,17 @@
"syscall"
"time"
- "github.com/opencord/voltha-lib-go/v3/pkg/adapters"
- "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
- com "github.com/opencord/voltha-lib-go/v3/pkg/adapters/common"
- conf "github.com/opencord/voltha-lib-go/v3/pkg/config"
- "github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
- "github.com/opencord/voltha-lib-go/v3/pkg/kafka"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- "github.com/opencord/voltha-lib-go/v3/pkg/probe"
- "github.com/opencord/voltha-lib-go/v3/pkg/version"
- ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- "github.com/opencord/voltha-protos/v3/go/voltha"
+ "github.com/opencord/voltha-lib-go/v4/pkg/adapters"
+ "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
+ com "github.com/opencord/voltha-lib-go/v4/pkg/adapters/common"
+ conf "github.com/opencord/voltha-lib-go/v4/pkg/config"
+ "github.com/opencord/voltha-lib-go/v4/pkg/db/kvstore"
+ "github.com/opencord/voltha-lib-go/v4/pkg/kafka"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
+ "github.com/opencord/voltha-lib-go/v4/pkg/probe"
+ "github.com/opencord/voltha-lib-go/v4/pkg/version"
+ ic "github.com/opencord/voltha-protos/v4/go/inter_container"
+ "github.com/opencord/voltha-protos/v4/go/voltha"
"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/config"
ac "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/onuadaptercore"
@@ -71,7 +71,7 @@
}
func (a *adapter) start(ctx context.Context) error {
- logger.Info("Starting Core Adapter components")
+ logger.Info(ctx, "Starting Core Adapter components")
var err error
var p *probe.Probe
@@ -79,6 +79,7 @@
if _, ok := value.(*probe.Probe); ok {
p = value.(*probe.Probe)
p.RegisterService(
+ ctx,
"message-bus",
"kv-store",
"container-proxy",
@@ -89,42 +90,42 @@
}
// Setup KV Client
- logger.Debugw("create-kv-client", log.Fields{"kvstore": a.config.KVStoreType})
- if err = a.setKVClient(); err != nil {
- logger.Fatalw("error-setting-kv-client", log.Fields{"error": err})
+ logger.Debugw(ctx, "create-kv-client", log.Fields{"kvstore": a.config.KVStoreType})
+ if err = a.setKVClient(ctx); err != nil {
+ logger.Fatalw(ctx, "error-setting-kv-client", log.Fields{"error": err})
}
if p != nil {
- p.UpdateStatus("kv-store", probe.ServiceStatusRunning)
+ p.UpdateStatus(ctx, "kv-store", probe.ServiceStatusRunning)
}
// Setup Log Config
/* address config update acc. to [VOL-2736] */
addr := a.config.KVStoreHost + ":" + strconv.Itoa(a.config.KVStorePort)
- cm := conf.NewConfigManager(a.kvClient, a.config.KVStoreType, addr, a.config.KVStoreTimeout)
+ cm := conf.NewConfigManager(ctx, a.kvClient, a.config.KVStoreType, addr, a.config.KVStoreTimeout)
go conf.StartLogLevelConfigProcessing(cm, ctx)
// Setup Kafka Client
- if a.kafkaClient, err = newKafkaClient("sarama", a.config.KafkaAdapterHost, a.config.KafkaAdapterPort); err != nil {
- logger.Fatalw("Unsupported-common-client", log.Fields{"error": err})
+ if a.kafkaClient, err = newKafkaClient(ctx, "sarama", a.config.KafkaAdapterHost, a.config.KafkaAdapterPort); err != nil {
+ logger.Fatalw(ctx, "Unsupported-common-client", log.Fields{"error": err})
}
if p != nil {
- p.UpdateStatus("message-bus", probe.ServiceStatusRunning)
+ p.UpdateStatus(ctx, "message-bus", probe.ServiceStatusRunning)
}
// Start the common InterContainer Proxy - retries as per program arguments or indefinitely per default
if a.kip, err = a.startInterContainerProxy(ctx, a.config.KafkaReconnectRetries); err != nil {
- logger.Fatalw("error-starting-inter-container-proxy", log.Fields{"error": err})
+ logger.Fatalw(ctx, "error-starting-inter-container-proxy", log.Fields{"error": err})
//aborting the complete processing here (does notmake sense after set Retry number [else use -1 for infinite])
return err
}
// Create the core proxy to handle requests to the Core
- a.coreProxy = com.NewCoreProxy(a.kip, a.config.Topic, a.config.CoreTopic)
+ a.coreProxy = com.NewCoreProxy(ctx, a.kip, a.config.Topic, a.config.CoreTopic)
- logger.Debugw("create adapter proxy", log.Fields{"OltTopic": a.config.OltTopic, "CoreTopic": a.config.CoreTopic})
- a.adapterProxy = com.NewAdapterProxy(a.kip, a.config.OltTopic, a.config.CoreTopic, cm.Backend)
+ logger.Debugw(ctx, "create adapter proxy", log.Fields{"OltTopic": a.config.OltTopic, "CoreTopic": a.config.CoreTopic})
+ a.adapterProxy = com.NewAdapterProxy(ctx, a.kip, a.config.CoreTopic, cm.Backend)
// Create the event proxy to post events to KAFKA
a.eventProxy = com.NewEventProxy(com.MsgClient(a.kafkaClient), com.MsgTopic(kafka.Topic{Name: a.config.EventTopic}))
@@ -132,17 +133,17 @@
// Create the open ONU interface adapter
if a.iAdapter, err = a.startVolthaInterfaceAdapter(ctx, a.kip, a.coreProxy, a.adapterProxy, a.eventProxy,
a.config, cm); err != nil {
- logger.Fatalw("error-starting-volthaInterfaceAdapter for OpenOnt", log.Fields{"error": err})
+ logger.Fatalw(ctx, "error-starting-volthaInterfaceAdapter for OpenOnt", log.Fields{"error": err})
}
// Register the core request handler
if err = a.setupRequestHandler(ctx, a.instanceID, a.iAdapter); err != nil {
- logger.Fatalw("error-setting-core-request-handler", log.Fields{"error": err})
+ logger.Fatalw(ctx, "error-setting-core-request-handler", log.Fields{"error": err})
}
// Register this adapter to the Core - retries indefinitely
if err = a.registerWithCore(ctx, -1); err != nil {
- logger.Fatalw("error-registering-with-core", log.Fields{"error": err})
+ logger.Fatalw(ctx, "error-registering-with-core", log.Fields{"error": err})
}
// check the readiness and liveliness and update the probe status
@@ -161,34 +162,34 @@
if a.kvClient != nil {
// Release all reservations
if err := a.kvClient.ReleaseAllReservations(ctx); err != nil {
- logger.Infow("fail-to-release-all-reservations", log.Fields{"error": err})
+ logger.Infow(ctx, "fail-to-release-all-reservations", log.Fields{"error": err})
}
// Close the DB connection
- a.kvClient.Close()
+ a.kvClient.Close(ctx)
}
if a.kip != nil {
- a.kip.Stop()
+ a.kip.Stop(ctx)
}
}
// #############################################
// Adapter Utility methods ##### begin #########
-func newKVClient(storeType, address string, timeout time.Duration) (kvstore.Client, error) {
- logger.Infow("kv-store-type", log.Fields{"store": storeType})
+func newKVClient(ctx context.Context, storeType, address string, timeout time.Duration) (kvstore.Client, error) {
+ logger.Infow(ctx, "kv-store-type", log.Fields{"store": storeType})
switch storeType {
case "consul":
- return kvstore.NewConsulClient(address, timeout)
+ return kvstore.NewConsulClient(ctx, address, timeout)
case "etcd":
- return kvstore.NewEtcdClient(address, timeout, log.FatalLevel)
+ return kvstore.NewEtcdClient(ctx, address, timeout, log.FatalLevel)
}
return nil, errors.New("unsupported-kv-store")
}
-func newKafkaClient(clientType, host string, port int) (kafka.Client, error) {
+func newKafkaClient(ctx context.Context, clientType, host string, port int) (kafka.Client, error) {
- logger.Infow("common-client-type", log.Fields{"client": clientType})
+ logger.Infow(ctx, "common-client-type", log.Fields{"client": clientType})
/* address config update acc. to [VOL-2736] */
addr := host + ":" + strconv.Itoa(port)
@@ -206,12 +207,12 @@
return nil, errors.New("unsupported-client-type")
}
-func (a *adapter) setKVClient() error {
+func (a *adapter) setKVClient(ctx context.Context) error {
addr := a.config.KVStoreHost + ":" + strconv.Itoa(a.config.KVStorePort)
- client, err := newKVClient(a.config.KVStoreType, addr, a.config.KVStoreTimeout)
+ client, err := newKVClient(ctx, a.config.KVStoreType, addr, a.config.KVStoreTimeout)
if err != nil {
a.kvClient = nil
- logger.Errorw("error-starting-KVClient", log.Fields{"error": err})
+ logger.Errorw(ctx, "error-starting-KVClient", log.Fields{"error": err})
return err
}
a.kvClient = client
@@ -219,7 +220,7 @@
}
func (a *adapter) startInterContainerProxy(ctx context.Context, retries int) (kafka.InterContainerProxy, error) {
- logger.Infow("starting-intercontainer-messaging-proxy", log.Fields{"host": a.config.KafkaAdapterHost,
+ logger.Infow(ctx, "starting-intercontainer-messaging-proxy", log.Fields{"host": a.config.KafkaAdapterHost,
"port": a.config.KafkaAdapterPort, "topic": a.config.Topic})
var err error
/* address config update acc. to [VOL-2736] */
@@ -230,8 +231,8 @@
kafka.DefaultTopic(&kafka.Topic{Name: a.config.Topic}))
count := 0
for {
- if err = kip.Start(); err != nil {
- logger.Warnw("error-starting-messaging-proxy", log.Fields{"error": err, "retry": retries, "count": count})
+ if err = kip.Start(ctx); err != nil {
+ logger.Warnw(ctx, "error-starting-messaging-proxy", log.Fields{"error": err, "retry": retries, "count": count})
if retries == count {
return nil, err
}
@@ -243,7 +244,7 @@
}
}
probe.UpdateStatusFromContext(ctx, "container-proxy", probe.ServiceStatusRunning)
- logger.Info("common-messaging-proxy-created")
+ logger.Info(ctx, "common-messaging-proxy-created")
return kip, nil
}
@@ -254,30 +255,30 @@
sAcONU := ac.NewOpenONUAC(ctx, a.kip, cp, ap, ep, a.kvClient, cfg, cm)
if err = sAcONU.Start(ctx); err != nil {
- logger.Fatalw("error-starting-OpenOnuAdapterCore", log.Fields{"error": err})
+ logger.Fatalw(ctx, "error-starting-OpenOnuAdapterCore", log.Fields{"error": err})
return nil, err
}
- logger.Info("open-ont-OpenOnuAdapterCore-started")
+ logger.Info(ctx, "open-ont-OpenOnuAdapterCore-started")
return sAcONU, nil
}
func (a *adapter) setupRequestHandler(ctx context.Context, coreInstanceID string, iadapter adapters.IAdapter) error {
- logger.Info("setting-request-handler")
+ logger.Info(ctx, "setting-request-handler")
requestProxy := com.NewRequestHandlerProxy(coreInstanceID, iadapter, a.coreProxy)
- if err := a.kip.SubscribeWithRequestHandlerInterface(kafka.Topic{Name: a.config.Topic}, requestProxy); err != nil {
- logger.Errorw("request-handler-setup-failed", log.Fields{"error": err})
+ if err := a.kip.SubscribeWithRequestHandlerInterface(ctx, kafka.Topic{Name: a.config.Topic}, requestProxy); err != nil {
+ logger.Errorw(ctx, "request-handler-setup-failed", log.Fields{"error": err})
return err
}
probe.UpdateStatusFromContext(ctx, "core-request-handler", probe.ServiceStatusRunning)
- logger.Info("request-handler-setup-done")
+ logger.Info(ctx, "request-handler-setup-done")
return nil
}
func (a *adapter) registerWithCore(ctx context.Context, retries int) error {
adapterID := fmt.Sprintf("brcm_openomci_onu_%d", a.config.CurrentReplica)
- logger.Infow("registering-with-core", log.Fields{
+ logger.Infow(ctx, "registering-with-core", log.Fields{
"adapterID": adapterID,
"currentReplica": a.config.CurrentReplica,
"totalReplicas": a.config.TotalReplicas,
@@ -302,7 +303,7 @@
count := 0
for {
if err := a.coreProxy.RegisterAdapter(context.TODO(), adapterDescription, deviceTypes); err != nil {
- logger.Warnw("registering-with-core-failed", log.Fields{"error": err})
+ logger.Warnw(ctx, "registering-with-core-failed", log.Fields{"error": err})
if retries == count {
return err
}
@@ -314,7 +315,7 @@
}
}
probe.UpdateStatusFromContext(ctx, "register-with-core", probe.ServiceStatusRunning)
- logger.Info("registered-with-core")
+ logger.Info(ctx, "registered-with-core")
return nil
}
@@ -360,7 +361,7 @@
}
case <-timeoutTimer.C:
// Check the status of the kv-store
- logger.Info("kv-store liveliness-recheck")
+ logger.Info(ctx, "kv-store liveliness-recheck")
if a.kvClient.IsConnectionUp(ctx) {
kvStoreChannel <- true
} else {
@@ -375,8 +376,8 @@
and update the status in the probe.
*/
func (a *adapter) checkKafkaReadiness(ctx context.Context) {
- livelinessChannel := a.kafkaClient.EnableLivenessChannel(true)
- healthinessChannel := a.kafkaClient.EnableHealthinessChannel(true)
+ livelinessChannel := a.kafkaClient.EnableLivenessChannel(ctx, true)
+ healthinessChannel := a.kafkaClient.EnableHealthinessChannel(ctx, true)
timeout := a.config.LiveProbeInterval
for {
timeoutTimer := time.NewTimer(timeout)
@@ -385,7 +386,7 @@
case healthiness := <-healthinessChannel:
if !healthiness {
// logger.Fatal will call os.Exit(1) to terminate
- logger.Fatal("Kafka service has become unhealthy")
+ logger.Fatal(ctx, "Kafka service has become unhealthy")
}
case liveliness := <-livelinessChannel:
if !liveliness {
@@ -402,13 +403,13 @@
<-timeoutTimer.C
}
case <-timeoutTimer.C:
- logger.Info("kafka-proxy-liveness-recheck")
+ logger.Info(ctx, "kafka-proxy-liveness-recheck")
// send the liveness probe in a goroutine; we don't want to deadlock ourselves as
// the liveness probe may wait (and block) writing to our channel.
- err := a.kafkaClient.SendLiveness()
+ err := a.kafkaClient.SendLiveness(ctx)
if err != nil {
// Catch possible error case if sending liveness after Sarama has been stopped.
- logger.Warnw("error-kafka-send-liveness", log.Fields{"error": err})
+ logger.Warnw(ctx, "error-kafka-send-liveness", log.Fields{"error": err})
}
}
}
@@ -417,13 +418,13 @@
// Adapter Utility methods ##### end #########
// #############################################
-func getVerifiedCodeVersion() string {
+func getVerifiedCodeVersion(ctx context.Context) string {
if version.VersionInfo.Version == "unknown-version" {
content, err := ioutil.ReadFile("VERSION")
if err == nil {
return (string(content))
}
- logger.Error("'VERSION'-file not readable")
+ logger.Error(ctx, "'VERSION'-file not readable")
}
return version.VersionInfo.Version
}
@@ -458,7 +459,7 @@
go func() {
select {
case <-ctx.Done():
- logger.Infow("Adapter run aborted due to internal errors", log.Fields{"context": "done"})
+ logger.Infow(ctx, "Adapter run aborted due to internal errors", log.Fields{"context": "done"})
exitChannel <- 2
case s := <-signalChannel:
switch s {
@@ -466,10 +467,10 @@
syscall.SIGINT,
syscall.SIGTERM,
syscall.SIGQUIT:
- logger.Infow("closing-signal-received", log.Fields{"signal": s})
+ logger.Infow(ctx, "closing-signal-received", log.Fields{"signal": s})
exitChannel <- 0
default:
- logger.Infow("unexpected-signal-received", log.Fields{"signal": s})
+ logger.Infow(ctx, "unexpected-signal-received", log.Fields{"signal": s})
exitChannel <- 1
}
}
@@ -481,31 +482,33 @@
func main() {
start := time.Now()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
cf := config.NewAdapterFlags()
- defaultAppName := cf.InstanceID + "_" + getVerifiedCodeVersion()
+ defaultAppName := cf.InstanceID + "_" + getVerifiedCodeVersion(ctx)
cf.ParseCommandArguments()
// Setup logging
logLevel, err := log.StringToLogLevel(cf.LogLevel)
if err != nil {
- logger.Fatalf("Cannot setup logging, %s", err)
+ logger.Fatalf(ctx, "Cannot setup logging, %s", err)
}
// Setup default logger - applies for packages that do not have specific logger set
if _, err := log.SetDefaultLogger(log.JSON, logLevel, log.Fields{"instanceId": cf.InstanceID}); err != nil {
- log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
+ logger.With(log.Fields{"error": err}).Fatal(ctx, "Cannot setup logging")
}
// Update all loggers (provisioned via init) with a common field
if err := log.UpdateAllLoggers(log.Fields{"instanceId": cf.InstanceID}); err != nil {
- logger.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
+ logger.With(log.Fields{"error": err}).Fatal(ctx, "Cannot setup logging")
}
log.SetAllLogLevel(logLevel)
- realMain() //fatal on httpListen(0,6060) ...
+ realMain(ctx) //fatal on httpListen(0,6060) ...
defer func() {
_ = log.CleanUp()
@@ -515,30 +518,34 @@
printVersion(defaultAppName)
return
}
- logger.Infow("config", log.Fields{"StartName": defaultAppName})
- logger.Infow("config", log.Fields{"BuildVersion": version.VersionInfo.String(" ")})
- logger.Infow("config", log.Fields{"Arguments": os.Args[1:]})
+ logger.Infow(ctx, "config", log.Fields{"StartName": defaultAppName})
+ logger.Infow(ctx, "config", log.Fields{"BuildVersion": version.VersionInfo.String(" ")})
+ logger.Infow(ctx, "config", log.Fields{"Arguments": os.Args[1:]})
// Print banner if specified
if cf.Banner {
printBanner()
}
- logger.Infow("config", log.Fields{"config": *cf})
-
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ logger.Infow(ctx, "config", log.Fields{"config": *cf})
ad := newAdapter(cf)
p := &probe.Probe{}
- logger.Infow("resources", log.Fields{"Context": ctx, "Adapter": ad.instanceID, "ProbeCoreState": p.GetStatus("register-with-core")})
+ logger.Infow(ctx, "resources", log.Fields{"Context": ctx, "Adapter": ad.instanceID, "ProbeCoreState": p.GetStatus("register-with-core")})
- go p.ListenAndServe(fmt.Sprintf("%s:%d", ad.config.ProbeHost, ad.config.ProbePort))
- logger.Infow("probeState", log.Fields{"ProbeCoreState": p.GetStatus("register-with-core")})
+ go p.ListenAndServe(ctx, fmt.Sprintf("%s:%d", ad.config.ProbeHost, ad.config.ProbePort))
+ logger.Infow(ctx, "probeState", log.Fields{"ProbeCoreState": p.GetStatus("register-with-core")})
probeCtx := context.WithValue(ctx, probe.ProbeContextKey, p)
+ closer, err := log.GetGlobalLFM().InitTracingAndLogCorrelation(cf.TraceEnabled, cf.TraceAgentAddress, cf.LogCorrelationEnabled)
+ if err != nil {
+ logger.Warnw(ctx, "unable-to-initialize-tracing-and-log-correlation-module", log.Fields{"error": err})
+ } else {
+ defer log.TerminateTracing(closer)
+ }
+
go func() {
err := ad.start(probeCtx)
// If this operation returns an error
@@ -549,12 +556,12 @@
}()
code := waitForExit(ctx)
- logger.Infow("received-a-closing-signal", log.Fields{"code": code})
+ logger.Infow(ctx, "received-a-closing-signal", log.Fields{"code": code})
// Cleanup before leaving
ad.stop(ctx)
elapsed := time.Since(start)
- logger.Infow("run-time", log.Fields{"Name": "openadapter", "time": elapsed / time.Microsecond})
- //logger.Infow("run-time", log.Fields{"instanceId": ad.config.InstanceID, "time": elapsed / time.Second})
+ logger.Infow(ctx, "run-time", log.Fields{"Name": "openadapter", "time": elapsed / time.Microsecond})
+ //logger.Infow(ctx,"run-time", log.Fields{"instanceId": ad.config.InstanceID, "time": elapsed / time.Second})
}
diff --git a/cmd/openonu-adapter/release.go b/cmd/openonu-adapter/release.go
index a8fb220..50a286f 100644
--- a/cmd/openonu-adapter/release.go
+++ b/cmd/openonu-adapter/release.go
@@ -19,6 +19,8 @@
//Package main invokes the application
package main
-func realMain() {
- logger.Infoln("NOT PROFILING")
+import "context"
+
+func realMain(ctx context.Context) {
+ logger.Infoln(ctx, "NOT PROFILING")
}
diff --git a/go.mod b/go.mod
index 2a56590..b0c5584 100644
--- a/go.mod
+++ b/go.mod
@@ -9,8 +9,8 @@
github.com/google/gopacket v1.1.17
github.com/looplab/fsm v0.1.0
github.com/opencord/omci-lib-go v0.13.4
- github.com/opencord/voltha-lib-go/v3 v3.1.23
- github.com/opencord/voltha-protos/v3 v3.3.9
+ github.com/opencord/voltha-lib-go/v4 v4.0.3
+ github.com/opencord/voltha-protos/v4 v4.0.5
github.com/stretchr/testify v1.6.1
google.golang.org/grpc v1.25.1 // indirect
)
diff --git a/go.sum b/go.sum
index ca7f92e..9c118f6 100644
--- a/go.sum
+++ b/go.sum
@@ -219,10 +219,11 @@
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/opencord/omci-lib-go v0.13.4 h1:L3GpFHrx3DASixkCvztnJbcLGUTU/21wJYdE/qG9/XA=
github.com/opencord/omci-lib-go v0.13.4/go.mod h1:6OIHB14Ch5qGgHzwSWlMACtk5KFoLzQ4LAhdcy4jwvo=
-github.com/opencord/voltha-lib-go/v3 v3.1.23 h1:cbrg+QmIXR3fQHSlo5+QokmSDkFdU7fTYmwxCU5QprY=
-github.com/opencord/voltha-lib-go/v3 v3.1.23/go.mod h1:sa508HZ5vlOauh0i+WC0XFX1JZnfHtJqNIms5XBT/Z0=
-github.com/opencord/voltha-protos/v3 v3.3.9 h1:BnfDN9oaRBgyAiH9ZN7LpBpEJYxjX/ZS7R4OT2hDrtY=
-github.com/opencord/voltha-protos/v3 v3.3.9/go.mod h1:nl1ETp5Iw3avxOaKD8BJlYY5wYI4KeV95aT1pL63nto=
+github.com/opencord/voltha-lib-go/v4 v4.0.3 h1:bOb6T+8EsO37MPgU7i3pF81Yj2fUU43rFwv1hQsUVis=
+github.com/opencord/voltha-lib-go/v4 v4.0.3/go.mod h1:QgdIa7PlU0jhZT3qCPtcVt8/CpingKm4dUEROBrUBZg=
+github.com/opencord/voltha-protos/v4 v4.0.2/go.mod h1:W/OIFIyvFh/C0vchRUuarIsMylEhzCRM9pNxLvkPtKc=
+github.com/opencord/voltha-protos/v4 v4.0.5 h1:aOCk7SbIZhM8uHtsqAEADvO3l0xQgDPytoKZKb5Y4Zg=
+github.com/opencord/voltha-protos/v4 v4.0.5/go.mod h1:W/OIFIyvFh/C0vchRUuarIsMylEhzCRM9pNxLvkPtKc=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
@@ -278,7 +279,6 @@
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
-github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@@ -310,7 +310,6 @@
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
-golang.org/x/crypto v0.0.0-20191001170739-f9e2070545dc h1:KyTYo8xkh/2WdbFLUyQwBS0Jfn3qfZ9QmuPbok2oENE=
golang.org/x/crypto v0.0.0-20191001170739-f9e2070545dc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw=
@@ -333,7 +332,6 @@
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3 h1:6KET3Sqa7fkVfD63QnAM81ZeYg5n4HwApOJkufONnHA=
golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0 h1:MsuvTghUPjX762sGLnGsxC3HM0B5r83wEtYcYR8/vRs=
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -356,7 +354,6 @@
golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24 h1:R8bzl0244nw47n1xKs1MUMAaTNgjavKcN/aX2Ss3+Fo=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
index 5bec526..6c2283d 100644
--- a/internal/pkg/config/config.go
+++ b/internal/pkg/config/config.go
@@ -58,6 +58,11 @@
defaultCurrentReplica = 1
defaultTotalReplicas = 1
defaultMaxTimeoutInterAdapterComm = 30 * time.Second
+
+ // For Tracing
+ defaultTraceEnabled = false
+ defaultTraceAgentAddress = "127.0.0.1:6831"
+ defaultLogCorrelationEnabled = true
)
// AdapterFlags represents the set of configurations used by the read-write adaptercore service
@@ -91,6 +96,9 @@
CurrentReplica int
TotalReplicas int
MaxTimeoutInterAdapterComm time.Duration
+ TraceEnabled bool
+ TraceAgentAddress string
+ LogCorrelationEnabled bool
}
// NewAdapterFlags returns a new RWCore config
@@ -124,6 +132,9 @@
CurrentReplica: defaultCurrentReplica,
TotalReplicas: defaultTotalReplicas,
MaxTimeoutInterAdapterComm: defaultMaxTimeoutInterAdapterComm,
+ TraceEnabled: defaultTraceEnabled,
+ TraceAgentAddress: defaultTraceAgentAddress,
+ LogCorrelationEnabled: defaultLogCorrelationEnabled,
}
return &adapterFlags
}
@@ -213,6 +224,15 @@
flag.DurationVar(&(so.MaxTimeoutInterAdapterComm), "max_timeout_interadapter_comm",
defaultMaxTimeoutInterAdapterComm, help)
+ help = fmt.Sprintf("Whether to send logs to tracing agent?")
+ flag.BoolVar(&(so.TraceEnabled), "trace_enabled", defaultTraceEnabled, help)
+
+ help = fmt.Sprintf("The address of tracing agent to which span info should be sent.")
+ flag.StringVar(&(so.TraceAgentAddress), "trace_agent_address", defaultTraceAgentAddress, help)
+
+ help = fmt.Sprintf("Whether to enrich log statements with fields denoting operation being executed for achieving correlation?")
+ flag.BoolVar(&(so.LogCorrelationEnabled), "log_correlation_enabled", defaultLogCorrelationEnabled, help)
+
flag.Parse()
containerName := getContainerInfo()
if len(containerName) > 0 {
diff --git a/internal/pkg/onuadaptercore/common.go b/internal/pkg/onuadaptercore/common.go
index f4d7e06..e011f04 100644
--- a/internal/pkg/onuadaptercore/common.go
+++ b/internal/pkg/onuadaptercore/common.go
@@ -18,15 +18,15 @@
package adaptercoreonu
import (
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
)
-var logger log.Logger
+var logger log.CLogger
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "adaptercoreonu"})
if err != nil {
panic(err)
}
diff --git a/internal/pkg/onuadaptercore/device_handler.go b/internal/pkg/onuadaptercore/device_handler.go
index 8349d51..9e02ed0 100644
--- a/internal/pkg/onuadaptercore/device_handler.go
+++ b/internal/pkg/onuadaptercore/device_handler.go
@@ -30,17 +30,17 @@
"github.com/golang/protobuf/ptypes"
"github.com/looplab/fsm"
me "github.com/opencord/omci-lib-go/generated"
- "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
- "github.com/opencord/voltha-lib-go/v3/pkg/db"
- flow "github.com/opencord/voltha-lib-go/v3/pkg/flows"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- vc "github.com/opencord/voltha-protos/v3/go/common"
- ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- "github.com/opencord/voltha-protos/v3/go/openflow_13"
- of "github.com/opencord/voltha-protos/v3/go/openflow_13"
- ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
- oop "github.com/opencord/voltha-protos/v3/go/openolt"
- "github.com/opencord/voltha-protos/v3/go/voltha"
+ "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
+ "github.com/opencord/voltha-lib-go/v4/pkg/db"
+ flow "github.com/opencord/voltha-lib-go/v4/pkg/flows"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
+ vc "github.com/opencord/voltha-protos/v4/go/common"
+ ic "github.com/opencord/voltha-protos/v4/go/inter_container"
+ "github.com/opencord/voltha-protos/v4/go/openflow_13"
+ of "github.com/opencord/voltha-protos/v4/go/openflow_13"
+ ofp "github.com/opencord/voltha-protos/v4/go/openflow_13"
+ oop "github.com/opencord/voltha-protos/v4/go/openolt"
+ "github.com/opencord/voltha-protos/v4/go/voltha"
)
/*
@@ -170,7 +170,7 @@
}
//newDeviceHandler creates a new device handler
-func newDeviceHandler(cp adapterif.CoreProxy, ap adapterif.AdapterProxy, ep adapterif.EventProxy, device *voltha.Device, adapter *OpenONUAC) *deviceHandler {
+func newDeviceHandler(ctx context.Context, cp adapterif.CoreProxy, ap adapterif.AdapterProxy, ep adapterif.EventProxy, device *voltha.Device, adapter *OpenONUAC) *deviceHandler {
var dh deviceHandler
dh.coreProxy = cp
dh.AdapterProxy = ap
@@ -205,14 +205,14 @@
{Name: devEvDeviceDownInd, Src: []string{devStUp}, Dst: devStDown},
},
fsm.Callbacks{
- "before_event": func(e *fsm.Event) { dh.logStateChange(e) },
- ("before_" + devEvDeviceInit): func(e *fsm.Event) { dh.doStateInit(e) },
- ("after_" + devEvDeviceInit): func(e *fsm.Event) { dh.postInit(e) },
- ("before_" + devEvGrpcConnected): func(e *fsm.Event) { dh.doStateConnected(e) },
- ("before_" + devEvGrpcDisconnected): func(e *fsm.Event) { dh.doStateInit(e) },
- ("after_" + devEvGrpcDisconnected): func(e *fsm.Event) { dh.postInit(e) },
- ("before_" + devEvDeviceUpInd): func(e *fsm.Event) { dh.doStateUp(e) },
- ("before_" + devEvDeviceDownInd): func(e *fsm.Event) { dh.doStateDown(e) },
+ "before_event": func(e *fsm.Event) { dh.logStateChange(ctx, e) },
+ ("before_" + devEvDeviceInit): func(e *fsm.Event) { dh.doStateInit(ctx, e) },
+ ("after_" + devEvDeviceInit): func(e *fsm.Event) { dh.postInit(ctx, e) },
+ ("before_" + devEvGrpcConnected): func(e *fsm.Event) { dh.doStateConnected(ctx, e) },
+ ("before_" + devEvGrpcDisconnected): func(e *fsm.Event) { dh.doStateInit(ctx, e) },
+ ("after_" + devEvGrpcDisconnected): func(e *fsm.Event) { dh.postInit(ctx, e) },
+ ("before_" + devEvDeviceUpInd): func(e *fsm.Event) { dh.doStateUp(ctx, e) },
+ ("before_" + devEvDeviceDownInd): func(e *fsm.Event) { dh.doStateDown(ctx, e) },
},
)
@@ -221,9 +221,9 @@
// start save the device to the data model
func (dh *deviceHandler) start(ctx context.Context) {
- logger.Debugw("starting-device-handler", log.Fields{"device": dh.device, "device-id": dh.deviceID})
+ logger.Debugw(ctx, "starting-device-handler", log.Fields{"device": dh.device, "device-id": dh.deviceID})
// Add the initial device to the local model
- logger.Debug("device-handler-started")
+ logger.Debug(ctx, "device-handler-started")
}
/*
@@ -239,63 +239,64 @@
//adoptOrReconcileDevice adopts the OLT device
func (dh *deviceHandler) adoptOrReconcileDevice(ctx context.Context, device *voltha.Device) {
- logger.Debugw("Adopt_or_reconcile_device", log.Fields{"device-id": device.Id, "Address": device.GetHostAndPort()})
+ logger.Debugw(ctx, "Adopt_or_reconcile_device", log.Fields{"device-id": device.Id, "Address": device.GetHostAndPort()})
- logger.Debugw("Device FSM: ", log.Fields{"state": string(dh.pDeviceStateFsm.Current())})
+ logger.Debugw(ctx, "Device FSM: ", log.Fields{"state": string(dh.pDeviceStateFsm.Current())})
if dh.pDeviceStateFsm.Is(devStNull) {
if err := dh.pDeviceStateFsm.Event(devEvDeviceInit); err != nil {
- logger.Errorw("Device FSM: Can't go to state DeviceInit", log.Fields{"err": err})
+ logger.Errorw(ctx, "Device FSM: Can't go to state DeviceInit", log.Fields{"err": err})
}
- logger.Debugw("Device FSM: ", log.Fields{"state": string(dh.pDeviceStateFsm.Current())})
+ logger.Debugw(ctx, "Device FSM: ", log.Fields{"state": string(dh.pDeviceStateFsm.Current())})
} else {
- logger.Debugw("AdoptOrReconcileDevice: Agent/device init already done", log.Fields{"device-id": device.Id})
+ logger.Debugw(ctx, "AdoptOrReconcileDevice: Agent/device init already done", log.Fields{"device-id": device.Id})
}
}
-func (dh *deviceHandler) processInterAdapterOMCIReqMessage(msg *ic.InterAdapterMessage) error {
+func (dh *deviceHandler) processInterAdapterOMCIReqMessage(ctx context.Context, msg *ic.InterAdapterMessage) error {
msgBody := msg.GetBody()
omciMsg := &ic.InterAdapterOmciMessage{}
if err := ptypes.UnmarshalAny(msgBody, omciMsg); err != nil {
- logger.Warnw("cannot-unmarshal-omci-msg-body", log.Fields{
+ logger.Warnw(ctx, "cannot-unmarshal-omci-msg-body", log.Fields{
"device-id": dh.deviceID, "error": err})
return err
}
//assuming omci message content is hex coded!
// with restricted output of 16(?) bytes would be ...omciMsg.Message[:16]
- logger.Debugw("inter-adapter-recv-omci", log.Fields{
+ logger.Debugw(ctx, "inter-adapter-recv-omci", log.Fields{
"device-id": dh.deviceID, "RxOmciMessage": hex.EncodeToString(omciMsg.Message)})
//receive_message(omci_msg.message)
- pDevEntry := dh.getOnuDeviceEntry(true)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, true)
if pDevEntry != nil {
if pDevEntry.PDevOmciCC != nil {
- return pDevEntry.PDevOmciCC.receiveMessage(context.TODO(), omciMsg.Message)
+ return pDevEntry.PDevOmciCC.receiveMessage(log.WithSpanFromContext(context.TODO(), ctx), omciMsg.Message)
}
- logger.Debugw("omciCC not ready to receive omci messages - incoming omci message ignored", log.Fields{"rxMsg": omciMsg.Message})
+ logger.Debugw(ctx, "omciCC not ready to receive omci messages - incoming omci message ignored", log.Fields{"rxMsg": omciMsg.Message})
}
- logger.Errorw("No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
}
func (dh *deviceHandler) processInterAdapterTechProfileDownloadReqMessage(
+ ctx context.Context,
msg *ic.InterAdapterMessage) error {
- logger.Infow("tech-profile-download-request", log.Fields{"device-id": dh.deviceID})
+ logger.Infow(ctx, "tech-profile-download-request", log.Fields{"device-id": dh.deviceID})
- pDevEntry := dh.getOnuDeviceEntry(true)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
}
if dh.pOnuTP == nil {
//should normally not happen ...
- logger.Errorw("onuTechProf instance not set up for DLMsg request - ignoring request",
+ logger.Errorw(ctx, "onuTechProf instance not set up for DLMsg request - ignoring request",
log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("techProfile DLMsg request while onuTechProf instance not setup: %s", dh.deviceID)
}
if !dh.ReadyForSpecificOmciConfig {
- logger.Errorw("TechProf-set rejected: improper device state", log.Fields{"device-id": dh.deviceID,
+ logger.Errorw(ctx, "TechProf-set rejected: improper device state", log.Fields{"device-id": dh.deviceID,
"device-state": deviceReasonMap[dh.deviceReason]})
return fmt.Errorf("improper device state %s on device %s", deviceReasonMap[dh.deviceReason], dh.deviceID)
}
@@ -306,7 +307,7 @@
msgBody := msg.GetBody()
techProfMsg := &ic.InterAdapterTechProfileDownloadMessage{}
if err := ptypes.UnmarshalAny(msgBody, techProfMsg); err != nil {
- logger.Warnw("cannot-unmarshal-techprof-msg-body", log.Fields{
+ logger.Warnw(ctx, "cannot-unmarshal-techprof-msg-body", log.Fields{
"device-id": dh.deviceID, "error": err})
return err
}
@@ -326,11 +327,11 @@
uniID := uint8(techProfMsg.UniId)
tpID, err := GetTpIDFromTpPath(techProfMsg.Path)
if err != nil {
- logger.Errorw("error-parsing-tpid-from-tppath", log.Fields{"err": err, "tp-path": techProfMsg.Path})
+ logger.Errorw(ctx, "error-parsing-tpid-from-tppath", log.Fields{"err": err, "tp-path": techProfMsg.Path})
return err
}
- if bTpModify := pDevEntry.updateOnuUniTpPath(uniID, uint8(tpID), techProfMsg.Path); bTpModify {
+ if bTpModify := pDevEntry.updateOnuUniTpPath(ctx, uniID, uint8(tpID), techProfMsg.Path); bTpModify {
// if there has been some change for some uni TechProfilePath
//in order to allow concurrent calls to other dh instances we do not wait for execution here
//but doing so we can not indicate problems to the caller (who does what with that then?)
@@ -349,9 +350,9 @@
var wg sync.WaitGroup
wg.Add(2) // for the 2 go routines to finish
// attention: deadline completion check and wg.Done is to be done in both routines
- go dh.pOnuTP.configureUniTp(dctx, uniID, techProfMsg.Path, &wg)
- go pDevEntry.updateOnuKvStore(dctx, &wg)
- dh.waitForCompletion(cancel, &wg, "TechProfDwld") //wait for background process to finish
+ go dh.pOnuTP.configureUniTp(log.WithSpanFromContext(dctx, ctx), uniID, techProfMsg.Path, &wg)
+ go pDevEntry.updateOnuKvStore(log.WithSpanFromContext(dctx, ctx), &wg)
+ dh.waitForCompletion(ctx, cancel, &wg, "TechProfDwld") //wait for background process to finish
return dh.combineErrorStrings(dh.pOnuTP.getTpProcessingErrorIndication(uniID, tpID), pDevEntry.getKvProcessingErrorIndication())
}
@@ -360,18 +361,19 @@
}
func (dh *deviceHandler) processInterAdapterDeleteGemPortReqMessage(
+ ctx context.Context,
msg *ic.InterAdapterMessage) error {
- logger.Infow("delete-gem-port-request", log.Fields{"device-id": dh.deviceID})
+ logger.Infow(ctx, "delete-gem-port-request", log.Fields{"device-id": dh.deviceID})
- pDevEntry := dh.getOnuDeviceEntry(true)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
}
if dh.pOnuTP == nil {
//should normally not happen ...
- logger.Warnw("onuTechProf instance not set up for DelGem request - ignoring request",
+ logger.Warnw(ctx, "onuTechProf instance not set up for DelGem request - ignoring request",
log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("techProfile DelGem request while onuTechProf instance not setup: %s", dh.deviceID)
}
@@ -379,7 +381,7 @@
msgBody := msg.GetBody()
delGemPortMsg := &ic.InterAdapterDeleteGemPortMessage{}
if err := ptypes.UnmarshalAny(msgBody, delGemPortMsg); err != nil {
- logger.Warnw("cannot-unmarshal-delete-gem-msg-body", log.Fields{
+ logger.Warnw(ctx, "cannot-unmarshal-delete-gem-msg-body", log.Fields{
"device-id": dh.deviceID, "error": err})
return err
}
@@ -397,7 +399,7 @@
uniID := uint8(delGemPortMsg.UniId)
tpID, err := GetTpIDFromTpPath(delGemPortMsg.TpPath)
if err != nil {
- logger.Errorw("error-extracting-tp-id-from-tp-path", log.Fields{"err": err, "tp-path": delGemPortMsg.TpPath})
+ logger.Errorw(ctx, "error-extracting-tp-id-from-tp-path", log.Fields{"err": err, "tp-path": delGemPortMsg.TpPath})
return err
}
@@ -411,26 +413,27 @@
var wg sync.WaitGroup
wg.Add(1) // for the 1 go routine to finish
- go dh.pOnuTP.deleteTpResource(dctx, uniID, tpID, delGemPortMsg.TpPath,
+ go dh.pOnuTP.deleteTpResource(log.WithSpanFromContext(dctx, ctx), uniID, tpID, delGemPortMsg.TpPath,
cResourceGemPort, delGemPortMsg.GemPortId, &wg)
- dh.waitForCompletion(cancel, &wg, "GemDelete") //wait for background process to finish
+ dh.waitForCompletion(ctx, cancel, &wg, "GemDelete") //wait for background process to finish
return dh.pOnuTP.getTpProcessingErrorIndication(uniID, tpID)
}
func (dh *deviceHandler) processInterAdapterDeleteTcontReqMessage(
+ ctx context.Context,
msg *ic.InterAdapterMessage) error {
- logger.Infow("delete-tcont-request", log.Fields{"device-id": dh.deviceID})
+ logger.Infow(ctx, "delete-tcont-request", log.Fields{"device-id": dh.deviceID})
- pDevEntry := dh.getOnuDeviceEntry(true)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
}
if dh.pOnuTP == nil {
//should normally not happen ...
- logger.Warnw("onuTechProf instance not set up for DelTcont request - ignoring request",
+ logger.Warnw(ctx, "onuTechProf instance not set up for DelTcont request - ignoring request",
log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("techProfile DelTcont request while onuTechProf instance not setup: %s", dh.deviceID)
}
@@ -438,7 +441,7 @@
msgBody := msg.GetBody()
delTcontMsg := &ic.InterAdapterDeleteTcontMessage{}
if err := ptypes.UnmarshalAny(msgBody, delTcontMsg); err != nil {
- logger.Warnw("cannot-unmarshal-delete-tcont-msg-body", log.Fields{
+ logger.Warnw(ctx, "cannot-unmarshal-delete-tcont-msg-body", log.Fields{
"device-id": dh.deviceID, "error": err})
return err
}
@@ -457,11 +460,11 @@
tpPath := delTcontMsg.TpPath
tpID, err := GetTpIDFromTpPath(tpPath)
if err != nil {
- logger.Errorw("error-extracting-tp-id-from-tp-path", log.Fields{"err": err, "tp-path": tpPath})
+ logger.Errorw(ctx, "error-extracting-tp-id-from-tp-path", log.Fields{"err": err, "tp-path": tpPath})
return err
}
- if bTpModify := pDevEntry.updateOnuUniTpPath(uniID, tpID, ""); bTpModify {
+ if bTpModify := pDevEntry.updateOnuUniTpPath(ctx, uniID, tpID, ""); bTpModify {
// deadline context to ensure completion of background routines waited for
deadline := time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
dctx, cancel := context.WithDeadline(context.Background(), deadline)
@@ -471,11 +474,11 @@
var wg sync.WaitGroup
wg.Add(2) // for the 2 go routines to finish
- go dh.pOnuTP.deleteTpResource(dctx, uniID, tpID, delTcontMsg.TpPath,
+ go dh.pOnuTP.deleteTpResource(log.WithSpanFromContext(dctx, ctx), uniID, tpID, delTcontMsg.TpPath,
cResourceTcont, delTcontMsg.AllocId, &wg)
// Removal of the tcont/alloc id mapping represents the removal of the tech profile
- go pDevEntry.updateOnuKvStore(dctx, &wg)
- dh.waitForCompletion(cancel, &wg, "TContDelete") //wait for background process to finish
+ go pDevEntry.updateOnuKvStore(log.WithSpanFromContext(dctx, ctx), &wg)
+ dh.waitForCompletion(ctx, cancel, &wg, "TContDelete") //wait for background process to finish
return dh.combineErrorStrings(dh.pOnuTP.getTpProcessingErrorIndication(uniID, tpID), pDevEntry.getKvProcessingErrorIndication())
}
@@ -485,38 +488,38 @@
//processInterAdapterMessage sends the proxied messages to the target device
// If the proxy address is not found in the unmarshalled message, it first fetches the onu device for which the message
// is meant, and then send the unmarshalled omci message to this onu
-func (dh *deviceHandler) processInterAdapterMessage(msg *ic.InterAdapterMessage) error {
+func (dh *deviceHandler) processInterAdapterMessage(ctx context.Context, msg *ic.InterAdapterMessage) error {
msgID := msg.Header.Id
msgType := msg.Header.Type
fromTopic := msg.Header.FromTopic
toTopic := msg.Header.ToTopic
toDeviceID := msg.Header.ToDeviceId
proxyDeviceID := msg.Header.ProxyDeviceId
- logger.Debugw("InterAdapter message header", log.Fields{"msgID": msgID, "msgType": msgType,
+ logger.Debugw(ctx, "InterAdapter message header", log.Fields{"msgID": msgID, "msgType": msgType,
"fromTopic": fromTopic, "toTopic": toTopic, "toDeviceID": toDeviceID, "proxyDeviceID": proxyDeviceID})
switch msgType {
// case ic.InterAdapterMessageType_ONU_IND_REQUEST: was handled by OpenONUAC already - see comments there
case ic.InterAdapterMessageType_OMCI_REQUEST:
{
- return dh.processInterAdapterOMCIReqMessage(msg)
+ return dh.processInterAdapterOMCIReqMessage(ctx, msg)
}
case ic.InterAdapterMessageType_TECH_PROFILE_DOWNLOAD_REQUEST:
{
- return dh.processInterAdapterTechProfileDownloadReqMessage(msg)
+ return dh.processInterAdapterTechProfileDownloadReqMessage(ctx, msg)
}
case ic.InterAdapterMessageType_DELETE_GEM_PORT_REQUEST:
{
- return dh.processInterAdapterDeleteGemPortReqMessage(msg)
+ return dh.processInterAdapterDeleteGemPortReqMessage(ctx, msg)
}
case ic.InterAdapterMessageType_DELETE_TCONT_REQUEST:
{
- return dh.processInterAdapterDeleteTcontReqMessage(msg)
+ return dh.processInterAdapterDeleteTcontReqMessage(ctx, msg)
}
default:
{
- logger.Errorw("inter-adapter-unhandled-type", log.Fields{
+ logger.Errorw(ctx, "inter-adapter-unhandled-type", log.Fields{
"msgType": msg.Header.Type, "device-id": dh.deviceID})
return fmt.Errorf("inter-adapter-unhandled-type: %d, %s", msg.Header.Type, dh.deviceID)
}
@@ -524,29 +527,30 @@
}
//FlowUpdateIncremental removes and/or adds the flow changes on a given device
-func (dh *deviceHandler) FlowUpdateIncremental(apOfFlowChanges *openflow_13.FlowChanges,
+func (dh *deviceHandler) FlowUpdateIncremental(ctx context.Context,
+ apOfFlowChanges *openflow_13.FlowChanges,
apOfGroupChanges *openflow_13.FlowGroupChanges, apFlowMetaData *voltha.FlowMetadata) error {
- logger.Debugw("FlowUpdateIncremental started", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "FlowUpdateIncremental started", log.Fields{"device-id": dh.deviceID})
var retError error = nil
//Remove flows (always remove flows first - remove old and add new with same cookie may be part of the same request)
if apOfFlowChanges.ToRemove != nil {
for _, flowItem := range apOfFlowChanges.ToRemove.Items {
if flowItem.GetCookie() == 0 {
- logger.Warnw("flow-remove no cookie: ignore and continuing on checking further flows", log.Fields{
+ logger.Warnw(ctx, "flow-remove no cookie: ignore and continuing on checking further flows", log.Fields{
"device-id": dh.deviceID})
retError = fmt.Errorf("flow-remove no cookie, device-id %s", dh.deviceID)
continue
}
flowInPort := flow.GetInPort(flowItem)
if flowInPort == uint32(of.OfpPortNo_OFPP_INVALID) {
- logger.Warnw("flow-remove inPort invalid: ignore and continuing on checking further flows", log.Fields{"device-id": dh.deviceID})
+ logger.Warnw(ctx, "flow-remove inPort invalid: ignore and continuing on checking further flows", log.Fields{"device-id": dh.deviceID})
retError = fmt.Errorf("flow-remove inPort invalid, device-id %s", dh.deviceID)
continue
//return fmt.Errorf("flow inPort invalid: %s", dh.deviceID)
} else if flowInPort == dh.ponPortNumber {
//this is some downstream flow, not regarded as error, just ignored
- logger.Debugw("flow-remove for downstream: ignore and continuing on checking further flows", log.Fields{
+ logger.Debugw(ctx, "flow-remove for downstream: ignore and continuing on checking further flows", log.Fields{
"device-id": dh.deviceID, "inPort": flowInPort})
continue
} else {
@@ -555,20 +559,20 @@
if uniPort, exist := dh.uniEntityMap[flowInPort]; exist {
loUniPort = uniPort
} else {
- logger.Warnw("flow-remove inPort not found in UniPorts: ignore and continuing on checking further flows",
+ logger.Warnw(ctx, "flow-remove inPort not found in UniPorts: ignore and continuing on checking further flows",
log.Fields{"device-id": dh.deviceID, "inPort": flowInPort})
retError = fmt.Errorf("flow-remove inPort not found in UniPorts, inPort %d, device-id %s",
flowInPort, dh.deviceID)
continue
}
flowOutPort := flow.GetOutPort(flowItem)
- logger.Debugw("flow-remove port indications", log.Fields{
+ logger.Debugw(ctx, "flow-remove port indications", log.Fields{
"device-id": dh.deviceID, "inPort": flowInPort, "outPort": flowOutPort,
"uniPortName": loUniPort.name})
- err := dh.removeFlowItemFromUniPort(flowItem, loUniPort)
+ err := dh.removeFlowItemFromUniPort(ctx, flowItem, loUniPort)
//try next flow after processing error
if err != nil {
- logger.Warnw("flow-remove processing error: continuing on checking further flows",
+ logger.Warnw(ctx, "flow-remove processing error: continuing on checking further flows",
log.Fields{"device-id": dh.deviceID, "error": err})
retError = err
continue
@@ -582,20 +586,20 @@
if apOfFlowChanges.ToAdd != nil {
for _, flowItem := range apOfFlowChanges.ToAdd.Items {
if flowItem.GetCookie() == 0 {
- logger.Debugw("incremental flow-add no cookie: ignore and continuing on checking further flows", log.Fields{
+ logger.Debugw(ctx, "incremental flow-add no cookie: ignore and continuing on checking further flows", log.Fields{
"device-id": dh.deviceID})
retError = fmt.Errorf("flow-add no cookie, device-id %s", dh.deviceID)
continue
}
flowInPort := flow.GetInPort(flowItem)
if flowInPort == uint32(of.OfpPortNo_OFPP_INVALID) {
- logger.Warnw("flow-add inPort invalid: ignore and continuing on checking further flows", log.Fields{"device-id": dh.deviceID})
+ logger.Warnw(ctx, "flow-add inPort invalid: ignore and continuing on checking further flows", log.Fields{"device-id": dh.deviceID})
retError = fmt.Errorf("flow-add inPort invalid, device-id %s", dh.deviceID)
continue
//return fmt.Errorf("flow inPort invalid: %s", dh.deviceID)
} else if flowInPort == dh.ponPortNumber {
//this is some downstream flow
- logger.Debugw("flow-add for downstream: ignore and continuing on checking further flows", log.Fields{
+ logger.Debugw(ctx, "flow-add for downstream: ignore and continuing on checking further flows", log.Fields{
"device-id": dh.deviceID, "inPort": flowInPort})
continue
} else {
@@ -604,7 +608,7 @@
if uniPort, exist := dh.uniEntityMap[flowInPort]; exist {
loUniPort = uniPort
} else {
- logger.Warnw("flow-add inPort not found in UniPorts: ignore and continuing on checking further flows",
+ logger.Warnw(ctx, "flow-add inPort not found in UniPorts: ignore and continuing on checking further flows",
log.Fields{"device-id": dh.deviceID, "inPort": flowInPort})
retError = fmt.Errorf("flow-add inPort not found in UniPorts, inPort %d, device-id %s",
flowInPort, dh.deviceID)
@@ -618,19 +622,19 @@
// for state checking compare also code here: processInterAdapterTechProfileDownloadReqMessage
// also abort for the other still possible flows here
if !dh.ReadyForSpecificOmciConfig {
- logger.Errorw("flow-add rejected: improper device state", log.Fields{"device-id": dh.deviceID,
+ logger.Errorw(ctx, "flow-add rejected: improper device state", log.Fields{"device-id": dh.deviceID,
"last device-reason": deviceReasonMap[dh.deviceReason]})
return fmt.Errorf("improper device state on device %s", dh.deviceID)
}
flowOutPort := flow.GetOutPort(flowItem)
- logger.Debugw("flow-add port indications", log.Fields{
+ logger.Debugw(ctx, "flow-add port indications", log.Fields{
"device-id": dh.deviceID, "inPort": flowInPort, "outPort": flowOutPort,
"uniPortName": loUniPort.name})
- err := dh.addFlowItemToUniPort(flowItem, loUniPort)
+ err := dh.addFlowItemToUniPort(ctx, flowItem, loUniPort)
//try next flow after processing error
if err != nil {
- logger.Warnw("flow-add processing error: continuing on checking further flows",
+ logger.Warnw(ctx, "flow-add processing error: continuing on checking further flows",
log.Fields{"device-id": dh.deviceID, "error": err})
retError = err
continue
@@ -648,8 +652,8 @@
//following are the expected device states after this activity:
//Device Admin-State : down (on rwCore), Port-State: UNKNOWN, Conn-State: REACHABLE, Reason: omci-admin-lock
// (Conn-State: REACHABLE might conflict with some previous ONU Down indication - maybe to be resolved later)
-func (dh *deviceHandler) disableDevice(device *voltha.Device) {
- logger.Debugw("disable-device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
+func (dh *deviceHandler) disableDevice(ctx context.Context, device *voltha.Device) {
+ logger.Debugw(ctx, "disable-device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
//admin-lock reason can also be used uniquely for setting the DeviceState accordingly
//note that disableDevice sequences in some 'ONU active' state may yield also
@@ -663,30 +667,30 @@
// disable UNI ports/ONU
// *** should generate UniDisableStateDone event - used to disable the port(s) on success
if dh.pLockStateFsm == nil {
- dh.createUniLockFsm(true, UniDisableStateDone)
+ dh.createUniLockFsm(ctx, true, UniDisableStateDone)
} else { //LockStateFSM already init
dh.pLockStateFsm.setSuccessEvent(UniDisableStateDone)
- dh.runUniLockFsm(true)
+ dh.runUniLockFsm(ctx, true)
}
} else {
- logger.Debugw("DeviceStateUpdate upon disable", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
+ logger.Debugw(ctx, "DeviceStateUpdate upon disable", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
"OperStatus": voltha.OperStatus_UNKNOWN, "device-id": dh.deviceID})
- if err := dh.coreProxy.DeviceStateUpdate(context.TODO(),
+ if err := dh.coreProxy.DeviceStateUpdate(log.WithSpanFromContext(context.TODO(), ctx),
dh.deviceID, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_UNKNOWN); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw("error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
}
// DeviceReason to update acc.to modified py code as per beginning of Sept 2020
//TODO with VOL-3045/VOL-3046: catch and return error, valid for all occurrences in the codebase
- _ = dh.deviceReasonUpdate(drOmciAdminLock, true)
+ _ = dh.deviceReasonUpdate(ctx, drOmciAdminLock, true)
}
}
}
//reEnableDevice unlocks the ONU and its UNI/VEIP ports (admin unlock via OMCI)
-func (dh *deviceHandler) reEnableDevice(device *voltha.Device) {
- logger.Debugw("reenable-device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
+func (dh *deviceHandler) reEnableDevice(ctx context.Context, device *voltha.Device) {
+ logger.Debugw(ctx, "reenable-device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
//setting ReadyForSpecificOmciConfig here is just a workaround for BBSIM testing in the sequence
// OnuSoftReboot-disable-enable, because BBSIM does not generate a new OnuIndication-Up event after SoftReboot
@@ -701,26 +705,26 @@
// enable ONU/UNI ports
// *** should generate UniEnableStateDone event - used to disable the port(s) on success
if dh.pUnlockStateFsm == nil {
- dh.createUniLockFsm(false, UniEnableStateDone)
+ dh.createUniLockFsm(ctx, false, UniEnableStateDone)
} else { //UnlockStateFSM already init
dh.pUnlockStateFsm.setSuccessEvent(UniEnableStateDone)
- dh.runUniLockFsm(false)
+ dh.runUniLockFsm(ctx, false)
}
}
-func (dh *deviceHandler) reconcileDeviceOnuInd() {
- logger.Debugw("reconciling - simulate onu indication", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) reconcileDeviceOnuInd(ctx context.Context) {
+ logger.Debugw(ctx, "reconciling - simulate onu indication", log.Fields{"device-id": dh.deviceID})
- pDevEntry := dh.getOnuDeviceEntry(true)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
return
}
- if err := pDevEntry.restoreDataFromOnuKvStore(context.TODO()); err != nil {
+ if err := pDevEntry.restoreDataFromOnuKvStore(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
if err == fmt.Errorf("no-ONU-data-found") {
- logger.Debugw("no persistent data found - abort reconciling", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "no persistent data found - abort reconciling", log.Fields{"device-id": dh.deviceID})
} else {
- logger.Errorw("reconciling - restoring OnuTp-data failed - abort", log.Fields{"err": err, "device-id": dh.deviceID})
+ logger.Errorw(ctx, "reconciling - restoring OnuTp-data failed - abort", log.Fields{"err": err, "device-id": dh.deviceID})
}
dh.reconciling = false
return
@@ -730,22 +734,22 @@
onuIndication.OnuId = pDevEntry.sOnuPersistentData.PersOnuID
onuIndication.OperState = pDevEntry.sOnuPersistentData.PersOperState
onuIndication.AdminState = pDevEntry.sOnuPersistentData.PersAdminState
- _ = dh.createInterface(&onuIndication)
+ _ = dh.createInterface(ctx, &onuIndication)
}
-func (dh *deviceHandler) reconcileDeviceTechProf() {
- logger.Debugw("reconciling - trigger tech profile config", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) reconcileDeviceTechProf(ctx context.Context) {
+ logger.Debugw(ctx, "reconciling - trigger tech profile config", log.Fields{"device-id": dh.deviceID})
- pDevEntry := dh.getOnuDeviceEntry(true)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
return
}
dh.pOnuTP.lockTpProcMutex()
defer dh.pOnuTP.unlockTpProcMutex()
if len(pDevEntry.sOnuPersistentData.PersUniConfig) == 0 {
- logger.Debugw("reconciling - no uni-configs have been stored before adapter restart - terminate reconcilement",
+ logger.Debugw(ctx, "reconciling - no uni-configs have been stored before adapter restart - terminate reconcilement",
log.Fields{"device-id": dh.deviceID})
dh.reconciling = false
return
@@ -753,7 +757,7 @@
for _, uniData := range pDevEntry.sOnuPersistentData.PersUniConfig {
//TODO: check for uni-port specific reconcilement in case of multi-uni-port-per-onu-support
if len(uniData.PersTpPathMap) == 0 {
- logger.Debugw("reconciling - no TPs have been stored before adapter restart - terminate reconcilement",
+ logger.Debugw(ctx, "reconciling - no TPs have been stored before adapter restart - terminate reconcilement",
log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.deviceID})
dh.reconciling = false
return
@@ -762,35 +766,35 @@
// deadline context to ensure completion of background routines waited for
//20200721: 10s proved to be less in 8*8 ONU test on local vbox machine with debug, might be further adapted
deadline := time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
- dctx, cancel := context.WithDeadline(context.Background(), deadline)
+ dctx, cancel := context.WithDeadline(ctx, deadline)
dh.pOnuTP.resetTpProcessingErrorIndication(uniData.PersUniID, tpID)
var wg sync.WaitGroup
wg.Add(1) // for the 1 go routine to finish
- go dh.pOnuTP.configureUniTp(dctx, uniData.PersUniID, uniData.PersTpPathMap[tpID], &wg)
- dh.waitForCompletion(cancel, &wg, "TechProfReconcile") //wait for background process to finish
+ go dh.pOnuTP.configureUniTp(log.WithSpanFromContext(dctx, ctx), uniData.PersUniID, uniData.PersTpPathMap[tpID], &wg)
+ dh.waitForCompletion(ctx, cancel, &wg, "TechProfReconcile") //wait for background process to finish
if err := dh.pOnuTP.getTpProcessingErrorIndication(uniData.PersUniID, tpID); err != nil {
- logger.Errorw(err.Error(), log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.deviceID})
}
}
if len(uniData.PersFlowParams) == 0 {
- logger.Debugw("reconciling - no flows have been stored before adapter restart - terminate reconcilement",
+ logger.Debugw(ctx, "reconciling - no flows have been stored before adapter restart - terminate reconcilement",
log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.deviceID})
dh.reconciling = false
}
}
}
-func (dh *deviceHandler) reconcileDeviceFlowConfig() {
- logger.Debugw("reconciling - trigger flow config", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) reconcileDeviceFlowConfig(ctx context.Context) {
+ logger.Debugw(ctx, "reconciling - trigger flow config", log.Fields{"device-id": dh.deviceID})
- pDevEntry := dh.getOnuDeviceEntry(true)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
return
}
if len(pDevEntry.sOnuPersistentData.PersUniConfig) == 0 {
- logger.Debugw("reconciling - no uni-configs have been stored before adapter restart - terminate reconcilement",
+ logger.Debugw(ctx, "reconciling - no uni-configs have been stored before adapter restart - terminate reconcilement",
log.Fields{"device-id": dh.deviceID})
dh.reconciling = false
return
@@ -798,57 +802,57 @@
for _, uniData := range pDevEntry.sOnuPersistentData.PersUniConfig {
//TODO: check for uni-port specific reconcilement in case of multi-uni-port-per-onu-support
if len(uniData.PersFlowParams) == 0 {
- logger.Debugw("reconciling - no flows have been stored before adapter restart - terminate reconcilement",
+ logger.Debugw(ctx, "reconciling - no flows have been stored before adapter restart - terminate reconcilement",
log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.deviceID})
dh.reconciling = false
return
}
var uniPort *onuUniPort
var exist bool
- uniNo := mkUniPortNum(dh.pOnuIndication.GetIntfId(), dh.pOnuIndication.GetOnuId(), uint32(uniData.PersUniID))
+ uniNo := mkUniPortNum(ctx, dh.pOnuIndication.GetIntfId(), dh.pOnuIndication.GetOnuId(), uint32(uniData.PersUniID))
if uniPort, exist = dh.uniEntityMap[uniNo]; !exist {
- logger.Errorw("onuUniPort data not found!", log.Fields{"uniNo": uniNo, "device-id": dh.deviceID})
+ logger.Errorw(ctx, "onuUniPort data not found!", log.Fields{"uniNo": uniNo, "device-id": dh.deviceID})
return
}
for _, flowData := range uniData.PersFlowParams {
- logger.Debugw("add flow with cookie slice", log.Fields{"device-id": dh.deviceID, "cookies": flowData.CookieSlice})
+ logger.Debugw(ctx, "add flow with cookie slice", log.Fields{"device-id": dh.deviceID, "cookies": flowData.CookieSlice})
//the slice can be passed 'by value' here, - which internally passes its reference copy
if _, exist = dh.UniVlanConfigFsmMap[uniData.PersUniID]; exist {
- if err := dh.UniVlanConfigFsmMap[uniData.PersUniID].SetUniFlowParams(flowData.VlanRuleParams.TpID,
+ if err := dh.UniVlanConfigFsmMap[uniData.PersUniID].SetUniFlowParams(ctx, flowData.VlanRuleParams.TpID,
flowData.CookieSlice, uint16(flowData.VlanRuleParams.MatchVid), uint16(flowData.VlanRuleParams.SetVid),
uint8(flowData.VlanRuleParams.SetPcp)); err != nil {
- logger.Errorw(err.Error(), log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.deviceID})
}
} else {
- if err := dh.createVlanFilterFsm(uniPort, flowData.VlanRuleParams.TpID, flowData.CookieSlice,
+ if err := dh.createVlanFilterFsm(ctx, uniPort, flowData.VlanRuleParams.TpID, flowData.CookieSlice,
uint16(flowData.VlanRuleParams.MatchVid), uint16(flowData.VlanRuleParams.SetVid),
uint8(flowData.VlanRuleParams.SetPcp), OmciVlanFilterAddDone); err != nil {
- logger.Errorw(err.Error(), log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, err.Error(), log.Fields{"device-id": dh.deviceID})
}
}
}
if len(uniData.PersTpPathMap) == 0 {
- logger.Debugw("reconciling - no TPs have been stored before adapter restart - terminate reconcilement",
+ logger.Debugw(ctx, "reconciling - no TPs have been stored before adapter restart - terminate reconcilement",
log.Fields{"uni-id": uniData.PersUniID, "device-id": dh.deviceID})
dh.reconciling = false
}
}
}
-func (dh *deviceHandler) reconcileMetrics() {
- logger.Debugw("reconciling - trigger metrics - to be implemented in scope of VOL-3324!", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) reconcileMetrics(ctx context.Context) {
+ logger.Debugw(ctx, "reconciling - trigger metrics - to be implemented in scope of VOL-3324!", log.Fields{"device-id": dh.deviceID})
//TODO: reset of reconciling-flag has always to be done in the last reconcile*() function
dh.reconciling = false
}
-func (dh *deviceHandler) deleteDevicePersistencyData() error {
- logger.Debugw("delete device persistency data", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) deleteDevicePersistencyData(ctx context.Context) error {
+ logger.Debugw(ctx, "delete device persistency data", log.Fields{"device-id": dh.deviceID})
- pDevEntry := dh.getOnuDeviceEntry(false)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
//IfDevEntry does not exist here, no problem - no persistent data should have been stored
- logger.Debugw("OnuDevice does not exist - nothing to delete", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "OnuDevice does not exist - nothing to delete", log.Fields{"device-id": dh.deviceID})
return nil
}
pDevEntry.lockOnuKVStoreMutex()
@@ -857,43 +861,43 @@
// deadline context to ensure completion of background routines waited for
//20200721: 10s proved to be less in 8*8 ONU test on local vbox machine with debug, might be further adapted
deadline := time.Now().Add(dh.pOpenOnuAc.maxTimeoutInterAdapterComm) //allowed run time to finish before execution
- dctx, cancel := context.WithDeadline(context.Background(), deadline)
+ dctx, cancel := context.WithDeadline(ctx, deadline)
pDevEntry.resetKvProcessingErrorIndication()
var wg sync.WaitGroup
wg.Add(1) // for the 1 go routine to finish
- go pDevEntry.deleteDataFromOnuKvStore(dctx, &wg)
- dh.waitForCompletion(cancel, &wg, "DeleteDevice") //wait for background process to finish
+ go pDevEntry.deleteDataFromOnuKvStore(log.WithSpanFromContext(dctx, ctx), &wg)
+ dh.waitForCompletion(ctx, cancel, &wg, "DeleteDevice") //wait for background process to finish
// TODO: further actions - stop metrics and FSMs, remove device ...
return pDevEntry.getKvProcessingErrorIndication()
}
-func (dh *deviceHandler) rebootDevice(device *voltha.Device) error {
- logger.Debugw("reboot-device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
+func (dh *deviceHandler) rebootDevice(ctx context.Context, device *voltha.Device) error {
+ logger.Debugw(ctx, "reboot-device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
if device.ConnectStatus != voltha.ConnectStatus_REACHABLE {
- logger.Errorw("device-unreachable", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
+ logger.Errorw(ctx, "device-unreachable", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
return fmt.Errorf("device-unreachable: %s, %s", dh.deviceID, device.SerialNumber)
}
- if err := dh.pOnuOmciDevice.reboot(context.TODO()); err != nil {
+ if err := dh.pOnuOmciDevice.reboot(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw("error-rebooting-device", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-rebooting-device", log.Fields{"device-id": dh.deviceID, "error": err})
return err
}
//transfer the possibly modified logical uni port state
- dh.disableUniPortStateUpdate()
+ dh.disableUniPortStateUpdate(ctx)
- logger.Debugw("call DeviceStateUpdate upon reboot", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
+ logger.Debugw(ctx, "call DeviceStateUpdate upon reboot", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
"OperStatus": voltha.OperStatus_DISCOVERED, "device-id": dh.deviceID})
- if err := dh.coreProxy.DeviceStateUpdate(context.TODO(), dh.deviceID, voltha.ConnectStatus_REACHABLE,
+ if err := dh.coreProxy.DeviceStateUpdate(log.WithSpanFromContext(context.TODO(), ctx), dh.deviceID, voltha.ConnectStatus_REACHABLE,
voltha.OperStatus_DISCOVERED); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw("error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
return err
}
- if err := dh.deviceReasonUpdate(drRebooting, true); err != nil {
+ if err := dh.deviceReasonUpdate(ctx, drRebooting, true); err != nil {
return err
}
dh.ReadyForSpecificOmciConfig = false
@@ -910,14 +914,14 @@
// ################ to be updated acc. needs of ONU Device ########################
// deviceHandler StateMachine related state transition methods ##### begin #########
-func (dh *deviceHandler) logStateChange(e *fsm.Event) {
- logger.Debugw("Device FSM: ", log.Fields{"event name": string(e.Event), "src state": string(e.Src), "dst state": string(e.Dst), "device-id": dh.deviceID})
+func (dh *deviceHandler) logStateChange(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "Device FSM: ", log.Fields{"event name": string(e.Event), "src state": string(e.Src), "dst state": string(e.Dst), "device-id": dh.deviceID})
}
// doStateInit provides the device update to the core
-func (dh *deviceHandler) doStateInit(e *fsm.Event) {
+func (dh *deviceHandler) doStateInit(ctx context.Context, e *fsm.Event) {
- logger.Debug("doStateInit-started")
+ logger.Debug(ctx, "doStateInit-started")
var err error
// populate what we know. rest comes later after mib sync
@@ -930,10 +934,10 @@
dh.logicalDeviceID = dh.deviceID // really needed - what for ??? //TODO!!!
if !dh.reconciling {
- logger.Infow("DeviceUpdate", log.Fields{"deviceReason": dh.device.Reason, "device-id": dh.deviceID})
- _ = dh.coreProxy.DeviceUpdate(context.TODO(), dh.device)
+ logger.Infow(ctx, "DeviceUpdate", log.Fields{"deviceReason": dh.device.Reason, "device-id": dh.deviceID})
+ _ = dh.coreProxy.DeviceUpdate(log.WithSpanFromContext(context.TODO(), ctx), dh.device)
} else {
- logger.Debugw("reconciling - don't notify core about DeviceUpdate",
+ logger.Debugw(ctx, "reconciling - don't notify core about DeviceUpdate",
log.Fields{"device-id": dh.deviceID})
}
@@ -943,7 +947,7 @@
// store proxy parameters for later communication - assumption: invariant, else they have to be requested dynamically!!
dh.ProxyAddressID = dh.device.ProxyAddress.GetDeviceId()
dh.ProxyAddressType = dh.device.ProxyAddress.GetDeviceType()
- logger.Debugw("device-updated", log.Fields{"device-id": dh.deviceID, "proxyAddressID": dh.ProxyAddressID,
+ logger.Debugw(ctx, "device-updated", log.Fields{"device-id": dh.deviceID, "proxyAddressID": dh.ProxyAddressID,
"proxyAddressType": dh.ProxyAddressType, "SNR": dh.device.SerialNumber,
"ParentId": dh.parentID, "ParentPortNo": dh.ponPortNumber})
@@ -957,7 +961,7 @@
)
*/
if !dh.reconciling {
- logger.Debugw("adding-pon-port", log.Fields{"device-id": dh.deviceID, "ponPortNo": dh.ponPortNumber})
+ logger.Debugw(ctx, "adding-pon-port", log.Fields{"device-id": dh.deviceID, "ponPortNo": dh.ponPortNumber})
var ponPortNo uint32 = 1
if dh.ponPortNumber != 0 {
ponPortNo = dh.ponPortNumber
@@ -971,35 +975,35 @@
Peers: []*voltha.Port_PeerPort{{DeviceId: dh.parentID, // Peer device is OLT
PortNo: ponPortNo}}, // Peer port is parent's port number
}
- if err = dh.coreProxy.PortCreated(context.TODO(), dh.deviceID, pPonPort); err != nil {
- logger.Fatalf("Device FSM: PortCreated-failed-%s", err)
+ if err = dh.coreProxy.PortCreated(log.WithSpanFromContext(context.TODO(), ctx), dh.deviceID, pPonPort); err != nil {
+ logger.Fatalf(ctx, "Device FSM: PortCreated-failed-%s", err)
e.Cancel(err)
return
}
} else {
- logger.Debugw("reconciling - pon-port already added", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "reconciling - pon-port already added", log.Fields{"device-id": dh.deviceID})
}
- logger.Debug("doStateInit-done")
+ logger.Debug(ctx, "doStateInit-done")
}
// postInit setups the DeviceEntry for the conerned device
-func (dh *deviceHandler) postInit(e *fsm.Event) {
+func (dh *deviceHandler) postInit(ctx context.Context, e *fsm.Event) {
- logger.Debug("postInit-started")
+ logger.Debug(ctx, "postInit-started")
var err error
/*
dh.Client = oop.NewOpenoltClient(dh.clientCon)
dh.pTransitionMap.Handle(ctx, GrpcConnected)
return nil
*/
- if err = dh.addOnuDeviceEntry(context.TODO()); err != nil {
- logger.Fatalf("Device FSM: addOnuDeviceEntry-failed-%s", err)
+ if err = dh.addOnuDeviceEntry(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
+ logger.Fatalf(ctx, "Device FSM: addOnuDeviceEntry-failed-%s", err)
e.Cancel(err)
return
}
if dh.reconciling {
- go dh.reconcileDeviceOnuInd()
+ go dh.reconcileDeviceOnuInd(ctx)
// reconcilement will be continued after mib download is done
}
/*
@@ -1045,28 +1049,28 @@
else:
self.logger.info('onu-already-activated')
*/
- logger.Debug("postInit-done")
+ logger.Debug(ctx, "postInit-done")
}
// doStateConnected get the device info and update to voltha core
// for comparison of the original method (not that easy to uncomment): compare here:
// voltha-openolt-adapter/adaptercore/device_handler.go
// -> this one obviously initiates all communication interfaces of the device ...?
-func (dh *deviceHandler) doStateConnected(e *fsm.Event) {
+func (dh *deviceHandler) doStateConnected(ctx context.Context, e *fsm.Event) {
- logger.Debug("doStateConnected-started")
+ logger.Debug(ctx, "doStateConnected-started")
err := errors.New("device FSM: function not implemented yet")
e.Cancel(err)
- logger.Debug("doStateConnected-done")
+ logger.Debug(ctx, "doStateConnected-done")
}
// doStateUp handle the onu up indication and update to voltha core
-func (dh *deviceHandler) doStateUp(e *fsm.Event) {
+func (dh *deviceHandler) doStateUp(ctx context.Context, e *fsm.Event) {
- logger.Debug("doStateUp-started")
+ logger.Debug(ctx, "doStateUp-started")
err := errors.New("device FSM: function not implemented yet")
e.Cancel(err)
- logger.Debug("doStateUp-done")
+ logger.Debug(ctx, "doStateUp-done")
/*
// Synchronous call to update device state - this method is run in its own go routine
@@ -1080,21 +1084,21 @@
}
// doStateDown handle the onu down indication
-func (dh *deviceHandler) doStateDown(e *fsm.Event) {
+func (dh *deviceHandler) doStateDown(ctx context.Context, e *fsm.Event) {
- logger.Debug("doStateDown-started")
+ logger.Debug(ctx, "doStateDown-started")
var err error
device := dh.device
if device == nil {
/*TODO: needs to handle error scenarios */
- logger.Errorw("Failed to fetch handler device", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "Failed to fetch handler device", log.Fields{"device-id": dh.deviceID})
e.Cancel(err)
return
}
cloned := proto.Clone(device).(*voltha.Device)
- logger.Debugw("do-state-down", log.Fields{"ClonedDeviceID": cloned.Id})
+ logger.Debugw(ctx, "do-state-down", log.Fields{"ClonedDeviceID": cloned.Id})
/*
// Update the all ports state on that device to disable
if er := dh.coreProxy.PortsStateUpdate(ctx, cloned.Id, voltha.OperStatus_UNKNOWN); er != nil {
@@ -1139,7 +1143,7 @@
*/
err = errors.New("device FSM: function not implemented yet")
e.Cancel(err)
- logger.Debug("doStateDown-done")
+ logger.Debug(ctx, "doStateDown-done")
}
// deviceHandler StateMachine related state transition methods ##### end #########
@@ -1149,21 +1153,21 @@
// deviceHandler utility methods ##### begin #########
//getOnuDeviceEntry gets the ONU device entry and may wait until its value is defined
-func (dh *deviceHandler) getOnuDeviceEntry(aWait bool) *OnuDeviceEntry {
+func (dh *deviceHandler) getOnuDeviceEntry(ctx context.Context, aWait bool) *OnuDeviceEntry {
dh.lockDevice.RLock()
pOnuDeviceEntry := dh.pOnuOmciDevice
if aWait && pOnuDeviceEntry == nil {
//keep the read sema short to allow for subsequent write
dh.lockDevice.RUnlock()
- logger.Debugw("Waiting for DeviceEntry to be set ...", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "Waiting for DeviceEntry to be set ...", log.Fields{"device-id": dh.deviceID})
// based on concurrent processing the deviceEntry setup may not yet be finished at his point
// so it might be needed to wait here for that event with some timeout
select {
case <-time.After(60 * time.Second): //timer may be discussed ...
- logger.Errorw("No valid DeviceEntry set after maxTime", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid DeviceEntry set after maxTime", log.Fields{"device-id": dh.deviceID})
return nil
case <-dh.deviceEntrySet:
- logger.Debugw("devicEntry ready now - continue", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "devicEntry ready now - continue", log.Fields{"device-id": dh.deviceID})
// if written now, we can return the written value without sema
return dh.pOnuOmciDevice
}
@@ -1183,9 +1187,9 @@
//addOnuDeviceEntry creates a new ONU device or returns the existing
func (dh *deviceHandler) addOnuDeviceEntry(ctx context.Context) error {
- logger.Debugw("adding-deviceEntry", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "adding-deviceEntry", log.Fields{"device-id": dh.deviceID})
- deviceEntry := dh.getOnuDeviceEntry(false)
+ deviceEntry := dh.getOnuDeviceEntry(ctx, false)
if deviceEntry == nil {
/* costum_me_map in python code seems always to be None,
we omit that here first (declaration unclear) -> todo at Adapter specialization ...*/
@@ -1197,43 +1201,43 @@
dh.setOnuDeviceEntry(deviceEntry, onuTechProfProc)
// fire deviceEntry ready event to spread to possibly waiting processing
dh.deviceEntrySet <- true
- logger.Debugw("onuDeviceEntry-added", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "onuDeviceEntry-added", log.Fields{"device-id": dh.deviceID})
} else {
- logger.Debugw("onuDeviceEntry-add: Device already exists", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "onuDeviceEntry-add: Device already exists", log.Fields{"device-id": dh.deviceID})
}
// might be updated with some error handling !!!
return nil
}
-func (dh *deviceHandler) createInterface(onuind *oop.OnuIndication) error {
- logger.Debugw("create_interface-started", log.Fields{"OnuId": onuind.GetOnuId(),
+func (dh *deviceHandler) createInterface(ctx context.Context, onuind *oop.OnuIndication) error {
+ logger.Debugw(ctx, "create_interface-started", log.Fields{"OnuId": onuind.GetOnuId(),
"OnuIntfId": onuind.GetIntfId(), "OnuSerialNumber": onuind.GetSerialNumber()})
dh.pOnuIndication = onuind // let's revise if storing the pointer is sufficient...
- pDevEntry := dh.getOnuDeviceEntry(true)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
}
if !dh.reconciling {
- if err := dh.storePersistentData(); err != nil {
- logger.Warnw("store persistent data error - continue as there will be additional write attempts",
+ if err := dh.storePersistentData(ctx); err != nil {
+ logger.Warnw(ctx, "store persistent data error - continue as there will be additional write attempts",
log.Fields{"device-id": dh.deviceID, "err": err})
}
- logger.Debugw("call DeviceStateUpdate upon create interface", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
+ logger.Debugw(ctx, "call DeviceStateUpdate upon create interface", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
"OperStatus": voltha.OperStatus_ACTIVATING, "device-id": dh.deviceID})
- if err := dh.coreProxy.DeviceStateUpdate(context.TODO(), dh.deviceID,
+ if err := dh.coreProxy.DeviceStateUpdate(log.WithSpanFromContext(context.TODO(), ctx), dh.deviceID,
voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVATING); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw("error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
}
} else {
- logger.Debugw("reconciling - don't notify core about DeviceStateUpdate to ACTIVATING",
+ logger.Debugw(ctx, "reconciling - don't notify core about DeviceStateUpdate to ACTIVATING",
log.Fields{"device-id": dh.deviceID})
if !pDevEntry.sOnuPersistentData.PersUniUnlockDone {
- logger.Debugw("reconciling - uni-ports were not unlocked before adapter restart - resume with a normal start-up",
+ logger.Debugw(ctx, "reconciling - uni-ports were not unlocked before adapter restart - resume with a normal start-up",
log.Fields{"device-id": dh.deviceID})
dh.reconciling = false
}
@@ -1244,7 +1248,7 @@
// but I would not know why, and the go code anyway does not work with the device directly anymore in the OnuDeviceEntry
// so let's just try to keep it simple ...
/*
- device, err := dh.coreProxy.GetDevice(context.TODO(), dh.device.Id, dh.device.Id)
+ device, err := dh.coreProxy.GetDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, dh.device.Id)
if err != nil || device == nil {
//TODO: needs to handle error scenarios
logger.Errorw("Failed to fetch device device at creating If", log.Fields{"err": err})
@@ -1252,27 +1256,27 @@
}
*/
- if err := pDevEntry.start(context.TODO()); err != nil {
+ if err := pDevEntry.start(log.WithSpanFromContext(context.TODO(), ctx)); err != nil {
return err
}
- _ = dh.deviceReasonUpdate(drStartingOpenomci, !dh.reconciling)
+ _ = dh.deviceReasonUpdate(ctx, drStartingOpenomci, !dh.reconciling)
/* this might be a good time for Omci Verify message? */
verifyExec := make(chan bool)
- omciVerify := newOmciTestRequest(context.TODO(),
+ omciVerify := newOmciTestRequest(log.WithSpanFromContext(context.TODO(), ctx),
dh.device.Id, pDevEntry.PDevOmciCC,
true, true) //exclusive and allowFailure (anyway not yet checked)
- omciVerify.performOmciTest(context.TODO(), verifyExec)
+ omciVerify.performOmciTest(log.WithSpanFromContext(context.TODO(), ctx), verifyExec)
/* give the handler some time here to wait for the OMCi verification result
after Timeout start and try MibUpload FSM anyway
(to prevent stopping on just not supported OMCI verification from ONU) */
select {
case <-time.After(2 * time.Second):
- logger.Warn("omci start-verification timed out (continue normal)")
+ logger.Warn(ctx, "omci start-verification timed out (continue normal)")
case testresult := <-verifyExec:
- logger.Infow("Omci start verification done", log.Fields{"result": testresult})
+ logger.Infow(ctx, "Omci start verification done", log.Fields{"result": testresult})
}
/* In py code it looks earlier (on activate ..)
@@ -1358,23 +1362,23 @@
if pMibUlFsm != nil {
if pMibUlFsm.Is(ulStDisabled) {
if err := pMibUlFsm.Event(ulEvStart); err != nil {
- logger.Errorw("MibSyncFsm: Can't go to state starting", log.Fields{"device-id": dh.deviceID, "err": err})
+ logger.Errorw(ctx, "MibSyncFsm: Can't go to state starting", log.Fields{"device-id": dh.deviceID, "err": err})
return fmt.Errorf("can't go to state starting: %s", dh.deviceID)
}
- logger.Debugw("MibSyncFsm", log.Fields{"state": string(pMibUlFsm.Current())})
+ logger.Debugw(ctx, "MibSyncFsm", log.Fields{"state": string(pMibUlFsm.Current())})
//Determine ONU status and start/re-start MIB Synchronization tasks
//Determine if this ONU has ever synchronized
if true { //TODO: insert valid check
if err := pMibUlFsm.Event(ulEvResetMib); err != nil {
- logger.Errorw("MibSyncFsm: Can't go to state resetting_mib", log.Fields{"device-id": dh.deviceID, "err": err})
+ logger.Errorw(ctx, "MibSyncFsm: Can't go to state resetting_mib", log.Fields{"device-id": dh.deviceID, "err": err})
return fmt.Errorf("can't go to state resetting_mib: %s", dh.deviceID)
}
} else {
if err := pMibUlFsm.Event(ulEvExamineMds); err != nil {
- logger.Errorw("MibSyncFsm: Can't go to state examine_mds", log.Fields{"device-id": dh.deviceID, "err": err})
+ logger.Errorw(ctx, "MibSyncFsm: Can't go to state examine_mds", log.Fields{"device-id": dh.deviceID, "err": err})
return fmt.Errorf("can't go to examine_mds: %s", dh.deviceID)
}
- logger.Debugw("state of MibSyncFsm", log.Fields{"state": string(pMibUlFsm.Current())})
+ logger.Debugw(ctx, "state of MibSyncFsm", log.Fields{"state": string(pMibUlFsm.Current())})
//Examine the MIB Data Sync
// callbacks to be handled:
// Event(ulEvSuccess)
@@ -1382,44 +1386,44 @@
// Event(ulEvMismatch)
}
} else {
- logger.Errorw("wrong state of MibSyncFsm - want: disabled", log.Fields{"have": string(pMibUlFsm.Current()),
+ logger.Errorw(ctx, "wrong state of MibSyncFsm - want: disabled", log.Fields{"have": string(pMibUlFsm.Current()),
"device-id": dh.deviceID})
return fmt.Errorf("wrong state of MibSyncFsm: %s", dh.deviceID)
}
} else {
- logger.Errorw("MibSyncFsm invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "MibSyncFsm invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("can't execute MibSync: %s", dh.deviceID)
}
return nil
}
-func (dh *deviceHandler) updateInterface(onuind *oop.OnuIndication) error {
+func (dh *deviceHandler) updateInterface(ctx context.Context, onuind *oop.OnuIndication) error {
//state checking to prevent unneeded processing (eg. on ONU 'unreachable' and 'down')
// (but note that the deviceReason may also have changed to e.g. TechProf*Delete_Success in between)
if dh.deviceReason != drStoppingOpenomci {
- logger.Debugw("updateInterface-started - stopping-device", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "updateInterface-started - stopping-device", log.Fields{"device-id": dh.deviceID})
//stop all running FSM processing - make use of the DH-state as mirrored in the deviceReason
//here no conflict with aborted FSM's should arise as a complete OMCI initialization is assumed on ONU-Up
//but that might change with some simple MDS check on ONU-Up treatment -> attention!!!
- if err := dh.resetFsms(); err != nil {
- logger.Errorw("error-updateInterface at FSM stop",
+ if err := dh.resetFsms(ctx); err != nil {
+ logger.Errorw(ctx, "error-updateInterface at FSM stop",
log.Fields{"device-id": dh.deviceID, "error": err})
// abort: system behavior is just unstable ...
return err
}
//all stored persistent data are not valid anymore (loosing knowledge about the connected ONU)
- _ = dh.deleteDevicePersistencyData() //ignore possible errors here and continue, hope is that data is synchronized with new ONU-Up
+ _ = dh.deleteDevicePersistencyData(ctx) //ignore possible errors here and continue, hope is that data is synchronized with new ONU-Up
//deviceEntry stop without omciCC reset here, regarding the OMCI_CC still valid for this ONU
// - in contrary to disableDevice - compare with processUniDisableStateDoneEvent
//stop the device entry which resets the attached omciCC
- pDevEntry := dh.getOnuDeviceEntry(false)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
}
- _ = pDevEntry.stop(context.TODO(), false)
+ _ = pDevEntry.stop(log.WithSpanFromContext(context.TODO(), ctx), false)
//TODO!!! remove existing traffic profiles
/* from py code, if TP's exist, remove them - not yet implemented
@@ -1431,39 +1435,39 @@
self._tech_profile_download_done[uni_id].clear()
*/
- dh.disableUniPortStateUpdate()
+ dh.disableUniPortStateUpdate(ctx)
dh.ReadyForSpecificOmciConfig = false
- if err := dh.deviceReasonUpdate(drStoppingOpenomci, true); err != nil {
+ if err := dh.deviceReasonUpdate(ctx, drStoppingOpenomci, true); err != nil {
// abort: system behavior is just unstable ...
return err
}
- logger.Debugw("call DeviceStateUpdate upon update interface", log.Fields{"ConnectStatus": voltha.ConnectStatus_UNREACHABLE,
+ logger.Debugw(ctx, "call DeviceStateUpdate upon update interface", log.Fields{"ConnectStatus": voltha.ConnectStatus_UNREACHABLE,
"OperStatus": voltha.OperStatus_DISCOVERED, "device-id": dh.deviceID})
- if err := dh.coreProxy.DeviceStateUpdate(context.TODO(), dh.deviceID,
+ if err := dh.coreProxy.DeviceStateUpdate(log.WithSpanFromContext(context.TODO(), ctx), dh.deviceID,
voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_DISCOVERED); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw("error-updating-device-state unreachable-discovered",
+ logger.Errorw(ctx, "error-updating-device-state unreachable-discovered",
log.Fields{"device-id": dh.deviceID, "error": err})
// abort: system behavior is just unstable ...
return err
}
} else {
- logger.Debugw("updateInterface - device already stopped", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "updateInterface - device already stopped", log.Fields{"device-id": dh.deviceID})
}
return nil
}
-func (dh *deviceHandler) resetFsms() error {
+func (dh *deviceHandler) resetFsms(ctx context.Context) error {
//all possible FSM's are stopped or reset here to ensure their transition to 'disabled'
//it is not sufficient to stop/reset the latest running FSM as done in previous versions
// as after down/up procedures all FSM's might be active/ongoing (in theory)
// and using the stop/reset event should never harm
- pDevEntry := dh.getOnuDeviceEntry(false)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
}
//the MibSync FSM might be active all the ONU-active time,
@@ -1512,38 +1516,38 @@
return nil
}
-func (dh *deviceHandler) processMibDatabaseSyncEvent(devEvent OnuDeviceEvent) {
- logger.Debugw("MibInSync event received, adding uni ports and locking the ONU interfaces", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) processMibDatabaseSyncEvent(ctx context.Context, devEvent OnuDeviceEvent) {
+ logger.Debugw(ctx, "MibInSync event received, adding uni ports and locking the ONU interfaces", log.Fields{"device-id": dh.deviceID})
- _ = dh.deviceReasonUpdate(drDiscoveryMibsyncComplete, !dh.reconciling)
- pDevEntry := dh.getOnuDeviceEntry(false)
+ _ = dh.deviceReasonUpdate(ctx, drDiscoveryMibsyncComplete, !dh.reconciling)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
return
}
i := uint8(0) //UNI Port limit: see MaxUnisPerOnu (by now 16) (OMCI supports max 255 p.b.)
- if unigInstKeys := pDevEntry.pOnuDB.getSortedInstKeys(me.UniGClassID); len(unigInstKeys) > 0 {
+ if unigInstKeys := pDevEntry.pOnuDB.getSortedInstKeys(ctx, me.UniGClassID); len(unigInstKeys) > 0 {
for _, mgmtEntityID := range unigInstKeys {
- logger.Debugw("Add UNI port for stored UniG instance:", log.Fields{
+ logger.Debugw(ctx, "Add UNI port for stored UniG instance:", log.Fields{
"device-id": dh.deviceID, "UnigMe EntityID": mgmtEntityID})
- dh.addUniPort(mgmtEntityID, i, uniPPTP)
+ dh.addUniPort(ctx, mgmtEntityID, i, uniPPTP)
i++
}
} else {
- logger.Debugw("No UniG instances found", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "No UniG instances found", log.Fields{"device-id": dh.deviceID})
}
- if veipInstKeys := pDevEntry.pOnuDB.getSortedInstKeys(me.VirtualEthernetInterfacePointClassID); len(veipInstKeys) > 0 {
+ if veipInstKeys := pDevEntry.pOnuDB.getSortedInstKeys(ctx, me.VirtualEthernetInterfacePointClassID); len(veipInstKeys) > 0 {
for _, mgmtEntityID := range veipInstKeys {
- logger.Debugw("Add VEIP acc. to stored VEIP instance:", log.Fields{
+ logger.Debugw(ctx, "Add VEIP acc. to stored VEIP instance:", log.Fields{
"device-id": dh.deviceID, "VEIP EntityID": mgmtEntityID})
- dh.addUniPort(mgmtEntityID, i, uniVEIP)
+ dh.addUniPort(ctx, mgmtEntityID, i, uniVEIP)
i++
}
} else {
- logger.Debugw("No VEIP instances found", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "No VEIP instances found", log.Fields{"device-id": dh.deviceID})
}
if i == 0 {
- logger.Warnw("No PPTP instances found", log.Fields{"device-id": dh.deviceID})
+ logger.Warnw(ctx, "No PPTP instances found", log.Fields{"device-id": dh.deviceID})
}
/* 200605: lock processing after initial MIBUpload removed now as the ONU should be in the lock state per default here */
/* 201117: build_dt-berlin-pod-openonugo_1T8GEM_voltha_DT_openonugo_master_test runs into error TC
@@ -1558,196 +1562,196 @@
// Init Uni Ports to Admin locked state
// *** should generate UniLockStateDone event *****
if dh.pLockStateFsm == nil {
- dh.createUniLockFsm(true, UniLockStateDone)
+ dh.createUniLockFsm(ctx, true, UniLockStateDone)
} else { //LockStateFSM already init
dh.pLockStateFsm.setSuccessEvent(UniLockStateDone)
- dh.runUniLockFsm(true)
+ dh.runUniLockFsm(ctx, true)
}
}
-func (dh *deviceHandler) processUniLockStateDoneEvent(devEvent OnuDeviceEvent) {
- logger.Infow("UniLockStateDone event: Starting MIB download", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) processUniLockStateDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
+ logger.Infow(ctx, "UniLockStateDone event: Starting MIB download", log.Fields{"device-id": dh.deviceID})
/* Mib download procedure -
***** should run over 'downloaded' state and generate MibDownloadDone event *****
*/
- pDevEntry := dh.getOnuDeviceEntry(false)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
return
}
pMibDlFsm := pDevEntry.pMibDownloadFsm.pFsm
if pMibDlFsm != nil {
if pMibDlFsm.Is(dlStDisabled) {
if err := pMibDlFsm.Event(dlEvStart); err != nil {
- logger.Errorw("MibDownloadFsm: Can't go to state starting", log.Fields{"device-id": dh.deviceID, "err": err})
+ logger.Errorw(ctx, "MibDownloadFsm: Can't go to state starting", log.Fields{"device-id": dh.deviceID, "err": err})
// maybe try a FSM reset and then again ... - TODO!!!
} else {
- logger.Debugw("MibDownloadFsm", log.Fields{"state": string(pMibDlFsm.Current())})
+ logger.Debugw(ctx, "MibDownloadFsm", log.Fields{"state": string(pMibDlFsm.Current())})
// maybe use more specific states here for the specific download steps ...
if err := pMibDlFsm.Event(dlEvCreateGal); err != nil {
- logger.Errorw("MibDownloadFsm: Can't start CreateGal", log.Fields{"device-id": dh.deviceID, "err": err})
+ logger.Errorw(ctx, "MibDownloadFsm: Can't start CreateGal", log.Fields{"device-id": dh.deviceID, "err": err})
} else {
- logger.Debugw("state of MibDownloadFsm", log.Fields{"state": string(pMibDlFsm.Current())})
+ logger.Debugw(ctx, "state of MibDownloadFsm", log.Fields{"state": string(pMibDlFsm.Current())})
//Begin MIB data download (running autonomously)
}
}
} else {
- logger.Errorw("wrong state of MibDownloadFsm - want: disabled", log.Fields{"have": string(pMibDlFsm.Current()),
+ logger.Errorw(ctx, "wrong state of MibDownloadFsm - want: disabled", log.Fields{"have": string(pMibDlFsm.Current()),
"device-id": dh.deviceID})
// maybe try a FSM reset and then again ... - TODO!!!
}
/***** Mib download started */
} else {
- logger.Errorw("MibDownloadFsm invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "MibDownloadFsm invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
}
}
-func (dh *deviceHandler) processMibDownloadDoneEvent(devEvent OnuDeviceEvent) {
- logger.Debugw("MibDownloadDone event received, unlocking the ONU interfaces", log.Fields{"device-id": dh.deviceID})
+func (dh *deviceHandler) processMibDownloadDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
+ logger.Debugw(ctx, "MibDownloadDone event received, unlocking the ONU interfaces", log.Fields{"device-id": dh.deviceID})
//initiate DevStateUpdate
if !dh.reconciling {
- logger.Debugw("call DeviceStateUpdate upon mib-download done", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
+ logger.Debugw(ctx, "call DeviceStateUpdate upon mib-download done", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
"OperStatus": voltha.OperStatus_ACTIVE, "device-id": dh.deviceID})
- if err := dh.coreProxy.DeviceStateUpdate(context.TODO(), dh.deviceID,
+ if err := dh.coreProxy.DeviceStateUpdate(log.WithSpanFromContext(context.TODO(), ctx), dh.deviceID,
voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw("error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
} else {
- logger.Debugw("dev state updated to 'Oper.Active'", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "dev state updated to 'Oper.Active'", log.Fields{"device-id": dh.deviceID})
}
} else {
- pDevEntry := dh.getOnuDeviceEntry(false)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
return
}
if pDevEntry.sOnuPersistentData.PersUniDisableDone {
- logger.Debugw("reconciling - uni-ports were disabled by admin before adapter restart - keep the ports locked and wait for re-enabling",
+ logger.Debugw(ctx, "reconciling - uni-ports were disabled by admin before adapter restart - keep the ports locked and wait for re-enabling",
log.Fields{"device-id": dh.deviceID})
dh.reconciling = false
return
}
- logger.Debugw("reconciling - don't notify core about DeviceStateUpdate to ACTIVE",
+ logger.Debugw(ctx, "reconciling - don't notify core about DeviceStateUpdate to ACTIVE",
log.Fields{"device-id": dh.deviceID})
}
- _ = dh.deviceReasonUpdate(drInitialMibDownloaded, !dh.reconciling)
+ _ = dh.deviceReasonUpdate(ctx, drInitialMibDownloaded, !dh.reconciling)
dh.ReadyForSpecificOmciConfig = true
// *** should generate UniUnlockStateDone event *****
if dh.pUnlockStateFsm == nil {
- dh.createUniLockFsm(false, UniUnlockStateDone)
+ dh.createUniLockFsm(ctx, false, UniUnlockStateDone)
} else { //UnlockStateFSM already init
dh.pUnlockStateFsm.setSuccessEvent(UniUnlockStateDone)
- dh.runUniLockFsm(false)
+ dh.runUniLockFsm(ctx, false)
}
}
-func (dh *deviceHandler) processUniUnlockStateDoneEvent(devEvent OnuDeviceEvent) {
- dh.enableUniPortStateUpdate() //cmp python yield self.enable_ports()
+func (dh *deviceHandler) processUniUnlockStateDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
+ dh.enableUniPortStateUpdate(ctx) //cmp python yield self.enable_ports()
if !dh.reconciling {
- logger.Infow("UniUnlockStateDone event: Sending OnuUp event", log.Fields{"device-id": dh.deviceID})
+ logger.Infow(ctx, "UniUnlockStateDone event: Sending OnuUp event", log.Fields{"device-id": dh.deviceID})
raisedTs := time.Now().UnixNano()
- go dh.sendOnuOperStateEvent(voltha.OperStatus_ACTIVE, dh.deviceID, raisedTs) //cmp python onu_active_event
- pDevEntry := dh.getOnuDeviceEntry(false)
+ go dh.sendOnuOperStateEvent(ctx, voltha.OperStatus_ACTIVE, dh.deviceID, raisedTs) //cmp python onu_active_event
+ pDevEntry := dh.getOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
return
}
pDevEntry.sOnuPersistentData.PersUniUnlockDone = true
- if err := dh.storePersistentData(); err != nil {
- logger.Warnw("store persistent data error - continue for now as there will be additional write attempts",
+ if err := dh.storePersistentData(ctx); err != nil {
+ logger.Warnw(ctx, "store persistent data error - continue for now as there will be additional write attempts",
log.Fields{"device-id": dh.deviceID, "err": err})
}
} else {
- logger.Debugw("reconciling - don't notify core that onu went to active but trigger tech profile config",
+ logger.Debugw(ctx, "reconciling - don't notify core that onu went to active but trigger tech profile config",
log.Fields{"device-id": dh.deviceID})
- go dh.reconcileDeviceTechProf()
+ go dh.reconcileDeviceTechProf(ctx)
// reconcilement will be continued after ani config is done
}
}
-func (dh *deviceHandler) processUniDisableStateDoneEvent(devEvent OnuDeviceEvent) {
- logger.Debugw("DeviceStateUpdate upon disable", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
+func (dh *deviceHandler) processUniDisableStateDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
+ logger.Debugw(ctx, "DeviceStateUpdate upon disable", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
"OperStatus": voltha.OperStatus_UNKNOWN, "device-id": dh.deviceID})
- if err := dh.coreProxy.DeviceStateUpdate(context.TODO(),
+ if err := dh.coreProxy.DeviceStateUpdate(log.WithSpanFromContext(context.TODO(), ctx),
dh.deviceID, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_UNKNOWN); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw("error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
}
- logger.Debugw("DeviceReasonUpdate upon disable", log.Fields{"reason": deviceReasonMap[drOmciAdminLock], "device-id": dh.deviceID})
+ logger.Debugw(ctx, "DeviceReasonUpdate upon disable", log.Fields{"reason": deviceReasonMap[drOmciAdminLock], "device-id": dh.deviceID})
// DeviceReason to update acc.to modified py code as per beginning of Sept 2020
- _ = dh.deviceReasonUpdate(drOmciAdminLock, true)
+ _ = dh.deviceReasonUpdate(ctx, drOmciAdminLock, true)
//transfer the modified logical uni port state
- dh.disableUniPortStateUpdate()
+ dh.disableUniPortStateUpdate(ctx)
- pDevEntry := dh.getOnuDeviceEntry(false)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
return
}
pDevEntry.sOnuPersistentData.PersUniDisableDone = true
- if err := dh.storePersistentData(); err != nil {
- logger.Warnw("store persistent data error - continue for now as there will be additional write attempts",
+ if err := dh.storePersistentData(ctx); err != nil {
+ logger.Warnw(ctx, "store persistent data error - continue for now as there will be additional write attempts",
log.Fields{"device-id": dh.deviceID, "err": err})
}
}
-func (dh *deviceHandler) processUniEnableStateDoneEvent(devEvent OnuDeviceEvent) {
- logger.Debugw("DeviceStateUpdate upon re-enable", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
+func (dh *deviceHandler) processUniEnableStateDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
+ logger.Debugw(ctx, "DeviceStateUpdate upon re-enable", log.Fields{"ConnectStatus": voltha.ConnectStatus_REACHABLE,
"OperStatus": voltha.OperStatus_ACTIVE, "device-id": dh.deviceID})
- if err := dh.coreProxy.DeviceStateUpdate(context.TODO(), dh.deviceID, voltha.ConnectStatus_REACHABLE,
+ if err := dh.coreProxy.DeviceStateUpdate(log.WithSpanFromContext(context.TODO(), ctx), dh.deviceID, voltha.ConnectStatus_REACHABLE,
voltha.OperStatus_ACTIVE); err != nil {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing
- logger.Errorw("error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
+ logger.Errorw(ctx, "error-updating-device-state", log.Fields{"device-id": dh.deviceID, "error": err})
}
- logger.Debugw("DeviceReasonUpdate upon re-enable", log.Fields{
+ logger.Debugw(ctx, "DeviceReasonUpdate upon re-enable", log.Fields{
"reason": deviceReasonMap[drOnuReenabled], "device-id": dh.deviceID})
// DeviceReason to update acc.to modified py code as per beginning of Sept 2020
- _ = dh.deviceReasonUpdate(drOnuReenabled, true)
+ _ = dh.deviceReasonUpdate(ctx, drOnuReenabled, true)
//transfer the modified logical uni port state
- dh.enableUniPortStateUpdate()
+ dh.enableUniPortStateUpdate(ctx)
- pDevEntry := dh.getOnuDeviceEntry(false)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
return
}
pDevEntry.sOnuPersistentData.PersUniDisableDone = false
- if err := dh.storePersistentData(); err != nil {
- logger.Warnw("store persistent data error - continue for now as there will be additional write attempts",
+ if err := dh.storePersistentData(ctx); err != nil {
+ logger.Warnw(ctx, "store persistent data error - continue for now as there will be additional write attempts",
log.Fields{"device-id": dh.deviceID, "err": err})
}
}
-func (dh *deviceHandler) processOmciAniConfigDoneEvent(devEvent OnuDeviceEvent) {
+func (dh *deviceHandler) processOmciAniConfigDoneEvent(ctx context.Context, devEvent OnuDeviceEvent) {
if devEvent == OmciAniConfigDone {
- logger.Debugw("OmciAniConfigDone event received", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "OmciAniConfigDone event received", log.Fields{"device-id": dh.deviceID})
// attention: the device reason update is done based on ONU-UNI-Port related activity
// - which may cause some inconsistency
if dh.deviceReason != drTechProfileConfigDownloadSuccess {
// which may be the case from some previous actvity even on this UNI Port (but also other UNI ports)
- _ = dh.deviceReasonUpdate(drTechProfileConfigDownloadSuccess, !dh.reconciling)
+ _ = dh.deviceReasonUpdate(ctx, drTechProfileConfigDownloadSuccess, !dh.reconciling)
}
if dh.reconciling {
- go dh.reconcileDeviceFlowConfig()
+ go dh.reconcileDeviceFlowConfig(ctx)
}
} else { // should be the OmciAniResourceRemoved block
- logger.Debugw("OmciAniResourceRemoved event received", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "OmciAniResourceRemoved event received", log.Fields{"device-id": dh.deviceID})
// attention: the device reason update is done based on ONU-UNI-Port related activity
// - which may cause some inconsistency
if dh.deviceReason != drTechProfileConfigDeleteSuccess {
// which may be the case from some previous actvity even on this ONU port (but also other UNI ports)
- _ = dh.deviceReasonUpdate(drTechProfileConfigDeleteSuccess, true)
+ _ = dh.deviceReasonUpdate(ctx, drTechProfileConfigDeleteSuccess, true)
}
}
}
-func (dh *deviceHandler) processOmciVlanFilterDoneEvent(aDevEvent OnuDeviceEvent) {
- logger.Debugw("OmciVlanFilterDone event received",
+func (dh *deviceHandler) processOmciVlanFilterDoneEvent(ctx context.Context, aDevEvent OnuDeviceEvent) {
+ logger.Debugw(ctx, "OmciVlanFilterDone event received",
log.Fields{"device-id": dh.deviceID, "event": aDevEvent})
// attention: the device reason update is done based on ONU-UNI-Port related activity
// - which may cause some inconsistency
@@ -1756,89 +1760,89 @@
if dh.deviceReason != drOmciFlowsPushed {
// which may be the case from some previous actvity on another UNI Port of the ONU
// or even some previous flow add activity on the same port
- _ = dh.deviceReasonUpdate(drOmciFlowsPushed, !dh.reconciling)
+ _ = dh.deviceReasonUpdate(ctx, drOmciFlowsPushed, !dh.reconciling)
if dh.reconciling {
- go dh.reconcileMetrics()
+ go dh.reconcileMetrics(ctx)
}
}
} else {
if dh.deviceReason != drOmciFlowsDeleted {
//not relevant for reconcile
- _ = dh.deviceReasonUpdate(drOmciFlowsDeleted, true)
+ _ = dh.deviceReasonUpdate(ctx, drOmciFlowsDeleted, true)
}
}
}
//deviceProcStatusUpdate evaluates possible processing events and initiates according next activities
-func (dh *deviceHandler) deviceProcStatusUpdate(devEvent OnuDeviceEvent) {
+func (dh *deviceHandler) deviceProcStatusUpdate(ctx context.Context, devEvent OnuDeviceEvent) {
switch devEvent {
case MibDatabaseSync:
{
- dh.processMibDatabaseSyncEvent(devEvent)
+ dh.processMibDatabaseSyncEvent(ctx, devEvent)
}
case UniLockStateDone:
{
- dh.processUniLockStateDoneEvent(devEvent)
+ dh.processUniLockStateDoneEvent(ctx, devEvent)
}
case MibDownloadDone:
{
- dh.processMibDownloadDoneEvent(devEvent)
+ dh.processMibDownloadDoneEvent(ctx, devEvent)
}
case UniUnlockStateDone:
{
- dh.processUniUnlockStateDoneEvent(devEvent)
+ dh.processUniUnlockStateDoneEvent(ctx, devEvent)
}
case UniEnableStateDone:
{
- dh.processUniEnableStateDoneEvent(devEvent)
+ dh.processUniEnableStateDoneEvent(ctx, devEvent)
}
case UniDisableStateDone:
{
- dh.processUniDisableStateDoneEvent(devEvent)
+ dh.processUniDisableStateDoneEvent(ctx, devEvent)
}
case OmciAniConfigDone, OmciAniResourceRemoved:
{
- dh.processOmciAniConfigDoneEvent(devEvent)
+ dh.processOmciAniConfigDoneEvent(ctx, devEvent)
}
case OmciVlanFilterAddDone, OmciVlanFilterRemDone:
{
- dh.processOmciVlanFilterDoneEvent(devEvent)
+ dh.processOmciVlanFilterDoneEvent(ctx, devEvent)
}
default:
{
- logger.Debugw("unhandled-device-event", log.Fields{"device-id": dh.deviceID, "event": devEvent})
+ logger.Debugw(ctx, "unhandled-device-event", log.Fields{"device-id": dh.deviceID, "event": devEvent})
}
} //switch
}
-func (dh *deviceHandler) addUniPort(aUniInstNo uint16, aUniID uint8, aPortType uniPortType) {
+func (dh *deviceHandler) addUniPort(ctx context.Context, aUniInstNo uint16, aUniID uint8, aPortType uniPortType) {
// parameters are IntfId, OnuId, uniId
- uniNo := mkUniPortNum(dh.pOnuIndication.GetIntfId(), dh.pOnuIndication.GetOnuId(),
+ uniNo := mkUniPortNum(ctx, dh.pOnuIndication.GetIntfId(), dh.pOnuIndication.GetOnuId(),
uint32(aUniID))
if _, present := dh.uniEntityMap[uniNo]; present {
- logger.Warnw("onuUniPort-add: Port already exists", log.Fields{"for InstanceId": aUniInstNo})
+ logger.Warnw(ctx, "onuUniPort-add: Port already exists", log.Fields{"for InstanceId": aUniInstNo})
} else {
//with arguments aUniID, a_portNo, aPortType
- pUniPort := newOnuUniPort(aUniID, uniNo, aUniInstNo, aPortType)
+ pUniPort := newOnuUniPort(ctx, aUniID, uniNo, aUniInstNo, aPortType)
if pUniPort == nil {
- logger.Warnw("onuUniPort-add: Could not create Port", log.Fields{"for InstanceId": aUniInstNo})
+ logger.Warnw(ctx, "onuUniPort-add: Could not create Port", log.Fields{"for InstanceId": aUniInstNo})
} else {
//store UniPort with the System-PortNumber key
dh.uniEntityMap[uniNo] = pUniPort
if !dh.reconciling {
// create announce the UniPort to the core as VOLTHA Port object
- if err := pUniPort.createVolthaPort(dh); err == nil {
- logger.Infow("onuUniPort-added", log.Fields{"for PortNo": uniNo})
+ if err := pUniPort.createVolthaPort(ctx, dh); err == nil {
+ logger.Infow(ctx, "onuUniPort-added", log.Fields{"for PortNo": uniNo})
} //error logging already within UniPort method
} else {
- logger.Debugw("reconciling - onuUniPort already added", log.Fields{"for PortNo": uniNo, "device-id": dh.deviceID})
+ logger.Debugw(ctx, "reconciling - onuUniPort already added", log.Fields{"for PortNo": uniNo, "device-id": dh.deviceID})
}
}
}
}
// enableUniPortStateUpdate enables UniPortState and update core port state accordingly
-func (dh *deviceHandler) enableUniPortStateUpdate() {
+func (dh *deviceHandler) enableUniPortStateUpdate(ctx context.Context) {
// py code was updated 2003xx to activate the real ONU UNI ports per OMCI (VEIP or PPTP)
// but towards core only the first port active state is signaled
// with following remark:
@@ -1850,44 +1854,44 @@
for uniNo, uniPort := range dh.uniEntityMap {
// only if this port is validated for operState transfer
if (1<<uniPort.uniID)&activeUniPortStateUpdateMask == (1 << uniPort.uniID) {
- logger.Infow("onuUniPort-forced-OperState-ACTIVE", log.Fields{"for PortNo": uniNo})
+ logger.Infow(ctx, "onuUniPort-forced-OperState-ACTIVE", log.Fields{"for PortNo": uniNo})
uniPort.setOperState(vc.OperStatus_ACTIVE)
if !dh.reconciling {
//maybe also use getter functions on uniPort - perhaps later ...
- go dh.coreProxy.PortStateUpdate(context.TODO(), dh.deviceID, voltha.Port_ETHERNET_UNI, uniPort.portNo, uniPort.operState)
+ go dh.coreProxy.PortStateUpdate(log.WithSpanFromContext(context.TODO(), ctx), dh.deviceID, voltha.Port_ETHERNET_UNI, uniPort.portNo, uniPort.operState)
} else {
//TODO there is no retry mechanism, return error
- logger.Debugw("reconciling - don't notify core about PortStateUpdate", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "reconciling - don't notify core about PortStateUpdate", log.Fields{"device-id": dh.deviceID})
}
}
}
}
// Disable UniPortState and update core port state accordingly
-func (dh *deviceHandler) disableUniPortStateUpdate() {
+func (dh *deviceHandler) disableUniPortStateUpdate(ctx context.Context) {
// compare enableUniPortStateUpdate() above
// -> use current restriction to operate only on first UNI port as inherited from actual Py code
for uniNo, uniPort := range dh.uniEntityMap {
// only if this port is validated for operState transfer
if (1<<uniPort.uniID)&activeUniPortStateUpdateMask == (1 << uniPort.uniID) {
- logger.Infow("onuUniPort-forced-OperState-UNKNOWN", log.Fields{"for PortNo": uniNo})
+ logger.Infow(ctx, "onuUniPort-forced-OperState-UNKNOWN", log.Fields{"for PortNo": uniNo})
uniPort.setOperState(vc.OperStatus_UNKNOWN)
//maybe also use getter functions on uniPort - perhaps later ...
- go dh.coreProxy.PortStateUpdate(context.TODO(), dh.deviceID, voltha.Port_ETHERNET_UNI, uniPort.portNo, uniPort.operState)
+ go dh.coreProxy.PortStateUpdate(log.WithSpanFromContext(context.TODO(), ctx), dh.deviceID, voltha.Port_ETHERNET_UNI, uniPort.portNo, uniPort.operState)
}
}
}
// ONU_Active/Inactive announcement on system KAFKA bus
// tried to re-use procedure of oltUpDownIndication from openolt_eventmgr.go with used values from Py code
-func (dh *deviceHandler) sendOnuOperStateEvent(aOperState vc.OperStatus_Types, aDeviceID string, raisedTs int64) {
+func (dh *deviceHandler) sendOnuOperStateEvent(ctx context.Context, aOperState vc.OperStatus_Types, aDeviceID string, raisedTs int64) {
var de voltha.DeviceEvent
eventContext := make(map[string]string)
//Populating event context
// assume giving ParentId in GetDevice twice really gives the ParentDevice (there is no GetParentDevice()...)
- parentDevice, err := dh.coreProxy.GetDevice(context.TODO(), dh.parentID, dh.parentID)
+ parentDevice, err := dh.coreProxy.GetDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.parentID, dh.parentID)
if err != nil || parentDevice == nil {
- logger.Errorw("Failed to fetch parent device for OnuEvent",
+ logger.Errorw(ctx, "Failed to fetch parent device for OnuEvent",
log.Fields{"parentID": dh.parentID, "err": err})
}
oltSerialNumber := parentDevice.SerialNumber
@@ -1898,7 +1902,7 @@
eventContext["olt_serial_number"] = oltSerialNumber
eventContext["device_id"] = aDeviceID
eventContext["registration_id"] = aDeviceID //py: string(device_id)??
- logger.Debugw("prepare ONU_ACTIVATED event",
+ logger.Debugw(ctx, "prepare ONU_ACTIVATED event",
log.Fields{"device-id": aDeviceID, "EventContext": eventContext})
/* Populating device event body */
@@ -1914,32 +1918,32 @@
cEventObjectType, cOnuActivatedEvent, "Cleared")
}
/* Send event to KAFKA */
- if err := dh.EventProxy.SendDeviceEvent(&de, equipment, pon, raisedTs); err != nil {
- logger.Warnw("could not send ONU_ACTIVATED event",
+ if err := dh.EventProxy.SendDeviceEvent(ctx, &de, equipment, pon, raisedTs); err != nil {
+ logger.Warnw(ctx, "could not send ONU_ACTIVATED event",
log.Fields{"device-id": aDeviceID, "error": err})
}
- logger.Debugw("ONU_ACTIVATED event sent to KAFKA",
+ logger.Debugw(ctx, "ctx, ONU_ACTIVATED event sent to KAFKA",
log.Fields{"device-id": aDeviceID, "with-EventName": de.DeviceEventName})
}
// createUniLockFsm initializes and runs the UniLock FSM to transfer the OMCI related commands for port lock/unlock
-func (dh *deviceHandler) createUniLockFsm(aAdminState bool, devEvent OnuDeviceEvent) {
+func (dh *deviceHandler) createUniLockFsm(ctx context.Context, aAdminState bool, devEvent OnuDeviceEvent) {
chLSFsm := make(chan Message, 2048)
var sFsmName string
if aAdminState {
- logger.Debugw("createLockStateFSM", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "createLockStateFSM", log.Fields{"device-id": dh.deviceID})
sFsmName = "LockStateFSM"
} else {
- logger.Debugw("createUnlockStateFSM", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "createUnlockStateFSM", log.Fields{"device-id": dh.deviceID})
sFsmName = "UnLockStateFSM"
}
- pDevEntry := dh.getOnuDeviceEntry(true)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
return
}
- pLSFsm := newLockStateFsm(pDevEntry.PDevOmciCC, aAdminState, devEvent,
+ pLSFsm := newLockStateFsm(ctx, pDevEntry.PDevOmciCC, aAdminState, devEvent,
sFsmName, dh, chLSFsm)
if pLSFsm != nil {
if aAdminState {
@@ -1947,14 +1951,14 @@
} else {
dh.pUnlockStateFsm = pLSFsm
}
- dh.runUniLockFsm(aAdminState)
+ dh.runUniLockFsm(ctx, aAdminState)
} else {
- logger.Errorw("LockStateFSM could not be created - abort!!", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "LockStateFSM could not be created - abort!!", log.Fields{"device-id": dh.deviceID})
}
}
// runUniLockFsm starts the UniLock FSM to transfer the OMCI related commands for port lock/unlock
-func (dh *deviceHandler) runUniLockFsm(aAdminState bool) {
+func (dh *deviceHandler) runUniLockFsm(ctx context.Context, aAdminState bool) {
/* Uni Port lock/unlock procedure -
***** should run via 'adminDone' state and generate the argument requested event *****
*/
@@ -1977,28 +1981,28 @@
if pLSStatemachine != nil {
if pLSStatemachine.Is(uniStDisabled) {
if err := pLSStatemachine.Event(uniEvStart); err != nil {
- logger.Warnw("LockStateFSM: can't start", log.Fields{"err": err})
+ logger.Warnw(ctx, "LockStateFSM: can't start", log.Fields{"err": err})
// maybe try a FSM reset and then again ... - TODO!!!
} else {
/***** LockStateFSM started */
- logger.Debugw("LockStateFSM started", log.Fields{
+ logger.Debugw(ctx, "LockStateFSM started", log.Fields{
"state": pLSStatemachine.Current(), "device-id": dh.deviceID})
}
} else {
- logger.Warnw("wrong state of LockStateFSM - want: disabled", log.Fields{
+ logger.Warnw(ctx, "wrong state of LockStateFSM - want: disabled", log.Fields{
"have": pLSStatemachine.Current(), "device-id": dh.deviceID})
// maybe try a FSM reset and then again ... - TODO!!!
}
} else {
- logger.Errorw("LockStateFSM StateMachine invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "LockStateFSM StateMachine invalid - cannot be executed!!", log.Fields{"device-id": dh.deviceID})
// maybe try a FSM reset and then again ... - TODO!!!
}
}
//setBackend provides a DB backend for the specified path on the existing KV client
-func (dh *deviceHandler) setBackend(aBasePathKvStore string) *db.Backend {
+func (dh *deviceHandler) setBackend(ctx context.Context, aBasePathKvStore string) *db.Backend {
addr := dh.pOpenOnuAc.KVStoreHost + ":" + strconv.Itoa(dh.pOpenOnuAc.KVStorePort)
- logger.Debugw("SetKVStoreBackend", log.Fields{"IpTarget": addr,
+ logger.Debugw(ctx, "SetKVStoreBackend", log.Fields{"IpTarget": addr,
"BasePathKvStore": aBasePathKvStore, "device-id": dh.deviceID})
kvbackend := &db.Backend{
Client: dh.pOpenOnuAc.kvClient,
@@ -2010,14 +2014,14 @@
return kvbackend
}
-func (dh *deviceHandler) getFlowOfbFields(apFlowItem *ofp.OfpFlowStats, loMatchVlan *uint16,
+func (dh *deviceHandler) getFlowOfbFields(ctx context.Context, apFlowItem *ofp.OfpFlowStats, loMatchVlan *uint16,
loAddPcp *uint8, loIPProto *uint32) {
for _, field := range flow.GetOfbFields(apFlowItem) {
switch field.Type {
case of.OxmOfbFieldTypes_OFPXMT_OFB_ETH_TYPE:
{
- logger.Debugw("flow type EthType", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow type EthType", log.Fields{"device-id": dh.deviceID,
"EthType": strconv.FormatInt(int64(field.GetEthType()), 16)})
}
/* TT related temporary workaround - should not be needed anymore
@@ -2043,38 +2047,38 @@
loMatchVlanMask == uint16(of.OfpVlanId_OFPVID_PRESENT)) {
*loMatchVlan = *loMatchVlan & 0xFFF // not transparent: copy only ID bits
}
- logger.Debugw("flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
"VID": strconv.FormatInt(int64(*loMatchVlan), 16)})
}
case of.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_PCP:
{
*loAddPcp = uint8(field.GetVlanPcp())
- logger.Debugw("flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
"PCP": loAddPcp})
}
case of.OxmOfbFieldTypes_OFPXMT_OFB_UDP_DST:
{
- logger.Debugw("flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
"UDP-DST": strconv.FormatInt(int64(field.GetUdpDst()), 16)})
}
case of.OxmOfbFieldTypes_OFPXMT_OFB_UDP_SRC:
{
- logger.Debugw("flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
"UDP-SRC": strconv.FormatInt(int64(field.GetUdpSrc()), 16)})
}
case of.OxmOfbFieldTypes_OFPXMT_OFB_IPV4_DST:
{
- logger.Debugw("flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
"IPv4-DST": field.GetIpv4Dst()})
}
case of.OxmOfbFieldTypes_OFPXMT_OFB_IPV4_SRC:
{
- logger.Debugw("flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
"IPv4-SRC": field.GetIpv4Src()})
}
case of.OxmOfbFieldTypes_OFPXMT_OFB_METADATA:
{
- logger.Debugw("flow field type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow field type", log.Fields{"device-id": dh.deviceID,
"Metadata": field.GetTableMetadata()})
}
/*
@@ -2087,7 +2091,7 @@
} //for all OfbFields
}
-func (dh *deviceHandler) getFlowActions(apFlowItem *ofp.OfpFlowStats, loSetPcp *uint8, loSetVlan *uint16) {
+func (dh *deviceHandler) getFlowActions(ctx context.Context, apFlowItem *ofp.OfpFlowStats, loSetPcp *uint8, loSetVlan *uint16) {
for _, action := range flow.GetActions(apFlowItem) {
switch action.Type {
/* not used:
@@ -2099,26 +2103,26 @@
*/
case of.OfpActionType_OFPAT_PUSH_VLAN:
{
- logger.Debugw("flow action type", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow action type", log.Fields{"device-id": dh.deviceID,
"PushEthType": strconv.FormatInt(int64(action.GetPush().Ethertype), 16)})
}
case of.OfpActionType_OFPAT_SET_FIELD:
{
pActionSetField := action.GetSetField()
if pActionSetField.Field.OxmClass != of.OfpOxmClass_OFPXMC_OPENFLOW_BASIC {
- logger.Warnw("flow action SetField invalid OxmClass (ignored)", log.Fields{"device-id": dh.deviceID,
+ logger.Warnw(ctx, "flow action SetField invalid OxmClass (ignored)", log.Fields{"device-id": dh.deviceID,
"OxcmClass": pActionSetField.Field.OxmClass})
}
if pActionSetField.Field.GetOfbField().Type == of.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_VID {
*loSetVlan = uint16(pActionSetField.Field.GetOfbField().GetVlanVid())
- logger.Debugw("flow Set VLAN from SetField action", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow Set VLAN from SetField action", log.Fields{"device-id": dh.deviceID,
"SetVlan": strconv.FormatInt(int64(*loSetVlan), 16)})
} else if pActionSetField.Field.GetOfbField().Type == of.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_PCP {
*loSetPcp = uint8(pActionSetField.Field.GetOfbField().GetVlanPcp())
- logger.Debugw("flow Set PCP from SetField action", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow Set PCP from SetField action", log.Fields{"device-id": dh.deviceID,
"SetPcp": *loSetPcp})
} else {
- logger.Warnw("flow action SetField invalid FieldType", log.Fields{"device-id": dh.deviceID,
+ logger.Warnw(ctx, "flow action SetField invalid FieldType", log.Fields{"device-id": dh.deviceID,
"Type": pActionSetField.Field.GetOfbField().Type})
}
}
@@ -2133,7 +2137,7 @@
}
//addFlowItemToUniPort parses the actual flow item to add it to the UniPort
-func (dh *deviceHandler) addFlowItemToUniPort(apFlowItem *ofp.OfpFlowStats, apUniPort *onuUniPort) error {
+func (dh *deviceHandler) addFlowItemToUniPort(ctx context.Context, apFlowItem *ofp.OfpFlowStats, apUniPort *onuUniPort) error {
var loSetVlan uint16 = uint16(of.OfpVlanId_OFPVID_NONE) //noValidEntry
var loMatchVlan uint16 = uint16(of.OfpVlanId_OFPVID_PRESENT) //reserved VLANID entry
var loAddPcp, loSetPcp uint8
@@ -2148,19 +2152,19 @@
* subscriber related flows.
*/
- metadata := flow.GetMetadataFromWriteMetadataAction(apFlowItem)
+ metadata := flow.GetMetadataFromWriteMetadataAction(ctx, apFlowItem)
if metadata == 0 {
- logger.Debugw("flow-add invalid metadata - abort",
+ logger.Debugw(ctx, "flow-add invalid metadata - abort",
log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("flow-add invalid metadata: %s", dh.deviceID)
}
- loTpID := flow.GetTechProfileIDFromWriteMetaData(metadata)
+ loTpID := flow.GetTechProfileIDFromWriteMetaData(ctx, metadata)
loCookie := apFlowItem.GetCookie()
loCookieSlice := []uint64{loCookie}
- logger.Debugw("flow-add base indications", log.Fields{"device-id": dh.deviceID,
+ logger.Debugw(ctx, "flow-add base indications", log.Fields{"device-id": dh.deviceID,
"TechProf-Id": loTpID, "cookie": loCookie})
- dh.getFlowOfbFields(apFlowItem, &loMatchVlan, &loAddPcp, &loIPProto)
+ dh.getFlowOfbFields(ctx, apFlowItem, &loMatchVlan, &loAddPcp, &loIPProto)
/* TT related temporary workaround - should not be needed anymore
if loIPProto == 2 {
// some workaround for TT workflow at proto == 2 (IGMP trap) -> ignore the flow
@@ -2170,10 +2174,10 @@
return nil
}
*/
- dh.getFlowActions(apFlowItem, &loSetPcp, &loSetVlan)
+ dh.getFlowActions(ctx, apFlowItem, &loSetPcp, &loSetVlan)
if loSetVlan == uint16(of.OfpVlanId_OFPVID_NONE) && loMatchVlan != uint16(of.OfpVlanId_OFPVID_PRESENT) {
- logger.Errorw("flow-add aborted - SetVlanId undefined, but MatchVid set", log.Fields{
+ logger.Errorw(ctx, "flow-add aborted - SetVlanId undefined, but MatchVid set", log.Fields{
"device-id": dh.deviceID, "UniPort": apUniPort.portNo,
"set_vid": strconv.FormatInt(int64(loSetVlan), 16),
"match_vid": strconv.FormatInt(int64(loMatchVlan), 16)})
@@ -2182,7 +2186,7 @@
return fmt.Errorf("flow-add Set/Match VlanId inconsistent: %s", dh.deviceID)
}
if loSetVlan == uint16(of.OfpVlanId_OFPVID_NONE) && loMatchVlan == uint16(of.OfpVlanId_OFPVID_PRESENT) {
- logger.Debugw("flow-add vlan-any/copy", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "flow-add vlan-any/copy", log.Fields{"device-id": dh.deviceID})
loSetVlan = loMatchVlan //both 'transparent' (copy any)
} else {
//looks like OMCI value 4097 (copyFromOuter - for Uni double tagged) is not supported here
@@ -2190,18 +2194,18 @@
// not set to transparent
loSetVlan &= 0x0FFF //mask VID bits as prerequisite for vlanConfigFsm
}
- logger.Debugw("flow-add vlan-set", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "flow-add vlan-set", log.Fields{"device-id": dh.deviceID})
}
if _, exist := dh.UniVlanConfigFsmMap[apUniPort.uniID]; exist {
- return dh.UniVlanConfigFsmMap[apUniPort.uniID].SetUniFlowParams(loTpID, loCookieSlice,
+ return dh.UniVlanConfigFsmMap[apUniPort.uniID].SetUniFlowParams(ctx, loTpID, loCookieSlice,
loMatchVlan, loSetVlan, loSetPcp)
}
- return dh.createVlanFilterFsm(apUniPort, loTpID, loCookieSlice,
+ return dh.createVlanFilterFsm(ctx, apUniPort, loTpID, loCookieSlice,
loMatchVlan, loSetVlan, loSetPcp, OmciVlanFilterAddDone)
}
//removeFlowItemFromUniPort parses the actual flow item to remove it from the UniPort
-func (dh *deviceHandler) removeFlowItemFromUniPort(apFlowItem *ofp.OfpFlowStats, apUniPort *onuUniPort) error {
+func (dh *deviceHandler) removeFlowItemFromUniPort(ctx context.Context, apFlowItem *ofp.OfpFlowStats, apUniPort *onuUniPort) error {
//optimization and assumption: the flow cookie uniquely identifies the flow and with that the internal rule
//hence only the cookie is used here to find the relevant flow and possibly remove the rule
//no extra check is done on the rule parameters
@@ -2211,7 +2215,7 @@
// from addFlow - where at reconcilement multiple cookies per flow ) can be configured in one sequence)
// - some possible 'delete-all' sequence would have to be implemented separately (where the cookies are don't care anyway)
loCookie := apFlowItem.GetCookie()
- logger.Debugw("flow-remove base indications", log.Fields{"device-id": dh.deviceID, "cookie": loCookie})
+ logger.Debugw(ctx, "flow-remove base indications", log.Fields{"device-id": dh.deviceID, "cookie": loCookie})
/* TT related temporary workaround - should not be needed anymore
for _, field := range flow.GetOfbFields(apFlowItem) {
@@ -2230,29 +2234,29 @@
*/
if _, exist := dh.UniVlanConfigFsmMap[apUniPort.uniID]; exist {
- return dh.UniVlanConfigFsmMap[apUniPort.uniID].RemoveUniFlowParams(loCookie)
+ return dh.UniVlanConfigFsmMap[apUniPort.uniID].RemoveUniFlowParams(ctx, loCookie)
}
- logger.Debugw("flow-remove called, but no flow is configured (no VlanConfigFsm, flow already removed) ",
+ logger.Debugw(ctx, "flow-remove called, but no flow is configured (no VlanConfigFsm, flow already removed) ",
log.Fields{"device-id": dh.deviceID})
//but as we regard the flow as not existing = removed we respond just ok
// and treat the reason accordingly (which in the normal removal procedure is initiated by the FSM)
- go dh.deviceProcStatusUpdate(OmciVlanFilterRemDone)
+ go dh.deviceProcStatusUpdate(ctx, OmciVlanFilterRemDone)
return nil
}
// createVlanFilterFsm initializes and runs the VlanFilter FSM to transfer OMCI related VLAN config
-func (dh *deviceHandler) createVlanFilterFsm(apUniPort *onuUniPort, aTpID uint16, aCookieSlice []uint64,
+func (dh *deviceHandler) createVlanFilterFsm(ctx context.Context, apUniPort *onuUniPort, aTpID uint16, aCookieSlice []uint64,
aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, aDevEvent OnuDeviceEvent) error {
chVlanFilterFsm := make(chan Message, 2048)
- pDevEntry := dh.getOnuDeviceEntry(true)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("no valid OnuDevice for device-id %x - aborting", dh.deviceID)
}
- pVlanFilterFsm := NewUniVlanConfigFsm(dh, pDevEntry.PDevOmciCC, apUniPort, dh.pOnuTP,
+ pVlanFilterFsm := NewUniVlanConfigFsm(ctx, dh, pDevEntry.PDevOmciCC, apUniPort, dh.pOnuTP,
pDevEntry.pOnuDB, aTpID, aDevEvent, "UniVlanConfigFsm", chVlanFilterFsm,
dh.pOpenOnuAc.AcceptIncrementalEvto, aCookieSlice, aMatchVlan, aSetVlan, aSetPcp)
if pVlanFilterFsm != nil {
@@ -2261,25 +2265,25 @@
if pVlanFilterStatemachine != nil {
if pVlanFilterStatemachine.Is(vlanStDisabled) {
if err := pVlanFilterStatemachine.Event(vlanEvStart); err != nil {
- logger.Warnw("UniVlanConfigFsm: can't start", log.Fields{"err": err})
+ logger.Warnw(ctx, "UniVlanConfigFsm: can't start", log.Fields{"err": err})
return fmt.Errorf("can't start UniVlanConfigFsm for device-id %x", dh.deviceID)
}
/***** UniVlanConfigFsm started */
- logger.Debugw("UniVlanConfigFsm started", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm started", log.Fields{
"state": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID,
"UniPort": apUniPort.portNo})
} else {
- logger.Warnw("wrong state of UniVlanConfigFsm - want: disabled", log.Fields{
+ logger.Warnw(ctx, "wrong state of UniVlanConfigFsm - want: disabled", log.Fields{
"have": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID})
return fmt.Errorf("uniVlanConfigFsm not in expected disabled state for device-id %x", dh.deviceID)
}
} else {
- logger.Errorw("UniVlanConfigFsm StateMachine invalid - cannot be executed!!", log.Fields{
+ logger.Errorw(ctx, "UniVlanConfigFsm StateMachine invalid - cannot be executed!!", log.Fields{
"device-id": dh.deviceID})
return fmt.Errorf("uniVlanConfigFsm invalid for device-id %x", dh.deviceID)
}
} else {
- logger.Errorw("UniVlanConfigFsm could not be created - abort!!", log.Fields{
+ logger.Errorw(ctx, "UniVlanConfigFsm could not be created - abort!!", log.Fields{
"device-id": dh.deviceID, "UniPort": apUniPort.portNo})
return fmt.Errorf("uniVlanConfigFsm could not be created for device-id %x", dh.deviceID)
}
@@ -2288,7 +2292,7 @@
//VerifyVlanConfigRequest checks on existence of a given uniPort
// and starts verification of flow config based on that
-func (dh *deviceHandler) VerifyVlanConfigRequest(aUniID uint8) {
+func (dh *deviceHandler) VerifyVlanConfigRequest(ctx context.Context, aUniID uint8) {
//ensure that the given uniID is available (configured) in the UniPort class (used for OMCI entities)
var pCurrentUniPort *onuUniPort
for _, uniPort := range dh.uniEntityMap {
@@ -2299,15 +2303,15 @@
}
}
if pCurrentUniPort == nil {
- logger.Debugw("VerifyVlanConfig aborted: requested uniID not found in PortDB",
+ logger.Debugw(ctx, "VerifyVlanConfig aborted: requested uniID not found in PortDB",
log.Fields{"device-id": dh.deviceID, "uni-id": aUniID})
return
}
- dh.verifyUniVlanConfigRequest(pCurrentUniPort)
+ dh.verifyUniVlanConfigRequest(ctx, pCurrentUniPort)
}
//verifyUniVlanConfigRequest checks on existence of flow configuration and starts it accordingly
-func (dh *deviceHandler) verifyUniVlanConfigRequest(apUniPort *onuUniPort) {
+func (dh *deviceHandler) verifyUniVlanConfigRequest(ctx context.Context, apUniPort *onuUniPort) {
//TODO!! verify and start pending flow configuration
//some pending config request my exist in case the UniVlanConfig FSM was already started - with internal data -
//but execution was set to 'on hold' as first the TechProfile config had to be applied
@@ -2317,19 +2321,19 @@
if pVlanFilterStatemachine != nil {
if pVlanFilterStatemachine.Is(vlanStWaitingTechProf) {
if err := pVlanFilterStatemachine.Event(vlanEvContinueConfig); err != nil {
- logger.Warnw("UniVlanConfigFsm: can't continue processing", log.Fields{"err": err})
+ logger.Warnw(ctx, "UniVlanConfigFsm: can't continue processing", log.Fields{"err": err})
} else {
/***** UniVlanConfigFsm continued */
- logger.Debugw("UniVlanConfigFsm continued", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm continued", log.Fields{
"state": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID,
"UniPort": apUniPort.portNo})
}
} else {
- logger.Debugw("no state of UniVlanConfigFsm to be continued", log.Fields{
+ logger.Debugw(ctx, "no state of UniVlanConfigFsm to be continued", log.Fields{
"have": pVlanFilterStatemachine.Current(), "device-id": dh.deviceID})
}
} else {
- logger.Debugw("UniVlanConfigFsm StateMachine does not exist, no flow processing", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm StateMachine does not exist, no flow processing", log.Fields{
"device-id": dh.deviceID})
}
@@ -2338,8 +2342,8 @@
//RemoveVlanFilterFsm deletes the stored pointer to the VlanConfigFsm
// intention is to provide this method to be called from VlanConfigFsm itself, when resources (and methods!) are cleaned up
-func (dh *deviceHandler) RemoveVlanFilterFsm(apUniPort *onuUniPort) {
- logger.Debugw("remove UniVlanConfigFsm StateMachine", log.Fields{
+func (dh *deviceHandler) RemoveVlanFilterFsm(ctx context.Context, apUniPort *onuUniPort) {
+ logger.Debugw(ctx, "remove UniVlanConfigFsm StateMachine", log.Fields{
"device-id": dh.deviceID, "uniPort": apUniPort.portNo})
//save to do, even if entry dows not exist
delete(dh.UniVlanConfigFsmMap, apUniPort.uniID)
@@ -2348,17 +2352,17 @@
//storePersUniFlowConfig updates local storage of OnuUniFlowConfig and writes it into kv-store afterwards to have it
//available for potential reconcilement
-func (dh *deviceHandler) storePersUniFlowConfig(aUniID uint8, aUniVlanFlowParams *[]uniVlanFlowParams) error {
+func (dh *deviceHandler) storePersUniFlowConfig(ctx context.Context, aUniID uint8, aUniVlanFlowParams *[]uniVlanFlowParams) error {
if dh.reconciling {
- logger.Debugw("reconciling - don't store persistent UniFlowConfig", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "reconciling - don't store persistent UniFlowConfig", log.Fields{"device-id": dh.deviceID})
return nil
}
- logger.Debugw("Store or clear persistent UniFlowConfig", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "Store or clear persistent UniFlowConfig", log.Fields{"device-id": dh.deviceID})
- pDevEntry := dh.getOnuDeviceEntry(true)
+ pDevEntry := dh.getOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
}
pDevEntry.updateOnuUniFlowConfig(aUniID, aUniVlanFlowParams)
@@ -2375,40 +2379,40 @@
var wg sync.WaitGroup
wg.Add(1) // for the 1 go routine to finish
- go pDevEntry.updateOnuKvStore(dctx, &wg)
- dh.waitForCompletion(cancel, &wg, "UpdateKvStore") //wait for background process to finish
+ go pDevEntry.updateOnuKvStore(log.WithSpanFromContext(dctx, ctx), &wg)
+ dh.waitForCompletion(ctx, cancel, &wg, "UpdateKvStore") //wait for background process to finish
return pDevEntry.getKvProcessingErrorIndication()
}
-func (dh *deviceHandler) waitForCompletion(cancel context.CancelFunc, wg *sync.WaitGroup, aCallerIdent string) {
+func (dh *deviceHandler) waitForCompletion(ctx context.Context, cancel context.CancelFunc, wg *sync.WaitGroup, aCallerIdent string) {
defer cancel() //ensure termination of context (may be pro forma)
wg.Wait()
- logger.Debugw("WaitGroup processing completed", log.Fields{
+ logger.Debugw(ctx, "WaitGroup processing completed", log.Fields{
"device-id": dh.deviceID, "called from": aCallerIdent})
}
-func (dh *deviceHandler) deviceReasonUpdate(deviceReason uint8, notifyCore bool) error {
+func (dh *deviceHandler) deviceReasonUpdate(ctx context.Context, deviceReason uint8, notifyCore bool) error {
dh.deviceReason = deviceReason
if notifyCore {
//TODO with VOL-3045/VOL-3046: return the error and stop further processing at calling position
- if err := dh.coreProxy.DeviceReasonUpdate(context.TODO(), dh.deviceID, deviceReasonMap[deviceReason]); err != nil {
- logger.Errorf("DeviceReasonUpdate error: %s",
+ if err := dh.coreProxy.DeviceReasonUpdate(log.WithSpanFromContext(context.TODO(), ctx), dh.deviceID, deviceReasonMap[deviceReason]); err != nil {
+ logger.Errorf(ctx, "DeviceReasonUpdate error: %s",
log.Fields{"device-id": dh.deviceID, "error": err}, deviceReasonMap[deviceReason])
return err
}
- logger.Infof("DeviceReasonUpdate success: %s - device-id: %s", deviceReasonMap[deviceReason], dh.deviceID)
+ logger.Infof(ctx, "DeviceReasonUpdate success: %s - device-id: %s", deviceReasonMap[deviceReason], dh.deviceID)
return nil
}
- logger.Infof("Don't notify core about DeviceReasonUpdate: %s - device-id: %s", deviceReasonMap[deviceReason], dh.deviceID)
+ logger.Infof(ctx, "Don't notify core about DeviceReasonUpdate: %s - device-id: %s", deviceReasonMap[deviceReason], dh.deviceID)
return nil
}
-func (dh *deviceHandler) storePersistentData() error {
- pDevEntry := dh.getOnuDeviceEntry(true)
+func (dh *deviceHandler) storePersistentData(ctx context.Context) error {
+ pDevEntry := dh.getOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Warnw("No valid OnuDevice", log.Fields{"device-id": dh.deviceID})
+ logger.Warnw(ctx, "No valid OnuDevice", log.Fields{"device-id": dh.deviceID})
return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
}
pDevEntry.lockOnuKVStoreMutex()
@@ -2422,10 +2426,10 @@
wg.Add(1) // for the 1 go routine to finish
go pDevEntry.updateOnuKvStore(dctx, &wg)
- dh.waitForCompletion(cancel, &wg, "UpdateKvStore") //wait for background process to finish
+ dh.waitForCompletion(ctx, cancel, &wg, "UpdateKvStore") //wait for background process to finish
if err := pDevEntry.getKvProcessingErrorIndication(); err != nil {
- logger.Warnw("KV-processing error", log.Fields{"device-id": dh.deviceID, "err": err})
+ logger.Warnw(ctx, "KV-processing error", log.Fields{"device-id": dh.deviceID, "err": err})
return err
}
return nil
diff --git a/internal/pkg/onuadaptercore/mib_download.go b/internal/pkg/onuadaptercore/mib_download.go
index cc39da0..21da07d 100644
--- a/internal/pkg/onuadaptercore/mib_download.go
+++ b/internal/pkg/onuadaptercore/mib_download.go
@@ -26,48 +26,48 @@
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- //ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- //"github.com/opencord/voltha-protos/v3/go/openflow_13"
- //"github.com/opencord/voltha-protos/v3/go/voltha"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
+ //ic "github.com/opencord/voltha-protos/v4/go/inter_container"
+ //"github.com/opencord/voltha-protos/v4/go/openflow_13"
+ //"github.com/opencord/voltha-protos/v4/go/voltha"
)
-func (onuDeviceEntry *OnuDeviceEntry) enterDLStartingState(e *fsm.Event) {
- logger.Debugw("MibDownload FSM", log.Fields{"Start downloading OMCI MIB in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
+func (onuDeviceEntry *OnuDeviceEntry) enterDLStartingState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibDownload FSM", log.Fields{"Start downloading OMCI MIB in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
// in case the used channel is not yet defined (can be re-used after restarts)
if onuDeviceEntry.omciMessageReceived == nil {
onuDeviceEntry.omciMessageReceived = make(chan bool)
- logger.Debug("MibDownload FSM - defining the BridgeInit RxChannel")
+ logger.Debug(ctx, "MibDownload FSM - defining the BridgeInit RxChannel")
}
// start go routine for processing of MibDownload messages
- go onuDeviceEntry.processMibDownloadMessages()
+ go onuDeviceEntry.processMibDownloadMessages(ctx)
}
-func (onuDeviceEntry *OnuDeviceEntry) enterCreatingGalState(e *fsm.Event) {
- logger.Debugw("MibDownload FSM", log.Fields{"Tx create::GAL Ethernet Profile in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
- meInstance := onuDeviceEntry.PDevOmciCC.sendCreateGalEthernetProfile(context.TODO(), ConstDefaultOmciTimeout, true)
+func (onuDeviceEntry *OnuDeviceEntry) enterCreatingGalState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibDownload FSM", log.Fields{"Tx create::GAL Ethernet Profile in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
+ meInstance := onuDeviceEntry.PDevOmciCC.sendCreateGalEthernetProfile(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
}
-func (onuDeviceEntry *OnuDeviceEntry) enterSettingOnu2gState(e *fsm.Event) {
- logger.Debugw("MibDownload FSM", log.Fields{"Tx Set::ONU2-G in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
- meInstance := onuDeviceEntry.PDevOmciCC.sendSetOnu2g(context.TODO(), ConstDefaultOmciTimeout, true)
+func (onuDeviceEntry *OnuDeviceEntry) enterSettingOnu2gState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibDownload FSM", log.Fields{"Tx Set::ONU2-G in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
+ meInstance := onuDeviceEntry.PDevOmciCC.sendSetOnu2g(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
}
-func (onuDeviceEntry *OnuDeviceEntry) enterBridgeInitState(e *fsm.Event) {
- logger.Debugw("MibDownload FSM - starting bridge config port loop", log.Fields{
+func (onuDeviceEntry *OnuDeviceEntry) enterBridgeInitState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibDownload FSM - starting bridge config port loop", log.Fields{
"in state": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
- go onuDeviceEntry.performInitialBridgeSetup()
+ go onuDeviceEntry.performInitialBridgeSetup(ctx)
}
-func (onuDeviceEntry *OnuDeviceEntry) enterDownloadedState(e *fsm.Event) {
- logger.Debugw("MibDownload FSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
- onuDeviceEntry.transferSystemEvent(MibDownloadDone)
+func (onuDeviceEntry *OnuDeviceEntry) enterDownloadedState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibDownload FSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": onuDeviceEntry.deviceID})
+ onuDeviceEntry.transferSystemEvent(ctx, MibDownloadDone)
//let's reset the state machine in order to release all resources now
pMibDlFsm := onuDeviceEntry.pMibDownloadFsm
if pMibDlFsm != nil {
@@ -80,8 +80,8 @@
}
}
-func (onuDeviceEntry *OnuDeviceEntry) enterResettingState(e *fsm.Event) {
- logger.Debugw("MibDownload FSM resetting", log.Fields{"device-id": onuDeviceEntry.deviceID})
+func (onuDeviceEntry *OnuDeviceEntry) enterResettingState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibDownload FSM resetting", log.Fields{"device-id": onuDeviceEntry.deviceID})
pMibDlFsm := onuDeviceEntry.pMibDownloadFsm
if pMibDlFsm != nil {
// abort running message processing
@@ -103,8 +103,8 @@
}
}
-func (onuDeviceEntry *OnuDeviceEntry) processMibDownloadMessages( /*ctx context.Context*/ ) {
- logger.Debugw("Start MibDownload Msg processing", log.Fields{"for device-id": onuDeviceEntry.deviceID})
+func (onuDeviceEntry *OnuDeviceEntry) processMibDownloadMessages(ctx context.Context) {
+ logger.Debugw(ctx, "Start MibDownload Msg processing", log.Fields{"for device-id": onuDeviceEntry.deviceID})
loop:
for {
// case <-ctx.Done():
@@ -113,35 +113,35 @@
// unless multiple channels are not involved, we should not use select
message, ok := <-onuDeviceEntry.pMibDownloadFsm.commChan
if !ok {
- logger.Info("MibDownload Rx Msg", log.Fields{"Message couldn't be read from channel for device-id": onuDeviceEntry.deviceID})
+ logger.Info(ctx, "MibDownload Rx Msg", log.Fields{"Message couldn't be read from channel for device-id": onuDeviceEntry.deviceID})
// but then we have to ensure a restart of the FSM as well - as exceptional procedure
_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRestart)
break loop
}
- logger.Debugw("MibDownload Rx Msg", log.Fields{"Received message for device-id": onuDeviceEntry.deviceID})
+ logger.Debugw(ctx, "MibDownload Rx Msg", log.Fields{"Received message for device-id": onuDeviceEntry.deviceID})
switch message.Type {
case TestMsg:
msg, _ := message.Data.(TestMessage)
if msg.TestMessageVal == AbortMessageProcessing {
- logger.Debugw("MibDownload abort ProcessMsg", log.Fields{"for device-id": onuDeviceEntry.deviceID})
+ logger.Debugw(ctx, "MibDownload abort ProcessMsg", log.Fields{"for device-id": onuDeviceEntry.deviceID})
break loop
}
- logger.Warnw("MibDownload unknown TestMessage", log.Fields{"device-id": onuDeviceEntry.deviceID, "MessageVal": msg.TestMessageVal})
+ logger.Warnw(ctx, "MibDownload unknown TestMessage", log.Fields{"device-id": onuDeviceEntry.deviceID, "MessageVal": msg.TestMessageVal})
case OMCI:
msg, _ := message.Data.(OmciMessage)
- onuDeviceEntry.handleOmciMibDownloadMessage(msg)
+ onuDeviceEntry.handleOmciMibDownloadMessage(ctx, msg)
default:
- logger.Warn("MibDownload Rx Msg", log.Fields{"Unknown message type received for device-id": onuDeviceEntry.deviceID,
+ logger.Warn(ctx, "MibDownload Rx Msg", log.Fields{"Unknown message type received for device-id": onuDeviceEntry.deviceID,
"message.Type": message.Type})
}
}
- logger.Debugw("End MibDownload Msg processing", log.Fields{"for device-id": onuDeviceEntry.deviceID})
+ logger.Debugw(ctx, "End MibDownload Msg processing", log.Fields{"for device-id": onuDeviceEntry.deviceID})
}
-func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadMessage(msg OmciMessage) {
- logger.Debugw("Rx OMCI MibDownload Msg", log.Fields{"device-id": onuDeviceEntry.deviceID,
+func (onuDeviceEntry *OnuDeviceEntry) handleOmciMibDownloadMessage(ctx context.Context, msg OmciMessage) {
+ logger.Debugw(ctx, "Rx OMCI MibDownload Msg", log.Fields{"device-id": onuDeviceEntry.deviceID,
"msgType": msg.OmciMsg.MessageType})
switch msg.OmciMsg.MessageType {
@@ -149,17 +149,17 @@
{
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse)
if msgLayer == nil {
- logger.Errorw("Omci Msg layer could not be detected for CreateResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
+ logger.Errorw(ctx, "Omci Msg layer could not be detected for CreateResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
return
}
msgObj, msgOk := msgLayer.(*omci.CreateResponse)
if !msgOk {
- logger.Errorw("Omci Msg layer could not be assigned for CreateResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
+ logger.Errorw(ctx, "Omci Msg layer could not be assigned for CreateResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
return
}
- logger.Debugw("CreateResponse Data", log.Fields{"device-id": onuDeviceEntry.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "CreateResponse Data", log.Fields{"device-id": onuDeviceEntry.deviceID, "data-fields": msgObj})
if msgObj.Result != me.Success && msgObj.Result != me.InstanceExists {
- logger.Errorw("Omci CreateResponse Error - later: drive FSM to abort state ?", log.Fields{"device-id": onuDeviceEntry.deviceID, "Error": msgObj.Result})
+ logger.Errorw(ctx, "Omci CreateResponse Error - later: drive FSM to abort state ?", log.Fields{"device-id": onuDeviceEntry.deviceID, "Error": msgObj.Result})
// possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
return
}
@@ -197,17 +197,17 @@
{
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse)
if msgLayer == nil {
- logger.Errorw("Omci Msg layer could not be detected for SetResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
+ logger.Errorw(ctx, "Omci Msg layer could not be detected for SetResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
return
}
msgObj, msgOk := msgLayer.(*omci.SetResponse)
if !msgOk {
- logger.Errorw("Omci Msg layer could not be assigned for SetResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
+ logger.Errorw(ctx, "Omci Msg layer could not be assigned for SetResponse", log.Fields{"device-id": onuDeviceEntry.deviceID})
return
}
- logger.Debugw("SetResponse Data", log.Fields{"device-id": onuDeviceEntry.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "SetResponse Data", log.Fields{"device-id": onuDeviceEntry.deviceID, "data-fields": msgObj})
if msgObj.Result != me.Success {
- logger.Errorw("Omci SetResponse Error - later: drive FSM to abort state ?", log.Fields{"device-id": onuDeviceEntry.deviceID,
+ logger.Errorw(ctx, "Omci SetResponse Error - later: drive FSM to abort state ?", log.Fields{"device-id": onuDeviceEntry.deviceID,
"Error": msgObj.Result})
// possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
return
@@ -230,26 +230,26 @@
} //SetResponseType
default:
{
- logger.Errorw("Rx OMCI MibDownload unhandled MsgType", log.Fields{"device-id": onuDeviceEntry.deviceID,
+ logger.Errorw(ctx, "Rx OMCI MibDownload unhandled MsgType", log.Fields{"device-id": onuDeviceEntry.deviceID,
"omciMsgType": msg.OmciMsg.MessageType})
return
}
} // switch msg.OmciMsg.MessageType
}
-func (onuDeviceEntry *OnuDeviceEntry) performInitialBridgeSetup() {
+func (onuDeviceEntry *OnuDeviceEntry) performInitialBridgeSetup(ctx context.Context) {
for uniNo, uniPort := range onuDeviceEntry.baseDeviceHandler.uniEntityMap {
- logger.Debugw("Starting IntialBridgeSetup", log.Fields{
+ logger.Debugw(ctx, "Starting IntialBridgeSetup", log.Fields{
"device-id": onuDeviceEntry.deviceID, "for PortNo": uniNo})
//create MBSP
meInstance := onuDeviceEntry.PDevOmciCC.sendCreateMBServiceProfile(
- context.TODO(), uniPort, ConstDefaultOmciTimeout, true)
+ log.WithSpanFromContext(context.TODO(), ctx), uniPort, ConstDefaultOmciTimeout, true)
onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
//verify response
- err := onuDeviceEntry.waitforOmciResponse(meInstance)
+ err := onuDeviceEntry.waitforOmciResponse(ctx, meInstance)
if err != nil {
- logger.Errorw("InitialBridgeSetup failed at MBSP, aborting MIB Download!",
+ logger.Errorw(ctx, "InitialBridgeSetup failed at MBSP, aborting MIB Download!",
log.Fields{"device-id": onuDeviceEntry.deviceID})
_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
return
@@ -257,12 +257,12 @@
//create MBPCD
meInstance = onuDeviceEntry.PDevOmciCC.sendCreateMBPConfigData(
- context.TODO(), uniPort, ConstDefaultOmciTimeout, true)
+ log.WithSpanFromContext(context.TODO(), ctx), uniPort, ConstDefaultOmciTimeout, true)
onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
//verify response
- err = onuDeviceEntry.waitforOmciResponse(meInstance)
+ err = onuDeviceEntry.waitforOmciResponse(ctx, meInstance)
if err != nil {
- logger.Errorw("InitialBridgeSetup failed at MBPCD, aborting MIB Download!",
+ logger.Errorw(ctx, "InitialBridgeSetup failed at MBPCD, aborting MIB Download!",
log.Fields{"device-id": onuDeviceEntry.deviceID})
_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
return
@@ -270,12 +270,12 @@
//create EVTOCD
meInstance = onuDeviceEntry.PDevOmciCC.sendCreateEVTOConfigData(
- context.TODO(), uniPort, ConstDefaultOmciTimeout, true)
+ log.WithSpanFromContext(context.TODO(), ctx), uniPort, ConstDefaultOmciTimeout, true)
onuDeviceEntry.PDevOmciCC.pLastTxMeInstance = meInstance
//verify response
- err = onuDeviceEntry.waitforOmciResponse(meInstance)
+ err = onuDeviceEntry.waitforOmciResponse(ctx, meInstance)
if err != nil {
- logger.Errorw("InitialBridgeSetup failed at EVTOCD, aborting MIB Download!",
+ logger.Errorw(ctx, "InitialBridgeSetup failed at EVTOCD, aborting MIB Download!",
log.Fields{"device-id": onuDeviceEntry.deviceID})
_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvReset)
return
@@ -283,25 +283,25 @@
}
// if Config has been done for all UNI related instances let the FSM proceed
// while we did not check here, if there is some port at all - !?
- logger.Infow("IntialBridgeSetup finished", log.Fields{"device-id": onuDeviceEntry.deviceID})
+ logger.Infow(ctx, "IntialBridgeSetup finished", log.Fields{"device-id": onuDeviceEntry.deviceID})
_ = onuDeviceEntry.pMibDownloadFsm.pFsm.Event(dlEvRxBridgeResp)
}
-func (onuDeviceEntry *OnuDeviceEntry) waitforOmciResponse(apMeInstance *me.ManagedEntity) error {
+func (onuDeviceEntry *OnuDeviceEntry) waitforOmciResponse(ctx context.Context, apMeInstance *me.ManagedEntity) error {
select {
// maybe be also some outside cancel (but no context modeled for the moment ...)
// case <-ctx.Done():
// logger.Info("MibDownload-bridge-init message reception canceled", log.Fields{"for device-id": onuDeviceEntry.deviceID})
case <-time.After(30 * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
- logger.Warnw("MibDownload-bridge-init timeout", log.Fields{"for device-id": onuDeviceEntry.deviceID})
+ logger.Warnw(ctx, "MibDownload-bridge-init timeout", log.Fields{"for device-id": onuDeviceEntry.deviceID})
return fmt.Errorf("mibDownloadBridgeInit timeout %s", onuDeviceEntry.deviceID)
case success := <-onuDeviceEntry.omciMessageReceived:
if success {
- logger.Debug("MibDownload-bridge-init response received")
+ logger.Debug(ctx, "MibDownload-bridge-init response received")
return nil
}
// should not happen so far
- logger.Warnw("MibDownload-bridge-init response error", log.Fields{"for device-id": onuDeviceEntry.deviceID})
+ logger.Warnw(ctx, "MibDownload-bridge-init response error", log.Fields{"for device-id": onuDeviceEntry.deviceID})
return fmt.Errorf("mibDownloadBridgeInit responseError %s", onuDeviceEntry.deviceID)
}
}
diff --git a/internal/pkg/onuadaptercore/mib_sync.go b/internal/pkg/onuadaptercore/mib_sync.go
index 97dfc47..98e7704 100644
--- a/internal/pkg/onuadaptercore/mib_sync.go
+++ b/internal/pkg/onuadaptercore/mib_sync.go
@@ -32,14 +32,14 @@
//"sync"
"time"
- //"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
+ //"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
- "github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- //ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- //"github.com/opencord/voltha-protos/v3/go/openflow_13"
- //"github.com/opencord/voltha-protos/v3/go/voltha"
+ "github.com/opencord/voltha-lib-go/v4/pkg/db/kvstore"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
+ //ic "github.com/opencord/voltha-protos/v4/go/inter_container"
+ //"github.com/opencord/voltha-protos/v4/go/openflow_13"
+ //"github.com/opencord/voltha-protos/v4/go/voltha"
)
var supportedClassIds = []me.ClassID{
@@ -65,67 +65,67 @@
var fsmMsg TestMessageType
-func (oo *OnuDeviceEntry) enterStartingState(e *fsm.Event) {
- logger.Debugw("MibSync FSM", log.Fields{"Start processing MibSync-msgs in State": e.FSM.Current(), "device-id": oo.deviceID})
- oo.pOnuDB = newOnuDeviceDB(context.TODO(), oo)
- go oo.processMibSyncMessages()
+func (oo *OnuDeviceEntry) enterStartingState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start processing MibSync-msgs in State": e.FSM.Current(), "device-id": oo.deviceID})
+ oo.pOnuDB = newOnuDeviceDB(log.WithSpanFromContext(context.TODO(), ctx), oo)
+ go oo.processMibSyncMessages(ctx)
}
-func (oo *OnuDeviceEntry) enterResettingMibState(e *fsm.Event) {
- logger.Debugw("MibSync FSM", log.Fields{"Start MibTemplate processing in State": e.FSM.Current(), "device-id": oo.deviceID})
+func (oo *OnuDeviceEntry) enterResettingMibState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start MibTemplate processing in State": e.FSM.Current(), "device-id": oo.deviceID})
- logger.Debugw("MibSync FSM", log.Fields{"send mibReset in State": e.FSM.Current(), "device-id": oo.deviceID})
- _ = oo.PDevOmciCC.sendMibReset(context.TODO(), ConstDefaultOmciTimeout, true)
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"send mibReset in State": e.FSM.Current(), "device-id": oo.deviceID})
+ _ = oo.PDevOmciCC.sendMibReset(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true)
//TODO: needs to handle timeouts
}
-func (oo *OnuDeviceEntry) enterGettingVendorAndSerialState(e *fsm.Event) {
- logger.Debugw("MibSync FSM", log.Fields{"Start getting VendorId and SerialNumber in State": e.FSM.Current(), "device-id": oo.deviceID})
+func (oo *OnuDeviceEntry) enterGettingVendorAndSerialState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting VendorId and SerialNumber in State": e.FSM.Current(), "device-id": oo.deviceID})
requestedAttributes := me.AttributeValueMap{"VendorId": "", "SerialNumber": 0}
- meInstance := oo.PDevOmciCC.sendGetMe(context.TODO(), me.OnuGClassID, onugMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
+ meInstance := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.OnuGClassID, onugMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oo.PDevOmciCC.pLastTxMeInstance = meInstance
}
-func (oo *OnuDeviceEntry) enterGettingEquipmentIDState(e *fsm.Event) {
- logger.Debugw("MibSync FSM", log.Fields{"Start getting EquipmentId in State": e.FSM.Current(), "device-id": oo.deviceID})
+func (oo *OnuDeviceEntry) enterGettingEquipmentIDState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting EquipmentId in State": e.FSM.Current(), "device-id": oo.deviceID})
requestedAttributes := me.AttributeValueMap{"EquipmentId": ""}
- meInstance := oo.PDevOmciCC.sendGetMe(context.TODO(), me.Onu2GClassID, onu2gMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
+ meInstance := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.Onu2GClassID, onu2gMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oo.PDevOmciCC.pLastTxMeInstance = meInstance
}
-func (oo *OnuDeviceEntry) enterGettingFirstSwVersionState(e *fsm.Event) {
- logger.Debugw("MibSync FSM", log.Fields{"Start getting IsActive and Version of first SW-image in State": e.FSM.Current(), "device-id": oo.deviceID})
+func (oo *OnuDeviceEntry) enterGettingFirstSwVersionState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting IsActive and Version of first SW-image in State": e.FSM.Current(), "device-id": oo.deviceID})
requestedAttributes := me.AttributeValueMap{"IsActive": 0, "Version": ""}
- meInstance := oo.PDevOmciCC.sendGetMe(context.TODO(), me.SoftwareImageClassID, firstSwImageMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
+ meInstance := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID, firstSwImageMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oo.PDevOmciCC.pLastTxMeInstance = meInstance
}
-func (oo *OnuDeviceEntry) enterGettingSecondSwVersionState(e *fsm.Event) {
- logger.Debugw("MibSync FSM", log.Fields{"Start getting IsActive and Version of second SW-image in State": e.FSM.Current(), "device-id": oo.deviceID})
+func (oo *OnuDeviceEntry) enterGettingSecondSwVersionState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting IsActive and Version of second SW-image in State": e.FSM.Current(), "device-id": oo.deviceID})
requestedAttributes := me.AttributeValueMap{"IsActive": 0, "Version": ""}
- meInstance := oo.PDevOmciCC.sendGetMe(context.TODO(), me.SoftwareImageClassID, secondSwImageMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
+ meInstance := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.SoftwareImageClassID, secondSwImageMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oo.PDevOmciCC.pLastTxMeInstance = meInstance
}
-func (oo *OnuDeviceEntry) enterGettingMacAddressState(e *fsm.Event) {
- logger.Debugw("MibSync FSM", log.Fields{"Start getting MacAddress in State": e.FSM.Current(), "device-id": oo.deviceID})
+func (oo *OnuDeviceEntry) enterGettingMacAddressState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start getting MacAddress in State": e.FSM.Current(), "device-id": oo.deviceID})
requestedAttributes := me.AttributeValueMap{"MacAddress": ""}
- meInstance := oo.PDevOmciCC.sendGetMe(context.TODO(), me.IpHostConfigDataClassID, ipHostConfigDataMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
+ meInstance := oo.PDevOmciCC.sendGetMe(log.WithSpanFromContext(context.TODO(), ctx), me.IpHostConfigDataClassID, ipHostConfigDataMeID, requestedAttributes, ConstDefaultOmciTimeout, true)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oo.PDevOmciCC.pLastTxMeInstance = meInstance
}
-func (oo *OnuDeviceEntry) enterGettingMibTemplate(e *fsm.Event) {
+func (oo *OnuDeviceEntry) enterGettingMibTemplate(ctx context.Context, e *fsm.Event) {
for i := firstSwImageMeID; i <= secondSwImageMeID; i++ {
if oo.swImages[i].isActive > 0 {
@@ -135,43 +135,43 @@
meStoredFromTemplate := false
oo.mibTemplatePath = fmt.Sprintf(cSuffixMibTemplateKvStore, oo.vendorID, oo.equipmentID, oo.activeSwVersion)
- logger.Debugw("MibSync FSM - MibTemplate - etcd search string", log.Fields{"path": fmt.Sprintf("%s/%s", cBasePathMibTemplateKvStore, oo.mibTemplatePath)})
- Value, err := oo.mibTemplateKVStore.Get(context.TODO(), oo.mibTemplatePath)
+ logger.Debugw(ctx, "MibSync FSM - MibTemplate - etcd search string", log.Fields{"path": fmt.Sprintf("%s/%s", cBasePathMibTemplateKvStore, oo.mibTemplatePath)})
+ Value, err := oo.mibTemplateKVStore.Get(log.WithSpanFromContext(context.TODO(), ctx), oo.mibTemplatePath)
if err == nil {
if Value != nil {
- logger.Debugf("MibSync FSM - MibTemplate read: Key: %s, Value: %s %s", Value.Key, Value.Value)
+ logger.Debugf(ctx, "MibSync FSM - MibTemplate read: Key: %s, Value: %s %s", Value.Key, Value.Value)
// swap out tokens with specific data
mibTmpString, _ := kvstore.ToString(Value.Value)
mibTmpString2 := strings.Replace(mibTmpString, "%SERIAL_NUMBER%", oo.serialNumber, -1)
mibTmpString = strings.Replace(mibTmpString2, "%MAC_ADDRESS%", oo.macAddress, -1)
mibTmpBytes := []byte(mibTmpString)
- logger.Debugf("MibSync FSM - MibTemplate tokens swapped out: %s", mibTmpBytes)
+ logger.Debugf(ctx, "MibSync FSM - MibTemplate tokens swapped out: %s", mibTmpBytes)
var fistLevelMap map[string]interface{}
if err = json.Unmarshal(mibTmpBytes, &fistLevelMap); err != nil {
- logger.Errorw("MibSync FSM - Failed to unmarshal template", log.Fields{"error": err, "device-id": oo.deviceID})
+ logger.Errorw(ctx, "MibSync FSM - Failed to unmarshal template", log.Fields{"error": err, "device-id": oo.deviceID})
} else {
for fistLevelKey, firstLevelValue := range fistLevelMap {
- logger.Debugw("MibSync FSM - fistLevelKey", log.Fields{"fistLevelKey": fistLevelKey})
+ logger.Debugw(ctx, "MibSync FSM - fistLevelKey", log.Fields{"fistLevelKey": fistLevelKey})
if uint16ValidNumber, err := strconv.ParseUint(fistLevelKey, 10, 16); err == nil {
meClassID := me.ClassID(uint16ValidNumber)
- logger.Debugw("MibSync FSM - fistLevelKey is a number in uint16-range", log.Fields{"uint16ValidNumber": uint16ValidNumber})
+ logger.Debugw(ctx, "MibSync FSM - fistLevelKey is a number in uint16-range", log.Fields{"uint16ValidNumber": uint16ValidNumber})
if isSupportedClassID(meClassID) {
- logger.Debugw("MibSync FSM - fistLevelKey is a supported classID", log.Fields{"meClassID": meClassID})
+ logger.Debugw(ctx, "MibSync FSM - fistLevelKey is a supported classID", log.Fields{"meClassID": meClassID})
secondLevelMap := firstLevelValue.(map[string]interface{})
for secondLevelKey, secondLevelValue := range secondLevelMap {
- logger.Debugw("MibSync FSM - secondLevelKey", log.Fields{"secondLevelKey": secondLevelKey})
+ logger.Debugw(ctx, "MibSync FSM - secondLevelKey", log.Fields{"secondLevelKey": secondLevelKey})
if uint16ValidNumber, err := strconv.ParseUint(secondLevelKey, 10, 16); err == nil {
meEntityID := uint16(uint16ValidNumber)
- logger.Debugw("MibSync FSM - secondLevelKey is a number and a valid EntityId", log.Fields{"meEntityID": meEntityID})
+ logger.Debugw(ctx, "MibSync FSM - secondLevelKey is a number and a valid EntityId", log.Fields{"meEntityID": meEntityID})
thirdLevelMap := secondLevelValue.(map[string]interface{})
for thirdLevelKey, thirdLevelValue := range thirdLevelMap {
if thirdLevelKey == "Attributes" {
- logger.Debugw("MibSync FSM - thirdLevelKey refers to attributes", log.Fields{"thirdLevelKey": thirdLevelKey})
+ logger.Debugw(ctx, "MibSync FSM - thirdLevelKey refers to attributes", log.Fields{"thirdLevelKey": thirdLevelKey})
attributesMap := thirdLevelValue.(map[string]interface{})
- logger.Debugw("MibSync FSM - attributesMap", log.Fields{"attributesMap": attributesMap})
- oo.pOnuDB.PutMe(meClassID, meEntityID, attributesMap)
+ logger.Debugw(ctx, "MibSync FSM - attributesMap", log.Fields{"attributesMap": attributesMap})
+ oo.pOnuDB.PutMe(ctx, meClassID, meEntityID, attributesMap)
meStoredFromTemplate = true
}
}
@@ -182,18 +182,18 @@
}
}
} else {
- logger.Debugw("No MIB template found", log.Fields{"path": oo.mibTemplatePath, "device-id": oo.deviceID})
+ logger.Debugw(ctx, "No MIB template found", log.Fields{"path": oo.mibTemplatePath, "device-id": oo.deviceID})
}
} else {
- logger.Errorf("Get from kvstore operation failed for path",
+ logger.Errorf(ctx, "Get from kvstore operation failed for path",
log.Fields{"path": oo.mibTemplatePath, "device-id": oo.deviceID})
}
if meStoredFromTemplate {
- logger.Debug("MibSync FSM - valid MEs stored from template")
- oo.pOnuDB.logMeDb()
+ logger.Debug(ctx, "MibSync FSM - valid MEs stored from template")
+ oo.pOnuDB.logMeDb(ctx)
fsmMsg = LoadMibTemplateOk
} else {
- logger.Debug("MibSync FSM - no valid MEs stored from template - perform MIB-upload!")
+ logger.Debug(ctx, "MibSync FSM - no valid MEs stored from template - perform MIB-upload!")
fsmMsg = LoadMibTemplateFailed
}
@@ -206,38 +206,38 @@
oo.pMibUploadFsm.commChan <- mibSyncMsg
}
-func (oo *OnuDeviceEntry) enterUploadingState(e *fsm.Event) {
- logger.Debugw("MibSync FSM", log.Fields{"send MibUpload in State": e.FSM.Current(), "device-id": oo.deviceID})
- _ = oo.PDevOmciCC.sendMibUpload(context.TODO(), ConstDefaultOmciTimeout, true)
+func (oo *OnuDeviceEntry) enterUploadingState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"send MibUpload in State": e.FSM.Current(), "device-id": oo.deviceID})
+ _ = oo.PDevOmciCC.sendMibUpload(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true)
}
-func (oo *OnuDeviceEntry) enterInSyncState(e *fsm.Event) {
- logger.Debugw("MibSync FSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": oo.deviceID})
- oo.transferSystemEvent(MibDatabaseSync)
+func (oo *OnuDeviceEntry) enterInSyncState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": oo.deviceID})
+ oo.transferSystemEvent(ctx, MibDatabaseSync)
}
-func (oo *OnuDeviceEntry) enterExaminingMdsState(e *fsm.Event) {
- logger.Debugw("MibSync FSM", log.Fields{"Start GetMds processing in State": e.FSM.Current(), "device-id": oo.deviceID})
- logger.Debug("function not implemented yet")
+func (oo *OnuDeviceEntry) enterExaminingMdsState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start GetMds processing in State": e.FSM.Current(), "device-id": oo.deviceID})
+ logger.Debug(ctx, "function not implemented yet")
}
-func (oo *OnuDeviceEntry) enterResynchronizingState(e *fsm.Event) {
- logger.Debugw("MibSync FSM", log.Fields{"Start MibResync processing in State": e.FSM.Current(), "device-id": oo.deviceID})
- logger.Debug("function not implemented yet")
+func (oo *OnuDeviceEntry) enterResynchronizingState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start MibResync processing in State": e.FSM.Current(), "device-id": oo.deviceID})
+ logger.Debug(ctx, "function not implemented yet")
}
-func (oo *OnuDeviceEntry) enterAuditingState(e *fsm.Event) {
- logger.Debugw("MibSync FSM", log.Fields{"Start MibResync processing in State": e.FSM.Current(), "device-id": oo.deviceID})
- logger.Debug("function not implemented yet")
+func (oo *OnuDeviceEntry) enterAuditingState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start MibResync processing in State": e.FSM.Current(), "device-id": oo.deviceID})
+ logger.Debug(ctx, "function not implemented yet")
}
-func (oo *OnuDeviceEntry) enterOutOfSyncState(e *fsm.Event) {
- logger.Debugw("MibSync FSM", log.Fields{"Start MibReconcile processing in State": e.FSM.Current(), "device-id": oo.deviceID})
- logger.Debug("function not implemented yet")
+func (oo *OnuDeviceEntry) enterOutOfSyncState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "MibSync FSM", log.Fields{"Start MibReconcile processing in State": e.FSM.Current(), "device-id": oo.deviceID})
+ logger.Debug(ctx, "function not implemented yet")
}
-func (oo *OnuDeviceEntry) processMibSyncMessages( /*ctx context.Context*/ ) {
- logger.Debugw("MibSync Msg", log.Fields{"Start routine to process OMCI-messages for device-id": oo.deviceID})
+func (oo *OnuDeviceEntry) processMibSyncMessages(ctx context.Context) {
+ logger.Debugw(ctx, "MibSync Msg", log.Fields{"Start routine to process OMCI-messages for device-id": oo.deviceID})
loop:
for {
// case <-ctx.Done():
@@ -245,152 +245,152 @@
// break loop
message, ok := <-oo.pMibUploadFsm.commChan
if !ok {
- logger.Info("MibSync Msg", log.Fields{"Message couldn't be read from channel for device-id": oo.deviceID})
+ logger.Info(ctx, "MibSync Msg", log.Fields{"Message couldn't be read from channel for device-id": oo.deviceID})
break loop
}
- logger.Debugw("MibSync Msg", log.Fields{"Received message on ONU MibSyncChan for device-id": oo.deviceID})
+ logger.Debugw(ctx, "MibSync Msg", log.Fields{"Received message on ONU MibSyncChan for device-id": oo.deviceID})
switch message.Type {
case TestMsg:
msg, _ := message.Data.(TestMessage)
- oo.handleTestMsg(msg)
+ oo.handleTestMsg(ctx, msg)
case OMCI:
msg, _ := message.Data.(OmciMessage)
- oo.handleOmciMessage(msg)
+ oo.handleOmciMessage(ctx, msg)
default:
- logger.Warn("MibSync Msg", log.Fields{"Unknown message type received for device-id": oo.deviceID, "message.Type": message.Type})
+ logger.Warn(ctx, "MibSync Msg", log.Fields{"Unknown message type received for device-id": oo.deviceID, "message.Type": message.Type})
}
}
- logger.Info("MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": oo.deviceID})
+ logger.Info(ctx, "MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": oo.deviceID})
// TODO: only this action?
_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
}
-func (oo *OnuDeviceEntry) handleTestMsg(msg TestMessage) {
+func (oo *OnuDeviceEntry) handleTestMsg(ctx context.Context, msg TestMessage) {
- logger.Debugw("MibSync Msg", log.Fields{"TestMessage received for device-id": oo.deviceID, "msg.TestMessageVal": msg.TestMessageVal})
+ logger.Debugw(ctx, "MibSync Msg", log.Fields{"TestMessage received for device-id": oo.deviceID, "msg.TestMessageVal": msg.TestMessageVal})
switch msg.TestMessageVal {
case LoadMibTemplateFailed:
_ = oo.pMibUploadFsm.pFsm.Event(ulEvUploadMib)
- logger.Debugw("MibSync Msg", log.Fields{"state": string(oo.pMibUploadFsm.pFsm.Current())})
+ logger.Debugw(ctx, "MibSync Msg", log.Fields{"state": string(oo.pMibUploadFsm.pFsm.Current())})
case LoadMibTemplateOk:
_ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
- logger.Debugw("MibSync Msg", log.Fields{"state": string(oo.pMibUploadFsm.pFsm.Current())})
+ logger.Debugw(ctx, "MibSync Msg", log.Fields{"state": string(oo.pMibUploadFsm.pFsm.Current())})
default:
- logger.Warn("MibSync Msg", log.Fields{"Unknown message type received for device-id": oo.deviceID, "msg.TestMessageVal": msg.TestMessageVal})
+ logger.Warn(ctx, "MibSync Msg", log.Fields{"Unknown message type received for device-id": oo.deviceID, "msg.TestMessageVal": msg.TestMessageVal})
}
}
-func (oo *OnuDeviceEntry) handleOmciMibResetResponseMessage(msg OmciMessage) {
+func (oo *OnuDeviceEntry) handleOmciMibResetResponseMessage(ctx context.Context, msg OmciMessage) {
if oo.pMibUploadFsm.pFsm.Is(ulStResettingMib) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibResetResponse)
if msgLayer != nil {
msgObj, msgOk := msgLayer.(*omci.MibResetResponse)
if msgOk {
- logger.Debugw("MibResetResponse Data", log.Fields{"data-fields": msgObj})
+ logger.Debugw(ctx, "MibResetResponse Data", log.Fields{"data-fields": msgObj})
if msgObj.Result == me.Success {
// trigger retrieval of VendorId and SerialNumber
_ = oo.pMibUploadFsm.pFsm.Event(ulEvGetVendorAndSerial)
return
}
- logger.Errorw("Omci MibResetResponse Error", log.Fields{"device-id": oo.deviceID, "Error": msgObj.Result})
+ logger.Errorw(ctx, "Omci MibResetResponse Error", log.Fields{"device-id": oo.deviceID, "Error": msgObj.Result})
} else {
- logger.Errorw("Omci Msg layer could not be assigned", log.Fields{"device-id": oo.deviceID})
+ logger.Errorw(ctx, "Omci Msg layer could not be assigned", log.Fields{"device-id": oo.deviceID})
}
} else {
- logger.Errorw("Omci Msg layer could not be detected", log.Fields{"device-id": oo.deviceID})
+ logger.Errorw(ctx, "Omci Msg layer could not be detected", log.Fields{"device-id": oo.deviceID})
}
} else {
- logger.Errorw("Wrong Omci MibResetResponse received", log.Fields{"in state ": oo.pMibUploadFsm.pFsm.Current,
+ logger.Errorw(ctx, "Wrong Omci MibResetResponse received", log.Fields{"in state ": oo.pMibUploadFsm.pFsm.Current,
"device-id": oo.deviceID})
}
- logger.Info("MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": oo.deviceID})
+ logger.Info(ctx, "MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": oo.deviceID})
_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
}
-func (oo *OnuDeviceEntry) handleOmciMibUploadResponseMessage(msg OmciMessage) {
+func (oo *OnuDeviceEntry) handleOmciMibUploadResponseMessage(ctx context.Context, msg OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibUploadResponse)
if msgLayer == nil {
- logger.Errorw("Omci Msg layer could not be detected", log.Fields{"device-id": oo.deviceID})
+ logger.Errorw(ctx, "Omci Msg layer could not be detected", log.Fields{"device-id": oo.deviceID})
return
}
msgObj, msgOk := msgLayer.(*omci.MibUploadResponse)
if !msgOk {
- logger.Errorw("Omci Msg layer could not be assigned", log.Fields{"device-id": oo.deviceID})
+ logger.Errorw(ctx, "Omci Msg layer could not be assigned", log.Fields{"device-id": oo.deviceID})
return
}
- logger.Debugw("MibUploadResponse Data for:", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "MibUploadResponse Data for:", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
/* to be verified / reworked !!! */
oo.PDevOmciCC.uploadNoOfCmds = msgObj.NumberOfCommands
if oo.PDevOmciCC.uploadSequNo < oo.PDevOmciCC.uploadNoOfCmds {
- _ = oo.PDevOmciCC.sendMibUploadNext(context.TODO(), ConstDefaultOmciTimeout, true)
+ _ = oo.PDevOmciCC.sendMibUploadNext(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true)
} else {
- logger.Errorw("Invalid number of commands received for:", log.Fields{"device-id": oo.deviceID, "uploadNoOfCmds": oo.PDevOmciCC.uploadNoOfCmds})
+ logger.Errorw(ctx, "Invalid number of commands received for:", log.Fields{"device-id": oo.deviceID, "uploadNoOfCmds": oo.PDevOmciCC.uploadNoOfCmds})
//TODO right action?
_ = oo.pMibUploadFsm.pFsm.Event(ulEvTimeout)
}
}
-func (oo *OnuDeviceEntry) handleOmciMibUploadNextResponseMessage(msg OmciMessage) {
+func (oo *OnuDeviceEntry) handleOmciMibUploadNextResponseMessage(ctx context.Context, msg OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeMibUploadNextResponse)
if msgLayer == nil {
- logger.Errorw("Omci Msg layer could not be detected", log.Fields{"device-id": oo.deviceID})
+ logger.Errorw(ctx, "Omci Msg layer could not be detected", log.Fields{"device-id": oo.deviceID})
return
}
msgObj, msgOk := msgLayer.(*omci.MibUploadNextResponse)
if !msgOk {
- logger.Errorw("Omci Msg layer could not be assigned", log.Fields{"device-id": oo.deviceID})
+ logger.Errorw(ctx, "Omci Msg layer could not be assigned", log.Fields{"device-id": oo.deviceID})
return
}
meName := msgObj.ReportedME.GetName()
if meName == "UnknownItuG988ManagedEntity" || meName == "UnknownVendorSpecificManagedEntity" {
- logger.Debugw("MibUploadNextResponse Data for unknown ME received - temporary workaround is to ignore it!",
+ logger.Debugw(ctx, "MibUploadNextResponse Data for unknown ME received - temporary workaround is to ignore it!",
log.Fields{"device-id": oo.deviceID, "data-fields": msgObj, "meName": meName})
} else {
- logger.Debugw("MibUploadNextResponse Data for:",
+ logger.Debugw(ctx, "MibUploadNextResponse Data for:",
log.Fields{"device-id": oo.deviceID, "meName": meName, "data-fields": msgObj})
meClassID := msgObj.ReportedME.GetClassID()
meEntityID := msgObj.ReportedME.GetEntityID()
meAttributes := msgObj.ReportedME.GetAttributeValueMap()
- oo.pOnuDB.PutMe(meClassID, meEntityID, meAttributes)
+ oo.pOnuDB.PutMe(ctx, meClassID, meEntityID, meAttributes)
}
if oo.PDevOmciCC.uploadSequNo < oo.PDevOmciCC.uploadNoOfCmds {
- _ = oo.PDevOmciCC.sendMibUploadNext(context.TODO(), ConstDefaultOmciTimeout, true)
+ _ = oo.PDevOmciCC.sendMibUploadNext(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true)
} else {
- oo.pOnuDB.logMeDb()
- err := oo.createAndPersistMibTemplate()
+ oo.pOnuDB.logMeDb(ctx)
+ err := oo.createAndPersistMibTemplate(ctx)
if err != nil {
- logger.Errorw("MibSync - MibTemplate - Failed to create and persist the mib template", log.Fields{"error": err, "device-id": oo.deviceID})
+ logger.Errorw(ctx, "MibSync - MibTemplate - Failed to create and persist the mib template", log.Fields{"error": err, "device-id": oo.deviceID})
}
_ = oo.pMibUploadFsm.pFsm.Event(ulEvSuccess)
}
}
-func (oo *OnuDeviceEntry) handleOmciGetResponseMessage(msg OmciMessage) error {
+func (oo *OnuDeviceEntry) handleOmciGetResponseMessage(ctx context.Context, msg OmciMessage) error {
var err error = nil
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeGetResponse)
if msgLayer == nil {
- logger.Errorw("omci Msg layer could not be detected for GetResponse - handling of MibSyncChan stopped", log.Fields{"device-id": oo.deviceID})
+ logger.Errorw(ctx, "omci Msg layer could not be detected for GetResponse - handling of MibSyncChan stopped", log.Fields{"device-id": oo.deviceID})
_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
return fmt.Errorf("omci Msg layer could not be detected for GetResponse - handling of MibSyncChan stopped: %s", oo.deviceID)
}
msgObj, msgOk := msgLayer.(*omci.GetResponse)
if !msgOk {
- logger.Errorw("omci Msg layer could not be assigned for GetResponse - handling of MibSyncChan stopped", log.Fields{"device-id": oo.deviceID})
+ logger.Errorw(ctx, "omci Msg layer could not be assigned for GetResponse - handling of MibSyncChan stopped", log.Fields{"device-id": oo.deviceID})
_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
return fmt.Errorf("omci Msg layer could not be assigned for GetResponse - handling of MibSyncChan stopped: %s", oo.deviceID)
}
- logger.Debugw("MibSync FSM - GetResponse Data", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "MibSync FSM - GetResponse Data", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
if msgObj.Result == me.Success {
entityID := oo.PDevOmciCC.pLastTxMeInstance.GetEntityID()
if msgObj.EntityClass == oo.PDevOmciCC.pLastTxMeInstance.GetClassID() && msgObj.EntityInstance == entityID {
meAttributes := msgObj.Attributes
meInstance := oo.PDevOmciCC.pLastTxMeInstance.GetName()
- logger.Debugf("MibSync FSM - GetResponse Data for %s", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj}, meInstance)
+ logger.Debugf(ctx, "MibSync FSM - GetResponse Data for %s", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj}, meInstance)
switch meInstance {
case "OnuG":
oo.vendorID = trimStringFromInterface(meAttributes["VendorId"])
@@ -399,10 +399,10 @@
snVendorPart := fmt.Sprintf("%s", snBytes[:4])
snNumberPart := hex.EncodeToString(snBytes[4:])
oo.serialNumber = snVendorPart + snNumberPart
- logger.Debugw("MibSync FSM - GetResponse Data for Onu-G - VendorId/SerialNumber", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "MibSync FSM - GetResponse Data for Onu-G - VendorId/SerialNumber", log.Fields{"device-id": oo.deviceID,
"onuDeviceEntry.vendorID": oo.vendorID, "onuDeviceEntry.serialNumber": oo.serialNumber})
} else {
- logger.Infow("MibSync FSM - SerialNumber has wrong length - fill serialNumber with zeros", log.Fields{"device-id": oo.deviceID, "length": len(snBytes)})
+ logger.Infow(ctx, "MibSync FSM - SerialNumber has wrong length - fill serialNumber with zeros", log.Fields{"device-id": oo.deviceID, "length": len(snBytes)})
oo.serialNumber = cEmptySerialNumberString
}
// trigger retrieval of EquipmentId
@@ -410,7 +410,7 @@
return nil
case "Onu2G":
oo.equipmentID = trimStringFromInterface(meAttributes["EquipmentId"])
- logger.Debugw("MibSync FSM - GetResponse Data for Onu2-G - EquipmentId", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "MibSync FSM - GetResponse Data for Onu2-G - EquipmentId", log.Fields{"device-id": oo.deviceID,
"onuDeviceEntry.equipmentID": oo.equipmentID})
// trigger retrieval of 1st SW-image info
_ = oo.pMibUploadFsm.pFsm.Event(ulEvGetFirstSwVersion)
@@ -419,7 +419,7 @@
if entityID <= secondSwImageMeID {
oo.swImages[entityID].version = trimStringFromInterface(meAttributes["Version"])
oo.swImages[entityID].isActive = meAttributes["IsActive"].(uint8)
- logger.Debugw("MibSync FSM - GetResponse Data for SoftwareImage - Version/IsActive",
+ logger.Debugw(ctx, "MibSync FSM - GetResponse Data for SoftwareImage - Version/IsActive",
log.Fields{"device-id": oo.deviceID, "entityID": entityID,
"version": oo.swImages[entityID].version, "isActive": oo.swImages[entityID].isActive})
} else {
@@ -436,10 +436,10 @@
macBytes, _ := me.InterfaceToOctets(meAttributes["MacAddress"])
if omciMacAddressLen == len(macBytes) {
oo.macAddress = hex.EncodeToString(macBytes[:])
- logger.Debugw("MibSync FSM - GetResponse Data for IpHostConfigData - MacAddress", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "MibSync FSM - GetResponse Data for IpHostConfigData - MacAddress", log.Fields{"device-id": oo.deviceID,
"onuDeviceEntry.macAddress": oo.macAddress})
} else {
- logger.Infow("MibSync FSM - MacAddress wrong length - fill macAddress with zeros", log.Fields{"device-id": oo.deviceID, "length": len(macBytes)})
+ logger.Infow(ctx, "MibSync FSM - MacAddress wrong length - fill macAddress with zeros", log.Fields{"device-id": oo.deviceID, "length": len(macBytes)})
oo.macAddress = cEmptyMacAddrString
}
// trigger retrieval of mib template
@@ -448,42 +448,42 @@
}
}
} else {
- if err = oo.handleOmciGetResponseErrors(msgObj); err == nil {
+ if err = oo.handleOmciGetResponseErrors(ctx, msgObj); err == nil {
return nil
}
}
- logger.Info("MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": oo.deviceID})
+ logger.Info(ctx, "MibSync Msg", log.Fields{"Stopped handling of MibSyncChan for device-id": oo.deviceID})
_ = oo.pMibUploadFsm.pFsm.Event(ulEvStop)
return err
}
-func (oo *OnuDeviceEntry) handleOmciMessage(msg OmciMessage) {
- logger.Debugw("MibSync Msg", log.Fields{"OmciMessage received for device-id": oo.deviceID,
+func (oo *OnuDeviceEntry) handleOmciMessage(ctx context.Context, msg OmciMessage) {
+ logger.Debugw(ctx, "MibSync Msg", log.Fields{"OmciMessage received for device-id": oo.deviceID,
"msgType": msg.OmciMsg.MessageType, "msg": msg})
//further analysis could be done here based on msg.OmciMsg.Payload, e.g. verification of error code ...
switch msg.OmciMsg.MessageType {
case omci.MibResetResponseType:
- oo.handleOmciMibResetResponseMessage(msg)
+ oo.handleOmciMibResetResponseMessage(ctx, msg)
case omci.MibUploadResponseType:
- oo.handleOmciMibUploadResponseMessage(msg)
+ oo.handleOmciMibUploadResponseMessage(ctx, msg)
case omci.MibUploadNextResponseType:
- oo.handleOmciMibUploadNextResponseMessage(msg)
+ oo.handleOmciMibUploadNextResponseMessage(ctx, msg)
case omci.GetResponseType:
//TODO: error handling
- _ = oo.handleOmciGetResponseMessage(msg)
+ _ = oo.handleOmciGetResponseMessage(ctx, msg)
default:
- log.Warnw("Unknown Message Type", log.Fields{"msgType": msg.OmciMsg.MessageType})
+ logger.Warnw(ctx, "Unknown Message Type", log.Fields{"msgType": msg.OmciMsg.MessageType})
}
}
-func (oo *OnuDeviceEntry) handleOmciGetResponseErrors(msgObj *omci.GetResponse) error {
+func (oo *OnuDeviceEntry) handleOmciGetResponseErrors(ctx context.Context, msgObj *omci.GetResponse) error {
var err error = nil
- logger.Debugf("MibSync FSM - erroneous result in GetResponse Data: %s", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj}, msgObj.Result)
+ logger.Debugf(ctx, "MibSync FSM - erroneous result in GetResponse Data: %s", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj}, msgObj.Result)
// Up to now the following erroneous results have been seen for different ONU-types to indicate an unsupported ME
if msgObj.Result == me.UnknownInstance || msgObj.Result == me.UnknownEntity || msgObj.Result == me.ProcessingError || msgObj.Result == me.NotSupported {
entityID := oo.PDevOmciCC.pLastTxMeInstance.GetEntityID()
@@ -491,19 +491,19 @@
meInstance := oo.PDevOmciCC.pLastTxMeInstance.GetName()
switch meInstance {
case "IpHostConfigData":
- logger.Debugw("MibSync FSM - erroneous result for IpHostConfigData received - ONU doesn't support ME - fill macAddress with zeros",
+ logger.Debugw(ctx, "MibSync FSM - erroneous result for IpHostConfigData received - ONU doesn't support ME - fill macAddress with zeros",
log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
oo.macAddress = cEmptyMacAddrString
// trigger retrieval of mib template
_ = oo.pMibUploadFsm.pFsm.Event(ulEvGetMibTemplate)
return nil
default:
- logger.Warnf("MibSync FSM - erroneous result for %s received - no exceptional treatment defined", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj}, meInstance)
+ logger.Warnf(ctx, "MibSync FSM - erroneous result for %s received - no exceptional treatment defined", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj}, meInstance)
err = fmt.Errorf("erroneous result for %s received - no exceptional treatment defined: %s", meInstance, oo.deviceID)
}
}
} else {
- logger.Errorf("MibSync FSM - erroneous result in GetResponse Data: %s", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj}, msgObj.Result)
+ logger.Errorf(ctx, "MibSync FSM - erroneous result in GetResponse Data: %s", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj}, msgObj.Result)
err = fmt.Errorf("erroneous result in GetResponse Data: %s - %s", msgObj.Result, oo.deviceID)
}
return err
@@ -523,30 +523,30 @@
return fmt.Sprintf("%s", bytes.Trim(ifBytes, "\x00"))
}
-func (oo *OnuDeviceEntry) mibDbVolatileDict() error {
- logger.Debug("MibVolatileDict- running from default Entry code")
+func (oo *OnuDeviceEntry) mibDbVolatileDict(ctx context.Context) error {
+ logger.Debug(ctx, "MibVolatileDict- running from default Entry code")
return errors.New("not_implemented")
}
// createAndPersistMibTemplate method creates a mib template for the device id when operator enables the ONU device for the first time.
// We are creating a placeholder for "SerialNumber" for ME Class ID 6 and 256 and "MacAddress" for ME Class ID 134 in the template
// and then storing the template into etcd "service/voltha/omci_mibs/go_templates/verdor_id/equipment_id/software_version" path.
-func (oo *OnuDeviceEntry) createAndPersistMibTemplate() error {
- logger.Debugw("MibSync - MibTemplate - path name", log.Fields{"path": oo.mibTemplatePath,
+func (oo *OnuDeviceEntry) createAndPersistMibTemplate(ctx context.Context) error {
+ logger.Debugw(ctx, "MibSync - MibTemplate - path name", log.Fields{"path": oo.mibTemplatePath,
"device-id": oo.deviceID})
oo.pOpenOnuAc.lockMibTemplateGenerated.Lock()
if mibTemplateIsGenerated, exist := oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath]; exist {
if mibTemplateIsGenerated {
- logger.Debugw("MibSync - MibTemplate - another thread has already started to generate it - skip",
+ logger.Debugw(ctx, "MibSync - MibTemplate - another thread has already started to generate it - skip",
log.Fields{"path": oo.mibTemplatePath, "device-id": oo.deviceID})
oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
return nil
}
- logger.Debugw("MibSync - MibTemplate - previous generation attempt seems to be failed - try again",
+ logger.Debugw(ctx, "MibSync - MibTemplate - previous generation attempt seems to be failed - try again",
log.Fields{"path": oo.mibTemplatePath, "device-id": oo.deviceID})
} else {
- logger.Debugw("MibSync - MibTemplate - first ONU-instance of this kind - start generation",
+ logger.Debugw(ctx, "MibSync - MibTemplate - first ONU-instance of this kind - start generation",
log.Fields{"path": oo.mibTemplatePath, "device-id": oo.deviceID})
}
oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath] = true
@@ -559,7 +559,7 @@
firstLevelMap := oo.pOnuDB.meDb
for firstLevelKey, firstLevelValue := range firstLevelMap {
- logger.Debugw("MibSync - MibTemplate - firstLevelKey", log.Fields{"firstLevelKey": firstLevelKey})
+ logger.Debugw(ctx, "MibSync - MibTemplate - firstLevelKey", log.Fields{"firstLevelKey": firstLevelKey})
classID := strconv.Itoa(int(firstLevelKey))
secondLevelMap := make(map[string]interface{})
@@ -586,21 +586,21 @@
}
mibTemplate, err := json.Marshal(&templateMap)
if err != nil {
- logger.Errorw("MibSync - MibTemplate - Failed to marshal mibTemplate", log.Fields{"error": err, "device-id": oo.deviceID})
+ logger.Errorw(ctx, "MibSync - MibTemplate - Failed to marshal mibTemplate", log.Fields{"error": err, "device-id": oo.deviceID})
oo.pOpenOnuAc.lockMibTemplateGenerated.Lock()
oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath] = false
oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
return err
}
- err = oo.mibTemplateKVStore.Put(context.TODO(), oo.mibTemplatePath, string(mibTemplate))
+ err = oo.mibTemplateKVStore.Put(log.WithSpanFromContext(context.TODO(), ctx), oo.mibTemplatePath, string(mibTemplate))
if err != nil {
- logger.Errorw("MibSync - MibTemplate - Failed to store template in etcd", log.Fields{"error": err, "device-id": oo.deviceID})
+ logger.Errorw(ctx, "MibSync - MibTemplate - Failed to store template in etcd", log.Fields{"error": err, "device-id": oo.deviceID})
oo.pOpenOnuAc.lockMibTemplateGenerated.Lock()
oo.pOpenOnuAc.mibTemplatesGenerated[oo.mibTemplatePath] = false
oo.pOpenOnuAc.lockMibTemplateGenerated.Unlock()
return err
}
- logger.Debugw("MibSync - MibTemplate - Stored the template to etcd", log.Fields{"device-id": oo.deviceID})
+ logger.Debugw(ctx, "MibSync - MibTemplate - Stored the template to etcd", log.Fields{"device-id": oo.deviceID})
return nil
}
diff --git a/internal/pkg/onuadaptercore/omci_ani_config.go b/internal/pkg/onuadaptercore/omci_ani_config.go
index 2cef989..72fd42e 100644
--- a/internal/pkg/onuadaptercore/omci_ani_config.go
+++ b/internal/pkg/onuadaptercore/omci_ani_config.go
@@ -29,10 +29,10 @@
"github.com/looplab/fsm"
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- //ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- //"github.com/opencord/voltha-protos/v3/go/openflow_13"
- //"github.com/opencord/voltha-protos/v3/go/voltha"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
+ //ic "github.com/opencord/voltha-protos/v4/go/inter_container"
+ //"github.com/opencord/voltha-protos/v4/go/openflow_13"
+ //"github.com/opencord/voltha-protos/v4/go/voltha"
)
const (
@@ -123,7 +123,7 @@
}
//newUniPonAniConfigFsm is the 'constructor' for the state machine to config the PON ANI ports of ONU UNI ports via OMCI
-func newUniPonAniConfigFsm(apDevOmciCC *omciCC, apUniPort *onuUniPort, apUniTechProf *onuUniTechProf,
+func newUniPonAniConfigFsm(ctx context.Context, apDevOmciCC *omciCC, apUniPort *onuUniPort, apUniTechProf *onuUniTechProf,
apOnuDB *onuDeviceDB, aTechProfileID uint8, aRequestEvent OnuDeviceEvent, aName string,
apDeviceHandler *deviceHandler, aCommChannel chan Message) *uniPonAniConfigFsm {
instFsm := &uniPonAniConfigFsm{
@@ -141,7 +141,7 @@
instFsm.pAdaptFsm = NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
if instFsm.pAdaptFsm == nil {
- logger.Errorw("uniPonAniConfigFsm's AdapterFsm could not be instantiated!!", log.Fields{
+ logger.Errorw(ctx, "uniPonAniConfigFsm's AdapterFsm could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
}
@@ -192,33 +192,33 @@
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(e) },
- ("enter_" + aniStStarting): func(e *fsm.Event) { instFsm.enterConfigStartingState(e) },
- ("enter_" + aniStCreatingDot1PMapper): func(e *fsm.Event) { instFsm.enterCreatingDot1PMapper(e) },
- ("enter_" + aniStCreatingMBPCD): func(e *fsm.Event) { instFsm.enterCreatingMBPCD(e) },
- ("enter_" + aniStSettingTconts): func(e *fsm.Event) { instFsm.enterSettingTconts(e) },
- ("enter_" + aniStCreatingGemNCTPs): func(e *fsm.Event) { instFsm.enterCreatingGemNCTPs(e) },
- ("enter_" + aniStCreatingGemIWs): func(e *fsm.Event) { instFsm.enterCreatingGemIWs(e) },
- ("enter_" + aniStSettingPQs): func(e *fsm.Event) { instFsm.enterSettingPQs(e) },
- ("enter_" + aniStSettingDot1PMapper): func(e *fsm.Event) { instFsm.enterSettingDot1PMapper(e) },
- ("enter_" + aniStConfigDone): func(e *fsm.Event) { instFsm.enterAniConfigDone(e) },
- ("enter_" + aniStRemovingGemIW): func(e *fsm.Event) { instFsm.enterRemovingGemIW(e) },
- ("enter_" + aniStRemovingGemNCTP): func(e *fsm.Event) { instFsm.enterRemovingGemNCTP(e) },
- ("enter_" + aniStResetTcont): func(e *fsm.Event) { instFsm.enterResettingTcont(e) },
- ("enter_" + aniStRemDot1PMapper): func(e *fsm.Event) { instFsm.enterRemoving1pMapper(e) },
- ("enter_" + aniStRemAniBPCD): func(e *fsm.Event) { instFsm.enterRemovingAniBPCD(e) },
- ("enter_" + aniStRemoveDone): func(e *fsm.Event) { instFsm.enterAniRemoveDone(e) },
- ("enter_" + aniStResetting): func(e *fsm.Event) { instFsm.enterResettingState(e) },
- ("enter_" + aniStDisabled): func(e *fsm.Event) { instFsm.enterDisabledState(e) },
+ "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
+ ("enter_" + aniStStarting): func(e *fsm.Event) { instFsm.enterConfigStartingState(ctx, e) },
+ ("enter_" + aniStCreatingDot1PMapper): func(e *fsm.Event) { instFsm.enterCreatingDot1PMapper(ctx, e) },
+ ("enter_" + aniStCreatingMBPCD): func(e *fsm.Event) { instFsm.enterCreatingMBPCD(ctx, e) },
+ ("enter_" + aniStSettingTconts): func(e *fsm.Event) { instFsm.enterSettingTconts(ctx, e) },
+ ("enter_" + aniStCreatingGemNCTPs): func(e *fsm.Event) { instFsm.enterCreatingGemNCTPs(ctx, e) },
+ ("enter_" + aniStCreatingGemIWs): func(e *fsm.Event) { instFsm.enterCreatingGemIWs(ctx, e) },
+ ("enter_" + aniStSettingPQs): func(e *fsm.Event) { instFsm.enterSettingPQs(ctx, e) },
+ ("enter_" + aniStSettingDot1PMapper): func(e *fsm.Event) { instFsm.enterSettingDot1PMapper(ctx, e) },
+ ("enter_" + aniStConfigDone): func(e *fsm.Event) { instFsm.enterAniConfigDone(ctx, e) },
+ ("enter_" + aniStRemovingGemIW): func(e *fsm.Event) { instFsm.enterRemovingGemIW(ctx, e) },
+ ("enter_" + aniStRemovingGemNCTP): func(e *fsm.Event) { instFsm.enterRemovingGemNCTP(ctx, e) },
+ ("enter_" + aniStResetTcont): func(e *fsm.Event) { instFsm.enterResettingTcont(ctx, e) },
+ ("enter_" + aniStRemDot1PMapper): func(e *fsm.Event) { instFsm.enterRemoving1pMapper(ctx, e) },
+ ("enter_" + aniStRemAniBPCD): func(e *fsm.Event) { instFsm.enterRemovingAniBPCD(ctx, e) },
+ ("enter_" + aniStRemoveDone): func(e *fsm.Event) { instFsm.enterAniRemoveDone(ctx, e) },
+ ("enter_" + aniStResetting): func(e *fsm.Event) { instFsm.enterResettingState(ctx, e) },
+ ("enter_" + aniStDisabled): func(e *fsm.Event) { instFsm.enterDisabledState(ctx, e) },
},
)
if instFsm.pAdaptFsm.pFsm == nil {
- logger.Errorw("uniPonAniConfigFsm's Base FSM could not be instantiated!!", log.Fields{
+ logger.Errorw(ctx, "uniPonAniConfigFsm's Base FSM could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
}
- logger.Debugw("uniPonAniConfigFsm created", log.Fields{"device-id": instFsm.deviceID})
+ logger.Debugw(ctx, "uniPonAniConfigFsm created", log.Fields{"device-id": instFsm.deviceID})
return instFsm
}
@@ -229,7 +229,7 @@
oFsm.chanSet = true
}
-func (oFsm *uniPonAniConfigFsm) prepareAndEnterConfigState(aPAFsm *AdapterFsm) {
+func (oFsm *uniPonAniConfigFsm) prepareAndEnterConfigState(ctx context.Context, aPAFsm *AdapterFsm) {
if aPAFsm != nil && aPAFsm.pFsm != nil {
//stick to pythonAdapter numbering scheme
//index 0 in naming refers to possible usage of multiple instances (later)
@@ -240,7 +240,7 @@
// Find a free TCONT Instance ID and use it
foundFreeTcontInstID := false
*/
- if tcontInstKeys := oFsm.pOnuDB.getSortedInstKeys(me.TContClassID); len(tcontInstKeys) > 0 {
+ if tcontInstKeys := oFsm.pOnuDB.getSortedInstKeys(ctx, me.TContClassID); len(tcontInstKeys) > 0 {
// FIXME: Ideally the ME configurations on the ONU should constantly be MIB Synced back to the ONU DB
// So, as soon as we use up a TCONT Entity on the ONU, the DB at ONU adapter should know that the TCONT
@@ -278,10 +278,10 @@
// Here the assumption is TP ID will always start from 64 (this is also true to Technology Profile Specification) and the
// TP ID will increment in single digit
oFsm.tcont0ID = tcontInstKeys[oFsm.techProfileID-tpIDOffset]
- logger.Debugw("Used TcontId:", log.Fields{"TcontId": strconv.FormatInt(int64(oFsm.tcont0ID), 16),
+ logger.Debugw(ctx, "Used TcontId:", log.Fields{"TcontId": strconv.FormatInt(int64(oFsm.tcont0ID), 16),
"device-id": oFsm.deviceID})
} else {
- logger.Errorw("tech profile id not in valid range", log.Fields{"device-id": oFsm.deviceID, "tp-id": oFsm.techProfileID, "num-tcont": len(tcontInstKeys)})
+ logger.Errorw(ctx, "tech profile id not in valid range", log.Fields{"device-id": oFsm.deviceID, "tp-id": oFsm.techProfileID, "num-tcont": len(tcontInstKeys)})
if oFsm.chanSet {
// indicate processing error/abort to the caller
oFsm.chSuccess <- 0
@@ -292,7 +292,7 @@
return
}
} else {
- logger.Errorw("No TCont instances found", log.Fields{"device-id": oFsm.deviceID})
+ logger.Errorw(ctx, "No TCont instances found", log.Fields{"device-id": oFsm.deviceID})
return
}
/*
@@ -313,7 +313,7 @@
//collect all GemConfigData in a separate Fsm related slice (needed also to avoid mix-up with unsorted mapPonAniConfig)
- if queueInstKeys := oFsm.pOnuDB.getSortedInstKeys(me.PriorityQueueClassID); len(queueInstKeys) > 0 {
+ if queueInstKeys := oFsm.pOnuDB.getSortedInstKeys(ctx, me.PriorityQueueClassID); len(queueInstKeys) > 0 {
loGemPortAttribs.gemPortID = gemEntry.gemPortID
// MibDb usage: upstream PrioQueue.RelatedPort = xxxxyyyy with xxxx=TCont.Entity(incl. slot) and yyyy=prio
@@ -337,12 +337,12 @@
if relatedPort, err := oFsm.pOnuDB.getUint32Attrib(returnVal); err == nil {
if relatedPort == usQrelPortMask {
loGemPortAttribs.upQueueID = mgmtEntityID
- logger.Debugw("UpQueue for GemPort found:", log.Fields{"gemPortID": loGemPortAttribs.gemPortID,
+ logger.Debugw(ctx, "UpQueue for GemPort found:", log.Fields{"gemPortID": loGemPortAttribs.gemPortID,
"upQueueID": strconv.FormatInt(int64(loGemPortAttribs.upQueueID), 16), "device-id": oFsm.deviceID})
usQueueFound = true
} else if (relatedPort&0xFFFFFF) == dsQrelPortMask && mgmtEntityID < 0x8000 {
loGemPortAttribs.downQueueID = mgmtEntityID
- logger.Debugw("DownQueue for GemPort found:", log.Fields{"gemPortID": loGemPortAttribs.gemPortID,
+ logger.Debugw(ctx, "DownQueue for GemPort found:", log.Fields{"gemPortID": loGemPortAttribs.gemPortID,
"downQueueID": strconv.FormatInt(int64(loGemPortAttribs.downQueueID), 16), "device-id": oFsm.deviceID})
dsQueueFound = true
}
@@ -350,18 +350,18 @@
break
}
} else {
- logger.Warnw("Could not convert attribute value", log.Fields{"device-id": oFsm.deviceID})
+ logger.Warnw(ctx, "Could not convert attribute value", log.Fields{"device-id": oFsm.deviceID})
}
} else {
- logger.Warnw("'RelatedPort' not found in meAttributes:", log.Fields{"device-id": oFsm.deviceID})
+ logger.Warnw(ctx, "'RelatedPort' not found in meAttributes:", log.Fields{"device-id": oFsm.deviceID})
}
} else {
- logger.Warnw("No attributes available in DB:", log.Fields{"meClassID": me.PriorityQueueClassID,
+ logger.Warnw(ctx, "No attributes available in DB:", log.Fields{"meClassID": me.PriorityQueueClassID,
"mgmtEntityID": mgmtEntityID, "device-id": oFsm.deviceID})
}
}
} else {
- logger.Warnw("No PriorityQueue instances found", log.Fields{"device-id": oFsm.deviceID})
+ logger.Warnw(ctx, "No PriorityQueue instances found", log.Fields{"device-id": oFsm.deviceID})
}
loGemPortAttribs.direction = gemEntry.direction
loGemPortAttribs.qosPolicy = gemEntry.queueSchedPolicy
@@ -375,7 +375,7 @@
loGemPortAttribs.staticACL = gemEntry.staticACL
loGemPortAttribs.dynamicACL = gemEntry.dynamicACL
- logger.Debugw("Multicast GemPort attributes:", log.Fields{
+ logger.Debugw(ctx, "Multicast GemPort attributes:", log.Fields{
"gemPortID": loGemPortAttribs.gemPortID,
"isMulticast": loGemPortAttribs.isMulticast,
"multicastGemID": loGemPortAttribs.multicastGemID,
@@ -384,7 +384,7 @@
})
} else {
- logger.Debugw("Upstream GemPort attributes:", log.Fields{
+ logger.Debugw(ctx, "Upstream GemPort attributes:", log.Fields{
"gemPortID": loGemPortAttribs.gemPortID,
"upQueueID": loGemPortAttribs.upQueueID,
"downQueueID": loGemPortAttribs.downQueueID,
@@ -399,13 +399,13 @@
}
}
-func (oFsm *uniPonAniConfigFsm) enterConfigStartingState(e *fsm.Event) {
- logger.Debugw("UniPonAniConfigFsm start", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterConfigStartingState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniPonAniConfigFsm start", log.Fields{
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
// in case the used channel is not yet defined (can be re-used after restarts)
if oFsm.omciMIdsResponseReceived == nil {
oFsm.omciMIdsResponseReceived = make(chan bool)
- logger.Debug("uniPonAniConfigFsm - OMCI multiInstance RxChannel defined")
+ logger.Debug(ctx, "uniPonAniConfigFsm - OMCI multiInstance RxChannel defined")
} else {
// as we may 're-use' this instance of FSM and the connected channel
// make sure there is no 'lingering' request in the already existing channel:
@@ -418,31 +418,31 @@
oFsm.gemPortAttribsSlice = nil
// start go routine for processing of LockState messages
- go oFsm.processOmciAniMessages()
+ go oFsm.processOmciAniMessages(ctx)
//let the state machine run forward from here directly
pConfigAniStateAFsm := oFsm.pAdaptFsm
if pConfigAniStateAFsm != nil {
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
- go oFsm.prepareAndEnterConfigState(pConfigAniStateAFsm)
+ go oFsm.prepareAndEnterConfigState(ctx, pConfigAniStateAFsm)
}
}
-func (oFsm *uniPonAniConfigFsm) enterCreatingDot1PMapper(e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm Tx Create::Dot1PMapper", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterCreatingDot1PMapper(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::Dot1PMapper", log.Fields{
"EntitytId": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
oFsm.requestEventOffset = 0 //0 offset for last config request activity
- meInstance := oFsm.pOmciCC.sendCreateDot1PMapper(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendCreateDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.mapperSP0ID, oFsm.pAdaptFsm.commChan)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
}
-func (oFsm *uniPonAniConfigFsm) enterCreatingMBPCD(e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm Tx Create::MBPCD", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterCreatingMBPCD(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::MBPCD", log.Fields{
"EntitytId": strconv.FormatInt(int64(oFsm.macBPCD0ID), 16),
"TPPtr": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
@@ -456,15 +456,15 @@
"TpPointer": oFsm.mapperSP0ID,
},
}
- meInstance := oFsm.pOmciCC.sendCreateMBPConfigDataVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendCreateMBPConfigDataVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
}
-func (oFsm *uniPonAniConfigFsm) enterSettingTconts(e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm Tx Set::Tcont", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterSettingTconts(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::Tcont", log.Fields{
"EntitytId": strconv.FormatInt(int64(oFsm.tcont0ID), 16),
"AllocId": strconv.FormatInt(int64(oFsm.alloc0ID), 16),
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
@@ -474,38 +474,38 @@
"AllocId": oFsm.alloc0ID,
},
}
- meInstance := oFsm.pOmciCC.sendSetTcontVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
}
-func (oFsm *uniPonAniConfigFsm) enterCreatingGemNCTPs(e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm - start creating GemNWCtp loop", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterCreatingGemNCTPs(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "uniPonAniConfigFsm - start creating GemNWCtp loop", log.Fields{
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
- go oFsm.performCreatingGemNCTPs()
+ go oFsm.performCreatingGemNCTPs(ctx)
}
-func (oFsm *uniPonAniConfigFsm) enterCreatingGemIWs(e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm - start creating GemIwTP loop", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterCreatingGemIWs(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "uniPonAniConfigFsm - start creating GemIwTP loop", log.Fields{
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
- go oFsm.performCreatingGemIWs()
+ go oFsm.performCreatingGemIWs(ctx)
}
-func (oFsm *uniPonAniConfigFsm) enterSettingPQs(e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm - start setting PrioQueue loop", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterSettingPQs(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "uniPonAniConfigFsm - start setting PrioQueue loop", log.Fields{
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
- go oFsm.performSettingPQs()
+ go oFsm.performSettingPQs(ctx)
}
-func (oFsm *uniPonAniConfigFsm) enterSettingDot1PMapper(e *fsm.Event) {
+func (oFsm *uniPonAniConfigFsm) enterSettingDot1PMapper(ctx context.Context, e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm Tx Set::.1pMapper with all PBits set", log.Fields{"EntitytId": 0x8042, /*cmp above*/
+ logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::.1pMapper with all PBits set", log.Fields{"EntitytId": 0x8042, /*cmp above*/
"toGemIw": 1024, /* cmp above */
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
- logger.Debugw("uniPonAniConfigFsm Tx Set::1pMapper", log.Fields{
+ logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::1pMapper", log.Fields{
"EntitytId": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
@@ -518,13 +518,13 @@
var loPrioGemPortArray [8]uint16
for _, gemPortAttribs := range oFsm.gemPortAttribsSlice {
if gemPortAttribs.isMulticast {
- logger.Debugw("uniPonAniConfigFsm Port is Multicast, ignoring .1pMapper", log.Fields{
+ logger.Debugw(ctx, "uniPonAniConfigFsm Port is Multicast, ignoring .1pMapper", log.Fields{
"device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID,
"prioString": gemPortAttribs.pbitString})
continue
}
if gemPortAttribs.pbitString == "" {
- logger.Warnw("uniPonAniConfigFsm PrioString empty string error", log.Fields{
+ logger.Warnw(ctx, "uniPonAniConfigFsm PrioString empty string error", log.Fields{
"device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID,
"prioString": gemPortAttribs.pbitString})
continue
@@ -536,13 +536,13 @@
if loPrioGemPortArray[i] == 0 {
loPrioGemPortArray[i] = gemPortAttribs.gemPortID //gemPortId=EntityID and unique
} else {
- logger.Warnw("uniPonAniConfigFsm PrioString not unique", log.Fields{
+ logger.Warnw(ctx, "uniPonAniConfigFsm PrioString not unique", log.Fields{
"device-id": oFsm.deviceID, "IgnoredGemPort": gemPortAttribs.gemPortID,
"SetGemPort": loPrioGemPortArray[i]})
}
}
} else {
- logger.Warnw("uniPonAniConfigFsm PrioString evaluation error", log.Fields{
+ logger.Warnw(ctx, "uniPonAniConfigFsm PrioString evaluation error", log.Fields{
"device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID,
"prioString": gemPortAttribs.pbitString, "position": i})
}
@@ -556,7 +556,7 @@
if value != 0 {
foundIwPtr = true
meParams.Attributes[meAttribute] = value
- logger.Debugw("UniPonAniConfigFsm Set::1pMapper", log.Fields{
+ logger.Debugw(ctx, "UniPonAniConfigFsm Set::1pMapper", log.Fields{
"for Prio": index,
"IwPtr": strconv.FormatInt(int64(value), 16),
"device-id": oFsm.deviceID})
@@ -569,7 +569,7 @@
meParams.Attributes["TpPointer"] = 0xffff
if !foundIwPtr {
- logger.Debugw("UniPonAniConfigFsm no GemIwPtr found for .1pMapper - abort", log.Fields{
+ logger.Debugw(ctx, "UniPonAniConfigFsm no GemIwPtr found for .1pMapper - abort", log.Fields{
"device-id": oFsm.deviceID})
//TODO With multicast is possible that no upstream gem ports are not present in the tech profile,
// this reset needs to be performed only if the tech profile provides upstream gem ports but no priority is set
@@ -600,25 +600,24 @@
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
}
-
}
-func (oFsm *uniPonAniConfigFsm) enterAniConfigDone(e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm ani config done", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterAniConfigDone(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "uniPonAniConfigFsm ani config done", log.Fields{
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
//use DeviceHandler event notification directly
- oFsm.pDeviceHandler.deviceProcStatusUpdate(OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset)))
+ oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset)))
//store that the UNI related techProfile processing is done for the given Profile and Uni
oFsm.pUniTechProf.setConfigDone(oFsm.pOnuUniPort.uniID, oFsm.techProfileID, true)
//if techProfile processing is done it must be checked, if some prior/parallel flow configuration is pending
// but only in case the techProfile was configured (not deleted)
if oFsm.requestEventOffset == 0 {
- go oFsm.pDeviceHandler.verifyUniVlanConfigRequest(oFsm.pOnuUniPort)
+ go oFsm.pDeviceHandler.verifyUniVlanConfigRequest(ctx, oFsm.pOnuUniPort)
}
if oFsm.chanSet {
// indicate processing done to the caller
- logger.Debugw("uniPonAniConfigFsm processingDone on channel", log.Fields{
+ logger.Debugw(ctx, "uniPonAniConfigFsm processingDone on channel", log.Fields{
"ProcessingStep": oFsm.procStep, "from_State": e.FSM.Current(), "device-id": oFsm.deviceID})
oFsm.chSuccess <- oFsm.procStep
oFsm.chanSet = false //reset the internal channel state
@@ -627,37 +626,37 @@
//the FSM is left active in this state as long as no specific reset or remove is requested from outside
}
-func (oFsm *uniPonAniConfigFsm) enterRemovingGemIW(e *fsm.Event) {
+func (oFsm *uniPonAniConfigFsm) enterRemovingGemIW(ctx context.Context, e *fsm.Event) {
// get the related GemPort entity Id from pUniTechProf, OMCI Gem* entityID is set to be equal to GemPortId!
oFsm.pUniTechProf.mutexTPState.Lock()
loGemPortID := (*(oFsm.pUniTechProf.mapRemoveGemEntry[oFsm.uniTpKey])).gemPortID
oFsm.pUniTechProf.mutexTPState.Unlock()
- logger.Debugw("uniPonAniConfigFsm - start removing one GemIwTP", log.Fields{
+ logger.Debugw(ctx, "uniPonAniConfigFsm - start removing one GemIwTP", log.Fields{
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
"GemIwTp-entity-id": loGemPortID})
oFsm.requestEventOffset = 1 //offset 1 to indicate last activity = remove
// this state entry is only expected in a suitable state (checked outside in onu_uni_tp)
- meInstance := oFsm.pOmciCC.sendDeleteGemIWTP(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendDeleteGemIWTP(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, loGemPortID)
oFsm.pLastTxMeInstance = meInstance
}
-func (oFsm *uniPonAniConfigFsm) enterRemovingGemNCTP(e *fsm.Event) {
+func (oFsm *uniPonAniConfigFsm) enterRemovingGemNCTP(ctx context.Context, e *fsm.Event) {
oFsm.pUniTechProf.mutexTPState.Lock()
loGemPortID := (*(oFsm.pUniTechProf.mapRemoveGemEntry[oFsm.uniTpKey])).gemPortID
oFsm.pUniTechProf.mutexTPState.Unlock()
- logger.Debugw("uniPonAniConfigFsm - start removing one GemNCTP", log.Fields{
+ logger.Debugw(ctx, "uniPonAniConfigFsm - start removing one GemNCTP", log.Fields{
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID,
"GemNCTP-entity-id": loGemPortID})
// this state entry is only expected in a suitable state (checked outside in onu_uni_tp)
- meInstance := oFsm.pOmciCC.sendDeleteGemNCTP(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendDeleteGemNCTP(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, loGemPortID)
oFsm.pLastTxMeInstance = meInstance
}
-func (oFsm *uniPonAniConfigFsm) enterResettingTcont(e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm - start resetting the TCont", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterResettingTcont(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "uniPonAniConfigFsm - start resetting the TCont", log.Fields{
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
oFsm.requestEventOffset = 1 //offset 1 for last remove activity
@@ -668,37 +667,37 @@
"AllocId": unusedTcontAllocID,
},
}
- meInstance := oFsm.pOmciCC.sendSetTcontVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
oFsm.pLastTxMeInstance = meInstance
}
-func (oFsm *uniPonAniConfigFsm) enterRemoving1pMapper(e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm - start deleting the .1pMapper", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterRemoving1pMapper(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "uniPonAniConfigFsm - start deleting the .1pMapper", log.Fields{
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
- meInstance := oFsm.pOmciCC.sendDeleteDot1PMapper(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendDeleteDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, oFsm.mapperSP0ID)
oFsm.pLastTxMeInstance = meInstance
}
-func (oFsm *uniPonAniConfigFsm) enterRemovingAniBPCD(e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm - start deleting the ANI MBCD", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterRemovingAniBPCD(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "uniPonAniConfigFsm - start deleting the ANI MBCD", log.Fields{
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
- meInstance := oFsm.pOmciCC.sendDeleteMBPConfigData(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendDeleteMBPConfigData(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, oFsm.macBPCD0ID)
oFsm.pLastTxMeInstance = meInstance
}
-func (oFsm *uniPonAniConfigFsm) enterAniRemoveDone(e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm ani removal done", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterAniRemoveDone(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "uniPonAniConfigFsm ani removal done", log.Fields{
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
//use DeviceHandler event notification directly
- oFsm.pDeviceHandler.deviceProcStatusUpdate(OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset)))
+ oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset)))
if oFsm.chanSet {
// indicate processing done to the caller
- logger.Debugw("uniPonAniConfigFsm processingDone on channel", log.Fields{
+ logger.Debugw(ctx, "uniPonAniConfigFsm processingDone on channel", log.Fields{
"ProcessingStep": oFsm.procStep, "from_State": e.FSM.Current(), "device-id": oFsm.deviceID})
oFsm.chSuccess <- oFsm.procStep
oFsm.chanSet = false //reset the internal channel state
@@ -716,8 +715,8 @@
}
}
-func (oFsm *uniPonAniConfigFsm) enterResettingState(e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm resetting", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterResettingState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "uniPonAniConfigFsm resetting", log.Fields{
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
pConfigAniStateAFsm := oFsm.pAdaptFsm
@@ -740,17 +739,17 @@
}
}
-func (oFsm *uniPonAniConfigFsm) enterDisabledState(e *fsm.Event) {
- logger.Debugw("uniPonAniConfigFsm enters disabled state", log.Fields{
+func (oFsm *uniPonAniConfigFsm) enterDisabledState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "uniPonAniConfigFsm enters disabled state", log.Fields{
"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID})
oFsm.pLastTxMeInstance = nil
//remove all TechProf related internal data to allow for new configuration (e.g. with disable/enable procedure)
- oFsm.pUniTechProf.clearAniSideConfig(oFsm.pOnuUniPort.uniID, oFsm.techProfileID)
+ oFsm.pUniTechProf.clearAniSideConfig(ctx, oFsm.pOnuUniPort.uniID, oFsm.techProfileID)
}
-func (oFsm *uniPonAniConfigFsm) processOmciAniMessages( /*ctx context.Context*/ ) {
- logger.Debugw("Start uniPonAniConfigFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID})
+func (oFsm *uniPonAniConfigFsm) processOmciAniMessages(ctx context.Context) {
+ logger.Debugw(ctx, "Start uniPonAniConfigFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID})
loop:
for {
// case <-ctx.Done():
@@ -758,47 +757,47 @@
// break loop
message, ok := <-oFsm.pAdaptFsm.commChan
if !ok {
- logger.Info("UniPonAniConfigFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
+ logger.Info(ctx, "UniPonAniConfigFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
// but then we have to ensure a restart of the FSM as well - as exceptional procedure
_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
break loop
}
- logger.Debugw("UniPonAniConfigFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "UniPonAniConfigFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
switch message.Type {
case TestMsg:
msg, _ := message.Data.(TestMessage)
if msg.TestMessageVal == AbortMessageProcessing {
- logger.Infow("UniPonAniConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Infow(ctx, "UniPonAniConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
break loop
}
- logger.Warnw("UniPonAniConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
+ logger.Warnw(ctx, "UniPonAniConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
case OMCI:
msg, _ := message.Data.(OmciMessage)
- oFsm.handleOmciAniConfigMessage(msg)
+ oFsm.handleOmciAniConfigMessage(ctx, msg)
default:
- logger.Warn("UniPonAniConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
+ logger.Warn(ctx, "UniPonAniConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
"message.Type": message.Type})
}
}
- logger.Infow("End uniPonAniConfigFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
+ logger.Infow(ctx, "End uniPonAniConfigFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
}
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigCreateResponseMessage(msg OmciMessage) {
+func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigCreateResponseMessage(ctx context.Context, msg OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse)
if msgLayer == nil {
- logger.Errorw("Omci Msg layer could not be detected for CreateResponse",
+ logger.Errorw(ctx, "Omci Msg layer could not be detected for CreateResponse",
log.Fields{"device-id": oFsm.deviceID})
return
}
msgObj, msgOk := msgLayer.(*omci.CreateResponse)
if !msgOk {
- logger.Errorw("Omci Msg layer could not be assigned for CreateResponse",
+ logger.Errorw(ctx, "Omci Msg layer could not be assigned for CreateResponse",
log.Fields{"device-id": oFsm.deviceID})
return
}
- logger.Debugw("CreateResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "CreateResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
if msgObj.Result == me.Success || msgObj.Result == me.InstanceExists {
//if the result is ok or Instance already exists (latest needed at least as long as we do not clear the OMCI techProfile data)
if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() &&
@@ -821,28 +820,28 @@
}
}
} else {
- logger.Errorw("Omci CreateResponse Error - later: drive FSM to abort state ?", log.Fields{"Error": msgObj.Result})
+ logger.Errorw(ctx, "Omci CreateResponse Error - later: drive FSM to abort state ?", log.Fields{"Error": msgObj.Result})
// possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
return
}
}
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigSetResponseMessage(msg OmciMessage) {
+func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigSetResponseMessage(ctx context.Context, msg OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse)
if msgLayer == nil {
- logger.Errorw("UniPonAniConfigFsm - Omci Msg layer could not be detected for SetResponse",
+ logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be detected for SetResponse",
log.Fields{"device-id": oFsm.deviceID})
return
}
msgObj, msgOk := msgLayer.(*omci.SetResponse)
if !msgOk {
- logger.Errorw("UniPonAniConfigFsm - Omci Msg layer could not be assigned for SetResponse",
+ logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be assigned for SetResponse",
log.Fields{"device-id": oFsm.deviceID})
return
}
- logger.Debugw("UniPonAniConfigFsm SetResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "UniPonAniConfigFsm SetResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
if msgObj.Result != me.Success {
- logger.Errorw("UniPonAniConfigFsm - Omci SetResponse Error - later: drive FSM to abort state ?",
+ logger.Errorw(ctx, "UniPonAniConfigFsm - Omci SetResponse Error - later: drive FSM to abort state ?",
log.Fields{"device-id": oFsm.deviceID, "Error": msgObj.Result})
// possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
return
@@ -874,22 +873,22 @@
}
}
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigDeleteResponseMessage(msg OmciMessage) {
+func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigDeleteResponseMessage(ctx context.Context, msg OmciMessage) {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeDeleteResponse)
if msgLayer == nil {
- logger.Errorw("UniPonAniConfigFsm - Omci Msg layer could not be detected for DeleteResponse",
+ logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be detected for DeleteResponse",
log.Fields{"device-id": oFsm.deviceID})
return
}
msgObj, msgOk := msgLayer.(*omci.DeleteResponse)
if !msgOk {
- logger.Errorw("UniPonAniConfigFsm - Omci Msg layer could not be assigned for DeleteResponse",
+ logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be assigned for DeleteResponse",
log.Fields{"device-id": oFsm.deviceID})
return
}
- logger.Debugw("UniPonAniConfigFsm DeleteResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "UniPonAniConfigFsm DeleteResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
if msgObj.Result != me.Success {
- logger.Errorw("UniPonAniConfigFsm - Omci DeleteResponse Error",
+ logger.Errorw(ctx, "UniPonAniConfigFsm - Omci DeleteResponse Error",
log.Fields{"device-id": oFsm.deviceID, "Error": msgObj.Result})
//TODO: - later: possibly force FSM into abort or ignore some errors for some messages?
// store error for mgmt display?
@@ -921,39 +920,39 @@
}
}
-func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigMessage(msg OmciMessage) {
- logger.Debugw("Rx OMCI UniPonAniConfigFsm Msg", log.Fields{"device-id": oFsm.deviceID,
+func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigMessage(ctx context.Context, msg OmciMessage) {
+ logger.Debugw(ctx, "Rx OMCI UniPonAniConfigFsm Msg", log.Fields{"device-id": oFsm.deviceID,
"msgType": msg.OmciMsg.MessageType})
switch msg.OmciMsg.MessageType {
case omci.CreateResponseType:
{
- oFsm.handleOmciAniConfigCreateResponseMessage(msg)
+ oFsm.handleOmciAniConfigCreateResponseMessage(ctx, msg)
} //CreateResponseType
case omci.SetResponseType:
{
- oFsm.handleOmciAniConfigSetResponseMessage(msg)
+ oFsm.handleOmciAniConfigSetResponseMessage(ctx, msg)
} //SetResponseType
case omci.DeleteResponseType:
{
- oFsm.handleOmciAniConfigDeleteResponseMessage(msg)
+ oFsm.handleOmciAniConfigDeleteResponseMessage(ctx, msg)
} //SetResponseType
default:
{
- logger.Errorw("uniPonAniConfigFsm - Rx OMCI unhandled MsgType",
+ logger.Errorw(ctx, "uniPonAniConfigFsm - Rx OMCI unhandled MsgType",
log.Fields{"omciMsgType": msg.OmciMsg.MessageType, "device-id": oFsm.deviceID})
return
}
}
}
-func (oFsm *uniPonAniConfigFsm) performCreatingGemNCTPs() {
+func (oFsm *uniPonAniConfigFsm) performCreatingGemNCTPs(ctx context.Context) {
// for all GemPorts of this T-Cont as given by the size of set gemPortAttribsSlice
for gemIndex, gemPortAttribs := range oFsm.gemPortAttribsSlice {
- logger.Debugw("uniPonAniConfigFsm Tx Create::GemNWCtp", log.Fields{
+ logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::GemNWCtp", log.Fields{
"EntitytId": strconv.FormatInt(int64(gemPortAttribs.gemPortID), 16),
"TcontId": strconv.FormatInt(int64(oFsm.tcont0ID), 16),
"device-id": oFsm.deviceID})
@@ -969,16 +968,16 @@
"PriorityQueuePointerForDownStream": gemPortAttribs.downQueueID,
},
}
- meInstance := oFsm.pOmciCC.sendCreateGemNCTPVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendCreateGemNCTPVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("GemNWCtp create failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "GemNWCtp create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex})
_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
return
@@ -986,14 +985,14 @@
} //for all GemPorts of this T-Cont
// if Config has been done for all GemPort instances let the FSM proceed
- logger.Debugw("GemNWCtp create loop finished", log.Fields{"device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "GemNWCtp create loop finished", log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxGemntcpsResp)
}
-func (oFsm *uniPonAniConfigFsm) performCreatingGemIWs() {
+func (oFsm *uniPonAniConfigFsm) performCreatingGemIWs(ctx context.Context) {
// for all GemPorts of this T-Cont as given by the size of set gemPortAttribsSlice
for gemIndex, gemPortAttribs := range oFsm.gemPortAttribsSlice {
- logger.Debugw("uniPonAniConfigFsm Tx Create::GemIwTp", log.Fields{
+ logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::GemIwTp", log.Fields{
"EntitytId": strconv.FormatInt(int64(gemPortAttribs.gemPortID), 16),
"SPPtr": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16),
"device-id": oFsm.deviceID})
@@ -1014,9 +1013,9 @@
true, oFsm.pAdaptFsm.commChan, meParams)
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("GemTP IW multicast create failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "GemTP IW multicast create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex})
_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
return
@@ -1059,9 +1058,9 @@
oFsm.pLastTxMeInstance = meInstance
}
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("GemTP create failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "GemTP create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex})
_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
return
@@ -1069,17 +1068,17 @@
} //for all GemPort's of this T-Cont
// if Config has been done for all GemPort instances let the FSM proceed
- logger.Debugw("GemIwTp create loop finished", log.Fields{"device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "GemIwTp create loop finished", log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxGemiwsResp)
}
-func (oFsm *uniPonAniConfigFsm) performSettingPQs() {
+func (oFsm *uniPonAniConfigFsm) performSettingPQs(ctx context.Context) {
const cu16StrictPrioWeight uint16 = 0xFFFF
//find all upstream PrioQueues related to this T-Cont
loQueueMap := ordered_map.NewOrderedMap()
for _, gemPortAttribs := range oFsm.gemPortAttribsSlice {
if gemPortAttribs.isMulticast {
- logger.Debugw("uniPonAniConfigFsm Port is Multicast, ignoring PQs", log.Fields{
+ logger.Debugw(ctx, "uniPonAniConfigFsm Port is Multicast, ignoring PQs", log.Fields{
"device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID,
"prioString": gemPortAttribs.pbitString})
continue
@@ -1113,29 +1112,29 @@
}
if (kv.Value).(uint16) == cu16StrictPrioWeight {
//StrictPrio indication
- logger.Debugw("uniPonAniConfigFsm Tx Set::PrioQueue to StrictPrio", log.Fields{
+ logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::PrioQueue to StrictPrio", log.Fields{
"EntitytId": strconv.FormatInt(int64(queueIndex), 16),
"device-id": oFsm.deviceID})
meParams.Attributes["TrafficSchedulerPointer"] = 0 //ensure T-Cont defined StrictPrio scheduling
} else {
//WRR indication
- logger.Debugw("uniPonAniConfigFsm Tx Set::PrioQueue to WRR", log.Fields{
+ logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::PrioQueue to WRR", log.Fields{
"EntitytId": strconv.FormatInt(int64(queueIndex), 16),
"Weight": kv.Value,
"device-id": oFsm.deviceID})
meParams.Attributes["TrafficSchedulerPointer"] = loTrafficSchedulerEID //ensure assignment of the relevant trafficScheduler
meParams.Attributes["Weight"] = uint8(kv.Value.(uint16))
}
- meInstance := oFsm.pOmciCC.sendSetPrioQueueVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendSetPrioQueueVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("PrioQueue set failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "PrioQueue set failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "QueueId": strconv.FormatInt(int64(queueIndex), 16)})
_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
return
@@ -1149,25 +1148,25 @@
} //for all upstream prioQueues
// if Config has been done for all PrioQueue instances let the FSM proceed
- logger.Debugw("PrioQueue set loop finished", log.Fields{"device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "PrioQueue set loop finished", log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxPrioqsResp)
}
-func (oFsm *uniPonAniConfigFsm) waitforOmciResponse() error {
+func (oFsm *uniPonAniConfigFsm) waitforOmciResponse(ctx context.Context) error {
select {
// maybe be also some outside cancel (but no context modeled for the moment ...)
// case <-ctx.Done():
// logger.Infow("LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.deviceID})
case <-time.After(30 * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
- logger.Warnw("UniPonAniConfigFsm multi entity timeout", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Warnw(ctx, "UniPonAniConfigFsm multi entity timeout", log.Fields{"for device-id": oFsm.deviceID})
return fmt.Errorf("uniPonAniConfigFsm multi entity timeout %s", oFsm.deviceID)
case success := <-oFsm.omciMIdsResponseReceived:
if success {
- logger.Debug("uniPonAniConfigFsm multi entity response received")
+ logger.Debug(ctx, "uniPonAniConfigFsm multi entity response received")
return nil
}
// should not happen so far
- logger.Warnw("uniPonAniConfigFsm multi entity response error", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Warnw(ctx, "uniPonAniConfigFsm multi entity response error", log.Fields{"for device-id": oFsm.deviceID})
return fmt.Errorf("uniPonAniConfigFsm multi entity responseError %s", oFsm.deviceID)
}
}
diff --git a/internal/pkg/onuadaptercore/omci_cc.go b/internal/pkg/onuadaptercore/omci_cc.go
index deb0905..8d6d4ef 100644
--- a/internal/pkg/onuadaptercore/omci_cc.go
+++ b/internal/pkg/onuadaptercore/omci_cc.go
@@ -35,13 +35,13 @@
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
- "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
+ "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
- //"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- //"github.com/opencord/voltha-protos/v3/go/openflow_13"
- //"github.com/opencord/voltha-protos/v3/go/voltha"
+ //"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
+ ic "github.com/opencord/voltha-protos/v4/go/inter_container"
+ //"github.com/opencord/voltha-protos/v4/go/openflow_13"
+ //"github.com/opencord/voltha-protos/v4/go/voltha"
)
// ### OMCI related definitions - retrieved from Python adapter code/trace ####
@@ -66,7 +66,7 @@
//callbackPairEntry to be used for OMCI send/receive correlation
type callbackPairEntry struct {
cbRespChannel chan Message
- cbFunction func(*omci.OMCI, *gp.Packet, chan Message) error
+ cbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
}
//callbackPair to be used for ReceiveCallback init
@@ -117,7 +117,7 @@
func newOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry,
deviceID string, deviceHandler *deviceHandler,
coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy) *omciCC {
- logger.Debugw("init-omciCC", log.Fields{"device-id": deviceID})
+ logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
var omciCC omciCC
omciCC.enabled = false
omciCC.pOnuDeviceEntry = onuDeviceEntry
@@ -144,7 +144,7 @@
//stop stops/resets the omciCC
func (oo *omciCC) stop(ctx context.Context) error {
- logger.Debugw("omciCC-stopping", log.Fields{"device-id": oo.deviceID})
+ logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
//reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
oo.mutexTxQueue.Lock()
oo.txQueue.Init() // clear the tx queue
@@ -175,7 +175,7 @@
// Rx handler for omci messages
func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI) error {
- logger.Debugw("rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
+ logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
"payload": hex.EncodeToString(omciMsg.Payload)})
/*
msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
@@ -214,7 +214,7 @@
}
default:
{
- logger.Errorw("rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
+ logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
rxOnuDiscards++
return errors.New("RxOnuMsgType unimplemented")
}
@@ -226,64 +226,64 @@
// Rx handler for onu messages
// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error {
- //logger.Debugw("cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
+ //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
// NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
// (am extendedFormat message could be destroyed this way!)
trailerLenData := rxMsg[42:44]
trailerLen := binary.BigEndian.Uint16(trailerLenData)
- //logger.Debugw("omci-received-trailer-len", log.Fields{"Length": trailerLen})
+ //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
if trailerLen != 40 { // invalid base Format entry -> autocorrect
binary.BigEndian.PutUint16(rxMsg[42:44], 40)
- logger.Debug("cc-corrected-omci-message: trailer len inserted")
+ logger.Debug(ctx, "cc-corrected-omci-message: trailer len inserted")
}
} else {
- logger.Errorw("received omci-message too small for OmciBaseFormat - abort", log.Fields{"Length": len(rxMsg)})
+ logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort", log.Fields{"Length": len(rxMsg)})
return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
}
packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
if packet == nil {
- logger.Errorw("omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
+ logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
}
omciLayer := packet.Layer(omci.LayerTypeOMCI)
if omciLayer == nil {
- logger.Errorw("omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
+ logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
}
omciMsg, ok := omciLayer.(*omci.OMCI)
if !ok {
- logger.Errorw("omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
+ logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
}
- logger.Debugw("omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
+ logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
"transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
if byte(omciMsg.MessageType)&me.AK == 0 {
// Not a response
- logger.Debug("RxMsg is no Omci Response Message")
+ logger.Debug(ctx, "RxMsg is no Omci Response Message")
if omciMsg.TransactionID == 0 {
return oo.receiveOnuMessage(ctx, omciMsg)
}
- logger.Errorw("Unexpected TransCorrId != 0 not accepted for autonomous messages",
+ logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
"device-id": oo.deviceID})
return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
}
- //logger.Debug("RxMsg is a Omci Response Message: try to schedule it to the requester")
+ //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
oo.mutexRxSchedMap.Lock()
rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
if ok && rxCallbackEntry.cbFunction != nil {
//disadvantage of decoupling: error verification made difficult, but anyway the question is
// how to react on erroneous frame reception, maybe can simply be ignored
- go rxCallbackEntry.cbFunction(omciMsg, &packet, rxCallbackEntry.cbRespChannel)
+ go rxCallbackEntry.cbFunction(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel)
// having posted the response the request is regarded as 'done'
delete(oo.rxSchedulerMap, omciMsg.TransactionID)
oo.mutexRxSchedMap.Unlock()
} else {
oo.mutexRxSchedMap.Unlock()
- logger.Errorw("omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
+ logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
}
@@ -402,7 +402,7 @@
func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
receiveCallbackPair callbackPair) error {
- logger.Debugw("register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
+ logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
// it could be checked, if the callback keay is already registered - but simply overwrite may be acceptable ...
oo.mutexRxSchedMap.Lock()
oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
@@ -439,7 +439,7 @@
omciTxRequest := queueElement.Value.(omciTransferStructure)
/* compare olt device handler code:
func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
- logger.Debugw("omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
+ logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
var deviceType string
var deviceID string
var proxyDeviceID string
@@ -448,15 +448,15 @@
if onuInCache, ok := dh.onus.Load(onuKey); !ok {
- logger.Debugw("omci indication for a device not in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
+ logger.Debugw(ctx,"omci indication for a device not in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
kwargs := make(map[string]interface{})
kwargs["onu_id"] = omciInd.OnuId
kwargs["parent_port_no"] = ponPort
- onuDevice, err := dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs)
+ onuDevice, err := dh.coreProxy.GetChildDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, kwargs)
if err != nil {
- logger.Errorw("onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
+ logger.Errorw(ctx,"onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
return
}
deviceType = onuDevice.Type
@@ -466,7 +466,7 @@
dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID))
} else {
//found in cache
- logger.Debugw("omci indication for a device in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
+ logger.Debugw(ctx,"omci indication for a device in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
deviceType = onuInCache.(*OnuDevice).deviceType
deviceID = onuInCache.(*OnuDevice).deviceID
proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID
@@ -493,24 +493,24 @@
oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child
if err != nil || device == nil {
/*TODO: needs to handle error scenarios */
- logger.Errorw("Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID,
+ logger.Errorw(ctx, "Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID,
"ChildId": oo.deviceID})
return fmt.Errorf("failed to fetch device %s", oo.deviceID)
}
- logger.Debugw("omci-message-to-send:", log.Fields{
+ logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
"TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
"device-id": oo.deviceID,
"toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
"proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame}
- if sendErr := oo.adapterProxy.SendInterAdapterMessage(context.Background(), omciMsg,
+ if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
ic.InterAdapterMessageType_OMCI_REQUEST,
//fromTopic,toType,toDevId, ProxyDevId
oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType,
oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
- logger.Errorw("send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
+ logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
return sendErr
}
oo.txQueue.Remove(queueElement) // Dequeue
@@ -542,22 +542,22 @@
// ###################################################################################
// # utility methods provided to work on OMCI messages
-func serialize(msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
+func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
omciLayer := &omci.OMCI{
TransactionID: tid,
MessageType: msgType,
}
- return serializeOmciLayer(omciLayer, request)
+ return serializeOmciLayer(ctx, omciLayer, request)
}
-func serializeOmciLayer(aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
+func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
var options gopacket.SerializeOptions
options.FixLengths = true
buffer := gopacket.NewSerializeBuffer()
err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
if err != nil {
- logger.Errorw("Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
+ logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
return nil, err
}
return buffer.Bytes(), nil
@@ -572,13 +572,13 @@
*/
//supply a response handler for omci response messages to be transferred to the requested FSM
-func (oo *omciCC) receiveOmciResponse(omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
+func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
- logger.Debugw("omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
+ logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
"transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
if oo.pOnuDeviceEntry == nil {
- logger.Errorw("Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
+ logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
"device-id": oo.deviceID})
return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
}
@@ -592,7 +592,7 @@
OmciPacket: packet,
},
}
- //logger.Debugw("Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
+ //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
respChan <- omciRespMsg
return nil
@@ -600,16 +600,16 @@
func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
- logger.Debugw("send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
+ logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
request := &omci.MibResetRequest{
MeBasePacket: omci.MeBasePacket{
EntityClass: me.OnuDataClassID,
},
}
tid := oo.getNextTid(highPrio)
- pkt, err := serialize(omci.MibResetRequestType, request, tid)
+ pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
if err != nil {
- logger.Errorw("Cannot serialize MibResetRequest", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
@@ -621,16 +621,16 @@
}
func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
- logger.Debugw("send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
+ logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
request := &omci.RebootRequest{
MeBasePacket: omci.MeBasePacket{
EntityClass: me.OnuGClassID,
},
}
tid := oo.getNextTid(highPrio)
- pkt, err := serialize(omci.RebootRequestType, request, tid)
+ pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
if err != nil {
- logger.Errorw("Cannot serialize RebootRequest", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
@@ -641,13 +641,13 @@
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send RebootRequest", log.Fields{
+ logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
- err = oo.pOnuDeviceEntry.waitForRebootResponse(responseChannel)
+ err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
if err != nil {
- logger.Errorw("aborting ONU Reboot!", log.Fields{
+ logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
@@ -655,16 +655,16 @@
}
func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
- logger.Debugw("send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
+ logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
request := &omci.MibUploadRequest{
MeBasePacket: omci.MeBasePacket{
EntityClass: me.OnuDataClassID,
},
}
tid := oo.getNextTid(highPrio)
- pkt, err := serialize(omci.MibUploadRequestType, request, tid)
+ pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
if err != nil {
- logger.Errorw("Cannot serialize MibUploadRequest", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
@@ -679,7 +679,7 @@
}
func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
- logger.Debugw("send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
+ logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
request := &omci.MibUploadNextRequest{
MeBasePacket: omci.MeBasePacket{
EntityClass: me.OnuDataClassID,
@@ -687,9 +687,9 @@
CommandSequenceNumber: oo.uploadSequNo,
}
tid := oo.getNextTid(highPrio)
- pkt, err := serialize(omci.MibUploadNextRequestType, request, tid)
+ pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
if err != nil {
- logger.Errorw("Cannot serialize MibUploadNextRequest", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
"Err": err, "device-id": oo.deviceID})
return err
}
@@ -704,7 +704,7 @@
func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
meParams := me.ParamData{
@@ -716,14 +716,14 @@
//all setByCreate parameters already set, no default option required ...
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode GalEnetProfileInstance for create", log.Fields{
+ logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize GalEnetProfile create", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -734,14 +734,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send GalEnetProfile create", log.Fields{
+ logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send GalEnetProfile-Create-msg done")
+ logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
return meInstance
}
- logger.Errorw("Cannot generate GalEnetProfileInstance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -749,7 +749,7 @@
// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
// ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
@@ -764,14 +764,14 @@
if omciErr.GetError() == nil {
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode ONU2-G instance for set", log.Fields{
+ logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize ONU2-G set", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -782,14 +782,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send ONU2-G set", log.Fields{
+ logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send ONU2-G-Set-msg done")
+ logger.Debug(ctx, "send ONU2-G-Set-msg done")
return meInstance
}
- logger.Errorw("Cannot generate ONU2-G", log.Fields{
+ logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -798,7 +798,7 @@
aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
- logger.Debugw("send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
meParams := me.ParamData{
@@ -818,14 +818,14 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
omci.TransactionID(tid), omci.AddDefaults(true))
if err != nil {
- logger.Errorw("Cannot encode MBSP for create", log.Fields{
+ logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize MBSP create", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -836,14 +836,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send MBSP create", log.Fields{
+ logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send MBSP-Create-msg done")
+ logger.Debug(ctx, "send MBSP-Create-msg done")
return meInstance
}
- logger.Errorw("Cannot generate MBSP Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -852,7 +852,7 @@
aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
instID := macBridgePortAniEID + aPUniPort.entityID
- logger.Debugw("send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
meParams := me.ParamData{
@@ -870,14 +870,14 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
omci.TransactionID(tid), omci.AddDefaults(true))
if err != nil {
- logger.Errorw("Cannot encode MBPCD for create", log.Fields{
+ logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize MBPCD create", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -888,14 +888,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send MBPCD create", log.Fields{
+ logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send MBPCD-Create-msg done")
+ logger.Debug(ctx, "send MBPCD-Create-msg done")
return meInstance
}
- logger.Errorw("Cannot generate MBPCD Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -905,7 +905,7 @@
tid := oo.getNextTid(highPrio)
//same entityId is used as for MBSP (see there), but just arbitrary ...
instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
- logger.Debugw("send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
// compare python adapter code WA VOL-1311: this is not done here!
@@ -927,14 +927,14 @@
//all setByCreate parameters already set, no default option required ...
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode EVTOCD for create", log.Fields{
+ logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize EVTOCD create", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -945,14 +945,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send EVTOCD create", log.Fields{
+ logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send EVTOCD-Create-msg done")
+ logger.Debug(ctx, "send EVTOCD-Create-msg done")
return meInstance
}
- logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -960,7 +960,7 @@
func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
// ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
@@ -972,14 +972,14 @@
if omciErr.GetError() == nil {
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode ONU-G instance for set", log.Fields{
+ logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize ONU-G set", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -990,14 +990,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send ONU-G set", log.Fields{
+ logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send ONU-G-Set-msg done")
+ logger.Debug(ctx, "send ONU-G-Set-msg done")
return meInstance
}
- logger.Errorw("Cannot generate ONU-G", log.Fields{
+ logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1005,7 +1005,7 @@
func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
// PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
@@ -1017,14 +1017,14 @@
if omciErr.GetError() == nil {
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode PPTPEthUni instance for set", log.Fields{
+ logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize PPTPEthUni-Set", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1035,14 +1035,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send PPTPEthUni-Set", log.Fields{
+ logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send PPTPEthUni-Set-msg done")
+ logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
return meInstance
}
- logger.Errorw("Cannot generate PPTPEthUni", log.Fields{
+ logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1052,7 +1052,7 @@
func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
// UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
@@ -1064,14 +1064,14 @@
if omciErr.GetError() == nil {
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode UNI-G instance for set", log.Fields{
+ logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
pkt, err := serializeOmciLayer(omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize UNI-G-Set", log.Fields{
+ logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1082,14 +1082,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send UNIG-G-Set", log.Fields{
+ logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send UNI-G-Set-msg done")
+ logger.Debug(ctx,"send UNI-G-Set-msg done")
return meInstance
}
- logger.Errorw("Cannot generate UNI-G", log.Fields{
+ logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1098,7 +1098,7 @@
func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
// ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
@@ -1110,14 +1110,14 @@
if omciErr.GetError() == nil {
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode VEIP instance for set", log.Fields{
+ logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize VEIP-Set", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1128,14 +1128,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send VEIP-Set", log.Fields{
+ logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send VEIP-Set-msg done")
+ logger.Debug(ctx, "send VEIP-Set-msg done")
return meInstance
}
- logger.Errorw("Cannot generate VEIP", log.Fields{
+ logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1144,7 +1144,7 @@
timeout int, highPrio bool) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
+ logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16)})
meParams := me.ParamData{
@@ -1156,12 +1156,12 @@
meClassIDName := meInstance.GetName()
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorf("Cannot encode instance for get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
+ logger.Errorf(ctx, "Cannot encode instance for get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
+ logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
return nil
}
omciRxCallbackPair := callbackPair{
@@ -1170,20 +1170,20 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
+ logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debugw("send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
+ logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
return meInstance
}
- logger.Errorw("Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
+ logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
aInstID uint16, rxChan chan Message) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
meParams := me.ParamData{
@@ -1196,14 +1196,14 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
omci.TransactionID(tid), omci.AddDefaults(true))
if err != nil {
- logger.Errorw("Cannot encode .1pMapper for create", log.Fields{
+ logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize .1pMapper create", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1214,14 +1214,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send .1pMapper create", log.Fields{
+ logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send .1pMapper-create-msg done")
+ logger.Debug(ctx, "send .1pMapper-create-msg done")
return meInstance
}
- logger.Errorw("Cannot generate .1pMapper", log.Fields{
+ logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1229,7 +1229,7 @@
func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1239,14 +1239,14 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
omci.TransactionID(tid), omci.AddDefaults(true))
if err != nil {
- logger.Errorw("Cannot encode MBPCD for create", log.Fields{
+ logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize MBPCD create", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1257,14 +1257,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send MBPCD create", log.Fields{
+ logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send MBPCD-Create-msg done")
+ logger.Debug(ctx, "send MBPCD-Create-msg done")
return meInstance
}
- logger.Errorw("Cannot generate MBPCD Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1272,7 +1272,7 @@
func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1282,14 +1282,14 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
omci.TransactionID(tid), omci.AddDefaults(true))
if err != nil {
- logger.Errorw("Cannot encode GemNCTP for create", log.Fields{
+ logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize GemNCTP create", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1300,14 +1300,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send GemNCTP create", log.Fields{
+ logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send GemNCTP-Create-msg done")
+ logger.Debug(ctx, "send GemNCTP-Create-msg done")
return meInstance
}
- logger.Errorw("Cannot generate GemNCTP Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1315,7 +1315,7 @@
func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1325,14 +1325,14 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode GemIwTp for create", log.Fields{
+ logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize GemIwTp create", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1343,14 +1343,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send GemIwTp create", log.Fields{
+ logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send GemIwTp-Create-msg done")
+ logger.Debug(ctx, "send GemIwTp-Create-msg done")
return meInstance
}
- logger.Errorw("Cannot generate GemIwTp Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1358,7 +1358,7 @@
func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1366,14 +1366,14 @@
if omciErr.GetError() == nil {
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode TCont for set", log.Fields{
+ logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize TCont set", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1384,14 +1384,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send TCont set", log.Fields{
+ logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send TCont-set msg done")
+ logger.Debug(ctx, "send TCont-set msg done")
return meInstance
}
- logger.Errorw("Cannot generate TCont Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1399,7 +1399,7 @@
func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1407,14 +1407,14 @@
if omciErr.GetError() == nil {
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode PrioQueue for set", log.Fields{
+ logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize PrioQueue set", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1425,14 +1425,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send PrioQueue set", log.Fields{
+ logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send PrioQueue-set msg done")
+ logger.Debug(ctx, "send PrioQueue-set msg done")
return meInstance
}
- logger.Errorw("Cannot generate PrioQueue Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1440,7 +1440,7 @@
func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1448,14 +1448,14 @@
if omciErr.GetError() == nil {
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode 1PMapper for set", log.Fields{
+ logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize 1PMapper set", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1466,14 +1466,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send 1PMapper set", log.Fields{
+ logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send 1PMapper-set msg done")
+ logger.Debug(ctx, "send 1PMapper-set msg done")
return meInstance
}
- logger.Errorw("Cannot generate 1PMapper Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1481,7 +1481,7 @@
func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1491,7 +1491,7 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode VTFD for create", log.Fields{
+ logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
"Err": err, "device-id": oo.deviceID})
//TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
// return (dual format) error code that can be used at caller for immediate error treatment
@@ -1499,9 +1499,9 @@
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize VTFD create", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1512,14 +1512,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send VTFD create", log.Fields{
+ logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send VTFD-Create-msg done")
+ logger.Debug(ctx, "send VTFD-Create-msg done")
return meInstance
}
- logger.Errorw("Cannot generate VTFD Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1528,7 +1528,7 @@
func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1537,7 +1537,7 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode VTFD for set", log.Fields{
+ logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
"Err": err, "device-id": oo.deviceID})
//TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
// return (dual format) error code that can be used at caller for immediate error treatment
@@ -1545,9 +1545,9 @@
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize VTFD set", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1558,14 +1558,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send VTFD set", log.Fields{
+ logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send VTFD-Set-msg done")
+ logger.Debug(ctx, "send VTFD-Set-msg done")
return meInstance
}
- logger.Errorw("Cannot generate VTFD Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1573,7 +1573,7 @@
func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1581,14 +1581,14 @@
if omciErr.GetError() == nil {
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode EVTOCD for create", log.Fields{
+ logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize EVTOCD create", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1599,14 +1599,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send EVTOCD create", log.Fields{
+ logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send EVTOCD-set msg done")
+ logger.Debug(ctx, "send EVTOCD-set msg done")
return meInstance
}
- logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1614,7 +1614,7 @@
func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1622,14 +1622,14 @@
if omciErr.GetError() == nil {
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode EVTOCD for set", log.Fields{
+ logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize EVTOCD set", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1640,14 +1640,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send EVTOCD set", log.Fields{
+ logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send EVTOCD-set msg done")
+ logger.Debug(ctx, "send EVTOCD-set msg done")
return meInstance
}
- logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1655,7 +1655,7 @@
func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1663,14 +1663,14 @@
if omciErr.GetError() == nil {
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode EVTOCD for delete", log.Fields{
+ logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize EVTOCD delete", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1681,14 +1681,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send EVTOCD delete", log.Fields{
+ logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send EVTOCD-delete msg done")
+ logger.Debug(ctx, "send EVTOCD-delete msg done")
return meInstance
}
- logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{
+ logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1696,7 +1696,7 @@
func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aInstID uint16) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -1706,7 +1706,7 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode VTFD for delete", log.Fields{
+ logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
//TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
// return (dual format) error code that can be used at caller for immediate error treatment
@@ -1714,9 +1714,9 @@
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize VTFD delete", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1727,14 +1727,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send VTFD delete", log.Fields{
+ logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send VTFD-Delete-msg done")
+ logger.Debug(ctx, "send VTFD-Delete-msg done")
return meInstance
}
- logger.Errorw("Cannot generate VTFD Instance for delete", log.Fields{
+ logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1742,7 +1742,7 @@
func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aInstID uint16) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -1752,7 +1752,7 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode GemIwTp for delete", log.Fields{
+ logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
//TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
// return (dual format) error code that can be used at caller for immediate error treatment
@@ -1760,9 +1760,9 @@
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize GemIwTp delete", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1773,14 +1773,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send GemIwTp delete", log.Fields{
+ logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send GemIwTp-Delete-msg done")
+ logger.Debug(ctx, "send GemIwTp-Delete-msg done")
return meInstance
}
- logger.Errorw("Cannot generate GemIwTp Instance for delete", log.Fields{
+ logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1788,7 +1788,7 @@
func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aInstID uint16) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -1798,7 +1798,7 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode GemNCtp for delete", log.Fields{
+ logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
//TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
// return (dual format) error code that can be used at caller for immediate error treatment
@@ -1806,9 +1806,9 @@
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize GemNCtp delete", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1819,14 +1819,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send GemNCtp delete", log.Fields{
+ logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send GemNCtp-Delete-msg done")
+ logger.Debug(ctx, "send GemNCtp-Delete-msg done")
return meInstance
}
- logger.Errorw("Cannot generate GemNCtp Instance for delete", log.Fields{
+ logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1834,7 +1834,7 @@
func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aInstID uint16) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -1844,7 +1844,7 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode .1pMapper for delete", log.Fields{
+ logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
//TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
// return (dual format) error code that can be used at caller for immediate error treatment
@@ -1852,9 +1852,9 @@
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize .1pMapper delete", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1865,14 +1865,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send .1pMapper delete", log.Fields{
+ logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send .1pMapper-Delete-msg done")
+ logger.Debug(ctx, "send .1pMapper-Delete-msg done")
return meInstance
}
- logger.Errorw("Cannot generate .1pMapper Instance for delete", log.Fields{
+ logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1880,7 +1880,7 @@
func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, aInstID uint16) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(aInstID), 16)})
@@ -1890,7 +1890,7 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
omci.TransactionID(tid))
if err != nil {
- logger.Errorw("Cannot encode MBPCD for delete", log.Fields{
+ logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
//TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
// return (dual format) error code that can be used at caller for immediate error treatment
@@ -1898,9 +1898,9 @@
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize MBPCD delete", log.Fields{
+ logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1911,14 +1911,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send MBPCD delete", log.Fields{
+ logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send MBPCD-Delete-msg done")
+ logger.Debug(ctx, "send MBPCD-Delete-msg done")
return meInstance
}
- logger.Errorw("Cannot generate MBPCD Instance for delete", log.Fields{
+ logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
"Err": omciErr.GetError(), "device-id": oo.deviceID})
return nil
}
@@ -1927,7 +1927,7 @@
func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1936,13 +1936,13 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
omci.AddDefaults(true))
if err != nil {
- logger.Errorw("Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
+ logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
+ logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1951,13 +1951,13 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
+ logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send MulticastGEMIWTP-create-msg done")
+ logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
return meInstance
}
- logger.Errorw("Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
+ logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
"device-id": oo.deviceID})
return nil
}
@@ -1966,7 +1966,7 @@
func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -1975,13 +1975,13 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
omci.AddDefaults(true))
if err != nil {
- logger.Errorw("Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
+ logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
+ logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil
}
@@ -1990,13 +1990,13 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
+ logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
return nil
}
- logger.Debug("send MulticastGEMIWTP-set-msg done")
+ logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
return meInstance
}
- logger.Errorw("Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
+ logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
"device-id": oo.deviceID})
return nil
}
@@ -2005,7 +2005,7 @@
func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2014,14 +2014,14 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
omci.AddDefaults(true))
if err != nil {
- logger.Errorw("Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
+ logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
"device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
+ logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
"device-id": oo.deviceID})
return nil
}
@@ -2031,14 +2031,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
+ logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
"device-id": oo.deviceID})
return nil
}
- logger.Debug("send MulticastOperationProfile-create-msg done")
+ logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
return meInstance
}
- logger.Errorw("Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
+ logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
"device-id": oo.deviceID})
return nil
}
@@ -2047,7 +2047,7 @@
func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2056,14 +2056,14 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
omci.AddDefaults(true))
if err != nil {
- logger.Errorw("Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
+ logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
"device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
+ logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
"device-id": oo.deviceID})
return nil
}
@@ -2073,14 +2073,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
+ logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
"device-id": oo.deviceID})
return nil
}
- logger.Debug("send MulticastOperationProfile-create-msg done")
+ logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
return meInstance
}
- logger.Errorw("Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
+ logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
"device-id": oo.deviceID})
return nil
}
@@ -2089,7 +2089,7 @@
func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
tid := oo.getNextTid(highPrio)
- logger.Debugw("send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
+ logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
"SequNo": strconv.FormatInt(int64(tid), 16),
"InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
@@ -2098,14 +2098,14 @@
omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
omci.AddDefaults(true))
if err != nil {
- logger.Errorw("Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
+ logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
"device-id": oo.deviceID})
return nil
}
- pkt, err := serializeOmciLayer(omciLayer, msgLayer)
+ pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
if err != nil {
- logger.Errorw("Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
+ logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
"device-id": oo.deviceID})
return nil
}
@@ -2115,14 +2115,14 @@
}
err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
if err != nil {
- logger.Errorw("Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
+ logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
"device-id": oo.deviceID})
return nil
}
- logger.Debug("send MulticastSubConfigInfo-create-msg done")
+ logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
return meInstance
}
- logger.Errorw("Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
+ logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
"device-id": oo.deviceID})
return nil
}
diff --git a/internal/pkg/onuadaptercore/omci_test_request.go b/internal/pkg/onuadaptercore/omci_test_request.go
index c62a4c6..fb8dceb 100644
--- a/internal/pkg/onuadaptercore/omci_test_request.go
+++ b/internal/pkg/onuadaptercore/omci_test_request.go
@@ -28,11 +28,11 @@
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
- //"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- //ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- //"github.com/opencord/voltha-protos/v3/go/openflow_13"
- //"github.com/opencord/voltha-protos/v3/go/voltha"
+ //"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
+ //ic "github.com/opencord/voltha-protos/v4/go/inter_container"
+ //"github.com/opencord/voltha-protos/v4/go/openflow_13"
+ //"github.com/opencord/voltha-protos/v4/go/voltha"
)
//omciTestRequest structure holds the information for the OMCI test
@@ -51,7 +51,7 @@
func newOmciTestRequest(ctx context.Context,
deviceID string, omciCc *omciCC,
exclusive bool, allowFailure bool) *omciTestRequest {
- logger.Debug("omciTestRequest-init")
+ logger.Debug(ctx, "omciTestRequest-init")
var omciTestRequest omciTestRequest
omciTestRequest.deviceID = deviceID
omciTestRequest.pDevOmciCC = omciCc
@@ -65,32 +65,32 @@
//
func (oo *omciTestRequest) performOmciTest(ctx context.Context, execChannel chan<- bool) {
- logger.Debug("omciTestRequest-start-test")
+ logger.Debug(ctx, "omciTestRequest-start-test")
if oo.pDevOmciCC != nil {
oo.verifyDone = execChannel
// test functionality is limited to ONU-2G get request for the moment
// without yet checking the received response automatically here (might be improved ??)
tid := oo.pDevOmciCC.getNextTid(false)
- onu2gBaseGet, _ := oo.createOnu2gBaseGet(tid)
+ onu2gBaseGet, _ := oo.createOnu2gBaseGet(ctx, tid)
omciRxCallbackPair := callbackPair{
cbKey: tid,
cbEntry: callbackPairEntry{nil, oo.receiveOmciVerifyResponse},
}
- logger.Debugw("performOmciTest-start sending frame", log.Fields{"for device-id": oo.deviceID})
+ logger.Debugw(ctx, "performOmciTest-start sending frame", log.Fields{"for device-id": oo.deviceID})
// send with default timeout and normal prio
go oo.pDevOmciCC.send(ctx, onu2gBaseGet, ConstDefaultOmciTimeout, 0, false, omciRxCallbackPair)
} else {
- logger.Errorw("performOmciTest: Device does not exist", log.Fields{"for device-id": oo.deviceID})
+ logger.Errorw(ctx, "performOmciTest: Device does not exist", log.Fields{"for device-id": oo.deviceID})
}
}
// these are OMCI related functions, could/should be collected in a separate file? TODO!!!
// for a simple start just included in here
//basic approach copied from bbsim, cmp /devices/onu.go and /internal/common/omci/mibpackets.go
-func (oo *omciTestRequest) createOnu2gBaseGet(tid uint16) ([]byte, error) {
+func (oo *omciTestRequest) createOnu2gBaseGet(ctx context.Context, tid uint16) ([]byte, error) {
request := &omci.GetRequest{
MeBasePacket: omci.MeBasePacket{
@@ -101,10 +101,10 @@
}
oo.txSeqNo = tid
- pkt, err := serialize(omci.GetRequestType, request, tid)
+ pkt, err := serialize(ctx, omci.GetRequestType, request, tid)
if err != nil {
//omciLogger.WithFields(log.Fields{ ...
- logger.Errorw("Cannot serialize Onu2-G GetRequest", log.Fields{"device-id": oo.deviceID, "Err": err})
+ logger.Errorw(ctx, "Cannot serialize Onu2-G GetRequest", log.Fields{"device-id": oo.deviceID, "Err": err})
return nil, err
}
// hexEncode would probably work as well, but not needed and leads to wrong logs on OltAdapter frame
@@ -113,23 +113,23 @@
}
//supply a response handler - in this testobject the message is evaluated directly, no response channel used
-func (oo *omciTestRequest) receiveOmciVerifyResponse(omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
+func (oo *omciTestRequest) receiveOmciVerifyResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
- logger.Debugw("verify-omci-message-response received:", log.Fields{"omciMsgType": omciMsg.MessageType,
+ logger.Debugw(ctx, "verify-omci-message-response received:", log.Fields{"omciMsgType": omciMsg.MessageType,
"transCorrId": omciMsg.TransactionID, "DeviceIdent": omciMsg.DeviceIdentifier})
if omciMsg.TransactionID == oo.txSeqNo {
- logger.Debugw("verify-omci-message-response", log.Fields{"correct TransCorrId": omciMsg.TransactionID})
+ logger.Debugw(ctx, "verify-omci-message-response", log.Fields{"correct TransCorrId": omciMsg.TransactionID})
} else {
- logger.Debugw("verify-omci-message-response error", log.Fields{"incorrect TransCorrId": omciMsg.TransactionID,
+ logger.Debugw(ctx, "verify-omci-message-response error", log.Fields{"incorrect TransCorrId": omciMsg.TransactionID,
"expected": oo.txSeqNo})
oo.verifyDone <- false
return fmt.Errorf("unexpected TransCorrId %s", oo.deviceID)
}
if omciMsg.MessageType == omci.GetResponseType {
- logger.Debugw("verify-omci-message-response", log.Fields{"correct RespType": omciMsg.MessageType})
+ logger.Debugw(ctx, "verify-omci-message-response", log.Fields{"correct RespType": omciMsg.MessageType})
} else {
- logger.Debugw("verify-omci-message-response error", log.Fields{"incorrect RespType": omciMsg.MessageType,
+ logger.Debugw(ctx, "verify-omci-message-response error", log.Fields{"incorrect RespType": omciMsg.MessageType,
"expected": omci.GetResponseType})
oo.verifyDone <- false
return fmt.Errorf("unexpected MessageType %s", oo.deviceID)
diff --git a/internal/pkg/onuadaptercore/omci_vlan_config.go b/internal/pkg/onuadaptercore/omci_vlan_config.go
index b9c9d79..50ab5b1 100644
--- a/internal/pkg/onuadaptercore/omci_vlan_config.go
+++ b/internal/pkg/onuadaptercore/omci_vlan_config.go
@@ -30,8 +30,8 @@
"github.com/looplab/fsm"
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- of "github.com/opencord/voltha-protos/v3/go/openflow_13"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
+ of "github.com/opencord/voltha-protos/v4/go/openflow_13"
)
const (
@@ -156,7 +156,7 @@
//NewUniVlanConfigFsm is the 'constructor' for the state machine to config the PON ANI ports
// of ONU UNI ports via OMCI
-func NewUniVlanConfigFsm(apDeviceHandler *deviceHandler, apDevOmciCC *omciCC, apUniPort *onuUniPort,
+func NewUniVlanConfigFsm(ctx context.Context, apDeviceHandler *deviceHandler, apDevOmciCC *omciCC, apUniPort *onuUniPort,
apUniTechProf *onuUniTechProf, apOnuDB *onuDeviceDB, aTechProfileID uint16,
aRequestEvent OnuDeviceEvent, aName string, aCommChannel chan Message, aAcceptIncrementalEvto bool,
aCookieSlice []uint64, aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8) *UniVlanConfigFsm {
@@ -177,7 +177,7 @@
instFsm.pAdaptFsm = NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
if instFsm.pAdaptFsm == nil {
- logger.Errorw("UniVlanConfigFsm's AdapterFsm could not be instantiated!!", log.Fields{
+ logger.Errorw(ctx, "UniVlanConfigFsm's AdapterFsm could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
}
@@ -211,33 +211,33 @@
{Name: vlanEvRestart, Src: []string{vlanStResetting}, Dst: vlanStDisabled},
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(e) },
- "enter_" + vlanStStarting: func(e *fsm.Event) { instFsm.enterConfigStarting(e) },
- "enter_" + vlanStConfigVtfd: func(e *fsm.Event) { instFsm.enterConfigVtfd(e) },
- "enter_" + vlanStConfigEvtocd: func(e *fsm.Event) { instFsm.enterConfigEvtocd(e) },
- "enter_" + vlanStConfigDone: func(e *fsm.Event) { instFsm.enterVlanConfigDone(e) },
- "enter_" + vlanStConfigIncrFlow: func(e *fsm.Event) { instFsm.enterConfigIncrFlow(e) },
- "enter_" + vlanStRemoveFlow: func(e *fsm.Event) { instFsm.enterRemoveFlow(e) },
- "enter_" + vlanStCleanupDone: func(e *fsm.Event) { instFsm.enterVlanCleanupDone(e) },
- "enter_" + vlanStResetting: func(e *fsm.Event) { instFsm.enterResetting(e) },
- "enter_" + vlanStDisabled: func(e *fsm.Event) { instFsm.enterDisabled(e) },
+ "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
+ "enter_" + vlanStStarting: func(e *fsm.Event) { instFsm.enterConfigStarting(ctx, e) },
+ "enter_" + vlanStConfigVtfd: func(e *fsm.Event) { instFsm.enterConfigVtfd(ctx, e) },
+ "enter_" + vlanStConfigEvtocd: func(e *fsm.Event) { instFsm.enterConfigEvtocd(ctx, e) },
+ "enter_" + vlanStConfigDone: func(e *fsm.Event) { instFsm.enterVlanConfigDone(ctx, e) },
+ "enter_" + vlanStConfigIncrFlow: func(e *fsm.Event) { instFsm.enterConfigIncrFlow(ctx, e) },
+ "enter_" + vlanStRemoveFlow: func(e *fsm.Event) { instFsm.enterRemoveFlow(ctx, e) },
+ "enter_" + vlanStCleanupDone: func(e *fsm.Event) { instFsm.enterVlanCleanupDone(ctx, e) },
+ "enter_" + vlanStResetting: func(e *fsm.Event) { instFsm.enterResetting(ctx, e) },
+ "enter_" + vlanStDisabled: func(e *fsm.Event) { instFsm.enterDisabled(ctx, e) },
},
)
if instFsm.pAdaptFsm.pFsm == nil {
- logger.Errorw("UniVlanConfigFsm's Base FSM could not be instantiated!!", log.Fields{
+ logger.Errorw(ctx, "UniVlanConfigFsm's Base FSM could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
}
- _ = instFsm.initUniFlowParams(aTechProfileID, aCookieSlice, aMatchVlan, aSetVlan, aSetPcp)
+ _ = instFsm.initUniFlowParams(ctx, aTechProfileID, aCookieSlice, aMatchVlan, aSetVlan, aSetPcp)
- logger.Debugw("UniVlanConfigFsm created", log.Fields{"device-id": instFsm.deviceID,
+ logger.Debugw(ctx, "UniVlanConfigFsm created", log.Fields{"device-id": instFsm.deviceID,
"accIncrEvto": instFsm.acceptIncrementalEvtoOption})
return instFsm
}
//initUniFlowParams is a simplified form of SetUniFlowParams() used for first flow parameters configuration
-func (oFsm *UniVlanConfigFsm) initUniFlowParams(aTpID uint16, aCookieSlice []uint64,
+func (oFsm *UniVlanConfigFsm) initUniFlowParams(ctx context.Context, aTpID uint16, aCookieSlice []uint64,
aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8) error {
loRuleParams := uniVlanRuleParams{
TpID: aTpID,
@@ -280,7 +280,7 @@
//no mutex protection is required for initial access and adding the first flow is always possible
oFsm.uniVlanFlowParamsSlice = make([]uniVlanFlowParams, 0)
oFsm.uniVlanFlowParamsSlice = append(oFsm.uniVlanFlowParamsSlice, loFlowParams)
- logger.Debugw("first UniVlanConfigFsm flow added", log.Fields{
+ logger.Debugw(ctx, "first UniVlanConfigFsm flow added", log.Fields{
"Cookies": oFsm.uniVlanFlowParamsSlice[0].CookieSlice,
"MatchVid": strconv.FormatInt(int64(loRuleParams.MatchVid), 16),
"SetVid": strconv.FormatInt(int64(loRuleParams.SetVid), 16),
@@ -290,9 +290,9 @@
oFsm.uniRemoveFlowsSlice = make([]uniRemoveVlanFlowParams, 0) //initially nothing to remove
//permanently store flow config for reconcile case
- if err := oFsm.pDeviceHandler.storePersUniFlowConfig(oFsm.pOnuUniPort.uniID,
+ if err := oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID,
&oFsm.uniVlanFlowParamsSlice); err != nil {
- logger.Errorw(err.Error(), log.Fields{"device-id": oFsm.deviceID})
+ logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID})
return err
}
@@ -310,7 +310,7 @@
//SetUniFlowParams verifies on existence of flow parameters to be configured,
// optionally udates the cookie list or appends a new flow if there is space
// if possible the FSM is trigggerd to start with the processing
-func (oFsm *UniVlanConfigFsm) SetUniFlowParams(aTpID uint16, aCookieSlice []uint64,
+func (oFsm *UniVlanConfigFsm) SetUniFlowParams(ctx context.Context, aTpID uint16, aCookieSlice []uint64,
aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8) error {
loRuleParams := uniVlanRuleParams{
TpID: aTpID,
@@ -356,21 +356,21 @@
// countable run time optimization (perhaps with including the hash in kvStore storage?)
if storedUniFlowParams.VlanRuleParams == loRuleParams {
flowEntryMatch = true
- logger.Debugw("UniVlanConfigFsm flow setting - rule already exists", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm flow setting - rule already exists", log.Fields{
"device-id": oFsm.deviceID})
var cookieMatch bool
for _, newCookie := range aCookieSlice { // for all cookies available in the arguments
cookieMatch = false
for _, cookie := range storedUniFlowParams.CookieSlice {
if cookie == newCookie {
- logger.Debugw("UniVlanConfigFsm flow setting - and cookie already exists", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm flow setting - and cookie already exists", log.Fields{
"device-id": oFsm.deviceID, "cookie": cookie})
cookieMatch = true
break //found new cookie - no further search for this requested cookie
}
}
if !cookieMatch {
- logger.Debugw("UniVlanConfigFsm flow setting -adding new cookie", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm flow setting -adding new cookie", log.Fields{
"device-id": oFsm.deviceID, "cookie": newCookie})
//as range works with copies of the slice we have to write to the original slice!!
oFsm.uniVlanFlowParamsSlice[flow].CookieSlice = append(oFsm.uniVlanFlowParamsSlice[flow].CookieSlice,
@@ -387,7 +387,7 @@
loFlowParams.CookieSlice = make([]uint64, 0)
loFlowParams.CookieSlice = append(loFlowParams.CookieSlice, aCookieSlice...)
oFsm.uniVlanFlowParamsSlice = append(oFsm.uniVlanFlowParamsSlice, loFlowParams)
- logger.Debugw("UniVlanConfigFsm flow add", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm flow add", log.Fields{
"Cookies": oFsm.uniVlanFlowParamsSlice[oFsm.numUniFlows].CookieSlice,
"MatchVid": strconv.FormatInt(int64(loRuleParams.MatchVid), 16),
"SetVid": strconv.FormatInt(int64(loRuleParams.SetVid), 16),
@@ -410,7 +410,7 @@
} // if not in the appropriate state a new entry will be automatically considered later
// when the configDone state is reached
} else {
- logger.Errorw("UniVlanConfigFsm flow limit exceeded", log.Fields{
+ logger.Errorw(ctx, "UniVlanConfigFsm flow limit exceeded", log.Fields{
"device-id": oFsm.deviceID, "flow-number": oFsm.numUniFlows})
return fmt.Errorf(" UniVlanConfigFsm flow limit exceeded %s", oFsm.deviceID)
}
@@ -421,14 +421,14 @@
// state transition notification is checked in deviceHandler
if oFsm.pDeviceHandler != nil {
//also the related TechProfile was already configured
- logger.Debugw("UniVlanConfigFsm rule already set - send immediate add-success event for reason update", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm rule already set - send immediate add-success event for reason update", log.Fields{
"device-id": oFsm.deviceID})
- go oFsm.pDeviceHandler.deviceProcStatusUpdate(oFsm.requestEvent)
+ go oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, oFsm.requestEvent)
}
} else {
// avoid device reason update as the rule config connected to this flow may still be in progress
// and the device reason should only be updated on success of rule config
- logger.Debugw("UniVlanConfigFsm rule already set but configuration ongoing, suppress early add-success event for reason update",
+ logger.Debugw(ctx, "UniVlanConfigFsm rule already set but configuration ongoing, suppress early add-success event for reason update",
log.Fields{"device-id": oFsm.deviceID,
"NumberofRules": oFsm.numUniFlows, "Configured rules": oFsm.configuredUniFlow})
}
@@ -436,8 +436,8 @@
if !flowEntryMatch || flowCookieModify { // some change was done to the flow entries
//permanently store flow config for reconcile case
- if err := oFsm.pDeviceHandler.storePersUniFlowConfig(oFsm.pOnuUniPort.uniID, &oFsm.uniVlanFlowParamsSlice); err != nil {
- logger.Errorw(err.Error(), log.Fields{"device-id": oFsm.deviceID})
+ if err := oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID, &oFsm.uniVlanFlowParamsSlice); err != nil {
+ logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID})
return err
}
}
@@ -447,7 +447,7 @@
//RemoveUniFlowParams verifies on existence of flow cookie,
// if found removes cookie from flow cookie list and if this is empty
// initiates removal of the flow related configuration from the ONU (via OMCI)
-func (oFsm *UniVlanConfigFsm) RemoveUniFlowParams(aCookie uint64) error {
+func (oFsm *UniVlanConfigFsm) RemoveUniFlowParams(ctx context.Context, aCookie uint64) error {
flowCookieMatch := false
//mutex protection is required for possible concurrent access to FSM members
oFsm.mutexFlowParams.Lock()
@@ -455,13 +455,13 @@
for flow, storedUniFlowParams := range oFsm.uniVlanFlowParamsSlice {
for i, cookie := range storedUniFlowParams.CookieSlice {
if cookie == aCookie {
- logger.Debugw("UniVlanConfigFsm flow removal - cookie found", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm flow removal - cookie found", log.Fields{
"device-id": oFsm.deviceID, "cookie": cookie})
flowCookieMatch = true
//remove the cookie from the cookie slice and verify it is getting empty
if len(storedUniFlowParams.CookieSlice) == 1 {
- logger.Debugw("UniVlanConfigFsm flow removal - full flow removal", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm flow removal - full flow removal", log.Fields{
"device-id": oFsm.deviceID})
oFsm.numUniFlows--
@@ -481,7 +481,7 @@
//at this point it is evident that no flow anymore refers to a still possibly active Techprofile
//request that this profile gets deleted before a new flow add is allowed
oFsm.pUniTechProf.setProfileToDelete(oFsm.pOnuUniPort.uniID, uint8(loRemoveParams.vlanRuleParams.TpID), true)
- logger.Debugw("UniVlanConfigFsm flow removal - no more flows", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm flow removal - no more flows", log.Fields{
"device-id": oFsm.deviceID})
} else {
oFsm.numUniFlows--
@@ -504,15 +504,15 @@
}
}
if tpIDInOtherFlows {
- logger.Debugw("UniVlanConfigFsm tp-id used in deleted flow is still used in other flows", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm tp-id used in deleted flow is still used in other flows", log.Fields{
"device-id": oFsm.deviceID, "tp-id": usedTpID})
} else {
- logger.Debugw("UniVlanConfigFsm tp-id used in deleted flow is not used anymore", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm tp-id used in deleted flow is not used anymore", log.Fields{
"device-id": oFsm.deviceID, "tp-id": usedTpID})
//request that this profile gets deleted before a new flow add is allowed
oFsm.pUniTechProf.setProfileToDelete(oFsm.pOnuUniPort.uniID, uint8(usedTpID), true)
}
- logger.Debugw("UniVlanConfigFsm flow removal - specific flow removed from data", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm flow removal - specific flow removed from data", log.Fields{
"device-id": oFsm.deviceID})
}
//trigger the FSM to remove the relevant rule
@@ -534,16 +534,16 @@
// state transition notification is checked in deviceHandler
if oFsm.pDeviceHandler != nil {
//making use of the add->remove successor enum assumption/definition
- go oFsm.pDeviceHandler.deviceProcStatusUpdate(OnuDeviceEvent(uint8(oFsm.requestEvent) + 1))
+ go oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent(uint8(oFsm.requestEvent)+1))
}
- logger.Debugw("UniVlanConfigFsm flow removal - rule persists with still valid cookies", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm flow removal - rule persists with still valid cookies", log.Fields{
"device-id": oFsm.deviceID, "cookies": oFsm.uniVlanFlowParamsSlice[flow].CookieSlice})
}
//permanently store the modified flow config for reconcile case
if oFsm.pDeviceHandler != nil {
- if err := oFsm.pDeviceHandler.storePersUniFlowConfig(oFsm.pOnuUniPort.uniID, &oFsm.uniVlanFlowParamsSlice); err != nil {
- logger.Errorw(err.Error(), log.Fields{"device-id": oFsm.deviceID})
+ if err := oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID, &oFsm.uniVlanFlowParamsSlice); err != nil {
+ logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID})
return err
}
}
@@ -556,14 +556,14 @@
}
} //search all flows
if !flowCookieMatch { //some cookie remove-request for a cookie that does not exist in the FSM data
- logger.Warnw("UniVlanConfigFsm flow removal - remove-cookie not found", log.Fields{
+ logger.Warnw(ctx, "UniVlanConfigFsm flow removal - remove-cookie not found", log.Fields{
"device-id": oFsm.deviceID, "remove-cookie": aCookie})
// but accept the request with success as no such cookie (flow) does exist
// no activity within the FSM for OMCI processing, the deviceReason may be updated immediately
// state transition notification is checked in deviceHandler
if oFsm.pDeviceHandler != nil {
//making use of the add->remove successor enum assumption/definition
- go oFsm.pDeviceHandler.deviceProcStatusUpdate(OnuDeviceEvent(uint8(oFsm.requestEvent) + 1))
+ go oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent(uint8(oFsm.requestEvent)+1))
}
return nil
} //unknown cookie
@@ -571,15 +571,15 @@
return nil
}
-func (oFsm *UniVlanConfigFsm) enterConfigStarting(e *fsm.Event) {
- logger.Debugw("UniVlanConfigFsm start", log.Fields{"in state": e.FSM.Current(),
+func (oFsm *UniVlanConfigFsm) enterConfigStarting(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniVlanConfigFsm start", log.Fields{"in state": e.FSM.Current(),
"device-id": oFsm.deviceID})
// this FSM is not intended for re-start, needs always new creation for a new run
// (self-destroying - compare enterDisabled())
oFsm.omciMIdsResponseReceived = make(chan bool)
// start go routine for processing of LockState messages
- go oFsm.processOmciVlanMessages()
+ go oFsm.processOmciVlanMessages(ctx)
//let the state machine run forward from here directly
pConfigVlanStateAFsm := oFsm.pAdaptFsm
if pConfigVlanStateAFsm != nil {
@@ -590,7 +590,7 @@
//cmp also usage in EVTOCDE create in omci_cc
oFsm.evtocdID = macBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo)
- if oFsm.pUniTechProf.getTechProfileDone(oFsm.pOnuUniPort.uniID, uint8(tpID)) {
+ if oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.uniID, uint8(tpID)) {
// let the vlan processing begin
_ = a_pAFsm.pFsm.Event(vlanEvStartConfig)
} else {
@@ -602,7 +602,7 @@
}
}
-func (oFsm *UniVlanConfigFsm) enterConfigVtfd(e *fsm.Event) {
+func (oFsm *UniVlanConfigFsm) enterConfigVtfd(ctx context.Context, e *fsm.Event) {
//mutex protection is required for possible concurrent access to FSM members
oFsm.mutexFlowParams.Lock()
if len(oFsm.uniVlanFlowParamsSlice) == 0 {
@@ -618,7 +618,7 @@
if oFsm.uniVlanFlowParamsSlice[0].VlanRuleParams.SetVid == uint32(of.OfpVlanId_OFPVID_PRESENT) {
// meaning transparent setup - no specific VTFD setting required
oFsm.mutexFlowParams.Unlock()
- logger.Debugw("UniVlanConfigFsm: no VTFD config required", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm: no VTFD config required", log.Fields{
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
// let the FSM proceed ... (from within this state all internal pointers may be expected to be correct)
// obviously calling some FSM event here directly does not work - so trying to decouple it ...
@@ -630,7 +630,7 @@
// This attribute uniquely identifies each instance of this managed entity. Through an identical ID,
// this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME.
vtfdID := macBridgePortAniEID + oFsm.pOnuUniPort.entityID + oFsm.uniVlanFlowParamsSlice[0].VlanRuleParams.TpID
- logger.Debugw("UniVlanConfigFsm create VTFD", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm create VTFD", log.Fields{
"EntitytId": strconv.FormatInt(int64(vtfdID), 16),
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
// setVid is assumed to be masked already by the caller to 12 bit
@@ -647,9 +647,9 @@
"NumberOfEntries": oFsm.numVlanFilterEntries,
},
}
- logger.Debugw("UniVlanConfigFsm sendcreate VTFD", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm sendcreate VTFD", log.Fields{
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
- meInstance := oFsm.pOmciCC.sendCreateVtfdVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
@@ -660,24 +660,24 @@
}
}
-func (oFsm *UniVlanConfigFsm) enterConfigEvtocd(e *fsm.Event) {
- logger.Debugw("UniVlanConfigFsm - start config EVTOCD loop", log.Fields{
+func (oFsm *UniVlanConfigFsm) enterConfigEvtocd(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniVlanConfigFsm - start config EVTOCD loop", log.Fields{
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
oFsm.requestEventOffset = 0 //0 offset for last flow-add activity
go func() {
tpID := oFsm.uniVlanFlowParamsSlice[0].VlanRuleParams.TpID
vlanID := oFsm.uniVlanFlowParamsSlice[0].VlanRuleParams.SetVid
- errEvto := oFsm.performConfigEvtocdEntries(oFsm.configuredUniFlow)
+ errEvto := oFsm.performConfigEvtocdEntries(ctx, oFsm.configuredUniFlow)
//This is correct passing scenario
if errEvto == nil {
- for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(oFsm.pOnuUniPort.uniID, uint8(tpID)) {
- log.Infow("Setting multicast MEs, with first flow", log.Fields{"deviceID": oFsm.deviceID,
+ for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(ctx, oFsm.pOnuUniPort.uniID, uint8(tpID)) {
+ logger.Infow(ctx, "Setting multicast MEs, with first flow", log.Fields{"deviceID": oFsm.deviceID,
"techProfile": tpID, "gemPort": gemPort, "vlanID": vlanID, "configuredUniFlow": oFsm.configuredUniFlow})
//can Use the first elements in the slice because it's the first flow.
- errCreateAllMulticastME := oFsm.performSettingMulticastME(tpID, gemPort,
+ errCreateAllMulticastME := oFsm.performSettingMulticastME(ctx, tpID, gemPort,
vlanID)
if errCreateAllMulticastME != nil {
- logger.Errorw("Multicast ME create failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "Multicast ME create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
}
@@ -688,8 +688,8 @@
}()
}
-func (oFsm *UniVlanConfigFsm) enterVlanConfigDone(e *fsm.Event) {
- logger.Debugw("UniVlanConfigFsm - checking on more flows", log.Fields{
+func (oFsm *UniVlanConfigFsm) enterVlanConfigDone(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniVlanConfigFsm - checking on more flows", log.Fields{
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
pConfigVlanStateBaseFsm := oFsm.pAdaptFsm.pFsm
if len(oFsm.uniRemoveFlowsSlice) > 0 {
@@ -709,18 +709,18 @@
return
}
- logger.Debugw("UniVlanConfigFsm - VLAN config done: send dh event notification", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm - VLAN config done: send dh event notification", log.Fields{
"device-id": oFsm.deviceID})
// it might appear that some flows are requested also after 'flowPushed' event has been generated ...
// state transition notification is checked in deviceHandler
if oFsm.pDeviceHandler != nil {
//making use of the add->remove successor enum assumption/definition
- go oFsm.pDeviceHandler.deviceProcStatusUpdate(OnuDeviceEvent(uint8(oFsm.requestEvent) + oFsm.requestEventOffset))
+ go oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent(uint8(oFsm.requestEvent)+oFsm.requestEventOffset))
}
}
-func (oFsm *UniVlanConfigFsm) enterConfigIncrFlow(e *fsm.Event) {
- logger.Debugw("UniVlanConfigFsm - start config further incremental flow", log.Fields{
+func (oFsm *UniVlanConfigFsm) enterConfigIncrFlow(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniVlanConfigFsm - start config further incremental flow", log.Fields{
"in state": e.FSM.Current(), "recent flow-number": oFsm.configuredUniFlow,
"device-id": oFsm.deviceID})
oFsm.mutexFlowParams.Lock()
@@ -749,7 +749,7 @@
if oFsm.uniVlanFlowParamsSlice[oFsm.configuredUniFlow].VlanRuleParams.SetVid == uint32(of.OfpVlanId_OFPVID_PRESENT) {
// meaning transparent setup - no specific VTFD setting required
oFsm.mutexFlowParams.Unlock()
- logger.Debugw("UniVlanConfigFsm: no VTFD config required", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm: no VTFD config required", log.Fields{
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
} else {
if oFsm.numVlanFilterEntries == 0 {
@@ -757,7 +757,7 @@
// this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME.
vtfdID := macBridgePortAniEID + oFsm.pOnuUniPort.entityID + oFsm.uniVlanFlowParamsSlice[0].VlanRuleParams.TpID
//no VTFD yet created
- logger.Debugw("UniVlanConfigFsm create VTFD", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm create VTFD", log.Fields{
"EntitytId": strconv.FormatInt(int64(vtfdID), 16),
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
// FIXME: VOL-3673: using oFsm.uniVlanFlowParamsSlice[0] is incorrect here, as the relevant (first) VTFD may
@@ -778,7 +778,7 @@
"NumberOfEntries": oFsm.numVlanFilterEntries,
},
}
- meInstance := oFsm.pOmciCC.sendCreateVtfdVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
@@ -791,7 +791,7 @@
// this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME.
vtfdID := macBridgePortAniEID + oFsm.pOnuUniPort.entityID + oFsm.uniVlanFlowParamsSlice[oFsm.configuredUniFlow].VlanRuleParams.TpID
- logger.Debugw("UniVlanConfigFsm set VTFD", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm set VTFD", log.Fields{
"EntitytId": strconv.FormatInt(int64(vtfdID), 16),
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
// setVid is assumed to be masked already by the caller to 12 bit
@@ -814,7 +814,7 @@
"NumberOfEntries": oFsm.numVlanFilterEntries,
},
}
- meInstance := oFsm.pOmciCC.sendCreateVtfdVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
@@ -824,9 +824,9 @@
oFsm.pLastTxMeInstance = meInstance
}
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("VTFD create/set failed, aborting VlanConfig FSM!",
+ logger.Errorw(ctx, "VTFD create/set failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
pConfigVlanStateBaseFsm := oFsm.pAdaptFsm.pFsm
go func(a_pBaseFsm *fsm.FSM) {
@@ -838,19 +838,19 @@
oFsm.requestEventOffset = 0 //0 offset for last flow-add activity
go func() {
tpID := oFsm.uniVlanFlowParamsSlice[oFsm.configuredUniFlow].VlanRuleParams.TpID
- errEvto := oFsm.performConfigEvtocdEntries(oFsm.configuredUniFlow)
+ errEvto := oFsm.performConfigEvtocdEntries(ctx, oFsm.configuredUniFlow)
//This is correct passing scenario
if errEvto == nil {
//TODO Possibly insert new state for multicast --> possibly another jira/later time.
- for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(oFsm.pOnuUniPort.uniID, uint8(tpID)) {
+ for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(ctx, oFsm.pOnuUniPort.uniID, uint8(tpID)) {
vlanID := oFsm.uniVlanFlowParamsSlice[oFsm.configuredUniFlow-1].VlanRuleParams.SetVid
- log.Infow("Setting multicast MEs for additional flows", log.Fields{"deviceID": oFsm.deviceID,
+ logger.Infow(ctx, "Setting multicast MEs for additional flows", log.Fields{"deviceID": oFsm.deviceID,
"techProfile": tpID, "gemPort": gemPort,
"vlanID": vlanID, "configuredUniFlow": oFsm.configuredUniFlow})
//-1 is to use the last configured flow
- errCreateAllMulticastME := oFsm.performSettingMulticastME(tpID, gemPort, vlanID)
+ errCreateAllMulticastME := oFsm.performSettingMulticastME(ctx, tpID, gemPort, vlanID)
if errCreateAllMulticastME != nil {
- logger.Errorw("Multicast ME create failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "Multicast ME create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
}
@@ -860,9 +860,9 @@
}()
}
-func (oFsm *UniVlanConfigFsm) enterRemoveFlow(e *fsm.Event) {
+func (oFsm *UniVlanConfigFsm) enterRemoveFlow(ctx context.Context, e *fsm.Event) {
oFsm.mutexFlowParams.Lock()
- logger.Debugw("UniVlanConfigFsm - start removing the top remove-flow", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm - start removing the top remove-flow", log.Fields{
"in state": e.FSM.Current(), "with last cookie": oFsm.uniRemoveFlowsSlice[0].cookie,
"device-id": oFsm.deviceID})
@@ -873,14 +873,14 @@
//shallow copy is sufficient as no reference variables are used within struct
loRuleParams := oFsm.uniRemoveFlowsSlice[0].vlanRuleParams
oFsm.mutexFlowParams.Unlock()
- logger.Debugw("UniVlanConfigFsm - remove-flow parameters are", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm - remove-flow parameters are", log.Fields{
"match vid": loRuleParams.MatchVid, "match Pcp": loRuleParams.MatchPcp,
"set vid": strconv.FormatInt(int64(loRuleParams.SetVid), 16),
"device-id": oFsm.deviceID})
if loRuleParams.SetVid == uint32(of.OfpVlanId_OFPVID_PRESENT) {
// meaning transparent setup - no specific VTFD setting required
- logger.Debugw("UniVlanConfigFsm: no VTFD removal required for transparent flow", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm: no VTFD removal required for transparent flow", log.Fields{
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
} else {
vtfdFilterList := make([]uint16, cVtfdTableSize) //needed for parameter serialization and 're-copy'
@@ -888,22 +888,22 @@
vtfdID := macBridgePortAniEID + oFsm.pOnuUniPort.entityID + loRuleParams.TpID
//only one active VLAN entry (hopefully the SetVID we want to remove - should be, but not verified ..)
// so we can just delete the VTFD entry
- logger.Debugw("UniVlanConfigFsm: VTFD delete (no more vlan filters)",
+ logger.Debugw(ctx, "UniVlanConfigFsm: VTFD delete (no more vlan filters)",
log.Fields{"current vlan list": oFsm.vlanFilterList,
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
loVlanEntryClear = 1 //full VlanFilter clear request
if loAllowSpecificOmciConfig { //specific OMCI config is expected to work acc. to the device state
- meInstance := oFsm.pOmciCC.sendDeleteVtfd(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendDeleteVtfd(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, vtfdID)
oFsm.pLastTxMeInstance = meInstance
} else {
- logger.Debugw("UniVlanConfigFsm delete VTFD OMCI handling skipped based on device state", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm delete VTFD OMCI handling skipped based on device state", log.Fields{
"device-id": oFsm.deviceID, "device-state": deviceReasonMap[oFsm.pDeviceHandler.deviceReason]})
}
} else {
//many VTFD already should exists - find and remove the one concerned by the actual remove rule
// by updating the VTFD per set command with new valid list
- logger.Debugw("UniVlanConfigFsm: VTFD removal of requested VLAN from the list on OMCI",
+ logger.Debugw(ctx, "UniVlanConfigFsm: VTFD removal of requested VLAN from the list on OMCI",
log.Fields{"current vlan list": oFsm.vlanFilterList,
"set-vlan": loRuleParams.SetVid, "device-id": oFsm.deviceID})
for i := uint8(0); i < oFsm.numVlanFilterEntries; i++ {
@@ -925,30 +925,30 @@
vtfdFilterList[i] = 0 //set last byte if needed
}
}
- logger.Debugw("UniVlanConfigFsm set VTFD", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm set VTFD", log.Fields{
"EntitytId": strconv.FormatInt(int64(vtfdID), 16),
"new vlan list": vtfdFilterList, "device-id": oFsm.deviceID})
if loAllowSpecificOmciConfig { //specific OMCI config is expected to work acc. to the device state
// FIXME: VOL-3685: Issues with resetting a table entry in EVTOCD ME
- meInstance := oFsm.pOmciCC.sendDeleteVtfd(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendDeleteVtfd(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, vtfdID)
oFsm.pLastTxMeInstance = meInstance
} else {
- logger.Debugw("UniVlanConfigFsm set VTFD OMCI handling skipped based on device state", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm set VTFD OMCI handling skipped based on device state", log.Fields{
"device-id": oFsm.deviceID, "device-state": deviceReasonMap[oFsm.pDeviceHandler.deviceReason]})
}
} else {
- logger.Warnw("UniVlanConfigFsm: requested VLAN for removal not found in list - ignore and continue (no VTFD set)",
+ logger.Warnw(ctx, "UniVlanConfigFsm: requested VLAN for removal not found in list - ignore and continue (no VTFD set)",
log.Fields{"device-id": oFsm.deviceID})
}
}
if loVlanEntryClear > 0 {
if loAllowSpecificOmciConfig { //specific OMCI config is expected to work acc. to the device state
//waiting on response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("VTFD delete/reset failed, aborting VlanConfig FSM!",
+ logger.Errorw(ctx, "VTFD delete/reset failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
// calling some FSM event must be decoupled
go func(a_pBaseFsm *fsm.FSM) {
@@ -973,10 +973,10 @@
}
if loAllowSpecificOmciConfig { //specific OMCI config is expected to work acc. to the device state
- go oFsm.removeEvtocdEntries(loRuleParams)
+ go oFsm.removeEvtocdEntries(ctx, loRuleParams)
} else {
// OMCI processing is not done, expectation is to have the ONU in some basic config state accordingly
- logger.Debugw("UniVlanConfigFsm remove EVTOCD OMCI handling skipped based on device state", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm remove EVTOCD OMCI handling skipped based on device state", log.Fields{
"device-id": oFsm.deviceID})
// calling some FSM event must be decoupled
go func(a_pBaseFsm *fsm.FSM) {
@@ -985,21 +985,21 @@
}
}
-func (oFsm *UniVlanConfigFsm) enterVlanCleanupDone(e *fsm.Event) {
- logger.Debugw("UniVlanConfigFsm - removing the removal data", log.Fields{
+func (oFsm *UniVlanConfigFsm) enterVlanCleanupDone(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniVlanConfigFsm - removing the removal data", log.Fields{
"in state": e.FSM.Current(), "device-id": oFsm.deviceID})
oFsm.mutexFlowParams.Lock()
if len(oFsm.uniRemoveFlowsSlice) <= 1 {
oFsm.uniRemoveFlowsSlice = nil //reset the slice
- logger.Debugw("UniVlanConfigFsm flow removal - last remove-flow deleted", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm flow removal - last remove-flow deleted", log.Fields{
"device-id": oFsm.deviceID})
} else {
//cut off the actual flow by slicing out the first element
oFsm.uniRemoveFlowsSlice = append(
oFsm.uniRemoveFlowsSlice[:0],
oFsm.uniRemoveFlowsSlice[1:]...)
- logger.Debugw("UniVlanConfigFsm flow removal - specific flow deleted from data", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm flow removal - specific flow deleted from data", log.Fields{
"device-id": oFsm.deviceID})
}
oFsm.mutexFlowParams.Unlock()
@@ -1017,8 +1017,8 @@
}
}
-func (oFsm *UniVlanConfigFsm) enterResetting(e *fsm.Event) {
- logger.Debugw("UniVlanConfigFsm resetting", log.Fields{"device-id": oFsm.deviceID})
+func (oFsm *UniVlanConfigFsm) enterResetting(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniVlanConfigFsm resetting", log.Fields{"device-id": oFsm.deviceID})
pConfigVlanStateAFsm := oFsm.pAdaptFsm
if pConfigVlanStateAFsm != nil {
@@ -1040,8 +1040,8 @@
}
}
-func (oFsm *UniVlanConfigFsm) enterDisabled(e *fsm.Event) {
- logger.Debugw("UniVlanConfigFsm enters disabled state", log.Fields{"device-id": oFsm.deviceID})
+func (oFsm *UniVlanConfigFsm) enterDisabled(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "UniVlanConfigFsm enters disabled state", log.Fields{"device-id": oFsm.deviceID})
oFsm.pLastTxMeInstance = nil
if oFsm.pDeviceHandler != nil {
//TODO: to clarify with improved error treatment for VlanConfigFsm (timeout,reception) errors
@@ -1052,60 +1052,60 @@
//permanently remove possibly stored persistent data
if len(oFsm.uniVlanFlowParamsSlice) > 0 {
var emptySlice = make([]uniVlanFlowParams, 0)
- _ = oFsm.pDeviceHandler.storePersUniFlowConfig(oFsm.pOnuUniPort.uniID, &emptySlice) //ignore errors
+ _ = oFsm.pDeviceHandler.storePersUniFlowConfig(ctx, oFsm.pOnuUniPort.uniID, &emptySlice) //ignore errors
}
} else {
- logger.Debugw("UniVlanConfigFsm persistency data not cleared", log.Fields{"device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "UniVlanConfigFsm persistency data not cleared", log.Fields{"device-id": oFsm.deviceID})
}
//request removal of 'reference' in the Handler (completely clear the FSM and its data)
- go oFsm.pDeviceHandler.RemoveVlanFilterFsm(oFsm.pOnuUniPort)
+ go oFsm.pDeviceHandler.RemoveVlanFilterFsm(ctx, oFsm.pOnuUniPort)
}
}
-func (oFsm *UniVlanConfigFsm) processOmciVlanMessages() { //ctx context.Context?
- logger.Debugw("Start UniVlanConfigFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID})
+func (oFsm *UniVlanConfigFsm) processOmciVlanMessages(ctx context.Context) { //ctx context.Context?
+ logger.Debugw(ctx, "Start UniVlanConfigFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID})
loop:
for {
// case <-ctx.Done():
- // logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID})
+ // logger.Info(ctx,"MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID})
// break loop
message, ok := <-oFsm.pAdaptFsm.commChan
if !ok {
- logger.Info("UniVlanConfigFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
+ logger.Info(ctx, "UniVlanConfigFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
// but then we have to ensure a restart of the FSM as well - as exceptional procedure
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
break loop
}
- logger.Debugw("UniVlanConfigFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "UniVlanConfigFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
switch message.Type {
case TestMsg:
msg, _ := message.Data.(TestMessage)
if msg.TestMessageVal == AbortMessageProcessing {
- logger.Infow("UniVlanConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Infow(ctx, "UniVlanConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
break loop
}
- logger.Warnw("UniVlanConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
+ logger.Warnw(ctx, "UniVlanConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
case OMCI:
msg, _ := message.Data.(OmciMessage)
- oFsm.handleOmciVlanConfigMessage(msg)
+ oFsm.handleOmciVlanConfigMessage(ctx, msg)
default:
- logger.Warn("UniVlanConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
+ logger.Warn(ctx, "UniVlanConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
"message.Type": message.Type})
}
}
- logger.Infow("End UniVlanConfigFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
+ logger.Infow(ctx, "End UniVlanConfigFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
}
-func (oFsm *UniVlanConfigFsm) handleOmciVlanConfigMessage(msg OmciMessage) {
- logger.Debugw("Rx OMCI UniVlanConfigFsm Msg", log.Fields{"device-id": oFsm.deviceID,
+func (oFsm *UniVlanConfigFsm) handleOmciVlanConfigMessage(ctx context.Context, msg OmciMessage) {
+ logger.Debugw(ctx, "Rx OMCI UniVlanConfigFsm Msg", log.Fields{"device-id": oFsm.deviceID,
"msgType": msg.OmciMsg.MessageType})
switch msg.OmciMsg.MessageType {
case omci.CreateResponseType:
{ // had to shift that to a method to cope with StaticCodeAnalysis restrictions :-(
- if err := oFsm.handleOmciCreateResponseMessage(msg.OmciPacket); err != nil {
- logger.Warnw("CreateResponse handling aborted", log.Fields{"err": err})
+ if err := oFsm.handleOmciCreateResponseMessage(ctx, msg.OmciPacket); err != nil {
+ logger.Warnw(ctx, "CreateResponse handling aborted", log.Fields{"err": err})
return
}
} //CreateResponseType
@@ -1113,19 +1113,19 @@
{ //leave that here as direct code as most often used
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse)
if msgLayer == nil {
- logger.Errorw("Omci Msg layer could not be detected for SetResponse",
+ logger.Errorw(ctx, "Omci Msg layer could not be detected for SetResponse",
log.Fields{"device-id": oFsm.deviceID})
return
}
msgObj, msgOk := msgLayer.(*omci.SetResponse)
if !msgOk {
- logger.Errorw("Omci Msg layer could not be assigned for SetResponse",
+ logger.Errorw(ctx, "Omci Msg layer could not be assigned for SetResponse",
log.Fields{"device-id": oFsm.deviceID})
return
}
- logger.Debugw("UniVlanConfigFsm SetResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "UniVlanConfigFsm SetResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
if msgObj.Result != me.Success {
- logger.Errorw("UniVlanConfigFsm Omci SetResponse Error - later: drive FSM to abort state ?",
+ logger.Errorw(ctx, "UniVlanConfigFsm Omci SetResponse Error - later: drive FSM to abort state ?",
log.Fields{"device-id": oFsm.deviceID, "Error": msgObj.Result})
// possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
return
@@ -1142,38 +1142,38 @@
} //SetResponseType
case omci.DeleteResponseType:
{ // had to shift that to a method to cope with StaticCodeAnalysis restrictions :-(
- if err := oFsm.handleOmciDeleteResponseMessage(msg.OmciPacket); err != nil {
- logger.Warnw("DeleteResponse handling aborted", log.Fields{"err": err})
+ if err := oFsm.handleOmciDeleteResponseMessage(ctx, msg.OmciPacket); err != nil {
+ logger.Warnw(ctx, "DeleteResponse handling aborted", log.Fields{"err": err})
return
}
} //DeleteResponseType
default:
{
- logger.Errorw("Rx OMCI unhandled MsgType",
+ logger.Errorw(ctx, "Rx OMCI unhandled MsgType",
log.Fields{"omciMsgType": msg.OmciMsg.MessageType, "device-id": oFsm.deviceID})
return
}
}
}
-func (oFsm *UniVlanConfigFsm) handleOmciCreateResponseMessage(apOmciPacket *gp.Packet) error {
+func (oFsm *UniVlanConfigFsm) handleOmciCreateResponseMessage(ctx context.Context, apOmciPacket *gp.Packet) error {
msgLayer := (*apOmciPacket).Layer(omci.LayerTypeCreateResponse)
if msgLayer == nil {
- logger.Errorw("Omci Msg layer could not be detected for CreateResponse",
+ logger.Errorw(ctx, "Omci Msg layer could not be detected for CreateResponse",
log.Fields{"device-id": oFsm.deviceID})
return fmt.Errorf("omci msg layer could not be detected for CreateResponse for device-id %x",
oFsm.deviceID)
}
msgObj, msgOk := msgLayer.(*omci.CreateResponse)
if !msgOk {
- logger.Errorw("Omci Msg layer could not be assigned for CreateResponse",
+ logger.Errorw(ctx, "Omci Msg layer could not be assigned for CreateResponse",
log.Fields{"device-id": oFsm.deviceID})
return fmt.Errorf("omci msg layer could not be assigned for CreateResponse for device-id %x",
oFsm.deviceID)
}
- logger.Debugw("UniVlanConfigFsm CreateResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "UniVlanConfigFsm CreateResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
if msgObj.Result != me.Success && msgObj.Result != me.InstanceExists {
- logger.Errorw("Omci CreateResponse Error - later: drive FSM to abort state ?", log.Fields{"device-id": oFsm.deviceID,
+ logger.Errorw(ctx, "Omci CreateResponse Error - later: drive FSM to abort state ?", log.Fields{"device-id": oFsm.deviceID,
"Error": msgObj.Result})
// possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
return fmt.Errorf("omci CreateResponse Error for device-id %x",
@@ -1199,24 +1199,24 @@
return nil
}
-func (oFsm *UniVlanConfigFsm) handleOmciDeleteResponseMessage(apOmciPacket *gp.Packet) error {
+func (oFsm *UniVlanConfigFsm) handleOmciDeleteResponseMessage(ctx context.Context, apOmciPacket *gp.Packet) error {
msgLayer := (*apOmciPacket).Layer(omci.LayerTypeDeleteResponse)
if msgLayer == nil {
- logger.Errorw("UniVlanConfigFsm - Omci Msg layer could not be detected for DeleteResponse",
+ logger.Errorw(ctx, "UniVlanConfigFsm - Omci Msg layer could not be detected for DeleteResponse",
log.Fields{"device-id": oFsm.deviceID})
return fmt.Errorf("omci msg layer could not be detected for DeleteResponse for device-id %x",
oFsm.deviceID)
}
msgObj, msgOk := msgLayer.(*omci.DeleteResponse)
if !msgOk {
- logger.Errorw("UniVlanConfigFsm - Omci Msg layer could not be assigned for DeleteResponse",
+ logger.Errorw(ctx, "UniVlanConfigFsm - Omci Msg layer could not be assigned for DeleteResponse",
log.Fields{"device-id": oFsm.deviceID})
return fmt.Errorf("omci msg layer could not be assigned for DeleteResponse for device-id %x",
oFsm.deviceID)
}
- logger.Debugw("UniVlanConfigFsm DeleteResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "UniVlanConfigFsm DeleteResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
if msgObj.Result != me.Success {
- logger.Errorw("UniVlanConfigFsm - Omci DeleteResponse Error - later: drive FSM to abort state ?",
+ logger.Errorw(ctx, "UniVlanConfigFsm - Omci DeleteResponse Error - later: drive FSM to abort state ?",
log.Fields{"device-id": oFsm.deviceID, "Error": msgObj.Result})
// possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
return fmt.Errorf("omci DeleteResponse Error for device-id %x",
@@ -1234,12 +1234,12 @@
return nil
}
-func (oFsm *UniVlanConfigFsm) performConfigEvtocdEntries(aFlowEntryNo uint8) error {
+func (oFsm *UniVlanConfigFsm) performConfigEvtocdEntries(ctx context.Context, aFlowEntryNo uint8) error {
if aFlowEntryNo == 0 {
// EthType set only at first flow element
// EVTOCD ME is expected to exist at this point already from MIB-Download (with AssociationType/Pointer)
// we need to extend the configuration by EthType definition and, to be sure, downstream 'inverse' mode
- logger.Debugw("UniVlanConfigFsm Tx Create::EVTOCD", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm Tx Create::EVTOCD", log.Fields{
"EntitytId": strconv.FormatInt(int64(oFsm.evtocdID), 16),
"i/oEthType": strconv.FormatInt(int64(cDefaultTpid), 16),
"device-id": oFsm.deviceID})
@@ -1265,9 +1265,9 @@
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("Evtocd create failed, aborting VlanConfig FSM!",
+ logger.Errorw(ctx, "Evtocd create failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return fmt.Errorf("evtocd create failed %s, error %s", oFsm.deviceID, err)
@@ -1282,16 +1282,16 @@
"DownstreamMode": uint8(cDefaultDownstreamMode),
},
}
- meInstance = oFsm.pOmciCC.sendSetEvtocdVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance = oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err = oFsm.waitforOmciResponse()
+ err = oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("Evtocd set TPID failed, aborting VlanConfig FSM!",
+ logger.Errorw(ctx, "Evtocd set TPID failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return fmt.Errorf("evtocd set TPID failed %s, error %s", oFsm.deviceID, err)
@@ -1313,7 +1313,7 @@
if oFsm.uniVlanFlowParamsSlice[aFlowEntryNo].VlanRuleParams.SetVid == uint32(of.OfpVlanId_OFPVID_PRESENT) {
//transparent transmission required
oFsm.mutexFlowParams.Unlock()
- logger.Debugw("UniVlanConfigFsm Tx Set::EVTOCD single tagged transparent rule", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD single tagged transparent rule", log.Fields{
"device-id": oFsm.deviceID})
sliceEvtocdRule := make([]uint8, 16)
// fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word'
@@ -1345,16 +1345,16 @@
"ReceivedFrameVlanTaggingOperationTable": sliceEvtocdRule,
},
}
- meInstance := oFsm.pOmciCC.sendSetEvtocdVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("Evtocd set transparent singletagged rule failed, aborting VlanConfig FSM!",
+ logger.Errorw(ctx, "Evtocd set transparent singletagged rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return fmt.Errorf("evtocd set transparent singletagged rule failed %s, error %s", oFsm.deviceID, err)
@@ -1368,7 +1368,7 @@
setPcp := oFsm.uniVlanFlowParamsSlice[aFlowEntryNo].VlanRuleParams.SetPcp
setVid := oFsm.uniVlanFlowParamsSlice[aFlowEntryNo].VlanRuleParams.SetVid
// this defines VID translation scenario: singletagged->singletagged (if not transparent)
- logger.Debugw("UniVlanConfigFsm Tx Set::EVTOCD single tagged translation rule", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD single tagged translation rule", log.Fields{
"match-pcp": matchPcp, "match-vid": matchVid, "set-pcp": setPcp, "set-vid:": setVid, "device-id": oFsm.deviceID})
sliceEvtocdRule := make([]uint8, 16)
// fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word'
@@ -1401,16 +1401,16 @@
"ReceivedFrameVlanTaggingOperationTable": sliceEvtocdRule,
},
}
- meInstance := oFsm.pOmciCC.sendSetEvtocdVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("Evtocd set singletagged translation rule failed, aborting VlanConfig FSM!",
+ logger.Errorw(ctx, "Evtocd set singletagged translation rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return fmt.Errorf("evtocd set singletagged translation rule failed %s, error %s", oFsm.deviceID, err)
@@ -1419,7 +1419,7 @@
//not transparent and not acceptIncrementalEvtoOption untagged/priotagged->singletagged
{ // just for local var's
// this defines stacking scenario: untagged->singletagged
- logger.Debugw("UniVlanConfigFsm Tx Set::EVTOCD untagged->singletagged rule", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD untagged->singletagged rule", log.Fields{
"device-id": oFsm.deviceID})
sliceEvtocdRule := make([]uint8, 16)
// fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word'
@@ -1453,16 +1453,16 @@
"ReceivedFrameVlanTaggingOperationTable": sliceEvtocdRule,
},
}
- meInstance := oFsm.pOmciCC.sendSetEvtocdVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("Evtocd set untagged->singletagged rule failed, aborting VlanConfig FSM!",
+ logger.Errorw(ctx, "Evtocd set untagged->singletagged rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return fmt.Errorf("evtocd set untagged->singletagged rule failed %s, error %s", oFsm.deviceID, err)
@@ -1471,7 +1471,7 @@
} // just for local var's
{ // just for local var's
// this defines 'stacking' scenario: priotagged->singletagged
- logger.Debugw("UniVlanConfigFsm Tx Set::EVTOCD priotagged->singletagged rule", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD priotagged->singletagged rule", log.Fields{
"device-id": oFsm.deviceID})
sliceEvtocdRule := make([]uint8, 16)
// fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word'
@@ -1506,16 +1506,16 @@
"ReceivedFrameVlanTaggingOperationTable": sliceEvtocdRule,
},
}
- meInstance := oFsm.pOmciCC.sendSetEvtocdVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("Evtocd set priotagged->singletagged rule failed, aborting VlanConfig FSM!",
+ logger.Errorw(ctx, "Evtocd set priotagged->singletagged rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return fmt.Errorf("evtocd set priotagged->singletagged rule failed %s, error %s", oFsm.deviceID, err)
@@ -1526,18 +1526,18 @@
}
// if Config has been done for all EVTOCD entries let the FSM proceed
- logger.Debugw("EVTOCD set loop finished", log.Fields{"device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "EVTOCD set loop finished", log.Fields{"device-id": oFsm.deviceID})
oFsm.configuredUniFlow++ // one (more) flow configured
return nil
}
-func (oFsm *UniVlanConfigFsm) removeEvtocdEntries(aRuleParams uniVlanRuleParams) {
+func (oFsm *UniVlanConfigFsm) removeEvtocdEntries(ctx context.Context, aRuleParams uniVlanRuleParams) {
// configured Input/Output TPID is not modified again - no influence if no filter is applied
if aRuleParams.SetVid == uint32(of.OfpVlanId_OFPVID_PRESENT) {
//transparent transmission was set
//perhaps the config is not needed for removal,
// but the specific InnerTpid setting is removed in favor of the real default forwarding rule
- logger.Debugw("UniVlanConfigFsm Tx Set::EVTOCD reset to default single tagged rule", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD reset to default single tagged rule", log.Fields{
"device-id": oFsm.deviceID})
sliceEvtocdRule := make([]uint8, 16)
// fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word'
@@ -1569,16 +1569,16 @@
"ReceivedFrameVlanTaggingOperationTable": sliceEvtocdRule,
},
}
- meInstance := oFsm.pOmciCC.sendSetEvtocdVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("Evtocd reset singletagged rule failed, aborting VlanConfig FSM!",
+ logger.Errorw(ctx, "Evtocd reset singletagged rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return
@@ -1587,7 +1587,7 @@
// according to py-code acceptIncrementalEvto program option decides upon stacking or translation scenario
if oFsm.acceptIncrementalEvtoOption {
// this defines VID translation scenario: singletagged->singletagged (if not transparent)
- logger.Debugw("UniVlanConfigFsm Tx Set::EVTOCD clear single tagged translation rule", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD clear single tagged translation rule", log.Fields{
"device-id": oFsm.deviceID, "match-vlan": aRuleParams.MatchVid})
sliceEvtocdRule := make([]uint8, 16)
// fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word'
@@ -1612,16 +1612,16 @@
"ReceivedFrameVlanTaggingOperationTable": sliceEvtocdRule,
},
}
- meInstance := oFsm.pOmciCC.sendSetEvtocdVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("Evtocd clear singletagged translation rule failed, aborting VlanConfig FSM!",
+ logger.Errorw(ctx, "Evtocd clear singletagged translation rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "match-vlan": aRuleParams.MatchVid})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return
@@ -1638,22 +1638,22 @@
// Interstingly this problem has not been observed in multi-tcont (or multi-service) scenario (in
// which case the oFsm.acceptIncrementalEvtoOption is set to true).
if oFsm.configuredUniFlow == 0 && !oFsm.acceptIncrementalEvtoOption {
- logger.Debugw("UniVlanConfigFsm Tx Remove::EVTOCD", log.Fields{"device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "UniVlanConfigFsm Tx Remove::EVTOCD", log.Fields{"device-id": oFsm.deviceID})
// When there are no more EVTOCD vlan configurations on the ONU and acceptIncrementalEvtoOption
// is not enabled, delete the EVTOCD ME.
meParams := me.ParamData{
EntityID: oFsm.evtocdID,
}
- meInstance := oFsm.pOmciCC.sendDeleteEvtocd(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendDeleteEvtocd(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("Evtocd delete rule failed, aborting VlanConfig FSM!",
+ logger.Errorw(ctx, "Evtocd delete rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return
@@ -1661,7 +1661,7 @@
} else {
// NOTE : We should ideally never ether this section when oFsm.acceptIncrementalEvtoOption is set to false
// This is true for only ATT/DT workflow
- logger.Debugw("UniVlanConfigFsm: Remove EVTOCD set operation",
+ logger.Debugw(ctx, "UniVlanConfigFsm: Remove EVTOCD set operation",
log.Fields{"configured-flow": oFsm.configuredUniFlow, "incremental-evto": oFsm.acceptIncrementalEvtoOption})
//not transparent and not acceptIncrementalEvtoOption: untagged/priotagged->singletagged
{ // just for local var's
@@ -1670,7 +1670,7 @@
// for untagged/priotagged, last rule wins (and remains the only one), maybe that should be
// checked already at flow-add (and rejected) - to be observed if such is possible in Voltha
// delete now assumes there is only one such rule!
- logger.Debugw("UniVlanConfigFsm Tx Set::EVTOCD reset untagged rule to default", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD reset untagged rule to default", log.Fields{
"device-id": oFsm.deviceID})
sliceEvtocdRule := make([]uint8, 16)
// fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word'
@@ -1709,9 +1709,9 @@
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("Evtocd reset untagged rule to default failed, aborting VlanConfig FSM!",
+ logger.Errorw(ctx, "Evtocd reset untagged rule to default failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return
@@ -1719,7 +1719,7 @@
} // just for local var's
{ // just for local var's
// this defines 'stacking' scenario: priotagged->singletagged
- logger.Debugw("UniVlanConfigFsm Tx Set::EVTOCD delete priotagged rule", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD delete priotagged rule", log.Fields{
"device-id": oFsm.deviceID})
sliceEvtocdRule := make([]uint8, 16)
// fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word'
@@ -1744,16 +1744,16 @@
"ReceivedFrameVlanTaggingOperationTable": sliceEvtocdRule,
},
}
- meInstance := oFsm.pOmciCC.sendSetEvtocdVar(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("Evtocd delete priotagged rule failed, aborting VlanConfig FSM!",
+ logger.Errorw(ctx, "Evtocd delete priotagged rule failed, aborting VlanConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvReset)
return
@@ -1764,51 +1764,51 @@
}
// if Config has been done for all EVTOCD entries let the FSM proceed
- logger.Debugw("EVTOCD filter remove loop finished", log.Fields{"device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "EVTOCD filter remove loop finished", log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(vlanEvRemFlowDone)
}
-func (oFsm *UniVlanConfigFsm) waitforOmciResponse() error {
+func (oFsm *UniVlanConfigFsm) waitforOmciResponse(ctx context.Context) error {
select {
// maybe be also some outside cancel (but no context modeled for the moment ...)
// case <-ctx.Done():
- // logger.Infow("LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.deviceID})
+ // logger.Infow(ctx,"LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.deviceID})
case <-time.After(30 * time.Second): //AS FOR THE OTHER OMCI FSM's
- logger.Warnw("UniVlanConfigFsm multi entity timeout", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Warnw(ctx, "UniVlanConfigFsm multi entity timeout", log.Fields{"for device-id": oFsm.deviceID})
return fmt.Errorf("uniVlanConfigFsm multi entity timeout %s", oFsm.deviceID)
case success := <-oFsm.omciMIdsResponseReceived:
if success {
- logger.Debug("UniVlanConfigFsm multi entity response received")
+ logger.Debug(ctx, "UniVlanConfigFsm multi entity response received")
return nil
}
// should not happen so far
- logger.Warnw("UniVlanConfigFsm multi entity response error", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Warnw(ctx, "UniVlanConfigFsm multi entity response error", log.Fields{"for device-id": oFsm.deviceID})
return fmt.Errorf("uniVlanConfigFsm multi entity responseError %s", oFsm.deviceID)
}
}
-func (oFsm *UniVlanConfigFsm) performSettingMulticastME(tpID uint16, multicastGemPortID uint16, vlanID uint32) error {
- logger.Debugw("Setting Multicast MEs", log.Fields{"device-id": oFsm.deviceID, "tpID": tpID,
+func (oFsm *UniVlanConfigFsm) performSettingMulticastME(ctx context.Context, tpID uint16, multicastGemPortID uint16, vlanID uint32) error {
+ logger.Debugw(ctx, "Setting Multicast MEs", log.Fields{"device-id": oFsm.deviceID, "tpID": tpID,
"multicastGemPortID": multicastGemPortID, "vlanID": vlanID})
- errCreateMOP := oFsm.performCreatingMulticastOperationProfile()
+ errCreateMOP := oFsm.performCreatingMulticastOperationProfile(ctx)
if errCreateMOP != nil {
- logger.Errorw("MulticastOperationProfile create failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "MulticastOperationProfile create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, errCreateMOP)
}
- errSettingMOP := oFsm.performSettingMulticastOperationProfile(multicastGemPortID, vlanID)
+ errSettingMOP := oFsm.performSettingMulticastOperationProfile(ctx, multicastGemPortID, vlanID)
if errSettingMOP != nil {
- logger.Errorw("MulticastOperationProfile setting failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "MulticastOperationProfile setting failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, errSettingMOP)
}
- errCreateMSCI := oFsm.performCreatingMulticastSubscriberConfigInfo()
+ errCreateMSCI := oFsm.performCreatingMulticastSubscriberConfigInfo(ctx)
if errCreateMSCI != nil {
- logger.Errorw("MulticastOperationProfile setting failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "MulticastOperationProfile setting failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, errCreateMSCI)
@@ -1828,9 +1828,9 @@
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("CreateMBPConfigData failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "CreateMBPConfigData failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "MBPConfigDataID": macBridgeServiceProfileEID})
_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, err)
@@ -1842,7 +1842,7 @@
// this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME.
mcastVtfdID := macBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo)
- logger.Debugw("UniVlanConfigFsm set VTFD for mcast", log.Fields{
+ logger.Debugw(ctx, "UniVlanConfigFsm set VTFD for mcast", log.Fields{
"EntitytId": strconv.FormatInt(int64(mcastVtfdID), 16), "mcastVlanID": vlanID,
"in state": oFsm.pAdaptFsm.pFsm.Current(), "device-id": oFsm.deviceID})
vtfdFilterList := make([]uint16, cVtfdTableSize) //needed for parameter serialization
@@ -1863,9 +1863,9 @@
meInstance = oFsm.pOmciCC.sendCreateVtfdVar(context.TODO(), ConstDefaultOmciTimeout, true,
oFsm.pAdaptFsm.commChan, meParams)
oFsm.pLastTxMeInstance = meInstance
- err = oFsm.waitforOmciResponse()
+ err = oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("CreateMcastVlanFilterData failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "CreateMcastVlanFilterData failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "mcastVtfdID": mcastVtfdID})
_ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset)
return fmt.Errorf("createMcastVlanFilterData responseError %s, error %s", oFsm.deviceID, err)
@@ -1874,10 +1874,10 @@
return nil
}
-func (oFsm *UniVlanConfigFsm) performCreatingMulticastSubscriberConfigInfo() error {
+func (oFsm *UniVlanConfigFsm) performCreatingMulticastSubscriberConfigInfo(ctx context.Context) error {
instID, err := oFsm.pDeviceHandler.getUniPortMEEntityID(oFsm.pOnuUniPort.portNo)
if err != nil {
- log.Errorw("error fetching uni port me instance",
+ logger.Errorw(ctx, "error fetching uni port me instance",
log.Fields{"device-id": oFsm.deviceID, "portNo": oFsm.pOnuUniPort.portNo})
return err
}
@@ -1896,16 +1896,16 @@
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err = oFsm.waitforOmciResponse()
+ err = oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("CreateMulticastSubConfigInfo create failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "CreateMulticastSubConfigInfo create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "MulticastSubConfigInfo": instID})
return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s", oFsm.deviceID)
}
return nil
}
-func (oFsm *UniVlanConfigFsm) performCreatingMulticastOperationProfile() error {
+func (oFsm *UniVlanConfigFsm) performCreatingMulticastOperationProfile(ctx context.Context) error {
instID := macBridgePortAniEID + uint16(oFsm.pOnuUniPort.macBpNo)
meParams := me.ParamData{
EntityID: instID,
@@ -1929,16 +1929,16 @@
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("CreateMulticastOperationProfile create failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "CreateMulticastOperationProfile create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "MulticastOperationProfileID": instID})
return fmt.Errorf("createMulticastOperationProfile responseError %s", oFsm.deviceID)
}
return nil
}
-func (oFsm *UniVlanConfigFsm) performSettingMulticastOperationProfile(multicastGemPortID uint16, vlanID uint32) error {
+func (oFsm *UniVlanConfigFsm) performSettingMulticastOperationProfile(ctx context.Context, multicastGemPortID uint16, vlanID uint32) error {
instID := macBridgePortAniEID + uint16(oFsm.pOnuUniPort.macBpNo)
//TODO check that this is correct
// Table control
@@ -1981,9 +1981,9 @@
// - this avoids misinterpretation of new received OMCI messages
oFsm.pLastTxMeInstance = meInstance
//verify response
- err := oFsm.waitforOmciResponse()
+ err := oFsm.waitforOmciResponse(ctx)
if err != nil {
- logger.Errorw("CreateMulticastOperationProfile create failed, aborting AniConfig FSM!",
+ logger.Errorw(ctx, "CreateMulticastOperationProfile create failed, aborting AniConfig FSM!",
log.Fields{"device-id": oFsm.deviceID, "MulticastOperationProfileID": instID})
return fmt.Errorf("createMulticastOperationProfile responseError %s", oFsm.deviceID)
}
diff --git a/internal/pkg/onuadaptercore/onu_device_db.go b/internal/pkg/onuadaptercore/onu_device_db.go
index eb069ce..7cc1cd4 100644
--- a/internal/pkg/onuadaptercore/onu_device_db.go
+++ b/internal/pkg/onuadaptercore/onu_device_db.go
@@ -24,7 +24,7 @@
"sort"
me "github.com/opencord/omci-lib-go/generated"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
)
type meDbMap map[me.ClassID]map[uint16]me.AttributeValueMap
@@ -38,7 +38,7 @@
//newOnuDeviceDB returns a new instance for a specific ONU_Device_Entry
func newOnuDeviceDB(ctx context.Context, aPOnuDeviceEntry *OnuDeviceEntry) *onuDeviceDB {
- logger.Debugw("Init OnuDeviceDB for:", log.Fields{"device-id": aPOnuDeviceEntry.deviceID})
+ logger.Debugw(ctx, "Init OnuDeviceDB for:", log.Fields{"device-id": aPOnuDeviceEntry.deviceID})
var onuDeviceDB onuDeviceDB
onuDeviceDB.ctx = ctx
onuDeviceDB.pOnuDeviceEntry = aPOnuDeviceEntry
@@ -47,17 +47,17 @@
return &onuDeviceDB
}
-func (onuDeviceDB *onuDeviceDB) PutMe(meClassID me.ClassID, meEntityID uint16, meAttributes me.AttributeValueMap) {
+func (onuDeviceDB *onuDeviceDB) PutMe(ctx context.Context, meClassID me.ClassID, meEntityID uint16, meAttributes me.AttributeValueMap) {
//filter out the OnuData
if me.OnuDataClassID == meClassID {
return
}
- //logger.Debugw("Search for key data :", log.Fields{"deviceId": onuDeviceDB.pOnuDeviceEntry.deviceID, "meClassID": meClassID, "meEntityID": meEntityID})
+ //logger.Debugw(ctx,"Search for key data :", log.Fields{"deviceId": onuDeviceDB.pOnuDeviceEntry.deviceID, "meClassID": meClassID, "meEntityID": meEntityID})
meInstMap, ok := onuDeviceDB.meDb[meClassID]
if !ok {
- logger.Debugw("meClassID not found - add to db :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+ logger.Debugw(ctx, "meClassID not found - add to db :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
meInstMap = make(map[uint16]me.AttributeValueMap)
onuDeviceDB.meDb[meClassID] = meInstMap
onuDeviceDB.meDb[meClassID][meEntityID] = meAttributes
@@ -65,19 +65,19 @@
meAttribs, ok := meInstMap[meEntityID]
if !ok {
/* verbose logging, avoid in >= debug level
- logger.Debugw("meEntityId not found - add to db :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+ logger.Debugw(ctx,"meEntityId not found - add to db :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
*/
meInstMap[meEntityID] = meAttributes
} else {
/* verbose logging, avoid in >= debug level
- logger.Debugw("ME-Instance exists already: merge attribute data :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID, "meAttribs": meAttribs})
+ logger.Debugw(ctx,"ME-Instance exists already: merge attribute data :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID, "meAttribs": meAttribs})
*/
for k, v := range meAttributes {
meAttribs[k] = v
}
meInstMap[meEntityID] = meAttribs
/* verbose logging, avoid in >= debug level
- logger.Debugw("ME-Instance updated :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID, "meAttribs": meAttribs})
+ logger.Debugw(ctx,"ME-Instance updated :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID, "meAttribs": meAttribs})
*/
}
}
@@ -87,7 +87,7 @@
if meAttributes, present := onuDeviceDB.meDb[meClassID][meEntityID]; present {
/* verbose logging, avoid in >= debug level
- logger.Debugw("ME found:", log.Fields{"meClassID": meClassID, "meEntityID": meEntityID, "meAttributes": meAttributes,
+ logger.Debugw(ctx,"ME found:", log.Fields{"meClassID": meClassID, "meEntityID": meEntityID, "meAttributes": meAttributes,
"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
*/
return meAttributes
@@ -120,7 +120,7 @@
}
*/
-func (onuDeviceDB *onuDeviceDB) getSortedInstKeys(meClassID me.ClassID) []uint16 {
+func (onuDeviceDB *onuDeviceDB) getSortedInstKeys(ctx context.Context, meClassID me.ClassID) []uint16 {
var meInstKeys []uint16
@@ -129,17 +129,17 @@
for k := range meInstMap {
meInstKeys = append(meInstKeys, k)
}
- logger.Debugw("meInstKeys - input order :", log.Fields{"meInstKeys": meInstKeys}) //TODO: delete the line after test phase!
+ logger.Debugw(ctx, "meInstKeys - input order :", log.Fields{"meInstKeys": meInstKeys}) //TODO: delete the line after test phase!
sort.Slice(meInstKeys, func(i, j int) bool { return meInstKeys[i] < meInstKeys[j] })
- logger.Debugw("meInstKeys - output order :", log.Fields{"meInstKeys": meInstKeys}) //TODO: delete the line after test phase!
+ logger.Debugw(ctx, "meInstKeys - output order :", log.Fields{"meInstKeys": meInstKeys}) //TODO: delete the line after test phase!
return meInstKeys
}
-func (onuDeviceDB *onuDeviceDB) logMeDb() {
- logger.Debugw("ME instances stored for :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+func (onuDeviceDB *onuDeviceDB) logMeDb(ctx context.Context) {
+ logger.Debugw(ctx, "ME instances stored for :", log.Fields{"device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
for meClassID, meInstMap := range onuDeviceDB.meDb {
for meEntityID, meAttribs := range meInstMap {
- logger.Debugw("ME instance: ", log.Fields{"meClassID": meClassID, "meEntityID": meEntityID, "meAttribs": meAttribs, "device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
+ logger.Debugw(ctx, "ME instance: ", log.Fields{"meClassID": meClassID, "meEntityID": meEntityID, "meAttribs": meAttribs, "device-id": onuDeviceDB.pOnuDeviceEntry.deviceID})
}
}
}
diff --git a/internal/pkg/onuadaptercore/onu_device_entry.go b/internal/pkg/onuadaptercore/onu_device_entry.go
index 667b534..82963cb 100644
--- a/internal/pkg/onuadaptercore/onu_device_entry.go
+++ b/internal/pkg/onuadaptercore/onu_device_entry.go
@@ -32,15 +32,15 @@
//"time"
"github.com/looplab/fsm"
- "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
- "github.com/opencord/voltha-lib-go/v3/pkg/db"
- "github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
+ "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
+ "github.com/opencord/voltha-lib-go/v4/pkg/db"
+ "github.com/opencord/voltha-lib-go/v4/pkg/db/kvstore"
- //"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- //ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- //"github.com/opencord/voltha-protos/v3/go/openflow_13"
- //"github.com/opencord/voltha-protos/v3/go/voltha"
+ //"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
+ //ic "github.com/opencord/voltha-protos/v4/go/inter_container"
+ //"github.com/opencord/voltha-protos/v4/go/openflow_13"
+ //"github.com/opencord/voltha-protos/v4/go/voltha"
)
const (
@@ -150,7 +150,7 @@
)
type activityDescr struct {
- databaseClass func() error
+ databaseClass func(context.Context) error
//advertiseEvents bool
auditDelay uint16
//tasks map[string]func() error
@@ -178,8 +178,8 @@
}
//Start starts (logs) the omci agent
-func (oo *AdapterFsm) logFsmStateChange(e *fsm.Event) {
- logger.Debugw("FSM state change", log.Fields{"device-id": oo.deviceID, "FSM name": oo.fsmName,
+func (oo *AdapterFsm) logFsmStateChange(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "FSM state change", log.Fields{"device-id": oo.deviceID, "FSM name": oo.fsmName,
"event name": string(e.Event), "src state": string(e.Src), "dst state": string(e.Dst)})
}
@@ -244,7 +244,7 @@
activeSwVersion string
macAddress string
//lockDeviceEntries sync.RWMutex
- mibDbClass func() error
+ mibDbClass func(context.Context) error
supportedFsms OmciDeviceFsms
devState OnuDeviceEvent
// for mibUpload
@@ -263,7 +263,7 @@
//newOnuDeviceEntry returns a new instance of a OnuDeviceEntry
//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
func newOnuDeviceEntry(ctx context.Context, dh *deviceHandler) *OnuDeviceEntry {
- logger.Debugw("init-onuDeviceEntry", log.Fields{"device-id": dh.deviceID})
+ logger.Debugw(ctx, "init-onuDeviceEntry", log.Fields{"device-id": dh.deviceID})
var onuDeviceEntry OnuDeviceEntry
onuDeviceEntry.deviceID = dh.deviceID
onuDeviceEntry.baseDeviceHandler = dh
@@ -302,10 +302,10 @@
}
}
onuDeviceEntry.mibDbClass = onuDeviceEntry.supportedFsms["mib-synchronizer"].databaseClass
- logger.Debug("access2mibDbClass")
- go onuDeviceEntry.mibDbClass()
+ logger.Debug(ctx, "access2mibDbClass")
+ go onuDeviceEntry.mibDbClass(ctx)
onuDeviceEntry.mibAuditDelay = onuDeviceEntry.supportedFsms["mib-synchronizer"].auditDelay
- logger.Debugw("MibAudit is set to", log.Fields{"Delay": onuDeviceEntry.mibAuditDelay})
+ logger.Debugw(ctx, "MibAudit is set to", log.Fields{"Delay": onuDeviceEntry.mibAuditDelay})
// Omci related Mib upload sync state machine
mibUploadChan := make(chan Message, 2048)
@@ -355,21 +355,21 @@
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { onuDeviceEntry.pMibUploadFsm.logFsmStateChange(e) },
- "enter_" + ulStStarting: func(e *fsm.Event) { onuDeviceEntry.enterStartingState(e) },
- "enter_" + ulStResettingMib: func(e *fsm.Event) { onuDeviceEntry.enterResettingMibState(e) },
- "enter_" + ulStGettingVendorAndSerial: func(e *fsm.Event) { onuDeviceEntry.enterGettingVendorAndSerialState(e) },
- "enter_" + ulStGettingEquipmentID: func(e *fsm.Event) { onuDeviceEntry.enterGettingEquipmentIDState(e) },
- "enter_" + ulStGettingFirstSwVersion: func(e *fsm.Event) { onuDeviceEntry.enterGettingFirstSwVersionState(e) },
- "enter_" + ulStGettingSecondSwVersion: func(e *fsm.Event) { onuDeviceEntry.enterGettingSecondSwVersionState(e) },
- "enter_" + ulStGettingMacAddress: func(e *fsm.Event) { onuDeviceEntry.enterGettingMacAddressState(e) },
- "enter_" + ulStGettingMibTemplate: func(e *fsm.Event) { onuDeviceEntry.enterGettingMibTemplate(e) },
- "enter_" + ulStUploading: func(e *fsm.Event) { onuDeviceEntry.enterUploadingState(e) },
- "enter_" + ulStExaminingMds: func(e *fsm.Event) { onuDeviceEntry.enterExaminingMdsState(e) },
- "enter_" + ulStResynchronizing: func(e *fsm.Event) { onuDeviceEntry.enterResynchronizingState(e) },
- "enter_" + ulStAuditing: func(e *fsm.Event) { onuDeviceEntry.enterAuditingState(e) },
- "enter_" + ulStOutOfSync: func(e *fsm.Event) { onuDeviceEntry.enterOutOfSyncState(e) },
- "enter_" + ulStInSync: func(e *fsm.Event) { onuDeviceEntry.enterInSyncState(e) },
+ "enter_state": func(e *fsm.Event) { onuDeviceEntry.pMibUploadFsm.logFsmStateChange(ctx, e) },
+ "enter_" + ulStStarting: func(e *fsm.Event) { onuDeviceEntry.enterStartingState(ctx, e) },
+ "enter_" + ulStResettingMib: func(e *fsm.Event) { onuDeviceEntry.enterResettingMibState(ctx, e) },
+ "enter_" + ulStGettingVendorAndSerial: func(e *fsm.Event) { onuDeviceEntry.enterGettingVendorAndSerialState(ctx, e) },
+ "enter_" + ulStGettingEquipmentID: func(e *fsm.Event) { onuDeviceEntry.enterGettingEquipmentIDState(ctx, e) },
+ "enter_" + ulStGettingFirstSwVersion: func(e *fsm.Event) { onuDeviceEntry.enterGettingFirstSwVersionState(ctx, e) },
+ "enter_" + ulStGettingSecondSwVersion: func(e *fsm.Event) { onuDeviceEntry.enterGettingSecondSwVersionState(ctx, e) },
+ "enter_" + ulStGettingMacAddress: func(e *fsm.Event) { onuDeviceEntry.enterGettingMacAddressState(ctx, e) },
+ "enter_" + ulStGettingMibTemplate: func(e *fsm.Event) { onuDeviceEntry.enterGettingMibTemplate(ctx, e) },
+ "enter_" + ulStUploading: func(e *fsm.Event) { onuDeviceEntry.enterUploadingState(ctx, e) },
+ "enter_" + ulStExaminingMds: func(e *fsm.Event) { onuDeviceEntry.enterExaminingMdsState(ctx, e) },
+ "enter_" + ulStResynchronizing: func(e *fsm.Event) { onuDeviceEntry.enterResynchronizingState(ctx, e) },
+ "enter_" + ulStAuditing: func(e *fsm.Event) { onuDeviceEntry.enterAuditingState(ctx, e) },
+ "enter_" + ulStOutOfSync: func(e *fsm.Event) { onuDeviceEntry.enterOutOfSyncState(ctx, e) },
+ "enter_" + ulStInSync: func(e *fsm.Event) { onuDeviceEntry.enterInSyncState(ctx, e) },
},
)
// Omci related Mib download state machine
@@ -400,31 +400,31 @@
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { onuDeviceEntry.pMibDownloadFsm.logFsmStateChange(e) },
- "enter_" + dlStStarting: func(e *fsm.Event) { onuDeviceEntry.enterDLStartingState(e) },
- "enter_" + dlStCreatingGal: func(e *fsm.Event) { onuDeviceEntry.enterCreatingGalState(e) },
- "enter_" + dlStSettingOnu2g: func(e *fsm.Event) { onuDeviceEntry.enterSettingOnu2gState(e) },
- "enter_" + dlStBridgeInit: func(e *fsm.Event) { onuDeviceEntry.enterBridgeInitState(e) },
- "enter_" + dlStDownloaded: func(e *fsm.Event) { onuDeviceEntry.enterDownloadedState(e) },
- "enter_" + dlStResetting: func(e *fsm.Event) { onuDeviceEntry.enterResettingState(e) },
+ "enter_state": func(e *fsm.Event) { onuDeviceEntry.pMibDownloadFsm.logFsmStateChange(ctx, e) },
+ "enter_" + dlStStarting: func(e *fsm.Event) { onuDeviceEntry.enterDLStartingState(ctx, e) },
+ "enter_" + dlStCreatingGal: func(e *fsm.Event) { onuDeviceEntry.enterCreatingGalState(ctx, e) },
+ "enter_" + dlStSettingOnu2g: func(e *fsm.Event) { onuDeviceEntry.enterSettingOnu2gState(ctx, e) },
+ "enter_" + dlStBridgeInit: func(e *fsm.Event) { onuDeviceEntry.enterBridgeInitState(ctx, e) },
+ "enter_" + dlStDownloaded: func(e *fsm.Event) { onuDeviceEntry.enterDownloadedState(ctx, e) },
+ "enter_" + dlStResetting: func(e *fsm.Event) { onuDeviceEntry.enterResettingState(ctx, e) },
},
)
if onuDeviceEntry.pMibDownloadFsm == nil || onuDeviceEntry.pMibDownloadFsm.pFsm == nil {
- logger.Errorw("MibDownloadFsm could not be instantiated", log.Fields{"device-id": dh.deviceID})
+ logger.Errorw(ctx, "MibDownloadFsm could not be instantiated", log.Fields{"device-id": dh.deviceID})
// TODO some specifc error treatment - or waiting for crash ?
}
- onuDeviceEntry.mibTemplateKVStore = onuDeviceEntry.baseDeviceHandler.setBackend(cBasePathMibTemplateKvStore)
+ onuDeviceEntry.mibTemplateKVStore = onuDeviceEntry.baseDeviceHandler.setBackend(ctx, cBasePathMibTemplateKvStore)
if onuDeviceEntry.mibTemplateKVStore == nil {
- logger.Errorw("Can't access mibTemplateKVStore - no backend connection to service",
+ logger.Errorw(ctx, "Can't access mibTemplateKVStore - no backend connection to service",
log.Fields{"device-id": dh.deviceID, "service": cBasePathMibTemplateKvStore})
}
onuDeviceEntry.onuKVStorePath = onuDeviceEntry.deviceID
baseKvStorePath := fmt.Sprintf(cBasePathOnuKVStore, dh.pOpenOnuAc.cm.Backend.PathPrefix)
- onuDeviceEntry.onuKVStore = onuDeviceEntry.baseDeviceHandler.setBackend(baseKvStorePath)
+ onuDeviceEntry.onuKVStore = onuDeviceEntry.baseDeviceHandler.setBackend(ctx, baseKvStorePath)
if onuDeviceEntry.onuKVStore == nil {
- logger.Errorw("Can't access onuKVStore - no backend connection to service",
+ logger.Errorw(ctx, "Can't access onuKVStore - no backend connection to service",
log.Fields{"device-id": dh.deviceID, "service": baseKvStorePath})
}
@@ -436,12 +436,12 @@
//start starts (logs) the omci agent
func (oo *OnuDeviceEntry) start(ctx context.Context) error {
- logger.Debugw("OnuDeviceEntry-starting", log.Fields{"for device-id": oo.deviceID})
+ logger.Debugw(ctx, "OnuDeviceEntry-starting", log.Fields{"for device-id": oo.deviceID})
if oo.PDevOmciCC == nil {
oo.PDevOmciCC = newOmciCC(ctx, oo, oo.deviceID, oo.baseDeviceHandler,
oo.coreProxy, oo.adapterProxy)
if oo.PDevOmciCC == nil {
- logger.Errorw("Could not create devOmciCc - abort", log.Fields{"for device-id": oo.deviceID})
+ logger.Errorw(ctx, "Could not create devOmciCc - abort", log.Fields{"for device-id": oo.deviceID})
return fmt.Errorf("could not create devOmciCc %s", oo.deviceID)
}
}
@@ -450,7 +450,7 @@
//stop stops/resets the omciCC
func (oo *OnuDeviceEntry) stop(ctx context.Context, abResetOmciCC bool) error {
- logger.Debugw("OnuDeviceEntry-stopping", log.Fields{"for device-id": oo.deviceID})
+ logger.Debugw(ctx, "OnuDeviceEntry-stopping", log.Fields{"for device-id": oo.deviceID})
if abResetOmciCC && (oo.PDevOmciCC != nil) {
_ = oo.PDevOmciCC.stop(ctx)
}
@@ -460,20 +460,20 @@
}
func (oo *OnuDeviceEntry) reboot(ctx context.Context) error {
- logger.Debugw("OnuDeviceEntry-rebooting", log.Fields{"for device-id": oo.deviceID})
+ logger.Debugw(ctx, "OnuDeviceEntry-rebooting", log.Fields{"for device-id": oo.deviceID})
if oo.PDevOmciCC != nil {
if err := oo.PDevOmciCC.sendReboot(ctx, ConstDefaultOmciTimeout, true, oo.omciRebootMessageReceivedChannel); err != nil {
- logger.Errorw("onu didn't reboot", log.Fields{"for device-id": oo.deviceID})
+ logger.Errorw(ctx, "onu didn't reboot", log.Fields{"for device-id": oo.deviceID})
return err
}
}
return nil
}
-func (oo *OnuDeviceEntry) waitForRebootResponse(responseChannel chan Message) error {
+func (oo *OnuDeviceEntry) waitForRebootResponse(ctx context.Context, responseChannel chan Message) error {
select {
case <-time.After(3 * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
- logger.Warnw("Reboot timeout", log.Fields{"for device-id": oo.deviceID})
+ logger.Warnw(ctx, "Reboot timeout", log.Fields{"for device-id": oo.deviceID})
return fmt.Errorf("rebootTimeout")
case data := <-responseChannel:
switch data.Data.(OmciMessage).OmciMsg.MessageType {
@@ -487,9 +487,9 @@
if !msgOk {
return fmt.Errorf("omci Msg layer could not be assigned for RebootResponseType %s", oo.deviceID)
}
- logger.Debugw("RebootResponse data", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "RebootResponse data", log.Fields{"device-id": oo.deviceID, "data-fields": msgObj})
if msgObj.Result != me.Success {
- logger.Errorw("Omci RebootResponse result error", log.Fields{"device-id": oo.deviceID, "Error": msgObj.Result})
+ logger.Errorw(ctx, "Omci RebootResponse result error", log.Fields{"device-id": oo.deviceID, "Error": msgObj.Result})
// possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
return fmt.Errorf("omci RebootResponse result error indication %s for device %s",
msgObj.Result, oo.deviceID)
@@ -497,61 +497,61 @@
return nil
}
}
- logger.Warnw("Reboot response message type error", log.Fields{"for device-id": oo.deviceID})
+ logger.Warnw(ctx, "Reboot response message type error", log.Fields{"for device-id": oo.deviceID})
return fmt.Errorf("unexpected OmciResponse type received %s", oo.deviceID)
}
}
//Relay the InSync message via Handler to Rw core - Status update
-func (oo *OnuDeviceEntry) transferSystemEvent(devEvent OnuDeviceEvent) {
- logger.Debugw("relaying system-event", log.Fields{"Event": devEvent})
+func (oo *OnuDeviceEntry) transferSystemEvent(ctx context.Context, devEvent OnuDeviceEvent) {
+ logger.Debugw(ctx, "relaying system-event", log.Fields{"Event": devEvent})
// decouple the handler transfer from further processing here
// TODO!!! check if really no synch is required within the system e.g. to ensure following steps ..
if devEvent == MibDatabaseSync {
if oo.devState < MibDatabaseSync { //devState has not been synced yet
oo.devState = MibDatabaseSync
- go oo.baseDeviceHandler.deviceProcStatusUpdate(devEvent)
+ go oo.baseDeviceHandler.deviceProcStatusUpdate(ctx, devEvent)
//TODO!!! device control: next step: start MIB capability verification from here ?!!!
} else {
- logger.Debugw("mibinsync-event in some already synced state - ignored", log.Fields{"state": oo.devState})
+ logger.Debugw(ctx, "mibinsync-event in some already synced state - ignored", log.Fields{"state": oo.devState})
}
} else if devEvent == MibDownloadDone {
if oo.devState < MibDownloadDone { //devState has not been synced yet
oo.devState = MibDownloadDone
- go oo.baseDeviceHandler.deviceProcStatusUpdate(devEvent)
+ go oo.baseDeviceHandler.deviceProcStatusUpdate(ctx, devEvent)
} else {
- logger.Debugw("mibdownloaddone-event was already seen - ignored", log.Fields{"state": oo.devState})
+ logger.Debugw(ctx, "mibdownloaddone-event was already seen - ignored", log.Fields{"state": oo.devState})
}
} else {
- logger.Warnw("device-event not yet handled", log.Fields{"state": devEvent})
+ logger.Warnw(ctx, "device-event not yet handled", log.Fields{"state": devEvent})
}
}
func (oo *OnuDeviceEntry) restoreDataFromOnuKvStore(ctx context.Context) error {
if oo.onuKVStore == nil {
- logger.Debugw("onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
+ logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
return fmt.Errorf(fmt.Sprintf("onuKVStore-not-set-abort-%s", oo.deviceID))
}
oo.sOnuPersistentData = onuPersistentData{0, 0, "", "", "", false, false, make([]uniPersConfig, 0)}
Value, err := oo.onuKVStore.Get(ctx, oo.onuKVStorePath)
if err == nil {
if Value != nil {
- logger.Debugw("ONU-data read",
+ logger.Debugw(ctx, "ONU-data read",
log.Fields{"Key": Value.Key, "device-id": oo.deviceID})
tmpBytes, _ := kvstore.ToByte(Value.Value)
if err = json.Unmarshal(tmpBytes, &oo.sOnuPersistentData); err != nil {
- logger.Errorw("unable to unmarshal ONU-data", log.Fields{"error": err, "device-id": oo.deviceID})
+ logger.Errorw(ctx, "unable to unmarshal ONU-data", log.Fields{"error": err, "device-id": oo.deviceID})
return fmt.Errorf(fmt.Sprintf("unable-to-unmarshal-ONU-data-%s", oo.deviceID))
}
- logger.Debugw("ONU-data", log.Fields{"sOnuPersistentData": oo.sOnuPersistentData,
+ logger.Debugw(ctx, "ONU-data", log.Fields{"sOnuPersistentData": oo.sOnuPersistentData,
"device-id": oo.deviceID})
} else {
- logger.Debugw("no ONU-data found", log.Fields{"path": oo.onuKVStorePath, "device-id": oo.deviceID})
+ logger.Debugw(ctx, "no ONU-data found", log.Fields{"path": oo.onuKVStorePath, "device-id": oo.deviceID})
return fmt.Errorf("no-ONU-data-found")
}
} else {
- logger.Errorw("unable to read from KVstore", log.Fields{"device-id": oo.deviceID})
+ logger.Errorw(ctx, "unable to read from KVstore", log.Fields{"device-id": oo.deviceID})
return fmt.Errorf(fmt.Sprintf("unable-to-read-from-KVstore-%s", oo.deviceID))
}
return nil
@@ -561,7 +561,7 @@
defer wg.Done()
if oo.onuKVStore == nil {
- logger.Debugw("onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
+ logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
oo.onuKVStoreprocResult = errors.New("onu-data delete aborted: onuKVStore not set")
return
}
@@ -569,7 +569,7 @@
go oo.deletePersistentData(ctx, processingStep)
if !oo.waitForTimeoutOrCompletion(ctx, oo.chOnuKvProcessingStep, processingStep) {
//timeout or error detected
- logger.Debugw("ONU-data not deleted - abort", log.Fields{"device-id": oo.deviceID})
+ logger.Debugw(ctx, "ONU-data not deleted - abort", log.Fields{"device-id": oo.deviceID})
oo.onuKVStoreprocResult = errors.New("onu-data delete aborted: during kv-access")
return
}
@@ -577,14 +577,14 @@
func (oo *OnuDeviceEntry) deletePersistentData(ctx context.Context, aProcessingStep uint8) {
- logger.Debugw("delete and clear internal persistency data", log.Fields{"device-id": oo.deviceID})
+ logger.Debugw(ctx, "delete and clear internal persistency data", log.Fields{"device-id": oo.deviceID})
oo.sOnuPersistentData.PersUniConfig = nil //releasing all UniConfig entries to garbage collector
oo.sOnuPersistentData = onuPersistentData{0, 0, "", "", "", false, false, make([]uniPersConfig, 0)} //default entry
- logger.Debugw("delete ONU-data from KVStore", log.Fields{"device-id": oo.deviceID})
+ logger.Debugw(ctx, "delete ONU-data from KVStore", log.Fields{"device-id": oo.deviceID})
err := oo.onuKVStore.Delete(ctx, oo.onuKVStorePath)
if err != nil {
- logger.Errorw("unable to delete in KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
+ logger.Errorw(ctx, "unable to delete in KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
oo.chOnuKvProcessingStep <- 0 //error indication
return
}
@@ -595,7 +595,7 @@
defer wg.Done()
if oo.onuKVStore == nil {
- logger.Debugw("onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
+ logger.Debugw(ctx, "onuKVStore not set - abort", log.Fields{"device-id": oo.deviceID})
oo.onuKVStoreprocResult = errors.New("onu-data update aborted: onuKVStore not set")
return
}
@@ -603,7 +603,7 @@
go oo.storeDataInOnuKvStore(ctx, processingStep)
if !oo.waitForTimeoutOrCompletion(ctx, oo.chOnuKvProcessingStep, processingStep) {
//timeout or error detected
- logger.Debugw("ONU-data not written - abort", log.Fields{"device-id": oo.deviceID})
+ logger.Debugw(ctx, "ONU-data not written - abort", log.Fields{"device-id": oo.deviceID})
oo.onuKVStoreprocResult = errors.New("onu-data update aborted: during writing process")
return
}
@@ -618,44 +618,44 @@
//TODO: verify usage of these values during restart UC
oo.sOnuPersistentData.PersAdminState = oo.baseDeviceHandler.pOnuIndication.AdminState
oo.sOnuPersistentData.PersOperState = oo.baseDeviceHandler.pOnuIndication.OperState
- logger.Debugw("Update ONU-data in KVStore", log.Fields{"device-id": oo.deviceID, "sOnuPersistentData": oo.sOnuPersistentData})
+ logger.Debugw(ctx, "Update ONU-data in KVStore", log.Fields{"device-id": oo.deviceID, "sOnuPersistentData": oo.sOnuPersistentData})
Value, err := json.Marshal(oo.sOnuPersistentData)
if err != nil {
- logger.Errorw("unable to marshal ONU-data", log.Fields{"sOnuPersistentData": oo.sOnuPersistentData,
+ logger.Errorw(ctx, "unable to marshal ONU-data", log.Fields{"sOnuPersistentData": oo.sOnuPersistentData,
"device-id": oo.deviceID, "err": err})
oo.chOnuKvProcessingStep <- 0 //error indication
return
}
err = oo.onuKVStore.Put(ctx, oo.onuKVStorePath, Value)
if err != nil {
- logger.Errorw("unable to write ONU-data into KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
+ logger.Errorw(ctx, "unable to write ONU-data into KVstore", log.Fields{"device-id": oo.deviceID, "err": err})
oo.chOnuKvProcessingStep <- 0 //error indication
return
}
oo.chOnuKvProcessingStep <- aProcessingStep //done
}
-func (oo *OnuDeviceEntry) updateOnuUniTpPath(aUniID uint8, aTpID uint8, aPathString string) bool {
+func (oo *OnuDeviceEntry) updateOnuUniTpPath(ctx context.Context, aUniID uint8, aTpID uint8, aPathString string) bool {
/* within some specific InterAdapter processing request write/read access to data is ensured to be sequentially,
as also the complete sequence is ensured to 'run to completion' before some new request is accepted
no specific concurrency protection to sOnuPersistentData is required here
*/
for k, v := range oo.sOnuPersistentData.PersUniConfig {
if v.PersUniID == aUniID {
- logger.Debugw("PersUniConfig-entry already exists", log.Fields{"device-id": oo.deviceID, "uniID": aUniID})
+ logger.Debugw(ctx, "PersUniConfig-entry already exists", log.Fields{"device-id": oo.deviceID, "uniID": aUniID})
existingPath, ok := oo.sOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID]
if !ok {
- logger.Debugw("tp-does-not-exist--to-be-created-afresh", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "tpID": aTpID, "path": aPathString})
+ logger.Debugw(ctx, "tp-does-not-exist--to-be-created-afresh", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "tpID": aTpID, "path": aPathString})
}
if existingPath != aPathString {
if aPathString == "" {
//existing entry to be deleted
- logger.Debugw("UniTp delete path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
+ logger.Debugw(ctx, "UniTp delete path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
oo.sOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID] = ""
} else {
//existing entry to be modified
- logger.Debugw("UniTp modify path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
+ logger.Debugw(ctx, "UniTp modify path value", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
oo.sOnuPersistentData.PersUniConfig[k].PersTpPathMap[aTpID] = aPathString
}
return true
@@ -663,18 +663,18 @@
//entry already exists
if aPathString == "" {
//no active TechProfile
- logger.Debugw("UniTp path has already been removed - no AniSide config to be removed", log.Fields{
+ logger.Debugw(ctx, "UniTp path has already been removed - no AniSide config to be removed", log.Fields{
"device-id": oo.deviceID, "uniID": aUniID})
// attention 201105: this block is at the moment entered for each of subsequent GemPortDeletes and TContDelete
// as the path is already cleared with the first GemPort - this will probably change with the upcoming real
// TechProfile removal (still TODO), but anyway the reasonUpdate initiated here should not harm overall behavior
- go oo.baseDeviceHandler.deviceProcStatusUpdate(OmciAniResourceRemoved)
+ go oo.baseDeviceHandler.deviceProcStatusUpdate(ctx, OmciAniResourceRemoved)
// no flow config pending on 'remove' so far
} else {
//the given TechProfile already exists and is assumed to be active - update devReason as if the config has been done here
//was needed e.g. in voltha POD Tests:Validate authentication on a disabled ONU
// (as here the TechProfile has not been removed with the disable-device before the new enable-device)
- logger.Debugw("UniTp path already exists - TechProfile supposed to be active", log.Fields{
+ logger.Debugw(ctx, "UniTp path already exists - TechProfile supposed to be active", log.Fields{
"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
//no deviceReason update (deviceProcStatusUpdate) here to ensure 'omci_flows_pushed' state within disable/enable procedure of ATT scenario
// (during which the flows are removed/re-assigned but the techProf is left active)
@@ -685,7 +685,7 @@
if oo.baseDeviceHandler.pOnuTP != nil {
oo.baseDeviceHandler.pOnuTP.setProfileToDelete(aUniID, aTpID, false)
}
- go oo.baseDeviceHandler.VerifyVlanConfigRequest(aUniID)
+ go oo.baseDeviceHandler.VerifyVlanConfigRequest(ctx, aUniID)
}
return false //indicate 'no change' - nothing more to do, TechProf inter-adapter message is return with success anyway here
}
@@ -694,11 +694,11 @@
if aPathString == "" {
//delete request in non-existing state , accept as no change
- logger.Debugw("UniTp path already removed", log.Fields{"device-id": oo.deviceID, "uniID": aUniID})
+ logger.Debugw(ctx, "UniTp path already removed", log.Fields{"device-id": oo.deviceID, "uniID": aUniID})
return false
}
//new entry to be created
- logger.Debugw("New UniTp path set", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
+ logger.Debugw(ctx, "New UniTp path set", log.Fields{"device-id": oo.deviceID, "uniID": aUniID, "path": aPathString})
perSubTpPathMap := make(map[uint8]string)
perSubTpPathMap[aTpID] = aPathString
oo.sOnuPersistentData.PersUniConfig =
@@ -725,7 +725,7 @@
ctx context.Context, aChOnuProcessingStep <-chan uint8, aProcessingStep uint8) bool {
select {
case <-ctx.Done():
- logger.Warnw("processing not completed in-time!",
+ logger.Warnw(ctx, "processing not completed in-time!",
log.Fields{"device-id": oo.deviceID, "error": ctx.Err()})
return false
case rxStep := <-aChOnuProcessingStep:
@@ -733,7 +733,7 @@
return true
}
//all other values are not accepted - including 0 for error indication
- logger.Warnw("Invalid processing step received: abort!",
+ logger.Warnw(ctx, "Invalid processing step received: abort!",
log.Fields{"device-id": oo.deviceID,
"wantedStep": aProcessingStep, "haveStep": rxStep})
return false
diff --git a/internal/pkg/onuadaptercore/onu_uni_port.go b/internal/pkg/onuadaptercore/onu_uni_port.go
index 8bc029d..ea8f2c5 100644
--- a/internal/pkg/onuadaptercore/onu_uni_port.go
+++ b/internal/pkg/onuadaptercore/onu_uni_port.go
@@ -26,11 +26,11 @@
//"sync"
//"time"
- //"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- vc "github.com/opencord/voltha-protos/v3/go/common"
- of "github.com/opencord/voltha-protos/v3/go/openflow_13"
- "github.com/opencord/voltha-protos/v3/go/voltha"
+ //"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
+ vc "github.com/opencord/voltha-protos/v4/go/common"
+ of "github.com/opencord/voltha-protos/v4/go/openflow_13"
+ "github.com/opencord/voltha-protos/v4/go/voltha"
)
type uniPortType uint8
@@ -59,9 +59,9 @@
}
//newOnuUniPort returns a new instance of a OnuUniPort
-func newOnuUniPort(aUniID uint8, aPortNo uint32, aInstNo uint16,
+func newOnuUniPort(ctx context.Context, aUniID uint8, aPortNo uint32, aInstNo uint16,
aPortType uniPortType) *onuUniPort {
- logger.Infow("init-onuUniPort", log.Fields{"uniID": aUniID,
+ logger.Infow(ctx, "init-onuUniPort", log.Fields{"uniID": aUniID,
"portNo": aPortNo, "InstNo": aInstNo, "type": aPortType})
var onuUniPort onuUniPort
onuUniPort.enabled = false
@@ -80,8 +80,8 @@
}
//createVolthaPort creates the Voltha port based on ONU UNI Port and informs the core about it
-func (oo *onuUniPort) createVolthaPort(apDeviceHandler *deviceHandler) error {
- logger.Debugw("creating-voltha-uni-port", log.Fields{
+func (oo *onuUniPort) createVolthaPort(ctx context.Context, apDeviceHandler *deviceHandler) error {
+ logger.Debugw(ctx, "creating-voltha-uni-port", log.Fields{
"device-id": apDeviceHandler.device.Id, "portNo": oo.portNo})
//200630: per [VOL-3202] OF port info is now to be delivered within UniPort create
// not doing so crashes rw_core processing (at least still in 200630 version)
@@ -106,7 +106,7 @@
ofUniPortState = of.OfpPortState_OFPPS_LIVE
}
*/
- logger.Debugw("ofPort values", log.Fields{
+ logger.Debugw(ctx, "ofPort values", log.Fields{
"forUniPortName": oo.name, "forMacBase": hwAddr,
"name": name, "hwAddr": ofHwAddr, "OperState": ofUniPortState})
@@ -130,17 +130,17 @@
},
}
if pUniPort != nil {
- if err := apDeviceHandler.coreProxy.PortCreated(context.TODO(),
+ if err := apDeviceHandler.coreProxy.PortCreated(log.WithSpanFromContext(context.TODO(), ctx),
apDeviceHandler.deviceID, pUniPort); err != nil {
- logger.Fatalf("adding-uni-port: create-VOLTHA-Port-failed-%s", err)
+ logger.Fatalf(ctx, "adding-uni-port: create-VOLTHA-Port-failed-%s", err)
return err
}
- logger.Infow("Voltha onuUniPort-added", log.Fields{
+ logger.Infow(ctx, "Voltha onuUniPort-added", log.Fields{
"device-id": apDeviceHandler.device.Id, "PortNo": oo.portNo})
oo.pPort = pUniPort
oo.operState = vc.OperStatus_DISCOVERED
} else {
- logger.Warnw("could not create Voltha UniPort", log.Fields{
+ logger.Warnw(ctx, "could not create Voltha UniPort", log.Fields{
"device-id": apDeviceHandler.device.Id, "PortNo": oo.portNo})
return fmt.Errorf("create Voltha UniPort %d failed on %s", oo.portNo, apDeviceHandler.device.Id)
}
diff --git a/internal/pkg/onuadaptercore/onu_uni_tp.go b/internal/pkg/onuadaptercore/onu_uni_tp.go
index 2be93b9..1272c0c 100644
--- a/internal/pkg/onuadaptercore/onu_uni_tp.go
+++ b/internal/pkg/onuadaptercore/onu_uni_tp.go
@@ -26,10 +26,10 @@
"strings"
"sync"
- "github.com/opencord/voltha-lib-go/v3/pkg/db"
- "github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- tp "github.com/opencord/voltha-lib-go/v3/pkg/techprofile"
+ "github.com/opencord/voltha-lib-go/v4/pkg/db"
+ "github.com/opencord/voltha-lib-go/v4/pkg/db/kvstore"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
+ tp "github.com/opencord/voltha-lib-go/v4/pkg/techprofile"
)
const cBasePathTechProfileKVStore = "%s/technology_profiles"
@@ -112,7 +112,7 @@
//newOnuUniTechProf returns the instance of a OnuUniTechProf
//(one instance per ONU/deviceHandler for all possible UNI's)
func newOnuUniTechProf(ctx context.Context, aDeviceHandler *deviceHandler) *onuUniTechProf {
- logger.Debugw("init-OnuUniTechProf", log.Fields{"device-id": aDeviceHandler.deviceID})
+ logger.Debugw(ctx, "init-OnuUniTechProf", log.Fields{"device-id": aDeviceHandler.deviceID})
var onuTP onuUniTechProf
onuTP.baseDeviceHandler = aDeviceHandler
onuTP.deviceID = aDeviceHandler.deviceID
@@ -124,9 +124,9 @@
onuTP.tpProfileExists = make(map[uniTP]bool)
onuTP.mapRemoveGemEntry = make(map[uniTP]*gemPortParamStruct)
baseKvStorePath := fmt.Sprintf(cBasePathTechProfileKVStore, aDeviceHandler.pOpenOnuAc.cm.Backend.PathPrefix)
- onuTP.techProfileKVStore = aDeviceHandler.setBackend(baseKvStorePath)
+ onuTP.techProfileKVStore = aDeviceHandler.setBackend(ctx, baseKvStorePath)
if onuTP.techProfileKVStore == nil {
- logger.Errorw("Can't access techProfileKVStore - no backend connection to service",
+ logger.Errorw(ctx, "Can't access techProfileKVStore - no backend connection to service",
log.Fields{"device-id": aDeviceHandler.deviceID, "service": baseKvStorePath})
}
@@ -160,16 +160,16 @@
func (onuTP *onuUniTechProf) configureUniTp(ctx context.Context,
aUniID uint8, aPathString string, wg *sync.WaitGroup) {
defer wg.Done() //always decrement the waitGroup on return
- logger.Debugw("configure the Uni according to TpPath", log.Fields{
+ logger.Debugw(ctx, "configure the Uni according to TpPath", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString})
tpID, err := GetTpIDFromTpPath(aPathString)
uniTpKey := uniTP{uniID: aUniID, tpID: tpID}
if err != nil {
- logger.Errorw("error-extracting-tp-id-from-tp-path", log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString})
+ logger.Errorw(ctx, "error-extracting-tp-id-from-tp-path", log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString})
return
}
if onuTP.techProfileKVStore == nil {
- logger.Errorw("techProfileKVStore not set - abort",
+ logger.Errorw(ctx, "techProfileKVStore not set - abort",
log.Fields{"device-id": onuTP.deviceID})
onuTP.procResult[uniTpKey] = errors.New("techProfile config aborted: techProfileKVStore not set")
return
@@ -185,7 +185,7 @@
}
}
if pCurrentUniPort == nil {
- logger.Errorw("TechProfile configuration aborted: requested uniID not found in PortDB",
+ logger.Errorw(ctx, "TechProfile configuration aborted: requested uniID not found in PortDB",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID})
onuTP.procResult[uniTpKey] = fmt.Errorf("techProfile config aborted: requested uniID not found %d on %s",
aUniID, onuTP.deviceID)
@@ -220,7 +220,7 @@
// and abort the processing here
return
}
- logger.Errorw("tech-profile related configuration aborted on read",
+ logger.Errorw(ctx, "tech-profile related configuration aborted on read",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID})
onuTP.procResult[uniTpKey] = fmt.Errorf("techProfile config aborted: tech-profile read issue for %d on %s",
aUniID, onuTP.deviceID)
@@ -235,14 +235,14 @@
if valuePA != nil {
//Config data for this uni and and at least TCont Index 0 exist
if err := onuTP.setAniSideConfigFromTechProfile(ctx, aUniID, tpID, pCurrentUniPort, processingStep); err != nil {
- logger.Errorw("tech-profile related FSM could not be started",
+ logger.Errorw(ctx, "tech-profile related FSM could not be started",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID})
onuTP.procResult[uniTpKey] = err
return
}
if !onuTP.waitForTimeoutOrCompletion(ctx, onuTP.chTpConfigProcessingStep, processingStep) {
//timeout or error detected
- logger.Errorw("tech-profile related configuration aborted on set",
+ logger.Errorw(ctx, "tech-profile related configuration aborted on set",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID})
onuTP.procResult[uniTpKey] = fmt.Errorf("techProfile config aborted: Omci AniSideConfig failed %d on %s",
@@ -255,7 +255,7 @@
}
} else {
// strange: UNI entry exists, but no ANI data, maybe such situation should be cleared up (if observed)
- logger.Errorw("no Tcont/Gem data for this UNI found - abort", log.Fields{
+ logger.Errorw(ctx, "no Tcont/Gem data for this UNI found - abort", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID})
onuTP.procResult[uniTpKey] = fmt.Errorf("techProfile config aborted: no Tcont/Gem data found for this UNI %d on %s",
@@ -263,7 +263,7 @@
return
}
} else {
- logger.Errorw("no PonAni data for this UNI found - abort", log.Fields{
+ logger.Errorw(ctx, "no PonAni data for this UNI found - abort", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID})
onuTP.procResult[uniTpKey] = fmt.Errorf("techProfile config aborted: no AniSide data found for this UNI %d on %s",
@@ -286,7 +286,7 @@
//pathstring is defined to be in the form of <ProfType>/<profID>/<Interface/../Identifier>
subStringSlice := strings.Split(aPathString, "/")
if len(subStringSlice) <= 2 {
- logger.Errorw("invalid path name format",
+ logger.Errorw(ctx, "invalid path name format",
log.Fields{"path": aPathString, "device-id": onuTP.deviceID})
onuTP.chTpConfigProcessingStep <- 0 //error indication
return
@@ -299,13 +299,13 @@
// if TPId has changed, current data is removed (note that the ONU config state may be
// ambivalent in such a case)
if _, existTP := onuTP.mapUniTpIndication[uniTPKey]; existTP {
- logger.Warnw("Some active profile entry at reading new TechProfile",
+ logger.Warnw(ctx, "Some active profile entry at reading new TechProfile",
log.Fields{"path": aPathString, "device-id": onuTP.deviceID,
"uni-id": aUniID, "wrongProfile": onuTP.mapUniTpIndication[uniTPKey].techProfileID})
if aTpID == onuTP.mapUniTpIndication[uniTPKey].techProfileID {
// ProfId not changed - assume profile to be still the same
// anyway this should not appear after full support of profile (Gem/TCont) removal
- logger.Warnw("New TechProfile already exists - aborting configuration",
+ logger.Warnw(ctx, "New TechProfile already exists - aborting configuration",
log.Fields{"device-id": onuTP.deviceID})
onuTP.tpProfileExists[uniTPKey] = true
onuTP.chTpConfigProcessingStep <- 0 //error indication
@@ -324,7 +324,7 @@
onuTP.mapUniTpIndication[uniTPKey].techProfileID = aTpID
onuTP.mapUniTpIndication[uniTPKey].techProfileConfigDone = false
onuTP.mapUniTpIndication[uniTPKey].techProfileToDelete = false
- logger.Debugw("tech-profile path indications",
+ logger.Debugw(ctx, "tech-profile path indications",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID,
"profType": onuTP.mapUniTpIndication[uniTPKey].techProfileType,
"profID": onuTP.mapUniTpIndication[uniTPKey].techProfileID})
@@ -332,29 +332,29 @@
Value, err := onuTP.techProfileKVStore.Get(ctx, aPathString)
if err == nil {
if Value != nil {
- logger.Debugw("tech-profile read",
+ logger.Debugw(ctx, "tech-profile read",
log.Fields{"Key": Value.Key, "device-id": onuTP.deviceID})
tpTmpBytes, _ := kvstore.ToByte(Value.Value)
if err = json.Unmarshal(tpTmpBytes, &tpInst); err != nil {
- logger.Errorw("TechProf - Failed to unmarshal tech-profile into tpInst",
+ logger.Errorw(ctx, "TechProf - Failed to unmarshal tech-profile into tpInst",
log.Fields{"error": err, "device-id": onuTP.deviceID})
onuTP.chTpConfigProcessingStep <- 0 //error indication
return
}
- logger.Debugw("TechProf - tpInst", log.Fields{"tpInst": tpInst})
+ logger.Debugw(ctx, "TechProf - tpInst", log.Fields{"tpInst": tpInst})
// access examples
- logger.Debugw("TechProf content", log.Fields{"Name": tpInst.Name,
+ logger.Debugw(ctx, "TechProf content", log.Fields{"Name": tpInst.Name,
"MaxGemPayloadSize": tpInst.InstanceCtrl.MaxGemPayloadSize,
"DownstreamGemDiscardmaxThreshold": tpInst.DownstreamGemPortAttributeList[0].DiscardConfig.MaxThreshold})
} else {
- logger.Errorw("No tech-profile found",
+ logger.Errorw(ctx, "No tech-profile found",
log.Fields{"path": aPathString, "device-id": onuTP.deviceID})
onuTP.chTpConfigProcessingStep <- 0 //error indication
return
}
} else {
- logger.Errorw("kvstore-get failed for path",
+ logger.Errorw(ctx, "kvstore-get failed for path",
log.Fields{"path": aPathString, "device-id": onuTP.deviceID})
onuTP.chTpConfigProcessingStep <- 0 //error indication
return
@@ -380,7 +380,7 @@
loGemPortRead := false
for pos, content := range tpInst.UpstreamGemPortAttributeList {
if uint32(pos) == loNumGemPorts {
- logger.Debugw("PonAniConfig abort GemPortList - GemList exceeds set NumberOfGemPorts",
+ logger.Debugw(ctx, "PonAniConfig abort GemPortList - GemList exceeds set NumberOfGemPorts",
log.Fields{"device-id": onuTP.deviceID, "index": pos, "NumGem": loNumGemPorts})
break
}
@@ -400,7 +400,7 @@
onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(pos)].direction = 3 //as defined in G.988
// expected Prio-Queue values 0..7 with 7 for highest PrioQueue, QueueIndex=Prio = 0..7
if content.PriorityQueue > 7 {
- logger.Errorw("PonAniConfig reject on GemPortList - PrioQueue value invalid",
+ logger.Errorw(ctx, "PonAniConfig reject on GemPortList - PrioQueue value invalid",
log.Fields{"device-id": onuTP.deviceID, "index": pos, "PrioQueue": content.PriorityQueue})
//remove PonAniConfig as done so far, delete map should be safe, even if not existing
delete(onuTP.mapPonAniConfig, uniTPKey)
@@ -426,7 +426,7 @@
}
for _, downstreamContent := range tpInst.DownstreamGemPortAttributeList {
- log.Debugw("Operating on Downstream Gem Port", log.Fields{"downstream-gem": downstreamContent})
+ logger.Debugw(ctx, "Operating on Downstream Gem Port", log.Fields{"downstream-gem": downstreamContent})
//Commenting this out due to faliure, needs investigation
//if uint32(pos) == loNumGemPorts {
// logger.Debugw("PonAniConfig abort GemPortList - GemList exceeds set NumberOfGemPorts",
@@ -438,23 +438,23 @@
if downstreamContent.IsMulticast != "" {
isMulticast, err = strconv.ParseBool(downstreamContent.IsMulticast)
if err != nil {
- logger.Errorw("multicast-error-config-unknown-flag-in-technology-profile",
+ logger.Errorw(ctx, "multicast-error-config-unknown-flag-in-technology-profile",
log.Fields{"UniTpKey": uniTPKey, "downstream-gem": downstreamContent, "error": err})
continue
}
}
- log.Infow("Gem Port is multicast", log.Fields{"isMulticast": isMulticast})
+ logger.Infow(ctx, "Gem Port is multicast", log.Fields{"isMulticast": isMulticast})
if isMulticast {
mcastGemID := uint16(downstreamContent.McastGemID)
_, existing := onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID]
if existing {
//GEM port was previously configured, avoid setting multicast attributes
- logger.Errorw("multicast-error-config-existing-gem-port-config", log.Fields{"UniTpKey": uniTPKey,
+ logger.Errorw(ctx, "multicast-error-config-existing-gem-port-config", log.Fields{"UniTpKey": uniTPKey,
"downstream-gem": downstreamContent, "key": mcastGemID})
continue
} else {
//GEM port is not configured, setting multicast attributes
- logger.Infow("creating-multicast-gem-port", log.Fields{"uniTpKey": uniTPKey,
+ logger.Infow(ctx, "creating-multicast-gem-port", log.Fields{"uniTpKey": uniTPKey,
"gemPortId": mcastGemID, "key": mcastGemID})
//for all further GemPorts we need to extend the mapGemPortParams
@@ -472,7 +472,7 @@
// expected Prio-Queue values 0..7 with 7 for highest PrioQueue, QueueIndex=Prio = 0..7
if downstreamContent.PriorityQueue > 7 {
- logger.Errorw("PonAniConfig reject on GemPortList - PrioQueue value invalid",
+ logger.Errorw(ctx, "PonAniConfig reject on GemPortList - PrioQueue value invalid",
log.Fields{"device-id": onuTP.deviceID, "index": mcastGemID, "PrioQueue": downstreamContent.PriorityQueue})
//remove PonAniConfig as done so far, delete map should be safe, even if not existing
delete(onuTP.mapPonAniConfig, uniTPKey)
@@ -502,7 +502,7 @@
}
if !loGemPortRead {
- logger.Errorw("PonAniConfig reject - no GemPort could be read from TechProfile",
+ logger.Errorw(ctx, "PonAniConfig reject - no GemPort could be read from TechProfile",
log.Fields{"path": aPathString, "device-id": onuTP.deviceID})
//remove PonAniConfig as done so far, delete map should be safe, even if not existing
delete(onuTP.mapPonAniConfig, uniTPKey)
@@ -510,11 +510,11 @@
return
}
//logger does not simply output the given structures, just give some example debug values
- logger.Debugw("PonAniConfig read from TechProfile", log.Fields{
+ logger.Debugw(ctx, "PonAniConfig read from TechProfile", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID,
"AllocId": onuTP.mapPonAniConfig[uniTPKey].tcontParams.allocID})
for gemIndex, gemEntry := range onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams {
- logger.Debugw("PonAniConfig read from TechProfile", log.Fields{
+ logger.Debugw(ctx, "PonAniConfig read from TechProfile", log.Fields{
"GemIndex": gemIndex,
"GemPort": gemEntry.gemPortID,
"QueueScheduling": gemEntry.queueSchedPolicy})
@@ -531,12 +531,12 @@
// hence we have to make sure they indicate 'success' on chTpConfigProcessingStep with aProcessingStep
uniTPKey := uniTP{uniID: aUniID, tpID: aTpID}
if onuTP.pAniConfigFsm == nil {
- return onuTP.createAniConfigFsm(aUniID, aTpID, apCurrentUniPort, OmciAniConfigDone, aProcessingStep)
+ return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, OmciAniConfigDone, aProcessingStep)
} else if _, ok := onuTP.pAniConfigFsm[uniTPKey]; !ok {
- return onuTP.createAniConfigFsm(aUniID, aTpID, apCurrentUniPort, OmciAniConfigDone, aProcessingStep)
+ return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, OmciAniConfigDone, aProcessingStep)
}
//AniConfigFsm already init
- return onuTP.runAniConfigFsm(aniEvStart, aProcessingStep, aUniID, aTpID)
+ return onuTP.runAniConfigFsm(ctx, aniEvStart, aProcessingStep, aUniID, aTpID)
}
// deleteTpResource removes Resources from the ONU's specified Uni
@@ -544,12 +544,12 @@
aUniID uint8, aTpID uint8, aPathString string, aResource resourceEntry, aEntryID uint32,
wg *sync.WaitGroup) {
defer wg.Done()
- logger.Debugw("will remove TP resources from ONU's UNI", log.Fields{
+ logger.Debugw(ctx, "will remove TP resources from ONU's UNI", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "Resource": aResource})
uniTPKey := uniTP{uniID: aUniID, tpID: aTpID}
if cResourceGemPort == aResource {
- logger.Debugw("remove GemPort from the list of existing ones of the TP", log.Fields{
+ logger.Debugw(ctx, "remove GemPort from the list of existing ones of the TP", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "GemPort": aEntryID})
// check if the requested GemPort exists in the DB, indicate it to the FSM
@@ -557,7 +557,7 @@
pLocAniConfigOnUni := onuTP.mapPonAniConfig[uniTPKey]
if pLocAniConfigOnUni == nil {
// No relevant entry exists anymore - acknowledge success
- logger.Debugw("AniConfig or GemEntry do not exists in DB", log.Fields{
+ logger.Debugw(ctx, "AniConfig or GemEntry do not exists in DB", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID})
return
}
@@ -566,13 +566,13 @@
//GemEntry to be deleted found
gemEntry.removeIndex = gemIndex //store the index for later removal
onuTP.mapRemoveGemEntry[uniTPKey] = pLocAniConfigOnUni.mapGemPortParams[gemIndex]
- logger.Debugw("Remove-GemEntry stored", log.Fields{
+ logger.Debugw(ctx, "Remove-GemEntry stored", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID, "GemIndex": gemIndex})
break //abort loop, always only one GemPort to remove
}
}
if onuTP.mapRemoveGemEntry[uniTPKey] == nil {
- logger.Errorw("GemPort removal aborted - GemPort not found",
+ logger.Errorw(ctx, "GemPort removal aborted - GemPort not found",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID, "GemPort": aEntryID})
/* Do not set some error indication to the outside system interface on delete
assume there is nothing to be deleted internally and hope a new config request will recover the situation
@@ -589,7 +589,7 @@
var processingStep uint8 = 1 // used to synchronize the different processing steps with chTpConfigProcessingStep
// hence we have to make sure they indicate 'success' on chTpConfigProcessingStep with aProcessingStep
if onuTP.pAniConfigFsm == nil {
- logger.Errorw("abort GemPort removal - no AniConfigFsm available",
+ logger.Errorw(ctx, "abort GemPort removal - no AniConfigFsm available",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID})
/* Do not set some error indication to the outside system interface on delete (see above)
onuTP.procResult[uniTpKey] = fmt.Errorf("GemPort removal aborted: no AniConfigFsm available %d on %s",
@@ -603,7 +603,7 @@
return
}
if _, ok := onuTP.pAniConfigFsm[uniTPKey]; !ok {
- logger.Errorw("abort GemPort removal - no AniConfigFsm available for this uni/tp",
+ logger.Errorw(ctx, "abort GemPort removal - no AniConfigFsm available for this uni/tp",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID})
/* Do not set some error indication to the outside system interface on delete (see above)
onuTP.procResult[uniTpKey] = fmt.Errorf("GemPort removal aborted: no AniConfigFsm available %d on %s for tpid",
@@ -616,7 +616,7 @@
delete(onuTP.mapRemoveGemEntry, uniTPKey)
return
}
- if nil != onuTP.runAniConfigFsm(aniEvRemGemiw, processingStep, aUniID, aTpID) {
+ if nil != onuTP.runAniConfigFsm(ctx, aniEvRemGemiw, processingStep, aUniID, aTpID) {
//even if the FSM invocation did not work we don't indicate a problem within procResult
//errors could exist also because there was nothing to delete - so we just accept that as 'deleted'
//TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented)
@@ -624,7 +624,7 @@
}
if !onuTP.waitForTimeoutOrCompletion(ctx, onuTP.chTpConfigProcessingStep, processingStep) {
//timeout or error detected
- logger.Errorw("GemPort removal aborted - Omci AniSideConfig failed",
+ logger.Errorw(ctx, "GemPort removal aborted - Omci AniSideConfig failed",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID})
//even if the FSM delete execution did not work we don't indicate a problem within procResult
//we should never respond to delete with error ...
@@ -636,7 +636,7 @@
return
}
} else {
- logger.Debugw("uniPonAniConfigFsm delete Gem on OMCI skipped based on device state", log.Fields{
+ logger.Debugw(ctx, "uniPonAniConfigFsm delete Gem on OMCI skipped based on device state", log.Fields{
"device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.deviceReason})
}
// remove GemPort from config DB
@@ -645,19 +645,19 @@
delete(onuTP.mapRemoveGemEntry, uniTPKey)
// deviceHandler StatusEvent (reason update) (see end of function) is only generated in case some element really was removed
} else { //if cResourceTcont == aResource {
- logger.Debugw("reset TCont with AllocId", log.Fields{
+ logger.Debugw(ctx, "reset TCont with AllocId", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "allocId": aEntryID})
// check if the TCont with the indicated AllocId exists in the DB, indicate its EntityId to the FSM
pLocAniConfigOnUni := onuTP.mapPonAniConfig[uniTPKey]
if pLocAniConfigOnUni == nil {
// No relevant entry exists anymore - acknowledge success
- logger.Debugw("AniConfig or TCont entry do not exists in DB", log.Fields{
+ logger.Debugw(ctx, "AniConfig or TCont entry do not exists in DB", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID})
return
}
if pLocAniConfigOnUni.tcontParams.allocID != uint16(aEntryID) {
- logger.Errorw("TCont removal aborted - indicated AllocId not found",
+ logger.Errorw(ctx, "TCont removal aborted - indicated AllocId not found",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID, "AllocId": aEntryID})
/* Do not set some error indication to the outside system interface on delete
assume there is nothing to be deleted internally and hope a new config request will recover the situation
@@ -667,26 +667,26 @@
return
}
//T-Cont to be reset found
- logger.Debugw("Reset-T-Cont AllocId found - valid", log.Fields{
+ logger.Debugw(ctx, "Reset-T-Cont AllocId found - valid", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID, "AllocId": aEntryID})
if onuTP.pAniConfigFsm == nil {
- logger.Errorw("no TCont removal on OMCI - no AniConfigFsm available",
+ logger.Errorw(ctx, "no TCont removal on OMCI - no AniConfigFsm available",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID})
/* Do not set some error indication to the outside system interface on delete (see above)
onuTP.procResult[uniTpKey] = fmt.Errorf("TCont cleanup aborted: no AniConfigFsm available %d on %s",
aUniID, onuTP.deviceID)
*/
//if the FSM is not valid, also TP related data should not be valid - clear the internal store profile data
- onuTP.clearAniSideConfig(aUniID, aTpID)
+ onuTP.clearAniSideConfig(ctx, aUniID, aTpID)
return
}
if _, ok := onuTP.pAniConfigFsm[uniTPKey]; !ok {
- logger.Errorw("no TCont removal on OMCI - no AniConfigFsm available for this uni/tp",
+ logger.Errorw(ctx, "no TCont removal on OMCI - no AniConfigFsm available for this uni/tp",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID})
//even if the FSM invocation did not work we don't indicate a problem within procResult
//errors could exist also because there was nothing to delete - so we just accept that as 'deleted'
//if the FSM is not valid, also TP related data should not be valid - clear the internal store profile data
- onuTP.clearAniSideConfig(aUniID, aTpID)
+ onuTP.clearAniSideConfig(ctx, aUniID, aTpID)
return
}
if onuTP.baseDeviceHandler.ReadyForSpecificOmciConfig {
@@ -696,7 +696,7 @@
// initiate OMCI TCont related cleanup
var processingStep uint8 = 1 // used to synchronize the different processing steps with chTpConfigProcessingStep
// hence we have to make sure they indicate 'success' on chTpConfigProcessingStep with aProcessingStep
- if nil != onuTP.runAniConfigFsm(aniEvRemTcontPath, processingStep, aUniID, aTpID) {
+ if nil != onuTP.runAniConfigFsm(ctx, aniEvRemTcontPath, processingStep, aUniID, aTpID) {
//even if the FSM invocation did not work we don't indicate a problem within procResult
//errors could exist also because there was nothing to delete - so we just accept that as 'deleted'
//TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented)
@@ -704,7 +704,7 @@
}
if !onuTP.waitForTimeoutOrCompletion(ctx, onuTP.chTpConfigProcessingStep, processingStep) {
//timeout or error detected
- logger.Errorw("TCont cleanup aborted - Omci AniSideConfig failed",
+ logger.Errorw(ctx, "TCont cleanup aborted - Omci AniSideConfig failed",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID})
//even if the FSM delete execution did not work we don't indicate a problem within procResult
//we should never respond to delete with error ...
@@ -716,24 +716,24 @@
return
}
} else {
- logger.Debugw("uniPonAniConfigFsm TCont cleanup on OMCI skipped based on device state", log.Fields{
+ logger.Debugw(ctx, "uniPonAniConfigFsm TCont cleanup on OMCI skipped based on device state", log.Fields{
"device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.deviceReason})
}
//clear the internal store profile data
- onuTP.clearAniSideConfig(aUniID, aTpID)
+ onuTP.clearAniSideConfig(ctx, aUniID, aTpID)
// reset also the FSM in order to admit a new OMCI configuration in case a new profile is created
// FSM stop maybe encapsulated as OnuTP method - perhaps later in context of module splitting
_ = onuTP.pAniConfigFsm[uniTPKey].pAdaptFsm.pFsm.Event(aniEvReset)
}
// generate deviceHandler StatusEvent in case the FSM was not invoked
- go onuTP.baseDeviceHandler.deviceProcStatusUpdate(OmciAniResourceRemoved)
+ go onuTP.baseDeviceHandler.deviceProcStatusUpdate(ctx, OmciAniResourceRemoved)
}
func (onuTP *onuUniTechProf) waitForTimeoutOrCompletion(
ctx context.Context, aChTpProcessingStep <-chan uint8, aProcessingStep uint8) bool {
select {
case <-ctx.Done():
- logger.Warnw("processing not completed in-time: force release of TpProcMutex!",
+ logger.Warnw(ctx, "processing not completed in-time: force release of TpProcMutex!",
log.Fields{"device-id": onuTP.deviceID, "error": ctx.Err()})
return false
case rxStep := <-aChTpProcessingStep:
@@ -741,7 +741,7 @@
return true
}
//all other values are not accepted - including 0 for error indication
- logger.Warnw("Invalid processing step received: abort and force release of TpProcMutex!",
+ logger.Warnw(ctx, "Invalid processing step received: abort and force release of TpProcMutex!",
log.Fields{"device-id": onuTP.deviceID,
"wantedStep": aProcessingStep, "haveStep": rxStep})
return false
@@ -749,32 +749,32 @@
}
// createUniLockFsm initializes and runs the AniConfig FSM to transfer the OMCI related commands for ANI side configuration
-func (onuTP *onuUniTechProf) createAniConfigFsm(aUniID uint8, aTpID uint8,
+func (onuTP *onuUniTechProf) createAniConfigFsm(ctx context.Context, aUniID uint8, aTpID uint8,
apCurrentUniPort *onuUniPort, devEvent OnuDeviceEvent, aProcessingStep uint8) error {
- logger.Debugw("createAniConfigFsm", log.Fields{"device-id": onuTP.deviceID})
+ logger.Debugw(ctx, "createAniConfigFsm", log.Fields{"device-id": onuTP.deviceID})
chAniConfigFsm := make(chan Message, 2048)
uniTPKey := uniTP{uniID: aUniID, tpID: aTpID}
- pDevEntry := onuTP.baseDeviceHandler.getOnuDeviceEntry(true)
+ pDevEntry := onuTP.baseDeviceHandler.getOnuDeviceEntry(ctx, true)
if pDevEntry == nil {
- logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": onuTP.deviceID})
+ logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": onuTP.deviceID})
return fmt.Errorf("no valid OnuDevice: %s", onuTP.deviceID)
}
- pAniCfgFsm := newUniPonAniConfigFsm(pDevEntry.PDevOmciCC, apCurrentUniPort, onuTP,
+ pAniCfgFsm := newUniPonAniConfigFsm(ctx, pDevEntry.PDevOmciCC, apCurrentUniPort, onuTP,
pDevEntry.pOnuDB, aTpID, devEvent,
"AniConfigFsm", onuTP.baseDeviceHandler, chAniConfigFsm)
if pAniCfgFsm == nil {
- logger.Errorw("AniConfigFSM could not be created - abort!!", log.Fields{"device-id": onuTP.deviceID})
+ logger.Errorw(ctx, "AniConfigFSM could not be created - abort!!", log.Fields{"device-id": onuTP.deviceID})
return fmt.Errorf("could not create AniConfigFSM: %s", onuTP.deviceID)
}
if onuTP.pAniConfigFsm == nil {
onuTP.pAniConfigFsm = make(map[uniTP]*uniPonAniConfigFsm)
}
onuTP.pAniConfigFsm[uniTPKey] = pAniCfgFsm
- return onuTP.runAniConfigFsm(aniEvStart, aProcessingStep, aUniID, aTpID)
+ return onuTP.runAniConfigFsm(ctx, aniEvStart, aProcessingStep, aUniID, aTpID)
}
// runAniConfigFsm starts the AniConfig FSM to transfer the OMCI related commands for ANI side configuration
-func (onuTP *onuUniTechProf) runAniConfigFsm(aEvent string, aProcessingStep uint8, aUniID uint8, aTpID uint8) error {
+func (onuTP *onuUniTechProf) runAniConfigFsm(ctx context.Context, aEvent string, aProcessingStep uint8, aUniID uint8, aTpID uint8) error {
/* Uni related ANI config procedure -
***** should run via 'aniConfigDone' state and generate the argument requested event *****
*/
@@ -784,35 +784,35 @@
if pACStatemachine != nil {
if aEvent == aniEvStart {
if !pACStatemachine.Is(aniStDisabled) {
- logger.Errorw("wrong state of AniConfigFSM to start - want: Disabled", log.Fields{
+ logger.Errorw(ctx, "wrong state of AniConfigFSM to start - want: Disabled", log.Fields{
"have": pACStatemachine.Current(), "device-id": onuTP.deviceID})
// maybe try a FSM reset and then again ... - TODO!!!
return fmt.Errorf("wrong state of AniConfigFSM to start: %s", onuTP.deviceID)
}
} else if !pACStatemachine.Is(aniStConfigDone) {
- logger.Errorw("wrong state of AniConfigFSM to remove - want: ConfigDone", log.Fields{
+ logger.Errorw(ctx, "wrong state of AniConfigFSM to remove - want: ConfigDone", log.Fields{
"have": pACStatemachine.Current(), "device-id": onuTP.deviceID})
return fmt.Errorf("wrong state of AniConfigFSM to remove: %s", onuTP.deviceID)
}
//FSM init requirement to get informed about FSM completion! (otherwise timeout of the TechProf config)
onuTP.pAniConfigFsm[uniTpKey].setFsmCompleteChannel(onuTP.chTpConfigProcessingStep, aProcessingStep)
if err := pACStatemachine.Event(aEvent); err != nil {
- logger.Errorw("AniConfigFSM: can't trigger event", log.Fields{"err": err})
+ logger.Errorw(ctx, "AniConfigFSM: can't trigger event", log.Fields{"err": err})
return fmt.Errorf("can't trigger event in AniConfigFSM: %s", onuTP.deviceID)
}
/***** AniConfigFSM event notified */
- logger.Debugw("AniConfigFSM event notified", log.Fields{
+ logger.Debugw(ctx, "AniConfigFSM event notified", log.Fields{
"state": pACStatemachine.Current(), "device-id": onuTP.deviceID, "event": aEvent})
return nil
}
- logger.Errorw("AniConfigFSM StateMachine invalid - cannot be executed!!", log.Fields{"device-id": onuTP.deviceID})
+ logger.Errorw(ctx, "AniConfigFSM StateMachine invalid - cannot be executed!!", log.Fields{"device-id": onuTP.deviceID})
// maybe try a FSM reset and then again ... - TODO!!!
return fmt.Errorf("stateMachine AniConfigFSM invalid: %s", onuTP.deviceID)
}
// clearAniSideConfig deletes internal TechProfile related data connected to the requested UniPort and TpID
-func (onuTP *onuUniTechProf) clearAniSideConfig(aUniID uint8, aTpID uint8) {
- logger.Debugw("removing TpIndication and PonAniConfig data", log.Fields{
+func (onuTP *onuUniTechProf) clearAniSideConfig(ctx context.Context, aUniID uint8, aTpID uint8) {
+ logger.Debugw(ctx, "removing TpIndication and PonAniConfig data", log.Fields{
"device-id": onuTP.deviceID, "uni-id": aUniID})
uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
@@ -834,14 +834,14 @@
}
// getTechProfileDone checks if the Techprofile processing with the requested TechProfile ID was done
-func (onuTP *onuUniTechProf) getTechProfileDone(aUniID uint8, aTpID uint8) bool {
+func (onuTP *onuUniTechProf) getTechProfileDone(ctx context.Context, aUniID uint8, aTpID uint8) bool {
uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
onuTP.mutexTPState.Lock()
defer onuTP.mutexTPState.Unlock()
if _, existTP := onuTP.mapUniTpIndication[uniTpKey]; existTP {
if onuTP.mapUniTpIndication[uniTpKey].techProfileID == aTpID {
if onuTP.mapUniTpIndication[uniTpKey].techProfileToDelete {
- logger.Debugw("TechProfile not relevant for requested flow config - waiting on delete",
+ logger.Debugw(ctx, "TechProfile not relevant for requested flow config - waiting on delete",
log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID})
return false //still waiting for removal of this techProfile first
}
@@ -863,7 +863,7 @@
}
// setProfileToDelete sets the requested techProfile toDelete state (if possible)
-func (onuTP *onuUniTechProf) getMulticastGemPorts(aUniID uint8, aTpID uint8) []uint16 {
+func (onuTP *onuUniTechProf) getMulticastGemPorts(ctx context.Context, aUniID uint8, aTpID uint8) []uint16 {
uniTpKey := uniTP{uniID: aUniID, tpID: aTpID}
onuTP.mutexTPState.Lock()
defer onuTP.mutexTPState.Unlock()
@@ -871,7 +871,7 @@
if techProfile, existTP := onuTP.mapPonAniConfig[uniTpKey]; existTP {
for _, gemPortParam := range techProfile.mapGemPortParams {
if gemPortParam.isMulticast {
- log.Debugw("Detected multicast gemPort", log.Fields{"device-id": onuTP.deviceID,
+ logger.Debugw(ctx, "Detected multicast gemPort", log.Fields{"device-id": onuTP.deviceID,
"aUniID": aUniID, "aTPID": aTpID, "uniTPKey": uniTpKey,
"mcastGemId": gemPortParam.multicastGemPortID})
gemPortIds = append(gemPortIds, gemPortParam.multicastGemPortID)
diff --git a/internal/pkg/onuadaptercore/openonu.go b/internal/pkg/onuadaptercore/openonu.go
index 16ef7d7..9fcb457 100644
--- a/internal/pkg/onuadaptercore/openonu.go
+++ b/internal/pkg/onuadaptercore/openonu.go
@@ -21,19 +21,20 @@
"context"
"errors"
"fmt"
- conf "github.com/opencord/voltha-lib-go/v3/pkg/config"
"sync"
"time"
+ conf "github.com/opencord/voltha-lib-go/v4/pkg/config"
+
"github.com/golang/protobuf/ptypes"
- "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
- "github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
- "github.com/opencord/voltha-lib-go/v3/pkg/kafka"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- "github.com/opencord/voltha-protos/v3/go/openflow_13"
- oop "github.com/opencord/voltha-protos/v3/go/openolt"
- "github.com/opencord/voltha-protos/v3/go/voltha"
+ "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
+ "github.com/opencord/voltha-lib-go/v4/pkg/db/kvstore"
+ "github.com/opencord/voltha-lib-go/v4/pkg/kafka"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
+ ic "github.com/opencord/voltha-protos/v4/go/inter_container"
+ "github.com/opencord/voltha-protos/v4/go/openflow_13"
+ oop "github.com/opencord/voltha-protos/v4/go/openolt"
+ "github.com/opencord/voltha-protos/v4/go/voltha"
"github.com/opencord/voltha-openonu-adapter-go/internal/pkg/config"
)
@@ -117,17 +118,17 @@
//Start starts (logs) the adapter
func (oo *OpenONUAC) Start(ctx context.Context) error {
- logger.Info("starting-openonu-adapter")
- logger.Info("openonu-adapter-started")
+ logger.Info(ctx, "starting-openonu-adapter")
+ logger.Info(ctx, "openonu-adapter-started")
return nil
}
/*
//stop terminates the session
func (oo *OpenONUAC) stop(ctx context.Context) error {
- logger.Info("stopping-device-manager")
+ logger.Info(ctx,"stopping-device-manager")
oo.exitChannel <- 1
- logger.Info("device-manager-stopped")
+ logger.Info(ctx,"device-manager-stopped")
return nil
}
*/
@@ -139,7 +140,7 @@
oo.deviceHandlers[agent.deviceID] = agent
oo.deviceHandlers[agent.deviceID].start(ctx)
if _, exist := oo.deviceHandlersCreateChan[agent.deviceID]; exist {
- logger.Debugw("deviceHandler created - trigger processing of pending ONU_IND_REQUEST", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw(ctx, "deviceHandler created - trigger processing of pending ONU_IND_REQUEST", log.Fields{"device-id": agent.deviceID})
oo.deviceHandlersCreateChan[agent.deviceID] <- true
}
}
@@ -153,11 +154,11 @@
}
//getDeviceHandler gets the ONU deviceHandler and may wait until it is created
-func (oo *OpenONUAC) getDeviceHandler(deviceID string, aWait bool) *deviceHandler {
+func (oo *OpenONUAC) getDeviceHandler(ctx context.Context, deviceID string, aWait bool) *deviceHandler {
oo.lockDeviceHandlersMap.Lock()
agent, ok := oo.deviceHandlers[deviceID]
if aWait && !ok {
- logger.Infow("Race condition: deviceHandler not present - wait for creation or timeout",
+ logger.Infow(ctx, "Race condition: deviceHandler not present - wait for creation or timeout",
log.Fields{"device-id": deviceID})
if _, exist := oo.deviceHandlersCreateChan[deviceID]; !exist {
oo.deviceHandlersCreateChan[deviceID] = make(chan bool, 1)
@@ -169,10 +170,10 @@
// so it might be needed to wait here for that event with some timeout
select {
case <-time.After(1 * time.Second): //timer may be discussed ...
- logger.Warnw("No valid deviceHandler created after max WaitTime", log.Fields{"device-id": deviceID})
+ logger.Warnw(ctx, "No valid deviceHandler created after max WaitTime", log.Fields{"device-id": deviceID})
return nil
case <-deviceCreateChan:
- logger.Debugw("deviceHandler is ready now - continue", log.Fields{"device-id": deviceID})
+ logger.Debugw(ctx, "deviceHandler is ready now - continue", log.Fields{"device-id": deviceID})
oo.lockDeviceHandlersMap.RLock()
defer oo.lockDeviceHandlersMap.RUnlock()
return oo.deviceHandlers[deviceID]
@@ -182,11 +183,11 @@
return agent
}
-func (oo *OpenONUAC) processInterAdapterONUIndReqMessage(msg *ic.InterAdapterMessage) error {
+func (oo *OpenONUAC) processInterAdapterONUIndReqMessage(ctx context.Context, msg *ic.InterAdapterMessage) error {
msgBody := msg.GetBody()
onuIndication := &oop.OnuIndication{}
if err := ptypes.UnmarshalAny(msgBody, onuIndication); err != nil {
- logger.Warnw("onu-ind-request-cannot-unmarshal-msg-body", log.Fields{"error": err})
+ logger.Warnw(ctx, "onu-ind-request-cannot-unmarshal-msg-body", log.Fields{"error": err})
return err
}
//ToDeviceId should address a DeviceHandler instance
@@ -201,22 +202,22 @@
//Adopt_device() arrived and DeviceHandler instance was created
waitForDhInstPresent = true
}
- if handler := oo.getDeviceHandler(targetDevice, waitForDhInstPresent); handler != nil {
- logger.Infow("onu-ind-request", log.Fields{"device-id": targetDevice,
+ if handler := oo.getDeviceHandler(ctx, targetDevice, waitForDhInstPresent); handler != nil {
+ logger.Infow(ctx, "onu-ind-request", log.Fields{"device-id": targetDevice,
"OnuId": onuIndication.GetOnuId(),
"AdminState": onuIndication.GetAdminState(), "OperState": onuOperstate,
"SNR": onuIndication.GetSerialNumber()})
if onuOperstate == "up" {
- return handler.createInterface(onuIndication)
+ return handler.createInterface(ctx, onuIndication)
} else if (onuOperstate == "down") || (onuOperstate == "unreachable") {
- return handler.updateInterface(onuIndication)
+ return handler.updateInterface(ctx, onuIndication)
} else {
- logger.Errorw("unknown-onu-ind-request operState", log.Fields{"OnuId": onuIndication.GetOnuId()})
+ logger.Errorw(ctx, "unknown-onu-ind-request operState", log.Fields{"OnuId": onuIndication.GetOnuId()})
return fmt.Errorf("invalidOperState: %s, %s", onuOperstate, targetDevice)
}
}
- logger.Warnw("no handler found for received onu-ind-request", log.Fields{
+ logger.Warnw(ctx, "no handler found for received onu-ind-request", log.Fields{
"msgToDeviceId": targetDevice})
return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", targetDevice))
}
@@ -228,16 +229,15 @@
// /voltha-openolt-adapter/adaptercore/openolt.go
// Adopt_device creates a new device handler if not present already and then adopts the device
-func (oo *OpenONUAC) Adopt_device(device *voltha.Device) error {
+func (oo *OpenONUAC) Adopt_device(ctx context.Context, device *voltha.Device) error {
if device == nil {
- logger.Warn("voltha-device-is-nil")
+ logger.Warn(ctx, "voltha-device-is-nil")
return errors.New("nil-device")
}
- ctx := context.Background()
- logger.Infow("adopt-device", log.Fields{"device-id": device.Id})
+ logger.Infow(ctx, "adopt-device", log.Fields{"device-id": device.Id})
var handler *deviceHandler
- if handler = oo.getDeviceHandler(device.Id, false); handler == nil {
- handler := newDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo)
+ if handler = oo.getDeviceHandler(ctx, device.Id, false); handler == nil {
+ handler := newDeviceHandler(ctx, oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo)
oo.addDeviceHandlerToMap(ctx, handler)
go handler.adoptOrReconcileDevice(ctx, device)
// Launch the creation of the device topic
@@ -247,8 +247,8 @@
}
//Get_ofp_device_info returns OFP information for the given device
-func (oo *OpenONUAC) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) {
- logger.Errorw("device-handler-not-set", log.Fields{"device-id": device.Id})
+func (oo *OpenONUAC) Get_ofp_device_info(ctx context.Context, device *voltha.Device) (*ic.SwitchCapability, error) {
+ logger.Errorw(ctx, "device-handler-not-set", log.Fields{"device-id": device.Id})
return nil, fmt.Errorf("device-handler-not-set %s", device.Id)
}
@@ -257,21 +257,21 @@
// cmp changes in onu_uni_port.go::CreateVolthaPort()
//Process_inter_adapter_message sends messages to a target device (between adapters)
-func (oo *OpenONUAC) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error {
- logger.Debugw("Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id,
+func (oo *OpenONUAC) Process_inter_adapter_message(ctx context.Context, msg *ic.InterAdapterMessage) error {
+ logger.Debugw(ctx, "Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id,
"msgProxyDeviceId": msg.Header.ProxyDeviceId, "msgToDeviceId": msg.Header.ToDeviceId, "Type": msg.Header.Type})
if msg.Header.Type == ic.InterAdapterMessageType_ONU_IND_REQUEST {
// we have to handle ONU_IND_REQUEST already here - see comments in processInterAdapterONUIndReqMessage()
- return oo.processInterAdapterONUIndReqMessage(msg)
+ return oo.processInterAdapterONUIndReqMessage(ctx, msg)
}
//ToDeviceId should address a DeviceHandler instance
targetDevice := msg.Header.ToDeviceId
- if handler := oo.getDeviceHandler(targetDevice, false); handler != nil {
+ if handler := oo.getDeviceHandler(ctx, targetDevice, false); handler != nil {
/* 200724: modification towards synchronous implementation - possible errors within processing shall be
* in the accordingly delayed response, some timing effect might result in Techprofile processing for multiple UNI's
*/
- return handler.processInterAdapterMessage(msg)
+ return handler.processInterAdapterMessage(ctx, msg)
/* so far the processing has been in background with according commented error treatment restrictions:
go handler.ProcessInterAdapterMessage(msg)
// error treatment might be more sophisticated
@@ -281,37 +281,36 @@
return nil
*/
}
- logger.Warnw("no handler found for received Inter-Proxy-message", log.Fields{
+ logger.Warnw(ctx, "no handler found for received Inter-Proxy-message", log.Fields{
"msgToDeviceId": targetDevice})
return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", targetDevice))
}
//Adapter_descriptor not implemented
-func (oo *OpenONUAC) Adapter_descriptor() error {
+func (oo *OpenONUAC) Adapter_descriptor(ctx context.Context) error {
return errors.New("unImplemented")
}
//Device_types unimplemented
-func (oo *OpenONUAC) Device_types() (*voltha.DeviceTypes, error) {
+func (oo *OpenONUAC) Device_types(ctx context.Context) (*voltha.DeviceTypes, error) {
return nil, errors.New("unImplemented")
}
//Health returns unimplemented
-func (oo *OpenONUAC) Health() (*voltha.HealthStatus, error) {
+func (oo *OpenONUAC) Health(ctx context.Context) (*voltha.HealthStatus, error) {
return nil, errors.New("unImplemented")
}
//Reconcile_device is called once when the adapter needs to re-create device - usually on core restart
-func (oo *OpenONUAC) Reconcile_device(device *voltha.Device) error {
+func (oo *OpenONUAC) Reconcile_device(ctx context.Context, device *voltha.Device) error {
if device == nil {
- logger.Warn("reconcile-device-voltha-device-is-nil")
+ logger.Warn(ctx, "reconcile-device-voltha-device-is-nil")
return errors.New("nil-device")
}
- ctx := context.Background()
- logger.Infow("reconcile-device", log.Fields{"device-id": device.Id})
+ logger.Infow(ctx, "reconcile-device", log.Fields{"device-id": device.Id})
var handler *deviceHandler
- if handler = oo.getDeviceHandler(device.Id, false); handler == nil {
- handler := newDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo)
+ if handler = oo.getDeviceHandler(ctx, device.Id, false); handler == nil {
+ handler := newDeviceHandler(ctx, oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo)
oo.addDeviceHandlerToMap(ctx, handler)
handler.device = device
handler.reconciling = true
@@ -324,76 +323,76 @@
}
//Abandon_device unimplemented
-func (oo *OpenONUAC) Abandon_device(device *voltha.Device) error {
+func (oo *OpenONUAC) Abandon_device(ctx context.Context, device *voltha.Device) error {
return errors.New("unImplemented")
}
//Disable_device disables the given device
-func (oo *OpenONUAC) Disable_device(device *voltha.Device) error {
- logger.Infow("disable-device", log.Fields{"device-id": device.Id})
- if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
- go handler.disableDevice(device)
+func (oo *OpenONUAC) Disable_device(ctx context.Context, device *voltha.Device) error {
+ logger.Infow(ctx, "disable-device", log.Fields{"device-id": device.Id})
+ if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil {
+ go handler.disableDevice(ctx, device)
return nil
}
- logger.Warnw("no handler found for device-disable", log.Fields{"device-id": device.Id})
+ logger.Warnw(ctx, "no handler found for device-disable", log.Fields{"device-id": device.Id})
return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
}
//Reenable_device enables the onu device after disable
-func (oo *OpenONUAC) Reenable_device(device *voltha.Device) error {
- logger.Infow("reenable-device", log.Fields{"device-id": device.Id})
- if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
- go handler.reEnableDevice(device)
+func (oo *OpenONUAC) Reenable_device(ctx context.Context, device *voltha.Device) error {
+ logger.Infow(ctx, "reenable-device", log.Fields{"device-id": device.Id})
+ if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil {
+ go handler.reEnableDevice(ctx, device)
return nil
}
- logger.Warnw("no handler found for device-reenable", log.Fields{"device-id": device.Id})
+ logger.Warnw(ctx, "no handler found for device-reenable", log.Fields{"device-id": device.Id})
return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
}
//Reboot_device reboots the given device
-func (oo *OpenONUAC) Reboot_device(device *voltha.Device) error {
- logger.Infow("reboot-device", log.Fields{"device-id": device.Id})
- if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
- go handler.rebootDevice(device)
+func (oo *OpenONUAC) Reboot_device(ctx context.Context, device *voltha.Device) error {
+ logger.Infow(ctx, "reboot-device", log.Fields{"device-id": device.Id})
+ if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil {
+ go handler.rebootDevice(ctx, device)
return nil
}
- logger.Warnw("no handler found for device-reboot", log.Fields{"device-id": device.Id})
+ logger.Warnw(ctx, "no handler found for device-reboot", log.Fields{"device-id": device.Id})
return fmt.Errorf(fmt.Sprintf("handler-not-found-#{device.Id}"))
}
//Self_test_device unimplemented
-func (oo *OpenONUAC) Self_test_device(device *voltha.Device) error {
+func (oo *OpenONUAC) Self_test_device(ctx context.Context, device *voltha.Device) error {
return errors.New("unImplemented")
}
// Delete_device deletes the given device
-func (oo *OpenONUAC) Delete_device(device *voltha.Device) error {
- logger.Infow("delete-device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
- if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
- err := handler.deleteDevicePersistencyData()
+func (oo *OpenONUAC) Delete_device(ctx context.Context, device *voltha.Device) error {
+ logger.Infow(ctx, "delete-device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
+ if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil {
+ err := handler.deleteDevicePersistencyData(ctx)
//don't leave any garbage - even in error case
oo.deleteDeviceHandlerToMap(handler)
return err
}
- logger.Warnw("no handler found for device-deletion", log.Fields{"device-id": device.Id})
+ logger.Warnw(ctx, "no handler found for device-deletion", log.Fields{"device-id": device.Id})
return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
}
//Get_device_details unimplemented
-func (oo *OpenONUAC) Get_device_details(device *voltha.Device) error {
+func (oo *OpenONUAC) Get_device_details(ctx context.Context, device *voltha.Device) error {
return errors.New("unImplemented")
}
//Update_flows_bulk returns
-func (oo *OpenONUAC) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error {
+func (oo *OpenONUAC) Update_flows_bulk(ctx context.Context, device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error {
return errors.New("unImplemented")
}
//Update_flows_incrementally updates (add/remove) the flows on a given device
-func (oo *OpenONUAC) Update_flows_incrementally(device *voltha.Device,
+func (oo *OpenONUAC) Update_flows_incrementally(ctx context.Context, device *voltha.Device,
flows *openflow_13.FlowChanges, groups *openflow_13.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error {
- logger.Infow("update-flows-incrementally", log.Fields{"device-id": device.Id})
+ logger.Infow(ctx, "update-flows-incrementally", log.Fields{"device-id": device.Id})
//flow config is relayed to handler even if the device might be in some 'inactive' state
// let the handler or related FSM's decide, what to do with the modified flow state info
// at least the flow-remove must be done in respect to internal data, while OMCI activity might not be needed here
@@ -401,91 +400,91 @@
// For now, there is no support for group changes (as in the actual Py-adapter code)
// but processing is continued for flowUpdate possibly also set in the request
if groups.ToAdd != nil && groups.ToAdd.Items != nil {
- logger.Warnw("Update-flow-incr: group add not supported (ignored)", log.Fields{"device-id": device.Id})
+ logger.Warnw(ctx, "Update-flow-incr: group add not supported (ignored)", log.Fields{"device-id": device.Id})
}
if groups.ToRemove != nil && groups.ToRemove.Items != nil {
- logger.Warnw("Update-flow-incr: group remove not supported (ignored)", log.Fields{"device-id": device.Id})
+ logger.Warnw(ctx, "Update-flow-incr: group remove not supported (ignored)", log.Fields{"device-id": device.Id})
}
if groups.ToUpdate != nil && groups.ToUpdate.Items != nil {
- logger.Warnw("Update-flow-incr: group update not supported (ignored)", log.Fields{"device-id": device.Id})
+ logger.Warnw(ctx, "Update-flow-incr: group update not supported (ignored)", log.Fields{"device-id": device.Id})
}
- if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
- err := handler.FlowUpdateIncremental(flows, groups, flowMetadata)
+ if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil {
+ err := handler.FlowUpdateIncremental(ctx, flows, groups, flowMetadata)
return err
}
- logger.Warnw("no handler found for incremental flow update", log.Fields{"device-id": device.Id})
+ logger.Warnw(ctx, "no handler found for incremental flow update", log.Fields{"device-id": device.Id})
return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
}
//Update_pm_config returns PmConfigs nil or error
-func (oo *OpenONUAC) Update_pm_config(device *voltha.Device, pmConfigs *voltha.PmConfigs) error {
+func (oo *OpenONUAC) Update_pm_config(ctx context.Context, device *voltha.Device, pmConfigs *voltha.PmConfigs) error {
return errors.New("unImplemented")
}
//Receive_packet_out sends packet out to the device
-func (oo *OpenONUAC) Receive_packet_out(deviceID string, egressPortNo int, packet *openflow_13.OfpPacketOut) error {
+func (oo *OpenONUAC) Receive_packet_out(ctx context.Context, deviceID string, egressPortNo int, packet *openflow_13.OfpPacketOut) error {
return errors.New("unImplemented")
}
//Suppress_event unimplemented
-func (oo *OpenONUAC) Suppress_event(filter *voltha.EventFilter) error {
+func (oo *OpenONUAC) Suppress_event(ctx context.Context, filter *voltha.EventFilter) error {
return errors.New("unImplemented")
}
//Unsuppress_event unimplemented
-func (oo *OpenONUAC) Unsuppress_event(filter *voltha.EventFilter) error {
+func (oo *OpenONUAC) Unsuppress_event(ctx context.Context, filter *voltha.EventFilter) error {
return errors.New("unImplemented")
}
//Download_image unimplemented
-func (oo *OpenONUAC) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+func (oo *OpenONUAC) Download_image(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
return nil, errors.New("unImplemented")
}
//Get_image_download_status unimplemented
-func (oo *OpenONUAC) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+func (oo *OpenONUAC) Get_image_download_status(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
return nil, errors.New("unImplemented")
}
//Cancel_image_download unimplemented
-func (oo *OpenONUAC) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+func (oo *OpenONUAC) Cancel_image_download(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
return nil, errors.New("unImplemented")
}
//Activate_image_update unimplemented
-func (oo *OpenONUAC) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+func (oo *OpenONUAC) Activate_image_update(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
return nil, errors.New("unImplemented")
}
//Revert_image_update unimplemented
-func (oo *OpenONUAC) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+func (oo *OpenONUAC) Revert_image_update(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
return nil, errors.New("unImplemented")
}
// Enable_port to Enable PON/NNI interface - seems not to be used/required according to python code
-func (oo *OpenONUAC) Enable_port(deviceID string, port *voltha.Port) error {
+func (oo *OpenONUAC) Enable_port(ctx context.Context, deviceID string, port *voltha.Port) error {
return errors.New("unImplemented")
}
// Disable_port to Disable pon/nni interface - seems not to be used/required according to python code
-func (oo *OpenONUAC) Disable_port(deviceID string, port *voltha.Port) error {
+func (oo *OpenONUAC) Disable_port(ctx context.Context, deviceID string, port *voltha.Port) error {
return errors.New("unImplemented")
}
//Child_device_lost - unimplemented
//needed for if update >= 3.1.x
-func (oo *OpenONUAC) Child_device_lost(deviceID string, pPortNo uint32, onuID uint32) error {
+func (oo *OpenONUAC) Child_device_lost(ctx context.Context, deviceID string, pPortNo uint32, onuID uint32) error {
return errors.New("unImplemented")
}
// Start_omci_test unimplemented
-func (oo *OpenONUAC) Start_omci_test(device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error) {
+func (oo *OpenONUAC) Start_omci_test(ctx context.Context, device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error) {
return nil, errors.New("unImplemented")
}
// Get_ext_value - unimplemented
-func (oo *OpenONUAC) Get_ext_value(deviceID string, device *voltha.Device, valueparam voltha.ValueType_Type) (*voltha.ReturnValues, error) {
+func (oo *OpenONUAC) Get_ext_value(ctx context.Context, deviceID string, device *voltha.Device, valueparam voltha.ValueType_Type) (*voltha.ReturnValues, error) {
return nil, errors.New("unImplemented")
}
diff --git a/internal/pkg/onuadaptercore/openonuimpl.go b/internal/pkg/onuadaptercore/openonuimpl.go
index a3e3780..c8cde8c 100644
--- a/internal/pkg/onuadaptercore/openonuimpl.go
+++ b/internal/pkg/onuadaptercore/openonuimpl.go
@@ -18,8 +18,9 @@
package adaptercoreonu
import (
+ "context"
"errors"
- //"github.com/opencord/voltha-lib-go/v3/pkg/log"
+ //"github.com/opencord/voltha-lib-go/v4/pkg/log"
)
/*
@@ -89,8 +90,8 @@
const cMibAuditDelayImpl = 0
//suppose global methods per adapter ...
-func mibDbVolatileDictImpl() error {
- logger.Debug("MibVolatileDict-called")
+func mibDbVolatileDictImpl(ctx context.Context) error {
+ logger.Debug(ctx, "MibVolatileDict-called")
return errors.New("not_implemented")
}
diff --git a/internal/pkg/onuadaptercore/platform.go b/internal/pkg/onuadaptercore/platform.go
index cd4c923..1f9898f 100644
--- a/internal/pkg/onuadaptercore/platform.go
+++ b/internal/pkg/onuadaptercore/platform.go
@@ -17,6 +17,8 @@
//Package adaptercoreonu provides the utility for onu devices, flows and statistics
package adaptercoreonu
+import "context"
+
//Attention: this file is more or less a coopy of file olt_platform.go from the voltha-openolt-adapter
// which includes system wide definitions and thus normally should be stored more centrally (within some voltha libs)!!
@@ -129,19 +131,19 @@
*/
//mkUniPortNum returns new UNIportNum based on intfID, onuID and uniID
-func mkUniPortNum(intfID, onuID, uniID uint32) uint32 {
+func mkUniPortNum(ctx context.Context, intfID, onuID, uniID uint32) uint32 {
//extended for checks available in the python onu adapter:!!
var limit = int(intfID)
if limit > maxPonsPerOlt {
- logger.Warn("Warning: exceeded the MAX pons per OLT")
+ logger.Warn(ctx, "Warning: exceeded the MAX pons per OLT")
}
limit = int(onuID)
if limit > maxOnusPerPon {
- logger.Warn("Warning: exceeded the MAX ONUS per PON")
+ logger.Warn(ctx, "Warning: exceeded the MAX ONUS per PON")
}
limit = int(uniID)
if limit > maxUnisPerOnu {
- logger.Warn("Warning: exceeded the MAX UNIS per ONU")
+ logger.Warn(ctx, "Warning: exceeded the MAX UNIS per ONU")
}
return (intfID << (bitsForUniID + bitsForONUID)) | (onuID << bitsForUniID) | uniID
}
@@ -187,7 +189,7 @@
//intfIDFromNniPortNum returns Intf ID derived from portNum
func intfIDFromNniPortNum(portNum uint32) (uint32, error) {
if portNum < minNniIntPortNum || portNum > maxNniPortNum {
- logger.Errorw("NNIPortNumber is not in valid range", log.Fields{"portNum": portNum})
+ logger.Errorw(ctx,"NNIPortNumber is not in valid range", log.Fields{"portNum": portNum})
return uint32(0), errors.New("invalid-port-range") //olterrors.ErrInvalidPortRange
}
return (portNum & 0xFFFF), nil
@@ -285,7 +287,7 @@
onuID = onuIDFromUniPortNum(uniPortNo)
uniID = uniIDFromPortNum(uniPortNo)
- logger.Debugw("flow extract info result",
+ logger.Debugw(ctx,"flow extract info result",
log.Fields{"uniPortNo": uniPortNo, "ponIntf": ponIntf,
"onuID": onuID, "uniID": uniID, "inPort": inPort, "ethType": ethType})
diff --git a/internal/pkg/onuadaptercore/uniportadmin.go b/internal/pkg/onuadaptercore/uniportadmin.go
index 0bc5e65..7cf4373 100644
--- a/internal/pkg/onuadaptercore/uniportadmin.go
+++ b/internal/pkg/onuadaptercore/uniportadmin.go
@@ -26,9 +26,9 @@
"github.com/opencord/omci-lib-go"
me "github.com/opencord/omci-lib-go/generated"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- //ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- //"github.com/opencord/voltha-protos/v3/go/openflow_13"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
+ //ic "github.com/opencord/voltha-protos/v4/go/inter_container"
+ //"github.com/opencord/voltha-protos/v4/go/openflow_13"
)
//lockStateFsm defines the structure for the state machine to lock/unlock the ONU UNI ports via OMCI
@@ -65,7 +65,7 @@
)
//newLockStateFsm is the 'constructor' for the state machine to lock/unlock the ONU UNI ports via OMCI
-func newLockStateFsm(apDevOmciCC *omciCC, aAdminState bool, aRequestEvent OnuDeviceEvent,
+func newLockStateFsm(ctx context.Context, apDevOmciCC *omciCC, aAdminState bool, aRequestEvent OnuDeviceEvent,
aName string, apDeviceHandler *deviceHandler, aCommChannel chan Message) *lockStateFsm {
instFsm := &lockStateFsm{
pDeviceHandler: apDeviceHandler,
@@ -76,7 +76,7 @@
}
instFsm.pAdaptFsm = NewAdapterFsm(aName, instFsm.deviceID, aCommChannel)
if instFsm.pAdaptFsm == nil {
- logger.Errorw("LockStateFsm's AdapterFsm could not be instantiated!!", log.Fields{
+ logger.Errorw(ctx, "LockStateFsm's AdapterFsm could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
}
@@ -105,12 +105,12 @@
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(e) },
- ("enter_" + uniStStarting): func(e *fsm.Event) { instFsm.enterAdminStartingState(e) },
- ("enter_" + uniStSettingOnuG): func(e *fsm.Event) { instFsm.enterSettingOnuGState(e) },
- ("enter_" + uniStSettingUnis): func(e *fsm.Event) { instFsm.enterSettingUnisState(e) },
- ("enter_" + uniStAdminDone): func(e *fsm.Event) { instFsm.enterAdminDoneState(e) },
- ("enter_" + uniStResetting): func(e *fsm.Event) { instFsm.enterResettingState(e) },
+ "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
+ ("enter_" + uniStStarting): func(e *fsm.Event) { instFsm.enterAdminStartingState(ctx, e) },
+ ("enter_" + uniStSettingOnuG): func(e *fsm.Event) { instFsm.enterSettingOnuGState(ctx, e) },
+ ("enter_" + uniStSettingUnis): func(e *fsm.Event) { instFsm.enterSettingUnisState(ctx, e) },
+ ("enter_" + uniStAdminDone): func(e *fsm.Event) { instFsm.enterAdminDoneState(ctx, e) },
+ ("enter_" + uniStResetting): func(e *fsm.Event) { instFsm.enterResettingState(ctx, e) },
},
)
} else { //port unlocking requested
@@ -138,22 +138,22 @@
},
fsm.Callbacks{
- "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(e) },
- ("enter_" + uniStStarting): func(e *fsm.Event) { instFsm.enterAdminStartingState(e) },
- ("enter_" + uniStSettingOnuG): func(e *fsm.Event) { instFsm.enterSettingOnuGState(e) },
- ("enter_" + uniStSettingUnis): func(e *fsm.Event) { instFsm.enterSettingUnisState(e) },
- ("enter_" + uniStAdminDone): func(e *fsm.Event) { instFsm.enterAdminDoneState(e) },
- ("enter_" + uniStResetting): func(e *fsm.Event) { instFsm.enterResettingState(e) },
+ "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) },
+ ("enter_" + uniStStarting): func(e *fsm.Event) { instFsm.enterAdminStartingState(ctx, e) },
+ ("enter_" + uniStSettingOnuG): func(e *fsm.Event) { instFsm.enterSettingOnuGState(ctx, e) },
+ ("enter_" + uniStSettingUnis): func(e *fsm.Event) { instFsm.enterSettingUnisState(ctx, e) },
+ ("enter_" + uniStAdminDone): func(e *fsm.Event) { instFsm.enterAdminDoneState(ctx, e) },
+ ("enter_" + uniStResetting): func(e *fsm.Event) { instFsm.enterResettingState(ctx, e) },
},
)
}
if instFsm.pAdaptFsm.pFsm == nil {
- logger.Errorw("LockStateFsm's Base FSM could not be instantiated!!", log.Fields{
+ logger.Errorw(ctx, "LockStateFsm's Base FSM could not be instantiated!!", log.Fields{
"device-id": instFsm.deviceID})
return nil
}
- logger.Debugw("LockStateFsm created", log.Fields{"device-id": instFsm.deviceID})
+ logger.Debugw(ctx, "LockStateFsm created", log.Fields{"device-id": instFsm.deviceID})
return instFsm
}
@@ -163,13 +163,13 @@
oFsm.requestEvent = aEvent
}
-func (oFsm *lockStateFsm) enterAdminStartingState(e *fsm.Event) {
- logger.Debugw("LockStateFSM start", log.Fields{"in state": e.FSM.Current(),
+func (oFsm *lockStateFsm) enterAdminStartingState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "LockStateFSM start", log.Fields{"in state": e.FSM.Current(),
"device-id": oFsm.deviceID})
// in case the used channel is not yet defined (can be re-used after restarts)
if oFsm.omciLockResponseReceived == nil {
oFsm.omciLockResponseReceived = make(chan bool)
- logger.Debug("LockStateFSM - OMCI UniLock RxChannel defined")
+ logger.Debug(ctx, "LockStateFSM - OMCI UniLock RxChannel defined")
} else {
// as we may 're-use' this instance of FSM and the connected channel
// make sure there is no 'lingering' request in the already existing channel:
@@ -179,7 +179,7 @@
}
}
// start go routine for processing of LockState messages
- go oFsm.processOmciLockMessages()
+ go oFsm.processOmciLockMessages(ctx)
//let the state machine run forward from here directly
pLockStateAFsm := oFsm.pAdaptFsm
@@ -193,15 +193,15 @@
}
}
-func (oFsm *lockStateFsm) enterSettingOnuGState(e *fsm.Event) {
+func (oFsm *lockStateFsm) enterSettingOnuGState(ctx context.Context, e *fsm.Event) {
var omciAdminState uint8 = 1 //default locked
if !oFsm.adminState {
omciAdminState = 0
}
- logger.Debugw("LockStateFSM Tx Set::ONU-G:admin", log.Fields{
+ logger.Debugw(ctx, "LockStateFSM Tx Set::ONU-G:admin", log.Fields{
"omciAdmin": omciAdminState, "in state": e.FSM.Current(), "device-id": oFsm.deviceID})
requestedAttributes := me.AttributeValueMap{"AdministrativeState": omciAdminState}
- meInstance := oFsm.pOmciCC.sendSetOnuGLS(context.TODO(), ConstDefaultOmciTimeout, true,
+ meInstance := oFsm.pOmciCC.sendSetOnuGLS(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true,
requestedAttributes, oFsm.pAdaptFsm.commChan)
//accept also nil as (error) return value for writing to LastTx
// - this avoids misinterpretation of new received OMCI messages
@@ -210,16 +210,16 @@
oFsm.pLastTxMeInstance = meInstance
}
-func (oFsm *lockStateFsm) enterSettingUnisState(e *fsm.Event) {
- logger.Debugw("LockStateFSM - starting PPTP config loop", log.Fields{
+func (oFsm *lockStateFsm) enterSettingUnisState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "LockStateFSM - starting PPTP config loop", log.Fields{
"in state": e.FSM.Current(), "device-id": oFsm.deviceID, "LockState": oFsm.adminState})
- go oFsm.performUniPortAdminSet()
+ go oFsm.performUniPortAdminSet(ctx)
}
-func (oFsm *lockStateFsm) enterAdminDoneState(e *fsm.Event) {
- logger.Debugw("LockStateFSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": oFsm.deviceID})
+func (oFsm *lockStateFsm) enterAdminDoneState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "LockStateFSM", log.Fields{"send notification to core in State": e.FSM.Current(), "device-id": oFsm.deviceID})
//use DeviceHandler event notification directly, no need/support to update DeviceEntryState for lock/unlock
- oFsm.pDeviceHandler.deviceProcStatusUpdate(oFsm.requestEvent)
+ oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, oFsm.requestEvent)
//let's reset the state machine in order to release all resources now
pLockStateAFsm := oFsm.pAdaptFsm
@@ -233,8 +233,8 @@
}
}
-func (oFsm *lockStateFsm) enterResettingState(e *fsm.Event) {
- logger.Debugw("LockStateFSM resetting", log.Fields{"device-id": oFsm.deviceID})
+func (oFsm *lockStateFsm) enterResettingState(ctx context.Context, e *fsm.Event) {
+ logger.Debugw(ctx, "LockStateFSM resetting", log.Fields{"device-id": oFsm.deviceID})
pLockStateAFsm := oFsm.pAdaptFsm
if pLockStateAFsm != nil {
// abort running message processing
@@ -257,61 +257,61 @@
}
}
-func (oFsm *lockStateFsm) processOmciLockMessages( /*ctx context.Context*/ ) {
- logger.Debugw("Start LockStateFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID})
+func (oFsm *lockStateFsm) processOmciLockMessages(ctx context.Context) {
+ logger.Debugw(ctx, "Start LockStateFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID})
loop:
for {
// case <-ctx.Done():
- // logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID})
+ // logger.Info(ctx,"MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID})
// break loop
message, ok := <-oFsm.pAdaptFsm.commChan
if !ok {
- logger.Info("LockStateFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
+ logger.Info(ctx, "LockStateFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID})
// but then we have to ensure a restart of the FSM as well - as exceptional procedure
_ = oFsm.pAdaptFsm.pFsm.Event(uniEvRestart)
break loop
}
- logger.Debugw("LockStateFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "LockStateFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID})
switch message.Type {
case TestMsg:
msg, _ := message.Data.(TestMessage)
if msg.TestMessageVal == AbortMessageProcessing {
- logger.Debugw("LockStateFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "LockStateFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID})
break loop
}
- logger.Warnw("LockStateFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
+ logger.Warnw(ctx, "LockStateFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal})
case OMCI:
msg, _ := message.Data.(OmciMessage)
- oFsm.handleOmciLockStateMessage(msg)
+ oFsm.handleOmciLockStateMessage(ctx, msg)
default:
- logger.Warn("LockStateFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
+ logger.Warn(ctx, "LockStateFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID,
"message.Type": message.Type})
}
}
- logger.Debugw("End LockStateFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
+ logger.Debugw(ctx, "End LockStateFsm Msg processing", log.Fields{"device-id": oFsm.deviceID})
}
-func (oFsm *lockStateFsm) handleOmciLockStateMessage(msg OmciMessage) {
- logger.Debugw("Rx OMCI LockStateFsm Msg", log.Fields{"device-id": oFsm.deviceID,
+func (oFsm *lockStateFsm) handleOmciLockStateMessage(ctx context.Context, msg OmciMessage) {
+ logger.Debugw(ctx, "Rx OMCI LockStateFsm Msg", log.Fields{"device-id": oFsm.deviceID,
"msgType": msg.OmciMsg.MessageType})
if msg.OmciMsg.MessageType == omci.SetResponseType {
msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse)
if msgLayer == nil {
- logger.Errorw("LockStateFsm - Omci Msg layer could not be detected for SetResponse",
+ logger.Errorw(ctx, "LockStateFsm - Omci Msg layer could not be detected for SetResponse",
log.Fields{"device-id": oFsm.deviceID})
return
}
msgObj, msgOk := msgLayer.(*omci.SetResponse)
if !msgOk {
- logger.Errorw("LockStateFsm - Omci Msg layer could not be assigned for SetResponse",
+ logger.Errorw(ctx, "LockStateFsm - Omci Msg layer could not be assigned for SetResponse",
log.Fields{"device-id": oFsm.deviceID})
return
}
- logger.Debugw("LockStateFsm SetResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
+ logger.Debugw(ctx, "LockStateFsm SetResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj})
if msgObj.Result != me.Success {
- logger.Errorw("LockStateFsm - Omci SetResponse Error - later: drive FSM to abort state ?", log.Fields{"Error": msgObj.Result})
+ logger.Errorw(ctx, "LockStateFsm - Omci SetResponse Error - later: drive FSM to abort state ?", log.Fields{"Error": msgObj.Result})
// possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display?
return
}
@@ -334,12 +334,12 @@
}
}
} else {
- logger.Errorw("LockStateFsm - Rx OMCI unhandled MsgType", log.Fields{"omciMsgType": msg.OmciMsg.MessageType})
+ logger.Errorw(ctx, "LockStateFsm - Rx OMCI unhandled MsgType", log.Fields{"omciMsgType": msg.OmciMsg.MessageType})
return
}
}
-func (oFsm *lockStateFsm) performUniPortAdminSet() {
+func (oFsm *lockStateFsm) performUniPortAdminSet(ctx context.Context) {
var omciAdminState uint8 = 1 //default locked
if !oFsm.adminState {
omciAdminState = 0
@@ -348,28 +348,28 @@
requestedAttributes := me.AttributeValueMap{"AdministrativeState": omciAdminState}
for uniNo, uniPort := range oFsm.pOmciCC.pBaseDeviceHandler.uniEntityMap {
- logger.Debugw("Setting PPTP admin state", log.Fields{
+ logger.Debugw(ctx, "Setting PPTP admin state", log.Fields{
"device-id": oFsm.deviceID, "for PortNo": uniNo})
var meInstance *me.ManagedEntity
if uniPort.portType == uniPPTP {
- meInstance = oFsm.pOmciCC.sendSetPptpEthUniLS(context.TODO(), uniPort.entityID, ConstDefaultOmciTimeout,
+ meInstance = oFsm.pOmciCC.sendSetPptpEthUniLS(log.WithSpanFromContext(context.TODO(), ctx), uniPort.entityID, ConstDefaultOmciTimeout,
true, requestedAttributes, oFsm.pAdaptFsm.commChan)
oFsm.pLastTxMeInstance = meInstance
} else if uniPort.portType == uniVEIP {
- meInstance = oFsm.pOmciCC.sendSetVeipLS(context.TODO(), uniPort.entityID, ConstDefaultOmciTimeout,
+ meInstance = oFsm.pOmciCC.sendSetVeipLS(log.WithSpanFromContext(context.TODO(), ctx), uniPort.entityID, ConstDefaultOmciTimeout,
true, requestedAttributes, oFsm.pAdaptFsm.commChan)
oFsm.pLastTxMeInstance = meInstance
} else {
- logger.Warnw("Unsupported PPTP type - skip",
+ logger.Warnw(ctx, "Unsupported PPTP type - skip",
log.Fields{"device-id": oFsm.deviceID, "Port": uniNo})
continue
}
//verify response
- err := oFsm.waitforOmciResponse(meInstance)
+ err := oFsm.waitforOmciResponse(ctx, meInstance)
if err != nil {
- logger.Errorw("PPTP Admin State set failed, aborting LockState set!",
+ logger.Errorw(ctx, "PPTP Admin State set failed, aborting LockState set!",
log.Fields{"device-id": oFsm.deviceID, "Port": uniNo})
_ = oFsm.pAdaptFsm.pFsm.Event(uniEvReset)
return
@@ -377,25 +377,25 @@
} //for all UNI ports
// if Config has been done for all UNI related instances let the FSM proceed
// while we did not check here, if there is some port at all - !?
- logger.Infow("PPTP config loop finished", log.Fields{"device-id": oFsm.deviceID})
+ logger.Infow(ctx, "PPTP config loop finished", log.Fields{"device-id": oFsm.deviceID})
_ = oFsm.pAdaptFsm.pFsm.Event(uniEvRxUnisResp)
}
-func (oFsm *lockStateFsm) waitforOmciResponse(apMeInstance *me.ManagedEntity) error {
+func (oFsm *lockStateFsm) waitforOmciResponse(ctx context.Context, apMeInstance *me.ManagedEntity) error {
select {
// maybe be also some outside cancel (but no context modeled for the moment ...)
// case <-ctx.Done():
- // logger.Infow("LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.deviceID})
+ // logger.Infow(ctx,"LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.deviceID})
case <-time.After(30 * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug
- logger.Warnw("LockStateFSM uni-set timeout", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Warnw(ctx, "LockStateFSM uni-set timeout", log.Fields{"for device-id": oFsm.deviceID})
return fmt.Errorf("lockStateFsm uni-set timeout for device-id %s", oFsm.deviceID)
case success := <-oFsm.omciLockResponseReceived:
if success {
- logger.Debug("LockStateFSM uni-set response received")
+ logger.Debug(ctx, "LockStateFSM uni-set response received")
return nil
}
// should not happen so far
- logger.Warnw("LockStateFSM uni-set response error", log.Fields{"for device-id": oFsm.deviceID})
+ logger.Warnw(ctx, "LockStateFSM uni-set response error", log.Fields{"for device-id": oFsm.deviceID})
return fmt.Errorf("lockStateFsm uni-set responseError for device-id %s", oFsm.deviceID)
}
}
diff --git a/pkg/mocks/common.go b/pkg/mocks/common.go
index 546f2fe..e469948 100644
--- a/pkg/mocks/common.go
+++ b/pkg/mocks/common.go
@@ -18,13 +18,13 @@
package mocks
import (
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
+ "github.com/opencord/voltha-lib-go/v4/pkg/log"
)
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- _, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "mocks"})
+ _, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "mocks"})
if err != nil {
panic(err)
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go
deleted file mode 100644
index 20e1a52..0000000
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go
+++ /dev/null
@@ -1,620 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package common
-
-import (
- "context"
- "sync"
-
- "github.com/golang/protobuf/ptypes"
- a "github.com/golang/protobuf/ptypes/any"
- "github.com/opencord/voltha-lib-go/v3/pkg/kafka"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- "github.com/opencord/voltha-protos/v3/go/voltha"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
-)
-
-type CoreProxy struct {
- kafkaICProxy kafka.InterContainerProxy
- adapterTopic string
- coreTopic string
- deviceIdCoreMap map[string]string
- lockDeviceIdCoreMap sync.RWMutex
-}
-
-func NewCoreProxy(kafkaProxy kafka.InterContainerProxy, adapterTopic string, coreTopic string) *CoreProxy {
- var proxy CoreProxy
- proxy.kafkaICProxy = kafkaProxy
- proxy.adapterTopic = adapterTopic
- proxy.coreTopic = coreTopic
- proxy.deviceIdCoreMap = make(map[string]string)
- proxy.lockDeviceIdCoreMap = sync.RWMutex{}
- logger.Debugw("TOPICS", log.Fields{"core": proxy.coreTopic, "adapter": proxy.adapterTopic})
-
- return &proxy
-}
-
-func unPackResponse(rpc string, deviceId string, success bool, response *a.Any) error {
- if success {
- return nil
- } else {
- unpackResult := &ic.Error{}
- var err error
- if err = ptypes.UnmarshalAny(response, unpackResult); err != nil {
- logger.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
- }
- logger.Debugw("response", log.Fields{"rpc": rpc, "deviceId": deviceId, "success": success, "error": err})
- // TODO: Need to get the real error code
- return status.Errorf(codes.Canceled, "%s", unpackResult.Reason)
- }
-}
-
-// UpdateCoreReference adds or update a core reference (really the topic name) for a given device Id
-func (ap *CoreProxy) UpdateCoreReference(deviceId string, coreReference string) {
- ap.lockDeviceIdCoreMap.Lock()
- defer ap.lockDeviceIdCoreMap.Unlock()
- ap.deviceIdCoreMap[deviceId] = coreReference
-}
-
-// DeleteCoreReference removes a core reference (really the topic name) for a given device Id
-func (ap *CoreProxy) DeleteCoreReference(deviceId string) {
- ap.lockDeviceIdCoreMap.Lock()
- defer ap.lockDeviceIdCoreMap.Unlock()
- delete(ap.deviceIdCoreMap, deviceId)
-}
-
-func (ap *CoreProxy) getCoreTopic(deviceId string) kafka.Topic {
- ap.lockDeviceIdCoreMap.Lock()
- defer ap.lockDeviceIdCoreMap.Unlock()
-
- if t, exist := ap.deviceIdCoreMap[deviceId]; exist {
- return kafka.Topic{Name: t}
- }
-
- return kafka.Topic{Name: ap.coreTopic}
-}
-
-func (ap *CoreProxy) getAdapterTopic(args ...string) kafka.Topic {
- return kafka.Topic{Name: ap.adapterTopic}
-}
-
-func (ap *CoreProxy) RegisterAdapter(ctx context.Context, adapter *voltha.Adapter, deviceTypes *voltha.DeviceTypes) error {
- logger.Debugw("registering-adapter", log.Fields{"coreTopic": ap.coreTopic, "adapterTopic": ap.adapterTopic})
- rpc := "Register"
- topic := kafka.Topic{Name: ap.coreTopic}
- replyToTopic := ap.getAdapterTopic()
- args := make([]*kafka.KVArg, 2)
-
- if adapter.TotalReplicas == 0 && adapter.CurrentReplica != 0 {
- log.Fatal("totalReplicas can't be 0, since you're here you have at least one")
- }
-
- if adapter.CurrentReplica == 0 && adapter.TotalReplicas != 0 {
- log.Fatal("currentReplica can't be 0, it has to start from 1")
- }
-
- if adapter.CurrentReplica == 0 && adapter.TotalReplicas == 0 {
- // if the adapter is not setting these fields they default to 0,
- // in that case it means the adapter is not ready to be scaled and thus it defaults
- // to a single instance
- adapter.CurrentReplica = 1
- adapter.TotalReplicas = 1
- }
-
- if adapter.CurrentReplica > adapter.TotalReplicas {
- log.Fatalf("CurrentReplica (%d) can't be greater than TotalReplicas (%d)",
- adapter.CurrentReplica, adapter.TotalReplicas)
- }
-
- args[0] = &kafka.KVArg{
- Key: "adapter",
- Value: adapter,
- }
- args[1] = &kafka.KVArg{
- Key: "deviceTypes",
- Value: deviceTypes,
- }
-
- success, result := ap.kafkaICProxy.InvokeRPC(ctx, rpc, &topic, &replyToTopic, true, "", args...)
- logger.Debugw("Register-Adapter-response", log.Fields{"replyTopic": replyToTopic, "success": success})
- return unPackResponse(rpc, "", success, result)
-}
-
-func (ap *CoreProxy) DeviceUpdate(ctx context.Context, device *voltha.Device) error {
- logger.Debugw("DeviceUpdate", log.Fields{"deviceId": device.Id})
- rpc := "DeviceUpdate"
- toTopic := ap.getCoreTopic(device.Id)
- args := make([]*kafka.KVArg, 1)
- args[0] = &kafka.KVArg{
- Key: "device",
- Value: device,
- }
- // Use a device specific topic as we are the only adaptercore handling requests for this device
- replyToTopic := ap.getAdapterTopic()
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, device.Id, args...)
- logger.Debugw("DeviceUpdate-response", log.Fields{"deviceId": device.Id, "success": success})
- return unPackResponse(rpc, device.Id, success, result)
-}
-
-func (ap *CoreProxy) PortCreated(ctx context.Context, deviceId string, port *voltha.Port) error {
- logger.Debugw("PortCreated", log.Fields{"portNo": port.PortNo})
- rpc := "PortCreated"
- // Use a device specific topic to send the request. The adapter handling the device creates a device
- // specific topic
- toTopic := ap.getCoreTopic(deviceId)
- args := make([]*kafka.KVArg, 2)
- id := &voltha.ID{Id: deviceId}
- args[0] = &kafka.KVArg{
- Key: "device_id",
- Value: id,
- }
- args[1] = &kafka.KVArg{
- Key: "port",
- Value: port,
- }
-
- // Use a device specific topic as we are the only adaptercore handling requests for this device
- replyToTopic := ap.getAdapterTopic()
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw("PortCreated-response", log.Fields{"deviceId": deviceId, "success": success})
- return unPackResponse(rpc, deviceId, success, result)
-}
-
-func (ap *CoreProxy) PortsStateUpdate(ctx context.Context, deviceId string, operStatus voltha.OperStatus_Types) error {
- logger.Debugw("PortsStateUpdate", log.Fields{"deviceId": deviceId})
- rpc := "PortsStateUpdate"
- // Use a device specific topic to send the request. The adapter handling the device creates a device
- // specific topic
- toTopic := ap.getCoreTopic(deviceId)
- args := make([]*kafka.KVArg, 2)
- id := &voltha.ID{Id: deviceId}
- oStatus := &ic.IntType{Val: int64(operStatus)}
-
- args[0] = &kafka.KVArg{
- Key: "device_id",
- Value: id,
- }
- args[1] = &kafka.KVArg{
- Key: "oper_status",
- Value: oStatus,
- }
-
- // Use a device specific topic as we are the only adaptercore handling requests for this device
- replyToTopic := ap.getAdapterTopic()
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw("PortsStateUpdate-response", log.Fields{"deviceId": deviceId, "success": success})
- return unPackResponse(rpc, deviceId, success, result)
-}
-
-func (ap *CoreProxy) DeleteAllPorts(ctx context.Context, deviceId string) error {
- logger.Debugw("DeleteAllPorts", log.Fields{"deviceId": deviceId})
- rpc := "DeleteAllPorts"
- // Use a device specific topic to send the request. The adapter handling the device creates a device
- // specific topic
- toTopic := ap.getCoreTopic(deviceId)
- args := make([]*kafka.KVArg, 2)
- id := &voltha.ID{Id: deviceId}
-
- args[0] = &kafka.KVArg{
- Key: "device_id",
- Value: id,
- }
-
- // Use a device specific topic as we are the only adaptercore handling requests for this device
- replyToTopic := ap.getAdapterTopic()
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw("DeleteAllPorts-response", log.Fields{"deviceId": deviceId, "success": success})
- return unPackResponse(rpc, deviceId, success, result)
-}
-
-func (ap *CoreProxy) DeviceStateUpdate(ctx context.Context, deviceId string,
- connStatus voltha.ConnectStatus_Types, operStatus voltha.OperStatus_Types) error {
- logger.Debugw("DeviceStateUpdate", log.Fields{"deviceId": deviceId})
- rpc := "DeviceStateUpdate"
- // Use a device specific topic to send the request. The adapter handling the device creates a device
- // specific topic
- toTopic := ap.getCoreTopic(deviceId)
- args := make([]*kafka.KVArg, 3)
- id := &voltha.ID{Id: deviceId}
- oStatus := &ic.IntType{Val: int64(operStatus)}
- cStatus := &ic.IntType{Val: int64(connStatus)}
-
- args[0] = &kafka.KVArg{
- Key: "device_id",
- Value: id,
- }
- args[1] = &kafka.KVArg{
- Key: "oper_status",
- Value: oStatus,
- }
- args[2] = &kafka.KVArg{
- Key: "connect_status",
- Value: cStatus,
- }
- // Use a device specific topic as we are the only adaptercore handling requests for this device
- replyToTopic := ap.getAdapterTopic()
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw("DeviceStateUpdate-response", log.Fields{"deviceId": deviceId, "success": success})
- return unPackResponse(rpc, deviceId, success, result)
-}
-
-func (ap *CoreProxy) ChildDeviceDetected(ctx context.Context, parentDeviceId string, parentPortNo int,
- childDeviceType string, channelId int, vendorId string, serialNumber string, onuId int64) (*voltha.Device, error) {
- logger.Debugw("ChildDeviceDetected", log.Fields{"pDeviceId": parentDeviceId, "channelId": channelId})
- rpc := "ChildDeviceDetected"
- // Use a device specific topic to send the request. The adapter handling the device creates a device
- // specific topic
- toTopic := ap.getCoreTopic(parentDeviceId)
- replyToTopic := ap.getAdapterTopic()
-
- args := make([]*kafka.KVArg, 7)
- id := &voltha.ID{Id: parentDeviceId}
- args[0] = &kafka.KVArg{
- Key: "parent_device_id",
- Value: id,
- }
- ppn := &ic.IntType{Val: int64(parentPortNo)}
- args[1] = &kafka.KVArg{
- Key: "parent_port_no",
- Value: ppn,
- }
- cdt := &ic.StrType{Val: childDeviceType}
- args[2] = &kafka.KVArg{
- Key: "child_device_type",
- Value: cdt,
- }
- channel := &ic.IntType{Val: int64(channelId)}
- args[3] = &kafka.KVArg{
- Key: "channel_id",
- Value: channel,
- }
- vId := &ic.StrType{Val: vendorId}
- args[4] = &kafka.KVArg{
- Key: "vendor_id",
- Value: vId,
- }
- sNo := &ic.StrType{Val: serialNumber}
- args[5] = &kafka.KVArg{
- Key: "serial_number",
- Value: sNo,
- }
- oId := &ic.IntType{Val: int64(onuId)}
- args[6] = &kafka.KVArg{
- Key: "onu_id",
- Value: oId,
- }
-
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw("ChildDeviceDetected-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
-
- if success {
- volthaDevice := &voltha.Device{}
- if err := ptypes.UnmarshalAny(result, volthaDevice); err != nil {
- logger.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
- return nil, status.Error(codes.InvalidArgument, err.Error())
- }
- return volthaDevice, nil
- } else {
- unpackResult := &ic.Error{}
- var err error
- if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
- logger.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
- }
- logger.Debugw("ChildDeviceDetected-return", log.Fields{"deviceid": parentDeviceId, "success": success, "error": err})
-
- return nil, status.Error(ICProxyErrorCodeToGrpcErrorCode(unpackResult.Code), unpackResult.Reason)
- }
-
-}
-
-func (ap *CoreProxy) ChildDevicesLost(ctx context.Context, parentDeviceId string) error {
- logger.Debugw("ChildDevicesLost", log.Fields{"pDeviceId": parentDeviceId})
- rpc := "ChildDevicesLost"
- // Use a device specific topic to send the request. The adapter handling the device creates a device
- // specific topic
- toTopic := ap.getCoreTopic(parentDeviceId)
- replyToTopic := ap.getAdapterTopic()
-
- args := make([]*kafka.KVArg, 1)
- id := &voltha.ID{Id: parentDeviceId}
- args[0] = &kafka.KVArg{
- Key: "parent_device_id",
- Value: id,
- }
-
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw("ChildDevicesLost-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
- return unPackResponse(rpc, parentDeviceId, success, result)
-}
-
-func (ap *CoreProxy) ChildDevicesDetected(ctx context.Context, parentDeviceId string) error {
- logger.Debugw("ChildDevicesDetected", log.Fields{"pDeviceId": parentDeviceId})
- rpc := "ChildDevicesDetected"
- // Use a device specific topic to send the request. The adapter handling the device creates a device
- // specific topic
- toTopic := ap.getCoreTopic(parentDeviceId)
- replyToTopic := ap.getAdapterTopic()
-
- args := make([]*kafka.KVArg, 1)
- id := &voltha.ID{Id: parentDeviceId}
- args[0] = &kafka.KVArg{
- Key: "parent_device_id",
- Value: id,
- }
-
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw("ChildDevicesDetected-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
- return unPackResponse(rpc, parentDeviceId, success, result)
-}
-
-func (ap *CoreProxy) GetDevice(ctx context.Context, parentDeviceId string, deviceId string) (*voltha.Device, error) {
- logger.Debugw("GetDevice", log.Fields{"deviceId": deviceId})
- rpc := "GetDevice"
-
- toTopic := ap.getCoreTopic(parentDeviceId)
- replyToTopic := ap.getAdapterTopic()
-
- args := make([]*kafka.KVArg, 1)
- id := &voltha.ID{Id: deviceId}
- args[0] = &kafka.KVArg{
- Key: "device_id",
- Value: id,
- }
-
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw("GetDevice-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
-
- if success {
- volthaDevice := &voltha.Device{}
- if err := ptypes.UnmarshalAny(result, volthaDevice); err != nil {
- logger.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
- return nil, status.Error(codes.InvalidArgument, err.Error())
- }
- return volthaDevice, nil
- } else {
- unpackResult := &ic.Error{}
- var err error
- if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
- logger.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
- }
- logger.Debugw("GetDevice-return", log.Fields{"deviceid": parentDeviceId, "success": success, "error": err})
- // TODO: Need to get the real error code
- return nil, status.Error(ICProxyErrorCodeToGrpcErrorCode(unpackResult.Code), unpackResult.Reason)
- }
-}
-
-func (ap *CoreProxy) GetChildDevice(ctx context.Context, parentDeviceId string, kwargs map[string]interface{}) (*voltha.Device, error) {
- logger.Debugw("GetChildDevice", log.Fields{"parentDeviceId": parentDeviceId, "kwargs": kwargs})
- rpc := "GetChildDevice"
-
- toTopic := ap.getCoreTopic(parentDeviceId)
- replyToTopic := ap.getAdapterTopic()
-
- args := make([]*kafka.KVArg, 4)
- id := &voltha.ID{Id: parentDeviceId}
- args[0] = &kafka.KVArg{
- Key: "device_id",
- Value: id,
- }
-
- var cnt uint8 = 0
- for k, v := range kwargs {
- cnt += 1
- if k == "serial_number" {
- val := &ic.StrType{Val: v.(string)}
- args[cnt] = &kafka.KVArg{
- Key: k,
- Value: val,
- }
- } else if k == "onu_id" {
- val := &ic.IntType{Val: int64(v.(uint32))}
- args[cnt] = &kafka.KVArg{
- Key: k,
- Value: val,
- }
- } else if k == "parent_port_no" {
- val := &ic.IntType{Val: int64(v.(uint32))}
- args[cnt] = &kafka.KVArg{
- Key: k,
- Value: val,
- }
- }
- }
-
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw("GetChildDevice-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
-
- if success {
- volthaDevice := &voltha.Device{}
- if err := ptypes.UnmarshalAny(result, volthaDevice); err != nil {
- logger.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
- return nil, status.Error(codes.InvalidArgument, err.Error())
- }
- return volthaDevice, nil
- } else {
- unpackResult := &ic.Error{}
- var err error
- if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
- logger.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
- }
- logger.Debugw("GetChildDevice-return", log.Fields{"deviceid": parentDeviceId, "success": success, "error": err})
-
- return nil, status.Error(ICProxyErrorCodeToGrpcErrorCode(unpackResult.Code), unpackResult.Reason)
- }
-}
-
-func (ap *CoreProxy) GetChildDevices(ctx context.Context, parentDeviceId string) (*voltha.Devices, error) {
- logger.Debugw("GetChildDevices", log.Fields{"parentDeviceId": parentDeviceId})
- rpc := "GetChildDevices"
-
- toTopic := ap.getCoreTopic(parentDeviceId)
- replyToTopic := ap.getAdapterTopic()
-
- args := make([]*kafka.KVArg, 1)
- id := &voltha.ID{Id: parentDeviceId}
- args[0] = &kafka.KVArg{
- Key: "device_id",
- Value: id,
- }
-
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw("GetChildDevices-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
-
- if success {
- volthaDevices := &voltha.Devices{}
- if err := ptypes.UnmarshalAny(result, volthaDevices); err != nil {
- logger.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
- return nil, status.Error(codes.InvalidArgument, err.Error())
- }
- return volthaDevices, nil
- } else {
- unpackResult := &ic.Error{}
- var err error
- if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
- logger.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
- }
- logger.Debugw("GetChildDevices-return", log.Fields{"deviceid": parentDeviceId, "success": success, "error": err})
-
- return nil, status.Error(ICProxyErrorCodeToGrpcErrorCode(unpackResult.Code), unpackResult.Reason)
- }
-}
-
-func (ap *CoreProxy) SendPacketIn(ctx context.Context, deviceId string, port uint32, pktPayload []byte) error {
- logger.Debugw("SendPacketIn", log.Fields{"deviceId": deviceId, "port": port, "pktPayload": pktPayload})
- rpc := "PacketIn"
- // Use a device specific topic to send the request. The adapter handling the device creates a device
- // specific topic
- toTopic := ap.getCoreTopic(deviceId)
- replyToTopic := ap.getAdapterTopic()
-
- args := make([]*kafka.KVArg, 3)
- id := &voltha.ID{Id: deviceId}
- args[0] = &kafka.KVArg{
- Key: "device_id",
- Value: id,
- }
- portNo := &ic.IntType{Val: int64(port)}
- args[1] = &kafka.KVArg{
- Key: "port",
- Value: portNo,
- }
- pkt := &ic.Packet{Payload: pktPayload}
- args[2] = &kafka.KVArg{
- Key: "packet",
- Value: pkt,
- }
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw("SendPacketIn-response", log.Fields{"pDeviceId": deviceId, "success": success})
- return unPackResponse(rpc, deviceId, success, result)
-}
-
-func (ap *CoreProxy) DeviceReasonUpdate(ctx context.Context, deviceId string, deviceReason string) error {
- logger.Debugw("DeviceReasonUpdate", log.Fields{"deviceId": deviceId, "deviceReason": deviceReason})
- rpc := "DeviceReasonUpdate"
- // Use a device specific topic to send the request. The adapter handling the device creates a device
- // specific topic
- toTopic := ap.getCoreTopic(deviceId)
- replyToTopic := ap.getAdapterTopic()
-
- args := make([]*kafka.KVArg, 2)
- id := &voltha.ID{Id: deviceId}
- args[0] = &kafka.KVArg{
- Key: "device_id",
- Value: id,
- }
- reason := &ic.StrType{Val: deviceReason}
- args[1] = &kafka.KVArg{
- Key: "device_reason",
- Value: reason,
- }
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw("DeviceReason-response", log.Fields{"pDeviceId": deviceId, "success": success})
- return unPackResponse(rpc, deviceId, success, result)
-}
-
-func (ap *CoreProxy) DevicePMConfigUpdate(ctx context.Context, pmConfigs *voltha.PmConfigs) error {
- logger.Debugw("DevicePMConfigUpdate", log.Fields{"pmConfigs": pmConfigs})
- rpc := "DevicePMConfigUpdate"
- // Use a device specific topic to send the request. The adapter handling the device creates a device
- // specific topic
- toTopic := ap.getCoreTopic(pmConfigs.Id)
- replyToTopic := ap.getAdapterTopic()
-
- args := make([]*kafka.KVArg, 1)
- args[0] = &kafka.KVArg{
- Key: "device_pm_config",
- Value: pmConfigs,
- }
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, pmConfigs.Id, args...)
- logger.Debugw("DevicePMConfigUpdate-response", log.Fields{"pDeviceId": pmConfigs.Id, "success": success})
- return unPackResponse(rpc, pmConfigs.Id, success, result)
-}
-
-func (ap *CoreProxy) ReconcileChildDevices(ctx context.Context, parentDeviceId string) error {
- logger.Debugw("ReconcileChildDevices", log.Fields{"parentDeviceId": parentDeviceId})
- rpc := "ReconcileChildDevices"
- // Use a device specific topic to send the request. The adapter handling the device creates a device
- // specific topic
- toTopic := ap.getCoreTopic(parentDeviceId)
- replyToTopic := ap.getAdapterTopic()
-
- args := []*kafka.KVArg{
- {Key: "parent_device_id", Value: &voltha.ID{Id: parentDeviceId}},
- }
-
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, parentDeviceId, args...)
- logger.Debugw("ReconcileChildDevices-response", log.Fields{"pDeviceId": parentDeviceId, "success": success})
- return unPackResponse(rpc, parentDeviceId, success, result)
-}
-
-func (ap *CoreProxy) PortStateUpdate(ctx context.Context, deviceId string, pType voltha.Port_PortType, portNum uint32,
- operStatus voltha.OperStatus_Types) error {
- logger.Debugw("PortStateUpdate", log.Fields{"deviceId": deviceId, "portType": pType, "portNo": portNum, "operation_status": operStatus})
- rpc := "PortStateUpdate"
- // Use a device specific topic to send the request. The adapter handling the device creates a device
- // specific topic
- toTopic := ap.getCoreTopic(deviceId)
- args := make([]*kafka.KVArg, 4)
- deviceID := &voltha.ID{Id: deviceId}
- portNo := &ic.IntType{Val: int64(portNum)}
- portType := &ic.IntType{Val: int64(pType)}
- oStatus := &ic.IntType{Val: int64(operStatus)}
-
- args[0] = &kafka.KVArg{
- Key: "device_id",
- Value: deviceID,
- }
- args[1] = &kafka.KVArg{
- Key: "oper_status",
- Value: oStatus,
- }
- args[2] = &kafka.KVArg{
- Key: "port_type",
- Value: portType,
- }
- args[3] = &kafka.KVArg{
- Key: "port_no",
- Value: portNo,
- }
-
- // Use a device specific topic as we are the only adaptercore handling requests for this device
- replyToTopic := ap.getAdapterTopic()
- success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, deviceId, args...)
- logger.Debugw("PortStateUpdate-response", log.Fields{"deviceId": deviceId, "success": success})
- return unPackResponse(rpc, deviceId, success, result)
-}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/iAdapter.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/iAdapter.go
deleted file mode 100644
index 1e81890..0000000
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/iAdapter.go
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package adapters
-
-import (
- ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- "github.com/opencord/voltha-protos/v3/go/openflow_13"
- "github.com/opencord/voltha-protos/v3/go/voltha"
-)
-
-//IAdapter represents the set of APIs a voltha adapter has to support.
-type IAdapter interface {
- Adapter_descriptor() error
- Device_types() (*voltha.DeviceTypes, error)
- Health() (*voltha.HealthStatus, error)
- Adopt_device(device *voltha.Device) error
- Reconcile_device(device *voltha.Device) error
- Abandon_device(device *voltha.Device) error
- Disable_device(device *voltha.Device) error
- Reenable_device(device *voltha.Device) error
- Reboot_device(device *voltha.Device) error
- Self_test_device(device *voltha.Device) error
- Delete_device(device *voltha.Device) error
- Get_device_details(device *voltha.Device) error
- Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error
- Update_flows_incrementally(device *voltha.Device, flows *openflow_13.FlowChanges, groups *openflow_13.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error
- Update_pm_config(device *voltha.Device, pm_configs *voltha.PmConfigs) error
- Receive_packet_out(deviceId string, egress_port_no int, msg *openflow_13.OfpPacketOut) error
- Suppress_event(filter *voltha.EventFilter) error
- Unsuppress_event(filter *voltha.EventFilter) error
- Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error)
- Process_inter_adapter_message(msg *ic.InterAdapterMessage) error
- Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error)
- Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error)
- Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error)
- Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error)
- Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error)
- Enable_port(deviceId string, port *voltha.Port) error
- Disable_port(deviceId string, port *voltha.Port) error
- Child_device_lost(parentDeviceId string, parentPortNo uint32, onuID uint32) error
- Start_omci_test(device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error)
- Get_ext_value(deviceId string, device *voltha.Device, valueflag voltha.ValueType_Type) (*voltha.ReturnValues, error)
-}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/kafka_inter_container_library.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/kafka_inter_container_library.go
deleted file mode 100644
index cbde834..0000000
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/kafka_inter_container_library.go
+++ /dev/null
@@ -1,937 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package kafka
-
-import (
- "context"
- "errors"
- "fmt"
- "reflect"
- "strings"
- "sync"
- "time"
-
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
-
- "github.com/golang/protobuf/proto"
- "github.com/golang/protobuf/ptypes"
- "github.com/golang/protobuf/ptypes/any"
- "github.com/google/uuid"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- ic "github.com/opencord/voltha-protos/v3/go/inter_container"
-)
-
-const (
- DefaultMaxRetries = 3
- DefaultRequestTimeout = 60000 // 60000 milliseconds - to handle a wider latency range
-)
-
-const (
- TransactionKey = "transactionID"
- FromTopic = "fromTopic"
-)
-
-var ErrorTransactionNotAcquired = errors.New("transaction-not-acquired")
-var ErrorTransactionInvalidId = errors.New("transaction-invalid-id")
-
-// requestHandlerChannel represents an interface associated with a channel. Whenever, an event is
-// obtained from that channel, this interface is invoked. This is used to handle
-// async requests into the Core via the kafka messaging bus
-type requestHandlerChannel struct {
- requesthandlerInterface interface{}
- ch <-chan *ic.InterContainerMessage
-}
-
-// transactionChannel represents a combination of a topic and a channel onto which a response received
-// on the kafka bus will be sent to
-type transactionChannel struct {
- topic *Topic
- ch chan *ic.InterContainerMessage
-}
-
-type InterContainerProxy interface {
- Start() error
- Stop()
- GetDefaultTopic() *Topic
- InvokeRPC(ctx context.Context, rpc string, toTopic *Topic, replyToTopic *Topic, waitForResponse bool, key string, kvArgs ...*KVArg) (bool, *any.Any)
- InvokeAsyncRPC(ctx context.Context, rpc string, toTopic *Topic, replyToTopic *Topic, waitForResponse bool, key string, kvArgs ...*KVArg) chan *RpcResponse
- SubscribeWithRequestHandlerInterface(topic Topic, handler interface{}) error
- SubscribeWithDefaultRequestHandler(topic Topic, initialOffset int64) error
- UnSubscribeFromRequestHandler(topic Topic) error
- DeleteTopic(topic Topic) error
- EnableLivenessChannel(enable bool) chan bool
- SendLiveness() error
-}
-
-// interContainerProxy represents the messaging proxy
-type interContainerProxy struct {
- kafkaAddress string
- defaultTopic *Topic
- defaultRequestHandlerInterface interface{}
- kafkaClient Client
- doneCh chan struct{}
- doneOnce sync.Once
-
- // This map is used to map a topic to an interface and channel. When a request is received
- // on that channel (registered to the topic) then that interface is invoked.
- topicToRequestHandlerChannelMap map[string]*requestHandlerChannel
- lockTopicRequestHandlerChannelMap sync.RWMutex
-
- // This map is used to map a channel to a response topic. This channel handles all responses on that
- // channel for that topic and forward them to the appropriate consumers channel, using the
- // transactionIdToChannelMap.
- topicToResponseChannelMap map[string]<-chan *ic.InterContainerMessage
- lockTopicResponseChannelMap sync.RWMutex
-
- // This map is used to map a transaction to a consumers channel. This is used whenever a request has been
- // sent out and we are waiting for a response.
- transactionIdToChannelMap map[string]*transactionChannel
- lockTransactionIdToChannelMap sync.RWMutex
-}
-
-type InterContainerProxyOption func(*interContainerProxy)
-
-func InterContainerAddress(address string) InterContainerProxyOption {
- return func(args *interContainerProxy) {
- args.kafkaAddress = address
- }
-}
-
-func DefaultTopic(topic *Topic) InterContainerProxyOption {
- return func(args *interContainerProxy) {
- args.defaultTopic = topic
- }
-}
-
-func RequestHandlerInterface(handler interface{}) InterContainerProxyOption {
- return func(args *interContainerProxy) {
- args.defaultRequestHandlerInterface = handler
- }
-}
-
-func MsgClient(client Client) InterContainerProxyOption {
- return func(args *interContainerProxy) {
- args.kafkaClient = client
- }
-}
-
-func newInterContainerProxy(opts ...InterContainerProxyOption) *interContainerProxy {
- proxy := &interContainerProxy{
- kafkaAddress: DefaultKafkaAddress,
- doneCh: make(chan struct{}),
- }
-
- for _, option := range opts {
- option(proxy)
- }
-
- return proxy
-}
-
-func NewInterContainerProxy(opts ...InterContainerProxyOption) InterContainerProxy {
- return newInterContainerProxy(opts...)
-}
-
-func (kp *interContainerProxy) Start() error {
- logger.Info("Starting-Proxy")
-
- // Kafka MsgClient should already have been created. If not, output fatal error
- if kp.kafkaClient == nil {
- logger.Fatal("kafka-client-not-set")
- }
-
- // Start the kafka client
- if err := kp.kafkaClient.Start(); err != nil {
- logger.Errorw("Cannot-create-kafka-proxy", log.Fields{"error": err})
- return err
- }
-
- // Create the topic to response channel map
- kp.topicToResponseChannelMap = make(map[string]<-chan *ic.InterContainerMessage)
- //
- // Create the transactionId to Channel Map
- kp.transactionIdToChannelMap = make(map[string]*transactionChannel)
-
- // Create the topic to request channel map
- kp.topicToRequestHandlerChannelMap = make(map[string]*requestHandlerChannel)
-
- return nil
-}
-
-func (kp *interContainerProxy) Stop() {
- logger.Info("stopping-intercontainer-proxy")
- kp.doneOnce.Do(func() { close(kp.doneCh) })
- // TODO : Perform cleanup
- kp.kafkaClient.Stop()
- err := kp.deleteAllTopicRequestHandlerChannelMap()
- if err != nil {
- logger.Errorw("failed-delete-all-topic-request-handler-channel-map", log.Fields{"error": err})
- }
- err = kp.deleteAllTopicResponseChannelMap()
- if err != nil {
- logger.Errorw("failed-delete-all-topic-response-channel-map", log.Fields{"error": err})
- }
- kp.deleteAllTransactionIdToChannelMap()
-}
-
-func (kp *interContainerProxy) GetDefaultTopic() *Topic {
- return kp.defaultTopic
-}
-
-// InvokeAsyncRPC is used to make an RPC request asynchronously
-func (kp *interContainerProxy) InvokeAsyncRPC(ctx context.Context, rpc string, toTopic *Topic, replyToTopic *Topic,
- waitForResponse bool, key string, kvArgs ...*KVArg) chan *RpcResponse {
-
- logger.Debugw("InvokeAsyncRPC", log.Fields{"rpc": rpc, "key": key})
- // If a replyToTopic is provided then we use it, otherwise just use the default toTopic. The replyToTopic is
- // typically the device ID.
- responseTopic := replyToTopic
- if responseTopic == nil {
- responseTopic = kp.GetDefaultTopic()
- }
-
- chnl := make(chan *RpcResponse)
-
- go func() {
-
- // once we're done,
- // close the response channel
- defer close(chnl)
-
- var err error
- var protoRequest *ic.InterContainerMessage
-
- // Encode the request
- protoRequest, err = encodeRequest(rpc, toTopic, responseTopic, key, kvArgs...)
- if err != nil {
- logger.Warnw("cannot-format-request", log.Fields{"rpc": rpc, "error": err})
- chnl <- NewResponse(RpcFormattingError, err, nil)
- return
- }
-
- // Subscribe for response, if needed, before sending request
- var ch <-chan *ic.InterContainerMessage
- if ch, err = kp.subscribeForResponse(*responseTopic, protoRequest.Header.Id); err != nil {
- logger.Errorw("failed-to-subscribe-for-response", log.Fields{"error": err, "toTopic": toTopic.Name})
- chnl <- NewResponse(RpcTransportError, err, nil)
- return
- }
-
- // Send request - if the topic is formatted with a device Id then we will send the request using a
- // specific key, hence ensuring a single partition is used to publish the request. This ensures that the
- // subscriber on that topic will receive the request in the order it was sent. The key used is the deviceId.
- logger.Debugw("sending-msg", log.Fields{"rpc": rpc, "toTopic": toTopic, "replyTopic": responseTopic, "key": key, "xId": protoRequest.Header.Id})
-
- // if the message is not sent on kafka publish an event an close the channel
- if err = kp.kafkaClient.Send(protoRequest, toTopic, key); err != nil {
- chnl <- NewResponse(RpcTransportError, err, nil)
- return
- }
-
- // if the client is not waiting for a response send the ack and close the channel
- chnl <- NewResponse(RpcSent, nil, nil)
- if !waitForResponse {
- return
- }
-
- defer func() {
- // Remove the subscription for a response on return
- if err := kp.unSubscribeForResponse(protoRequest.Header.Id); err != nil {
- logger.Warnw("invoke-async-rpc-unsubscriber-for-response-failed", log.Fields{"err": err})
- }
- }()
-
- // Wait for response as well as timeout or cancellation
- select {
- case msg, ok := <-ch:
- if !ok {
- logger.Warnw("channel-closed", log.Fields{"rpc": rpc, "replyTopic": replyToTopic.Name})
- chnl <- NewResponse(RpcTransportError, status.Error(codes.Aborted, "channel closed"), nil)
- }
- logger.Debugw("received-response", log.Fields{"rpc": rpc, "msgHeader": msg.Header})
- if responseBody, err := decodeResponse(msg); err != nil {
- chnl <- NewResponse(RpcReply, err, nil)
- } else {
- if responseBody.Success {
- chnl <- NewResponse(RpcReply, nil, responseBody.Result)
- } else {
- // response body contains an error
- unpackErr := &ic.Error{}
- if err := ptypes.UnmarshalAny(responseBody.Result, unpackErr); err != nil {
- chnl <- NewResponse(RpcReply, err, nil)
- } else {
- chnl <- NewResponse(RpcReply, status.Error(codes.Internal, unpackErr.Reason), nil)
- }
- }
- }
- case <-ctx.Done():
- logger.Errorw("context-cancelled", log.Fields{"rpc": rpc, "ctx": ctx.Err()})
- err := status.Error(codes.DeadlineExceeded, ctx.Err().Error())
- chnl <- NewResponse(RpcTimeout, err, nil)
- case <-kp.doneCh:
- chnl <- NewResponse(RpcSystemClosing, nil, nil)
- logger.Warnw("received-exit-signal", log.Fields{"toTopic": toTopic.Name, "rpc": rpc})
- }
- }()
- return chnl
-}
-
-// InvokeRPC is used to send a request to a given topic
-func (kp *interContainerProxy) InvokeRPC(ctx context.Context, rpc string, toTopic *Topic, replyToTopic *Topic,
- waitForResponse bool, key string, kvArgs ...*KVArg) (bool, *any.Any) {
-
- // If a replyToTopic is provided then we use it, otherwise just use the default toTopic. The replyToTopic is
- // typically the device ID.
- responseTopic := replyToTopic
- if responseTopic == nil {
- responseTopic = kp.defaultTopic
- }
-
- // Encode the request
- protoRequest, err := encodeRequest(rpc, toTopic, responseTopic, key, kvArgs...)
- if err != nil {
- logger.Warnw("cannot-format-request", log.Fields{"rpc": rpc, "error": err})
- return false, nil
- }
-
- // Subscribe for response, if needed, before sending request
- var ch <-chan *ic.InterContainerMessage
- if waitForResponse {
- var err error
- if ch, err = kp.subscribeForResponse(*responseTopic, protoRequest.Header.Id); err != nil {
- logger.Errorw("failed-to-subscribe-for-response", log.Fields{"error": err, "toTopic": toTopic.Name})
- }
- }
-
- // Send request - if the topic is formatted with a device Id then we will send the request using a
- // specific key, hence ensuring a single partition is used to publish the request. This ensures that the
- // subscriber on that topic will receive the request in the order it was sent. The key used is the deviceId.
- //key := GetDeviceIdFromTopic(*toTopic)
- logger.Debugw("sending-msg", log.Fields{"rpc": rpc, "toTopic": toTopic, "replyTopic": responseTopic, "key": key, "xId": protoRequest.Header.Id})
- go func() {
- if err := kp.kafkaClient.Send(protoRequest, toTopic, key); err != nil {
- logger.Errorw("send-failed", log.Fields{
- "topic": toTopic,
- "key": key,
- "error": err})
- }
- }()
-
- if waitForResponse {
- // Create a child context based on the parent context, if any
- var cancel context.CancelFunc
- childCtx := context.Background()
- if ctx == nil {
- ctx, cancel = context.WithTimeout(context.Background(), DefaultRequestTimeout*time.Millisecond)
- } else {
- childCtx, cancel = context.WithTimeout(ctx, DefaultRequestTimeout*time.Millisecond)
- }
- defer cancel()
-
- // Wait for response as well as timeout or cancellation
- // Remove the subscription for a response on return
- defer func() {
- if err := kp.unSubscribeForResponse(protoRequest.Header.Id); err != nil {
- logger.Errorw("response-unsubscribe-failed", log.Fields{
- "id": protoRequest.Header.Id,
- "error": err})
- }
- }()
- select {
- case msg, ok := <-ch:
- if !ok {
- logger.Warnw("channel-closed", log.Fields{"rpc": rpc, "replyTopic": replyToTopic.Name})
- protoError := &ic.Error{Reason: "channel-closed"}
- var marshalledArg *any.Any
- if marshalledArg, err = ptypes.MarshalAny(protoError); err != nil {
- return false, nil // Should never happen
- }
- return false, marshalledArg
- }
- logger.Debugw("received-response", log.Fields{"rpc": rpc, "msgHeader": msg.Header})
- var responseBody *ic.InterContainerResponseBody
- var err error
- if responseBody, err = decodeResponse(msg); err != nil {
- logger.Errorw("decode-response-error", log.Fields{"error": err})
- // FIXME we should return something
- }
- return responseBody.Success, responseBody.Result
- case <-ctx.Done():
- logger.Debugw("context-cancelled", log.Fields{"rpc": rpc, "ctx": ctx.Err()})
- // pack the error as proto any type
- protoError := &ic.Error{Reason: ctx.Err().Error(), Code: ic.ErrorCode_DEADLINE_EXCEEDED}
-
- var marshalledArg *any.Any
- if marshalledArg, err = ptypes.MarshalAny(protoError); err != nil {
- return false, nil // Should never happen
- }
- return false, marshalledArg
- case <-childCtx.Done():
- logger.Debugw("context-cancelled", log.Fields{"rpc": rpc, "ctx": childCtx.Err()})
- // pack the error as proto any type
- protoError := &ic.Error{Reason: childCtx.Err().Error(), Code: ic.ErrorCode_DEADLINE_EXCEEDED}
-
- var marshalledArg *any.Any
- if marshalledArg, err = ptypes.MarshalAny(protoError); err != nil {
- return false, nil // Should never happen
- }
- return false, marshalledArg
- case <-kp.doneCh:
- logger.Infow("received-exit-signal", log.Fields{"toTopic": toTopic.Name, "rpc": rpc})
- return true, nil
- }
- }
- return true, nil
-}
-
-// SubscribeWithRequestHandlerInterface allows a caller to assign a target object to be invoked automatically
-// when a message is received on a given topic
-func (kp *interContainerProxy) SubscribeWithRequestHandlerInterface(topic Topic, handler interface{}) error {
-
- // Subscribe to receive messages for that topic
- var ch <-chan *ic.InterContainerMessage
- var err error
- if ch, err = kp.kafkaClient.Subscribe(&topic); err != nil {
- //if ch, err = kp.Subscribe(topic); err != nil {
- logger.Errorw("failed-to-subscribe", log.Fields{"error": err, "topic": topic.Name})
- return err
- }
-
- kp.defaultRequestHandlerInterface = handler
- kp.addToTopicRequestHandlerChannelMap(topic.Name, &requestHandlerChannel{requesthandlerInterface: handler, ch: ch})
- // Launch a go routine to receive and process kafka messages
- go kp.waitForMessages(ch, topic, handler)
-
- return nil
-}
-
-// SubscribeWithDefaultRequestHandler allows a caller to add a topic to an existing target object to be invoked automatically
-// when a message is received on a given topic. So far there is only 1 target registered per microservice
-func (kp *interContainerProxy) SubscribeWithDefaultRequestHandler(topic Topic, initialOffset int64) error {
- // Subscribe to receive messages for that topic
- var ch <-chan *ic.InterContainerMessage
- var err error
- if ch, err = kp.kafkaClient.Subscribe(&topic, &KVArg{Key: Offset, Value: initialOffset}); err != nil {
- logger.Errorw("failed-to-subscribe", log.Fields{"error": err, "topic": topic.Name})
- return err
- }
- kp.addToTopicRequestHandlerChannelMap(topic.Name, &requestHandlerChannel{requesthandlerInterface: kp.defaultRequestHandlerInterface, ch: ch})
-
- // Launch a go routine to receive and process kafka messages
- go kp.waitForMessages(ch, topic, kp.defaultRequestHandlerInterface)
-
- return nil
-}
-
-func (kp *interContainerProxy) UnSubscribeFromRequestHandler(topic Topic) error {
- return kp.deleteFromTopicRequestHandlerChannelMap(topic.Name)
-}
-
-func (kp *interContainerProxy) deleteFromTopicResponseChannelMap(topic string) error {
- kp.lockTopicResponseChannelMap.Lock()
- defer kp.lockTopicResponseChannelMap.Unlock()
- if _, exist := kp.topicToResponseChannelMap[topic]; exist {
- // Unsubscribe to this topic first - this will close the subscribed channel
- var err error
- if err = kp.kafkaClient.UnSubscribe(&Topic{Name: topic}, kp.topicToResponseChannelMap[topic]); err != nil {
- logger.Errorw("unsubscribing-error", log.Fields{"topic": topic})
- }
- delete(kp.topicToResponseChannelMap, topic)
- return err
- } else {
- return fmt.Errorf("%s-Topic-not-found", topic)
- }
-}
-
-// nolint: unused
-func (kp *interContainerProxy) deleteAllTopicResponseChannelMap() error {
- logger.Debug("delete-all-topic-response-channel")
- kp.lockTopicResponseChannelMap.Lock()
- defer kp.lockTopicResponseChannelMap.Unlock()
- var unsubscribeFailTopics []string
- for topic := range kp.topicToResponseChannelMap {
- // Unsubscribe to this topic first - this will close the subscribed channel
- if err := kp.kafkaClient.UnSubscribe(&Topic{Name: topic}, kp.topicToResponseChannelMap[topic]); err != nil {
- unsubscribeFailTopics = append(unsubscribeFailTopics, topic)
- logger.Errorw("unsubscribing-error", log.Fields{"topic": topic, "error": err})
- // Do not return. Continue to try to unsubscribe to other topics.
- } else {
- // Only delete from channel map if successfully unsubscribed.
- delete(kp.topicToResponseChannelMap, topic)
- }
- }
- if len(unsubscribeFailTopics) > 0 {
- return fmt.Errorf("unsubscribe-errors: %v", unsubscribeFailTopics)
- }
- return nil
-}
-
-func (kp *interContainerProxy) addToTopicRequestHandlerChannelMap(topic string, arg *requestHandlerChannel) {
- kp.lockTopicRequestHandlerChannelMap.Lock()
- defer kp.lockTopicRequestHandlerChannelMap.Unlock()
- if _, exist := kp.topicToRequestHandlerChannelMap[topic]; !exist {
- kp.topicToRequestHandlerChannelMap[topic] = arg
- }
-}
-
-func (kp *interContainerProxy) deleteFromTopicRequestHandlerChannelMap(topic string) error {
- kp.lockTopicRequestHandlerChannelMap.Lock()
- defer kp.lockTopicRequestHandlerChannelMap.Unlock()
- if _, exist := kp.topicToRequestHandlerChannelMap[topic]; exist {
- // Close the kafka client client first by unsubscribing to this topic
- if err := kp.kafkaClient.UnSubscribe(&Topic{Name: topic}, kp.topicToRequestHandlerChannelMap[topic].ch); err != nil {
- return err
- }
- delete(kp.topicToRequestHandlerChannelMap, topic)
- return nil
- } else {
- return fmt.Errorf("%s-Topic-not-found", topic)
- }
-}
-
-// nolint: unused
-func (kp *interContainerProxy) deleteAllTopicRequestHandlerChannelMap() error {
- logger.Debug("delete-all-topic-request-channel")
- kp.lockTopicRequestHandlerChannelMap.Lock()
- defer kp.lockTopicRequestHandlerChannelMap.Unlock()
- var unsubscribeFailTopics []string
- for topic := range kp.topicToRequestHandlerChannelMap {
- // Close the kafka client client first by unsubscribing to this topic
- if err := kp.kafkaClient.UnSubscribe(&Topic{Name: topic}, kp.topicToRequestHandlerChannelMap[topic].ch); err != nil {
- unsubscribeFailTopics = append(unsubscribeFailTopics, topic)
- logger.Errorw("unsubscribing-error", log.Fields{"topic": topic, "error": err})
- // Do not return. Continue to try to unsubscribe to other topics.
- } else {
- // Only delete from channel map if successfully unsubscribed.
- delete(kp.topicToRequestHandlerChannelMap, topic)
- }
- }
- if len(unsubscribeFailTopics) > 0 {
- return fmt.Errorf("unsubscribe-errors: %v", unsubscribeFailTopics)
- }
- return nil
-}
-
-func (kp *interContainerProxy) addToTransactionIdToChannelMap(id string, topic *Topic, arg chan *ic.InterContainerMessage) {
- kp.lockTransactionIdToChannelMap.Lock()
- defer kp.lockTransactionIdToChannelMap.Unlock()
- if _, exist := kp.transactionIdToChannelMap[id]; !exist {
- kp.transactionIdToChannelMap[id] = &transactionChannel{topic: topic, ch: arg}
- }
-}
-
-func (kp *interContainerProxy) deleteFromTransactionIdToChannelMap(id string) {
- kp.lockTransactionIdToChannelMap.Lock()
- defer kp.lockTransactionIdToChannelMap.Unlock()
- if transChannel, exist := kp.transactionIdToChannelMap[id]; exist {
- // Close the channel first
- close(transChannel.ch)
- delete(kp.transactionIdToChannelMap, id)
- }
-}
-
-func (kp *interContainerProxy) deleteTopicTransactionIdToChannelMap(id string) {
- kp.lockTransactionIdToChannelMap.Lock()
- defer kp.lockTransactionIdToChannelMap.Unlock()
- for key, value := range kp.transactionIdToChannelMap {
- if value.topic.Name == id {
- close(value.ch)
- delete(kp.transactionIdToChannelMap, key)
- }
- }
-}
-
-// nolint: unused
-func (kp *interContainerProxy) deleteAllTransactionIdToChannelMap() {
- logger.Debug("delete-all-transaction-id-channel-map")
- kp.lockTransactionIdToChannelMap.Lock()
- defer kp.lockTransactionIdToChannelMap.Unlock()
- for key, value := range kp.transactionIdToChannelMap {
- close(value.ch)
- delete(kp.transactionIdToChannelMap, key)
- }
-}
-
-func (kp *interContainerProxy) DeleteTopic(topic Topic) error {
- // If we have any consumers on that topic we need to close them
- if err := kp.deleteFromTopicResponseChannelMap(topic.Name); err != nil {
- logger.Errorw("delete-from-topic-responsechannelmap-failed", log.Fields{"error": err})
- }
- if err := kp.deleteFromTopicRequestHandlerChannelMap(topic.Name); err != nil {
- logger.Errorw("delete-from-topic-requesthandlerchannelmap-failed", log.Fields{"error": err})
- }
- kp.deleteTopicTransactionIdToChannelMap(topic.Name)
-
- return kp.kafkaClient.DeleteTopic(&topic)
-}
-
-func encodeReturnedValue(returnedVal interface{}) (*any.Any, error) {
- // Encode the response argument - needs to be a proto message
- if returnedVal == nil {
- return nil, nil
- }
- protoValue, ok := returnedVal.(proto.Message)
- if !ok {
- logger.Warnw("response-value-not-proto-message", log.Fields{"error": ok, "returnVal": returnedVal})
- err := errors.New("response-value-not-proto-message")
- return nil, err
- }
-
- // Marshal the returned value, if any
- var marshalledReturnedVal *any.Any
- var err error
- if marshalledReturnedVal, err = ptypes.MarshalAny(protoValue); err != nil {
- logger.Warnw("cannot-marshal-returned-val", log.Fields{"error": err})
- return nil, err
- }
- return marshalledReturnedVal, nil
-}
-
-func encodeDefaultFailedResponse(request *ic.InterContainerMessage) *ic.InterContainerMessage {
- responseHeader := &ic.Header{
- Id: request.Header.Id,
- Type: ic.MessageType_RESPONSE,
- FromTopic: request.Header.ToTopic,
- ToTopic: request.Header.FromTopic,
- Timestamp: ptypes.TimestampNow(),
- }
- responseBody := &ic.InterContainerResponseBody{
- Success: false,
- Result: nil,
- }
- var marshalledResponseBody *any.Any
- var err error
- // Error should never happen here
- if marshalledResponseBody, err = ptypes.MarshalAny(responseBody); err != nil {
- logger.Warnw("cannot-marshal-failed-response-body", log.Fields{"error": err})
- }
-
- return &ic.InterContainerMessage{
- Header: responseHeader,
- Body: marshalledResponseBody,
- }
-
-}
-
-//formatRequest formats a request to send over kafka and returns an InterContainerMessage message on success
-//or an error on failure
-func encodeResponse(request *ic.InterContainerMessage, success bool, returnedValues ...interface{}) (*ic.InterContainerMessage, error) {
- //logger.Debugw("encodeResponse", log.Fields{"success": success, "returnedValues": returnedValues})
- responseHeader := &ic.Header{
- Id: request.Header.Id,
- Type: ic.MessageType_RESPONSE,
- FromTopic: request.Header.ToTopic,
- ToTopic: request.Header.FromTopic,
- KeyTopic: request.Header.KeyTopic,
- Timestamp: ptypes.TimestampNow(),
- }
-
- // Go over all returned values
- var marshalledReturnedVal *any.Any
- var err error
-
- // for now we support only 1 returned value - (excluding the error)
- if len(returnedValues) > 0 {
- if marshalledReturnedVal, err = encodeReturnedValue(returnedValues[0]); err != nil {
- logger.Warnw("cannot-marshal-response-body", log.Fields{"error": err})
- }
- }
-
- responseBody := &ic.InterContainerResponseBody{
- Success: success,
- Result: marshalledReturnedVal,
- }
-
- // Marshal the response body
- var marshalledResponseBody *any.Any
- if marshalledResponseBody, err = ptypes.MarshalAny(responseBody); err != nil {
- logger.Warnw("cannot-marshal-response-body", log.Fields{"error": err})
- return nil, err
- }
-
- return &ic.InterContainerMessage{
- Header: responseHeader,
- Body: marshalledResponseBody,
- }, nil
-}
-
-func CallFuncByName(myClass interface{}, funcName string, params ...interface{}) (out []reflect.Value, err error) {
- myClassValue := reflect.ValueOf(myClass)
- // Capitalize the first letter in the funcName to workaround the first capital letters required to
- // invoke a function from a different package
- funcName = strings.Title(funcName)
- m := myClassValue.MethodByName(funcName)
- if !m.IsValid() {
- return make([]reflect.Value, 0), fmt.Errorf("method-not-found \"%s\"", funcName)
- }
- in := make([]reflect.Value, len(params))
- for i, param := range params {
- in[i] = reflect.ValueOf(param)
- }
- out = m.Call(in)
- return
-}
-
-func (kp *interContainerProxy) addTransactionId(transactionId string, currentArgs []*ic.Argument) []*ic.Argument {
- arg := &KVArg{
- Key: TransactionKey,
- Value: &ic.StrType{Val: transactionId},
- }
-
- var marshalledArg *any.Any
- var err error
- if marshalledArg, err = ptypes.MarshalAny(&ic.StrType{Val: transactionId}); err != nil {
- logger.Warnw("cannot-add-transactionId", log.Fields{"error": err})
- return currentArgs
- }
- protoArg := &ic.Argument{
- Key: arg.Key,
- Value: marshalledArg,
- }
- return append(currentArgs, protoArg)
-}
-
-func (kp *interContainerProxy) addFromTopic(fromTopic string, currentArgs []*ic.Argument) []*ic.Argument {
- var marshalledArg *any.Any
- var err error
- if marshalledArg, err = ptypes.MarshalAny(&ic.StrType{Val: fromTopic}); err != nil {
- logger.Warnw("cannot-add-transactionId", log.Fields{"error": err})
- return currentArgs
- }
- protoArg := &ic.Argument{
- Key: FromTopic,
- Value: marshalledArg,
- }
- return append(currentArgs, protoArg)
-}
-
-func (kp *interContainerProxy) handleMessage(msg *ic.InterContainerMessage, targetInterface interface{}) {
-
- // First extract the header to know whether this is a request - responses are handled by a different handler
- if msg.Header.Type == ic.MessageType_REQUEST {
- var out []reflect.Value
- var err error
-
- // Get the request body
- requestBody := &ic.InterContainerRequestBody{}
- if err = ptypes.UnmarshalAny(msg.Body, requestBody); err != nil {
- logger.Warnw("cannot-unmarshal-request", log.Fields{"error": err})
- } else {
- logger.Debugw("received-request", log.Fields{"rpc": requestBody.Rpc, "header": msg.Header})
- // let the callee unpack the arguments as its the only one that knows the real proto type
- // Augment the requestBody with the message Id as it will be used in scenarios where cores
- // are set in pairs and competing
- requestBody.Args = kp.addTransactionId(msg.Header.Id, requestBody.Args)
-
- // Augment the requestBody with the From topic name as it will be used in scenarios where a container
- // needs to send an unsollicited message to the currently requested container
- requestBody.Args = kp.addFromTopic(msg.Header.FromTopic, requestBody.Args)
-
- out, err = CallFuncByName(targetInterface, requestBody.Rpc, requestBody.Args)
- if err != nil {
- logger.Warn(err)
- }
- }
- // Response required?
- if requestBody.ResponseRequired {
- // If we already have an error before then just return that
- var returnError *ic.Error
- var returnedValues []interface{}
- var success bool
- if err != nil {
- returnError = &ic.Error{Reason: err.Error()}
- returnedValues = make([]interface{}, 1)
- returnedValues[0] = returnError
- } else {
- returnedValues = make([]interface{}, 0)
- // Check for errors first
- lastIndex := len(out) - 1
- if out[lastIndex].Interface() != nil { // Error
- if retError, ok := out[lastIndex].Interface().(error); ok {
- if retError.Error() == ErrorTransactionNotAcquired.Error() {
- logger.Debugw("Ignoring request", log.Fields{"error": retError, "txId": msg.Header.Id})
- return // Ignore - process is in competing mode and ignored transaction
- }
- returnError = &ic.Error{Reason: retError.Error()}
- returnedValues = append(returnedValues, returnError)
- } else { // Should never happen
- returnError = &ic.Error{Reason: "incorrect-error-returns"}
- returnedValues = append(returnedValues, returnError)
- }
- } else if len(out) == 2 && reflect.ValueOf(out[0].Interface()).IsValid() && reflect.ValueOf(out[0].Interface()).IsNil() {
- logger.Warnw("Unexpected response of (nil,nil)", log.Fields{"txId": msg.Header.Id})
- return // Ignore - should not happen
- } else { // Non-error case
- success = true
- for idx, val := range out {
- //logger.Debugw("returned-api-response-loop", log.Fields{"idx": idx, "val": val.Interface()})
- if idx != lastIndex {
- returnedValues = append(returnedValues, val.Interface())
- }
- }
- }
- }
-
- var icm *ic.InterContainerMessage
- if icm, err = encodeResponse(msg, success, returnedValues...); err != nil {
- logger.Warnw("error-encoding-response-returning-failure-result", log.Fields{"error": err})
- icm = encodeDefaultFailedResponse(msg)
- }
- // To preserve ordering of messages, all messages to a given topic are sent to the same partition
- // by providing a message key. The key is encoded in the topic name. If the deviceId is not
- // present then the key will be empty, hence all messages for a given topic will be sent to all
- // partitions.
- replyTopic := &Topic{Name: msg.Header.FromTopic}
- key := msg.Header.KeyTopic
- logger.Debugw("sending-response-to-kafka", log.Fields{"rpc": requestBody.Rpc, "header": icm.Header, "key": key})
- // TODO: handle error response.
- go func() {
- if err := kp.kafkaClient.Send(icm, replyTopic, key); err != nil {
- logger.Errorw("send-reply-failed", log.Fields{
- "topic": replyTopic,
- "key": key,
- "error": err})
- }
- }()
- }
- } else if msg.Header.Type == ic.MessageType_RESPONSE {
- logger.Debugw("response-received", log.Fields{"msg-header": msg.Header})
- go kp.dispatchResponse(msg)
- } else {
- logger.Warnw("unsupported-message-received", log.Fields{"msg-header": msg.Header})
- }
-}
-
-func (kp *interContainerProxy) waitForMessages(ch <-chan *ic.InterContainerMessage, topic Topic, targetInterface interface{}) {
- // Wait for messages
- for msg := range ch {
- //logger.Debugw("request-received", log.Fields{"msg": msg, "topic": topic.Name, "target": targetInterface})
- go kp.handleMessage(msg, targetInterface)
- }
-}
-
-func (kp *interContainerProxy) dispatchResponse(msg *ic.InterContainerMessage) {
- kp.lockTransactionIdToChannelMap.RLock()
- defer kp.lockTransactionIdToChannelMap.RUnlock()
- if _, exist := kp.transactionIdToChannelMap[msg.Header.Id]; !exist {
- logger.Debugw("no-waiting-channel", log.Fields{"transaction": msg.Header.Id})
- return
- }
- kp.transactionIdToChannelMap[msg.Header.Id].ch <- msg
-}
-
-// subscribeForResponse allows a caller to subscribe to a given topic when waiting for a response.
-// This method is built to prevent all subscribers to receive all messages as is the case of the Subscribe
-// API. There is one response channel waiting for kafka messages before dispatching the message to the
-// corresponding waiting channel
-func (kp *interContainerProxy) subscribeForResponse(topic Topic, trnsId string) (chan *ic.InterContainerMessage, error) {
- logger.Debugw("subscribeForResponse", log.Fields{"topic": topic.Name, "trnsid": trnsId})
-
- // Create a specific channel for this consumers. We cannot use the channel from the kafkaclient as it will
- // broadcast any message for this topic to all channels waiting on it.
- // Set channel size to 1 to prevent deadlock, see VOL-2708
- ch := make(chan *ic.InterContainerMessage, 1)
- kp.addToTransactionIdToChannelMap(trnsId, &topic, ch)
-
- return ch, nil
-}
-
-func (kp *interContainerProxy) unSubscribeForResponse(trnsId string) error {
- logger.Debugw("unsubscribe-for-response", log.Fields{"trnsId": trnsId})
- kp.deleteFromTransactionIdToChannelMap(trnsId)
- return nil
-}
-
-func (kp *interContainerProxy) EnableLivenessChannel(enable bool) chan bool {
- return kp.kafkaClient.EnableLivenessChannel(enable)
-}
-
-func (kp *interContainerProxy) EnableHealthinessChannel(enable bool) chan bool {
- return kp.kafkaClient.EnableHealthinessChannel(enable)
-}
-
-func (kp *interContainerProxy) SendLiveness() error {
- return kp.kafkaClient.SendLiveness()
-}
-
-//formatRequest formats a request to send over kafka and returns an InterContainerMessage message on success
-//or an error on failure
-func encodeRequest(rpc string, toTopic *Topic, replyTopic *Topic, key string, kvArgs ...*KVArg) (*ic.InterContainerMessage, error) {
- requestHeader := &ic.Header{
- Id: uuid.New().String(),
- Type: ic.MessageType_REQUEST,
- FromTopic: replyTopic.Name,
- ToTopic: toTopic.Name,
- KeyTopic: key,
- Timestamp: ptypes.TimestampNow(),
- }
- requestBody := &ic.InterContainerRequestBody{
- Rpc: rpc,
- ResponseRequired: true,
- ReplyToTopic: replyTopic.Name,
- }
-
- for _, arg := range kvArgs {
- if arg == nil {
- // In case the caller sends an array with empty args
- continue
- }
- var marshalledArg *any.Any
- var err error
- // ascertain the value interface type is a proto.Message
- protoValue, ok := arg.Value.(proto.Message)
- if !ok {
- logger.Warnw("argument-value-not-proto-message", log.Fields{"error": ok, "Value": arg.Value})
- err := errors.New("argument-value-not-proto-message")
- return nil, err
- }
- if marshalledArg, err = ptypes.MarshalAny(protoValue); err != nil {
- logger.Warnw("cannot-marshal-request", log.Fields{"error": err})
- return nil, err
- }
- protoArg := &ic.Argument{
- Key: arg.Key,
- Value: marshalledArg,
- }
- requestBody.Args = append(requestBody.Args, protoArg)
- }
-
- var marshalledData *any.Any
- var err error
- if marshalledData, err = ptypes.MarshalAny(requestBody); err != nil {
- logger.Warnw("cannot-marshal-request", log.Fields{"error": err})
- return nil, err
- }
- request := &ic.InterContainerMessage{
- Header: requestHeader,
- Body: marshalledData,
- }
- return request, nil
-}
-
-func decodeResponse(response *ic.InterContainerMessage) (*ic.InterContainerResponseBody, error) {
- // Extract the message body
- responseBody := ic.InterContainerResponseBody{}
- if err := ptypes.UnmarshalAny(response.Body, &responseBody); err != nil {
- logger.Warnw("cannot-unmarshal-response", log.Fields{"error": err})
- return nil, err
- }
- //logger.Debugw("response-decoded-successfully", log.Fields{"response-status": &responseBody.Success})
-
- return &responseBody, nil
-
-}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/log/log_classic.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/log/log_classic.go
deleted file mode 100644
index b47b562..0000000
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/log/log_classic.go
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Older Version of Logger interface without support of Context Injection
-// This is Depreciated and should not be used anymore. Instead use CLogger
-// defined in log.go file.
-// This file will be deleted once all code files of voltha compopnents have been
-// changed to use new CLogger interface methods supporting context injection
-package log
-
-import (
- zp "go.uber.org/zap"
-)
-
-// Logger represents an abstract logging interface. Any logging implementation used
-// will need to abide by this interface
-type Logger interface {
- Debug(...interface{})
- Debugln(...interface{})
- Debugf(string, ...interface{})
- Debugw(string, Fields)
-
- Info(...interface{})
- Infoln(...interface{})
- Infof(string, ...interface{})
- Infow(string, Fields)
-
- Warn(...interface{})
- Warnln(...interface{})
- Warnf(string, ...interface{})
- Warnw(string, Fields)
-
- Error(...interface{})
- Errorln(...interface{})
- Errorf(string, ...interface{})
- Errorw(string, Fields)
-
- Fatal(...interface{})
- Fatalln(...interface{})
- Fatalf(string, ...interface{})
- Fatalw(string, Fields)
-
- With(Fields) Logger
-
- // The following are added to be able to use this logger as a gRPC LoggerV2 if needed
- //
- Warning(...interface{})
- Warningln(...interface{})
- Warningf(string, ...interface{})
-
- // V reports whether verbosity level l is at least the requested verbose level.
- V(l LogLevel) bool
-
- //Returns the log level of this specific logger
- GetLogLevel() LogLevel
-}
-
-// logger has been refactored to be a thin wrapper on clogger implementation to support
-// all existing log statements during transition to new clogger
-type logger struct {
- cl *clogger
-}
-
-func AddPackage(outputType string, level LogLevel, defaultFields Fields, pkgNames ...string) (Logger, error) {
- // Get package name of caller method and pass further on; else this method is considered caller
- pkgName, _, _, _ := getCallerInfo()
-
- pkgNames = append(pkgNames, pkgName)
- clg, err := RegisterPackage(outputType, level, defaultFields, pkgNames...)
- if err != nil {
- return nil, err
- }
-
- return logger{cl: clg.(*clogger)}, nil
-}
-
-func getPackageLevelSugaredLogger() *zp.SugaredLogger {
- pkgName, _, _, _ := getCallerInfo()
- if _, exist := loggers[pkgName]; exist {
- return loggers[pkgName].log
- }
- return defaultLogger.log
-}
-
-func getPackageLevelLogger() CLogger {
- pkgName, _, _, _ := getCallerInfo()
- if _, exist := loggers[pkgName]; exist {
- return loggers[pkgName]
- }
- return defaultLogger
-}
-
-// With returns a logger initialized with the key-value pairs
-func (l logger) With(keysAndValues Fields) Logger {
- return logger{cl: &clogger{log: l.cl.log.With(serializeMap(keysAndValues)...), parent: l.cl.parent}}
-}
-
-// Debug logs a message at level Debug on the standard logger.
-func (l logger) Debug(args ...interface{}) {
- l.cl.log.Debug(args...)
-}
-
-// Debugln logs a message at level Debug on the standard logger with a line feed. Default in any case.
-func (l logger) Debugln(args ...interface{}) {
- l.cl.log.Debug(args...)
-}
-
-// Debugw logs a message at level Debug on the standard logger.
-func (l logger) Debugf(format string, args ...interface{}) {
- l.cl.log.Debugf(format, args...)
-}
-
-// Debugw logs a message with some additional context. The variadic key-value
-// pairs are treated as they are in With.
-func (l logger) Debugw(msg string, keysAndValues Fields) {
- if l.V(DebugLevel) {
- l.cl.log.Debugw(msg, serializeMap(keysAndValues)...)
- }
-}
-
-// Info logs a message at level Info on the standard logger.
-func (l logger) Info(args ...interface{}) {
- l.cl.log.Info(args...)
-}
-
-// Infoln logs a message at level Info on the standard logger with a line feed. Default in any case.
-func (l logger) Infoln(args ...interface{}) {
- l.cl.log.Info(args...)
- //msg := fmt.Sprintln(args...)
- //l.sourced().Info(msg[:len(msg)-1])
-}
-
-// Infof logs a message at level Info on the standard logger.
-func (l logger) Infof(format string, args ...interface{}) {
- l.cl.log.Infof(format, args...)
-}
-
-// Infow logs a message with some additional context. The variadic key-value
-// pairs are treated as they are in With.
-func (l logger) Infow(msg string, keysAndValues Fields) {
- if l.V(InfoLevel) {
- l.cl.log.Infow(msg, serializeMap(keysAndValues)...)
- }
-}
-
-// Warn logs a message at level Warn on the standard logger.
-func (l logger) Warn(args ...interface{}) {
- l.cl.log.Warn(args...)
-}
-
-// Warnln logs a message at level Warn on the standard logger with a line feed. Default in any case.
-func (l logger) Warnln(args ...interface{}) {
- l.cl.log.Warn(args...)
-}
-
-// Warnf logs a message at level Warn on the standard logger.
-func (l logger) Warnf(format string, args ...interface{}) {
- l.cl.log.Warnf(format, args...)
-}
-
-// Warnw logs a message with some additional context. The variadic key-value
-// pairs are treated as they are in With.
-func (l logger) Warnw(msg string, keysAndValues Fields) {
- if l.V(WarnLevel) {
- l.cl.log.Warnw(msg, serializeMap(keysAndValues)...)
- }
-}
-
-// Error logs a message at level Error on the standard logger.
-func (l logger) Error(args ...interface{}) {
- l.cl.log.Error(args...)
-}
-
-// Errorln logs a message at level Error on the standard logger with a line feed. Default in any case.
-func (l logger) Errorln(args ...interface{}) {
- l.cl.log.Error(args...)
-}
-
-// Errorf logs a message at level Error on the standard logger.
-func (l logger) Errorf(format string, args ...interface{}) {
- l.cl.log.Errorf(format, args...)
-}
-
-// Errorw logs a message with some additional context. The variadic key-value
-// pairs are treated as they are in With.
-func (l logger) Errorw(msg string, keysAndValues Fields) {
- if l.V(ErrorLevel) {
- l.cl.log.Errorw(msg, serializeMap(keysAndValues)...)
- }
-}
-
-// Fatal logs a message at level Fatal on the standard logger.
-func (l logger) Fatal(args ...interface{}) {
- l.cl.log.Fatal(args...)
-}
-
-// Fatalln logs a message at level Fatal on the standard logger with a line feed. Default in any case.
-func (l logger) Fatalln(args ...interface{}) {
- l.cl.log.Fatal(args...)
-}
-
-// Fatalf logs a message at level Fatal on the standard logger.
-func (l logger) Fatalf(format string, args ...interface{}) {
- l.cl.log.Fatalf(format, args...)
-}
-
-// Fatalw logs a message with some additional context. The variadic key-value
-// pairs are treated as they are in With.
-func (l logger) Fatalw(msg string, keysAndValues Fields) {
- if l.V(FatalLevel) {
- l.cl.log.Fatalw(msg, serializeMap(keysAndValues)...)
- }
-}
-
-// Warning logs a message at level Warn on the standard logger.
-func (l logger) Warning(args ...interface{}) {
- l.cl.log.Warn(args...)
-}
-
-// Warningln logs a message at level Warn on the standard logger with a line feed. Default in any case.
-func (l logger) Warningln(args ...interface{}) {
- l.cl.log.Warn(args...)
-}
-
-// Warningf logs a message at level Warn on the standard logger.
-func (l logger) Warningf(format string, args ...interface{}) {
- l.cl.log.Warnf(format, args...)
-}
-
-// V reports whether verbosity level l is at least the requested verbose level.
-func (l logger) V(level LogLevel) bool {
- return l.cl.parent.Core().Enabled(logLevelToLevel(level))
-}
-
-// GetLogLevel returns the current level of the logger