[VOL-2694] Use package specific logger instance in all log statements
Change-Id: Icf1cb5ade42e42179aed7731b767af2f52481e3d
diff --git a/rw_core/mocks/common_test.go b/rw_core/common.go
similarity index 71%
copy from rw_core/mocks/common_test.go
copy to rw_core/common.go
index eb1534f..7372b14 100644
--- a/rw_core/mocks/common_test.go
+++ b/rw_core/common.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2019-present Open Networking Foundation
+ * Copyright 2020-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.
@@ -13,21 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package mocks
+
+// Package main Common Logger initialization
+package main
import (
"github.com/opencord/voltha-lib-go/v3/pkg/log"
)
-const (
- logLevel = log.FatalLevel
-)
+var logger log.Logger
-// Unit test initialization. This init() function handles all unit tests in
-// the current directory.
func init() {
// Setup this package so that it's log level can be modified at run time
- _, err := log.AddPackage(log.JSON, logLevel, log.Fields{"instanceId": "mocks"})
+ var err error
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "main"})
if err != nil {
panic(err)
}
diff --git a/rw_core/config/config.go b/rw_core/config/config.go
index 3a626c0..39ba9ba 100644
--- a/rw_core/config/config.go
+++ b/rw_core/config/config.go
@@ -19,10 +19,7 @@
import (
"flag"
"fmt"
-
"time"
-
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
)
// RW Core service default constants
@@ -102,13 +99,6 @@
ProbePort int
}
-func init() {
- _, err := log.AddPackage(log.JSON, log.WarnLevel, nil)
- if err != nil {
- log.Errorw("unable-to-register-a-package-to-the-log-map", log.Fields{"error": err})
- }
-}
-
// NewRWCoreFlags returns a new RWCore config
func NewRWCoreFlags() *RWCoreFlags {
var rwCoreFlag = RWCoreFlags{ // Default values
diff --git a/rw_core/core/adapter_manager.go b/rw_core/core/adapter_manager.go
index 45a0ff5..9706cfb 100644
--- a/rw_core/core/adapter_manager.go
+++ b/rw_core/core/adapter_manager.go
@@ -70,7 +70,7 @@
func (aa *AdapterAgent) getAdapter() *voltha.Adapter {
aa.lock.RLock()
defer aa.lock.RUnlock()
- log.Debugw("getAdapter", log.Fields{"adapter": aa.adapter})
+ logger.Debugw("getAdapter", log.Fields{"adapter": aa.adapter})
return aa.adapter
}
@@ -130,25 +130,25 @@
}
func (aMgr *AdapterManager) start(ctx context.Context) error {
- log.Info("starting-adapter-manager")
+ logger.Info("starting-adapter-manager")
// Load the existing adapterAgents and device types - this will also ensure the correct paths have been
// created if there are no data in the dB to start
err := aMgr.loadAdaptersAndDevicetypesInMemory()
if err != nil {
- log.Errorw("Failed-to-load-adapters-and-device-types-in-memeory", log.Fields{"error": err})
+ logger.Errorw("Failed-to-load-adapters-and-device-types-in-memeory", log.Fields{"error": err})
return err
}
//// Create the proxies
aMgr.adapterProxy, err = aMgr.clusterDataProxy.CreateProxy(ctx, "/adapters", false)
if err != nil {
- log.Errorw("Failed-to-create-adapter-proxy", log.Fields{"error": err})
+ logger.Errorw("Failed-to-create-adapter-proxy", log.Fields{"error": err})
return err
}
aMgr.deviceTypeProxy, err = aMgr.clusterDataProxy.CreateProxy(ctx, "/device_types", false)
if err != nil {
- log.Errorw("Failed-to-create-device-proxy", log.Fields{"error": err})
+ logger.Errorw("Failed-to-create-device-proxy", log.Fields{"error": err})
return err
}
@@ -156,7 +156,7 @@
aMgr.adapterProxy.RegisterCallback(model.PostUpdate, aMgr.adapterUpdated)
aMgr.deviceTypeProxy.RegisterCallback(model.PostUpdate, aMgr.deviceTypesUpdated)
probe.UpdateStatusFromContext(ctx, "adapter-manager", probe.ServiceStatusRunning)
- log.Info("adapter-manager-started")
+ logger.Info("adapter-manager-started")
return nil
}
@@ -165,21 +165,21 @@
// Load the adapters
adaptersIf, err := aMgr.clusterDataProxy.List(context.Background(), "/adapters", 0, false, "")
if err != nil {
- log.Errorw("Failed-to-list-adapters-from-cluster-data-proxy", log.Fields{"error": err})
+ logger.Errorw("Failed-to-list-adapters-from-cluster-data-proxy", log.Fields{"error": err})
return err
}
if adaptersIf != nil {
for _, adapterIf := range adaptersIf.([]interface{}) {
if adapter, ok := adapterIf.(*voltha.Adapter); ok {
if err := aMgr.addAdapter(adapter, false); err != nil {
- log.Errorw("failed to add adapter", log.Fields{"adapterId": adapter.Id})
+ logger.Errorw("failed to add adapter", log.Fields{"adapterId": adapter.Id})
} else {
- log.Debugw("adapter added successfully", log.Fields{"adapterId": adapter.Id})
+ logger.Debugw("adapter added successfully", log.Fields{"adapterId": adapter.Id})
}
}
}
} else {
- log.Debug("no-existing-adapter-found")
+ logger.Debug("no-existing-adapter-found")
// No adapter data. In order to have a proxy setup for that path let's create a fake adapter
return aMgr.addAdapter(&voltha.Adapter{Id: SentinelAdapterID}, true)
}
@@ -187,23 +187,23 @@
// Load the device types
deviceTypesIf, err := aMgr.clusterDataProxy.List(context.Background(), "/device_types", 0, false, "")
if err != nil {
- log.Errorw("Failed-to-list-device-types-from-cluster-data-proxy", log.Fields{"error": err})
+ logger.Errorw("Failed-to-list-device-types-from-cluster-data-proxy", log.Fields{"error": err})
return err
}
if deviceTypesIf != nil {
dTypes := &voltha.DeviceTypes{Items: []*voltha.DeviceType{}}
for _, deviceTypeIf := range deviceTypesIf.([]interface{}) {
if dType, ok := deviceTypeIf.(*voltha.DeviceType); ok {
- log.Debugw("found-existing-device-types", log.Fields{"deviceTypes": dTypes})
+ logger.Debugw("found-existing-device-types", log.Fields{"deviceTypes": dTypes})
dTypes.Items = append(dTypes.Items, dType)
} else {
- log.Errorw("not an voltha device type", log.Fields{"interface": deviceTypeIf})
+ logger.Errorw("not an voltha device type", log.Fields{"interface": deviceTypeIf})
}
}
return aMgr.addDeviceTypes(dTypes, false)
}
- log.Debug("no-existing-device-type-found")
+ logger.Debug("no-existing-device-type-found")
// No device types data. In order to have a proxy setup for that path let's create a fake device type
return aMgr.addDeviceTypes(&voltha.DeviceTypes{Items: []*voltha.DeviceType{{Id: SentinelDevicetypeID, Adapter: SentinelAdapterID}}}, true)
}
@@ -229,7 +229,7 @@
go func() {
err := aMgr.deviceMgr.adapterRestarted(ctx, adapter)
if err != nil {
- log.Errorw("unable-to-restart-adapter", log.Fields{"error": err})
+ logger.Errorw("unable-to-restart-adapter", log.Fields{"error": err})
}
}()
return
@@ -239,13 +239,13 @@
// Update the adapters
adaptersIf, err := aMgr.clusterDataProxy.List(ctx, "/adapters", 0, false, "")
if err != nil {
- log.Errorw("failed-to-list-adapters-from-cluster-proxy", log.Fields{"error": err})
+ logger.Errorw("failed-to-list-adapters-from-cluster-proxy", log.Fields{"error": err})
return
}
if adaptersIf != nil {
for _, adapterIf := range adaptersIf.([]interface{}) {
if adapter, ok := adapterIf.(*voltha.Adapter); ok {
- log.Debugw("found-existing-adapter", log.Fields{"adapterId": adapter.Id})
+ logger.Debugw("found-existing-adapter", log.Fields{"adapterId": adapter.Id})
aMgr.updateAdapterWithoutLock(adapter)
}
}
@@ -255,14 +255,14 @@
// Update the device types
deviceTypesIf, err := aMgr.clusterDataProxy.List(context.Background(), "/device_types", 0, false, "")
if err != nil {
- log.Errorw("Failed-to-list-device-types-in-cluster-data-proxy", log.Fields{"error": err})
+ logger.Errorw("Failed-to-list-device-types-in-cluster-data-proxy", log.Fields{"error": err})
return
}
if deviceTypesIf != nil {
dTypes := &voltha.DeviceTypes{Items: []*voltha.DeviceType{}}
for _, deviceTypeIf := range deviceTypesIf.([]interface{}) {
if dType, ok := deviceTypeIf.(*voltha.DeviceType); ok {
- log.Debugw("found-existing-device-types", log.Fields{"deviceTypes": dTypes})
+ logger.Debugw("found-existing-device-types", log.Fields{"deviceTypes": dTypes})
aMgr.updateDeviceTypeWithoutLock(dType)
}
}
@@ -272,7 +272,7 @@
func (aMgr *AdapterManager) addAdapter(adapter *voltha.Adapter, saveToDb bool) error {
aMgr.lockAdaptersMap.Lock()
defer aMgr.lockAdaptersMap.Unlock()
- log.Debugw("adding-adapter", log.Fields{"adapter": adapter})
+ logger.Debugw("adding-adapter", log.Fields{"adapter": adapter})
if _, exist := aMgr.adapterAgents[adapter.Id]; !exist {
clonedAdapter := (proto.Clone(adapter)).(*voltha.Adapter)
aMgr.adapterAgents[adapter.Id] = newAdapterAgent(clonedAdapter, nil)
@@ -280,20 +280,20 @@
// Save the adapter to the KV store - first check if it already exist
kvAdapter, err := aMgr.clusterDataProxy.Get(context.Background(), "/adapters/"+adapter.Id, 0, false, "")
if err != nil {
- log.Errorw("failed-to-get-adapters-from-cluster-proxy", log.Fields{"error": err})
+ logger.Errorw("failed-to-get-adapters-from-cluster-proxy", log.Fields{"error": err})
return err
}
if kvAdapter == nil {
added, err := aMgr.clusterDataProxy.AddWithID(context.Background(), "/adapters", adapter.Id, clonedAdapter, "")
if err != nil {
- log.Errorw("failed-to-save-adapter-to-cluster-proxy", log.Fields{"error": err})
+ logger.Errorw("failed-to-save-adapter-to-cluster-proxy", log.Fields{"error": err})
return err
}
if added == nil {
//TODO: Errors when saving to KV would require a separate go routine to be launched and try the saving again
- log.Errorw("failed-to-save-adapter", log.Fields{"adapter": adapter})
+ logger.Errorw("failed-to-save-adapter", log.Fields{"adapter": adapter})
} else {
- log.Debugw("adapter-saved-to-KV-Store", log.Fields{"adapter": adapter})
+ logger.Debugw("adapter-saved-to-KV-Store", log.Fields{"adapter": adapter})
}
}
}
@@ -305,7 +305,7 @@
if deviceTypes == nil {
return fmt.Errorf("no-device-type")
}
- log.Debugw("adding-device-types", log.Fields{"deviceTypes": deviceTypes})
+ logger.Debugw("adding-device-types", log.Fields{"deviceTypes": deviceTypes})
aMgr.lockAdaptersMap.Lock()
defer aMgr.lockAdaptersMap.Unlock()
aMgr.lockdDeviceTypeToAdapterMap.Lock()
@@ -315,7 +315,7 @@
if adapterAgent, exist := aMgr.adapterAgents[clonedDType.Adapter]; exist {
adapterAgent.updateDeviceType(clonedDType)
} else {
- log.Debugw("adapter-not-exist", log.Fields{"deviceTypes": deviceTypes, "adapterId": clonedDType.Adapter})
+ logger.Debugw("adapter-not-exist", log.Fields{"deviceTypes": deviceTypes, "adapterId": clonedDType.Adapter})
aMgr.adapterAgents[clonedDType.Adapter] = newAdapterAgent(&voltha.Adapter{Id: clonedDType.Adapter}, deviceTypes)
}
aMgr.deviceTypeToAdapterMap[clonedDType.Id] = clonedDType.Adapter
@@ -325,7 +325,7 @@
for _, deviceType := range deviceTypes.Items {
dType, err := aMgr.clusterDataProxy.Get(context.Background(), "/device_types/"+deviceType.Id, 0, false, "")
if err != nil {
- log.Errorw("Failed-to--device-types-from-cluster-data-proxy", log.Fields{"error": err})
+ logger.Errorw("Failed-to--device-types-from-cluster-data-proxy", log.Fields{"error": err})
return err
}
if dType == nil {
@@ -333,13 +333,13 @@
clonedDType := (proto.Clone(deviceType)).(*voltha.DeviceType)
added, err := aMgr.clusterDataProxy.AddWithID(context.Background(), "/device_types", deviceType.Id, clonedDType, "")
if err != nil {
- log.Errorw("Failed-to-add-device-types-to-cluster-data-proxy", log.Fields{"error": err})
+ logger.Errorw("Failed-to-add-device-types-to-cluster-data-proxy", log.Fields{"error": err})
return err
}
if added == nil {
- log.Errorw("failed-to-save-deviceType", log.Fields{"deviceType": deviceType})
+ logger.Errorw("failed-to-save-deviceType", log.Fields{"deviceType": deviceType})
} else {
- log.Debugw("device-type-saved-to-KV-Store", log.Fields{"deviceType": deviceType})
+ logger.Debugw("device-type-saved-to-KV-Store", log.Fields{"deviceType": deviceType})
}
}
}
@@ -405,29 +405,29 @@
}
func (aMgr *AdapterManager) registerAdapter(adapter *voltha.Adapter, deviceTypes *voltha.DeviceTypes) (*voltha.CoreInstance, error) {
- log.Debugw("registerAdapter", log.Fields{"adapter": adapter, "deviceTypes": deviceTypes.Items})
+ logger.Debugw("registerAdapter", log.Fields{"adapter": adapter, "deviceTypes": deviceTypes.Items})
if aMgr.getAdapter(adapter.Id) != nil {
// Already registered - Adapter may have restarted. Trigger the reconcile process for that adapter
go func() {
err := aMgr.deviceMgr.adapterRestarted(context.Background(), adapter)
if err != nil {
- log.Errorw("unable-to-restart-adapter", log.Fields{"error": err})
+ logger.Errorw("unable-to-restart-adapter", log.Fields{"error": err})
}
}()
return &voltha.CoreInstance{InstanceId: aMgr.coreInstanceID}, nil
}
// Save the adapter and the device types
if err := aMgr.addAdapter(adapter, true); err != nil {
- log.Errorw("failed-to-add-adapter", log.Fields{"error": err})
+ logger.Errorw("failed-to-add-adapter", log.Fields{"error": err})
return nil, err
}
if err := aMgr.addDeviceTypes(deviceTypes, true); err != nil {
- log.Errorw("failed-to-add-device-types", log.Fields{"error": err})
+ logger.Errorw("failed-to-add-device-types", log.Fields{"error": err})
return nil, err
}
- log.Debugw("adapter-registered", log.Fields{"adapter": adapter.Id})
+ logger.Debugw("adapter-registered", log.Fields{"adapter": adapter.Id})
return &voltha.CoreInstance{InstanceId: aMgr.coreInstanceID}, nil
}
@@ -474,24 +474,24 @@
//adapterUpdated is a callback invoked when an adapter change has been noticed
func (aMgr *AdapterManager) adapterUpdated(ctx context.Context, args ...interface{}) interface{} {
- log.Debugw("updateAdapter-callback", log.Fields{"argsLen": len(args)})
+ logger.Debugw("updateAdapter-callback", log.Fields{"argsLen": len(args)})
var previousData *voltha.Adapters
var latestData *voltha.Adapters
var ok bool
if previousData, ok = args[0].(*voltha.Adapters); !ok {
- log.Errorw("invalid-args", log.Fields{"args0": args[0]})
+ logger.Errorw("invalid-args", log.Fields{"args0": args[0]})
return nil
}
if latestData, ok = args[1].(*voltha.Adapters); !ok {
- log.Errorw("invalid-args", log.Fields{"args1": args[1]})
+ logger.Errorw("invalid-args", log.Fields{"args1": args[1]})
return nil
}
if previousData != nil && latestData != nil {
if reflect.DeepEqual(previousData.Items, latestData.Items) {
- log.Debug("update-not-required")
+ logger.Debug("update-not-required")
return nil
}
}
@@ -507,25 +507,25 @@
//deviceTypesUpdated is a callback invoked when a device type change has been noticed
func (aMgr *AdapterManager) deviceTypesUpdated(ctx context.Context, args ...interface{}) interface{} {
- log.Debugw("deviceTypesUpdated-callback", log.Fields{"argsLen": len(args)})
+ logger.Debugw("deviceTypesUpdated-callback", log.Fields{"argsLen": len(args)})
var previousData *voltha.DeviceTypes
var latestData *voltha.DeviceTypes
var ok bool
if previousData, ok = args[0].(*voltha.DeviceTypes); !ok {
- log.Errorw("invalid-args", log.Fields{"args0": args[0]})
+ logger.Errorw("invalid-args", log.Fields{"args0": args[0]})
return nil
}
if latestData, ok = args[1].(*voltha.DeviceTypes); !ok {
- log.Errorw("invalid-args", log.Fields{"args1": args[1]})
+ logger.Errorw("invalid-args", log.Fields{"args1": args[1]})
return nil
}
if previousData != nil && latestData != nil {
if reflect.DeepEqual(previousData.Items, latestData.Items) {
- log.Debug("update-not-required")
+ logger.Debug("update-not-required")
return nil
}
}
diff --git a/rw_core/core/adapter_proxy.go b/rw_core/core/adapter_proxy.go
index d0a2e3f..4c9837b 100755
--- a/rw_core/core/adapter_proxy.go
+++ b/rw_core/core/adapter_proxy.go
@@ -58,7 +58,7 @@
// Wait for first response which would indicate whether the request was successfully sent to kafka.
firstResponse, ok := <-respChnl
if !ok || firstResponse.MType != kafka.RpcSent {
- log.Errorw("failure to request to kafka", log.Fields{"rpc": rpc, "device-id": deviceID, "error": firstResponse.Err})
+ logger.Errorw("failure to request to kafka", log.Fields{"rpc": rpc, "device-id": deviceID, "error": firstResponse.Err})
return nil, firstResponse.Err
}
// return the kafka channel for the caller to wait for the response of the RPC call
@@ -67,7 +67,7 @@
// adoptDevice invokes adopt device rpc
func (ap *AdapterProxy) adoptDevice(ctx context.Context, device *voltha.Device) (chan *kafka.RpcResponse, error) {
- log.Debugw("adoptDevice", log.Fields{"device-id": device.Id})
+ logger.Debugw("adoptDevice", log.Fields{"device-id": device.Id})
rpc := "adopt_device"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -80,7 +80,7 @@
// disableDevice invokes disable device rpc
func (ap *AdapterProxy) disableDevice(ctx context.Context, device *voltha.Device) (chan *kafka.RpcResponse, error) {
- log.Debugw("disableDevice", log.Fields{"device-id": device.Id})
+ logger.Debugw("disableDevice", log.Fields{"device-id": device.Id})
rpc := "disable_device"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -92,7 +92,7 @@
// reEnableDevice invokes reenable device rpc
func (ap *AdapterProxy) reEnableDevice(ctx context.Context, device *voltha.Device) (chan *kafka.RpcResponse, error) {
- log.Debugw("reEnableDevice", log.Fields{"device-id": device.Id})
+ logger.Debugw("reEnableDevice", log.Fields{"device-id": device.Id})
rpc := "reenable_device"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -104,7 +104,7 @@
// rebootDevice invokes reboot device rpc
func (ap *AdapterProxy) rebootDevice(ctx context.Context, device *voltha.Device) (chan *kafka.RpcResponse, error) {
- log.Debugw("rebootDevice", log.Fields{"device-id": device.Id})
+ logger.Debugw("rebootDevice", log.Fields{"device-id": device.Id})
rpc := "reboot_device"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -116,7 +116,7 @@
// deleteDevice invokes delete device rpc
func (ap *AdapterProxy) deleteDevice(ctx context.Context, device *voltha.Device) (chan *kafka.RpcResponse, error) {
- log.Debugw("deleteDevice", log.Fields{"device-id": device.Id})
+ logger.Debugw("deleteDevice", log.Fields{"device-id": device.Id})
rpc := "delete_device"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -128,7 +128,7 @@
// getOfpDeviceInfo invokes get ofp device info rpc
func (ap *AdapterProxy) getOfpDeviceInfo(ctx context.Context, device *voltha.Device) (chan *kafka.RpcResponse, error) {
- log.Debugw("getOfpDeviceInfo", log.Fields{"device-id": device.Id})
+ logger.Debugw("getOfpDeviceInfo", log.Fields{"device-id": device.Id})
rpc := "get_ofp_device_info"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -140,7 +140,7 @@
// getOfpPortInfo invokes get ofp port info rpc
func (ap *AdapterProxy) getOfpPortInfo(ctx context.Context, device *voltha.Device, portNo uint32) (chan *kafka.RpcResponse, error) {
- log.Debugw("getOfpPortInfo", log.Fields{"device-id": device.Id, "port-no": portNo})
+ logger.Debugw("getOfpPortInfo", log.Fields{"device-id": device.Id, "port-no": portNo})
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
{Key: "device", Value: device},
@@ -152,7 +152,7 @@
// reconcileDevice invokes reconcile device rpc
func (ap *AdapterProxy) reconcileDevice(ctx context.Context, device *voltha.Device) (chan *kafka.RpcResponse, error) {
- log.Debugw("reconcileDevice", log.Fields{"device-id": device.Id})
+ logger.Debugw("reconcileDevice", log.Fields{"device-id": device.Id})
rpc := "reconcile_device"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -164,7 +164,7 @@
// downloadImage invokes download image rpc
func (ap *AdapterProxy) downloadImage(ctx context.Context, device *voltha.Device, download *voltha.ImageDownload) (chan *kafka.RpcResponse, error) {
- log.Debugw("downloadImage", log.Fields{"device-id": device.Id, "image": download.Name})
+ logger.Debugw("downloadImage", log.Fields{"device-id": device.Id, "image": download.Name})
rpc := "download_image"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -177,7 +177,7 @@
// getImageDownloadStatus invokes get image download status rpc
func (ap *AdapterProxy) getImageDownloadStatus(ctx context.Context, device *voltha.Device, download *voltha.ImageDownload) (chan *kafka.RpcResponse, error) {
- log.Debugw("getImageDownloadStatus", log.Fields{"device-id": device.Id, "image": download.Name})
+ logger.Debugw("getImageDownloadStatus", log.Fields{"device-id": device.Id, "image": download.Name})
rpc := "get_image_download_status"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -190,7 +190,7 @@
// cancelImageDownload invokes cancel image download rpc
func (ap *AdapterProxy) cancelImageDownload(ctx context.Context, device *voltha.Device, download *voltha.ImageDownload) (chan *kafka.RpcResponse, error) {
- log.Debugw("cancelImageDownload", log.Fields{"device-id": device.Id, "image": download.Name})
+ logger.Debugw("cancelImageDownload", log.Fields{"device-id": device.Id, "image": download.Name})
rpc := "cancel_image_download"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -203,7 +203,7 @@
// activateImageUpdate invokes activate image update rpc
func (ap *AdapterProxy) activateImageUpdate(ctx context.Context, device *voltha.Device, download *voltha.ImageDownload) (chan *kafka.RpcResponse, error) {
- log.Debugw("activateImageUpdate", log.Fields{"device-id": device.Id, "image": download.Name})
+ logger.Debugw("activateImageUpdate", log.Fields{"device-id": device.Id, "image": download.Name})
rpc := "activate_image_update"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -216,7 +216,7 @@
// revertImageUpdate invokes revert image update rpc
func (ap *AdapterProxy) revertImageUpdate(ctx context.Context, device *voltha.Device, download *voltha.ImageDownload) (chan *kafka.RpcResponse, error) {
- log.Debugw("revertImageUpdate", log.Fields{"device-id": device.Id, "image": download.Name})
+ logger.Debugw("revertImageUpdate", log.Fields{"device-id": device.Id, "image": download.Name})
rpc := "revert_image_update"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -228,7 +228,7 @@
}
func (ap *AdapterProxy) packetOut(ctx context.Context, deviceType string, deviceID string, outPort uint32, packet *openflow_13.OfpPacketOut) (chan *kafka.RpcResponse, error) {
- log.Debugw("packetOut", log.Fields{"device-id": deviceID, "device-type": deviceType, "out-port": outPort})
+ logger.Debugw("packetOut", log.Fields{"device-id": deviceID, "device-type": deviceType, "out-port": outPort})
toTopic := ap.getAdapterTopic(deviceType)
rpc := "receive_packet_out"
args := []*kafka.KVArg{
@@ -242,7 +242,7 @@
// updateFlowsBulk invokes update flows bulk rpc
func (ap *AdapterProxy) updateFlowsBulk(ctx context.Context, device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) (chan *kafka.RpcResponse, error) {
- log.Debugw("updateFlowsBulk", log.Fields{"device-id": device.Id, "flow-count": len(flows.Items), "group-count": len(groups.Items), "flow-metadata": flowMetadata})
+ logger.Debugw("updateFlowsBulk", log.Fields{"device-id": device.Id, "flow-count": len(flows.Items), "group-count": len(groups.Items), "flow-metadata": flowMetadata})
toTopic := ap.getAdapterTopic(device.Adapter)
rpc := "update_flows_bulk"
args := []*kafka.KVArg{
@@ -257,7 +257,7 @@
// updateFlowsIncremental invokes update flows incremental rpc
func (ap *AdapterProxy) updateFlowsIncremental(ctx context.Context, device *voltha.Device, flowChanges *openflow_13.FlowChanges, groupChanges *openflow_13.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) (chan *kafka.RpcResponse, error) {
- log.Debugw("updateFlowsIncremental",
+ logger.Debugw("updateFlowsIncremental",
log.Fields{
"device-id": device.Id,
"flow-to-add-count": len(flowChanges.ToAdd.Items),
@@ -280,7 +280,7 @@
// updatePmConfigs invokes update pm configs rpc
func (ap *AdapterProxy) updatePmConfigs(ctx context.Context, device *voltha.Device, pmConfigs *voltha.PmConfigs) (chan *kafka.RpcResponse, error) {
- log.Debugw("updatePmConfigs", log.Fields{"device-id": device.Id, "pm-configs-id": pmConfigs.Id})
+ logger.Debugw("updatePmConfigs", log.Fields{"device-id": device.Id, "pm-configs-id": pmConfigs.Id})
toTopic := ap.getAdapterTopic(device.Adapter)
rpc := "Update_pm_config"
args := []*kafka.KVArg{
@@ -293,7 +293,7 @@
// simulateAlarm invokes simulate alarm rpc
func (ap *AdapterProxy) simulateAlarm(ctx context.Context, device *voltha.Device, simulateReq *voltha.SimulateAlarmRequest) (chan *kafka.RpcResponse, error) {
- log.Debugw("simulateAlarm", log.Fields{"device-id": device.Id, "simulate-req-id": simulateReq.Id})
+ logger.Debugw("simulateAlarm", log.Fields{"device-id": device.Id, "simulate-req-id": simulateReq.Id})
rpc := "simulate_alarm"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -306,7 +306,7 @@
}
func (ap *AdapterProxy) disablePort(ctx context.Context, device *voltha.Device, port *voltha.Port) (chan *kafka.RpcResponse, error) {
- log.Debugw("disablePort", log.Fields{"device-id": device.Id, "port-no": port.PortNo})
+ logger.Debugw("disablePort", log.Fields{"device-id": device.Id, "port-no": port.PortNo})
rpc := "disable_port"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -318,7 +318,7 @@
}
func (ap *AdapterProxy) enablePort(ctx context.Context, device *voltha.Device, port *voltha.Port) (chan *kafka.RpcResponse, error) {
- log.Debugw("enablePort", log.Fields{"device-id": device.Id, "port-no": port.PortNo})
+ logger.Debugw("enablePort", log.Fields{"device-id": device.Id, "port-no": port.PortNo})
rpc := "enable_port"
toTopic := ap.getAdapterTopic(device.Adapter)
args := []*kafka.KVArg{
@@ -331,7 +331,7 @@
// childDeviceLost invokes child device_lost rpc
func (ap *AdapterProxy) childDeviceLost(ctx context.Context, deviceType string, pDeviceID string, pPortNo uint32, onuID uint32) (chan *kafka.RpcResponse, error) {
- log.Debugw("childDeviceLost", log.Fields{"parent-device-id": pDeviceID, "parent-port-no": pPortNo, "onu-id": onuID})
+ logger.Debugw("childDeviceLost", log.Fields{"parent-device-id": pDeviceID, "parent-port-no": pPortNo, "onu-id": onuID})
rpc := "child_device_lost"
toTopic := ap.getAdapterTopic(deviceType)
args := []*kafka.KVArg{
@@ -344,7 +344,7 @@
}
func (ap *AdapterProxy) startOmciTest(ctx context.Context, device *voltha.Device, omcitestrequest *voltha.OmciTestRequest) (chan *kafka.RpcResponse, error) {
- log.Debugw("Omci_test_Request_adapter_proxy", log.Fields{"device": device, "omciTestRequest": omcitestrequest})
+ logger.Debugw("Omci_test_Request_adapter_proxy", log.Fields{"device": device, "omciTestRequest": omcitestrequest})
rpc := "start_omci_test"
toTopic := ap.getAdapterTopic(device.Adapter)
// Use a device specific topic as we are the only core handling requests for this device
diff --git a/rw_core/core/adapter_proxy_test.go b/rw_core/core/adapter_proxy_test.go
index 36e5e51..8784ff2 100755
--- a/rw_core/core/adapter_proxy_test.go
+++ b/rw_core/core/adapter_proxy_test.go
@@ -68,10 +68,10 @@
kafka.DefaultTopic(&kafka.Topic{Name: coreName}))
if err = coreKafkaICProxy.Start(); err != nil {
- log.Fatalw("Failure-starting-core-kafka-intercontainerProxy", log.Fields{"error": err})
+ logger.Fatalw("Failure-starting-core-kafka-intercontainerProxy", log.Fields{"error": err})
}
if err = coreKafkaICProxy.SubscribeWithDefaultRequestHandler(kafka.Topic{Name: coreName}, 0); err != nil {
- log.Fatalw("Failure-subscribing-core-request-handler", log.Fields{"error": err})
+ logger.Fatalw("Failure-subscribing-core-request-handler", log.Fields{"error": err})
}
// Setup adapter inter-container proxy and adapter request handler
@@ -84,10 +84,10 @@
kafka.RequestHandlerInterface(adapterReqHandler))
if err = adapterKafkaICProxy.Start(); err != nil {
- log.Fatalw("Failure-starting-adapter-kafka-intercontainerProxy", log.Fields{"error": err})
+ logger.Fatalw("Failure-starting-adapter-kafka-intercontainerProxy", log.Fields{"error": err})
}
if err = adapterKafkaICProxy.SubscribeWithDefaultRequestHandler(kafka.Topic{Name: adapterName}, 0); err != nil {
- log.Fatalw("Failure-subscribing-adapter-request-handler", log.Fields{"error": err})
+ logger.Fatalw("Failure-subscribing-adapter-request-handler", log.Fields{"error": err})
}
}
diff --git a/rw_core/core/adapter_request_handler.go b/rw_core/core/adapter_request_handler.go
index 85af539..3c1c5d0 100644
--- a/rw_core/core/adapter_request_handler.go
+++ b/rw_core/core/adapter_request_handler.go
@@ -78,7 +78,7 @@
if devID != "" {
var ownedByMe bool
if ownedByMe, err = rhp.core.deviceOwnership.OwnedByMe(ctx, &utils.DeviceID{ID: devID}); err != nil {
- log.Warnw("getting-ownership-failed", log.Fields{"deviceId": devID, "error": err})
+ logger.Warnw("getting-ownership-failed", log.Fields{"deviceId": devID, "error": err})
return nil, kafka.ErrorTransactionInvalidId
}
acquired, err = txn.Acquired(ctx, timeout, ownedByMe)
@@ -86,10 +86,10 @@
acquired, err = txn.Acquired(ctx, timeout)
}
if err == nil && acquired {
- log.Debugw("transaction-acquired", log.Fields{"transactionId": txn.txnID})
+ logger.Debugw("transaction-acquired", log.Fields{"transactionId": txn.txnID})
return txn, nil
}
- log.Debugw("transaction-not-acquired", log.Fields{"transactionId": txn.txnID, "error": err})
+ logger.Debugw("transaction-not-acquired", log.Fields{"transactionId": txn.txnID, "error": err})
return nil, kafka.ErrorTransactionNotAcquired
}
@@ -102,7 +102,7 @@
// Register registers the adapter
func (rhp *AdapterRequestHandlerProxy) Register(args []*ic.Argument) (*voltha.CoreInstance, error) {
if len(args) < 3 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -113,29 +113,29 @@
switch arg.Key {
case "adapter":
if err := ptypes.UnmarshalAny(arg.Value, adapter); err != nil {
- log.Warnw("cannot-unmarshal-adapter", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-adapter", log.Fields{"error": err})
return nil, err
}
case "deviceTypes":
if err := ptypes.UnmarshalAny(arg.Value, deviceTypes); err != nil {
- log.Warnw("cannot-unmarshal-device-types", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-types", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("Register", log.Fields{"adapter": *adapter, "device-types": deviceTypes, "transaction-id": transactionID.Val, "core-id": rhp.coreInstanceID})
+ logger.Debugw("Register", log.Fields{"adapter": *adapter, "device-types": deviceTypes, "transaction-id": transactionID.Val, "core-id": rhp.coreInstanceID})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, "")
if err != nil {
if err.Error() == kafka.ErrorTransactionNotAcquired.Error() {
- log.Debugw("Another core handled the request", log.Fields{"transactionId": transactionID})
+ logger.Debugw("Another core handled the request", log.Fields{"transactionId": transactionID})
// Update our adapters in memory
go rhp.adapterMgr.updateAdaptersAndDevicetypesInMemory(context.TODO(), adapter)
}
@@ -149,7 +149,7 @@
// GetDevice returns device info
func (rhp *AdapterRequestHandlerProxy) GetDevice(args []*ic.Argument) (*voltha.Device, error) {
if len(args) < 2 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -160,23 +160,23 @@
switch arg.Key {
case "device_id":
if err := ptypes.UnmarshalAny(arg.Value, pID); err != nil {
- log.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("GetDevice", log.Fields{"deviceID": pID.Id, "transactionID": transactionID.Val})
+ logger.Debugw("GetDevice", log.Fields{"deviceID": pID.Id, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, pID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
@@ -185,7 +185,7 @@
// Get the device via the device manager
device, err := rhp.deviceMgr.GetDevice(context.TODO(), pID.Id)
if err != nil {
- log.Debugw("get-device-failed", log.Fields{"deviceID": pID.Id, "error": err})
+ logger.Debugw("get-device-failed", log.Fields{"deviceID": pID.Id, "error": err})
}
return device, err
}
@@ -193,7 +193,7 @@
// DeviceUpdate updates device using adapter data
func (rhp *AdapterRequestHandlerProxy) DeviceUpdate(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 2 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -204,32 +204,32 @@
switch arg.Key {
case "device":
if err := ptypes.UnmarshalAny(arg.Value, device); err != nil {
- log.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("DeviceUpdate", log.Fields{"deviceID": device.Id, "transactionID": transactionID.Val})
+ logger.Debugw("DeviceUpdate", log.Fields{"deviceID": device.Id, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, device.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
}
- log.Debugw("DeviceUpdate got txn", log.Fields{"deviceID": device.Id, "transactionID": transactionID.Val})
+ logger.Debugw("DeviceUpdate got txn", log.Fields{"deviceID": device.Id, "transactionID": transactionID.Val})
if err := rhp.deviceMgr.updateDeviceUsingAdapterData(context.TODO(), device); err != nil {
- log.Debugw("unable-to-update-device-using-adapter-data", log.Fields{"error": err})
+ logger.Debugw("unable-to-update-device-using-adapter-data", log.Fields{"error": err})
return nil, err
}
return &empty.Empty{}, nil
@@ -238,7 +238,7 @@
// GetChildDevice returns details of child device
func (rhp *AdapterRequestHandlerProxy) GetChildDevice(args []*ic.Argument) (*voltha.Device, error) {
if len(args) < 3 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -252,38 +252,38 @@
switch arg.Key {
case "device_id":
if err := ptypes.UnmarshalAny(arg.Value, pID); err != nil {
- log.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
return nil, err
}
case "serial_number":
if err := ptypes.UnmarshalAny(arg.Value, serialNumber); err != nil {
- log.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
return nil, err
}
case "onu_id":
if err := ptypes.UnmarshalAny(arg.Value, onuID); err != nil {
- log.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
return nil, err
}
case "parent_port_no":
if err := ptypes.UnmarshalAny(arg.Value, parentPortNo); err != nil {
- log.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("GetChildDevice", log.Fields{"parentDeviceID": pID.Id, "args": args, "transactionID": transactionID.Val})
+ logger.Debugw("GetChildDevice", log.Fields{"parentDeviceID": pID.Id, "args": args, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, pID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
@@ -295,7 +295,7 @@
// GetChildDeviceWithProxyAddress returns details of child device with proxy address
func (rhp *AdapterRequestHandlerProxy) GetChildDeviceWithProxyAddress(args []*ic.Argument) (*voltha.Device, error) {
if len(args) < 2 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -306,23 +306,23 @@
switch arg.Key {
case "proxy_address":
if err := ptypes.UnmarshalAny(arg.Value, proxyAddress); err != nil {
- log.Warnw("cannot-unmarshal-proxy-address", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-proxy-address", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("GetChildDeviceWithProxyAddress", log.Fields{"proxyAddress": proxyAddress, "transactionID": transactionID.Val})
+ logger.Debugw("GetChildDeviceWithProxyAddress", log.Fields{"proxyAddress": proxyAddress, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, proxyAddress.DeviceId)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
@@ -334,7 +334,7 @@
// GetPorts returns the ports information of the device based on the port type.
func (rhp *AdapterRequestHandlerProxy) GetPorts(args []*ic.Argument) (*voltha.Ports, error) {
if len(args) < 3 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -345,28 +345,28 @@
switch arg.Key {
case "device_id":
if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
- log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case "port_type":
if err := ptypes.UnmarshalAny(arg.Value, pt); err != nil {
- log.Warnw("cannot-unmarshal-porttype", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-porttype", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("GetPorts", log.Fields{"deviceID": deviceID.Id, "portype": pt.Val, "transactionID": transactionID.Val})
+ logger.Debugw("GetPorts", log.Fields{"deviceID": deviceID.Id, "portype": pt.Val, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, deviceID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
@@ -378,7 +378,7 @@
// GetChildDevices gets all the child device IDs from the device passed as parameter
func (rhp *AdapterRequestHandlerProxy) GetChildDevices(args []*ic.Argument) (*voltha.Devices, error) {
if len(args) < 2 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -389,23 +389,23 @@
switch arg.Key {
case "device_id":
if err := ptypes.UnmarshalAny(arg.Value, pID); err != nil {
- log.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-ID", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("GetChildDevices", log.Fields{"deviceID": pID.Id, "transactionID": transactionID.Val})
+ logger.Debugw("GetChildDevices", log.Fields{"deviceID": pID.Id, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, pID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
@@ -418,7 +418,7 @@
// {parent_device_id, parent_port_no, child_device_type, channel_id, vendor_id, serial_number)
func (rhp *AdapterRequestHandlerProxy) ChildDeviceDetected(args []*ic.Argument) (*voltha.Device, error) {
if len(args) < 5 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -435,47 +435,47 @@
switch arg.Key {
case "parent_device_id":
if err := ptypes.UnmarshalAny(arg.Value, pID); err != nil {
- log.Warnw("cannot-unmarshal-parent-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-parent-device-id", log.Fields{"error": err})
return nil, err
}
case "parent_port_no":
if err := ptypes.UnmarshalAny(arg.Value, portNo); err != nil {
- log.Warnw("cannot-unmarshal-parent-port", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-parent-port", log.Fields{"error": err})
return nil, err
}
case "child_device_type":
if err := ptypes.UnmarshalAny(arg.Value, dt); err != nil {
- log.Warnw("cannot-unmarshal-child-device-type", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-child-device-type", log.Fields{"error": err})
return nil, err
}
case "channel_id":
if err := ptypes.UnmarshalAny(arg.Value, chnlID); err != nil {
- log.Warnw("cannot-unmarshal-channel-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-channel-id", log.Fields{"error": err})
return nil, err
}
case "vendor_id":
if err := ptypes.UnmarshalAny(arg.Value, vendorID); err != nil {
- log.Warnw("cannot-unmarshal-vendor-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-vendor-id", log.Fields{"error": err})
return nil, err
}
case "serial_number":
if err := ptypes.UnmarshalAny(arg.Value, serialNumber); err != nil {
- log.Warnw("cannot-unmarshal-serial-number", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-serial-number", log.Fields{"error": err})
return nil, err
}
case "onu_id":
if err := ptypes.UnmarshalAny(arg.Value, onuID); err != nil {
- log.Warnw("cannot-unmarshal-onu-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-onu-id", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("ChildDeviceDetected", log.Fields{"parentDeviceID": pID.Id, "parentPortNo": portNo.Val,
+ logger.Debugw("ChildDeviceDetected", log.Fields{"parentDeviceID": pID.Id, "parentPortNo": portNo.Val,
"deviceType": dt.Val, "channelID": chnlID.Val, "serialNumber": serialNumber.Val,
"vendorID": vendorID.Val, "onuID": onuID.Val, "transactionID": transactionID.Val})
@@ -483,7 +483,7 @@
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, pID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
@@ -491,7 +491,7 @@
device, err := rhp.deviceMgr.childDeviceDetected(context.TODO(), pID.Id, portNo.Val, dt.Val, chnlID.Val, vendorID.Val, serialNumber.Val, onuID.Val)
if err != nil {
- log.Debugw("child-detection-failed", log.Fields{"parentID": pID.Id, "onuID": onuID.Val, "error": err})
+ logger.Debugw("child-detection-failed", log.Fields{"parentID": pID.Id, "onuID": onuID.Val, "error": err})
}
return device, err
}
@@ -499,7 +499,7 @@
// DeviceStateUpdate updates device status
func (rhp *AdapterRequestHandlerProxy) DeviceStateUpdate(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 3 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -511,34 +511,34 @@
switch arg.Key {
case "device_id":
if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
- log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case "oper_status":
if err := ptypes.UnmarshalAny(arg.Value, operStatus); err != nil {
- log.Warnw("cannot-unmarshal-operStatus", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-operStatus", log.Fields{"error": err})
return nil, err
}
case "connect_status":
if err := ptypes.UnmarshalAny(arg.Value, connStatus); err != nil {
- log.Warnw("cannot-unmarshal-connStatus", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-connStatus", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("DeviceStateUpdate", log.Fields{"deviceID": deviceID.Id, "oper-status": operStatus,
+ logger.Debugw("DeviceStateUpdate", log.Fields{"deviceID": deviceID.Id, "oper-status": operStatus,
"conn-status": connStatus, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, deviceID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
@@ -546,7 +546,7 @@
if err := rhp.deviceMgr.updateDeviceStatus(context.TODO(), deviceID.Id, voltha.OperStatus_Types(operStatus.Val),
voltha.ConnectStatus_Types(connStatus.Val)); err != nil {
- log.Debugw("unable-to-update-device-status", log.Fields{"error": err})
+ logger.Debugw("unable-to-update-device-status", log.Fields{"error": err})
return nil, err
}
return &empty.Empty{}, nil
@@ -555,7 +555,7 @@
// ChildrenStateUpdate updates child device status
func (rhp *AdapterRequestHandlerProxy) ChildrenStateUpdate(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 3 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -567,34 +567,34 @@
switch arg.Key {
case "device_id":
if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
- log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case "oper_status":
if err := ptypes.UnmarshalAny(arg.Value, operStatus); err != nil {
- log.Warnw("cannot-unmarshal-operStatus", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-operStatus", log.Fields{"error": err})
return nil, err
}
case "connect_status":
if err := ptypes.UnmarshalAny(arg.Value, connStatus); err != nil {
- log.Warnw("cannot-unmarshal-connStatus", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-connStatus", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("ChildrenStateUpdate", log.Fields{"deviceID": deviceID.Id, "oper-status": operStatus,
+ logger.Debugw("ChildrenStateUpdate", log.Fields{"deviceID": deviceID.Id, "oper-status": operStatus,
"conn-status": connStatus, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, deviceID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
@@ -603,7 +603,7 @@
// When the enum is not set (i.e. -1), Go still convert to the Enum type with the value being -1
if err := rhp.deviceMgr.updateChildrenStatus(context.TODO(), deviceID.Id, voltha.OperStatus_Types(operStatus.Val),
voltha.ConnectStatus_Types(connStatus.Val)); err != nil {
- log.Debugw("unable-to-update-children-status", log.Fields{"error": err})
+ logger.Debugw("unable-to-update-children-status", log.Fields{"error": err})
return nil, err
}
return &empty.Empty{}, nil
@@ -612,7 +612,7 @@
// PortsStateUpdate updates the ports state related to the device
func (rhp *AdapterRequestHandlerProxy) PortsStateUpdate(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 2 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -623,35 +623,35 @@
switch arg.Key {
case "device_id":
if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
- log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case "oper_status":
if err := ptypes.UnmarshalAny(arg.Value, operStatus); err != nil {
- log.Warnw("cannot-unmarshal-operStatus", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-operStatus", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("PortsStateUpdate", log.Fields{"deviceID": deviceID.Id, "operStatus": operStatus, "transactionID": transactionID.Val})
+ logger.Debugw("PortsStateUpdate", log.Fields{"deviceID": deviceID.Id, "operStatus": operStatus, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, deviceID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
}
if err := rhp.deviceMgr.updatePortsState(context.TODO(), deviceID.Id, voltha.OperStatus_Types(operStatus.Val)); err != nil {
- log.Debugw("unable-to-update-ports-state", log.Fields{"error": err})
+ logger.Debugw("unable-to-update-ports-state", log.Fields{"error": err})
return nil, err
}
return &empty.Empty{}, nil
@@ -660,7 +660,7 @@
// PortStateUpdate updates the port state of the device
func (rhp *AdapterRequestHandlerProxy) PortStateUpdate(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 3 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -673,39 +673,39 @@
switch arg.Key {
case "device_id":
if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
- log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case "oper_status":
if err := ptypes.UnmarshalAny(arg.Value, operStatus); err != nil {
- log.Warnw("cannot-unmarshal-operStatus", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-operStatus", log.Fields{"error": err})
return nil, err
}
case "port_type":
if err := ptypes.UnmarshalAny(arg.Value, portType); err != nil {
- log.Warnw("cannot-unmarshal-porttype", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-porttype", log.Fields{"error": err})
return nil, err
}
case "port_no":
if err := ptypes.UnmarshalAny(arg.Value, portNo); err != nil {
- log.Warnw("cannot-unmarshal-portno", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-portno", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("PortStateUpdate", log.Fields{"deviceID": deviceID.Id, "operStatus": operStatus,
+ logger.Debugw("PortStateUpdate", log.Fields{"deviceID": deviceID.Id, "operStatus": operStatus,
"portType": portType, "portNo": portNo, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, deviceID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
@@ -716,7 +716,7 @@
// If the error doesn't change behavior and is essentially ignored, it is not an error, it is a
// warning.
// TODO: VOL-2707
- log.Debugw("unable-to-update-port-state", log.Fields{"error": err})
+ logger.Debugw("unable-to-update-port-state", log.Fields{"error": err})
return nil, err
}
return &empty.Empty{}, nil
@@ -725,7 +725,7 @@
// DeleteAllPorts deletes all ports of device
func (rhp *AdapterRequestHandlerProxy) DeleteAllPorts(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 3 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -735,30 +735,30 @@
switch arg.Key {
case "device_id":
if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
- log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("DeleteAllPorts", log.Fields{"deviceID": deviceID.Id, "transactionID": transactionID.Val})
+ logger.Debugw("DeleteAllPorts", log.Fields{"deviceID": deviceID.Id, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, deviceID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
}
if err := rhp.deviceMgr.deleteAllPorts(context.TODO(), deviceID.Id); err != nil {
- log.Debugw("unable-to-delete-ports", log.Fields{"error": err})
+ logger.Debugw("unable-to-delete-ports", log.Fields{"error": err})
return nil, err
}
return &empty.Empty{}, nil
@@ -768,7 +768,7 @@
// This will trigger the Core to disable all the child devices.
func (rhp *AdapterRequestHandlerProxy) ChildDevicesLost(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 2 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -778,30 +778,30 @@
switch arg.Key {
case "parent_device_id":
if err := ptypes.UnmarshalAny(arg.Value, parentDeviceID); err != nil {
- log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("ChildDevicesLost", log.Fields{"deviceID": parentDeviceID.Id, "transactionID": transactionID.Val})
+ logger.Debugw("ChildDevicesLost", log.Fields{"deviceID": parentDeviceID.Id, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, parentDeviceID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
}
if err := rhp.deviceMgr.childDevicesLost(context.TODO(), parentDeviceID.Id); err != nil {
- log.Debugw("unable-to-disable-child-devices", log.Fields{"error": err})
+ logger.Debugw("unable-to-disable-child-devices", log.Fields{"error": err})
return nil, err
}
return &empty.Empty{}, nil
@@ -811,7 +811,7 @@
// This will trigger the Core to Enable all the child devices of that parent.
func (rhp *AdapterRequestHandlerProxy) ChildDevicesDetected(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 2 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -821,30 +821,30 @@
switch arg.Key {
case "parent_device_id":
if err := ptypes.UnmarshalAny(arg.Value, parentDeviceID); err != nil {
- log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("ChildDevicesDetected", log.Fields{"deviceID": parentDeviceID.Id, "transactionID": transactionID.Val})
+ logger.Debugw("ChildDevicesDetected", log.Fields{"deviceID": parentDeviceID.Id, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, parentDeviceID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
}
if err := rhp.deviceMgr.childDevicesDetected(context.TODO(), parentDeviceID.Id); err != nil {
- log.Debugw("child-devices-detection-failed", log.Fields{"parentID": parentDeviceID.Id, "error": err})
+ logger.Debugw("child-devices-detection-failed", log.Fields{"parentID": parentDeviceID.Id, "error": err})
return nil, err
}
return &empty.Empty{}, nil
@@ -853,7 +853,7 @@
// PortCreated adds port to device
func (rhp *AdapterRequestHandlerProxy) PortCreated(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 3 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -864,35 +864,35 @@
switch arg.Key {
case "device_id":
if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
- log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case "port":
if err := ptypes.UnmarshalAny(arg.Value, port); err != nil {
- log.Warnw("cannot-unmarshal-port", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-port", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("PortCreated", log.Fields{"deviceID": deviceID.Id, "port": port, "transactionID": transactionID.Val})
+ logger.Debugw("PortCreated", log.Fields{"deviceID": deviceID.Id, "port": port, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, deviceID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
}
if err := rhp.deviceMgr.addPort(context.TODO(), deviceID.Id, port); err != nil {
- log.Debugw("unable-to-add-port", log.Fields{"error": err})
+ logger.Debugw("unable-to-add-port", log.Fields{"error": err})
return nil, err
}
return &empty.Empty{}, nil
@@ -901,7 +901,7 @@
// DevicePMConfigUpdate initializes the pm configs as defined by the adapter.
func (rhp *AdapterRequestHandlerProxy) DevicePMConfigUpdate(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 2 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -911,31 +911,31 @@
switch arg.Key {
case "device_pm_config":
if err := ptypes.UnmarshalAny(arg.Value, pmConfigs); err != nil {
- log.Warnw("cannot-unmarshal-pm-config", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-pm-config", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("DevicePMConfigUpdate", log.Fields{"deviceID": pmConfigs.Id, "configs": pmConfigs,
+ logger.Debugw("DevicePMConfigUpdate", log.Fields{"deviceID": pmConfigs.Id, "configs": pmConfigs,
"transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, pmConfigs.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
}
if err := rhp.deviceMgr.initPmConfigs(context.TODO(), pmConfigs.Id, pmConfigs); err != nil {
- log.Debugw("unable-to-initialize-pm-configs", log.Fields{"error": err})
+ logger.Debugw("unable-to-initialize-pm-configs", log.Fields{"error": err})
return nil, err
}
return &empty.Empty{}, nil
@@ -944,7 +944,7 @@
// PacketIn sends the incoming packet of device
func (rhp *AdapterRequestHandlerProxy) PacketIn(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 4 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -956,27 +956,27 @@
switch arg.Key {
case "device_id":
if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
- log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case "port":
if err := ptypes.UnmarshalAny(arg.Value, portNo); err != nil {
- log.Warnw("cannot-unmarshal-port-no", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-port-no", log.Fields{"error": err})
return nil, err
}
case "packet":
if err := ptypes.UnmarshalAny(arg.Value, packet); err != nil {
- log.Warnw("cannot-unmarshal-packet", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-packet", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("PacketIn", log.Fields{"deviceID": deviceID.Id, "port": portNo.Val, "packet": packet,
+ logger.Debugw("PacketIn", log.Fields{"deviceID": deviceID.Id, "port": portNo.Val, "packet": packet,
"transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
@@ -985,14 +985,14 @@
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, deviceID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
}
if err := rhp.deviceMgr.PacketIn(context.TODO(), deviceID.Id, uint32(portNo.Val), transactionID.Val, packet.Payload); err != nil {
- log.Debugw("unable-to-receive-packet-from-adapter", log.Fields{"error": err})
+ logger.Debugw("unable-to-receive-packet-from-adapter", log.Fields{"error": err})
return nil, err
}
@@ -1002,7 +1002,7 @@
// UpdateImageDownload updates image download
func (rhp *AdapterRequestHandlerProxy) UpdateImageDownload(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 2 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -1013,36 +1013,36 @@
switch arg.Key {
case "device_id":
if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
- log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case "image_download":
if err := ptypes.UnmarshalAny(arg.Value, img); err != nil {
- log.Warnw("cannot-unmarshal-imgaeDownload", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-imgaeDownload", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("UpdateImageDownload", log.Fields{"deviceID": deviceID.Id, "image-download": img,
+ logger.Debugw("UpdateImageDownload", log.Fields{"deviceID": deviceID.Id, "image-download": img,
"transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, deviceID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
}
if err := rhp.deviceMgr.updateImageDownload(context.TODO(), deviceID.Id, img); err != nil {
- log.Debugw("unable-to-update-image-download", log.Fields{"error": err})
+ logger.Debugw("unable-to-update-image-download", log.Fields{"error": err})
return nil, err
}
return &empty.Empty{}, nil
@@ -1051,7 +1051,7 @@
// ReconcileChildDevices reconciles child devices
func (rhp *AdapterRequestHandlerProxy) ReconcileChildDevices(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 2 {
- log.Warn("invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
return nil, err
}
@@ -1061,30 +1061,30 @@
switch arg.Key {
case "parent_device_id":
if err := ptypes.UnmarshalAny(arg.Value, parentDeviceID); err != nil {
- log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("ReconcileChildDevices", log.Fields{"deviceID": parentDeviceID.Id, "transactionID": transactionID.Val})
+ logger.Debugw("ReconcileChildDevices", log.Fields{"deviceID": parentDeviceID.Id, "transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, parentDeviceID.Id)
if err != nil {
- log.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
}
if err := rhp.deviceMgr.reconcileChildDevices(context.TODO(), parentDeviceID.Id); err != nil {
- log.Debugw("unable-to-reconcile-child-devices", log.Fields{"error": err})
+ logger.Debugw("unable-to-reconcile-child-devices", log.Fields{"error": err})
return nil, err
}
return &empty.Empty{}, nil
@@ -1093,7 +1093,7 @@
// DeviceReasonUpdate updates device reason
func (rhp *AdapterRequestHandlerProxy) DeviceReasonUpdate(args []*ic.Argument) (*empty.Empty, error) {
if len(args) < 2 {
- log.Warn("DeviceReasonUpdate: invalid-number-of-args", log.Fields{"args": args})
+ logger.Warn("DeviceReasonUpdate: invalid-number-of-args", log.Fields{"args": args})
err := errors.New("DeviceReasonUpdate: invalid-number-of-args")
return nil, err
}
@@ -1104,36 +1104,36 @@
switch arg.Key {
case "device_id":
if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
- log.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
case "device_reason":
if err := ptypes.UnmarshalAny(arg.Value, reason); err != nil {
- log.Warnw("cannot-unmarshal-reason", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-reason", log.Fields{"error": err})
return nil, err
}
case kafka.TransactionKey:
if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
- log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ logger.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
return nil, err
}
}
}
- log.Debugw("DeviceReasonUpdate", log.Fields{"deviceId": deviceID.Id, "reason": reason.Val,
+ logger.Debugw("DeviceReasonUpdate", log.Fields{"deviceId": deviceID.Id, "reason": reason.Val,
"transactionID": transactionID.Val})
// Try to grab the transaction as this core may be competing with another Core
if rhp.competeForTransaction() {
txn, err := rhp.takeRequestOwnership(context.TODO(), transactionID.Val, deviceID.Id)
if err != nil {
- log.Debugw("DeviceReasonUpdate: Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
+ logger.Debugw("DeviceReasonUpdate: Core did not process request", log.Fields{"transactionID": transactionID, "error": err})
return nil, err
}
defer txn.Close(context.TODO())
}
if err := rhp.deviceMgr.updateDeviceReason(context.TODO(), deviceID.Id, reason.Val); err != nil {
- log.Debugw("unable-to-update-device-reason", log.Fields{"error": err})
+ logger.Debugw("unable-to-update-device-reason", log.Fields{"error": err})
return nil, err
}
diff --git a/rw_core/mocks/common_test.go b/rw_core/core/common.go
similarity index 71%
copy from rw_core/mocks/common_test.go
copy to rw_core/core/common.go
index eb1534f..93d82f1 100644
--- a/rw_core/mocks/common_test.go
+++ b/rw_core/core/common.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2019-present Open Networking Foundation
+ * Copyright 2020-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.
@@ -13,21 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package mocks
+
+// Package core Common Logger initialization
+package core
import (
"github.com/opencord/voltha-lib-go/v3/pkg/log"
)
-const (
- logLevel = log.FatalLevel
-)
+var logger log.Logger
-// Unit test initialization. This init() function handles all unit tests in
-// the current directory.
func init() {
// Setup this package so that it's log level can be modified at run time
- _, err := log.AddPackage(log.JSON, logLevel, log.Fields{"instanceId": "mocks"})
+ var err error
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "core"})
if err != nil {
panic(err)
}
diff --git a/rw_core/core/common_test.go b/rw_core/core/common_test.go
index 8375f70..f2cf3da 100644
--- a/rw_core/core/common_test.go
+++ b/rw_core/core/common_test.go
@@ -39,7 +39,6 @@
)
const (
- logLevel = log.FatalLevel
volthaSerialNumberKey = "voltha_serial_number"
retryInterval = 50 * time.Millisecond
)
@@ -60,13 +59,6 @@
type isConditionSatisfied func() bool
func init() {
- _, err := log.AddPackage(log.JSON, logLevel, log.Fields{"instanceId": "coreTests"})
- if err != nil {
- panic(err)
- }
- // Update all loggers to log level specified as input parameter
- log.SetAllLogLevel(log.ErrorLevel)
-
//Default mode is two rw-core running in a pair of competing cores
coreInCompeteMode = true
}
@@ -117,7 +109,7 @@
txnPrefix,
client,
cf.KVStoreTimeout); err != nil {
- log.Fatal("creating-transaction-context-failed")
+ logger.Fatal("creating-transaction-context-failed")
}
return client
}
@@ -136,16 +128,16 @@
case OnuAdapter:
adapter = cm.NewONUAdapter(adapterCoreProxy)
default:
- log.Fatalf("invalid-adapter-type-%d", adapterType)
+ logger.Fatalf("invalid-adapter-type-%d", adapterType)
}
adapterReqHandler = com.NewRequestHandlerProxy(coreInstanceID, adapter, adapterCoreProxy)
if err = adapterKafkaICProxy.Start(); err != nil {
- log.Errorw("Failure-starting-adapter-intercontainerProxy", log.Fields{"error": err})
+ logger.Errorw("Failure-starting-adapter-intercontainerProxy", log.Fields{"error": err})
return nil, err
}
if err = adapterKafkaICProxy.SubscribeWithRequestHandlerInterface(kafka.Topic{Name: adapterName}, adapterReqHandler); err != nil {
- log.Errorw("Failure-to-subscribe-onu-request-handler", log.Fields{"error": err})
+ logger.Errorw("Failure-to-subscribe-onu-request-handler", log.Fields{"error": err})
return nil, err
}
return adapter, nil
diff --git a/rw_core/core/core.go b/rw_core/core/core.go
index 0206ee0..57d00cf 100644
--- a/rw_core/core/core.go
+++ b/rw_core/core/core.go
@@ -58,13 +58,6 @@
deviceOwnership *DeviceOwnership
}
-func init() {
- _, err := log.AddPackage(log.JSON, log.WarnLevel, nil)
- if err != nil {
- log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
- }
-}
-
// NewCore creates instance of rw core
func NewCore(ctx context.Context, id string, cf *config.RWCoreFlags, kvClient kvstore.Client, kafkaClient kafka.Client) *Core {
var core Core
@@ -111,11 +104,11 @@
}
}
- log.Info("starting-core-services", log.Fields{"coreId": core.instanceID})
+ logger.Info("starting-core-services", log.Fields{"coreId": core.instanceID})
// Wait until connection to KV Store is up
if err := core.waitUntilKVStoreReachableOrMaxTries(ctx, core.config.MaxConnectionRetries, core.config.ConnectionRetryInterval); err != nil {
- log.Fatal("Unable-to-connect-to-KV-store")
+ logger.Fatal("Unable-to-connect-to-KV-store")
}
if p != nil {
p.UpdateStatus("kv-store", probe.ServiceStatusRunning)
@@ -137,7 +130,7 @@
// private copies of the poiner to core.kmp.
core.initKafkaManager(ctx)
- log.Debugw("values", log.Fields{"kmp": core.kmp})
+ logger.Debugw("values", log.Fields{"kmp": core.kmp})
core.deviceMgr = newDeviceManager(core)
core.adapterMgr = newAdapterManager(core.clusterDataProxy, core.instanceID, core.kafkaClient, core.deviceMgr)
core.deviceMgr.adapterMgr = core.adapterMgr
@@ -162,14 +155,14 @@
core.deviceOwnership = NewDeviceOwnership(core.instanceID, core.kvClient, core.deviceMgr, core.logicalDeviceMgr,
"service/voltha/owns_device", 10)
- log.Info("core-services-started")
+ logger.Info("core-services-started")
return nil
}
// Stop brings down core services
func (core *Core) Stop(ctx context.Context) {
core.stopOnce.Do(func() {
- log.Info("stopping-adaptercore")
+ logger.Info("stopping-adaptercore")
// Signal to the KVStoreMonitor that we are stopping.
close(core.exitChannel)
// Stop all the started services
@@ -185,7 +178,7 @@
if core.kmp != nil {
core.kmp.Stop()
}
- log.Info("adaptercore-stopped")
+ logger.Info("adaptercore-stopped")
})
}
@@ -193,10 +186,10 @@
func (core *Core) startGRPCService(ctx context.Context) {
// create an insecure gserver server
core.grpcServer = grpcserver.NewGrpcServer(core.config.GrpcHost, core.config.GrpcPort, nil, false, probe.GetProbeFromContext(ctx))
- log.Info("grpc-server-created")
+ logger.Info("grpc-server-created")
core.grpcNBIAPIHandler = NewAPIHandler(core)
- log.Infow("grpc-handler", log.Fields{"core_binding_key": core.config.CoreBindingKey})
+ logger.Infow("grpc-handler", log.Fields{"core_binding_key": core.config.CoreBindingKey})
core.logicalDeviceMgr.setGrpcNbiHandler(core.grpcNBIAPIHandler)
// Create a function to register the core GRPC service with the GRPC server
f := func(gs *grpc.Server) {
@@ -207,7 +200,7 @@
}
core.grpcServer.AddService(f)
- log.Info("grpc-service-added")
+ logger.Info("grpc-service-added")
/*
* Start the GRPC server
@@ -221,14 +214,14 @@
* ready, when it really isn't.
*/
probe.UpdateStatusFromContext(ctx, "grpc-service", probe.ServiceStatusRunning)
- log.Info("grpc-server-started")
+ logger.Info("grpc-server-started")
core.grpcServer.Start(ctx)
probe.UpdateStatusFromContext(ctx, "grpc-service", probe.ServiceStatusStopped)
}
// Initialize the kafka manager, but we will start it later
func (core *Core) initKafkaManager(ctx context.Context) {
- log.Infow("initialize-kafka-manager", log.Fields{"host": core.config.KafkaAdapterHost,
+ logger.Infow("initialize-kafka-manager", log.Fields{"host": core.config.KafkaAdapterHost,
"port": core.config.KafkaAdapterPort, "topic": core.config.CoreTopic})
probe.UpdateStatusFromContext(ctx, "message-bus", probe.ServiceStatusPreparing)
@@ -278,51 +271,51 @@
*/
func (core *Core) startKafkaManager(ctx context.Context, startupRetryInterval time.Duration, liveProbeInterval time.Duration, notLiveProbeInterval time.Duration) {
- log.Infow("starting-kafka-manager-thread", log.Fields{"host": core.config.KafkaAdapterHost,
+ logger.Infow("starting-kafka-manager-thread", log.Fields{"host": core.config.KafkaAdapterHost,
"port": core.config.KafkaAdapterPort, "topic": core.config.CoreTopic})
started := false
for !started {
// If we haven't started yet, then try to start
- log.Infow("starting-kafka-proxy", log.Fields{})
+ logger.Infow("starting-kafka-proxy", log.Fields{})
if err := core.kmp.Start(); err != nil {
// We failed to start. Delay and then try again later.
// Don't worry about liveness, as we can't be live until we've started.
probe.UpdateStatusFromContext(ctx, "message-bus", probe.ServiceStatusNotReady)
- log.Infow("error-starting-kafka-messaging-proxy", log.Fields{"error": err})
+ logger.Infow("error-starting-kafka-messaging-proxy", log.Fields{"error": err})
time.Sleep(startupRetryInterval)
} else {
// We started. We only need to do this once.
// Next we'll fall through and start checking liveness.
- log.Infow("started-kafka-proxy", log.Fields{})
+ logger.Infow("started-kafka-proxy", log.Fields{})
// cannot do this until after the kmp is started
if err := core.registerAdapterRequestHandlers(ctx, core.instanceID, core.deviceMgr, core.logicalDeviceMgr, core.adapterMgr, core.clusterDataProxy, core.localDataProxy); err != nil {
- log.Fatal("Failure-registering-adapterRequestHandler")
+ logger.Fatal("Failure-registering-adapterRequestHandler")
}
started = true
}
}
- log.Info("started-kafka-message-proxy")
+ logger.Info("started-kafka-message-proxy")
livenessChannel := core.kmp.EnableLivenessChannel(true)
- log.Info("enabled-kafka-liveness-channel")
+ logger.Info("enabled-kafka-liveness-channel")
timeout := liveProbeInterval
for {
timeoutTimer := time.NewTimer(timeout)
select {
case liveness := <-livenessChannel:
- log.Infow("kafka-manager-thread-liveness-event", log.Fields{"liveness": liveness})
+ logger.Infow("kafka-manager-thread-liveness-event", log.Fields{"liveness": liveness})
// there was a state change in Kafka liveness
if !liveness {
probe.UpdateStatusFromContext(ctx, "message-bus", probe.ServiceStatusNotReady)
if core.grpcServer != nil {
- log.Info("kafka-manager-thread-set-server-notready")
+ logger.Info("kafka-manager-thread-set-server-notready")
}
// retry frequently while life is bad
@@ -331,7 +324,7 @@
probe.UpdateStatusFromContext(ctx, "message-bus", probe.ServiceStatusRunning)
if core.grpcServer != nil {
- log.Info("kafka-manager-thread-set-server-ready")
+ logger.Info("kafka-manager-thread-set-server-ready")
}
// retry infrequently while life is good
@@ -341,14 +334,14 @@
<-timeoutTimer.C
}
case <-timeoutTimer.C:
- log.Info("kafka-proxy-liveness-recheck")
+ logger.Info("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.
go func() {
err := core.kmp.SendLiveness()
if err != nil {
// Catch possible error case if sending liveness after Sarama has been stopped.
- log.Warnw("error-kafka-send-liveness", log.Fields{"error": err})
+ logger.Warnw("error-kafka-send-liveness", log.Fields{"error": err})
}
}()
}
@@ -357,12 +350,12 @@
// waitUntilKVStoreReachableOrMaxTries will wait until it can connect to a KV store or until maxtries has been reached
func (core *Core) waitUntilKVStoreReachableOrMaxTries(ctx context.Context, maxRetries int, retryInterval time.Duration) error {
- log.Infow("verifying-KV-store-connectivity", log.Fields{"host": core.config.KVStoreHost,
+ logger.Infow("verifying-KV-store-connectivity", log.Fields{"host": core.config.KVStoreHost,
"port": core.config.KVStorePort, "retries": maxRetries, "retryInterval": retryInterval})
count := 0
for {
if !core.kvClient.IsConnectionUp(ctx) {
- log.Info("KV-store-unreachable")
+ logger.Info("KV-store-unreachable")
if maxRetries != -1 {
if count >= maxRetries {
return status.Error(codes.Unavailable, "kv store unreachable")
@@ -371,13 +364,13 @@
count++
// Take a nap before retrying
time.Sleep(retryInterval)
- log.Infow("retry-KV-store-connectivity", log.Fields{"retryCount": count, "maxRetries": maxRetries, "retryInterval": retryInterval})
+ logger.Infow("retry-KV-store-connectivity", log.Fields{"retryCount": count, "maxRetries": maxRetries, "retryInterval": retryInterval})
} else {
break
}
}
- log.Info("KV-store-reachable")
+ logger.Info("KV-store-reachable")
return nil
}
@@ -389,39 +382,39 @@
// Register the broadcast topic to handle any core-bound broadcast requests
if err := core.kmp.SubscribeWithRequestHandlerInterface(kafka.Topic{Name: core.config.CoreTopic}, requestProxy); err != nil {
- log.Fatalw("Failed-registering-broadcast-handler", log.Fields{"topic": core.config.CoreTopic})
+ logger.Fatalw("Failed-registering-broadcast-handler", log.Fields{"topic": core.config.CoreTopic})
return err
}
// Register the core-pair topic to handle core-bound requests destined to the core pair
if err := core.kmp.SubscribeWithDefaultRequestHandler(kafka.Topic{Name: core.config.CorePairTopic}, kafka.OffsetNewest); err != nil {
- log.Fatalw("Failed-registering-pair-handler", log.Fields{"topic": core.config.CorePairTopic})
+ logger.Fatalw("Failed-registering-pair-handler", log.Fields{"topic": core.config.CorePairTopic})
return err
}
- log.Info("request-handler-registered")
+ logger.Info("request-handler-registered")
return nil
}
func (core *Core) startDeviceManager(ctx context.Context) {
- log.Info("DeviceManager-Starting...")
+ logger.Info("DeviceManager-Starting...")
core.deviceMgr.start(ctx, core.logicalDeviceMgr)
- log.Info("DeviceManager-Started")
+ logger.Info("DeviceManager-Started")
}
func (core *Core) startLogicalDeviceManager(ctx context.Context) {
- log.Info("Logical-DeviceManager-Starting...")
+ logger.Info("Logical-DeviceManager-Starting...")
core.logicalDeviceMgr.start(ctx)
- log.Info("Logical-DeviceManager-Started")
+ logger.Info("Logical-DeviceManager-Started")
}
func (core *Core) startAdapterManager(ctx context.Context) {
- log.Info("Adapter-Manager-Starting...")
+ logger.Info("Adapter-Manager-Starting...")
err := core.adapterMgr.start(ctx)
if err != nil {
- log.Fatalf("failed-to-start-adapter-manager: error %v ", err)
+ logger.Fatalf("failed-to-start-adapter-manager: error %v ", err)
}
- log.Info("Adapter-Manager-Started")
+ logger.Info("Adapter-Manager-Started")
}
/*
@@ -439,12 +432,12 @@
* start issuing UNAVAILABLE response while the probe is not ready.
*/
func (core *Core) monitorKvstoreLiveness(ctx context.Context) {
- log.Info("start-monitoring-kvstore-liveness")
+ logger.Info("start-monitoring-kvstore-liveness")
// Instruct backend to create Liveness channel for transporting state updates
livenessChannel := core.backend.EnableLivenessChannel()
- log.Debug("enabled-kvstore-liveness-channel")
+ logger.Debug("enabled-kvstore-liveness-channel")
// Default state for kvstore is alive for rw_core
timeout := core.config.LiveProbeInterval
@@ -454,13 +447,13 @@
select {
case liveness := <-livenessChannel:
- log.Debugw("received-liveness-change-notification", log.Fields{"liveness": liveness})
+ logger.Debugw("received-liveness-change-notification", log.Fields{"liveness": liveness})
if !liveness {
probe.UpdateStatusFromContext(ctx, "kv-store", probe.ServiceStatusNotReady)
if core.grpcServer != nil {
- log.Info("kvstore-set-server-notready")
+ logger.Info("kvstore-set-server-notready")
}
timeout = core.config.NotLiveProbeInterval
@@ -469,7 +462,7 @@
probe.UpdateStatusFromContext(ctx, "kv-store", probe.ServiceStatusRunning)
if core.grpcServer != nil {
- log.Info("kvstore-set-server-ready")
+ logger.Info("kvstore-set-server-ready")
}
timeout = core.config.LiveProbeInterval
@@ -483,7 +476,7 @@
break loop
case <-timeoutTimer.C:
- log.Info("kvstore-perform-liveness-check-on-timeout")
+ logger.Info("kvstore-perform-liveness-check-on-timeout")
// Trigger Liveness check if no liveness update received within the timeout period.
// The Liveness check will push Live state to same channel which this routine is
diff --git a/rw_core/core/device_agent.go b/rw_core/core/device_agent.go
index 25f3413..1df4572 100755
--- a/rw_core/core/device_agent.go
+++ b/rw_core/core/device_agent.go
@@ -97,7 +97,7 @@
defer func() {
if !startSucceeded {
if err := agent.stop(ctx); err != nil {
- log.Errorw("failed-to-cleanup-after-unsuccessful-start", log.Fields{"device-id": agent.deviceID, "error": err})
+ logger.Errorw("failed-to-cleanup-after-unsuccessful-start", log.Fields{"device-id": agent.deviceID, "error": err})
}
}
}()
@@ -124,7 +124,7 @@
} else {
return nil, status.Errorf(codes.NotFound, "device-%s-loading-failed", agent.deviceID)
}
- log.Infow("device-loaded-from-dB", log.Fields{"device-id": agent.deviceID})
+ logger.Infow("device-loaded-from-dB", log.Fields{"device-id": agent.deviceID})
} else {
// Create a new device
// Assumption is that AdminState, FlowGroups, and Flows are unitialized since this
@@ -158,7 +158,7 @@
agent.deviceProxy.RegisterCallback(model.PostUpdate, agent.processUpdate)
startSucceeded = true
- log.Debugw("device-agent-started", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("device-agent-started", log.Fields{"device-id": agent.deviceID})
return agent.getDevice(ctx)
}
@@ -174,7 +174,7 @@
}
defer agent.requestQueue.RequestComplete()
- log.Infow("stopping-device-agent", log.Fields{"deviceId": agent.deviceID, "parentId": agent.parentID})
+ logger.Infow("stopping-device-agent", log.Fields{"deviceId": agent.deviceID, "parentId": agent.parentID})
// First unregister any callbacks
if agent.deviceProxy != nil {
@@ -187,7 +187,7 @@
return err
}
if removed == nil {
- log.Debugw("device-already-removed", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("device-already-removed", log.Fields{"device-id": agent.deviceID})
}
// Stop the request queue - no more requests can be processed
@@ -197,7 +197,7 @@
agent.stopped = true
- log.Infow("device-agent-stopped", log.Fields{"device-id": agent.deviceID, "parent-id": agent.parentID})
+ logger.Infow("device-agent-stopped", log.Fields{"device-id": agent.deviceID, "parent-id": agent.parentID})
return nil
}
@@ -205,22 +205,22 @@
// Load the most recent state from the KVStore for the device.
func (agent *DeviceAgent) reconcileWithKVStore(ctx context.Context) {
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
- log.Warnw("request-aborted", log.Fields{"device-id": agent.deviceID, "error": err})
+ logger.Warnw("request-aborted", log.Fields{"device-id": agent.deviceID, "error": err})
return
}
defer agent.requestQueue.RequestComplete()
- log.Debug("reconciling-device-agent-devicetype")
+ logger.Debug("reconciling-device-agent-devicetype")
// TODO: context timeout
device, err := agent.clusterDataProxy.Get(ctx, "/devices/"+agent.deviceID, 1, true, "")
if err != nil {
- log.Errorw("kv-get-failed", log.Fields{"device-id": agent.deviceID, "error": err})
+ logger.Errorw("kv-get-failed", log.Fields{"device-id": agent.deviceID, "error": err})
return
}
if device != nil {
if d, ok := device.(*voltha.Device); ok {
agent.deviceType = d.Adapter
agent.device = proto.Clone(d).(*voltha.Device)
- log.Debugw("reconciled-device-agent-devicetype", log.Fields{"device-id": agent.deviceID, "type": agent.deviceType})
+ logger.Debugw("reconciled-device-agent-devicetype", log.Fields{"device-id": agent.deviceID, "type": agent.deviceType})
}
}
}
@@ -228,7 +228,7 @@
// onSuccess is a common callback for scenarios where we receive a nil response following a request to an adapter
// and the only action required is to publish a successful result on kafka
func (agent *DeviceAgent) onSuccess(rpc string, response interface{}, reqArgs ...interface{}) {
- log.Debugw("response successful", log.Fields{"rpc": rpc, "device-id": agent.deviceID})
+ logger.Debugw("response successful", log.Fields{"rpc": rpc, "device-id": agent.deviceID})
// TODO: Post success message onto kafka
}
@@ -236,9 +236,9 @@
// and the only action required is to publish the failed result on kafka
func (agent *DeviceAgent) onFailure(rpc string, response interface{}, reqArgs ...interface{}) {
if res, ok := response.(error); ok {
- log.Errorw("rpc-failed", log.Fields{"rpc": rpc, "device-id": agent.deviceID, "error": res, "args": reqArgs})
+ logger.Errorw("rpc-failed", log.Fields{"rpc": rpc, "device-id": agent.deviceID, "error": res, "args": reqArgs})
} else {
- log.Errorw("rpc-failed-invalid-error", log.Fields{"rpc": rpc, "device-id": agent.deviceID, "args": reqArgs})
+ logger.Errorw("rpc-failed-invalid-error", log.Fields{"rpc": rpc, "device-id": agent.deviceID, "args": reqArgs})
}
// TODO: Post failure message onto kafka
}
@@ -281,7 +281,7 @@
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("enableDevice", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("enableDevice", log.Fields{"device-id": agent.deviceID})
cloned := agent.getDeviceWithoutLock()
@@ -295,7 +295,7 @@
cloned.Adapter = adapterName
if cloned.AdminState == voltha.AdminState_ENABLED {
- log.Debugw("device-already-enabled", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("device-already-enabled", log.Fields{"device-id": agent.deviceID})
return nil
}
@@ -410,10 +410,10 @@
}
func (agent *DeviceAgent) addFlowsAndGroupsToAdapter(ctx context.Context, newFlows []*ofp.OfpFlowStats, newGroups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) (coreutils.Response, error) {
- log.Debugw("add-flows-groups-to-adapters", log.Fields{"device-id": agent.deviceID, "flows": newFlows, "groups": newGroups, "flow-metadata": flowMetadata})
+ logger.Debugw("add-flows-groups-to-adapters", log.Fields{"device-id": agent.deviceID, "flows": newFlows, "groups": newGroups, "flow-metadata": flowMetadata})
if (len(newFlows) | len(newGroups)) == 0 {
- log.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": newFlows, "groups": newGroups})
+ logger.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": newFlows, "groups": newGroups})
return coreutils.DoneResponse(), nil
}
@@ -439,7 +439,7 @@
// Sanity check
if (len(updatedAllFlows) | len(flowsToDelete) | len(updatedAllGroups) | len(groupsToDelete)) == 0 {
- log.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": newFlows, "groups": newGroups})
+ logger.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": newFlows, "groups": newGroups})
return coreutils.DoneResponse(), nil
}
@@ -455,7 +455,7 @@
response := coreutils.NewResponse()
if !dType.AcceptsAddRemoveFlowUpdates {
if len(updatedAllGroups) != 0 && reflect.DeepEqual(existingGroups.Items, updatedAllGroups) && len(updatedAllFlows) != 0 && reflect.DeepEqual(existingFlows.Items, updatedAllFlows) {
- log.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": newFlows, "groups": newGroups})
+ logger.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": newFlows, "groups": newGroups})
cancel()
return coreutils.DoneResponse(), nil
}
@@ -493,17 +493,17 @@
return err
}
if errs := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, response); errs != nil {
- log.Warnw("no-adapter-response", log.Fields{"device-id": agent.deviceID, "result": errs})
+ logger.Warnw("no-adapter-response", log.Fields{"device-id": agent.deviceID, "result": errs})
return status.Errorf(codes.Aborted, "flow-failure-device-%s", agent.deviceID)
}
return nil
}
func (agent *DeviceAgent) deleteFlowsAndGroupsFromAdapter(ctx context.Context, flowsToDel []*ofp.OfpFlowStats, groupsToDel []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) (coreutils.Response, error) {
- log.Debugw("delete-flows-groups-from-adapter", log.Fields{"device-id": agent.deviceID, "flows": flowsToDel, "groups": groupsToDel})
+ logger.Debugw("delete-flows-groups-from-adapter", log.Fields{"device-id": agent.deviceID, "flows": flowsToDel, "groups": groupsToDel})
if (len(flowsToDel) | len(groupsToDel)) == 0 {
- log.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": flowsToDel, "groups": groupsToDel})
+ logger.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": flowsToDel, "groups": groupsToDel})
return coreutils.DoneResponse(), nil
}
@@ -538,7 +538,7 @@
}
}
- log.Debugw("deleteFlowsAndGroups",
+ logger.Debugw("deleteFlowsAndGroups",
log.Fields{
"device-id": agent.deviceID,
"flows-to-del": len(flowsToDel),
@@ -549,7 +549,7 @@
// Sanity check
if (len(flowsToKeep) | len(flowsToDel) | len(groupsToKeep) | len(groupsToDel)) == 0 {
- log.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows-to-del": flowsToDel, "groups-to-del": groupsToDel})
+ logger.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows-to-del": flowsToDel, "groups-to-del": groupsToDel})
return coreutils.DoneResponse(), nil
}
@@ -565,7 +565,7 @@
response := coreutils.NewResponse()
if !dType.AcceptsAddRemoveFlowUpdates {
if len(groupsToKeep) != 0 && reflect.DeepEqual(existingGroups.Items, groupsToKeep) && len(flowsToKeep) != 0 && reflect.DeepEqual(existingFlows.Items, flowsToKeep) {
- log.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceID, "flowsToDel": flowsToDel, "groupsToDel": groupsToDel})
+ logger.Debugw("nothing-to-update", log.Fields{"deviceId": agent.deviceID, "flowsToDel": flowsToDel, "groupsToDel": groupsToDel})
cancel()
return coreutils.DoneResponse(), nil
}
@@ -609,10 +609,10 @@
}
func (agent *DeviceAgent) updateFlowsAndGroupsToAdapter(ctx context.Context, updatedFlows []*ofp.OfpFlowStats, updatedGroups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) (coreutils.Response, error) {
- log.Debugw("updateFlowsAndGroups", log.Fields{"device-id": agent.deviceID, "flows": updatedFlows, "groups": updatedGroups})
+ logger.Debugw("updateFlowsAndGroups", log.Fields{"device-id": agent.deviceID, "flows": updatedFlows, "groups": updatedGroups})
if (len(updatedFlows) | len(updatedGroups)) == 0 {
- log.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": updatedFlows, "groups": updatedGroups})
+ logger.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": updatedFlows, "groups": updatedGroups})
return coreutils.DoneResponse(), nil
}
@@ -634,11 +634,11 @@
existingGroups := proto.Clone(device.FlowGroups).(*ofp.FlowGroups)
if len(updatedGroups) != 0 && reflect.DeepEqual(existingGroups.Items, updatedGroups) && len(updatedFlows) != 0 && reflect.DeepEqual(existingFlows.Items, updatedFlows) {
- log.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": updatedFlows, "groups": updatedGroups})
+ logger.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": updatedFlows, "groups": updatedGroups})
return coreutils.DoneResponse(), nil
}
- log.Debugw("updating-flows-and-groups",
+ logger.Debugw("updating-flows-and-groups",
log.Fields{
"device-id": agent.deviceID,
"updated-flows": updatedFlows,
@@ -692,7 +692,7 @@
}
}
- log.Debugw("updating-flows-and-groups",
+ logger.Debugw("updating-flows-and-groups",
log.Fields{
"device-id": agent.deviceID,
"flows-to-add": flowsToAdd,
@@ -703,7 +703,7 @@
// Sanity check
if (len(flowsToAdd) | len(flowsToDelete) | len(groupsToAdd) | len(groupsToDelete) | len(updatedGroups)) == 0 {
- log.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": updatedFlows, "groups": updatedGroups})
+ logger.Debugw("nothing-to-update", log.Fields{"device-id": agent.deviceID, "flows": updatedFlows, "groups": updatedGroups})
cancel()
return coreutils.DoneResponse(), nil
}
@@ -743,7 +743,7 @@
//deleteAllFlows deletes all flows in the device table
func (agent *DeviceAgent) deleteAllFlows(ctx context.Context) error {
- log.Debugw("deleteAllFlows", log.Fields{"deviceId": agent.deviceID})
+ logger.Debugw("deleteAllFlows", log.Fields{"deviceId": agent.deviceID})
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
return err
}
@@ -765,12 +765,12 @@
return err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("disableDevice", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("disableDevice", log.Fields{"device-id": agent.deviceID})
cloned := agent.getDeviceWithoutLock()
if cloned.AdminState == voltha.AdminState_DISABLED {
- log.Debugw("device-already-disabled", log.Fields{"id": agent.deviceID})
+ logger.Debugw("device-already-disabled", log.Fields{"id": agent.deviceID})
return nil
}
if cloned.AdminState == voltha.AdminState_PREPROVISIONED ||
@@ -801,7 +801,7 @@
return err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("rebootDevice", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("rebootDevice", log.Fields{"device-id": agent.deviceID})
device := agent.getDeviceWithoutLock()
subCtx, cancel := context.WithTimeout(context.Background(), agent.defaultTimeout)
@@ -815,7 +815,7 @@
}
func (agent *DeviceAgent) deleteDevice(ctx context.Context) error {
- log.Debugw("deleteDevice", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("deleteDevice", log.Fields{"device-id": agent.deviceID})
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
return err
}
@@ -852,7 +852,7 @@
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("setParentId", log.Fields{"device-id": device.Id, "parent-id": parentID})
+ logger.Debugw("setParentId", log.Fields{"device-id": device.Id, "parent-id": parentID})
cloned := agent.getDeviceWithoutLock()
cloned.ParentId = parentID
@@ -869,7 +869,7 @@
return err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("updatePmConfigs", log.Fields{"device-id": pmConfigs.Id})
+ logger.Debugw("updatePmConfigs", log.Fields{"device-id": pmConfigs.Id})
cloned := agent.getDeviceWithoutLock()
cloned.PmConfigs = proto.Clone(pmConfigs).(*voltha.PmConfigs)
@@ -893,7 +893,7 @@
return err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("initPmConfigs", log.Fields{"device-id": pmConfigs.Id})
+ logger.Debugw("initPmConfigs", log.Fields{"device-id": pmConfigs.Id})
cloned := agent.getDeviceWithoutLock()
cloned.PmConfigs = proto.Clone(pmConfigs).(*voltha.PmConfigs)
@@ -913,7 +913,7 @@
return nil, err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("listPmConfigs", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("listPmConfigs", log.Fields{"device-id": agent.deviceID})
return agent.getDeviceWithoutLock().PmConfigs, nil
}
@@ -924,7 +924,7 @@
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("downloadImage", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("downloadImage", log.Fields{"device-id": agent.deviceID})
device := agent.getDeviceWithoutLock()
@@ -939,7 +939,7 @@
cloned.ImageDownloads = []*voltha.ImageDownload{clonedImg}
} else {
if device.AdminState != voltha.AdminState_ENABLED {
- log.Debugw("device-not-enabled", log.Fields{"id": agent.deviceID})
+ logger.Debugw("device-not-enabled", log.Fields{"id": agent.deviceID})
return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, expected-admin-state:%s", agent.deviceID, voltha.AdminState_ENABLED)
}
// Save the image
@@ -983,7 +983,7 @@
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("cancelImageDownload", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("cancelImageDownload", log.Fields{"device-id": agent.deviceID})
device := agent.getDeviceWithoutLock()
@@ -1022,7 +1022,7 @@
return nil, err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("activateImage", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("activateImage", log.Fields{"device-id": agent.deviceID})
cloned := agent.getDeviceWithoutLock()
// Verify whether the Image is in the list of image being downloaded
@@ -1063,7 +1063,7 @@
return nil, err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("revertImage", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("revertImage", log.Fields{"device-id": agent.deviceID})
cloned := agent.getDeviceWithoutLock()
@@ -1098,7 +1098,7 @@
}
func (agent *DeviceAgent) getImageDownloadStatus(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
- log.Debugw("getImageDownloadStatus", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("getImageDownloadStatus", log.Fields{"device-id": agent.deviceID})
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
return nil, err
@@ -1130,7 +1130,7 @@
return err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("updating-image-download", log.Fields{"device-id": agent.deviceID, "img": img})
+ logger.Debugw("updating-image-download", log.Fields{"device-id": agent.deviceID, "img": img})
cloned := agent.getDeviceWithoutLock()
@@ -1162,7 +1162,7 @@
return nil, err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("getImageDownload", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("getImageDownload", log.Fields{"device-id": agent.deviceID})
cloned := agent.getDeviceWithoutLock()
for _, image := range cloned.ImageDownloads {
@@ -1178,14 +1178,14 @@
return nil, err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("listImageDownloads", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("listImageDownloads", log.Fields{"device-id": agent.deviceID})
return &voltha.ImageDownloads{Items: agent.getDeviceWithoutLock().ImageDownloads}, nil
}
// getPorts retrieves the ports information of the device based on the port type.
func (agent *DeviceAgent) getPorts(ctx context.Context, portType voltha.Port_PortType) *voltha.Ports {
- log.Debugw("getPorts", log.Fields{"device-id": agent.deviceID, "port-type": portType})
+ logger.Debugw("getPorts", log.Fields{"device-id": agent.deviceID, "port-type": portType})
ports := &voltha.Ports{}
if device, _ := agent.deviceMgr.GetDevice(ctx, agent.deviceID); device != nil {
for _, port := range device.Ports {
@@ -1199,7 +1199,7 @@
// getSwitchCapability retrieves the switch capability of a parent device
func (agent *DeviceAgent) getSwitchCapability(ctx context.Context) (*ic.SwitchCapability, error) {
- log.Debugw("getSwitchCapability", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("getSwitchCapability", log.Fields{"device-id": agent.deviceID})
cloned, err := agent.getDevice(ctx)
if err != nil {
@@ -1228,7 +1228,7 @@
// getPortCapability retrieves the port capability of a device
func (agent *DeviceAgent) getPortCapability(ctx context.Context, portNo uint32) (*ic.PortCapability, error) {
- log.Debugw("getPortCapability", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("getPortCapability", log.Fields{"device-id": agent.deviceID})
device, err := agent.getDevice(ctx)
if err != nil {
return nil, err
@@ -1265,7 +1265,7 @@
if err, ok := response.(error); ok {
errResp = err
}
- log.Warnw("packet-out-error", log.Fields{
+ logger.Warnw("packet-out-error", log.Fields{
"device-id": agent.deviceID,
"error": errResp,
"packet": hex.EncodeToString(packet),
@@ -1298,20 +1298,20 @@
var ok bool
if len(args) == 2 {
if previous, ok = args[0].(*voltha.Device); !ok {
- log.Errorw("invalid-callback-type", log.Fields{"data": args[0]})
+ logger.Errorw("invalid-callback-type", log.Fields{"data": args[0]})
return nil
}
if current, ok = args[1].(*voltha.Device); !ok {
- log.Errorw("invalid-callback-type", log.Fields{"data": args[1]})
+ logger.Errorw("invalid-callback-type", log.Fields{"data": args[1]})
return nil
}
} else {
- log.Errorw("too-many-args-in-callback", log.Fields{"len": len(args)})
+ logger.Errorw("too-many-args-in-callback", log.Fields{"len": len(args)})
return nil
}
// Perform the state transition in it's own go routine
if err := agent.deviceMgr.processTransition(context.Background(), previous, current); err != nil {
- log.Errorw("failed-process-transition", log.Fields{"device-id": previous.Id,
+ logger.Errorw("failed-process-transition", log.Fields{"device-id": previous.Id,
"previous-admin-state": previous.AdminState, "current-admin-state": current.AdminState})
}
return nil
@@ -1339,7 +1339,7 @@
return err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("updateDeviceUsingAdapterData", log.Fields{"device-id": device.Id})
+ logger.Debugw("updateDeviceUsingAdapterData", log.Fields{"device-id": device.Id})
updatedDevice, err := agent.mergeDeviceInfoFromAdapter(device)
if err != nil {
@@ -1350,7 +1350,7 @@
}
func (agent *DeviceAgent) updateDeviceWithoutLock(ctx context.Context, device *voltha.Device) error {
- log.Debugw("updateDevice", log.Fields{"deviceId": device.Id})
+ logger.Debugw("updateDevice", log.Fields{"deviceId": device.Id})
//cloned := proto.Clone(device).(*voltha.Device)
cloned := device
return agent.updateDeviceInStoreWithoutLock(ctx, cloned, false, "")
@@ -1366,20 +1366,20 @@
// Ensure the enums passed in are valid - they will be invalid if they are not set when this function is invoked
if s, ok := voltha.ConnectStatus_Types_value[connStatus.String()]; ok {
- log.Debugw("updateDeviceStatus-conn", log.Fields{"ok": ok, "val": s})
+ logger.Debugw("updateDeviceStatus-conn", log.Fields{"ok": ok, "val": s})
cloned.ConnectStatus = connStatus
}
if s, ok := voltha.OperStatus_Types_value[operStatus.String()]; ok {
- log.Debugw("updateDeviceStatus-oper", log.Fields{"ok": ok, "val": s})
+ logger.Debugw("updateDeviceStatus-oper", log.Fields{"ok": ok, "val": s})
cloned.OperStatus = operStatus
}
- log.Debugw("updateDeviceStatus", log.Fields{"deviceId": cloned.Id, "operStatus": cloned.OperStatus, "connectStatus": cloned.ConnectStatus})
+ logger.Debugw("updateDeviceStatus", log.Fields{"deviceId": cloned.Id, "operStatus": cloned.OperStatus, "connectStatus": cloned.ConnectStatus})
// Store the device
return agent.updateDeviceInStoreWithoutLock(ctx, cloned, false, "")
}
func (agent *DeviceAgent) updatePortsOperState(ctx context.Context, operStatus voltha.OperStatus_Types) error {
- log.Debugw("updatePortsOperState", log.Fields{"device-id": agent.deviceID})
+ logger.Debugw("updatePortsOperState", log.Fields{"device-id": agent.deviceID})
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
return err
}
@@ -1410,13 +1410,13 @@
port.OperStatus = operStatus
}
}
- log.Debugw("portStatusUpdate", log.Fields{"deviceId": cloned.Id})
+ logger.Debugw("portStatusUpdate", log.Fields{"deviceId": cloned.Id})
// Store the device
return agent.updateDeviceInStoreWithoutLock(ctx, cloned, false, "")
}
func (agent *DeviceAgent) deleteAllPorts(ctx context.Context) error {
- log.Debugw("deleteAllPorts", log.Fields{"deviceId": agent.deviceID})
+ logger.Debugw("deleteAllPorts", log.Fields{"deviceId": agent.deviceID})
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
return err
}
@@ -1426,16 +1426,16 @@
if cloned.AdminState != voltha.AdminState_DISABLED && cloned.AdminState != voltha.AdminState_DELETED {
err := status.Error(codes.FailedPrecondition, fmt.Sprintf("invalid-state-%v", cloned.AdminState))
- log.Warnw("invalid-state-removing-ports", log.Fields{"state": cloned.AdminState, "error": err})
+ logger.Warnw("invalid-state-removing-ports", log.Fields{"state": cloned.AdminState, "error": err})
return err
}
if len(cloned.Ports) == 0 {
- log.Debugw("no-ports-present", log.Fields{"deviceId": agent.deviceID})
+ logger.Debugw("no-ports-present", log.Fields{"deviceId": agent.deviceID})
return nil
}
cloned.Ports = []*voltha.Port{}
- log.Debugw("portStatusUpdate", log.Fields{"deviceId": cloned.Id})
+ logger.Debugw("portStatusUpdate", log.Fields{"deviceId": cloned.Id})
// Store the device
return agent.updateDeviceInStoreWithoutLock(ctx, cloned, false, "")
}
@@ -1445,26 +1445,26 @@
return err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("addPort", log.Fields{"deviceId": agent.deviceID})
+ logger.Debugw("addPort", log.Fields{"deviceId": agent.deviceID})
cloned := agent.getDeviceWithoutLock()
updatePort := false
if cloned.Ports == nil {
// First port
- log.Debugw("addPort-first-port-to-add", log.Fields{"deviceId": agent.deviceID})
+ logger.Debugw("addPort-first-port-to-add", log.Fields{"deviceId": agent.deviceID})
cloned.Ports = make([]*voltha.Port, 0)
} else {
for _, p := range cloned.Ports {
if p.Type == port.Type && p.PortNo == port.PortNo {
if p.Label == "" && p.Type == voltha.Port_PON_OLT {
//Creation of OLT PON port is being processed after a default PON port was created. Just update it.
- log.Infow("update-pon-port-created-by-default", log.Fields{"default-port": p, "port-to-add": port})
+ logger.Infow("update-pon-port-created-by-default", log.Fields{"default-port": p, "port-to-add": port})
p.Label = port.Label
p.OperStatus = port.OperStatus
updatePort = true
break
}
- log.Debugw("port already exists", log.Fields{"port": port})
+ logger.Debugw("port already exists", log.Fields{"port": port})
return nil
}
}
@@ -1484,7 +1484,7 @@
return err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("adding-peer-peerPort", log.Fields{"device-id": agent.deviceID, "peer-peerPort": peerPort})
+ logger.Debugw("adding-peer-peerPort", log.Fields{"device-id": agent.deviceID, "peer-peerPort": peerPort})
cloned := agent.getDeviceWithoutLock()
@@ -1494,7 +1494,7 @@
if port.PortNo == peerPort.PortNo { // found peerPort
cp := proto.Clone(peerPort).(*voltha.Port_PeerPort)
port.Peers = append(port.Peers, cp)
- log.Debugw("found-peer", log.Fields{"device-id": agent.deviceID, "portNo": peerPort.PortNo, "deviceId": agent.deviceID})
+ logger.Debugw("found-peer", log.Fields{"device-id": agent.deviceID, "portNo": peerPort.PortNo, "deviceId": agent.deviceID})
found = true
break
}
@@ -1510,7 +1510,7 @@
Peers: []*voltha.Port_PeerPort{proto.Clone(peerPort).(*voltha.Port_PeerPort)},
}
cloned.Ports = append(cloned.Ports, ponPort)
- log.Infow("adding-default-pon-port", log.Fields{"device-id": agent.deviceID, "peer": peerPort, "pon-port": ponPort})
+ logger.Infow("adding-default-pon-port", log.Fields{"device-id": agent.deviceID, "peer": peerPort, "pon-port": ponPort})
}
// Store the device
return agent.updateDeviceInStoreWithoutLock(ctx, cloned, false, "")
@@ -1519,7 +1519,7 @@
// TODO: A generic device update by attribute
func (agent *DeviceAgent) updateDeviceAttribute(ctx context.Context, name string, value interface{}) {
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
- log.Warnw("request-aborted", log.Fields{"device-id": agent.deviceID, "name": name, "error": err})
+ logger.Warnw("request-aborted", log.Fields{"device-id": agent.deviceID, "name": name, "error": err})
return
}
defer agent.requestQueue.RequestComplete()
@@ -1547,11 +1547,11 @@
}
}
}
- log.Debugw("update-field-status", log.Fields{"deviceId": cloned.Id, "name": name, "updated": updated})
+ logger.Debugw("update-field-status", log.Fields{"deviceId": cloned.Id, "name": name, "updated": updated})
// Save the data
if err := agent.updateDeviceInStoreWithoutLock(ctx, cloned, false, ""); err != nil {
- log.Warnw("attribute-update-failed", log.Fields{"attribute": name, "value": value})
+ logger.Warnw("attribute-update-failed", log.Fields{"attribute": name, "value": value})
}
}
@@ -1560,7 +1560,7 @@
return err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("simulateAlarm", log.Fields{"id": agent.deviceID})
+ logger.Debugw("simulateAlarm", log.Fields{"id": agent.deviceID})
cloned := agent.getDeviceWithoutLock()
@@ -1585,7 +1585,7 @@
if afterUpdate == nil {
return status.Errorf(codes.Internal, "failed-update-device:%s", agent.deviceID)
}
- log.Debugw("updated-device-in-store", log.Fields{"deviceId: ": agent.deviceID})
+ logger.Debugw("updated-device-in-store", log.Fields{"deviceId: ": agent.deviceID})
agent.device = proto.Clone(device).(*voltha.Device)
@@ -1600,7 +1600,7 @@
cloned := agent.getDeviceWithoutLock()
cloned.Reason = reason
- log.Debugw("updateDeviceReason", log.Fields{"deviceId": cloned.Id, "reason": cloned.Reason})
+ logger.Debugw("updateDeviceReason", log.Fields{"deviceId": cloned.Id, "reason": cloned.Reason})
// Store the device
return agent.updateDeviceInStoreWithoutLock(ctx, cloned, false, "")
}
@@ -1610,7 +1610,7 @@
return err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("disablePort", log.Fields{"device-id": agent.deviceID, "port-no": Port.PortNo})
+ logger.Debugw("disablePort", log.Fields{"device-id": agent.deviceID, "port-no": Port.PortNo})
var cp *voltha.Port
// Get the most up to date the device info
device := agent.getDeviceWithoutLock()
@@ -1631,7 +1631,7 @@
}
// Store the device
if err := agent.updateDeviceInStoreWithoutLock(ctx, device, false, ""); err != nil {
- log.Debugw("updateDeviceInStoreWithoutLock error ", log.Fields{"device-id": agent.deviceID, "port-no": Port.PortNo, "error": err})
+ logger.Debugw("updateDeviceInStoreWithoutLock error ", log.Fields{"device-id": agent.deviceID, "port-no": Port.PortNo, "error": err})
return err
}
@@ -1651,7 +1651,7 @@
return err
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("enablePort", log.Fields{"device-id": agent.deviceID, "port-no": Port.PortNo})
+ logger.Debugw("enablePort", log.Fields{"device-id": agent.deviceID, "port-no": Port.PortNo})
var cp *voltha.Port
// Get the most up to date the device info
@@ -1673,7 +1673,7 @@
}
// Store the device
if err := agent.updateDeviceInStoreWithoutLock(ctx, device, false, ""); err != nil {
- log.Debugw("updateDeviceInStoreWithoutLock error ", log.Fields{"device-id": agent.deviceID, "port-no": Port.PortNo, "error": err})
+ logger.Debugw("updateDeviceInStoreWithoutLock error ", log.Fields{"device-id": agent.deviceID, "port-no": Port.PortNo, "error": err})
return err
}
//send request to adapter
@@ -1693,7 +1693,7 @@
}
defer agent.requestQueue.RequestComplete()
- log.Debugw("childDeviceLost", log.Fields{"child-device-id": device.Id, "parent-device-id": agent.deviceID})
+ logger.Debugw("childDeviceLost", log.Fields{"child-device-id": device.Id, "parent-device-ud": agent.deviceID})
//Remove the associated peer ports on the parent device
parentDevice := agent.getDeviceWithoutLock()
@@ -1756,6 +1756,6 @@
if err := ptypes.UnmarshalAny(rpcResponse.Reply, testResp); err != nil {
return nil, status.Errorf(codes.InvalidArgument, "%s", err.Error())
}
- log.Debugw("Omci_test_Request-Success-device-agent", log.Fields{"testResp": testResp})
+ logger.Debugw("Omci_test_Request-Success-device-agent", log.Fields{"testResp": testResp})
return testResp, nil
}
diff --git a/rw_core/core/device_agent_test.go b/rw_core/core/device_agent_test.go
index 85fc09e..4f1506f 100755
--- a/rw_core/core/device_agent_test.go
+++ b/rw_core/core/device_agent_test.go
@@ -21,7 +21,6 @@
"github.com/opencord/voltha-go/rw_core/config"
com "github.com/opencord/voltha-lib-go/v3/pkg/adapters/common"
"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
lm "github.com/opencord/voltha-lib-go/v3/pkg/mocks"
ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
"github.com/opencord/voltha-protos/v3/go/voltha"
@@ -55,7 +54,7 @@
var err error
test.etcdServer, test.kvClientPort, err = startEmbeddedEtcdServer("voltha.rwcore.da.test", "voltha.rwcore.da.etcd", "error")
if err != nil {
- log.Fatal(err)
+ logger.Fatal(err)
}
// Create the kafka client
test.kClient = lm.NewKafkaClient()
@@ -106,7 +105,7 @@
cfg.InCompetingMode = inCompeteMode
grpcPort, err := freeport.GetFreePort()
if err != nil {
- log.Fatal("Cannot get a freeport for grpc")
+ logger.Fatal("Cannot get a freeport for grpc")
}
cfg.GrpcPort = grpcPort
cfg.GrpcHost = "127.0.0.1"
@@ -115,7 +114,7 @@
dat.core = NewCore(context.Background(), dat.coreInstanceID, cfg, client, dat.kClient)
err = dat.core.Start(context.Background())
if err != nil {
- log.Fatal("Cannot start core")
+ logger.Fatal("Cannot start core")
}
}
diff --git a/rw_core/core/device_manager.go b/rw_core/core/device_manager.go
index be23f5e..e8b79a6 100755
--- a/rw_core/core/device_manager.go
+++ b/rw_core/core/device_manager.go
@@ -72,18 +72,18 @@
}
func (dMgr *DeviceManager) start(ctx context.Context, logicalDeviceMgr *LogicalDeviceManager) {
- log.Info("starting-device-manager")
+ logger.Info("starting-device-manager")
dMgr.logicalDeviceMgr = logicalDeviceMgr
dMgr.stateTransitions = NewTransitionMap(dMgr)
probe.UpdateStatusFromContext(ctx, "device-manager", probe.ServiceStatusRunning)
- log.Info("device-manager-started")
+ logger.Info("device-manager-started")
}
func (dMgr *DeviceManager) stop(ctx context.Context) {
- log.Info("stopping-device-manager")
+ logger.Info("stopping-device-manager")
dMgr.exitChannel <- 1
probe.UpdateStatusFromContext(ctx, "device-manager", probe.ServiceStatusStopped)
- log.Info("device-manager-stopped")
+ logger.Info("device-manager-stopped")
}
func sendResponse(ctx context.Context, ch chan interface{}, result interface{}) {
@@ -91,10 +91,10 @@
// Returned response only of the ctx has not been cancelled/timeout/etc
// Channel is automatically closed when a context is Done
ch <- result
- log.Debugw("sendResponse", log.Fields{"result": result})
+ logger.Debugw("sendResponse", log.Fields{"result": result})
} else {
// Should the transaction be reverted back?
- log.Debugw("sendResponse-context-error", log.Fields{"context-error": ctx.Err()})
+ logger.Debugw("sendResponse-context-error", log.Fields{"context-error": ctx.Err()})
}
}
@@ -132,13 +132,13 @@
go func() {
_, err = dMgr.core.deviceOwnership.OwnedByMe(ctx, &utils.DeviceID{ID: deviceID})
if err != nil {
- log.Errorw("unable-to-find-core-instance-active-owns-this-device", log.Fields{"error": err})
+ logger.Errorw("unable-to-find-core-instance-active-owns-this-device", log.Fields{"error": err})
}
}()
return agent.(*DeviceAgent)
}
//TODO: Change the return params to return an error as well
- log.Errorw("loading-device-failed", log.Fields{"deviceId": deviceID, "error": err})
+ logger.Errorw("loading-device-failed", log.Fields{"deviceId": deviceID, "error": err})
return nil
}
@@ -157,16 +157,16 @@
func (dMgr *DeviceManager) createDevice(ctx context.Context, device *voltha.Device, ch chan interface{}) {
deviceExist, err := dMgr.isParentDeviceExist(ctx, device)
if err != nil {
- log.Errorf("Failed to fetch parent device info")
+ logger.Errorf("Failed to fetch parent device info")
sendResponse(ctx, ch, err)
return
}
if deviceExist {
- log.Errorf("Device is Pre-provisioned already with same IP-Port or MAC Address")
+ logger.Errorf("Device is Pre-provisioned already with same IP-Port or MAC Address")
sendResponse(ctx, ch, errors.New("Device is already pre-provisioned"))
return
}
- log.Debugw("createDevice", log.Fields{"device": device, "aproxy": dMgr.adapterProxy})
+ logger.Debugw("createDevice", log.Fields{"device": device, "aproxy": dMgr.adapterProxy})
// Ensure this device is set as root
device.Root = true
@@ -174,7 +174,7 @@
agent := newDeviceAgent(dMgr.adapterProxy, device, dMgr, dMgr.clusterDataProxy, dMgr.defaultTimeout)
device, err = agent.start(ctx, device)
if err != nil {
- log.Errorw("Fail-to-start-device", log.Fields{"device-id": agent.deviceID, "error": err})
+ logger.Errorw("Fail-to-start-device", log.Fields{"device-id": agent.deviceID, "error": err})
sendResponse(ctx, ch, err)
return
}
@@ -184,11 +184,11 @@
}
func (dMgr *DeviceManager) enableDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
- log.Debugw("enableDevice", log.Fields{"deviceid": id})
+ logger.Debugw("enableDevice", log.Fields{"deviceid": id})
var res interface{}
if agent := dMgr.getDeviceAgent(ctx, id.Id); agent != nil {
res = agent.enableDevice(ctx)
- log.Debugw("EnableDevice-result", log.Fields{"result": res})
+ logger.Debugw("EnableDevice-result", log.Fields{"result": res})
} else {
res = status.Errorf(codes.NotFound, "%s", id.Id)
}
@@ -197,11 +197,11 @@
}
func (dMgr *DeviceManager) disableDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
- log.Debugw("disableDevice", log.Fields{"deviceid": id})
+ logger.Debugw("disableDevice", log.Fields{"deviceid": id})
var res interface{}
if agent := dMgr.getDeviceAgent(ctx, id.Id); agent != nil {
res = agent.disableDevice(ctx)
- log.Debugw("disableDevice-result", log.Fields{"result": res})
+ logger.Debugw("disableDevice-result", log.Fields{"result": res})
} else {
res = status.Errorf(codes.NotFound, "%s", id.Id)
}
@@ -210,11 +210,11 @@
}
func (dMgr *DeviceManager) rebootDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
- log.Debugw("rebootDevice", log.Fields{"deviceid": id})
+ logger.Debugw("rebootDevice", log.Fields{"deviceid": id})
var res interface{}
if agent := dMgr.getDeviceAgent(ctx, id.Id); agent != nil {
res = agent.rebootDevice(ctx)
- log.Debugw("rebootDevice-result", log.Fields{"result": res})
+ logger.Debugw("rebootDevice-result", log.Fields{"result": res})
} else {
res = status.Errorf(codes.NotFound, "%s", id.Id)
}
@@ -222,11 +222,11 @@
}
func (dMgr *DeviceManager) deleteDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
- log.Debugw("deleteDevice", log.Fields{"deviceid": id})
+ logger.Debugw("deleteDevice", log.Fields{"deviceid": id})
var res interface{}
if agent := dMgr.getDeviceAgent(ctx, id.Id); agent != nil {
res = agent.deleteDevice(ctx)
- log.Debugw("deleteDevice-result", log.Fields{"result": res})
+ logger.Debugw("deleteDevice-result", log.Fields{"result": res})
} else {
res = status.Errorf(codes.NotFound, "%s", id.Id)
}
@@ -237,7 +237,7 @@
// This function is called only in the Core that does not own this device. In the Core that owns this device then a
// deletion deletion also includes removal of any reference of this device.
func (dMgr *DeviceManager) stopManagingDevice(ctx context.Context, id string) {
- log.Infow("stopManagingDevice", log.Fields{"deviceId": id})
+ logger.Infow("stopManagingDevice", log.Fields{"deviceId": id})
if dMgr.IsDeviceInCache(id) { // Proceed only if an agent is present for this device
if root, _ := dMgr.IsRootDevice(id); root {
// stop managing the logical device
@@ -245,20 +245,20 @@
if ldeviceID != "" { // Can happen if logical device agent was already stopped
err := dMgr.core.deviceOwnership.AbandonDevice(ldeviceID)
if err != nil {
- log.Errorw("unable-to-abandon-the-device", log.Fields{"error": err})
+ logger.Errorw("unable-to-abandon-the-device", log.Fields{"error": err})
}
}
// We do not need to stop the child devices as this is taken care by the state machine.
}
if agent := dMgr.getDeviceAgent(ctx, id); agent != nil {
if err := agent.stop(ctx); err != nil {
- log.Warnw("unable-to-stop-device-agent", log.Fields{"device-id": agent.deviceID, "error": err})
+ logger.Warnw("unable-to-stop-device-agent", log.Fields{"device-id": agent.deviceID, "error": err})
}
dMgr.deleteDeviceAgentFromMap(agent)
// Abandon the device ownership
err := dMgr.core.deviceOwnership.AbandonDevice(id)
if err != nil {
- log.Warnw("unable-to-abandon-device", log.Fields{"error": err})
+ logger.Warnw("unable-to-abandon-device", log.Fields{"error": err})
}
}
}
@@ -266,14 +266,14 @@
// RunPostDeviceDelete removes any reference of this device
func (dMgr *DeviceManager) RunPostDeviceDelete(ctx context.Context, cDevice *voltha.Device, pDevice *voltha.Device) error {
- log.Infow("RunPostDeviceDelete", log.Fields{"deviceId": cDevice.Id})
+ logger.Infow("RunPostDeviceDelete", log.Fields{"deviceId": cDevice.Id})
dMgr.stopManagingDevice(ctx, cDevice.Id)
return nil
}
// GetDevice will returns a device, either from memory or from the dB, if present
func (dMgr *DeviceManager) GetDevice(ctx context.Context, id string) (*voltha.Device, error) {
- log.Debugw("GetDevice", log.Fields{"deviceid": id})
+ logger.Debugw("GetDevice", log.Fields{"deviceid": id})
if agent := dMgr.getDeviceAgent(ctx, id); agent != nil {
return agent.getDevice(ctx)
}
@@ -282,7 +282,7 @@
// GetChildDevice will return a device, either from memory or from the dB, if present
func (dMgr *DeviceManager) GetChildDevice(ctx context.Context, parentDeviceID string, serialNumber string, onuID int64, parentPortNo int64) (*voltha.Device, error) {
- log.Debugw("GetChildDevice", log.Fields{"parentDeviceid": parentDeviceID, "serialNumber": serialNumber,
+ logger.Debugw("GetChildDevice", log.Fields{"parentDeviceid": parentDeviceID, "serialNumber": serialNumber,
"parentPortNo": parentPortNo, "onuId": onuID})
var parentDevice *voltha.Device
@@ -295,7 +295,7 @@
return nil, status.Errorf(codes.Aborted, "%s", err.Error())
}
if len(childDeviceIds) == 0 {
- log.Debugw("no-child-devices", log.Fields{"parentDeviceId": parentDevice.Id, "serialNumber": serialNumber, "onuId": onuID})
+ logger.Debugw("no-child-devices", log.Fields{"parentDeviceId": parentDevice.Id, "serialNumber": serialNumber, "onuId": onuID})
return nil, status.Errorf(codes.NotFound, "%s", parentDeviceID)
}
@@ -307,14 +307,14 @@
foundOnuID := false
if searchDevice.ProxyAddress.OnuId == uint32(onuID) {
if searchDevice.ParentPortNo == uint32(parentPortNo) {
- log.Debugw("found-child-by-onuid", log.Fields{"parentDeviceId": parentDevice.Id, "onuId": onuID})
+ logger.Debugw("found-child-by-onuid", log.Fields{"parentDeviceId": parentDevice.Id, "onuId": onuID})
foundOnuID = true
}
}
foundSerialNumber := false
if searchDevice.SerialNumber == serialNumber {
- log.Debugw("found-child-by-serialnumber", log.Fields{"parentDeviceId": parentDevice.Id, "serialNumber": serialNumber})
+ logger.Debugw("found-child-by-serialnumber", log.Fields{"parentDeviceId": parentDevice.Id, "serialNumber": serialNumber})
foundSerialNumber = true
}
@@ -334,18 +334,18 @@
}
if foundChildDevice != nil {
- log.Debugw("child-device-found", log.Fields{"parentDeviceId": parentDevice.Id, "foundChildDevice": foundChildDevice})
+ logger.Debugw("child-device-found", log.Fields{"parentDeviceId": parentDevice.Id, "foundChildDevice": foundChildDevice})
return foundChildDevice, nil
}
- log.Warnw("child-device-not-found", log.Fields{"parentDeviceId": parentDevice.Id,
+ logger.Warnw("child-device-not-found", log.Fields{"parentDeviceId": parentDevice.Id,
"serialNumber": serialNumber, "onuId": onuID, "parentPortNo": parentPortNo})
return nil, status.Errorf(codes.NotFound, "%s", parentDeviceID)
}
// GetChildDeviceWithProxyAddress will return a device based on proxy address
func (dMgr *DeviceManager) GetChildDeviceWithProxyAddress(ctx context.Context, proxyAddress *voltha.Device_ProxyAddress) (*voltha.Device, error) {
- log.Debugw("GetChildDeviceWithProxyAddress", log.Fields{"proxyAddress": proxyAddress})
+ logger.Debugw("GetChildDeviceWithProxyAddress", log.Fields{"proxyAddress": proxyAddress})
var parentDevice *voltha.Device
var err error
@@ -357,7 +357,7 @@
return nil, status.Errorf(codes.Aborted, "%s", err.Error())
}
if len(childDeviceIds) == 0 {
- log.Debugw("no-child-devices", log.Fields{"parentDeviceId": parentDevice.Id})
+ logger.Debugw("no-child-devices", log.Fields{"parentDeviceId": parentDevice.Id})
return nil, status.Errorf(codes.NotFound, "%s", proxyAddress)
}
@@ -372,11 +372,11 @@
}
if foundChildDevice != nil {
- log.Debugw("child-device-found", log.Fields{"proxyAddress": proxyAddress})
+ logger.Debugw("child-device-found", log.Fields{"proxyAddress": proxyAddress})
return foundChildDevice, nil
}
- log.Warnw("child-device-not-found", log.Fields{"proxyAddress": proxyAddress})
+ logger.Warnw("child-device-not-found", log.Fields{"proxyAddress": proxyAddress})
return nil, status.Errorf(codes.NotFound, "%s", proxyAddress)
}
@@ -398,11 +398,11 @@
// ListDevices retrieves the latest devices from the data model
func (dMgr *DeviceManager) ListDevices(ctx context.Context) (*voltha.Devices, error) {
- log.Debug("ListDevices")
+ logger.Debug("ListDevices")
result := &voltha.Devices{}
devices, err := dMgr.clusterDataProxy.List(ctx, "/devices", 0, false, "")
if err != nil {
- log.Errorw("failed-to-list-devices-from-cluster-proxy", log.Fields{"error": err})
+ logger.Errorw("failed-to-list-devices-from-cluster-proxy", log.Fields{"error": err})
return nil, err
}
if devices != nil {
@@ -410,10 +410,10 @@
device := d.(*voltha.Device)
// If device is not in memory then set it up
if !dMgr.IsDeviceInCache(device.Id) {
- log.Debugw("loading-device-from-Model", log.Fields{"id": device.Id})
+ logger.Debugw("loading-device-from-Model", log.Fields{"id": device.Id})
agent := newDeviceAgent(dMgr.adapterProxy, device, dMgr, dMgr.clusterDataProxy, dMgr.defaultTimeout)
if _, err := agent.start(ctx, nil); err != nil {
- log.Warnw("failure-starting-agent", log.Fields{"deviceId": device.Id})
+ logger.Warnw("failure-starting-agent", log.Fields{"deviceId": device.Id})
} else {
dMgr.addDeviceAgentToMap(agent)
}
@@ -421,7 +421,7 @@
result.Items = append(result.Items, device)
}
}
- log.Debugw("ListDevices-end", log.Fields{"len": len(result.Items)})
+ logger.Debugw("ListDevices-end", log.Fields{"len": len(result.Items)})
return result, nil
}
@@ -430,7 +430,7 @@
hostPort := newDevice.GetHostAndPort()
devices, err := dMgr.clusterDataProxy.List(ctx, "/devices", 0, false, "")
if err != nil {
- log.Errorw("Failed to list devices from cluster data proxy", log.Fields{"error": err})
+ logger.Errorw("Failed to list devices from cluster data proxy", log.Fields{"error": err})
return false, err
}
if devices != nil {
@@ -453,7 +453,7 @@
func (dMgr *DeviceManager) getDeviceFromModel(ctx context.Context, deviceID string) (*voltha.Device, error) {
device, err := dMgr.clusterDataProxy.Get(ctx, "/devices/"+deviceID, 0, false, "")
if err != nil {
- log.Errorw("failed-to-get-device-info-from-cluster-proxy", log.Fields{"error": err})
+ logger.Errorw("failed-to-get-device-info-from-cluster-proxy", log.Fields{"error": err})
return nil, err
}
if device != nil {
@@ -478,15 +478,15 @@
dMgr.devicesLoadingLock.Unlock()
// Proceed with the loading only if the device exist in the Model (could have been deleted)
if device, err = dMgr.getDeviceFromModel(ctx, deviceID); err == nil {
- log.Debugw("loading-device", log.Fields{"deviceId": deviceID})
+ logger.Debugw("loading-device", log.Fields{"deviceId": deviceID})
agent := newDeviceAgent(dMgr.adapterProxy, device, dMgr, dMgr.clusterDataProxy, dMgr.defaultTimeout)
if _, err = agent.start(ctx, nil); err != nil {
- log.Warnw("Failure loading device", log.Fields{"deviceId": deviceID, "error": err})
+ logger.Warnw("Failure loading device", log.Fields{"deviceId": deviceID, "error": err})
} else {
dMgr.addDeviceAgentToMap(agent)
}
} else {
- log.Debugw("Device not in model", log.Fields{"deviceId": deviceID})
+ logger.Debugw("Device not in model", log.Fields{"deviceId": deviceID})
}
// announce completion of task to any number of waiting channels
dMgr.devicesLoadingLock.Lock()
@@ -515,28 +515,28 @@
// loadRootDeviceParentAndChildren loads the children and parents of a root device in memory
func (dMgr *DeviceManager) loadRootDeviceParentAndChildren(ctx context.Context, device *voltha.Device) error {
- log.Debugw("loading-parent-and-children", log.Fields{"deviceId": device.Id})
+ logger.Debugw("loading-parent-and-children", log.Fields{"deviceId": device.Id})
if device.Root {
// Scenario A
if device.ParentId != "" {
// Load logical device if needed.
if err := dMgr.logicalDeviceMgr.load(ctx, device.ParentId); err != nil {
- log.Warnw("failure-loading-logical-device", log.Fields{"lDeviceId": device.ParentId})
+ logger.Warnw("failure-loading-logical-device", log.Fields{"lDeviceId": device.ParentId})
}
} else {
- log.Debugw("no-parent-to-load", log.Fields{"deviceId": device.Id})
+ logger.Debugw("no-parent-to-load", log.Fields{"deviceId": device.Id})
}
// Load all child devices, if needed
if childDeviceIds, err := dMgr.getAllChildDeviceIds(device); err == nil {
for _, childDeviceID := range childDeviceIds {
if _, err := dMgr.loadDevice(ctx, childDeviceID); err != nil {
- log.Warnw("failure-loading-device", log.Fields{"deviceId": childDeviceID, "error": err})
+ logger.Warnw("failure-loading-device", log.Fields{"deviceId": childDeviceID, "error": err})
return err
}
}
- log.Debugw("loaded-children", log.Fields{"deviceId": device.Id, "numChildren": len(childDeviceIds)})
+ logger.Debugw("loaded-children", log.Fields{"deviceId": device.Id, "numChildren": len(childDeviceIds)})
} else {
- log.Debugw("no-child-to-load", log.Fields{"deviceId": device.Id})
+ logger.Debugw("no-child-to-load", log.Fields{"deviceId": device.Id})
}
}
return nil
@@ -547,7 +547,7 @@
// acting on the device is received by the core. In such a scenario, the Core will load the device in memory first
// and the proceed with the request.
func (dMgr *DeviceManager) load(ctx context.Context, deviceID string) error {
- log.Debug("load...")
+ logger.Debug("load...")
// First load the device - this may fail in case the device was deleted intentionally by the other core
var dAgent *DeviceAgent
var err error
@@ -569,10 +569,10 @@
if device.Root {
// Load all children as well as the parent of this device (logical_device)
if err := dMgr.loadRootDeviceParentAndChildren(ctx, device); err != nil {
- log.Warnw("failure-loading-device-parent-and-children", log.Fields{"deviceId": deviceID})
+ logger.Warnw("failure-loading-device-parent-and-children", log.Fields{"deviceId": deviceID})
return err
}
- log.Debugw("successfully-loaded-parent-and-children", log.Fields{"deviceId": deviceID})
+ logger.Debugw("successfully-loaded-parent-and-children", log.Fields{"deviceId": deviceID})
} else {
// Scenario B - use the parentId of that device (root device) to trigger the loading
if device.ParentId != "" {
@@ -584,7 +584,7 @@
// ListDeviceIds retrieves the latest device IDs information from the data model (memory data only)
func (dMgr *DeviceManager) ListDeviceIds() (*voltha.IDs, error) {
- log.Debug("ListDeviceIDs")
+ logger.Debug("ListDeviceIDs")
// Report only device IDs that are in the device agent map
return dMgr.listDeviceIdsFromMap(), nil
}
@@ -592,7 +592,7 @@
//ReconcileDevices is a request to a voltha core to update its list of managed devices. This will
//trigger loading the devices along with their children and parent in memory
func (dMgr *DeviceManager) ReconcileDevices(ctx context.Context, ids *voltha.IDs, ch chan interface{}) {
- log.Debugw("ReconcileDevices", log.Fields{"numDevices": len(ids.Items)})
+ logger.Debugw("ReconcileDevices", log.Fields{"numDevices": len(ids.Items)})
var res interface{}
if ids != nil && len(ids.Items) != 0 {
toReconcile := len(ids.Items)
@@ -600,7 +600,7 @@
var err error
for _, id := range ids.Items {
if err = dMgr.load(ctx, id.Id); err != nil {
- log.Warnw("failure-reconciling-device", log.Fields{"deviceId": id.Id, "error": err})
+ logger.Warnw("failure-reconciling-device", log.Fields{"deviceId": id.Id, "error": err})
} else {
reconciled++
}
@@ -624,12 +624,12 @@
// adapterRestarted is invoked whenever an adapter is restarted
func (dMgr *DeviceManager) adapterRestarted(ctx context.Context, adapter *voltha.Adapter) error {
- log.Debugw("adapter-restarted", log.Fields{"adapter": adapter.Id})
+ logger.Debugw("adapter-restarted", log.Fields{"adapter": adapter.Id})
// Let's reconcile the device managed by this Core only
rootDeviceIds := dMgr.core.deviceOwnership.GetAllDeviceIdsOwnedByMe()
if len(rootDeviceIds) == 0 {
- log.Debugw("nothing-to-reconcile", log.Fields{"adapterId": adapter.Id})
+ logger.Debugw("nothing-to-reconcile", log.Fields{"adapterId": adapter.Id})
return nil
}
@@ -638,10 +638,10 @@
if rootDevice, _ := dMgr.getDeviceFromModel(ctx, rootDeviceID); rootDevice != nil {
if rootDevice.Adapter == adapter.Id {
if isOkToReconcile(rootDevice) {
- log.Debugw("reconciling-root-device", log.Fields{"rootId": rootDevice.Id})
+ logger.Debugw("reconciling-root-device", log.Fields{"rootId": rootDevice.Id})
responses = append(responses, dMgr.sendReconcileDeviceRequest(ctx, rootDevice))
} else {
- log.Debugw("not-reconciling-root-device", log.Fields{"rootId": rootDevice.Id, "state": rootDevice.AdminState})
+ logger.Debugw("not-reconciling-root-device", log.Fields{"rootId": rootDevice.Id, "state": rootDevice.AdminState})
}
} else { // Should we be reconciling the root's children instead?
childManagedByAdapter:
@@ -650,10 +650,10 @@
if childDevice, _ := dMgr.getDeviceFromModel(ctx, peer.DeviceId); childDevice != nil {
if childDevice.Adapter == adapter.Id {
if isOkToReconcile(childDevice) {
- log.Debugw("reconciling-child-device", log.Fields{"childId": childDevice.Id})
+ logger.Debugw("reconciling-child-device", log.Fields{"childId": childDevice.Id})
responses = append(responses, dMgr.sendReconcileDeviceRequest(ctx, childDevice))
} else {
- log.Debugw("not-reconciling-child-device", log.Fields{"childId": childDevice.Id, "state": childDevice.AdminState})
+ logger.Debugw("not-reconciling-child-device", log.Fields{"childId": childDevice.Id, "state": childDevice.AdminState})
}
} else {
// All child devices under a parent device are typically managed by the same adapter type.
@@ -672,7 +672,7 @@
return status.Errorf(codes.Aborted, "errors-%s", res)
}
} else {
- log.Debugw("no-managed-device-to-reconcile", log.Fields{"adapterId": adapter.Id})
+ logger.Debugw("no-managed-device-to-reconcile", log.Fields{"adapterId": adapter.Id})
}
return nil
}
@@ -719,7 +719,7 @@
}
func (dMgr *DeviceManager) updateDeviceUsingAdapterData(ctx context.Context, device *voltha.Device) error {
- log.Debugw("updateDeviceUsingAdapterData", log.Fields{"deviceid": device.Id, "device": device})
+ logger.Debugw("updateDeviceUsingAdapterData", log.Fields{"deviceid": device.Id, "device": device})
if agent := dMgr.getDeviceAgent(ctx, device.Id); agent != nil {
return agent.updateDeviceUsingAdapterData(ctx, device)
}
@@ -737,7 +737,7 @@
for _, peerPort := range port.Peers {
if agent := dMgr.getDeviceAgent(ctx, peerPort.DeviceId); agent != nil {
if err := agent.addPeerPort(ctx, meAsPeer); err != nil {
- log.Errorw("failed-to-add-peer", log.Fields{"peer-device-id": peerPort.DeviceId})
+ logger.Errorw("failed-to-add-peer", log.Fields{"peer-device-id": peerPort.DeviceId})
return err
}
}
@@ -749,11 +749,11 @@
go func() {
err = dMgr.logicalDeviceMgr.updateLogicalPort(context.Background(), device, port)
if err != nil {
- log.Errorw("unable-to-update-logical-port", log.Fields{"error": err})
+ logger.Errorw("unable-to-update-logical-port", log.Fields{"error": err})
}
}()
} else {
- log.Errorw("failed-to-retrieve-device", log.Fields{"deviceId": deviceID})
+ logger.Errorw("failed-to-retrieve-device", log.Fields{"deviceId": deviceID})
return err
}
return nil
@@ -762,7 +762,7 @@
}
func (dMgr *DeviceManager) addFlowsAndGroups(ctx context.Context, deviceID string, flows []*ofp.OfpFlowStats, groups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) error {
- log.Debugw("addFlowsAndGroups", log.Fields{"deviceid": deviceID, "groups:": groups, "flowMetadata": flowMetadata})
+ logger.Debugw("addFlowsAndGroups", log.Fields{"deviceid": deviceID, "groups:": groups, "flowMetadata": flowMetadata})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
return agent.addFlowsAndGroups(ctx, flows, groups, flowMetadata)
}
@@ -770,7 +770,7 @@
}
func (dMgr *DeviceManager) deleteFlowsAndGroups(ctx context.Context, deviceID string, flows []*ofp.OfpFlowStats, groups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) error {
- log.Debugw("deleteFlowsAndGroups", log.Fields{"deviceid": deviceID})
+ logger.Debugw("deleteFlowsAndGroups", log.Fields{"deviceid": deviceID})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
return agent.deleteFlowsAndGroups(ctx, flows, groups, flowMetadata)
}
@@ -778,7 +778,7 @@
}
func (dMgr *DeviceManager) updateFlowsAndGroups(ctx context.Context, deviceID string, flows []*ofp.OfpFlowStats, groups []*ofp.OfpGroupEntry, flowMetadata *voltha.FlowMetadata) error {
- log.Debugw("updateFlowsAndGroups", log.Fields{"deviceid": deviceID})
+ logger.Debugw("updateFlowsAndGroups", log.Fields{"deviceid": deviceID})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
return agent.updateFlowsAndGroups(ctx, flows, groups, flowMetadata)
}
@@ -818,7 +818,7 @@
}
func (dMgr *DeviceManager) getSwitchCapability(ctx context.Context, deviceID string) (*ic.SwitchCapability, error) {
- log.Debugw("getSwitchCapability", log.Fields{"deviceid": deviceID})
+ logger.Debugw("getSwitchCapability", log.Fields{"deviceid": deviceID})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
return agent.getSwitchCapability(ctx)
}
@@ -826,7 +826,7 @@
}
func (dMgr *DeviceManager) getPorts(ctx context.Context, deviceID string, portType voltha.Port_PortType) (*voltha.Ports, error) {
- log.Debugw("getPorts", log.Fields{"deviceid": deviceID, "portType": portType})
+ logger.Debugw("getPorts", log.Fields{"deviceid": deviceID, "portType": portType})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
return agent.getPorts(ctx, portType), nil
}
@@ -834,7 +834,7 @@
}
func (dMgr *DeviceManager) getPortCapability(ctx context.Context, deviceID string, portNo uint32) (*ic.PortCapability, error) {
- log.Debugw("getPortCapability", log.Fields{"deviceid": deviceID})
+ logger.Debugw("getPortCapability", log.Fields{"deviceid": deviceID})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
return agent.getPortCapability(ctx, portNo)
}
@@ -842,7 +842,7 @@
}
func (dMgr *DeviceManager) updateDeviceStatus(ctx context.Context, deviceID string, operStatus voltha.OperStatus_Types, connStatus voltha.ConnectStatus_Types) error {
- log.Debugw("updateDeviceStatus", log.Fields{"deviceid": deviceID, "operStatus": operStatus, "connStatus": connStatus})
+ logger.Debugw("updateDeviceStatus", log.Fields{"deviceid": deviceID, "operStatus": operStatus, "connStatus": connStatus})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
return agent.updateDeviceStatus(ctx, operStatus, connStatus)
}
@@ -850,7 +850,7 @@
}
func (dMgr *DeviceManager) updateChildrenStatus(ctx context.Context, deviceID string, operStatus voltha.OperStatus_Types, connStatus voltha.ConnectStatus_Types) error {
- log.Debugw("updateChildrenStatus", log.Fields{"parentDeviceid": deviceID, "operStatus": operStatus, "connStatus": connStatus})
+ logger.Debugw("updateChildrenStatus", log.Fields{"parentDeviceid": deviceID, "operStatus": operStatus, "connStatus": connStatus})
var parentDevice *voltha.Device
var err error
if parentDevice, err = dMgr.GetDevice(ctx, deviceID); err != nil {
@@ -861,7 +861,7 @@
return status.Errorf(codes.Aborted, "%s", err.Error())
}
if len(childDeviceIds) == 0 {
- log.Debugw("no-child-device", log.Fields{"parentDeviceId": parentDevice.Id})
+ logger.Debugw("no-child-device", log.Fields{"parentDeviceId": parentDevice.Id})
}
for _, childDeviceID := range childDeviceIds {
if agent := dMgr.getDeviceAgent(ctx, childDeviceID); agent != nil {
@@ -874,10 +874,10 @@
}
func (dMgr *DeviceManager) updatePortState(ctx context.Context, deviceID string, portType voltha.Port_PortType, portNo uint32, operStatus voltha.OperStatus_Types) error {
- log.Debugw("updatePortState", log.Fields{"deviceid": deviceID, "portType": portType, "portNo": portNo, "operStatus": operStatus})
+ logger.Debugw("updatePortState", log.Fields{"deviceid": deviceID, "portType": portType, "portNo": portNo, "operStatus": operStatus})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
if err := agent.updatePortState(ctx, portType, portNo, operStatus); err != nil {
- log.Errorw("updating-port-state-failed", log.Fields{"deviceid": deviceID, "portNo": portNo, "error": err})
+ logger.Errorw("updating-port-state-failed", log.Fields{"deviceid": deviceID, "portNo": portNo, "error": err})
return err
}
// Notify the logical device manager to change the port state
@@ -892,7 +892,7 @@
// it as a warning and not an error because it
// doesn't stop or modify processing.
// TODO: VOL-2707
- log.Warnw("unable-to-update-logical-port-state", log.Fields{"error": err})
+ logger.Warnw("unable-to-update-logical-port-state", log.Fields{"error": err})
}
}()
}
@@ -902,7 +902,7 @@
}
func (dMgr *DeviceManager) deleteAllPorts(ctx context.Context, deviceID string) error {
- log.Debugw("DeleteAllPorts", log.Fields{"deviceid": deviceID})
+ logger.Debugw("DeleteAllPorts", log.Fields{"deviceid": deviceID})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
if err := agent.deleteAllPorts(ctx); err != nil {
return err
@@ -914,11 +914,11 @@
go func() {
err = dMgr.logicalDeviceMgr.deleteAllLogicalPorts(ctx, device)
if err != nil {
- log.Errorw("unable-to-delete-logical-ports", log.Fields{"error": err})
+ logger.Errorw("unable-to-delete-logical-ports", log.Fields{"error": err})
}
}()
} else {
- log.Warnw("failed-to-retrieve-device", log.Fields{"deviceId": deviceID})
+ logger.Warnw("failed-to-retrieve-device", log.Fields{"deviceId": deviceID})
return err
}
return nil
@@ -928,18 +928,18 @@
//updatePortsState updates all ports on the device
func (dMgr *DeviceManager) updatePortsState(ctx context.Context, deviceID string, state voltha.OperStatus_Types) error {
- log.Debugw("updatePortsState", log.Fields{"deviceid": deviceID})
+ logger.Debugw("updatePortsState", log.Fields{"deviceid": deviceID})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
switch state {
case voltha.OperStatus_ACTIVE:
if err := agent.updatePortsOperState(ctx, state); err != nil {
- log.Warnw("updatePortsOperState-failed", log.Fields{"deviceId": deviceID, "error": err})
+ logger.Warnw("updatePortsOperState-failed", log.Fields{"deviceId": deviceID, "error": err})
return err
}
case voltha.OperStatus_UNKNOWN:
if err := agent.updatePortsOperState(ctx, state); err != nil {
- log.Warnw("updatePortsOperState-failed", log.Fields{"deviceId": deviceID, "error": err})
+ logger.Warnw("updatePortsOperState-failed", log.Fields{"deviceId": deviceID, "error": err})
return err
}
default:
@@ -948,11 +948,11 @@
// Notify the logical device about the state change
device, err := dMgr.GetDevice(ctx, deviceID)
if err != nil {
- log.Warnw("non-existent-device", log.Fields{"deviceId": deviceID, "error": err})
+ logger.Warnw("non-existent-device", log.Fields{"deviceId": deviceID, "error": err})
return err
}
if err := dMgr.logicalDeviceMgr.updatePortsState(ctx, device, state); err != nil {
- log.Warnw("failed-updating-ports-state", log.Fields{"deviceId": deviceID, "error": err})
+ logger.Warnw("failed-updating-ports-state", log.Fields{"deviceId": deviceID, "error": err})
return err
}
return nil
@@ -962,13 +962,13 @@
func (dMgr *DeviceManager) childDeviceDetected(ctx context.Context, parentDeviceID string, parentPortNo int64, deviceType string,
channelID int64, vendorID string, serialNumber string, onuID int64) (*voltha.Device, error) {
- log.Debugw("childDeviceDetected", log.Fields{"parentDeviceId": parentDeviceID, "parentPortNo": parentPortNo, "deviceType": deviceType, "channelId": channelID, "vendorId": vendorID, "serialNumber": serialNumber, "onuId": onuID})
+ logger.Debugw("childDeviceDetected", log.Fields{"parentDeviceId": parentDeviceID, "parentPortNo": parentPortNo, "deviceType": deviceType, "channelId": channelID, "vendorId": vendorID, "serialNumber": serialNumber, "onuId": onuID})
if deviceType == "" && vendorID != "" {
- log.Debug("device-type-is-nil-fetching-device-type")
+ logger.Debug("device-type-is-nil-fetching-device-type")
deviceTypesIf, err := dMgr.adapterMgr.clusterDataProxy.List(ctx, "/device_types", 0, false, "")
if err != nil {
- log.Errorw("failed-to-get-device-type-info", log.Fields{"error": err})
+ logger.Errorw("failed-to-get-device-type-info", log.Fields{"error": err})
return nil, err
}
if deviceTypesIf != nil {
@@ -987,7 +987,7 @@
}
//if no match found for the vendorid,report adapter with the custom error message
if deviceType == "" {
- log.Errorw("failed-to-fetch-adapter-name ", log.Fields{"vendorId": vendorID})
+ logger.Errorw("failed-to-fetch-adapter-name ", log.Fields{"vendorId": vendorID})
return nil, status.Errorf(codes.NotFound, "%s", vendorID)
}
@@ -1010,7 +1010,7 @@
}
if device, err := dMgr.GetChildDevice(ctx, parentDeviceID, serialNumber, onuID, parentPortNo); err == nil {
- log.Warnw("child-device-exists", log.Fields{"parentId": parentDeviceID, "serialNumber": serialNumber})
+ logger.Warnw("child-device-exists", log.Fields{"parentId": parentDeviceID, "serialNumber": serialNumber})
return device, status.Errorf(codes.AlreadyExists, "%s", serialNumber)
}
@@ -1020,7 +1020,7 @@
agent := newDeviceAgent(dMgr.adapterProxy, childDevice, dMgr, dMgr.clusterDataProxy, dMgr.defaultTimeout)
childDevice, err := agent.start(ctx, childDevice)
if err != nil {
- log.Errorw("error-starting-child-device", log.Fields{"parent-device-id": childDevice.ParentId, "child-device-id": agent.deviceID, "error": err})
+ logger.Errorw("error-starting-child-device", log.Fields{"parent-device-id": childDevice.ParentId, "child-device-id": agent.deviceID, "error": err})
return nil, err
}
dMgr.addDeviceAgentToMap(agent)
@@ -1029,7 +1029,7 @@
// ownership of this device to this Core
_, err = dMgr.core.deviceOwnership.OwnedByMe(ctx, &utils.DeviceID{ID: agent.deviceID})
if err != nil {
- log.Errorw("unable-to-find-core-instance-active-owns-this-device", log.Fields{"error": err})
+ logger.Errorw("unable-to-find-core-instance-active-owns-this-device", log.Fields{"error": err})
}
// Activate the child device
@@ -1037,7 +1037,7 @@
go func() {
err := agent.enableDevice(context.Background())
if err != nil {
- log.Errorw("unable-to-enable-device", log.Fields{"error": err})
+ logger.Errorw("unable-to-enable-device", log.Fields{"error": err})
}
}()
}
@@ -1046,7 +1046,7 @@
go func() {
err := dMgr.kafkaICProxy.DeviceDiscovered(agent.deviceID, deviceType, parentDeviceID, dMgr.coreInstanceID)
if err != nil {
- log.Errorw("unable-to-discover-the-device", log.Fields{"error": err})
+ logger.Errorw("unable-to-discover-the-device", log.Fields{"error": err})
}
}()
@@ -1057,14 +1057,14 @@
// This will be triggered on every update to the device.
handlers := dMgr.stateTransitions.GetTransitionHandler(previous, current)
if handlers == nil {
- log.Debugw("no-op-transition", log.Fields{"deviceId": current.Id})
+ logger.Debugw("no-op-transition", log.Fields{"deviceId": current.Id})
return nil
}
- log.Debugw("handler-found", log.Fields{"num-expectedHandlers": len(handlers), "isParent": current.Root, "current-data": current})
+ logger.Debugw("handler-found", log.Fields{"num-expectedHandlers": len(handlers), "isParent": current.Root, "current-data": current})
for _, handler := range handlers {
- log.Debugw("running-handler", log.Fields{"handler": funcName(handler)})
+ logger.Debugw("running-handler", log.Fields{"handler": funcName(handler)})
if err := handler(ctx, current, previous); err != nil {
- log.Warnw("handler-failed", log.Fields{"handler": funcName(handler), "error": err})
+ logger.Warnw("handler-failed", log.Fields{"handler": funcName(handler), "error": err})
return err
}
}
@@ -1072,7 +1072,7 @@
}
func (dMgr *DeviceManager) packetOut(ctx context.Context, deviceID string, outPort uint32, packet *ofp.OfpPacketOut) error {
- log.Debugw("packetOut", log.Fields{"deviceId": deviceID, "outPort": outPort})
+ logger.Debugw("packetOut", log.Fields{"deviceId": deviceID, "outPort": outPort})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
return agent.packetOut(ctx, outPort, packet)
}
@@ -1081,16 +1081,16 @@
// PacketIn receives packet from adapter
func (dMgr *DeviceManager) PacketIn(ctx context.Context, deviceID string, port uint32, transactionID string, packet []byte) error {
- log.Debugw("PacketIn", log.Fields{"deviceId": deviceID, "port": port})
+ logger.Debugw("PacketIn", log.Fields{"deviceId": deviceID, "port": port})
// Get the logical device Id based on the deviceId
var device *voltha.Device
var err error
if device, err = dMgr.GetDevice(ctx, deviceID); err != nil {
- log.Errorw("device-not-found", log.Fields{"deviceId": deviceID})
+ logger.Errorw("device-not-found", log.Fields{"deviceId": deviceID})
return err
}
if !device.Root {
- log.Errorw("device-not-root", log.Fields{"deviceId": deviceID})
+ logger.Errorw("device-not-root", log.Fields{"deviceId": deviceID})
return status.Errorf(codes.FailedPrecondition, "%s", deviceID)
}
@@ -1101,7 +1101,7 @@
}
func (dMgr *DeviceManager) setParentID(ctx context.Context, device *voltha.Device, parentID string) error {
- log.Debugw("setParentId", log.Fields{"deviceId": device.Id, "parentId": parentID})
+ logger.Debugw("setParentId", log.Fields{"deviceId": device.Id, "parentId": parentID})
if agent := dMgr.getDeviceAgent(ctx, device.Id); agent != nil {
return agent.setParentID(ctx, device, parentID)
}
@@ -1110,15 +1110,15 @@
// CreateLogicalDevice creates logical device in core
func (dMgr *DeviceManager) CreateLogicalDevice(ctx context.Context, cDevice *voltha.Device, pDevice *voltha.Device) error {
- log.Info("CreateLogicalDevice")
+ logger.Info("CreateLogicalDevice")
// Verify whether the logical device has already been created
if cDevice.ParentId != "" {
- log.Debugw("Parent device already exist.", log.Fields{"deviceId": cDevice.Id, "logicalDeviceId": cDevice.Id})
+ logger.Debugw("Parent device already exist.", log.Fields{"deviceId": cDevice.Id, "logicalDeviceId": cDevice.Id})
return nil
}
var err error
if _, err = dMgr.logicalDeviceMgr.createLogicalDevice(ctx, cDevice); err != nil {
- log.Warnw("createlogical-device-error", log.Fields{"device": cDevice})
+ logger.Warnw("createlogical-device-error", log.Fields{"device": cDevice})
return err
}
return nil
@@ -1126,10 +1126,10 @@
// DeleteLogicalDevice deletes logical device from core
func (dMgr *DeviceManager) DeleteLogicalDevice(ctx context.Context, cDevice *voltha.Device, pDevice *voltha.Device) error {
- log.Info("DeleteLogicalDevice")
+ logger.Info("DeleteLogicalDevice")
var err error
if err = dMgr.logicalDeviceMgr.deleteLogicalDevice(ctx, cDevice); err != nil {
- log.Warnw("deleteLogical-device-error", log.Fields{"deviceId": cDevice.Id})
+ logger.Warnw("deleteLogical-device-error", log.Fields{"deviceId": cDevice.Id})
return err
}
// Remove the logical device Id from the parent device
@@ -1140,16 +1140,16 @@
// DeleteLogicalPort removes the logical port associated with a device
func (dMgr *DeviceManager) DeleteLogicalPort(ctx context.Context, device *voltha.Device) error {
- log.Info("deleteLogicalPort")
+ logger.Info("deleteLogicalPort")
var err error
// Get the logical port associated with this device
var lPortID *voltha.LogicalPortId
if lPortID, err = dMgr.logicalDeviceMgr.getLogicalPortID(ctx, device); err != nil {
- log.Warnw("getLogical-port-error", log.Fields{"deviceId": device.Id, "error": err})
+ logger.Warnw("getLogical-port-error", log.Fields{"deviceId": device.Id, "error": err})
return err
}
if err = dMgr.logicalDeviceMgr.deleteLogicalPort(ctx, lPortID); err != nil {
- log.Warnw("deleteLogical-port-error", log.Fields{"deviceId": device.Id})
+ logger.Warnw("deleteLogical-port-error", log.Fields{"deviceId": device.Id})
return err
}
return nil
@@ -1157,10 +1157,10 @@
// DeleteLogicalPorts removes the logical ports associated with that deviceId
func (dMgr *DeviceManager) DeleteLogicalPorts(ctx context.Context, cDevice *voltha.Device, pDevice *voltha.Device) error {
- log.Debugw("delete-all-logical-ports", log.Fields{"device-id": cDevice.Id})
+ logger.Debugw("delete-all-logical-ports", log.Fields{"device-id": cDevice.Id})
if err := dMgr.logicalDeviceMgr.deleteLogicalPorts(ctx, cDevice.Id); err != nil {
// Just log the error. The logical device or port may already have been deleted before this callback is invoked.
- log.Warnw("deleteLogical-ports-error", log.Fields{"device-id": cDevice.Id, "error": err})
+ logger.Warnw("deleteLogical-ports-error", log.Fields{"device-id": cDevice.Id, "error": err})
}
return nil
}
@@ -1178,11 +1178,11 @@
//childDevicesLost is invoked by an adapter to indicate that a parent device is in a state (Disabled) where it
//cannot manage the child devices. This will trigger the Core to disable all the child devices.
func (dMgr *DeviceManager) childDevicesLost(ctx context.Context, parentDeviceID string) error {
- log.Debug("childDevicesLost")
+ logger.Debug("childDevicesLost")
var err error
var parentDevice *voltha.Device
if parentDevice, err = dMgr.GetDevice(ctx, parentDeviceID); err != nil {
- log.Warnw("failed-getting-device", log.Fields{"deviceId": parentDeviceID, "error": err})
+ logger.Warnw("failed-getting-device", log.Fields{"deviceId": parentDeviceID, "error": err})
return err
}
return dMgr.DisableAllChildDevices(ctx, parentDevice, nil)
@@ -1191,13 +1191,13 @@
//childDevicesDetected is invoked by an adapter when child devices are found, typically after after a
// disable/enable sequence. This will trigger the Core to Enable all the child devices of that parent.
func (dMgr *DeviceManager) childDevicesDetected(ctx context.Context, parentDeviceID string) error {
- log.Debug("childDevicesDetected")
+ logger.Debug("childDevicesDetected")
var err error
var parentDevice *voltha.Device
var childDeviceIds []string
if parentDevice, err = dMgr.GetDevice(ctx, parentDeviceID); err != nil {
- log.Warnw("failed-getting-device", log.Fields{"deviceId": parentDeviceID, "error": err})
+ logger.Warnw("failed-getting-device", log.Fields{"deviceId": parentDeviceID, "error": err})
return err
}
@@ -1205,7 +1205,7 @@
return status.Errorf(codes.NotFound, "%s", parentDevice.Id)
}
if len(childDeviceIds) == 0 {
- log.Debugw("no-child-device", log.Fields{"parentDeviceId": parentDevice.Id})
+ logger.Debugw("no-child-device", log.Fields{"parentDeviceId": parentDevice.Id})
}
allChildEnableRequestSent := true
for _, childDeviceID := range childDeviceIds {
@@ -1214,12 +1214,12 @@
go func() {
err = agent.enableDevice(ctx)
if err != nil {
- log.Errorw("unable-to-enable-device", log.Fields{"error": err})
+ logger.Errorw("unable-to-enable-device", log.Fields{"error": err})
}
}()
} else {
err = status.Errorf(codes.Unavailable, "no agent for child device %s", childDeviceID)
- log.Errorw("no-child-device-agent", log.Fields{"parentDeviceId": parentDevice.Id, "childId": childDeviceID})
+ logger.Errorw("no-child-device-agent", log.Fields{"parentDeviceId": parentDevice.Id, "childId": childDeviceID})
allChildEnableRequestSent = false
}
}
@@ -1236,20 +1236,20 @@
//DisableAllChildDevices is invoked as a callback when the parent device is disabled
func (dMgr *DeviceManager) DisableAllChildDevices(ctx context.Context, parentCurrDevice *voltha.Device, parentPrevDevice *voltha.Device) error {
- log.Debug("DisableAllChildDevices")
+ logger.Debug("DisableAllChildDevices")
var childDeviceIds []string
var err error
if childDeviceIds, err = dMgr.getAllChildDeviceIds(parentCurrDevice); err != nil {
return status.Errorf(codes.NotFound, "%s", parentCurrDevice.Id)
}
if len(childDeviceIds) == 0 {
- log.Debugw("no-child-device", log.Fields{"parentDeviceId": parentCurrDevice.Id})
+ logger.Debugw("no-child-device", log.Fields{"parentDeviceId": parentCurrDevice.Id})
}
for _, childDeviceID := range childDeviceIds {
if agent := dMgr.getDeviceAgent(ctx, childDeviceID); agent != nil {
if err = agent.disableDevice(ctx); err != nil {
// Just log the error - this error happens only if the child device was already in deleted state.
- log.Errorw("failure-disable-device", log.Fields{"deviceId": childDeviceID, "error": err.Error()})
+ logger.Errorw("failure-disable-device", log.Fields{"deviceId": childDeviceID, "error": err.Error()})
}
}
}
@@ -1258,19 +1258,19 @@
//DeleteAllChildDevices is invoked as a callback when the parent device is deleted
func (dMgr *DeviceManager) DeleteAllChildDevices(ctx context.Context, parentCurrDevice *voltha.Device, parentPrevDevice *voltha.Device) error {
- log.Debug("DeleteAllChildDevices")
+ logger.Debug("DeleteAllChildDevices")
var childDeviceIds []string
var err error
if childDeviceIds, err = dMgr.getAllChildDeviceIds(parentCurrDevice); err != nil {
return status.Errorf(codes.NotFound, "%s", parentCurrDevice.Id)
}
if len(childDeviceIds) == 0 {
- log.Debugw("no-child-device", log.Fields{"parentDeviceId": parentCurrDevice.Id})
+ logger.Debugw("no-child-device", log.Fields{"parentDeviceId": parentCurrDevice.Id})
}
for _, childDeviceID := range childDeviceIds {
if agent := dMgr.getDeviceAgent(ctx, childDeviceID); agent != nil {
if err = agent.deleteDevice(ctx); err != nil {
- log.Warnw("failure-delete-device", log.Fields{"deviceId": childDeviceID, "error": err.Error()})
+ logger.Warnw("failure-delete-device", log.Fields{"deviceId": childDeviceID, "error": err.Error()})
}
// No further action is required here. The deleteDevice will change the device state where the resulting
// callback will take care of cleaning the child device agent.
@@ -1281,30 +1281,30 @@
//DeleteAllUNILogicalPorts is invoked as a callback when the parent device is deleted
func (dMgr *DeviceManager) DeleteAllUNILogicalPorts(ctx context.Context, curr *voltha.Device, prev *voltha.Device) error {
- log.Debugw("delete-all-uni-logical-ports", log.Fields{"parent-device-id": curr.Id})
+ logger.Debugw("delete-all-uni-logical-ports", log.Fields{"parent-device-id": curr.Id})
if err := dMgr.logicalDeviceMgr.deleteAllUNILogicalPorts(ctx, curr); err != nil {
// Just log the error and let the remaining pipeline proceed - ports may already have been deleted
- log.Warnw("delete-all-uni-logical-ports-failed", log.Fields{"parent-device-id": curr.Id, "error": err})
+ logger.Warnw("delete-all-uni-logical-ports-failed", log.Fields{"parent-device-id": curr.Id, "error": err})
}
return nil
}
//DeleteAllLogicalPorts is invoked as a callback when the parent device's connection status moves to UNREACHABLE
func (dMgr *DeviceManager) DeleteAllLogicalPorts(ctx context.Context, parentDevice *voltha.Device, prev *voltha.Device) error {
- log.Debugw("delete-all-logical-ports", log.Fields{"parent-device-id": parentDevice.Id})
+ logger.Debugw("delete-all-logical-ports", log.Fields{"parent-device-id": parentDevice.Id})
if err := dMgr.logicalDeviceMgr.deleteAllLogicalPorts(ctx, parentDevice); err != nil {
// Just log error as logical device may already have been deleted
- log.Warnw("delete-all-logical-ports-fail", log.Fields{"parent-device-id": parentDevice.Id, "error": err})
+ logger.Warnw("delete-all-logical-ports-fail", log.Fields{"parent-device-id": parentDevice.Id, "error": err})
}
return nil
}
//DeleteAllDeviceFlows is invoked as a callback when the parent device's connection status moves to UNREACHABLE
func (dMgr *DeviceManager) DeleteAllDeviceFlows(ctx context.Context, parentDevice *voltha.Device, prev *voltha.Device) error {
- log.Debugw("delete-all-device-flows", log.Fields{"parent-device-id": parentDevice.Id})
+ logger.Debugw("delete-all-device-flows", log.Fields{"parent-device-id": parentDevice.Id})
if agent := dMgr.getDeviceAgent(ctx, parentDevice.Id); agent != nil {
if err := agent.deleteAllFlows(ctx); err != nil {
- log.Errorw("error-deleting-all-device-flows", log.Fields{"parent-device-id": parentDevice.Id})
+ logger.Errorw("error-deleting-all-device-flows", log.Fields{"parent-device-id": parentDevice.Id})
return err
}
return nil
@@ -1314,7 +1314,7 @@
//getAllChildDeviceIds is a helper method to get all the child device IDs from the device passed as parameter
func (dMgr *DeviceManager) getAllChildDeviceIds(parentDevice *voltha.Device) ([]string, error) {
- log.Debugw("getAllChildDeviceIds", log.Fields{"parentDeviceId": parentDevice.Id})
+ logger.Debugw("getAllChildDeviceIds", log.Fields{"parentDeviceId": parentDevice.Id})
childDeviceIds := make([]string, 0)
if parentDevice != nil {
for _, port := range parentDevice.Ports {
@@ -1322,14 +1322,14 @@
childDeviceIds = append(childDeviceIds, peer.DeviceId)
}
}
- log.Debugw("returning-getAllChildDeviceIds", log.Fields{"parentDeviceId": parentDevice.Id, "childDeviceIds": childDeviceIds})
+ logger.Debugw("returning-getAllChildDeviceIds", log.Fields{"parentDeviceId": parentDevice.Id, "childDeviceIds": childDeviceIds})
}
return childDeviceIds, nil
}
//getAllChildDevices is a helper method to get all the child device IDs from the device passed as parameter
func (dMgr *DeviceManager) getAllChildDevices(ctx context.Context, parentDeviceID string) (*voltha.Devices, error) {
- log.Debugw("getAllChildDevices", log.Fields{"parentDeviceId": parentDeviceID})
+ logger.Debugw("getAllChildDevices", log.Fields{"parentDeviceId": parentDeviceID})
if parentDevice, err := dMgr.GetDevice(ctx, parentDeviceID); err == nil {
childDevices := make([]*voltha.Device, 0)
if childDeviceIds, er := dMgr.getAllChildDeviceIds(parentDevice); er == nil {
@@ -1346,21 +1346,21 @@
// SetupUNILogicalPorts creates UNI ports on the logical device that represents a child UNI interface
func (dMgr *DeviceManager) SetupUNILogicalPorts(ctx context.Context, cDevice *voltha.Device, pDevice *voltha.Device) error {
- log.Info("addUNILogicalPort")
+ logger.Info("addUNILogicalPort")
if err := dMgr.logicalDeviceMgr.setupUNILogicalPorts(ctx, cDevice); err != nil {
- log.Warnw("addUNILogicalPort-error", log.Fields{"device": cDevice, "err": err})
+ logger.Warnw("addUNILogicalPort-error", log.Fields{"device": cDevice, "err": err})
return err
}
return nil
}
func (dMgr *DeviceManager) downloadImage(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
- log.Debugw("downloadImage", log.Fields{"deviceid": img.Id, "imageName": img.Name})
+ logger.Debugw("downloadImage", log.Fields{"deviceid": img.Id, "imageName": img.Name})
var res interface{}
var err error
if agent := dMgr.getDeviceAgent(ctx, img.Id); agent != nil {
if res, err = agent.downloadImage(ctx, img); err != nil {
- log.Debugw("downloadImage-failed", log.Fields{"err": err, "imageName": img.Name})
+ logger.Debugw("downloadImage-failed", log.Fields{"err": err, "imageName": img.Name})
res = err
}
} else {
@@ -1370,12 +1370,12 @@
}
func (dMgr *DeviceManager) cancelImageDownload(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
- log.Debugw("cancelImageDownload", log.Fields{"deviceid": img.Id, "imageName": img.Name})
+ logger.Debugw("cancelImageDownload", log.Fields{"deviceid": img.Id, "imageName": img.Name})
var res interface{}
var err error
if agent := dMgr.getDeviceAgent(ctx, img.Id); agent != nil {
if res, err = agent.cancelImageDownload(ctx, img); err != nil {
- log.Debugw("cancelImageDownload-failed", log.Fields{"err": err, "imageName": img.Name})
+ logger.Debugw("cancelImageDownload-failed", log.Fields{"err": err, "imageName": img.Name})
res = err
}
} else {
@@ -1385,12 +1385,12 @@
}
func (dMgr *DeviceManager) activateImage(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
- log.Debugw("activateImage", log.Fields{"deviceid": img.Id, "imageName": img.Name})
+ logger.Debugw("activateImage", log.Fields{"deviceid": img.Id, "imageName": img.Name})
var res interface{}
var err error
if agent := dMgr.getDeviceAgent(ctx, img.Id); agent != nil {
if res, err = agent.activateImage(ctx, img); err != nil {
- log.Debugw("activateImage-failed", log.Fields{"err": err, "imageName": img.Name})
+ logger.Debugw("activateImage-failed", log.Fields{"err": err, "imageName": img.Name})
res = err
}
} else {
@@ -1400,12 +1400,12 @@
}
func (dMgr *DeviceManager) revertImage(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
- log.Debugw("revertImage", log.Fields{"deviceid": img.Id, "imageName": img.Name})
+ logger.Debugw("revertImage", log.Fields{"deviceid": img.Id, "imageName": img.Name})
var res interface{}
var err error
if agent := dMgr.getDeviceAgent(ctx, img.Id); agent != nil {
if res, err = agent.revertImage(ctx, img); err != nil {
- log.Debugw("revertImage-failed", log.Fields{"err": err, "imageName": img.Name})
+ logger.Debugw("revertImage-failed", log.Fields{"err": err, "imageName": img.Name})
res = err
}
} else {
@@ -1415,12 +1415,12 @@
}
func (dMgr *DeviceManager) getImageDownloadStatus(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
- log.Debugw("getImageDownloadStatus", log.Fields{"deviceid": img.Id, "imageName": img.Name})
+ logger.Debugw("getImageDownloadStatus", log.Fields{"deviceid": img.Id, "imageName": img.Name})
var res interface{}
var err error
if agent := dMgr.getDeviceAgent(ctx, img.Id); agent != nil {
if res, err = agent.getImageDownloadStatus(ctx, img); err != nil {
- log.Debugw("getImageDownloadStatus-failed", log.Fields{"err": err, "imageName": img.Name})
+ logger.Debugw("getImageDownloadStatus-failed", log.Fields{"err": err, "imageName": img.Name})
res = err
}
} else {
@@ -1430,10 +1430,10 @@
}
func (dMgr *DeviceManager) updateImageDownload(ctx context.Context, deviceID string, img *voltha.ImageDownload) error {
- log.Debugw("updateImageDownload", log.Fields{"deviceid": img.Id, "imageName": img.Name})
+ logger.Debugw("updateImageDownload", log.Fields{"deviceid": img.Id, "imageName": img.Name})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
if err := agent.updateImageDownload(ctx, img); err != nil {
- log.Debugw("updateImageDownload-failed", log.Fields{"err": err, "imageName": img.Name})
+ logger.Debugw("updateImageDownload-failed", log.Fields{"err": err, "imageName": img.Name})
return err
}
} else {
@@ -1443,7 +1443,7 @@
}
func (dMgr *DeviceManager) getImageDownload(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
- log.Debugw("getImageDownload", log.Fields{"deviceid": img.Id, "imageName": img.Name})
+ logger.Debugw("getImageDownload", log.Fields{"deviceid": img.Id, "imageName": img.Name})
if agent := dMgr.getDeviceAgent(ctx, img.Id); agent != nil {
return agent.getImageDownload(ctx, img)
}
@@ -1451,7 +1451,7 @@
}
func (dMgr *DeviceManager) listImageDownloads(ctx context.Context, deviceID string) (*voltha.ImageDownloads, error) {
- log.Debugw("listImageDownloads", log.Fields{"deviceID": deviceID})
+ logger.Debugw("listImageDownloads", log.Fields{"deviceID": deviceID})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
return agent.listImageDownloads(ctx, deviceID)
}
@@ -1459,7 +1459,7 @@
}
func (dMgr *DeviceManager) NotifyInvalidTransition(ctx context.Context, cDevice *voltha.Device, pDevice *voltha.Device) error {
- log.Errorw("NotifyInvalidTransition", log.Fields{
+ logger.Errorw("NotifyInvalidTransition", log.Fields{
"device": cDevice.Id,
"prev-admin-state": pDevice.AdminState,
"prev-oper-state": pDevice.OperStatus,
@@ -1488,27 +1488,27 @@
// GetParentDeviceID returns parent device id, either from memory or from the dB, if present
func (dMgr *DeviceManager) GetParentDeviceID(ctx context.Context, deviceID string) string {
if device, _ := dMgr.GetDevice(ctx, deviceID); device != nil {
- log.Infow("GetParentDeviceId", log.Fields{"deviceId": device.Id, "parentId": device.ParentId})
+ logger.Infow("GetParentDeviceId", log.Fields{"deviceId": device.Id, "parentId": device.ParentId})
return device.ParentId
}
return ""
}
func (dMgr *DeviceManager) simulateAlarm(ctx context.Context, simulatereq *voltha.SimulateAlarmRequest, ch chan interface{}) {
- log.Debugw("simulateAlarm", log.Fields{"id": simulatereq.Id, "Indicator": simulatereq.Indicator, "IntfId": simulatereq.IntfId,
+ logger.Debugw("simulateAlarm", log.Fields{"id": simulatereq.Id, "Indicator": simulatereq.Indicator, "IntfId": simulatereq.IntfId,
"PortTypeName": simulatereq.PortTypeName, "OnuDeviceId": simulatereq.OnuDeviceId, "InverseBitErrorRate": simulatereq.InverseBitErrorRate,
"Drift": simulatereq.Drift, "NewEqd": simulatereq.NewEqd, "OnuSerialNumber": simulatereq.OnuSerialNumber, "Operation": simulatereq.Operation})
var res interface{}
if agent := dMgr.getDeviceAgent(ctx, simulatereq.Id); agent != nil {
res = agent.simulateAlarm(ctx, simulatereq)
- log.Debugw("simulateAlarm-result", log.Fields{"result": res})
+ logger.Debugw("simulateAlarm-result", log.Fields{"result": res})
}
//TODO CLI always get successful response
sendResponse(ctx, ch, res)
}
func (dMgr *DeviceManager) updateDeviceReason(ctx context.Context, deviceID string, reason string) error {
- log.Debugw("updateDeviceReason", log.Fields{"deviceid": deviceID, "reason": reason})
+ logger.Debugw("updateDeviceReason", log.Fields{"deviceid": deviceID, "reason": reason})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
return agent.updateDeviceReason(ctx, reason)
}
@@ -1516,11 +1516,11 @@
}
func (dMgr *DeviceManager) enablePort(ctx context.Context, port *voltha.Port, ch chan interface{}) {
- log.Debugw("enablePort", log.Fields{"device-id": port.DeviceId, "port-no": port.PortNo})
+ logger.Debugw("enablePort", log.Fields{"device-id": port.DeviceId, "port-no": port.PortNo})
var res interface{}
if agent := dMgr.getDeviceAgent(ctx, port.DeviceId); agent != nil {
res = agent.enablePort(ctx, port)
- log.Debugw("enablePort-result", log.Fields{"result": res})
+ logger.Debugw("enablePort-result", log.Fields{"result": res})
} else {
res = status.Errorf(codes.NotFound, "%s", port.DeviceId)
}
@@ -1529,11 +1529,11 @@
}
func (dMgr *DeviceManager) disablePort(ctx context.Context, port *voltha.Port, ch chan interface{}) {
- log.Debugw("disablePort", log.Fields{"device-id": port.DeviceId, "port-no": port.PortNo})
+ logger.Debugw("disablePort", log.Fields{"device-id": port.DeviceId, "port-no": port.PortNo})
var res interface{}
if agent := dMgr.getDeviceAgent(ctx, port.DeviceId); agent != nil {
res = agent.disablePort(ctx, port)
- log.Debugw("disablePort-result", log.Fields{"result": res})
+ logger.Debugw("disablePort-result", log.Fields{"result": res})
} else {
res = status.Errorf(codes.NotFound, "%s", port.DeviceId)
}
@@ -1543,11 +1543,11 @@
// childDeviceLost calls parent adapter to delete child device and all its references
func (dMgr *DeviceManager) ChildDeviceLost(ctx context.Context, curr *voltha.Device, prev *voltha.Device) error {
- log.Debugw("childDeviceLost", log.Fields{"child-device-id": curr.Id, "parent-device-id": curr.ParentId})
+ logger.Debugw("childDeviceLost", log.Fields{"child-device-id": curr.Id, "parent-device-id": curr.ParentId})
if parentAgent := dMgr.getDeviceAgent(ctx, curr.ParentId); parentAgent != nil {
if err := parentAgent.ChildDeviceLost(ctx, curr); err != nil {
// Just log the message and let the remaining pipeline proceed.
- log.Warnw("childDeviceLost", log.Fields{"child-device-id": curr.Id, "parent-device-id": curr.ParentId, "error": err})
+ logger.Warnw("childDeviceLost", log.Fields{"child-device-id": curr.Id, "parent-device-id": curr.ParentId, "error": err})
}
}
// Do not return an error as parent device may also have been deleted. Let the remaining pipeline proceed.
@@ -1555,13 +1555,13 @@
}
func (dMgr *DeviceManager) startOmciTest(ctx context.Context, omcitestrequest *voltha.OmciTestRequest) (*voltha.TestResponse, error) {
- log.Debugw("Omci_test_Request", log.Fields{"device-id": omcitestrequest.Id, "uuid": omcitestrequest.Uuid})
+ logger.Debugw("Omci_test_Request", log.Fields{"device-id": omcitestrequest.Id, "uuid": omcitestrequest.Uuid})
if agent := dMgr.getDeviceAgent(ctx, omcitestrequest.Id); agent != nil {
res, err := agent.startOmciTest(ctx, omcitestrequest)
if err != nil {
return nil, err
}
- log.Debugw("Omci_test_Response_result-device-magnager", log.Fields{"result": res})
+ logger.Debugw("Omci_test_Response_result-device-magnager", log.Fields{"result": res})
return res, nil
}
return nil, status.Errorf(codes.NotFound, "%s", omcitestrequest.Id)
diff --git a/rw_core/core/device_ownership.go b/rw_core/core/device_ownership.go
index 171b91f..2389c78 100644
--- a/rw_core/core/device_ownership.go
+++ b/rw_core/core/device_ownership.go
@@ -30,13 +30,6 @@
"google.golang.org/grpc/status"
)
-func init() {
- _, err := log.AddPackage(log.JSON, log.WarnLevel, nil)
- if err != nil {
- log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
- }
-}
-
type ownership struct {
id string
owned bool
@@ -79,17 +72,17 @@
// Start starts device device ownership
func (da *DeviceOwnership) Start(ctx context.Context) {
- log.Info("starting-deviceOwnership", log.Fields{"instanceId": da.instanceID})
- log.Info("deviceOwnership-started")
+ logger.Info("starting-deviceOwnership", log.Fields{"instanceId": da.instanceID})
+ logger.Info("deviceOwnership-started")
}
// Stop stops device ownership
func (da *DeviceOwnership) Stop(ctx context.Context) {
- log.Info("stopping-deviceOwnership")
+ logger.Info("stopping-deviceOwnership")
da.exitChannel <- 1
// Need to flush all device reservations
da.abandonAllDevices()
- log.Info("deviceOwnership-stopped")
+ logger.Info("deviceOwnership-stopped")
}
func (da *DeviceOwnership) tryToReserveKey(ctx context.Context, id string) bool {
@@ -98,11 +91,11 @@
kvKey := fmt.Sprintf("%s_%s", da.ownershipPrefix, id)
value, err := da.kvClient.Reserve(ctx, kvKey, da.instanceID, da.reservationTimeout)
if err != nil {
- log.Errorw("error", log.Fields{"error": err, "id": id, "instanceId": da.instanceID})
+ logger.Errorw("error", log.Fields{"error": err, "id": id, "instanceId": da.instanceID})
}
if value != nil {
if currOwner, err = kvstore.ToString(value); err != nil {
- log.Error("unexpected-owner-type")
+ logger.Error("unexpected-owner-type")
}
return currOwner == da.instanceID
}
@@ -113,30 +106,30 @@
// Try to reserve the key
kvKey := fmt.Sprintf("%s_%s", da.ownershipPrefix, id)
if err := da.kvClient.RenewReservation(ctx, kvKey); err != nil {
- log.Errorw("reservation-renewal-error", log.Fields{"error": err, "instance": da.instanceID})
+ logger.Errorw("reservation-renewal-error", log.Fields{"error": err, "instance": da.instanceID})
return false
}
return true
}
func (da *DeviceOwnership) monitorOwnership(ctx context.Context, id string, chnl chan int) {
- log.Debugw("start-device-monitoring", log.Fields{"id": id})
+ logger.Debugw("start-device-monitoring", log.Fields{"id": id})
op := "starting"
exit := false
ticker := time.NewTicker(time.Duration(da.reservationTimeout) / 3 * time.Second)
for {
select {
case <-da.exitChannel:
- log.Debugw("closing-monitoring", log.Fields{"Id": id})
+ logger.Debugw("closing-monitoring", log.Fields{"Id": id})
exit = true
case <-ticker.C:
- log.Debugw(fmt.Sprintf("%s-reservation", op), log.Fields{"Id": id})
+ logger.Debugw(fmt.Sprintf("%s-reservation", op), log.Fields{"Id": id})
case <-chnl:
- log.Debugw("closing-device-monitoring", log.Fields{"Id": id})
+ logger.Debugw("closing-device-monitoring", log.Fields{"Id": id})
exit = true
}
if exit {
- log.Infow("exiting-device-monitoring", log.Fields{"Id": id})
+ logger.Infow("exiting-device-monitoring", log.Fields{"Id": id})
ticker.Stop()
break
}
@@ -145,19 +138,19 @@
// Device owned; renew reservation
op = "renew"
if da.renewReservation(ctx, id) {
- log.Debugw("reservation-renewed", log.Fields{"id": id, "instanceId": da.instanceID})
+ logger.Debugw("reservation-renewed", log.Fields{"id": id, "instanceId": da.instanceID})
} else {
- log.Debugw("reservation-not-renewed", log.Fields{"id": id, "instanceId": da.instanceID})
+ logger.Debugw("reservation-not-renewed", log.Fields{"id": id, "instanceId": da.instanceID})
}
} else {
// Device not owned or not owned by me; try to seize ownership
op = "retry"
if err := da.setOwnership(id, da.tryToReserveKey(ctx, id)); err != nil {
- log.Errorw("unexpected-error", log.Fields{"error": err})
+ logger.Errorw("unexpected-error", log.Fields{"error": err})
}
}
}
- log.Debugw("device-monitoring-stopped", log.Fields{"id": id})
+ logger.Debugw("device-monitoring-stopped", log.Fields{"id": id})
}
func (da *DeviceOwnership) getOwnership(id string) (bool, bool) {
@@ -174,7 +167,7 @@
defer da.deviceMapLock.Unlock()
if _, exist := da.deviceMap[id]; exist {
if da.deviceMap[id].owned != owner {
- log.Debugw("ownership-changed", log.Fields{"Id": id, "owner": owner})
+ logger.Debugw("ownership-changed", log.Fields{"Id": id, "owner": owner})
}
da.deviceMap[id].owned = owner
return nil
@@ -204,7 +197,7 @@
var idStr string
var cache bool
if ownershipKey, idStr, cache, err = da.getOwnershipKey(ctx, id); err != nil {
- log.Warnw("no-ownershipkey", log.Fields{"error": err})
+ logger.Warnw("no-ownershipkey", log.Fields{"error": err})
return false, err
}
@@ -223,7 +216,7 @@
deviceOwned, ownedByMe := da.getOwnership(ownershipKey)
if deviceOwned {
- log.Debugw("ownership", log.Fields{"Id": ownershipKey, "owned": ownedByMe})
+ logger.Debugw("ownership", log.Fields{"Id": ownershipKey, "owned": ownedByMe})
return ownedByMe, nil
}
// Not owned by me or maybe nobody else. Try to reserve it
@@ -237,7 +230,7 @@
chnl: myChnl}
da.deviceMapLock.Unlock()
- log.Debugw("set-new-ownership", log.Fields{"Id": ownershipKey, "owned": reservedByMe})
+ logger.Debugw("set-new-ownership", log.Fields{"Id": ownershipKey, "owned": reservedByMe})
go da.monitorOwnership(context.Background(), ownershipKey, myChnl)
return reservedByMe, nil
}
@@ -265,7 +258,7 @@
// Stop the Go routine monitoring the device
close(o.chnl)
delete(da.deviceMap, id)
- log.Debugw("abandoning-device", log.Fields{"Id": id})
+ logger.Debugw("abandoning-device", log.Fields{"Id": id})
return nil
}
// id is not ownership key
diff --git a/rw_core/core/device_state_transitions.go b/rw_core/core/device_state_transitions.go
index 610b3aa..3bf01ec 100644
--- a/rw_core/core/device_state_transitions.go
+++ b/rw_core/core/device_state_transitions.go
@@ -19,7 +19,6 @@
import (
"context"
"github.com/opencord/voltha-go/rw_core/coreif"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
"github.com/opencord/voltha-protos/v3/go/voltha"
)
@@ -296,13 +295,13 @@
return nil
}
- //log.Infow("DeviceType", log.Fields{"device": pDevice})
+ //logger.Infow("DeviceType", log.Fields{"device": pDevice})
deviceType := parent
if !pDevice.Root {
- log.Info("device is child")
+ logger.Info("device is child")
deviceType = child
}
- log.Infof("deviceType:%d-deviceId:%s-previous:%v-current:%v", deviceType, pDevice.Id, pState, cState)
+ logger.Infof("deviceType:%d-deviceId:%s-previous:%v-current:%v", deviceType, pDevice.Id, pState, cState)
//2. Go over transition array to get the right transition
var currentMatch []TransitionHandler
diff --git a/rw_core/core/device_state_transitions_test.go b/rw_core/core/device_state_transitions_test.go
index 161cf24..8e06cb7 100644
--- a/rw_core/core/device_state_transitions_test.go
+++ b/rw_core/core/device_state_transitions_test.go
@@ -22,7 +22,6 @@
"github.com/opencord/voltha-go/rw_core/coreif"
"github.com/opencord/voltha-go/rw_core/mocks"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
"github.com/opencord/voltha-protos/v3/go/voltha"
"github.com/stretchr/testify/assert"
)
@@ -39,9 +38,6 @@
}
func init() {
- if _, err := log.AddPackage(log.JSON, log.WarnLevel, nil); err != nil {
- log.Fatal("failure-adding-package-core")
- }
tdm = newTestDeviceManager()
transitionMap = NewTransitionMap(tdm)
}
diff --git a/rw_core/core/grpc_nbi_api_handler.go b/rw_core/core/grpc_nbi_api_handler.go
index 74cea5e..f4786aa 100755
--- a/rw_core/core/grpc_nbi_api_handler.go
+++ b/rw_core/core/grpc_nbi_api_handler.go
@@ -105,7 +105,7 @@
err = errors.New("serial-number-not-found")
}
if !ok || serNum == nil {
- log.Error(err)
+ logger.Error(err)
return nil, err
}
// Create KV transaction
@@ -120,11 +120,11 @@
// Metadata in context
if _, ok = md[handler.core.config.CoreBindingKey]; ok {
// OFAgent field in metadata
- log.Debug("OFController-request")
+ logger.Debug("OFController-request")
return true
}
}
- log.Debug("not-OFController-request")
+ logger.Debug("not-OFController-request")
return false
}
@@ -152,7 +152,7 @@
if id != nil {
var ownedByMe bool
if ownedByMe, err = handler.core.deviceOwnership.OwnedByMe(ctx, id); err != nil {
- log.Warnw("getting-ownership-failed", log.Fields{"deviceId": id, "error": err})
+ logger.Warnw("getting-ownership-failed", log.Fields{"deviceId": id, "error": err})
return nil, errorIDNotFound
}
acquired, err = txn.Acquired(ctx, timeout.Milliseconds(), ownedByMe)
@@ -160,10 +160,10 @@
acquired, err = txn.Acquired(ctx, timeout.Milliseconds())
}
if err == nil && acquired {
- log.Debugw("transaction-acquired", log.Fields{"transactionId": txn.txnID})
+ logger.Debugw("transaction-acquired", log.Fields{"transactionId": txn.txnID})
return txn, nil
}
- log.Debugw("transaction-not-acquired", log.Fields{"transactionId": txn.txnID, "error": err})
+ logger.Debugw("transaction-not-acquired", log.Fields{"transactionId": txn.txnID, "error": err})
return nil, errorTransactionNotAcquired
}
@@ -177,33 +177,33 @@
} else if err, ok := res.(error); ok {
return &empty.Empty{}, err
} else {
- log.Warnw("unexpected-return-type", log.Fields{"result": res})
+ logger.Warnw("unexpected-return-type", log.Fields{"result": res})
err = status.Errorf(codes.Internal, "%s", res)
return &empty.Empty{}, err
}
case <-ctx.Done():
- log.Debug("client-timeout")
+ logger.Debug("client-timeout")
return nil, ctx.Err()
}
}
// ListCoreInstances returns details on the running core containers
func (handler *APIHandler) ListCoreInstances(ctx context.Context, empty *empty.Empty) (*voltha.CoreInstances, error) {
- log.Debug("ListCoreInstances")
+ logger.Debug("ListCoreInstances")
// TODO: unused stub
return &voltha.CoreInstances{}, status.Errorf(codes.NotFound, "no-core-instances")
}
// GetCoreInstance returns the details of a specific core container
func (handler *APIHandler) GetCoreInstance(ctx context.Context, id *voltha.ID) (*voltha.CoreInstance, error) {
- log.Debugw("GetCoreInstance", log.Fields{"id": id})
+ logger.Debugw("GetCoreInstance", log.Fields{"id": id})
//TODO: unused stub
return &voltha.CoreInstance{}, status.Errorf(codes.NotFound, "core-instance-%s", id.Id)
}
// GetLogicalDevicePort returns logical device port details
func (handler *APIHandler) GetLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*voltha.LogicalPort, error) {
- log.Debugw("GetLogicalDevicePort-request", log.Fields{"id": *id})
+ logger.Debugw("GetLogicalDevicePort-request", log.Fields{"id": *id})
if handler.competeForTransaction() {
txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
@@ -217,7 +217,7 @@
// EnableLogicalDevicePort enables logical device port
func (handler *APIHandler) EnableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*empty.Empty, error) {
- log.Debugw("EnableLogicalDevicePort-request", log.Fields{"id": id, "test": common.TestModeKeys_api_test.String()})
+ logger.Debugw("EnableLogicalDevicePort-request", log.Fields{"id": id, "test": common.TestModeKeys_api_test.String()})
if isTestMode(ctx) {
return &empty.Empty{}, nil
}
@@ -238,7 +238,7 @@
// DisableLogicalDevicePort disables logical device port
func (handler *APIHandler) DisableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*empty.Empty, error) {
- log.Debugw("DisableLogicalDevicePort-request", log.Fields{"id": id, "test": common.TestModeKeys_api_test.String()})
+ logger.Debugw("DisableLogicalDevicePort-request", log.Fields{"id": id, "test": common.TestModeKeys_api_test.String()})
if isTestMode(ctx) {
return &empty.Empty{}, nil
}
@@ -259,7 +259,7 @@
// UpdateLogicalDeviceFlowTable updates logical device flow table
func (handler *APIHandler) UpdateLogicalDeviceFlowTable(ctx context.Context, flow *openflow_13.FlowTableUpdate) (*empty.Empty, error) {
- log.Debugw("UpdateLogicalDeviceFlowTable-request", log.Fields{"flow": flow, "test": common.TestModeKeys_api_test.String()})
+ logger.Debugw("UpdateLogicalDeviceFlowTable-request", log.Fields{"flow": flow, "test": common.TestModeKeys_api_test.String()})
if isTestMode(ctx) {
return &empty.Empty{}, nil
}
@@ -280,7 +280,7 @@
// UpdateLogicalDeviceFlowGroupTable updates logical device flow group table
func (handler *APIHandler) UpdateLogicalDeviceFlowGroupTable(ctx context.Context, flow *openflow_13.FlowGroupTableUpdate) (*empty.Empty, error) {
- log.Debugw("UpdateLogicalDeviceFlowGroupTable-request", log.Fields{"flow": flow, "test": common.TestModeKeys_api_test.String()})
+ logger.Debugw("UpdateLogicalDeviceFlowGroupTable-request", log.Fields{"flow": flow, "test": common.TestModeKeys_api_test.String()})
if isTestMode(ctx) {
return &empty.Empty{}, nil
}
@@ -301,7 +301,7 @@
// GetDevice must be implemented in the read-only containers - should it also be implemented here?
func (handler *APIHandler) GetDevice(ctx context.Context, id *voltha.ID) (*voltha.Device, error) {
- log.Debugw("GetDevice-request", log.Fields{"id": id})
+ logger.Debugw("GetDevice-request", log.Fields{"id": id})
return handler.deviceMgr.GetDevice(ctx, id.Id)
}
@@ -309,10 +309,10 @@
// ListDevices retrieves the latest devices from the data model
func (handler *APIHandler) ListDevices(ctx context.Context, empty *empty.Empty) (*voltha.Devices, error) {
- log.Debug("ListDevices")
+ logger.Debug("ListDevices")
devices, err := handler.deviceMgr.ListDevices(ctx)
if err != nil {
- log.Errorw("Failed to list devices", log.Fields{"error": err})
+ logger.Errorw("Failed to list devices", log.Fields{"error": err})
return nil, err
}
return devices, nil
@@ -320,7 +320,7 @@
// ListDeviceIds returns the list of device ids managed by a voltha core
func (handler *APIHandler) ListDeviceIds(ctx context.Context, empty *empty.Empty) (*voltha.IDs, error) {
- log.Debug("ListDeviceIDs")
+ logger.Debug("ListDeviceIDs")
if isTestMode(ctx) {
return &voltha.IDs{Items: make([]*voltha.ID, 0)}, nil
}
@@ -329,7 +329,7 @@
//ReconcileDevices is a request to a voltha core to managed a list of devices based on their IDs
func (handler *APIHandler) ReconcileDevices(ctx context.Context, ids *voltha.IDs) (*empty.Empty, error) {
- log.Debug("ReconcileDevices")
+ logger.Debug("ReconcileDevices")
if isTestMode(ctx) {
return &empty.Empty{}, nil
}
@@ -344,7 +344,7 @@
// GetLogicalDevice provides a cloned most up to date logical device
func (handler *APIHandler) GetLogicalDevice(ctx context.Context, id *voltha.ID) (*voltha.LogicalDevice, error) {
- log.Debugw("GetLogicalDevice-request", log.Fields{"id": id})
+ logger.Debugw("GetLogicalDevice-request", log.Fields{"id": id})
if handler.competeForTransaction() {
txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
if err != nil {
@@ -357,7 +357,7 @@
// ListLogicalDevices returns the list of all logical devices
func (handler *APIHandler) ListLogicalDevices(ctx context.Context, empty *empty.Empty) (*voltha.LogicalDevices, error) {
- log.Debug("ListLogicalDevices-request")
+ logger.Debug("ListLogicalDevices-request")
if handler.competeForTransaction() {
txn, err := handler.takeRequestOwnership(ctx, nil)
if err != nil {
@@ -375,13 +375,13 @@
// ListAdapters returns the contents of all adapters known to the system
func (handler *APIHandler) ListAdapters(ctx context.Context, empty *empty.Empty) (*voltha.Adapters, error) {
- log.Debug("ListAdapters")
+ logger.Debug("ListAdapters")
return handler.adapterMgr.listAdapters(ctx)
}
// ListLogicalDeviceFlows returns the flows of logical device
func (handler *APIHandler) ListLogicalDeviceFlows(ctx context.Context, id *voltha.ID) (*openflow_13.Flows, error) {
- log.Debugw("ListLogicalDeviceFlows", log.Fields{"id": *id})
+ logger.Debugw("ListLogicalDeviceFlows", log.Fields{"id": *id})
if handler.competeForTransaction() {
txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
if err != nil {
@@ -394,7 +394,7 @@
// ListLogicalDeviceFlowGroups returns logical device flow groups
func (handler *APIHandler) ListLogicalDeviceFlowGroups(ctx context.Context, id *voltha.ID) (*openflow_13.FlowGroups, error) {
- log.Debugw("ListLogicalDeviceFlowGroups", log.Fields{"id": *id})
+ logger.Debugw("ListLogicalDeviceFlowGroups", log.Fields{"id": *id})
if handler.competeForTransaction() {
txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
if err != nil {
@@ -407,7 +407,7 @@
// ListLogicalDevicePorts returns ports of logical device
func (handler *APIHandler) ListLogicalDevicePorts(ctx context.Context, id *voltha.ID) (*voltha.LogicalPorts, error) {
- log.Debugw("ListLogicalDevicePorts", log.Fields{"logicaldeviceid": id})
+ logger.Debugw("ListLogicalDevicePorts", log.Fields{"logicaldeviceid": id})
if handler.competeForTransaction() {
txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
if err != nil {
@@ -421,10 +421,10 @@
// CreateDevice creates a new parent device in the data model
func (handler *APIHandler) CreateDevice(ctx context.Context, device *voltha.Device) (*voltha.Device, error) {
if device.MacAddress == "" && device.GetHostAndPort() == "" {
- log.Errorf("No Device Info Present")
+ logger.Errorf("No Device Info Present")
return &voltha.Device{}, errors.New("no-device-info-present; MAC or HOSTIP&PORT")
}
- log.Debugw("create-device", log.Fields{"device": *device})
+ logger.Debugw("create-device", log.Fields{"device": *device})
if isTestMode(ctx) {
return &voltha.Device{Id: device.Id}, nil
}
@@ -445,29 +445,29 @@
case res := <-ch:
if res != nil {
if err, ok := res.(error); ok {
- log.Errorw("create-device-failed", log.Fields{"error": err})
+ logger.Errorw("create-device-failed", log.Fields{"error": err})
return nil, err
}
if d, ok := res.(*voltha.Device); ok {
_, err := handler.core.deviceOwnership.OwnedByMe(ctx, &utils.DeviceID{ID: d.Id})
if err != nil {
- log.Errorw("unable-to-find-core-instance-active-owns-this-device", log.Fields{"error": err})
+ logger.Errorw("unable-to-find-core-instance-active-owns-this-device", log.Fields{"error": err})
}
return d, nil
}
}
- log.Warnw("create-device-unexpected-return-type", log.Fields{"result": res})
+ logger.Warnw("create-device-unexpected-return-type", log.Fields{"result": res})
err := status.Errorf(codes.Internal, "%s", res)
return &voltha.Device{}, err
case <-ctx.Done():
- log.Debug("createdevice-client-timeout")
+ logger.Debug("createdevice-client-timeout")
return &voltha.Device{}, ctx.Err()
}
}
// EnableDevice activates a device by invoking the adopt_device API on the appropriate adapter
func (handler *APIHandler) EnableDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
- log.Debugw("enabledevice", log.Fields{"id": id})
+ logger.Debugw("enabledevice", log.Fields{"id": id})
if isTestMode(ctx) {
return &empty.Empty{}, nil
}
@@ -488,7 +488,7 @@
// DisableDevice disables a device along with any child device it may have
func (handler *APIHandler) DisableDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
- log.Debugw("disabledevice-request", log.Fields{"id": id})
+ logger.Debugw("disabledevice-request", log.Fields{"id": id})
if isTestMode(ctx) {
return &empty.Empty{}, nil
}
@@ -509,7 +509,7 @@
//RebootDevice invoked the reboot API to the corresponding adapter
func (handler *APIHandler) RebootDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
- log.Debugw("rebootDevice-request", log.Fields{"id": id})
+ logger.Debugw("rebootDevice-request", log.Fields{"id": id})
if isTestMode(ctx) {
return &empty.Empty{}, nil
}
@@ -530,7 +530,7 @@
// DeleteDevice removes a device from the data model
func (handler *APIHandler) DeleteDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
- log.Debugw("deletedevice-request", log.Fields{"id": id})
+ logger.Debugw("deletedevice-request", log.Fields{"id": id})
if isTestMode(ctx) {
return &empty.Empty{}, nil
}
@@ -557,7 +557,7 @@
// ListDevicePorts returns the ports details for a specific device entry
func (handler *APIHandler) ListDevicePorts(ctx context.Context, id *voltha.ID) (*voltha.Ports, error) {
- log.Debugw("listdeviceports-request", log.Fields{"id": id})
+ logger.Debugw("listdeviceports-request", log.Fields{"id": id})
if handler.competeForTransaction() {
txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{ID: id.Id})
if err != nil {
@@ -577,7 +577,7 @@
// ListDeviceFlows returns the flow details for a specific device entry
func (handler *APIHandler) ListDeviceFlows(ctx context.Context, id *voltha.ID) (*openflow_13.Flows, error) {
- log.Debugw("listdeviceflows-request", log.Fields{"id": id})
+ logger.Debugw("listdeviceflows-request", log.Fields{"id": id})
if handler.competeForTransaction() {
txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{ID: id.Id})
if err != nil {
@@ -597,7 +597,7 @@
// ListDeviceFlowGroups returns the flow group details for a specific device entry
func (handler *APIHandler) ListDeviceFlowGroups(ctx context.Context, id *voltha.ID) (*voltha.FlowGroups, error) {
- log.Debugw("ListDeviceFlowGroups", log.Fields{"deviceid": id})
+ logger.Debugw("ListDeviceFlowGroups", log.Fields{"deviceid": id})
if device, _ := handler.deviceMgr.GetDevice(ctx, id.Id); device != nil {
return device.GetFlowGroups(), nil
@@ -607,26 +607,26 @@
// ListDeviceGroups returns all the device groups known to the system
func (handler *APIHandler) ListDeviceGroups(ctx context.Context, empty *empty.Empty) (*voltha.DeviceGroups, error) {
- log.Debug("ListDeviceGroups")
+ logger.Debug("ListDeviceGroups")
return &voltha.DeviceGroups{}, errors.New("UnImplemented")
}
// GetDeviceGroup returns a specific device group entry
func (handler *APIHandler) GetDeviceGroup(ctx context.Context, id *voltha.ID) (*voltha.DeviceGroup, error) {
- log.Debug("GetDeviceGroup")
+ logger.Debug("GetDeviceGroup")
return &voltha.DeviceGroup{}, errors.New("UnImplemented")
}
// ListDeviceTypes returns all the device types known to the system
func (handler *APIHandler) ListDeviceTypes(ctx context.Context, _ *empty.Empty) (*voltha.DeviceTypes, error) {
- log.Debug("ListDeviceTypes")
+ logger.Debug("ListDeviceTypes")
return &voltha.DeviceTypes{Items: handler.adapterMgr.listDeviceTypes()}, nil
}
// GetDeviceType returns the device type for a specific device entry
func (handler *APIHandler) GetDeviceType(ctx context.Context, id *voltha.ID) (*voltha.DeviceType, error) {
- log.Debugw("GetDeviceType", log.Fields{"typeid": id})
+ logger.Debugw("GetDeviceType", log.Fields{"typeid": id})
if deviceType := handler.adapterMgr.getDeviceType(id.Id); deviceType != nil {
return deviceType, nil
@@ -637,7 +637,7 @@
// GetVoltha returns the contents of all components (i.e. devices, logical_devices, ...)
func (handler *APIHandler) GetVoltha(ctx context.Context, empty *empty.Empty) (*voltha.Voltha, error) {
- log.Debug("GetVoltha")
+ logger.Debug("GetVoltha")
/*
* For now, encode all the version information into a JSON object and
* pass that back as "version" so the client can get all the
@@ -647,7 +647,7 @@
data, err := json.Marshal(&version.VersionInfo)
info := version.VersionInfo.Version
if err != nil {
- log.Warnf("Unable to encode version information as JSON: %s", err.Error())
+ logger.Warnf("Unable to encode version information as JSON: %s", err.Error())
} else {
info = string(data)
}
@@ -659,7 +659,7 @@
// processImageRequest is a helper method to execute an image download request
func (handler *APIHandler) processImageRequest(ctx context.Context, img *voltha.ImageDownload, requestType int) (*common.OperationResp, error) {
- log.Debugw("processImageDownload", log.Fields{"img": *img, "requestType": requestType})
+ logger.Debugw("processImageDownload", log.Fields{"img": *img, "requestType": requestType})
if isTestMode(ctx) {
resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
return resp, nil
@@ -687,7 +687,7 @@
case RevertImage:
go handler.deviceMgr.revertImage(ctx, img, ch)
default:
- log.Warn("invalid-request-type", log.Fields{"requestType": requestType})
+ logger.Warn("invalid-request-type", log.Fields{"requestType": requestType})
return failedresponse, status.Errorf(codes.InvalidArgument, "%d", requestType)
}
select {
@@ -700,17 +700,17 @@
return opResp, nil
}
}
- log.Warnw("download-image-unexpected-return-type", log.Fields{"result": res})
+ logger.Warnw("download-image-unexpected-return-type", log.Fields{"result": res})
return failedresponse, status.Errorf(codes.Internal, "%s", res)
case <-ctx.Done():
- log.Debug("downloadImage-client-timeout")
+ logger.Debug("downloadImage-client-timeout")
return &common.OperationResp{}, ctx.Err()
}
}
// DownloadImage execute an image download request
func (handler *APIHandler) DownloadImage(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
- log.Debugw("DownloadImage-request", log.Fields{"img": *img})
+ logger.Debugw("DownloadImage-request", log.Fields{"img": *img})
if isTestMode(ctx) {
resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
return resp, nil
@@ -721,7 +721,7 @@
// CancelImageDownload cancels image download request
func (handler *APIHandler) CancelImageDownload(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
- log.Debugw("cancelImageDownload-request", log.Fields{"img": *img})
+ logger.Debugw("cancelImageDownload-request", log.Fields{"img": *img})
if isTestMode(ctx) {
resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
return resp, nil
@@ -731,7 +731,7 @@
// ActivateImageUpdate activates image update request
func (handler *APIHandler) ActivateImageUpdate(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
- log.Debugw("activateImageUpdate-request", log.Fields{"img": *img})
+ logger.Debugw("activateImageUpdate-request", log.Fields{"img": *img})
if isTestMode(ctx) {
resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
return resp, nil
@@ -742,7 +742,7 @@
// RevertImageUpdate reverts image update
func (handler *APIHandler) RevertImageUpdate(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
- log.Debugw("revertImageUpdate-request", log.Fields{"img": *img})
+ logger.Debugw("revertImageUpdate-request", log.Fields{"img": *img})
if isTestMode(ctx) {
resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
return resp, nil
@@ -753,7 +753,7 @@
// GetImageDownloadStatus returns status of image download
func (handler *APIHandler) GetImageDownloadStatus(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
- log.Debugw("getImageDownloadStatus-request", log.Fields{"img": *img})
+ logger.Debugw("getImageDownloadStatus-request", log.Fields{"img": *img})
if isTestMode(ctx) {
resp := &voltha.ImageDownload{DownloadState: voltha.ImageDownload_DOWNLOAD_SUCCEEDED}
return resp, nil
@@ -783,17 +783,17 @@
return downloadResp, nil
}
}
- log.Warnw("download-image-status", log.Fields{"result": res})
+ logger.Warnw("download-image-status", log.Fields{"result": res})
return failedresponse, status.Errorf(codes.Internal, "%s", res)
case <-ctx.Done():
- log.Debug("downloadImage-client-timeout")
+ logger.Debug("downloadImage-client-timeout")
return failedresponse, ctx.Err()
}
}
// GetImageDownload returns image download
func (handler *APIHandler) GetImageDownload(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
- log.Debugw("GetImageDownload-request", log.Fields{"img": *img})
+ logger.Debugw("GetImageDownload-request", log.Fields{"img": *img})
if isTestMode(ctx) {
resp := &voltha.ImageDownload{DownloadState: voltha.ImageDownload_DOWNLOAD_SUCCEEDED}
return resp, nil
@@ -808,7 +808,7 @@
// ListImageDownloads returns image downloads
func (handler *APIHandler) ListImageDownloads(ctx context.Context, id *voltha.ID) (*voltha.ImageDownloads, error) {
- log.Debugw("ListImageDownloads-request", log.Fields{"deviceId": id.Id})
+ logger.Debugw("ListImageDownloads-request", log.Fields{"deviceId": id.Id})
if isTestMode(ctx) {
resp := &voltha.ImageDownloads{Items: []*voltha.ImageDownload{}}
return resp, nil
@@ -828,7 +828,7 @@
// GetImages returns all images for a specific device entry
func (handler *APIHandler) GetImages(ctx context.Context, id *voltha.ID) (*voltha.Images, error) {
- log.Debugw("GetImages", log.Fields{"deviceid": id.Id})
+ logger.Debugw("GetImages", log.Fields{"deviceid": id.Id})
device, err := handler.deviceMgr.GetDevice(ctx, id.Id)
if err != nil {
return &voltha.Images{}, err
@@ -838,7 +838,7 @@
// UpdateDevicePmConfigs updates the PM configs
func (handler *APIHandler) UpdateDevicePmConfigs(ctx context.Context, configs *voltha.PmConfigs) (*empty.Empty, error) {
- log.Debugw("UpdateDevicePmConfigs-request", log.Fields{"configs": *configs})
+ logger.Debugw("UpdateDevicePmConfigs-request", log.Fields{"configs": *configs})
if isTestMode(ctx) {
return &empty.Empty{}, nil
}
@@ -858,7 +858,7 @@
// ListDevicePmConfigs returns pm configs of device
func (handler *APIHandler) ListDevicePmConfigs(ctx context.Context, id *voltha.ID) (*voltha.PmConfigs, error) {
- log.Debugw("ListDevicePmConfigs-request", log.Fields{"deviceId": *id})
+ logger.Debugw("ListDevicePmConfigs-request", log.Fields{"deviceId": *id})
if handler.competeForTransaction() {
txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
if err != nil {
@@ -870,34 +870,34 @@
}
func (handler *APIHandler) CreateEventFilter(ctx context.Context, filter *voltha.EventFilter) (*voltha.EventFilter, error) {
- log.Debugw("CreateEventFilter-request", log.Fields{"filter": *filter})
+ logger.Debugw("CreateEventFilter-request", log.Fields{"filter": *filter})
return nil, errors.New("UnImplemented")
}
func (handler *APIHandler) UpdateEventFilter(ctx context.Context, filter *voltha.EventFilter) (*voltha.EventFilter, error) {
- log.Debugw("UpdateEventFilter-request", log.Fields{"filter": *filter})
+ logger.Debugw("UpdateEventFilter-request", log.Fields{"filter": *filter})
return nil, errors.New("UnImplemented")
}
func (handler *APIHandler) DeleteEventFilter(ctx context.Context, filterInfo *voltha.EventFilter) (*empty.Empty, error) {
- log.Debugw("DeleteEventFilter-request", log.Fields{"device-id": filterInfo.DeviceId, "filter-id": filterInfo.Id})
+ logger.Debugw("DeleteEventFilter-request", log.Fields{"device-id": filterInfo.DeviceId, "filter-id": filterInfo.Id})
return nil, errors.New("UnImplemented")
}
// GetEventFilter returns all the filters present for a device
func (handler *APIHandler) GetEventFilter(ctx context.Context, id *voltha.ID) (*voltha.EventFilters, error) {
- log.Debugw("GetEventFilter-request", log.Fields{"device-id": id})
+ logger.Debugw("GetEventFilter-request", log.Fields{"device-id": id})
return nil, errors.New("UnImplemented")
}
// ListEventFilters returns all the filters known to the system
func (handler *APIHandler) ListEventFilters(ctx context.Context, empty *empty.Empty) (*voltha.EventFilters, error) {
- log.Debug("ListEventFilter-request")
+ logger.Debug("ListEventFilter-request")
return nil, errors.New("UnImplemented")
}
func (handler *APIHandler) SelfTest(ctx context.Context, id *voltha.ID) (*voltha.SelfTestResponse, error) {
- log.Debugw("SelfTest-request", log.Fields{"id": id})
+ logger.Debugw("SelfTest-request", log.Fields{"id": id})
if isTestMode(ctx) {
resp := &voltha.SelfTestResponse{Result: voltha.SelfTestResponse_SUCCESS}
return resp, nil
@@ -906,7 +906,7 @@
}
func (handler *APIHandler) forwardPacketOut(ctx context.Context, packet *openflow_13.PacketOut) {
- log.Debugw("forwardPacketOut-request", log.Fields{"packet": packet})
+ logger.Debugw("forwardPacketOut-request", log.Fields{"packet": packet})
//TODO: Update this logic once the OF Controller (OFAgent in this case) can include a transaction Id in its
// request. For performance reason we can let both Cores in a Core-Pair forward the Packet to the adapters and
// let once of the shim layer (kafka proxy or adapter request handler filters out the duplicate packet)
@@ -914,19 +914,19 @@
if agent := handler.logicalDeviceMgr.getLogicalDeviceAgent(ctx, packet.Id); agent != nil {
agent.packetOut(ctx, packet.PacketOut)
} else {
- log.Errorf("No logical device agent present", log.Fields{"logicaldeviceID": packet.Id})
+ logger.Errorf("No logical device agent present", log.Fields{"logicaldeviceID": packet.Id})
}
}
}
// StreamPacketsOut sends packets to adapter
func (handler *APIHandler) StreamPacketsOut(packets voltha.VolthaService_StreamPacketsOutServer) error {
- log.Debugw("StreamPacketsOut-request", log.Fields{"packets": packets})
+ logger.Debugw("StreamPacketsOut-request", log.Fields{"packets": packets})
loop:
for {
select {
case <-packets.Context().Done():
- log.Infow("StreamPacketsOut-context-done", log.Fields{"packets": packets, "error": packets.Context().Err()})
+ logger.Infow("StreamPacketsOut-context-done", log.Fields{"packets": packets, "error": packets.Context().Err()})
break loop
default:
}
@@ -934,26 +934,26 @@
packet, err := packets.Recv()
if err == io.EOF {
- log.Debugw("Received-EOF", log.Fields{"packets": packets})
+ logger.Debugw("Received-EOF", log.Fields{"packets": packets})
break loop
}
if err != nil {
- log.Errorw("Failed to receive packet out", log.Fields{"error": err})
+ logger.Errorw("Failed to receive packet out", log.Fields{"error": err})
continue
}
handler.forwardPacketOut(packets.Context(), packet)
}
- log.Debugw("StreamPacketsOut-request-done", log.Fields{"packets": packets})
+ logger.Debugw("StreamPacketsOut-request-done", log.Fields{"packets": packets})
return nil
}
func (handler *APIHandler) sendPacketIn(deviceID string, transationID string, packet *openflow_13.OfpPacketIn) {
// TODO: Augment the OF PacketIn to include the transactionId
packetIn := openflow_13.PacketIn{Id: deviceID, PacketIn: packet}
- log.Debugw("sendPacketIn", log.Fields{"packetIn": packetIn})
+ logger.Debugw("sendPacketIn", log.Fields{"packetIn": packetIn})
handler.packetInQueue <- packetIn
}
@@ -972,9 +972,9 @@
defer streamingTracker.Unlock()
if _, ok := streamingTracker.calls[method]; ok {
// bail out the other packet in thread
- log.Debugf("%s streaming call already running. Exiting it", method)
+ logger.Debugf("%s streaming call already running. Exiting it", method)
done <- true
- log.Debugf("Last %s exited. Continuing ...", method)
+ logger.Debugf("Last %s exited. Continuing ...", method)
} else {
streamingTracker.calls[method] = &callTracker{failedPacket: nil}
}
@@ -985,10 +985,10 @@
if tracker.failedPacket != nil {
switch tracker.failedPacket.(type) {
case openflow_13.PacketIn:
- log.Debug("Enqueueing last failed packetIn")
+ logger.Debug("Enqueueing last failed packetIn")
handler.packetInQueue <- tracker.failedPacket.(openflow_13.PacketIn)
case openflow_13.ChangeEvent:
- log.Debug("Enqueueing last failed changeEvent")
+ logger.Debug("Enqueueing last failed changeEvent")
handler.changeEventQueue <- tracker.failedPacket.(openflow_13.ChangeEvent)
}
}
@@ -998,22 +998,22 @@
// ReceivePacketsIn receives packets from adapter
func (handler *APIHandler) ReceivePacketsIn(empty *empty.Empty, packetsIn voltha.VolthaService_ReceivePacketsInServer) error {
var streamingTracker = handler.getStreamingTracker("ReceivePacketsIn", handler.packetInQueueDone)
- log.Debugw("ReceivePacketsIn-request", log.Fields{"packetsIn": packetsIn})
+ logger.Debugw("ReceivePacketsIn-request", log.Fields{"packetsIn": packetsIn})
err := handler.flushFailedPackets(streamingTracker)
if err != nil {
- log.Errorw("unable-to-flush-failed-packets", log.Fields{"error": err})
+ logger.Errorw("unable-to-flush-failed-packets", log.Fields{"error": err})
}
loop:
for {
select {
case packet := <-handler.packetInQueue:
- log.Debugw("sending-packet-in", log.Fields{
+ logger.Debugw("sending-packet-in", log.Fields{
"packet": hex.EncodeToString(packet.PacketIn.Data),
})
if err := packetsIn.Send(&packet); err != nil {
- log.Errorw("failed-to-send-packet", log.Fields{"error": err})
+ logger.Errorw("failed-to-send-packet", log.Fields{"error": err})
// save the last failed packet in
streamingTracker.failedPacket = packet
} else {
@@ -1023,7 +1023,7 @@
}
}
case <-handler.packetInQueueDone:
- log.Debug("Another ReceivePacketsIn running. Bailing out ...")
+ logger.Debug("Another ReceivePacketsIn running. Bailing out ...")
break loop
}
}
@@ -1037,18 +1037,18 @@
//if _, ok := portStatus.(*openflow_13.OfpPortStatus); ok {
//}
event := openflow_13.ChangeEvent{Id: deviceID, Event: &openflow_13.ChangeEvent_PortStatus{PortStatus: portStatus}}
- log.Debugw("sendChangeEvent", log.Fields{"event": event})
+ logger.Debugw("sendChangeEvent", log.Fields{"event": event})
handler.changeEventQueue <- event
}
// ReceiveChangeEvents receives change in events
func (handler *APIHandler) ReceiveChangeEvents(empty *empty.Empty, changeEvents voltha.VolthaService_ReceiveChangeEventsServer) error {
var streamingTracker = handler.getStreamingTracker("ReceiveChangeEvents", handler.changeEventQueueDone)
- log.Debugw("ReceiveChangeEvents-request", log.Fields{"changeEvents": changeEvents})
+ logger.Debugw("ReceiveChangeEvents-request", log.Fields{"changeEvents": changeEvents})
err := handler.flushFailedPackets(streamingTracker)
if err != nil {
- log.Errorw("unable-to-flush-failed-packets", log.Fields{"error": err})
+ logger.Errorw("unable-to-flush-failed-packets", log.Fields{"error": err})
}
loop:
@@ -1056,9 +1056,9 @@
select {
// Dequeue a change event
case event := <-handler.changeEventQueue:
- log.Debugw("sending-change-event", log.Fields{"event": event})
+ logger.Debugw("sending-change-event", log.Fields{"event": event})
if err := changeEvents.Send(&event); err != nil {
- log.Errorw("failed-to-send-change-event", log.Fields{"error": err})
+ logger.Errorw("failed-to-send-change-event", log.Fields{"error": err})
// save last failed changeevent
streamingTracker.failedPacket = event
} else {
@@ -1068,7 +1068,7 @@
}
}
case <-handler.changeEventQueueDone:
- log.Debug("Another ReceiveChangeEvents already running. Bailing out ...")
+ logger.Debug("Another ReceiveChangeEvents already running. Bailing out ...")
break loop
}
}
@@ -1081,20 +1081,20 @@
ctx context.Context,
ofAgent *voltha.OfAgentSubscriber,
) (*voltha.OfAgentSubscriber, error) {
- log.Debugw("Subscribe-request", log.Fields{"ofAgent": ofAgent})
+ logger.Debugw("Subscribe-request", log.Fields{"ofAgent": ofAgent})
return &voltha.OfAgentSubscriber{OfagentId: ofAgent.OfagentId, VolthaId: ofAgent.VolthaId}, nil
}
// GetAlarmDeviceData @TODO useless stub, what should this actually do?
func (handler *APIHandler) GetAlarmDeviceData(ctx context.Context, in *common.ID) (*omci.AlarmDeviceData, error) {
- log.Debug("GetAlarmDeviceData-stub")
+ logger.Debug("GetAlarmDeviceData-stub")
return &omci.AlarmDeviceData{}, errors.New("UnImplemented")
}
// ListLogicalDeviceMeters returns logical device meters
func (handler *APIHandler) ListLogicalDeviceMeters(ctx context.Context, id *voltha.ID) (*openflow_13.Meters, error) {
- log.Debugw("ListLogicalDeviceMeters", log.Fields{"id": *id})
+ logger.Debugw("ListLogicalDeviceMeters", log.Fields{"id": *id})
if handler.competeForTransaction() {
txn, err := handler.takeRequestOwnership(ctx, &utils.LogicalDeviceID{ID: id.Id})
if err != nil {
@@ -1107,13 +1107,13 @@
// GetMeterStatsOfLogicalDevice @TODO useless stub, what should this actually do?
func (handler *APIHandler) GetMeterStatsOfLogicalDevice(ctx context.Context, in *common.ID) (*openflow_13.MeterStatsReply, error) {
- log.Debug("GetMeterStatsOfLogicalDevice")
+ logger.Debug("GetMeterStatsOfLogicalDevice")
return &openflow_13.MeterStatsReply{}, errors.New("UnImplemented")
}
// GetMibDeviceData @TODO useless stub, what should this actually do?
func (handler *APIHandler) GetMibDeviceData(ctx context.Context, in *common.ID) (*omci.MibDeviceData, error) {
- log.Debug("GetMibDeviceData")
+ logger.Debug("GetMibDeviceData")
return &omci.MibDeviceData{}, errors.New("UnImplemented")
}
@@ -1122,7 +1122,7 @@
ctx context.Context,
in *voltha.SimulateAlarmRequest,
) (*common.OperationResp, error) {
- log.Debugw("SimulateAlarm-request", log.Fields{"id": in.Id})
+ logger.Debugw("SimulateAlarm-request", log.Fields{"id": in.Id})
successResp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
if isTestMode(ctx) {
return successResp, nil
@@ -1145,7 +1145,7 @@
// UpdateLogicalDeviceMeterTable - This function sends meter mod request to logical device manager and waits for response
func (handler *APIHandler) UpdateLogicalDeviceMeterTable(ctx context.Context, meter *openflow_13.MeterModUpdate) (*empty.Empty, error) {
- log.Debugw("UpdateLogicalDeviceMeterTable-request",
+ logger.Debugw("UpdateLogicalDeviceMeterTable-request",
log.Fields{"meter": meter, "test": common.TestModeKeys_api_test.String()})
if isTestMode(ctx) {
return &empty.Empty{}, nil
@@ -1176,7 +1176,7 @@
}
func (handler *APIHandler) EnablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) {
- log.Debugw("EnablePort-request", log.Fields{"device-id": port.DeviceId, "port-no": port.PortNo})
+ logger.Debugw("EnablePort-request", log.Fields{"device-id": port.DeviceId, "port-no": port.PortNo})
if isTestMode(ctx) {
return &empty.Empty{}, nil
}
@@ -1197,7 +1197,7 @@
func (handler *APIHandler) DisablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) {
- log.Debugw("DisablePort-request", log.Fields{"device-id": port.DeviceId, "port-no": port.PortNo})
+ logger.Debugw("DisablePort-request", log.Fields{"device-id": port.DeviceId, "port-no": port.PortNo})
if isTestMode(ctx) {
return &empty.Empty{}, nil
}
@@ -1217,6 +1217,6 @@
}
func (handler *APIHandler) StartOmciTestAction(ctx context.Context, omcitestrequest *voltha.OmciTestRequest) (*voltha.TestResponse, error) {
- log.Debugw("Omci_test_Request", log.Fields{"id": omcitestrequest.Id, "uuid": omcitestrequest.Uuid})
+ logger.Debugw("Omci_test_Request", log.Fields{"id": omcitestrequest.Id, "uuid": omcitestrequest.Uuid})
return handler.deviceMgr.startOmciTest(ctx, omcitestrequest)
}
diff --git a/rw_core/core/grpc_nbi_api_handler_test.go b/rw_core/core/grpc_nbi_api_handler_test.go
index 47a46e3..f151e48 100755
--- a/rw_core/core/grpc_nbi_api_handler_test.go
+++ b/rw_core/core/grpc_nbi_api_handler_test.go
@@ -66,7 +66,7 @@
var err error
test.etcdServer, test.kvClientPort, err = startEmbeddedEtcdServer("voltha.rwcore.nb.test", "voltha.rwcore.nb.etcd", "error")
if err != nil {
- log.Fatal(err)
+ logger.Fatal(err)
}
// Create the kafka client
test.kClient = lm.NewKafkaClient()
@@ -89,7 +89,7 @@
cfg.InCompetingMode = inCompeteMode
grpcPort, err := freeport.GetFreePort()
if err != nil {
- log.Fatal("Cannot get a freeport for grpc")
+ logger.Fatal("Cannot get a freeport for grpc")
}
cfg.GrpcPort = grpcPort
cfg.GrpcHost = "127.0.0.1"
@@ -98,7 +98,7 @@
nb.core = NewCore(ctx, nb.coreInstanceID, cfg, client, nb.kClient)
err = nb.core.Start(context.Background())
if err != nil {
- log.Fatal("Cannot start core")
+ logger.Fatal("Cannot start core")
}
}
@@ -106,7 +106,7 @@
// Setup the mock OLT adapter
oltAdapter, err := createMockAdapter(OltAdapter, nb.kClient, nb.coreInstanceID, coreName, nb.oltAdapterName)
if err != nil {
- log.Fatalw("setting-mock-olt-adapter-failed", log.Fields{"error": err})
+ logger.Fatalw("setting-mock-olt-adapter-failed", log.Fields{"error": err})
}
nb.oltAdapter = (oltAdapter).(*cm.OLTAdapter)
nb.numONUPerOLT = nb.oltAdapter.GetNumONUPerOLT()
@@ -121,14 +121,14 @@
types := []*voltha.DeviceType{{Id: nb.oltAdapterName, Adapter: nb.oltAdapterName, AcceptsAddRemoveFlowUpdates: true}}
deviceTypes := &voltha.DeviceTypes{Items: types}
if _, err := nb.core.adapterMgr.registerAdapter(registrationData, deviceTypes); err != nil {
- log.Errorw("failed-to-register-adapter", log.Fields{"error": err})
+ logger.Errorw("failed-to-register-adapter", log.Fields{"error": err})
assert.NotNil(t, err)
}
// Setup the mock ONU adapter
onuAdapter, err := createMockAdapter(OnuAdapter, nb.kClient, nb.coreInstanceID, coreName, nb.onuAdapterName)
if err != nil {
- log.Fatalw("setting-mock-onu-adapter-failed", log.Fields{"error": err})
+ logger.Fatalw("setting-mock-onu-adapter-failed", log.Fields{"error": err})
}
nb.onuAdapter = (onuAdapter).(*cm.ONUAdapter)
@@ -141,7 +141,7 @@
types = []*voltha.DeviceType{{Id: nb.onuAdapterName, Adapter: nb.onuAdapterName, AcceptsAddRemoveFlowUpdates: true}}
deviceTypes = &voltha.DeviceTypes{Items: types}
if _, err := nb.core.adapterMgr.registerAdapter(registrationData, deviceTypes); err != nil {
- log.Errorw("failed-to-register-adapter", log.Fields{"error": err})
+ logger.Errorw("failed-to-register-adapter", log.Fields{"error": err})
assert.NotNil(t, err)
}
}
@@ -304,7 +304,7 @@
case nb.onuAdapterName:
assert.Equal(t, "Voltha-onu", a.Vendor)
default:
- log.Fatal("unregistered-adapter", a.Id)
+ logger.Fatal("unregistered-adapter", a.Id)
}
}
deviceTypes, err := nbi.ListDeviceTypes(getContext(), &empty.Empty{})
@@ -322,7 +322,7 @@
assert.Equal(t, false, dt.AcceptsBulkFlowUpdate)
assert.Equal(t, true, dt.AcceptsAddRemoveFlowUpdates)
default:
- log.Fatal("invalid-device-type", dt.Id)
+ logger.Fatal("invalid-device-type", dt.Id)
}
}
}
@@ -1025,13 +1025,13 @@
func TestSuite1(t *testing.T) {
f, err := os.Create("profile.cpu")
if err != nil {
- log.Fatalf("could not create CPU profile: %v\n ", err)
+ logger.Fatalf("could not create CPU profile: %v\n ", err)
}
defer f.Close()
runtime.SetBlockProfileRate(1)
runtime.SetMutexProfileFraction(-1)
if err := pprof.StartCPUProfile(f); err != nil {
- log.Fatalf("could not start CPU profile: %v\n", err)
+ logger.Fatalf("could not start CPU profile: %v\n", err)
}
defer pprof.StopCPUProfile()
diff --git a/rw_core/core/logical_device_agent.go b/rw_core/core/logical_device_agent.go
index a6ce9ab..743614a 100644
--- a/rw_core/core/logical_device_agent.go
+++ b/rw_core/core/logical_device_agent.go
@@ -92,13 +92,13 @@
return nil
}
- log.Infow("starting-logical_device-agent", log.Fields{"logical-device-id": agent.logicalDeviceID, "load-from-db": loadFromDB})
+ logger.Infow("starting-logical_device-agent", log.Fields{"logical-device-id": agent.logicalDeviceID, "load-from-db": loadFromDB})
var startSucceeded bool
defer func() {
if !startSucceeded {
if err := agent.stop(ctx); err != nil {
- log.Errorw("failed-to-cleanup-after-unsuccessful-start", log.Fields{"logical-device-id": agent.logicalDeviceID, "error": err})
+ logger.Errorw("failed-to-cleanup-after-unsuccessful-start", log.Fields{"logical-device-id": agent.logicalDeviceID, "error": err})
}
}
}()
@@ -123,7 +123,7 @@
}
ld.DatapathId = datapathID
ld.Desc = (proto.Clone(switchCap.Desc)).(*ofp.OfpDesc)
- log.Debugw("Switch-capability", log.Fields{"Desc": ld.Desc, "fromAd": switchCap.Desc})
+ logger.Debugw("Switch-capability", log.Fields{"Desc": ld.Desc, "fromAd": switchCap.Desc})
ld.SwitchFeatures = (proto.Clone(switchCap.SwitchFeatures)).(*ofp.OfpSwitchFeatures)
ld.Flows = &ofp.Flows{Items: nil}
ld.FlowGroups = &ofp.FlowGroups{Items: nil}
@@ -135,9 +135,9 @@
return err
}
if added == nil {
- log.Errorw("failed-to-add-logical-device", log.Fields{"logical-device-id": agent.logicalDeviceID})
+ logger.Errorw("failed-to-add-logical-device", log.Fields{"logical-device-id": agent.logicalDeviceID})
} else {
- log.Debugw("logicaldevice-created", log.Fields{"logical-device-id": agent.logicalDeviceID, "root-id": ld.RootDeviceId})
+ logger.Debugw("logicaldevice-created", log.Fields{"logical-device-id": agent.logicalDeviceID, "root-id": ld.RootDeviceId})
}
agent.logicalDevice = proto.Clone(ld).(*voltha.LogicalDevice)
@@ -146,7 +146,7 @@
go func() {
err := agent.setupLogicalPorts(context.Background())
if err != nil {
- log.Errorw("unable-to-setup-logical-ports", log.Fields{"error": err})
+ logger.Errorw("unable-to-setup-logical-ports", log.Fields{"error": err})
}
}()
} else {
@@ -183,7 +183,7 @@
fmt.Sprintf("/logical_devices/%s/meters", agent.logicalDeviceID),
false)
if err != nil {
- log.Errorw("failed-to-create-meter-proxy", log.Fields{"error": err})
+ logger.Errorw("failed-to-create-meter-proxy", log.Fields{"error": err})
return err
}
agent.groupProxy, err = agent.clusterDataProxy.CreateProxy(
@@ -191,7 +191,7 @@
fmt.Sprintf("/logical_devices/%s/flow_groups", agent.logicalDeviceID),
false)
if err != nil {
- log.Errorw("failed-to-create-group-proxy", log.Fields{"error": err})
+ logger.Errorw("failed-to-create-group-proxy", log.Fields{"error": err})
return err
}
agent.ldProxy, err = agent.clusterDataProxy.CreateProxy(
@@ -199,7 +199,7 @@
fmt.Sprintf("/logical_devices/%s", agent.logicalDeviceID),
false)
if err != nil {
- log.Errorw("failed-to-create-logical-device-proxy", log.Fields{"error": err})
+ logger.Errorw("failed-to-create-logical-device-proxy", log.Fields{"error": err})
return err
}
// TODO: Use a port proxy once the POST_ADD is fixed
@@ -213,7 +213,7 @@
if loadFromDB {
go func() {
if err := agent.buildRoutes(context.Background()); err != nil {
- log.Warn("routes-not-ready", log.Fields{"logical-device-id": agent.logicalDeviceID, "error": err})
+ logger.Warn("routes-not-ready", log.Fields{"logical-device-id": agent.logicalDeviceID, "error": err})
}
}()
}
@@ -226,7 +226,7 @@
func (agent *LogicalDeviceAgent) stop(ctx context.Context) error {
var returnErr error
agent.stopOnce.Do(func() {
- log.Info("stopping-logical_device-agent")
+ logger.Info("stopping-logical_device-agent")
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
// This should never happen - an error is returned only if the agent is stopped and an agent is only stopped once.
@@ -241,7 +241,7 @@
} else if removed == nil {
returnErr = status.Errorf(codes.Aborted, "failed-to-remove-logical-ldevice-%s", agent.logicalDeviceID)
} else {
- log.Debugw("logicaldevice-removed", log.Fields{"logicaldeviceId": agent.logicalDeviceID})
+ logger.Debugw("logicaldevice-removed", log.Fields{"logicaldeviceId": agent.logicalDeviceID})
}
// Stop the request queue and request complete indication
@@ -249,7 +249,7 @@
close(agent.exitChannel)
- log.Info("logical_device-agent-stopped")
+ logger.Info("logical_device-agent-stopped")
})
return returnErr
}
@@ -265,7 +265,7 @@
// ListLogicalDeviceFlows returns logical device flows
func (agent *LogicalDeviceAgent) ListLogicalDeviceFlows(ctx context.Context) (*ofp.Flows, error) {
- log.Debug("ListLogicalDeviceFlows")
+ logger.Debug("ListLogicalDeviceFlows")
logicalDevice, err := agent.GetLogicalDevice(ctx)
if err != nil {
@@ -279,7 +279,7 @@
// ListLogicalDeviceMeters returns logical device meters
func (agent *LogicalDeviceAgent) ListLogicalDeviceMeters(ctx context.Context) (*ofp.Meters, error) {
- log.Debug("ListLogicalDeviceMeters")
+ logger.Debug("ListLogicalDeviceMeters")
logicalDevice, err := agent.GetLogicalDevice(ctx)
if err != nil {
@@ -293,7 +293,7 @@
// ListLogicalDeviceFlowGroups returns logical device flow groups
func (agent *LogicalDeviceAgent) ListLogicalDeviceFlowGroups(ctx context.Context) (*ofp.FlowGroups, error) {
- log.Debug("ListLogicalDeviceFlowGroups")
+ logger.Debug("ListLogicalDeviceFlowGroups")
logicalDevice, err := agent.GetLogicalDevice(ctx)
if err != nil {
@@ -307,7 +307,7 @@
// ListLogicalDevicePorts returns logical device ports
func (agent *LogicalDeviceAgent) ListLogicalDevicePorts(ctx context.Context) (*voltha.LogicalPorts, error) {
- log.Debug("ListLogicalDevicePorts")
+ logger.Debug("ListLogicalDevicePorts")
logicalDevice, err := agent.GetLogicalDevice(ctx)
if err != nil {
return nil, err
@@ -324,11 +324,11 @@
func (agent *LogicalDeviceAgent) updateLogicalDeviceFlowsWithoutLock(ctx context.Context, flows *ofp.Flows) error {
ld := agent.getLogicalDeviceWithoutLock()
- log.Debugw("logical-device-before", log.Fields{"lports": len(ld.Ports)})
+ logger.Debugw("logical-device-before", log.Fields{"lports": len(ld.Ports)})
ld.Flows = flows
if err := agent.updateLogicalDeviceWithoutLock(ctx, ld); err != nil {
- log.Errorw("error-updating-logical-device-with-flows", log.Fields{"error": err})
+ logger.Errorw("error-updating-logical-device-with-flows", log.Fields{"error": err})
return err
}
return nil
@@ -338,11 +338,11 @@
func (agent *LogicalDeviceAgent) updateLogicalDeviceMetersWithoutLock(ctx context.Context, meters *ofp.Meters) error {
ld := agent.getLogicalDeviceWithoutLock()
- log.Debugw("logical-device-before", log.Fields{"lports": len(ld.Ports)})
+ logger.Debugw("logical-device-before", log.Fields{"lports": len(ld.Ports)})
ld.Meters = meters
if err := agent.updateLogicalDeviceWithoutLock(ctx, ld); err != nil {
- log.Errorw("error-updating-logical-device-with-meters", log.Fields{"error": err})
+ logger.Errorw("error-updating-logical-device-with-meters", log.Fields{"error": err})
return err
}
return nil
@@ -352,11 +352,11 @@
func (agent *LogicalDeviceAgent) updateLogicalDeviceFlowGroupsWithoutLock(ctx context.Context, flowGroups *ofp.FlowGroups) error {
ld := agent.getLogicalDeviceWithoutLock()
- log.Debugw("logical-device-before", log.Fields{"lports": len(ld.Ports)})
+ logger.Debugw("logical-device-before", log.Fields{"lports": len(ld.Ports)})
ld.FlowGroups = flowGroups
if err := agent.updateLogicalDeviceWithoutLock(ctx, ld); err != nil {
- log.Errorw("error-updating-logical-device-with-flowgroups", log.Fields{"error": err})
+ logger.Errorw("error-updating-logical-device-with-flowgroups", log.Fields{"error": err})
return err
}
return nil
@@ -364,12 +364,12 @@
// getLogicalDeviceWithoutLock returns a cloned logical device to a function that already holds the agent lock.
func (agent *LogicalDeviceAgent) getLogicalDeviceWithoutLock() *voltha.LogicalDevice {
- log.Debug("getLogicalDeviceWithoutLock")
+ logger.Debug("getLogicalDeviceWithoutLock")
return proto.Clone(agent.logicalDevice).(*voltha.LogicalDevice)
}
func (agent *LogicalDeviceAgent) updateLogicalPort(ctx context.Context, device *voltha.Device, port *voltha.Port) error {
- log.Debugw("updateLogicalPort", log.Fields{"deviceId": device.Id, "port": port})
+ logger.Debugw("updateLogicalPort", log.Fields{"deviceId": device.Id, "port": port})
var err error
if port.Type == voltha.Port_ETHERNET_NNI {
if _, err = agent.addNNILogicalPort(ctx, device, port); err != nil {
@@ -385,7 +385,7 @@
// Update the device routes to ensure all routes on the logical device have been calculated
if err = agent.buildRoutes(ctx); err != nil {
// Not an error - temporary state
- log.Warnw("failed-to-update-routes", log.Fields{"device-id": device.Id, "port": port, "error": err})
+ logger.Warnw("failed-to-update-routes", log.Fields{"device-id": device.Id, "port": port, "error": err})
}
}
return nil
@@ -395,17 +395,17 @@
// added to it. While the logical device was being created we could have received requests to add
// NNI and UNI ports which were discarded. Now is the time to add them if needed
func (agent *LogicalDeviceAgent) setupLogicalPorts(ctx context.Context) error {
- log.Infow("setupLogicalPorts", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Infow("setupLogicalPorts", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
// First add any NNI ports which could have been missing
if err := agent.setupNNILogicalPorts(ctx, agent.rootDeviceID); err != nil {
- log.Errorw("error-setting-up-NNI-ports", log.Fields{"error": err, "deviceId": agent.rootDeviceID})
+ logger.Errorw("error-setting-up-NNI-ports", log.Fields{"error": err, "deviceId": agent.rootDeviceID})
return err
}
// Now, set up the UNI ports if needed.
children, err := agent.deviceMgr.getAllChildDevices(ctx, agent.rootDeviceID)
if err != nil {
- log.Errorw("error-getting-child-devices", log.Fields{"error": err, "deviceId": agent.rootDeviceID})
+ logger.Errorw("error-getting-child-devices", log.Fields{"error": err, "deviceId": agent.rootDeviceID})
return err
}
responses := make([]coreutils.Response, 0)
@@ -414,7 +414,7 @@
responses = append(responses, response)
go func(child *voltha.Device) {
if err = agent.setupUNILogicalPorts(context.Background(), child); err != nil {
- log.Error("setting-up-UNI-ports-failed", log.Fields{"deviceID": child.Id})
+ logger.Error("setting-up-UNI-ports-failed", log.Fields{"deviceID": child.Id})
response.Error(status.Errorf(codes.Internal, "UNI-ports-setup-failed: %s", child.Id))
}
response.Done()
@@ -429,13 +429,13 @@
// setupNNILogicalPorts creates an NNI port on the logical device that represents an NNI interface on a root device
func (agent *LogicalDeviceAgent) setupNNILogicalPorts(ctx context.Context, deviceID string) error {
- log.Infow("setupNNILogicalPorts-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Infow("setupNNILogicalPorts-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
// Build the logical device based on information retrieved from the device adapter
var err error
var device *voltha.Device
if device, err = agent.deviceMgr.GetDevice(ctx, deviceID); err != nil {
- log.Errorw("error-retrieving-device", log.Fields{"error": err, "deviceId": deviceID})
+ logger.Errorw("error-retrieving-device", log.Fields{"error": err, "deviceId": deviceID})
return err
}
@@ -443,7 +443,7 @@
for _, port := range device.Ports {
if port.Type == voltha.Port_ETHERNET_NNI {
if _, err = agent.addNNILogicalPort(ctx, device, port); err != nil {
- log.Errorw("error-adding-UNI-port", log.Fields{"error": err})
+ logger.Errorw("error-adding-UNI-port", log.Fields{"error": err})
}
agent.addLogicalPortToMap(port.PortNo, true)
}
@@ -453,7 +453,7 @@
// updatePortState updates the port state of the device
func (agent *LogicalDeviceAgent) updatePortState(ctx context.Context, deviceID string, portNo uint32, operStatus voltha.OperStatus_Types) error {
- log.Infow("updatePortState-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "portNo": portNo, "state": operStatus})
+ logger.Infow("updatePortState-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "portNo": portNo, "state": operStatus})
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
return err
}
@@ -471,7 +471,7 @@
}
// Update the logical device
if err := agent.updateLogicalDeviceWithoutLock(ctx, cloned); err != nil {
- log.Errorw("error-updating-logical-device", log.Fields{"error": err})
+ logger.Errorw("error-updating-logical-device", log.Fields{"error": err})
return err
}
return nil
@@ -482,7 +482,7 @@
// updatePortsState updates the ports state related to the device
func (agent *LogicalDeviceAgent) updatePortsState(ctx context.Context, device *voltha.Device, state voltha.OperStatus_Types) error {
- log.Infow("updatePortsState-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Infow("updatePortsState-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
return err
}
@@ -503,7 +503,7 @@
}
// Updating the logical device will trigger the poprt change events to be populated to the controller
if err := agent.updateLogicalDeviceWithoutLock(ctx, cloned); err != nil {
- log.Warnw("logical-device-update-failed", log.Fields{"ldeviceId": agent.logicalDeviceID, "error": err})
+ logger.Warnw("logical-device-update-failed", log.Fields{"ldeviceId": agent.logicalDeviceID, "error": err})
return err
}
return nil
@@ -511,7 +511,7 @@
// setupUNILogicalPorts creates a UNI port on the logical device that represents a child UNI interface
func (agent *LogicalDeviceAgent) setupUNILogicalPorts(ctx context.Context, childDevice *voltha.Device) error {
- log.Infow("setupUNILogicalPort", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Infow("setupUNILogicalPort", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
// Build the logical device based on information retrieved from the device adapter
var err error
var added bool
@@ -519,7 +519,7 @@
for _, port := range childDevice.Ports {
if port.Type == voltha.Port_ETHERNET_UNI {
if added, err = agent.addUNILogicalPort(ctx, childDevice, port); err != nil {
- log.Errorw("error-adding-UNI-port", log.Fields{"error": err})
+ logger.Errorw("error-adding-UNI-port", log.Fields{"error": err})
}
if added {
agent.addLogicalPortToMap(port.PortNo, false)
@@ -531,7 +531,7 @@
// deleteAllLogicalPorts deletes all logical ports associated with this logical device
func (agent *LogicalDeviceAgent) deleteAllLogicalPorts(ctx context.Context) error {
- log.Infow("updatePortsState-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Infow("updatePortsState-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
return err
}
@@ -545,7 +545,7 @@
cloned.Ports = updateLogicalPorts
if err := agent.updateLogicalDeviceWithoutLock(ctx, cloned); err != nil {
- log.Warnw("logical-device-update-failed", log.Fields{"ldeviceId": agent.logicalDeviceID, "error": err})
+ logger.Warnw("logical-device-update-failed", log.Fields{"ldeviceId": agent.logicalDeviceID, "error": err})
return err
}
return nil
@@ -553,7 +553,7 @@
// deleteAllUNILogicalPorts deletes all UNI logical ports associated with this parent device
func (agent *LogicalDeviceAgent) deleteAllUNILogicalPorts(ctx context.Context, parentDevice *voltha.Device) error {
- log.Debugw("delete-all-uni-logical-ports", log.Fields{"logical-device-id": agent.logicalDeviceID})
+ logger.Debugw("delete-all-uni-logical-ports", log.Fields{"logical-device-id": agent.logicalDeviceID})
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
return err
}
@@ -576,7 +576,7 @@
return err
}
} else {
- log.Debugw("no-change-required", log.Fields{"logical-device-id": agent.logicalDeviceID})
+ logger.Debugw("no-change-required", log.Fields{"logical-device-id": agent.logicalDeviceID})
}
return nil
}
@@ -586,7 +586,7 @@
updateCtx := context.WithValue(ctx, model.RequestTimestamp, time.Now().UnixNano())
afterUpdate, err := agent.clusterDataProxy.Update(updateCtx, "/logical_devices/"+agent.logicalDeviceID, logicalDevice, false, "")
if err != nil {
- log.Errorw("failed-to-update-logical-devices-to-cluster-proxy", log.Fields{"error": err})
+ logger.Errorw("failed-to-update-logical-devices-to-cluster-proxy", log.Fields{"error": err})
return err
}
if afterUpdate == nil {
@@ -612,7 +612,7 @@
if agent.deviceRoutes != nil && agent.deviceRoutes.IsUpToDate(ld) {
return nil
}
- log.Debug("Generation of device route required")
+ logger.Debug("Generation of device route required")
if err := agent.buildRoutes(ctx); err != nil {
return err
}
@@ -621,7 +621,7 @@
//updateFlowTable updates the flow table of that logical device
func (agent *LogicalDeviceAgent) updateFlowTable(ctx context.Context, flow *ofp.OfpFlowMod) error {
- log.Debug("updateFlowTable")
+ logger.Debug("updateFlowTable")
if flow == nil {
return nil
}
@@ -646,7 +646,7 @@
//updateGroupTable updates the group table of that logical device
func (agent *LogicalDeviceAgent) updateGroupTable(ctx context.Context, groupMod *ofp.OfpGroupMod) error {
- log.Debug("updateGroupTable")
+ logger.Debug("updateGroupTable")
if groupMod == nil {
return nil
}
@@ -668,7 +668,7 @@
// updateMeterTable updates the meter table of that logical device
func (agent *LogicalDeviceAgent) updateMeterTable(ctx context.Context, meterMod *ofp.OfpMeterMod) error {
- log.Debug("updateMeterTable")
+ logger.Debug("updateMeterTable")
if meterMod == nil {
return nil
}
@@ -686,7 +686,7 @@
}
func (agent *LogicalDeviceAgent) meterAdd(ctx context.Context, meterMod *ofp.OfpMeterMod) error {
- log.Debugw("meterAdd", log.Fields{"metermod": *meterMod})
+ logger.Debugw("meterAdd", log.Fields{"metermod": *meterMod})
if meterMod == nil {
return nil
}
@@ -694,18 +694,18 @@
return err
}
defer agent.requestQueue.RequestComplete()
- log.Debug("Acquired logical device lock")
+ logger.Debug("Acquired logical device lock")
lDevice := agent.getLogicalDeviceWithoutLock()
var meters []*ofp.OfpMeterEntry
if lDevice.Meters != nil && lDevice.Meters.Items != nil {
meters = lDevice.Meters.Items
}
- log.Debugw("Available meters", log.Fields{"meters": meters})
+ logger.Debugw("Available meters", log.Fields{"meters": meters})
for _, meter := range meters {
if meterMod.MeterId == meter.Config.MeterId {
- log.Infow("Meter-already-exists", log.Fields{"meter": *meterMod})
+ logger.Infow("Meter-already-exists", log.Fields{"meter": *meterMod})
return nil
}
}
@@ -714,15 +714,15 @@
meters = append(meters, meterEntry)
//Update model
if err := agent.updateLogicalDeviceMetersWithoutLock(ctx, &ofp.Meters{Items: meters}); err != nil {
- log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
- log.Debugw("Meter-added-successfully", log.Fields{"Added-meter": meterEntry, "updated-meters": lDevice.Meters})
+ logger.Debugw("Meter-added-successfully", log.Fields{"Added-meter": meterEntry, "updated-meters": lDevice.Meters})
return nil
}
func (agent *LogicalDeviceAgent) meterDelete(ctx context.Context, meterMod *ofp.OfpMeterMod) error {
- log.Debug("meterDelete", log.Fields{"meterMod": *meterMod})
+ logger.Debug("meterDelete", log.Fields{"meterMod": *meterMod})
if meterMod == nil {
return nil
}
@@ -742,13 +742,13 @@
changedMeter := false
changedFow := false
- log.Debugw("Available meters", log.Fields{"meters": meters})
+ logger.Debugw("Available meters", log.Fields{"meters": meters})
for index, meter := range meters {
if meterMod.MeterId == meter.Config.MeterId {
flows = lDevice.Flows.Items
changedFow, updatedFlows = agent.getUpdatedFlowsAfterDeletebyMeterID(flows, meterMod.MeterId)
meters = append(meters[:index], meters[index+1:]...)
- log.Debugw("Meter has been deleted", log.Fields{"meter": meter, "index": index})
+ logger.Debugw("Meter has been deleted", log.Fields{"meter": meter, "index": index})
changedMeter = true
break
}
@@ -760,27 +760,27 @@
metersToUpdate = &ofp.Meters{Items: meters}
}
if err := agent.updateLogicalDeviceMetersWithoutLock(ctx, metersToUpdate); err != nil {
- log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
- log.Debug("Meter-deleted-from-DB-successfully", log.Fields{"updatedMeters": metersToUpdate, "no-of-meter": len(metersToUpdate.Items)})
+ logger.Debug("Meter-deleted-from-DB-successfully", log.Fields{"updatedMeters": metersToUpdate, "no-of-meter": len(metersToUpdate.Items)})
}
if changedFow {
//Update model
if err := agent.updateLogicalDeviceFlowsWithoutLock(ctx, &ofp.Flows{Items: updatedFlows}); err != nil {
- log.Errorw("db-flow-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("db-flow-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
- log.Debug("Flows-associated-with-meter-deleted-from-DB-successfully",
+ logger.Debug("Flows-associated-with-meter-deleted-from-DB-successfully",
log.Fields{"updated-no-of-flows": len(updatedFlows), "meter": meterMod.MeterId})
}
- log.Debugw("meterDelete success", log.Fields{"meterID": meterMod.MeterId})
+ logger.Debugw("meterDelete success", log.Fields{"meterID": meterMod.MeterId})
return nil
}
func (agent *LogicalDeviceAgent) meterModify(ctx context.Context, meterMod *ofp.OfpMeterMod) error {
- log.Debug("meterModify")
+ logger.Debug("meterModify")
if meterMod == nil {
return nil
}
@@ -802,7 +802,7 @@
newmeterEntry.Stats.FlowCount = meter.Stats.FlowCount
meters[index] = newmeterEntry
changedMeter = true
- log.Debugw("Found meter, replaced with new meter", log.Fields{"old meter": meter, "new meter": newmeterEntry})
+ logger.Debugw("Found meter, replaced with new meter", log.Fields{"old meter": meter, "new meter": newmeterEntry})
break
}
}
@@ -813,25 +813,25 @@
metersToUpdate = &ofp.Meters{Items: meters}
}
if err := agent.updateLogicalDeviceMetersWithoutLock(ctx, metersToUpdate); err != nil {
- log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
- log.Debugw("meter-updated-in-DB-successfully", log.Fields{"updated_meters": meters})
+ logger.Debugw("meter-updated-in-DB-successfully", log.Fields{"updated_meters": meters})
return nil
}
- log.Errorw("Meter not found ", log.Fields{"meter": meterMod})
+ logger.Errorw("Meter not found ", log.Fields{"meter": meterMod})
return fmt.Errorf("no-logical-device-present:%d", meterMod.MeterId)
}
func (agent *LogicalDeviceAgent) getUpdatedFlowsAfterDeletebyMeterID(flows []*ofp.OfpFlowStats, meterID uint32) (bool, []*ofp.OfpFlowStats) {
- log.Infow("Delete flows matching meter", log.Fields{"meter": meterID})
+ logger.Infow("Delete flows matching meter", log.Fields{"meter": meterID})
changed := false
//updatedFlows := make([]*ofp.OfpFlowStats, 0)
for index := len(flows) - 1; index >= 0; index-- {
if mID := fu.GetMeterIdFromFlow(flows[index]); mID != 0 && mID == meterID {
- log.Debugw("Flow to be deleted", log.Fields{"flow": flows[index], "index": index})
+ logger.Debugw("Flow to be deleted", log.Fields{"flow": flows[index], "index": index})
flows = append(flows[:index], flows[index+1:]...)
changed = true
}
@@ -843,13 +843,13 @@
flowCommand := modCommand.GetCommand()
meterID := fu.GetMeterIdFromFlow(flow)
- log.Debugw("Meter-id-in-flow-mod", log.Fields{"meterId": meterID})
+ logger.Debugw("Meter-id-in-flow-mod", log.Fields{"meterId": meterID})
if meterID == 0 {
- log.Debugw("No meter present in the flow", log.Fields{"flow": *flow})
+ logger.Debugw("No meter present in the flow", log.Fields{"flow": *flow})
return false
}
if meters == nil {
- log.Debug("No meters present in logical device")
+ logger.Debug("No meters present in logical device")
return false
}
changedMeter := false
@@ -862,7 +862,7 @@
meter.Stats.FlowCount--
changedMeter = true
}
- log.Debugw("Found meter, updated meter flow stats", log.Fields{" meterId": meterID})
+ logger.Debugw("Found meter, updated meter flow stats", log.Fields{" meterId": meterID})
break
}
}
@@ -871,7 +871,7 @@
//flowAdd adds a flow to the flow table of that logical device
func (agent *LogicalDeviceAgent) flowAdd(ctx context.Context, mod *ofp.OfpFlowMod) error {
- log.Debugw("flowAdd", log.Fields{"flow": mod})
+ logger.Debugw("flowAdd", log.Fields{"flow": mod})
if mod == nil {
return nil
}
@@ -901,7 +901,7 @@
if checkOverlap {
if overlapped := fu.FindOverlappingFlows(flows, mod); len(overlapped) != 0 {
// TODO: should this error be notified other than being logged?
- log.Warnw("overlapped-flows", log.Fields{"logicaldeviceId": agent.logicalDeviceID})
+ logger.Warnw("overlapped-flows", log.Fields{"logicaldeviceId": agent.logicalDeviceID})
} else {
// Add flow
flow, err = fu.FlowStatsEntryFromFlowModMessage(mod)
@@ -936,23 +936,23 @@
changed = true
}
}
- log.Debugw("flowAdd-changed", log.Fields{"changed": changed})
+ logger.Debugw("flowAdd-changed", log.Fields{"changed": changed})
if changed {
var flowMetadata voltha.FlowMetadata
if err := agent.GetMeterConfig(updatedFlows, meters, &flowMetadata); err != nil { // This should never happen,meters should be installed before flow arrives
- log.Error("Meter-referred-in-flows-not-present")
+ logger.Error("Meter-referred-in-flows-not-present")
return err
}
deviceRules, err := agent.flowDecomposer.DecomposeRules(ctx, agent, ofp.Flows{Items: updatedFlows}, *lDevice.FlowGroups)
if err != nil {
return err
}
- log.Debugw("rules", log.Fields{"rules": deviceRules.String()})
+ logger.Debugw("rules", log.Fields{"rules": deviceRules.String()})
// Update model
if err := agent.updateLogicalDeviceFlowsWithoutLock(ctx, &ofp.Flows{Items: flows}); err != nil {
- log.Errorw("db-flow-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("db-flow-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
if !updated {
@@ -964,10 +964,10 @@
if changedMeterStats {
//Update model
if err := agent.updateLogicalDeviceMetersWithoutLock(ctx, metersToUpdate); err != nil {
- log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
- log.Debugw("meter-stats-updated-in-DB-successfully", log.Fields{"updated_meters": meters})
+ logger.Debugw("meter-stats-updated-in-DB-successfully", log.Fields{"updated_meters": meters})
}
}
@@ -978,7 +978,7 @@
go func() {
// Wait for completion
if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, respChannels...); res != nil {
- log.Warnw("failure-to-add-flows", log.Fields{"errors": res, "logical-device-id": agent.logicalDeviceID})
+ logger.Warnw("failure-to-add-flows", log.Fields{"errors": res, "logical-device-id": agent.logicalDeviceID})
// TODO : revert added flow
}
}()
@@ -996,7 +996,7 @@
for _, meter := range meters {
if flowMeterID == meter.Config.MeterId {
metadata.Meters = append(metadata.Meters, meter.Config)
- log.Debugw("Found meter in logical device",
+ logger.Debugw("Found meter in logical device",
log.Fields{"meterID": flowMeterID, "meter-band": meter.Config})
m[flowMeterID] = true
foundMeter = true
@@ -1004,20 +1004,20 @@
}
}
if !foundMeter {
- log.Errorw("Meter-referred-by-flow-is-not-found-in-logicaldevice",
+ logger.Errorw("Meter-referred-by-flow-is-not-found-in-logicaldevice",
log.Fields{"meterID": flowMeterID, "Available-meters": meters, "flow": *flow})
return errors.New("Meter-referred-by-flow-is-not-found-in-logicaldevice")
}
}
}
- log.Debugw("meter-bands-for-flows", log.Fields{"flows": len(flows), "metadata": metadata})
+ logger.Debugw("meter-bands-for-flows", log.Fields{"flows": len(flows), "metadata": metadata})
return nil
}
//flowDelete deletes a flow from the flow table of that logical device
func (agent *LogicalDeviceAgent) flowDelete(ctx context.Context, mod *ofp.OfpFlowMod) error {
- log.Debug("flowDelete")
+ logger.Debug("flowDelete")
if mod == nil {
return nil
}
@@ -1065,23 +1065,23 @@
}
}
- log.Debugw("flowDelete", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "toKeep": len(toKeep), "toDelete": toDelete})
+ logger.Debugw("flowDelete", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "toKeep": len(toKeep), "toDelete": toDelete})
//Update flows
if len(toDelete) > 0 {
var flowMetadata voltha.FlowMetadata
if err := agent.GetMeterConfig(toDelete, meters, &flowMetadata); err != nil { // This should never happen
- log.Error("Meter-referred-in-flows-not-present")
+ logger.Error("Meter-referred-in-flows-not-present")
return errors.New("Meter-referred-in-flows-not-present")
}
deviceRules, err := agent.flowDecomposer.DecomposeRules(ctx, agent, ofp.Flows{Items: toDelete}, ofp.FlowGroups{Items: flowGroups})
if err != nil {
return err
}
- log.Debugw("rules", log.Fields{"rules": deviceRules.String()})
+ logger.Debugw("rules", log.Fields{"rules": deviceRules.String()})
if err := agent.updateLogicalDeviceFlowsWithoutLock(ctx, &ofp.Flows{Items: toKeep}); err != nil {
- log.Errorw("cannot-update-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("cannot-update-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
@@ -1092,7 +1092,7 @@
go func() {
// Wait for completion
if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, respChnls...); res != nil {
- log.Errorw("failure-updating-device-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "errors": res})
+ logger.Errorw("failure-updating-device-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "errors": res})
// TODO: Revert the flow deletion
}
}()
@@ -1103,7 +1103,7 @@
}
func (agent *LogicalDeviceAgent) addFlowsAndGroupsToDevices(ctx context.Context, deviceRules *fu.DeviceRules, flowMetadata *voltha.FlowMetadata) []coreutils.Response {
- log.Debugw("send-add-flows-to-device-manager", log.Fields{"logicalDeviceID": agent.logicalDeviceID, "deviceRules": deviceRules, "flowMetadata": flowMetadata})
+ logger.Debugw("send-add-flows-to-device-manager", log.Fields{"logicalDeviceID": agent.logicalDeviceID, "deviceRules": deviceRules, "flowMetadata": flowMetadata})
responses := make([]coreutils.Response, 0)
for deviceID, value := range deviceRules.GetRules() {
@@ -1113,7 +1113,7 @@
ctx, cancel := context.WithTimeout(context.Background(), agent.defaultTimeout)
defer cancel()
if err := agent.deviceMgr.addFlowsAndGroups(ctx, deviceId, value.ListFlows(), value.ListGroups(), flowMetadata); err != nil {
- log.Errorw("flow-add-failed", log.Fields{"deviceID": deviceId, "error": err})
+ logger.Errorw("flow-add-failed", log.Fields{"deviceID": deviceId, "error": err})
response.Error(status.Errorf(codes.Internal, "flow-add-failed: %s", deviceId))
}
response.Done()
@@ -1124,7 +1124,7 @@
}
func (agent *LogicalDeviceAgent) deleteFlowsAndGroupsFromDevices(ctx context.Context, deviceRules *fu.DeviceRules, flowMetadata *voltha.FlowMetadata) []coreutils.Response {
- log.Debugw("send-delete-flows-to-device-manager", log.Fields{"logicalDeviceID": agent.logicalDeviceID})
+ logger.Debugw("send-delete-flows-to-device-manager", log.Fields{"logicalDeviceID": agent.logicalDeviceID})
responses := make([]coreutils.Response, 0)
for deviceID, value := range deviceRules.GetRules() {
@@ -1134,7 +1134,7 @@
ctx, cancel := context.WithTimeout(context.Background(), agent.defaultTimeout)
defer cancel()
if err := agent.deviceMgr.deleteFlowsAndGroups(ctx, deviceId, value.ListFlows(), value.ListGroups(), flowMetadata); err != nil {
- log.Error("flow-delete-failed", log.Fields{"deviceID": deviceId, "error": err})
+ logger.Error("flow-delete-failed", log.Fields{"deviceID": deviceId, "error": err})
response.Error(status.Errorf(codes.Internal, "flow-delete-failed: %s", deviceId))
}
response.Done()
@@ -1144,7 +1144,7 @@
}
func (agent *LogicalDeviceAgent) updateFlowsAndGroupsOfDevice(ctx context.Context, deviceRules *fu.DeviceRules, flowMetadata *voltha.FlowMetadata) []coreutils.Response {
- log.Debugw("send-update-flows-to-device-manager", log.Fields{"logicalDeviceID": agent.logicalDeviceID})
+ logger.Debugw("send-update-flows-to-device-manager", log.Fields{"logicalDeviceID": agent.logicalDeviceID})
responses := make([]coreutils.Response, 0)
for deviceID, value := range deviceRules.GetRules() {
@@ -1154,7 +1154,7 @@
ctx, cancel := context.WithTimeout(context.Background(), agent.defaultTimeout)
defer cancel()
if err := agent.deviceMgr.updateFlowsAndGroups(ctx, deviceId, value.ListFlows(), value.ListGroups(), flowMetadata); err != nil {
- log.Error("flow-update-failed", log.Fields{"deviceID": deviceId, "error": err})
+ logger.Error("flow-update-failed", log.Fields{"deviceID": deviceId, "error": err})
response.Error(status.Errorf(codes.Internal, "flow-update-failed: %s", deviceId))
}
response.Done()
@@ -1165,7 +1165,7 @@
//flowDeleteStrict deletes a flow from the flow table of that logical device
func (agent *LogicalDeviceAgent) flowDeleteStrict(ctx context.Context, mod *ofp.OfpFlowMod) error {
- log.Debug("flowDeleteStrict")
+ logger.Debug("flowDeleteStrict")
if mod == nil {
return nil
}
@@ -1212,7 +1212,7 @@
metersToUpdate = &ofp.Meters{Items: meters}
}
if err := agent.updateLogicalDeviceMetersWithoutLock(ctx, metersToUpdate); err != nil {
- log.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("db-meter-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
@@ -1220,17 +1220,17 @@
if changedFlow {
var flowMetadata voltha.FlowMetadata
if err := agent.GetMeterConfig(flowsToDelete, meters, &flowMetadata); err != nil {
- log.Error("meter-referred-in-flows-not-present")
+ logger.Error("meter-referred-in-flows-not-present")
return err
}
deviceRules, err := agent.flowDecomposer.DecomposeRules(ctx, agent, ofp.Flows{Items: flowsToDelete}, ofp.FlowGroups{Items: flowGroups})
if err != nil {
return err
}
- log.Debugw("rules", log.Fields{"rules": deviceRules.String()})
+ logger.Debugw("rules", log.Fields{"rules": deviceRules.String()})
if err := agent.updateLogicalDeviceFlowsWithoutLock(ctx, &ofp.Flows{Items: flows}); err != nil {
- log.Errorw("cannot-update-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("cannot-update-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
@@ -1240,7 +1240,7 @@
// Wait for completion
go func() {
if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, respChnls...); res != nil {
- log.Warnw("failure-deleting-device-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "errors": res})
+ logger.Warnw("failure-deleting-device-flows", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "errors": res})
//TODO: Revert flow changes
}
}()
@@ -1259,7 +1259,7 @@
}
func (agent *LogicalDeviceAgent) groupAdd(ctx context.Context, groupMod *ofp.OfpGroupMod) error {
- log.Debug("groupAdd")
+ logger.Debug("groupAdd")
if groupMod == nil {
return nil
}
@@ -1280,10 +1280,10 @@
fg.AddGroup(fu.GroupEntryFromGroupMod(groupMod))
deviceRules.AddFlowsAndGroup(agent.rootDeviceID, fg)
- log.Debugw("rules", log.Fields{"rules for group-add": deviceRules.String()})
+ logger.Debugw("rules", log.Fields{"rules for group-add": deviceRules.String()})
if err := agent.updateLogicalDeviceFlowGroupsWithoutLock(ctx, &ofp.FlowGroups{Items: groups}); err != nil {
- log.Errorw("cannot-update-group", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("cannot-update-group", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
@@ -1293,7 +1293,7 @@
// Wait for completion
go func() {
if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, respChnls...); res != nil {
- log.Warnw("failure-updating-device-flows-groups", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "errors": res})
+ logger.Warnw("failure-updating-device-flows-groups", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "errors": res})
//TODO: Revert flow changes
}
}()
@@ -1303,7 +1303,7 @@
}
func (agent *LogicalDeviceAgent) groupDelete(ctx context.Context, groupMod *ofp.OfpGroupMod) error {
- log.Debug("groupDelete")
+ logger.Debug("groupDelete")
if groupMod == nil {
return nil
}
@@ -1337,17 +1337,17 @@
if err != nil {
return err
}
- log.Debugw("rules", log.Fields{"rules": deviceRules.String()})
+ logger.Debugw("rules", log.Fields{"rules": deviceRules.String()})
if groupsChanged {
if err := agent.updateLogicalDeviceFlowGroupsWithoutLock(ctx, &ofp.FlowGroups{Items: groups}); err != nil {
- log.Errorw("cannot-update-group", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("cannot-update-group", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
}
if flowsChanged {
if err := agent.updateLogicalDeviceFlowsWithoutLock(ctx, &ofp.Flows{Items: flows}); err != nil {
- log.Errorw("cannot-update-flow", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("cannot-update-flow", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
}
@@ -1358,7 +1358,7 @@
// Wait for completion
go func() {
if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, respChnls...); res != nil {
- log.Warnw("failure-updating-device-flows-groups", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "errors": res})
+ logger.Warnw("failure-updating-device-flows-groups", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "errors": res})
//TODO: Revert flow changes
}
}()
@@ -1367,7 +1367,7 @@
}
func (agent *LogicalDeviceAgent) groupModify(ctx context.Context, groupMod *ofp.OfpGroupMod) error {
- log.Debug("groupModify")
+ logger.Debug("groupModify")
if groupMod == nil {
return nil
}
@@ -1395,10 +1395,10 @@
fg.AddGroup(fu.GroupEntryFromGroupMod(groupMod))
deviceRules.AddFlowsAndGroup(agent.rootDeviceID, fg)
- log.Debugw("rules", log.Fields{"rules for group-modify": deviceRules.String()})
+ logger.Debugw("rules", log.Fields{"rules for group-modify": deviceRules.String()})
if err := agent.updateLogicalDeviceFlowGroupsWithoutLock(ctx, &ofp.FlowGroups{Items: groups}); err != nil {
- log.Errorw("Cannot-update-logical-group", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("Cannot-update-logical-group", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
@@ -1408,7 +1408,7 @@
// Wait for completion
go func() {
if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, respChnls...); res != nil {
- log.Warnw("failure-updating-device-flows-groups", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "errors": res})
+ logger.Warnw("failure-updating-device-flows-groups", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "errors": res})
//TODO: Revert flow changes
}
}()
@@ -1436,9 +1436,9 @@
copy(logicalDevice.Ports[index:], logicalDevice.Ports[index+1:])
logicalDevice.Ports[len(logicalDevice.Ports)-1] = nil
logicalDevice.Ports = logicalDevice.Ports[:len(logicalDevice.Ports)-1]
- log.Debugw("logical-port-deleted", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Debugw("logical-port-deleted", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
if err := agent.updateLogicalDeviceWithoutLock(ctx, logicalDevice); err != nil {
- log.Errorw("logical-device-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("logical-device-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
@@ -1448,7 +1448,7 @@
// Reset the logical device routes
go func() {
if err := agent.buildRoutes(context.Background()); err != nil {
- log.Warnw("device-routes-not-ready", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "error": err})
+ logger.Warnw("device-routes-not-ready", log.Fields{"logicalDeviceId": agent.logicalDeviceID, "error": err})
}
}()
}
@@ -1474,9 +1474,9 @@
}
logicalDevice.Ports = lPortstoKeep
- log.Debugw("updated-logical-ports", log.Fields{"ports": lPortstoKeep})
+ logger.Debugw("updated-logical-ports", log.Fields{"ports": lPortstoKeep})
if err := agent.updateLogicalDeviceWithoutLock(ctx, logicalDevice); err != nil {
- log.Errorw("logical-device-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Errorw("logical-device-update-failed", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
return err
}
// Remove the port from the cached logical ports set
@@ -1485,7 +1485,7 @@
// Reset the logical device routes
go func() {
if err := agent.buildRoutes(context.Background()); err != nil {
- log.Warnw("routes-not-ready", log.Fields{"logical-device-id": agent.logicalDeviceID, "error": err})
+ logger.Warnw("routes-not-ready", log.Fields{"logical-device-id": agent.logicalDeviceID, "error": err})
}
}()
@@ -1539,9 +1539,9 @@
}
func (agent *LogicalDeviceAgent) getPreCalculatedRoute(ingress, egress uint32) ([]route.Hop, error) {
- log.Debugw("ROUTE", log.Fields{"len": len(agent.deviceRoutes.Routes)})
+ logger.Debugw("ROUTE", log.Fields{"len": len(agent.deviceRoutes.Routes)})
for routeLink, route := range agent.deviceRoutes.Routes {
- log.Debugw("ROUTELINKS", log.Fields{"ingress": ingress, "egress": egress, "routelink": routeLink})
+ logger.Debugw("ROUTELINKS", log.Fields{"ingress": ingress, "egress": egress, "routelink": routeLink})
if ingress == routeLink.Ingress && egress == routeLink.Egress {
return route, nil
}
@@ -1551,14 +1551,14 @@
// GetRoute returns route
func (agent *LogicalDeviceAgent) GetRoute(ctx context.Context, ingressPortNo uint32, egressPortNo uint32) ([]route.Hop, error) {
- log.Debugw("getting-route", log.Fields{"ingress-port": ingressPortNo, "egress-port": egressPortNo})
+ logger.Debugw("getting-route", log.Fields{"ingress-port": ingressPortNo, "egress-port": egressPortNo})
routes := make([]route.Hop, 0)
// Note: A port value of 0 is equivalent to a nil port
// Consider different possibilities
if egressPortNo != 0 && ((egressPortNo & 0x7fffffff) == uint32(ofp.OfpPortNo_OFPP_CONTROLLER)) {
- log.Debugw("controller-flow", log.Fields{"ingressPortNo": ingressPortNo, "egressPortNo": egressPortNo, "logicalPortsNo": agent.logicalPortsNo})
+ logger.Debugw("controller-flow", log.Fields{"ingressPortNo": ingressPortNo, "egressPortNo": egressPortNo, "logicalPortsNo": agent.logicalPortsNo})
if agent.isNNIPort(ingressPortNo) {
//This is a trap on the NNI Port
if len(agent.deviceRoutes.Routes) == 0 {
@@ -1582,7 +1582,7 @@
//treat it as if the output port is the first NNI of the OLT
var err error
if egressPortNo, err = agent.getFirstNNIPort(); err != nil {
- log.Warnw("no-nni-port", log.Fields{"error": err})
+ logger.Warnw("no-nni-port", log.Fields{"error": err})
return nil, err
}
}
@@ -1641,7 +1641,7 @@
//rebuildRoutes rebuilds the device routes
func (agent *LogicalDeviceAgent) buildRoutes(ctx context.Context) error {
- log.Debugf("building-routes", log.Fields{"logical-device-id": agent.logicalDeviceID})
+ logger.Debugf("building-routes", log.Fields{"logical-device-id": agent.logicalDeviceID})
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
return err
}
@@ -1665,7 +1665,7 @@
//updateRoutes updates the device routes
func (agent *LogicalDeviceAgent) updateRoutes(ctx context.Context, lp *voltha.LogicalPort) error {
- log.Debugw("updateRoutes", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
+ logger.Debugw("updateRoutes", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
return err
}
@@ -1724,23 +1724,23 @@
// the POST_ADD notification is fixed, we will use the logical device to
// update that data.
func (agent *LogicalDeviceAgent) portUpdated(ctx context.Context, args ...interface{}) interface{} {
- log.Debugw("portUpdated-callback", log.Fields{"argsLen": len(args)})
+ logger.Debugw("portUpdated-callback", log.Fields{"argsLen": len(args)})
var oldLD *voltha.LogicalDevice
var newlD *voltha.LogicalDevice
var ok bool
if oldLD, ok = args[0].(*voltha.LogicalDevice); !ok {
- log.Errorw("invalid-args", log.Fields{"args0": args[0]})
+ logger.Errorw("invalid-args", log.Fields{"args0": args[0]})
return nil
}
if newlD, ok = args[1].(*voltha.LogicalDevice); !ok {
- log.Errorw("invalid-args", log.Fields{"args1": args[1]})
+ logger.Errorw("invalid-args", log.Fields{"args1": args[1]})
return nil
}
if reflect.DeepEqual(oldLD.Ports, newlD.Ports) {
- log.Debug("ports-have-not-changed")
+ logger.Debug("ports-have-not-changed")
return nil
}
@@ -1769,16 +1769,16 @@
// (true, nil). If the device is not in the correct state it will return (false, nil) as this is a valid
// scenario. This also applies to the case where the port was already added.
func (agent *LogicalDeviceAgent) addNNILogicalPort(ctx context.Context, device *voltha.Device, port *voltha.Port) (bool, error) {
- log.Debugw("addNNILogicalPort", log.Fields{"NNI": port})
+ logger.Debugw("addNNILogicalPort", log.Fields{"NNI": port})
if device.AdminState != voltha.AdminState_ENABLED || device.OperStatus != voltha.OperStatus_ACTIVE {
- log.Infow("device-not-ready", log.Fields{"deviceId": device.Id, "admin": device.AdminState, "oper": device.OperStatus})
+ logger.Infow("device-not-ready", log.Fields{"deviceId": device.Id, "admin": device.AdminState, "oper": device.OperStatus})
return false, nil
}
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
return false, err
}
if agent.portExist(device, port) {
- log.Debugw("port-already-exist", log.Fields{"port": port})
+ logger.Debugw("port-already-exist", log.Fields{"port": port})
agent.requestQueue.RequestComplete()
return false, nil
}
@@ -1788,7 +1788,7 @@
var err error
// First get the port capability
if portCap, err = agent.deviceMgr.getPortCapability(ctx, device.Id, port.PortNo); err != nil {
- log.Errorw("error-retrieving-port-capabilities", log.Fields{"error": err})
+ logger.Errorw("error-retrieving-port-capabilities", log.Fields{"error": err})
return false, err
}
@@ -1799,7 +1799,7 @@
defer agent.requestQueue.RequestComplete()
// Double check again if this port has been already added since the getPortCapability could have taken a long time
if agent.portExist(device, port) {
- log.Debugw("port-already-exist", log.Fields{"port": port})
+ logger.Debugw("port-already-exist", log.Fields{"port": port})
return false, nil
}
@@ -1820,7 +1820,7 @@
cloned.Ports = append(cloned.Ports, lp)
if err = agent.updateLogicalDeviceWithoutLock(ctx, cloned); err != nil {
- log.Errorw("error-updating-logical-device", log.Fields{"error": err})
+ logger.Errorw("error-updating-logical-device", log.Fields{"error": err})
return false, err
}
@@ -1828,7 +1828,7 @@
clonedLP := (proto.Clone(lp)).(*voltha.LogicalPort)
go func() {
if err := agent.updateRoutes(context.Background(), clonedLP); err != nil {
- log.Warnw("routes-not-ready", log.Fields{"logical-device-id": agent.logicalDeviceID, "logical-port": lp.OfpPort.PortNo, "error": err})
+ logger.Warnw("routes-not-ready", log.Fields{"logical-device-id": agent.logicalDeviceID, "logical-port": lp.OfpPort.PortNo, "error": err})
}
}()
@@ -1850,9 +1850,9 @@
// (true, nil). If the device is not in the correct state it will return (false, nil) as this is a valid
// scenario. This also applies to the case where the port was already added.
func (agent *LogicalDeviceAgent) addUNILogicalPort(ctx context.Context, childDevice *voltha.Device, port *voltha.Port) (bool, error) {
- log.Debugw("addUNILogicalPort", log.Fields{"port": port})
+ logger.Debugw("addUNILogicalPort", log.Fields{"port": port})
if childDevice.AdminState != voltha.AdminState_ENABLED || childDevice.OperStatus != voltha.OperStatus_ACTIVE {
- log.Infow("device-not-ready", log.Fields{"deviceId": childDevice.Id, "admin": childDevice.AdminState, "oper": childDevice.OperStatus})
+ logger.Infow("device-not-ready", log.Fields{"deviceId": childDevice.Id, "admin": childDevice.AdminState, "oper": childDevice.OperStatus})
return false, nil
}
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
@@ -1860,7 +1860,7 @@
}
if agent.portExist(childDevice, port) {
- log.Debugw("port-already-exist", log.Fields{"port": port})
+ logger.Debugw("port-already-exist", log.Fields{"port": port})
agent.requestQueue.RequestComplete()
return false, nil
}
@@ -1869,7 +1869,7 @@
var err error
// First get the port capability
if portCap, err = agent.deviceMgr.getPortCapability(ctx, childDevice.Id, port.PortNo); err != nil {
- log.Errorw("error-retrieving-port-capabilities", log.Fields{"error": err})
+ logger.Errorw("error-retrieving-port-capabilities", log.Fields{"error": err})
return false, err
}
if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
@@ -1878,13 +1878,13 @@
defer agent.requestQueue.RequestComplete()
// Double check again if this port has been already added since the getPortCapability could have taken a long time
if agent.portExist(childDevice, port) {
- log.Debugw("port-already-exist", log.Fields{"port": port})
+ logger.Debugw("port-already-exist", log.Fields{"port": port})
return false, nil
}
// Get stored logical device
ldevice := agent.getLogicalDeviceWithoutLock()
- log.Debugw("adding-uni", log.Fields{"deviceId": childDevice.Id})
+ logger.Debugw("adding-uni", log.Fields{"deviceId": childDevice.Id})
portCap.Port.RootPort = false
portCap.Port.Id = port.Label
portCap.Port.OfpPort.PortNo = port.PortNo
@@ -1903,7 +1903,7 @@
go func() {
if err := agent.updateRoutes(context.Background(), clonedLP); err != nil {
- log.Warn("routes-not-ready", log.Fields{"logical-device-id": agent.logicalDeviceID, "error": err})
+ logger.Warn("routes-not-ready", log.Fields{"logical-device-id": agent.logicalDeviceID, "error": err})
}
}()
@@ -1911,7 +1911,7 @@
}
func (agent *LogicalDeviceAgent) packetOut(ctx context.Context, packet *ofp.OfpPacketOut) {
- log.Debugw("packet-out", log.Fields{
+ logger.Debugw("packet-out", log.Fields{
"packet": hex.EncodeToString(packet.Data),
"inPort": packet.GetInPort(),
})
@@ -1919,19 +1919,19 @@
//frame := packet.GetData()
//TODO: Use a channel between the logical agent and the device agent
if err := agent.deviceMgr.packetOut(ctx, agent.rootDeviceID, outPort, packet); err != nil {
- log.Error("packetout-failed", log.Fields{"logicalDeviceID": agent.rootDeviceID})
+ logger.Error("packetout-failed", log.Fields{"logicalDeviceID": agent.rootDeviceID})
}
}
func (agent *LogicalDeviceAgent) packetIn(port uint32, transactionID string, packet []byte) {
- log.Debugw("packet-in", log.Fields{
+ logger.Debugw("packet-in", log.Fields{
"port": port,
"packet": hex.EncodeToString(packet),
"transactionId": transactionID,
})
packetIn := fu.MkPacketIn(port, packet)
agent.ldeviceMgr.grpcNbiHdlr.sendPacketIn(agent.logicalDeviceID, transactionID, packetIn)
- log.Debugw("sending-packet-in", log.Fields{"packet": hex.EncodeToString(packetIn.Data)})
+ logger.Debugw("sending-packet-in", log.Fields{"packet": hex.EncodeToString(packetIn.Data)})
}
func (agent *LogicalDeviceAgent) addLogicalPortToMap(portNo uint32, nniPort bool) {
diff --git a/rw_core/core/logical_device_agent_test.go b/rw_core/core/logical_device_agent_test.go
index 957bb50..53e355e 100644
--- a/rw_core/core/logical_device_agent_test.go
+++ b/rw_core/core/logical_device_agent_test.go
@@ -22,7 +22,6 @@
com "github.com/opencord/voltha-lib-go/v3/pkg/adapters/common"
fu "github.com/opencord/voltha-lib-go/v3/pkg/flows"
"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
lm "github.com/opencord/voltha-lib-go/v3/pkg/mocks"
ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
"github.com/opencord/voltha-protos/v3/go/voltha"
@@ -377,7 +376,7 @@
var err error
test.etcdServer, test.kvClientPort, err = startEmbeddedEtcdServer("voltha.rwcore.lda.test", "voltha.rwcore.lda.etcd", "error")
if err != nil {
- log.Fatal(err)
+ logger.Fatal(err)
}
// Create the kafka client
test.kClient = lm.NewKafkaClient()
@@ -454,7 +453,7 @@
cfg.InCompetingMode = inCompeteMode
grpcPort, err := freeport.GetFreePort()
if err != nil {
- log.Fatal("Cannot get a freeport for grpc")
+ logger.Fatal("Cannot get a freeport for grpc")
}
cfg.GrpcPort = grpcPort
cfg.GrpcHost = "127.0.0.1"
@@ -463,7 +462,7 @@
lda.core = NewCore(ctx, lda.coreInstanceID, cfg, client, lda.kClient)
err = lda.core.Start(ctx)
if err != nil {
- log.Fatal("Cannot start core")
+ logger.Fatal("Cannot start core")
}
}
diff --git a/rw_core/core/logical_device_manager.go b/rw_core/core/logical_device_manager.go
index 1859784..070d4ef 100644
--- a/rw_core/core/logical_device_manager.go
+++ b/rw_core/core/logical_device_manager.go
@@ -64,16 +64,16 @@
}
func (ldMgr *LogicalDeviceManager) start(ctx context.Context) {
- log.Info("starting-logical-device-manager")
+ logger.Info("starting-logical-device-manager")
probe.UpdateStatusFromContext(ctx, "logical-device-manager", probe.ServiceStatusRunning)
- log.Info("logical-device-manager-started")
+ logger.Info("logical-device-manager-started")
}
func (ldMgr *LogicalDeviceManager) stop(ctx context.Context) {
- log.Info("stopping-logical-device-manager")
+ logger.Info("stopping-logical-device-manager")
ldMgr.exitChannel <- 1
probe.UpdateStatusFromContext(ctx, "logical-device-manager", probe.ServiceStatusStopped)
- log.Info("logical-device-manager-stopped")
+ logger.Info("logical-device-manager-stopped")
}
func sendAPIResponse(ctx context.Context, ch chan interface{}, result interface{}) {
@@ -81,10 +81,10 @@
// Returned response only of the ctx has not been cancelled/timeout/etc
// Channel is automatically closed when a context is Done
ch <- result
- log.Debugw("sendResponse", log.Fields{"result": result})
+ logger.Debugw("sendResponse", log.Fields{"result": result})
} else {
// Should the transaction be reverted back?
- log.Debugw("sendResponse-context-error", log.Fields{"context-error": ctx.Err()})
+ logger.Debugw("sendResponse-context-error", log.Fields{"context-error": ctx.Err()})
}
}
@@ -104,7 +104,7 @@
// This can happen when an agent for the logical device has been created but the logical device
// itself is not ready for action as it is waiting for switch and port capabilities from the
// relevant adapter. In such a case prevent any request aimed at that logical device.
- log.Debugf("Logical device %s is not ready to serve requests", logicalDeviceID)
+ logger.Debugf("Logical device %s is not ready to serve requests", logicalDeviceID)
return nil
}
return lda
@@ -125,7 +125,7 @@
// GetLogicalDevice provides a cloned most up to date logical device. If device is not in memory
// it will be fetched from the dB
func (ldMgr *LogicalDeviceManager) getLogicalDevice(ctx context.Context, id string) (*voltha.LogicalDevice, error) {
- log.Debugw("getlogicalDevice", log.Fields{"logicaldeviceid": id})
+ logger.Debugw("getlogicalDevice", log.Fields{"logicaldeviceid": id})
if agent := ldMgr.getLogicalDeviceAgent(ctx, id); agent != nil {
return agent.GetLogicalDevice(ctx)
}
@@ -133,7 +133,7 @@
}
func (ldMgr *LogicalDeviceManager) listManagedLogicalDevices(ctx context.Context) (*voltha.LogicalDevices, error) {
- log.Debug("listManagedLogicalDevices")
+ logger.Debug("listManagedLogicalDevices")
result := &voltha.LogicalDevices{}
ldMgr.logicalDeviceAgents.Range(func(key, value interface{}) bool {
agent := value.(*LogicalDeviceAgent)
@@ -148,11 +148,11 @@
//listLogicalDevices returns the list of all logical devices
func (ldMgr *LogicalDeviceManager) listLogicalDevices(ctx context.Context) (*voltha.LogicalDevices, error) {
- log.Debug("ListAllLogicalDevices")
+ logger.Debug("ListAllLogicalDevices")
result := &voltha.LogicalDevices{}
logicalDevices, err := ldMgr.clusterDataProxy.List(ctx, "/logical_devices", 0, true, "")
if err != nil {
- log.Errorw("failed-to-list-logical-devices-from-cluster-proxy", log.Fields{"error": err})
+ logger.Errorw("failed-to-list-logical-devices-from-cluster-proxy", log.Fields{"error": err})
return nil, err
}
if logicalDevices != nil {
@@ -164,7 +164,7 @@
}
func (ldMgr *LogicalDeviceManager) createLogicalDevice(ctx context.Context, device *voltha.Device) (*string, error) {
- log.Debugw("creating-logical-device", log.Fields{"deviceId": device.Id})
+ logger.Debugw("creating-logical-device", log.Fields{"deviceId": device.Id})
// Sanity check
if !device.Root {
return nil, errors.New("device-not-root")
@@ -177,17 +177,17 @@
macAddress := device.MacAddress
id := strings.Replace(macAddress, ":", "", -1)
if id == "" {
- log.Errorw("mac-address-not-set", log.Fields{"deviceId": device.Id})
+ logger.Errorw("mac-address-not-set", log.Fields{"deviceId": device.Id})
return nil, errors.New("mac-address-not-set")
}
- log.Debugw("logical-device-id", log.Fields{"logicaldeviceId": id})
+ logger.Debugw("logical-device-id", log.Fields{"logicaldeviceId": id})
agent := newLogicalDeviceAgent(id, device.Id, ldMgr, ldMgr.deviceMgr, ldMgr.clusterDataProxy, ldMgr.defaultTimeout)
ldMgr.addLogicalDeviceAgentToMap(agent)
// Update the root device with the logical device Id reference
if err := ldMgr.deviceMgr.setParentID(ctx, device, id); err != nil {
- log.Errorw("failed-setting-parent-id", log.Fields{"logicalDeviceId": id, "deviceId": device.Id})
+ logger.Errorw("failed-setting-parent-id", log.Fields{"logicalDeviceId": id, "deviceId": device.Id})
return nil, err
}
@@ -195,12 +195,12 @@
//agent := newLogicalDeviceAgent(id, device.Id, ldMgr, ldMgr.deviceMgr, ldMgr.clusterDataProxy, ldMgr.defaultTimeout)
err := agent.start(context.Background(), false)
if err != nil {
- log.Errorw("unable-to-create-the-logical-device", log.Fields{"error": err})
+ logger.Errorw("unable-to-create-the-logical-device", log.Fields{"error": err})
ldMgr.deleteLogicalDeviceAgent(id)
}
}()
- log.Debug("creating-logical-device-ends")
+ logger.Debug("creating-logical-device-ends")
return &id, nil
}
@@ -208,15 +208,15 @@
// reference of this logical device in cache. The device Id is passed as param because the logical device may already
// have been removed from the model. This function returns the logical device Id if found
func (ldMgr *LogicalDeviceManager) stopManagingLogicalDeviceWithDeviceID(ctx context.Context, id string) string {
- log.Infow("stop-managing-logical-device", log.Fields{"deviceId": id})
+ logger.Infow("stop-managing-logical-device", log.Fields{"deviceId": id})
// Go over the list of logical device agents to find the one which has rootDeviceId as id
var ldID = ""
ldMgr.logicalDeviceAgents.Range(func(key, value interface{}) bool {
ldAgent := value.(*LogicalDeviceAgent)
if ldAgent.rootDeviceID == id {
- log.Infow("stopping-logical-device-agent", log.Fields{"lDeviceId": key})
+ logger.Infow("stopping-logical-device-agent", log.Fields{"lDeviceId": key})
if err := ldAgent.stop(ctx); err != nil {
- log.Errorw("failed-to-stop-LDAgent", log.Fields{"error": err})
+ logger.Errorw("failed-to-stop-LDAgent", log.Fields{"error": err})
return false
}
ldID = key.(string)
@@ -231,7 +231,7 @@
func (ldMgr *LogicalDeviceManager) getLogicalDeviceFromModel(ctx context.Context, lDeviceID string) (*voltha.LogicalDevice, error) {
logicalDevice, err := ldMgr.clusterDataProxy.Get(ctx, "/logical_devices/"+lDeviceID, 0, false, "")
if err != nil {
- log.Errorw("failed-to-get-logical-devices-from-cluster-proxy", log.Fields{"error": err})
+ logger.Errorw("failed-to-get-logical-devices-from-cluster-proxy", log.Fields{"error": err})
return nil, err
}
if logicalDevice != nil {
@@ -254,14 +254,14 @@
ldMgr.logicalDeviceLoadingInProgress[lDeviceID] = []chan int{make(chan int, 1)}
ldMgr.logicalDevicesLoadingLock.Unlock()
if _, err := ldMgr.getLogicalDeviceFromModel(ctx, lDeviceID); err == nil {
- log.Debugw("loading-logical-device", log.Fields{"lDeviceId": lDeviceID})
+ logger.Debugw("loading-logical-device", log.Fields{"lDeviceId": lDeviceID})
agent := newLogicalDeviceAgent(lDeviceID, "", ldMgr, ldMgr.deviceMgr, ldMgr.clusterDataProxy, ldMgr.defaultTimeout)
if err := agent.start(ctx, true); err != nil {
return err
}
ldMgr.logicalDeviceAgents.Store(agent.logicalDeviceID, agent)
} else {
- log.Debugw("logicalDevice not in model", log.Fields{"lDeviceId": lDeviceID})
+ logger.Debugw("logicalDevice not in model", log.Fields{"lDeviceId": lDeviceID})
}
// announce completion of task to any number of waiting channels
ldMgr.logicalDevicesLoadingLock.Lock()
@@ -289,7 +289,7 @@
}
func (ldMgr *LogicalDeviceManager) deleteLogicalDevice(ctx context.Context, device *voltha.Device) error {
- log.Debugw("deleting-logical-device", log.Fields{"deviceId": device.Id})
+ logger.Debugw("deleting-logical-device", log.Fields{"deviceId": device.Id})
// Sanity check
if !device.Root {
return errors.New("device-not-root")
@@ -298,18 +298,18 @@
if agent := ldMgr.getLogicalDeviceAgent(ctx, logDeviceID); agent != nil {
// Stop the logical device agent
if err := agent.stop(ctx); err != nil {
- log.Errorw("failed-to-stop-agent", log.Fields{"error": err})
+ logger.Errorw("failed-to-stop-agent", log.Fields{"error": err})
return err
}
//Remove the logical device agent from the Map
ldMgr.deleteLogicalDeviceAgent(logDeviceID)
err := ldMgr.core.deviceOwnership.AbandonDevice(logDeviceID)
if err != nil {
- log.Errorw("unable-to-abandon-the-device", log.Fields{"error": err})
+ logger.Errorw("unable-to-abandon-the-device", log.Fields{"error": err})
}
}
- log.Debug("deleting-logical-device-ends")
+ logger.Debug("deleting-logical-device-ends")
return nil
}
@@ -359,7 +359,7 @@
// ListLogicalDeviceFlows returns the flows of logical device
func (ldMgr *LogicalDeviceManager) ListLogicalDeviceFlows(ctx context.Context, id string) (*openflow_13.Flows, error) {
- log.Debugw("ListLogicalDeviceFlows", log.Fields{"logicaldeviceid": id})
+ logger.Debugw("ListLogicalDeviceFlows", log.Fields{"logicaldeviceid": id})
if agent := ldMgr.getLogicalDeviceAgent(ctx, id); agent != nil {
return agent.ListLogicalDeviceFlows(ctx)
}
@@ -368,7 +368,7 @@
// ListLogicalDeviceFlowGroups returns logical device flow groups
func (ldMgr *LogicalDeviceManager) ListLogicalDeviceFlowGroups(ctx context.Context, id string) (*openflow_13.FlowGroups, error) {
- log.Debugw("ListLogicalDeviceFlowGroups", log.Fields{"logicaldeviceid": id})
+ logger.Debugw("ListLogicalDeviceFlowGroups", log.Fields{"logicaldeviceid": id})
if agent := ldMgr.getLogicalDeviceAgent(ctx, id); agent != nil {
return agent.ListLogicalDeviceFlowGroups(ctx)
}
@@ -377,7 +377,7 @@
// ListLogicalDevicePorts returns logical device ports
func (ldMgr *LogicalDeviceManager) ListLogicalDevicePorts(ctx context.Context, id string) (*voltha.LogicalPorts, error) {
- log.Debugw("ListLogicalDevicePorts", log.Fields{"logicaldeviceid": id})
+ logger.Debugw("ListLogicalDevicePorts", log.Fields{"logicaldeviceid": id})
if agent := ldMgr.getLogicalDeviceAgent(ctx, id); agent != nil {
return agent.ListLogicalDevicePorts(ctx)
}
@@ -419,12 +419,12 @@
// deleteLogicalPort removes the logical port associated with a device
func (ldMgr *LogicalDeviceManager) deleteLogicalPort(ctx context.Context, lPortID *voltha.LogicalPortId) error {
- log.Debugw("deleting-logical-port", log.Fields{"LDeviceId": lPortID.Id})
+ logger.Debugw("deleting-logical-port", log.Fields{"LDeviceId": lPortID.Id})
// Get logical port
var logicalPort *voltha.LogicalPort
var err error
if logicalPort, err = ldMgr.getLogicalPort(ctx, lPortID); err != nil {
- log.Debugw("no-logical-device-port-present", log.Fields{"logicalPortId": lPortID.PortId})
+ logger.Debugw("no-logical-device-port-present", log.Fields{"logicalPortId": lPortID.PortId})
return err
}
// Sanity check
@@ -433,17 +433,17 @@
}
if agent := ldMgr.getLogicalDeviceAgent(ctx, lPortID.Id); agent != nil {
if err := agent.deleteLogicalPort(ctx, logicalPort); err != nil {
- log.Warnw("deleting-logicalport-failed", log.Fields{"LDeviceId": lPortID.Id, "error": err})
+ logger.Warnw("deleting-logicalport-failed", log.Fields{"LDeviceId": lPortID.Id, "error": err})
}
}
- log.Debug("deleting-logical-port-ends")
+ logger.Debug("deleting-logical-port-ends")
return nil
}
// deleteLogicalPort removes the logical port associated with a child device
func (ldMgr *LogicalDeviceManager) deleteLogicalPorts(ctx context.Context, deviceID string) error {
- log.Debugw("deleting-logical-ports", log.Fields{"deviceId": deviceID})
+ logger.Debugw("deleting-logical-ports", log.Fields{"deviceId": deviceID})
// Get logical port
ldID, err := ldMgr.getLogicalDeviceIDFromDeviceID(ctx, deviceID)
if err != nil {
@@ -451,16 +451,16 @@
}
if agent := ldMgr.getLogicalDeviceAgent(ctx, *ldID); agent != nil {
if err = agent.deleteLogicalPorts(ctx, deviceID); err != nil {
- log.Warnw("deleteLogicalPorts-failed", log.Fields{"ldeviceId": *ldID})
+ logger.Warnw("deleteLogicalPorts-failed", log.Fields{"ldeviceId": *ldID})
return err
}
}
- log.Debug("deleting-logical-port-ends")
+ logger.Debug("deleting-logical-port-ends")
return nil
}
func (ldMgr *LogicalDeviceManager) setupUNILogicalPorts(ctx context.Context, childDevice *voltha.Device) error {
- log.Debugw("setupUNILogicalPorts", log.Fields{"childDeviceId": childDevice.Id, "parentDeviceId": childDevice.ParentId, "current-data": childDevice})
+ logger.Debugw("setupUNILogicalPorts", log.Fields{"childDeviceId": childDevice.Id, "parentDeviceId": childDevice.ParentId, "current-data": childDevice})
// Sanity check
if childDevice.Root {
return errors.New("Device-root")
@@ -470,7 +470,7 @@
parentID := childDevice.ParentId
logDeviceID := ldMgr.deviceMgr.GetParentDeviceID(ctx, parentID)
- log.Debugw("setupUNILogicalPorts", log.Fields{"logDeviceId": logDeviceID, "parentId": parentID})
+ logger.Debugw("setupUNILogicalPorts", log.Fields{"logDeviceId": logDeviceID, "parentId": parentID})
if parentID == "" || logDeviceID == "" {
return errors.New("device-in-invalid-state")
@@ -485,13 +485,13 @@
}
func (ldMgr *LogicalDeviceManager) deleteAllLogicalPorts(ctx context.Context, device *voltha.Device) error {
- log.Debugw("deleteAllLogicalPorts", log.Fields{"deviceId": device.Id})
+ logger.Debugw("deleteAllLogicalPorts", log.Fields{"deviceId": device.Id})
var ldID *string
var err error
//Get the logical device Id for this device
if ldID, err = ldMgr.getLogicalDeviceID(ctx, device); err != nil {
- log.Warnw("no-logical-device-found", log.Fields{"deviceId": device.Id, "error": err})
+ logger.Warnw("no-logical-device-found", log.Fields{"deviceId": device.Id, "error": err})
return err
}
if agent := ldMgr.getLogicalDeviceAgent(ctx, *ldID); agent != nil {
@@ -503,7 +503,7 @@
}
func (ldMgr *LogicalDeviceManager) deleteAllUNILogicalPorts(ctx context.Context, parentDevice *voltha.Device) error {
- log.Debugw("delete-all-uni-logical-ports", log.Fields{"parent-device-id": parentDevice.Id})
+ logger.Debugw("delete-all-uni-logical-ports", log.Fields{"parent-device-id": parentDevice.Id})
var ldID *string
var err error
@@ -520,13 +520,13 @@
}
func (ldMgr *LogicalDeviceManager) updatePortState(ctx context.Context, deviceID string, portNo uint32, state voltha.OperStatus_Types) error {
- log.Debugw("updatePortState", log.Fields{"deviceId": deviceID, "state": state, "portNo": portNo})
+ logger.Debugw("updatePortState", log.Fields{"deviceId": deviceID, "state": state, "portNo": portNo})
var ldID *string
var err error
//Get the logical device Id for this device
if ldID, err = ldMgr.getLogicalDeviceIDFromDeviceID(ctx, deviceID); err != nil {
- log.Warnw("no-logical-device-found", log.Fields{"deviceId": deviceID, "error": err})
+ logger.Warnw("no-logical-device-found", log.Fields{"deviceId": deviceID, "error": err})
return err
}
if agent := ldMgr.getLogicalDeviceAgent(ctx, *ldID); agent != nil {
@@ -538,13 +538,13 @@
}
func (ldMgr *LogicalDeviceManager) updatePortsState(ctx context.Context, device *voltha.Device, state voltha.OperStatus_Types) error {
- log.Debugw("updatePortsState", log.Fields{"deviceId": device.Id, "state": state, "current-data": device})
+ logger.Debugw("updatePortsState", log.Fields{"deviceId": device.Id, "state": state, "current-data": device})
var ldID *string
var err error
//Get the logical device Id for this device
if ldID, err = ldMgr.getLogicalDeviceID(ctx, device); err != nil {
- log.Warnw("no-logical-device-found", log.Fields{"deviceId": device.Id, "error": err})
+ logger.Warnw("no-logical-device-found", log.Fields{"deviceId": device.Id, "error": err})
return err
}
if agent := ldMgr.getLogicalDeviceAgent(ctx, *ldID); agent != nil {
@@ -556,11 +556,11 @@
}
func (ldMgr *LogicalDeviceManager) updateFlowTable(ctx context.Context, id string, flow *openflow_13.OfpFlowMod, ch chan interface{}) {
- log.Debugw("updateFlowTable", log.Fields{"logicalDeviceId": id})
+ logger.Debugw("updateFlowTable", log.Fields{"logicalDeviceId": id})
var res interface{}
if agent := ldMgr.getLogicalDeviceAgent(ctx, id); agent != nil {
res = agent.updateFlowTable(ctx, flow)
- log.Debugw("updateFlowTable-result", log.Fields{"result": res})
+ logger.Debugw("updateFlowTable-result", log.Fields{"result": res})
} else {
res = status.Errorf(codes.NotFound, "%s", id)
}
@@ -568,11 +568,11 @@
}
func (ldMgr *LogicalDeviceManager) updateMeterTable(ctx context.Context, id string, meter *openflow_13.OfpMeterMod, ch chan interface{}) {
- log.Debugw("updateMeterTable", log.Fields{"logicalDeviceId": id})
+ logger.Debugw("updateMeterTable", log.Fields{"logicalDeviceId": id})
var res interface{}
if agent := ldMgr.getLogicalDeviceAgent(ctx, id); agent != nil {
res = agent.updateMeterTable(ctx, meter)
- log.Debugw("updateMeterTable-result", log.Fields{"result": res})
+ logger.Debugw("updateMeterTable-result", log.Fields{"result": res})
} else {
res = status.Errorf(codes.NotFound, "%s", id)
}
@@ -581,18 +581,18 @@
// ListLogicalDeviceMeters returns logical device meters
func (ldMgr *LogicalDeviceManager) ListLogicalDeviceMeters(ctx context.Context, id string) (*openflow_13.Meters, error) {
- log.Debugw("ListLogicalDeviceMeters", log.Fields{"logicalDeviceId": id})
+ logger.Debugw("ListLogicalDeviceMeters", log.Fields{"logicalDeviceId": id})
if agent := ldMgr.getLogicalDeviceAgent(ctx, id); agent != nil {
return agent.ListLogicalDeviceMeters(ctx)
}
return nil, status.Errorf(codes.NotFound, "%s", id)
}
func (ldMgr *LogicalDeviceManager) updateGroupTable(ctx context.Context, id string, groupMod *openflow_13.OfpGroupMod, ch chan interface{}) {
- log.Debugw("updateGroupTable", log.Fields{"logicalDeviceId": id})
+ logger.Debugw("updateGroupTable", log.Fields{"logicalDeviceId": id})
var res interface{}
if agent := ldMgr.getLogicalDeviceAgent(ctx, id); agent != nil {
res = agent.updateGroupTable(ctx, groupMod)
- log.Debugw("updateGroupTable-result", log.Fields{"result": res})
+ logger.Debugw("updateGroupTable-result", log.Fields{"result": res})
} else {
res = status.Errorf(codes.NotFound, "%s", id)
}
@@ -600,11 +600,11 @@
}
func (ldMgr *LogicalDeviceManager) enableLogicalPort(ctx context.Context, id *voltha.LogicalPortId, ch chan interface{}) {
- log.Debugw("enableLogicalPort", log.Fields{"logicalDeviceId": id})
+ logger.Debugw("enableLogicalPort", log.Fields{"logicalDeviceId": id})
var res interface{}
if agent := ldMgr.getLogicalDeviceAgent(ctx, id.Id); agent != nil {
res = agent.enableLogicalPort(ctx, id.PortId)
- log.Debugw("enableLogicalPort-result", log.Fields{"result": res})
+ logger.Debugw("enableLogicalPort-result", log.Fields{"result": res})
} else {
res = status.Errorf(codes.NotFound, "%s", id.Id)
}
@@ -612,11 +612,11 @@
}
func (ldMgr *LogicalDeviceManager) disableLogicalPort(ctx context.Context, id *voltha.LogicalPortId, ch chan interface{}) {
- log.Debugw("disableLogicalPort", log.Fields{"logicalDeviceId": id})
+ logger.Debugw("disableLogicalPort", log.Fields{"logicalDeviceId": id})
var res interface{}
if agent := ldMgr.getLogicalDeviceAgent(ctx, id.Id); agent != nil {
res = agent.disableLogicalPort(ctx, id.PortId)
- log.Debugw("disableLogicalPort-result", log.Fields{"result": res})
+ logger.Debugw("disableLogicalPort-result", log.Fields{"result": res})
} else {
res = status.Errorf(codes.NotFound, "%s", id.Id)
}
@@ -624,11 +624,11 @@
}
func (ldMgr *LogicalDeviceManager) packetIn(ctx context.Context, logicalDeviceID string, port uint32, transactionID string, packet []byte) error {
- log.Debugw("packetIn", log.Fields{"logicalDeviceId": logicalDeviceID, "port": port})
+ logger.Debugw("packetIn", log.Fields{"logicalDeviceId": logicalDeviceID, "port": port})
if agent := ldMgr.getLogicalDeviceAgent(ctx, logicalDeviceID); agent != nil {
agent.packetIn(port, transactionID, packet)
} else {
- log.Error("logical-device-not-exist", log.Fields{"logicalDeviceId": logicalDeviceID})
+ logger.Error("logical-device-not-exist", log.Fields{"logicalDeviceId": logicalDeviceID})
}
return nil
}
diff --git a/rw_core/core/transaction.go b/rw_core/core/transaction.go
index fc55683..a353ef2 100644
--- a/rw_core/core/transaction.go
+++ b/rw_core/core/transaction.go
@@ -88,13 +88,6 @@
"ABANDONED-BY-OTHER",
"ABANDONED_WATCH_BY_SELF"}
-func init() {
- _, err := log.AddPackage(log.JSON, log.DebugLevel, nil)
- if err != nil {
- log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
- }
-}
-
// NewTransactionContext creates transaction context instance
func NewTransactionContext(
owner string,
@@ -201,7 +194,7 @@
if err := c.tryToReserveTxn(ctx, durationInSecs*2); err == nil {
res = SeizedBySelf
} else {
- log.Debugw("watch-other-server",
+ logger.Debugw("watch-other-server",
log.Fields{"transactionId": c.txnID, "owner": currOwner, "timeout": durationInSecs})
res = c.Watch(ctx, durationInSecs)
}
@@ -214,7 +207,7 @@
default:
acquired = false
}
- log.Debugw("acquire-transaction-status", log.Fields{"transactionId": c.txnID, "acquired": acquired, "result": txnState[res]})
+ logger.Debugw("acquire-transaction-status", log.Fields{"transactionId": c.txnID, "acquired": acquired, "result": txnState[res]})
return acquired, nil
}
@@ -225,11 +218,11 @@
value, _ := ctx.kvClient.Reserve(ctxt, c.txnKey, ctx.owner, durationInSecs)
if value != nil {
if currOwner, err = kvstore.ToString(value); err != nil { // This should never happen
- log.Errorw("unexpected-owner-type", log.Fields{"transactionId": c.txnID, "error": err})
+ logger.Errorw("unexpected-owner-type", log.Fields{"transactionId": c.txnID, "error": err})
return err
}
if currOwner == ctx.owner {
- log.Debugw("acquired-transaction", log.Fields{"transactionId": c.txnID, "result": txnState[res]})
+ logger.Debugw("acquired-transaction", log.Fields{"transactionId": c.txnID, "result": txnState[res]})
// Setup the monitoring channel
c.monitorCh = make(chan int)
go c.holdOnToTxnUntilProcessingCompleted(ctxt, c.txnKey, ctx.owner, durationInSecs)
@@ -256,14 +249,14 @@
// Do an immediate delete of the transaction in the KV Store to free up KV Storage faster
err = c.Delete(ctxt)
if err != nil {
- log.Errorw("unable-to-delete-the-transaction", log.Fields{"error": err})
+ logger.Errorw("unable-to-delete-the-transaction", log.Fields{"error": err})
}
return res
}
} else {
// An unexpected value - let's get out of here as something did not go according to plan
res = AbandonedWatchBySelf
- log.Debugw("cannot-read-transaction-value", log.Fields{"txn": c.txnID, "error": err})
+ logger.Debugw("cannot-read-transaction-value", log.Fields{"txn": c.txnID, "error": err})
return res
}
}
@@ -272,7 +265,7 @@
select {
case event := <-events:
transactionWasAcquiredByOther = true
- log.Debugw("received-event", log.Fields{"txn": c.txnID, "type": event.EventType})
+ logger.Debugw("received-event", log.Fields{"txn": c.txnID, "type": event.EventType})
if event.EventType == kvstore.DELETE {
// The other core failed to process the request
res = AbandonedByOther
@@ -285,14 +278,14 @@
// Successful request completion has been detected. Remove the transaction key
err := c.Delete(ctxt)
if err != nil {
- log.Errorw("unable-to-delete-the-transaction", log.Fields{"error": err})
+ logger.Errorw("unable-to-delete-the-transaction", log.Fields{"error": err})
}
} else {
- log.Debugw("Ignoring-PUT-event", log.Fields{"val": val, "key": key})
+ logger.Debugw("Ignoring-PUT-event", log.Fields{"val": val, "key": key})
continue
}
} else {
- log.Warnw("received-unexpected-PUT-event", log.Fields{"txn": c.txnID, "key": key, "ctxKey": c.txnKey})
+ logger.Warnw("received-unexpected-PUT-event", log.Fields{"txn": c.txnID, "key": key, "ctxKey": c.txnKey})
}
}
case <-time.After(time.Duration(durationInSecs) * time.Second):
@@ -303,7 +296,7 @@
// guarantee that the peer is actually gone instead of limiting the time the peer can get hold of a
// request.
if !transactionWasAcquiredByOther {
- log.Debugw("timeout-no-peer", log.Fields{"txId": c.txnID})
+ logger.Debugw("timeout-no-peer", log.Fields{"txId": c.txnID})
res = AbandonedByOther
} else {
continue
@@ -316,14 +309,14 @@
// Close closes transaction
func (c *KVTransaction) Close(ctxt context.Context) error {
- log.Debugw("close", log.Fields{"txn": c.txnID})
+ logger.Debugw("close", log.Fields{"txn": c.txnID})
// Stop monitoring the key (applies only when there has been no transaction switch over)
if c.monitorCh != nil {
close(c.monitorCh)
err := ctx.kvClient.Put(ctxt, c.txnKey, TransactionComplete)
if err != nil {
- log.Errorw("unable-to-write-a-key-value-pair-to-the-KV-store", log.Fields{"error": err})
+ logger.Errorw("unable-to-write-a-key-value-pair-to-the-KV-store", log.Fields{"error": err})
}
}
return nil
@@ -331,7 +324,7 @@
// Delete deletes transaction
func (c *KVTransaction) Delete(ctxt context.Context) error {
- log.Debugw("delete", log.Fields{"txn": c.txnID})
+ logger.Debugw("delete", log.Fields{"txn": c.txnID})
return ctx.kvClient.Delete(ctxt, c.txnKey)
}
@@ -339,7 +332,7 @@
// is used to calculate the frequency at which the Core processing the transaction renews the lease. This function
// exits only when the transaction is Closed, i.e completed.
func (c *KVTransaction) holdOnToTxnUntilProcessingCompleted(ctxt context.Context, key string, owner string, durationInSecs int64) {
- log.Debugw("holdOnToTxnUntilProcessingCompleted", log.Fields{"txn": c.txnID})
+ logger.Debugw("holdOnToTxnUntilProcessingCompleted", log.Fields{"txn": c.txnID})
renewInterval := durationInSecs / NumTxnRenewalPerRequest
if renewInterval < MinTxnRenewalIntervalInSec {
renewInterval = MinTxnRenewalIntervalInSec
@@ -348,12 +341,12 @@
for {
select {
case <-c.monitorCh:
- log.Debugw("transaction-renewal-exits", log.Fields{"txn": c.txnID})
+ logger.Debugw("transaction-renewal-exits", log.Fields{"txn": c.txnID})
break forLoop
case <-time.After(time.Duration(renewInterval) * time.Second):
if err := ctx.kvClient.RenewReservation(ctxt, c.txnKey); err != nil {
// Log and continue.
- log.Warnw("transaction-renewal-failed", log.Fields{"txnId": c.txnKey, "error": err})
+ logger.Warnw("transaction-renewal-failed", log.Fields{"txnId": c.txnKey, "error": err})
}
}
}
diff --git a/rw_core/mocks/common_test.go b/rw_core/flowdecomposition/common.go
similarity index 71%
copy from rw_core/mocks/common_test.go
copy to rw_core/flowdecomposition/common.go
index eb1534f..daee4cf 100644
--- a/rw_core/mocks/common_test.go
+++ b/rw_core/flowdecomposition/common.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2019-present Open Networking Foundation
+ * Copyright 2020-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.
@@ -13,21 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package mocks
+
+// Package flowdecomposition Common Logger initialization
+package flowdecomposition
import (
"github.com/opencord/voltha-lib-go/v3/pkg/log"
)
-const (
- logLevel = log.FatalLevel
-)
+var logger log.Logger
-// Unit test initialization. This init() function handles all unit tests in
-// the current directory.
func init() {
// Setup this package so that it's log level can be modified at run time
- _, err := log.AddPackage(log.JSON, logLevel, log.Fields{"instanceId": "mocks"})
+ var err error
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "flowdecomposition"})
if err != nil {
panic(err)
}
diff --git a/rw_core/flowdecomposition/flow_decomposer.go b/rw_core/flowdecomposition/flow_decomposer.go
index 76794e3..94594b0 100644
--- a/rw_core/flowdecomposition/flow_decomposer.go
+++ b/rw_core/flowdecomposition/flow_decomposer.go
@@ -29,13 +29,6 @@
"google.golang.org/grpc/status"
)
-func init() {
- _, err := log.AddPackage(log.JSON, log.DebugLevel, nil)
- if err != nil {
- log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
- }
-}
-
// FlowDecomposer represent flow decomposer attribute
type FlowDecomposer struct {
deviceMgr coreif.DeviceManager
@@ -116,7 +109,7 @@
func (fd *FlowDecomposer) processControllerBoundFlow(ctx context.Context, agent coreif.LogicalDeviceAgent, path []route.Hop,
inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats) (*fu.DeviceRules, error) {
- log.Debugw("trap-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo, "flow": flow})
+ logger.Debugw("trap-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo, "flow": flow})
deviceRules := fu.NewDeviceRules()
meterID := fu.GetMeterIdFromFlow(flow)
metadataFromwriteMetadata := fu.GetMetadataFromWriteMetadataAction(flow)
@@ -127,7 +120,7 @@
//case of packet_in from NNI port rule
if agent.GetDeviceRoutes().IsRootPort(inPortNo) {
// Trap flow for NNI port
- log.Debug("trap-nni")
+ logger.Debug("trap-nni")
fa := &fu.FlowArgs{
KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie},
@@ -147,7 +140,7 @@
deviceRules.AddFlowsAndGroup(egressHop.DeviceID, fg)
} else {
// Trap flow for UNI port
- log.Debug("trap-uni")
+ logger.Debug("trap-uni")
//inPortNo is 0 for wildcard input case, do not include upstream port for controller bound flow in input
var inPorts []uint32
@@ -177,7 +170,7 @@
}
fgParent.AddFlow(fs)
deviceRules.AddFlowsAndGroup(egressHop.DeviceID, fgParent)
- log.Debugw("parent-trap-flow-set", log.Fields{"flow": faParent})
+ logger.Debugw("parent-trap-flow-set", log.Fields{"flow": faParent})
// Upstream flow on child (onu) device
var actions []*ofp.OfpAction
@@ -218,7 +211,7 @@
}
fgChild.AddFlow(fs)
deviceRules.AddFlowsAndGroup(ingressHop.DeviceID, fgChild)
- log.Debugw("child-trap-flow-set", log.Fields{"flow": faChild})
+ logger.Debugw("child-trap-flow-set", log.Fields{"flow": faChild})
}
}
@@ -232,7 +225,7 @@
func (fd *FlowDecomposer) processUpstreamNonControllerBoundFlow(ctx context.Context,
path []route.Hop, inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats) (*fu.DeviceRules, error) {
- log.Debugw("upstream-non-controller-bound-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo})
+ logger.Debugw("upstream-non-controller-bound-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo})
deviceRules := fu.NewDeviceRules()
meterID := fu.GetMeterIdFromFlow(flow)
@@ -242,9 +235,9 @@
egressHop := path[1]
if flow.TableId == 0 && fu.HasNextTable(flow) {
- log.Debugw("decomposing-onu-flow-in-upstream-has-next-table", log.Fields{"table_id": flow.TableId})
+ logger.Debugw("decomposing-onu-flow-in-upstream-has-next-table", log.Fields{"table_id": flow.TableId})
if outPortNo != 0 {
- log.Warnw("outPort-should-not-be-specified", log.Fields{"outPortNo": outPortNo})
+ logger.Warnw("outPort-should-not-be-specified", log.Fields{"outPortNo": outPortNo})
return deviceRules, nil
}
fa := &fu.FlowArgs{
@@ -269,7 +262,7 @@
fg.AddFlow(fs)
deviceRules.AddFlowsAndGroup(ingressHop.DeviceID, fg)
} else if flow.TableId == 1 && outPortNo != 0 {
- log.Debugw("decomposing-olt-flow-in-upstream-has-next-table", log.Fields{"table_id": flow.TableId})
+ logger.Debugw("decomposing-olt-flow-in-upstream-has-next-table", log.Fields{"table_id": flow.TableId})
fa := &fu.FlowArgs{
KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata},
MatchFields: []*ofp.OfpOxmOfbField{
@@ -299,48 +292,48 @@
// processDownstreamFlowWithNextTable decomposes downstream flows containing next table ID instructions
func (fd *FlowDecomposer) processDownstreamFlowWithNextTable(ctx context.Context, agent coreif.LogicalDeviceAgent, path []route.Hop,
inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats) (*fu.DeviceRules, error) {
- log.Debugw("decomposing-olt-flow-in-downstream-flow-with-next-table", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo})
+ logger.Debugw("decomposing-olt-flow-in-downstream-flow-with-next-table", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo})
deviceRules := fu.NewDeviceRules()
meterID := fu.GetMeterIdFromFlow(flow)
metadataFromwriteMetadata := fu.GetMetadataFromWriteMetadataAction(flow)
if outPortNo != 0 {
- log.Warnw("outPort-should-not-be-specified", log.Fields{"outPortNo": outPortNo})
+ logger.Warnw("outPort-should-not-be-specified", log.Fields{"outPortNo": outPortNo})
return deviceRules, nil
}
if flow.TableId != 0 {
- log.Warnw("This is not olt pipeline table, so skipping", log.Fields{"tableId": flow.TableId})
+ logger.Warnw("This is not olt pipeline table, so skipping", log.Fields{"tableId": flow.TableId})
return deviceRules, nil
}
ingressHop := path[0]
egressHop := path[1]
if metadataFromwriteMetadata != 0 {
- log.Debugw("creating-metadata-flow", log.Fields{"flow": flow})
+ logger.Debugw("creating-metadata-flow", log.Fields{"flow": flow})
portNumber := fu.GetEgressPortNumberFromWriteMetadata(flow)
if portNumber != 0 {
recalculatedRoute, err := agent.GetRoute(ctx, inPortNo, portNumber)
if err != nil {
- log.Errorw("no-route-double-tag", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo, "metadata": metadataFromwriteMetadata, "error": err})
+ logger.Errorw("no-route-double-tag", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo, "metadata": metadataFromwriteMetadata, "error": err})
return deviceRules, nil
}
switch len(recalculatedRoute) {
case 0:
- log.Errorw("no-route-double-tag", log.Fields{"inPortNo": inPortNo, "outPortNo": portNumber, "comment": "deleting-flow", "metadata": metadataFromwriteMetadata})
+ logger.Errorw("no-route-double-tag", log.Fields{"inPortNo": inPortNo, "outPortNo": portNumber, "comment": "deleting-flow", "metadata": metadataFromwriteMetadata})
//TODO: Delete flow
return deviceRules, nil
case 2:
- log.Debugw("route-found", log.Fields{"ingressHop": ingressHop, "egressHop": egressHop})
+ logger.Debugw("route-found", log.Fields{"ingressHop": ingressHop, "egressHop": egressHop})
default:
- log.Errorw("invalid-route-length", log.Fields{"routeLen": len(path)})
+ logger.Errorw("invalid-route-length", log.Fields{"routeLen": len(path)})
return deviceRules, nil
}
ingressHop = recalculatedRoute[0]
}
innerTag := fu.GetInnerTagFromMetaData(flow)
if innerTag == 0 {
- log.Errorw("no-inner-route-double-tag", log.Fields{"inPortNo": inPortNo, "outPortNo": portNumber, "comment": "deleting-flow", "metadata": metadataFromwriteMetadata})
+ logger.Errorw("no-inner-route-double-tag", log.Fields{"inPortNo": inPortNo, "outPortNo": portNumber, "comment": "deleting-flow", "metadata": metadataFromwriteMetadata})
//TODO: Delete flow
return deviceRules, nil
}
@@ -367,7 +360,7 @@
fg.AddFlow(fs)
deviceRules.AddFlowsAndGroup(ingressHop.DeviceID, fg)
} else { // Create standard flow
- log.Debugw("creating-standard-flow", log.Fields{"flow": flow})
+ logger.Debugw("creating-standard-flow", log.Fields{"flow": flow})
fa := &fu.FlowArgs{
KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata},
MatchFields: []*ofp.OfpOxmOfbField{
@@ -398,7 +391,7 @@
func (fd *FlowDecomposer) processUnicastFlow(ctx context.Context, path []route.Hop,
inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats) (*fu.DeviceRules, error) {
- log.Debugw("decomposing-onu-flow-in-downstream-unicast-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo})
+ logger.Debugw("decomposing-onu-flow-in-downstream-unicast-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo})
deviceRules := fu.NewDeviceRules()
egressHop := path[1]
@@ -434,18 +427,18 @@
inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats, grpID uint32,
groupMap map[uint32]*ofp.OfpGroupEntry) *fu.DeviceRules {
- log.Debugw("multicast-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo})
+ logger.Debugw("multicast-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo})
deviceRules := fu.NewDeviceRules()
//having no Group yet is the same as having a Group with no buckets
var grp *ofp.OfpGroupEntry
var ok bool
if grp, ok = groupMap[grpID]; !ok {
- log.Warnw("Group-id-not-present-in-map", log.Fields{"grpId": grpID, "groupMap": groupMap})
+ logger.Warnw("Group-id-not-present-in-map", log.Fields{"grpId": grpID, "groupMap": groupMap})
return deviceRules
}
if grp == nil || grp.Desc == nil {
- log.Warnw("Group-or-desc-nil", log.Fields{"grpId": grpID, "grp": grp})
+ logger.Warnw("Group-or-desc-nil", log.Fields{"grpId": grpID, "grp": grp})
return deviceRules
}
@@ -468,14 +461,14 @@
nniPorts := agent.GetNNIPorts()
if len(nniPorts) > 0 {
inPortNo = nniPorts[0]
- log.Debugw("assigning-nni-port-as-in-port-for-multicast-flow", log.Fields{"nni": nniPorts[0], "flow:": flow})
+ logger.Debugw("assigning-nni-port-as-in-port-for-multicast-flow", log.Fields{"nni": nniPorts[0], "flow:": flow})
}
}
outPortNo := fu.GetOutPort(flow)
deviceRules := fu.NewDeviceRules()
path, err := agent.GetRoute(ctx, inPortNo, outPortNo)
if err != nil {
- log.Errorw("no-route", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo, "error": err})
+ logger.Errorw("no-route", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo, "error": err})
return deviceRules, err
}
@@ -483,7 +476,7 @@
case 0:
return deviceRules, status.Errorf(codes.FailedPrecondition, "no route from:%d to:%d", inPortNo, outPortNo)
case 2:
- log.Debugw("route-found", log.Fields{"ingressHop": path[0], "egressHop": path[1]})
+ logger.Debugw("route-found", log.Fields{"ingressHop": path[0], "egressHop": path[1]})
default:
return deviceRules, status.Errorf(codes.Aborted, "invalid route length %d", len(path))
}
@@ -502,25 +495,25 @@
}
isUpstream := !ingressDevice.Root
if isUpstream { // Unicast OLT and ONU UL
- log.Debug("process-olt-nd-onu-upstream-noncontrollerbound-unicast-flows", log.Fields{"flows": flow})
+ logger.Debug("process-olt-nd-onu-upstream-noncontrollerbound-unicast-flows", log.Fields{"flows": flow})
deviceRules, err = fd.processUpstreamNonControllerBoundFlow(ctx, path, inPortNo, outPortNo, flow)
if err != nil {
return nil, err
}
} else if fu.HasNextTable(flow) && flow.TableId == 0 { // Unicast OLT flow DL
- log.Debugw("process-olt-downstream-noncontrollerbound-flow-with-nexttable", log.Fields{"flows": flow})
+ logger.Debugw("process-olt-downstream-noncontrollerbound-flow-with-nexttable", log.Fields{"flows": flow})
deviceRules, err = fd.processDownstreamFlowWithNextTable(ctx, agent, path, inPortNo, outPortNo, flow)
if err != nil {
return nil, err
}
} else if flow.TableId == 1 && outPortNo != 0 { // Unicast ONU flow DL
- log.Debugw("process-onu-downstream-unicast-flow", log.Fields{"flows": flow})
+ logger.Debugw("process-onu-downstream-unicast-flow", log.Fields{"flows": flow})
deviceRules, err = fd.processUnicastFlow(ctx, path, inPortNo, outPortNo, flow)
if err != nil {
return nil, err
}
} else if grpID := fu.GetGroup(flow); grpID != 0 && flow.TableId == 0 { //Multicast
- log.Debugw("process-multicast-flow", log.Fields{"flows": flow})
+ logger.Debugw("process-multicast-flow", log.Fields{"flows": flow})
deviceRules = fd.processMulticastFlow(ctx, path, inPortNo, outPortNo, flow, grpID, groupMap)
} else {
return deviceRules, status.Errorf(codes.Aborted, "unknown downstream flow %v", *flow)
diff --git a/rw_core/flowdecomposition/flow_decomposer_test.go b/rw_core/flowdecomposition/flow_decomposer_test.go
index 002c3a2..0b18e6e 100644
--- a/rw_core/flowdecomposition/flow_decomposer_test.go
+++ b/rw_core/flowdecomposition/flow_decomposer_test.go
@@ -891,7 +891,7 @@
}
func TestUnicastDownstreamRuleDecomposition(t *testing.T) {
- log.Debugf("Starting Test Unicast Downstream")
+ logger.Debugf("Starting Test Unicast Downstream")
fa1 := &fu.FlowArgs{
KV: fu.OfpFlowModArgs{"priority": 500, "table_id": 0},
MatchFields: []*ofp.OfpOxmOfbField{
diff --git a/rw_core/main.go b/rw_core/main.go
index 2cc5240..7c87e2d 100644
--- a/rw_core/main.go
+++ b/rw_core/main.go
@@ -50,16 +50,9 @@
receiverChannels []<-chan *ic.InterContainerMessage
}
-func init() {
- _, err := log.AddPackage(log.JSON, log.DebugLevel, nil)
- if err != nil {
- log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
- }
-}
-
func newKVClient(storeType string, address string, timeout int) (kvstore.Client, error) {
- log.Infow("kv-store-type", log.Fields{"store": storeType})
+ logger.Infow("kv-store-type", log.Fields{"store": storeType})
switch storeType {
case "consul":
return kvstore.NewConsulClient(address, timeout)
@@ -71,7 +64,7 @@
func newKafkaClient(clientType string, host string, port int, instanceID string, livenessChannelInterval time.Duration) (kafka.Client, error) {
- log.Infow("kafka-client-type", log.Fields{"client": clientType})
+ logger.Infow("kafka-client-type", log.Fields{"client": clientType})
switch clientType {
case "sarama":
return kafka.NewSaramaClient(
@@ -103,16 +96,16 @@
}
func (rw *rwCore) start(ctx context.Context, instanceID string) {
- log.Info("Starting RW Core components")
+ logger.Info("Starting RW Core components")
// Setup KV Client
- log.Debugw("create-kv-client", log.Fields{"kvstore": rw.config.KVStoreType})
+ logger.Debugw("create-kv-client", log.Fields{"kvstore": rw.config.KVStoreType})
var err error
if rw.kvClient, err = newKVClient(
rw.config.KVStoreType,
rw.config.KVStoreHost+":"+strconv.Itoa(rw.config.KVStorePort),
rw.config.KVStoreTimeout); err != nil {
- log.Fatal(err)
+ logger.Fatal(err)
}
cm := conf.NewConfigManager(rw.kvClient, rw.config.KVStoreType, rw.config.KVStoreHost, rw.config.KVStorePort, rw.config.KVStoreTimeout)
go conf.StartLogLevelConfigProcessing(cm, ctx)
@@ -122,7 +115,7 @@
rw.config.KVStoreDataPrefix+"/transactions/",
rw.kvClient,
rw.config.KVStoreTimeout); err != nil {
- log.Fatal("creating-transaction-context-failed")
+ logger.Fatal("creating-transaction-context-failed")
}
// Setup Kafka Client
@@ -131,7 +124,7 @@
rw.config.KafkaAdapterPort,
instanceID,
rw.config.LiveProbeInterval/2); err != nil {
- log.Fatal("Unsupported-kafka-client")
+ logger.Fatal("Unsupported-kafka-client")
}
// Create the core service
@@ -140,7 +133,7 @@
// start the core
err = rw.core.Start(ctx)
if err != nil {
- log.Fatalf("failed-to-start-rwcore", log.Fields{"error": err})
+ logger.Fatalf("failed-to-start-rwcore", log.Fields{"error": err})
}
}
@@ -155,7 +148,7 @@
if rw.kvClient != nil {
// Release all reservations
if err := rw.kvClient.ReleaseAllReservations(ctx); err != nil {
- log.Infow("fail-to-release-all-reservations", log.Fields{"error": err})
+ logger.Infow("fail-to-release-all-reservations", log.Fields{"error": err})
}
// Close the DB connection
rw.kvClient.Close()
@@ -185,10 +178,10 @@
syscall.SIGINT,
syscall.SIGTERM,
syscall.SIGQUIT:
- log.Infow("closing-signal-received", log.Fields{"signal": s})
+ logger.Infow("closing-signal-received", log.Fields{"signal": s})
exitChannel <- 0
default:
- log.Infow("unexpected-signal-received", log.Fields{"signal": s})
+ logger.Infow("unexpected-signal-received", log.Fields{"signal": s})
exitChannel <- 1
}
}()
@@ -224,7 +217,7 @@
if len(hostName) > 0 {
instanceID = hostName
} else {
- log.Fatal("HOSTNAME not set")
+ logger.Fatal("HOSTNAME not set")
}
realMain()
@@ -236,12 +229,12 @@
//Setup default logger - applies for packages that do not have specific logger set
if _, err := log.SetDefaultLogger(log.JSON, logLevel, log.Fields{"instanceId": instanceID}); err != nil {
- log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
+ logger.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
}
// Update all loggers (provisioned via init) with a common field
if err := log.UpdateAllLoggers(log.Fields{"instanceId": instanceID}); err != nil {
- log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
+ logger.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
}
// Update all loggers to log level specified as input parameter
@@ -252,7 +245,7 @@
defer func() {
err := log.CleanUp()
if err != nil {
- log.Errorw("unable-to-flush-any-buffered-log-entries", log.Fields{"error": err})
+ logger.Errorw("unable-to-flush-any-buffered-log-entries", log.Fields{"error": err})
}
}()
@@ -267,7 +260,7 @@
printBanner()
}
- log.Infow("rw-core-config", log.Fields{"config": *cf})
+ logger.Infow("rw-core-config", log.Fields{"config": *cf})
// Create the core
rw := newRWCore(cf)
@@ -291,11 +284,11 @@
go rw.start(probeCtx, instanceID)
code := waitForExit()
- log.Infow("received-a-closing-signal", log.Fields{"code": code})
+ logger.Infow("received-a-closing-signal", log.Fields{"code": code})
// Cleanup before leaving
rw.stop(probeCtx)
elapsed := time.Since(start)
- log.Infow("rw-core-run-time", log.Fields{"core": instanceID, "time": elapsed / time.Second})
+ logger.Infow("rw-core-run-time", log.Fields{"core": instanceID, "time": elapsed / time.Second})
}
diff --git a/rw_core/mocks/adapter_olt.go b/rw_core/mocks/adapter_olt.go
index 46f0e28..4d58f00 100644
--- a/rw_core/mocks/adapter_olt.go
+++ b/rw_core/mocks/adapter_olt.go
@@ -64,7 +64,7 @@
d.MacAddress = strings.ToUpper(com.GetRandomMacAddress())
oltA.storeDevice(d)
if res := oltA.coreProxy.DeviceUpdate(context.TODO(), d); res != nil {
- log.Fatalf("deviceUpdate-failed-%s", res)
+ logger.Fatalf("deviceUpdate-failed-%s", res)
}
nniPort := &voltha.Port{
PortNo: 2,
@@ -74,7 +74,7 @@
}
var err error
if err = oltA.coreProxy.PortCreated(context.TODO(), d.Id, nniPort); err != nil {
- log.Fatalf("PortCreated-failed-%s", err)
+ logger.Fatalf("PortCreated-failed-%s", err)
}
ponPort := &voltha.Port{
@@ -84,23 +84,23 @@
OperStatus: voltha.OperStatus_ACTIVE,
}
if err = oltA.coreProxy.PortCreated(context.TODO(), d.Id, ponPort); err != nil {
- log.Fatalf("PortCreated-failed-%s", err)
+ logger.Fatalf("PortCreated-failed-%s", err)
}
d.ConnectStatus = voltha.ConnectStatus_REACHABLE
d.OperStatus = voltha.OperStatus_ACTIVE
if err = oltA.coreProxy.DeviceStateUpdate(context.TODO(), d.Id, d.ConnectStatus, d.OperStatus); err != nil {
- log.Fatalf("Device-state-update-failed-%s", err)
+ logger.Fatalf("Device-state-update-failed-%s", err)
}
//Get the latest device data from the Core
if d, err = oltA.coreProxy.GetDevice(context.TODO(), d.Id, d.Id); err != nil {
- log.Fatalf("getting-device-failed-%s", err)
+ logger.Fatalf("getting-device-failed-%s", err)
}
if err = oltA.updateDevice(d); err != nil {
- log.Fatalf("saving-device-failed-%s", err)
+ logger.Fatalf("saving-device-failed-%s", err)
}
// Register Child devices
@@ -116,7 +116,7 @@
"onu_adapter_mock",
com.GetRandomSerialNumber(),
int64(seqNo)); err != nil {
- log.Fatalf("failure-sending-child-device-%s", err)
+ logger.Fatalf("failure-sending-child-device-%s", err)
}
}(i)
}
@@ -127,7 +127,7 @@
// Get_ofp_device_info returns ofp device info
func (oltA *OLTAdapter) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) { // nolint
if d := oltA.getDevice(device.Id); d == nil {
- log.Fatalf("device-not-found-%s", device.Id)
+ logger.Fatalf("device-not-found-%s", device.Id)
}
return &ic.SwitchCapability{
Desc: &of.OfpDesc{
@@ -149,7 +149,7 @@
// Get_ofp_port_info returns ofp port info
func (oltA *OLTAdapter) Get_ofp_port_info(device *voltha.Device, portNo int64) (*ic.PortCapability, error) { // nolint
if d := oltA.getDevice(device.Id); d == nil {
- log.Fatalf("device-not-found-%s", device.Id)
+ logger.Fatalf("device-not-found-%s", device.Id)
}
capability := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
return &ic.PortCapability{
@@ -184,13 +184,13 @@
func (oltA *OLTAdapter) Disable_device(device *voltha.Device) error { // nolint
go func() {
if d := oltA.getDevice(device.Id); d == nil {
- log.Fatalf("device-not-found-%s", device.Id)
+ logger.Fatalf("device-not-found-%s", device.Id)
}
cloned := proto.Clone(device).(*voltha.Device)
// Update the all ports state on that device to disable
if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_UNKNOWN); err != nil {
- log.Warnw("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+ logger.Warnw("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
}
//Update the device operational state
@@ -199,18 +199,18 @@
if err := oltA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
// Device may already have been deleted in the core
- log.Warnw("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
+ logger.Warnw("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
return
}
if err := oltA.updateDevice(cloned); err != nil {
- log.Fatalf("saving-device-failed-%s", err)
+ logger.Fatalf("saving-device-failed-%s", err)
}
// Tell the Core that all child devices have been disabled (by default it's an action already taken by the Core
if err := oltA.coreProxy.ChildDevicesLost(context.TODO(), cloned.Id); err != nil {
// Device may already have been deleted in the core
- log.Warnw("lost-notif-of-child-devices-failed", log.Fields{"deviceId": device.Id, "error": err})
+ logger.Warnw("lost-notif-of-child-devices-failed", log.Fields{"deviceId": device.Id, "error": err})
}
}()
return nil
@@ -220,25 +220,25 @@
func (oltA *OLTAdapter) Reenable_device(device *voltha.Device) error { // nolint
go func() {
if d := oltA.getDevice(device.Id); d == nil {
- log.Fatalf("device-not-found-%s", device.Id)
+ logger.Fatalf("device-not-found-%s", device.Id)
}
cloned := proto.Clone(device).(*voltha.Device)
// Update the all ports state on that device to enable
if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_ACTIVE); err != nil {
- log.Fatalf("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+ logger.Fatalf("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
}
//Update the device state
cloned.OperStatus = voltha.OperStatus_ACTIVE
if err := oltA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
- log.Fatalf("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
+ logger.Fatalf("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
}
// Tell the Core that all child devices have been enabled
if err := oltA.coreProxy.ChildDevicesDetected(context.TODO(), cloned.Id); err != nil {
- log.Fatalf("detection-notif-of-child-devices-failed", log.Fields{"deviceId": device.Id, "error": err})
+ logger.Fatalf("detection-notif-of-child-devices-failed", log.Fields{"deviceId": device.Id, "error": err})
}
}()
return nil
@@ -250,7 +250,7 @@
if Port.Type == voltha.Port_PON_OLT {
if err := oltA.coreProxy.PortStateUpdate(context.TODO(), deviceId, voltha.Port_PON_OLT, Port.PortNo, voltha.OperStatus_ACTIVE); err != nil {
- log.Fatalf("updating-ports-failed", log.Fields{"device-id": deviceId, "error": err})
+ logger.Fatalf("updating-ports-failed", log.Fields{"device-id": deviceId, "error": err})
}
}
@@ -265,7 +265,7 @@
if Port.Type == voltha.Port_PON_OLT {
if err := oltA.coreProxy.PortStateUpdate(context.TODO(), deviceId, voltha.Port_PON_OLT, Port.PortNo, voltha.OperStatus_DISCOVERED); err != nil {
// Corresponding device may have been deleted
- log.Warnw("updating-ports-failed", log.Fields{"device-id": deviceId, "error": err})
+ logger.Warnw("updating-ports-failed", log.Fields{"device-id": deviceId, "error": err})
}
}
}()
@@ -297,14 +297,14 @@
// Reboot_device -
func (oltA *OLTAdapter) Reboot_device(device *voltha.Device) error { // nolint
- log.Infow("reboot-device", log.Fields{"deviceId": device.Id})
+ logger.Infow("reboot-device", log.Fields{"deviceId": device.Id})
go func() {
if err := oltA.coreProxy.DeviceStateUpdate(context.TODO(), device.Id, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN); err != nil {
- log.Fatalf("device-state-update-failed", log.Fields{"device-id": device.Id})
+ logger.Fatalf("device-state-update-failed", log.Fields{"device-id": device.Id})
}
if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), device.Id, voltha.OperStatus_UNKNOWN); err != nil {
- log.Fatalf("port-update-failed", log.Fields{"device-id": device.Id})
+ logger.Fatalf("port-update-failed", log.Fields{"device-id": device.Id})
}
}()
return nil
diff --git a/rw_core/mocks/adapter_onu.go b/rw_core/mocks/adapter_onu.go
index c31cb93..92dff06 100644
--- a/rw_core/mocks/adapter_onu.go
+++ b/rw_core/mocks/adapter_onu.go
@@ -59,14 +59,14 @@
d.MacAddress = strings.ToUpper(com.GetRandomMacAddress())
onuA.storeDevice(d)
if res := onuA.coreProxy.DeviceUpdate(context.TODO(), d); res != nil {
- log.Fatalf("deviceUpdate-failed-%s", res)
+ logger.Fatalf("deviceUpdate-failed-%s", res)
}
d.ConnectStatus = voltha.ConnectStatus_REACHABLE
d.OperStatus = voltha.OperStatus_DISCOVERED
if err := onuA.coreProxy.DeviceStateUpdate(context.TODO(), d.Id, d.ConnectStatus, d.OperStatus); err != nil {
- log.Fatalf("device-state-update-failed-%s", err)
+ logger.Fatalf("device-state-update-failed-%s", err)
}
uniPortNo := uint32(2)
@@ -84,7 +84,7 @@
}
var err error
if err = onuA.coreProxy.PortCreated(context.TODO(), d.Id, uniPort); err != nil {
- log.Fatalf("PortCreated-failed-%s", err)
+ logger.Fatalf("PortCreated-failed-%s", err)
}
ponPortNo := uint32(1)
@@ -101,22 +101,22 @@
PortNo: device.ParentPortNo}}, // Peer port is parent's port number
}
if err = onuA.coreProxy.PortCreated(context.TODO(), d.Id, ponPort); err != nil {
- log.Fatalf("PortCreated-failed-%s", err)
+ logger.Fatalf("PortCreated-failed-%s", err)
}
d.ConnectStatus = voltha.ConnectStatus_REACHABLE
d.OperStatus = voltha.OperStatus_ACTIVE
if err = onuA.coreProxy.DeviceStateUpdate(context.TODO(), d.Id, d.ConnectStatus, d.OperStatus); err != nil {
- log.Fatalf("device-state-update-failed-%s", err)
+ logger.Fatalf("device-state-update-failed-%s", err)
}
//Get the latest device data from the Core
if d, err = onuA.coreProxy.GetDevice(context.TODO(), d.Id, d.Id); err != nil {
- log.Fatalf("getting-device-failed-%s", err)
+ logger.Fatalf("getting-device-failed-%s", err)
}
if err = onuA.updateDevice(d); err != nil {
- log.Fatalf("saving-device-failed-%s", err)
+ logger.Fatalf("saving-device-failed-%s", err)
}
}()
return nil
@@ -125,7 +125,7 @@
// Get_ofp_port_info returns ofp device info
func (onuA *ONUAdapter) Get_ofp_port_info(device *voltha.Device, portNo int64) (*ic.PortCapability, error) { // nolint
if d := onuA.getDevice(device.Id); d == nil {
- log.Fatalf("device-not-found-%s", device.Id)
+ logger.Fatalf("device-not-found-%s", device.Id)
}
capability := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
return &ic.PortCapability{
@@ -150,13 +150,13 @@
func (onuA *ONUAdapter) Disable_device(device *voltha.Device) error { // nolint
go func() {
if d := onuA.getDevice(device.Id); d == nil {
- log.Fatalf("device-not-found-%s", device.Id)
+ logger.Fatalf("device-not-found-%s", device.Id)
}
cloned := proto.Clone(device).(*voltha.Device)
// Update the all ports state on that device to disable
if err := onuA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_UNKNOWN); err != nil {
// Device may also have been deleted in the Core
- log.Warnw("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+ logger.Warnw("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
return
}
//Update the device state
@@ -164,11 +164,11 @@
cloned.OperStatus = voltha.OperStatus_UNKNOWN
if err := onuA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
- log.Warnw("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
+ logger.Warnw("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
return
}
if err := onuA.updateDevice(cloned); err != nil {
- log.Fatalf("saving-device-failed-%s", err)
+ logger.Fatalf("saving-device-failed-%s", err)
}
}()
return nil
@@ -178,13 +178,13 @@
func (onuA *ONUAdapter) Reenable_device(device *voltha.Device) error { // nolint
go func() {
if d := onuA.getDevice(device.Id); d == nil {
- log.Fatalf("device-not-found-%s", device.Id)
+ logger.Fatalf("device-not-found-%s", device.Id)
}
cloned := proto.Clone(device).(*voltha.Device)
// Update the all ports state on that device to enable
if err := onuA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_ACTIVE); err != nil {
- log.Fatalf("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+ logger.Fatalf("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
}
//Update the device state
@@ -192,10 +192,10 @@
cloned.OperStatus = voltha.OperStatus_ACTIVE
if err := onuA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
- log.Fatalf("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
+ logger.Fatalf("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
}
if err := onuA.updateDevice(cloned); err != nil {
- log.Fatalf("saving-device-failed-%s", err)
+ logger.Fatalf("saving-device-failed-%s", err)
}
}()
return nil
diff --git a/rw_core/mocks/common_test.go b/rw_core/mocks/common.go
similarity index 73%
rename from rw_core/mocks/common_test.go
rename to rw_core/mocks/common.go
index eb1534f..3b2df29 100644
--- a/rw_core/mocks/common_test.go
+++ b/rw_core/mocks/common.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2019-present Open Networking Foundation
+ * Copyright 2020-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.
@@ -13,21 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+// Package mocks Common Logger initialization
package mocks
import (
"github.com/opencord/voltha-lib-go/v3/pkg/log"
)
-const (
- logLevel = log.FatalLevel
-)
+var logger log.Logger
-// Unit test initialization. This init() function handles all unit tests in
-// the current directory.
func init() {
// Setup this package so that it's log level can be modified at run time
- _, err := log.AddPackage(log.JSON, logLevel, log.Fields{"instanceId": "mocks"})
+ var err error
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "mocks"})
if err != nil {
panic(err)
}
diff --git a/rw_core/profile.go b/rw_core/profile.go
index 9b955b0..bce0af9 100644
--- a/rw_core/profile.go
+++ b/rw_core/profile.go
@@ -26,7 +26,7 @@
func realMain() {
go func() {
- log.Infoln(http.ListenAndServe("0.0.0.0:6060", nil))
+ logger.Infoln(http.ListenAndServe("0.0.0.0:6060", nil))
}()
}
diff --git a/rw_core/release.go b/rw_core/release.go
index 46750e2..67f8187 100644
--- a/rw_core/release.go
+++ b/rw_core/release.go
@@ -18,10 +18,6 @@
package main
-import (
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
-)
-
func realMain() {
- log.Infoln("NOT PROFILING")
+ logger.Infoln("NOT PROFILING")
}
diff --git a/rw_core/mocks/common_test.go b/rw_core/route/common.go
similarity index 71%
copy from rw_core/mocks/common_test.go
copy to rw_core/route/common.go
index eb1534f..e47f8c9 100644
--- a/rw_core/mocks/common_test.go
+++ b/rw_core/route/common.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2019-present Open Networking Foundation
+ * Copyright 2020-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.
@@ -13,21 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package mocks
+
+// Package route Common Logger initialization
+package route
import (
"github.com/opencord/voltha-lib-go/v3/pkg/log"
)
-const (
- logLevel = log.FatalLevel
-)
+var logger log.Logger
-// Unit test initialization. This init() function handles all unit tests in
-// the current directory.
func init() {
// Setup this package so that it's log level can be modified at run time
- _, err := log.AddPackage(log.JSON, logLevel, log.Fields{"instanceId": "mocks"})
+ var err error
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "route"})
if err != nil {
panic(err)
}
diff --git a/rw_core/route/device_route.go b/rw_core/route/device_route.go
index c22ff2a..a36c841 100644
--- a/rw_core/route/device_route.go
+++ b/rw_core/route/device_route.go
@@ -26,13 +26,6 @@
"sync"
)
-func init() {
- _, err := log.AddPackage(log.JSON, log.WarnLevel, nil)
- if err != nil {
- log.Fatalw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
- }
-}
-
// Hop represent a route hop
type Hop struct {
DeviceID string
@@ -75,7 +68,7 @@
dr.RootPorts = make(map[uint32]uint32)
dr.Routes = make(map[PathID][]Hop)
dr.devicesPonPorts = make(map[string][]*voltha.Port)
- log.Debug("new device routes created ...")
+ logger.Debug("new device routes created ...")
return &dr
}
@@ -92,7 +85,7 @@
dr.routeBuildLock.Lock()
defer dr.routeBuildLock.Unlock()
- log.Debugw("computing-all-routes", log.Fields{"len-logical-ports": len(lps)})
+ logger.Debugw("computing-all-routes", log.Fields{"len-logical-ports": len(lps)})
var err error
defer func() {
// On error, clear the routes - any flow request or a port add/delete will trigger the rebuild
@@ -143,7 +136,7 @@
}
for _, rootDevicePort := range rootDevice.Ports {
if rootDevicePort.Type == voltha.Port_PON_OLT {
- log.Debugw("peers", log.Fields{"root-device-id": rootDevice.Id, "port-no": rootDevicePort.PortNo, "len-peers": len(rootDevicePort.Peers)})
+ logger.Debugw("peers", log.Fields{"root-device-id": rootDevice.Id, "port-no": rootDevicePort.PortNo, "len-peers": len(rootDevicePort.Peers)})
for _, rootDevicePeer := range rootDevicePort.Peers {
childDevice, err = dr.getDevice(ctx, rootDevicePeer.DeviceId)
if err != nil {
@@ -206,7 +199,7 @@
// AddPort augments the current set of routes with new routes corresponding to the logical port "lp". If the routes have
// not been built yet then use logical port "lps" to compute all current routes (lps includes lp)
func (dr *DeviceRoutes) AddPort(ctx context.Context, lp *voltha.LogicalPort, lps []*voltha.LogicalPort) error {
- log.Debugw("add-port-to-routes", log.Fields{"port": lp, "len-logical-ports": len(lps)})
+ logger.Debugw("add-port-to-routes", log.Fields{"port": lp, "len-logical-ports": len(lps)})
dr.routeBuildLock.Lock()
if len(dr.Routes) == 0 {
@@ -280,8 +273,8 @@
// Print prints routes
func (dr *DeviceRoutes) Print() error {
- log.Debugw("Print", log.Fields{"logical-device-id": dr.logicalDeviceID, "logical-ports": dr.logicalPorts})
- if log.V(log.DebugLevel) {
+ logger.Debugw("Print", log.Fields{"logical-device-id": dr.logicalDeviceID, "logical-ports": dr.logicalPorts})
+ if logger.V(log.DebugLevel) {
output := ""
routeNumber := 1
for k, v := range dr.Routes {
@@ -295,9 +288,9 @@
routeNumber++
}
if len(dr.Routes) == 0 {
- log.Debugw("no-routes-found", log.Fields{"logical-device-id": dr.logicalDeviceID})
+ logger.Debugw("no-routes-found", log.Fields{"logical-device-id": dr.logicalDeviceID})
} else {
- log.Debugw("graph_routes", log.Fields{"lDeviceId": dr.logicalDeviceID, "Routes": output})
+ logger.Debugw("graph_routes", log.Fields{"lDeviceId": dr.logicalDeviceID, "Routes": output})
}
}
return nil
@@ -342,7 +335,7 @@
func (dr *DeviceRoutes) getDevice(ctx context.Context, deviceID string) (*voltha.Device, error) {
device, err := dr.getDeviceFromModel(ctx, deviceID)
if err != nil {
- log.Errorw("device-not-found", log.Fields{"deviceId": deviceID, "error": err})
+ logger.Errorw("device-not-found", log.Fields{"deviceId": deviceID, "error": err})
return nil, err
}
dr.devicesPonPortsLock.Lock()
diff --git a/rw_core/mocks/common_test.go b/rw_core/utils/common.go
similarity index 71%
copy from rw_core/mocks/common_test.go
copy to rw_core/utils/common.go
index eb1534f..679788f 100644
--- a/rw_core/mocks/common_test.go
+++ b/rw_core/utils/common.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2019-present Open Networking Foundation
+ * Copyright 2020-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.
@@ -13,21 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package mocks
+
+// Package utils common Logger initialization
+package utils
import (
"github.com/opencord/voltha-lib-go/v3/pkg/log"
)
-const (
- logLevel = log.FatalLevel
-)
+var logger log.Logger
-// Unit test initialization. This init() function handles all unit tests in
-// the current directory.
func init() {
// Setup this package so that it's log level can be modified at run time
- _, err := log.AddPackage(log.JSON, logLevel, log.Fields{"instanceId": "mocks"})
+ var err error
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "utils"})
if err != nil {
panic(err)
}
diff --git a/rw_core/utils/core_utils.go b/rw_core/utils/core_utils.go
index bffd9c4..1030735 100644
--- a/rw_core/utils/core_utils.go
+++ b/rw_core/utils/core_utils.go
@@ -83,7 +83,7 @@
for {
req, ok := <-rq.queue
if !ok {
- log.Warnw("request-sequencer-queue-closed", log.Fields{"id": rq.queueID})
+ logger.Warnw("request-sequencer-queue-closed", log.Fields{"id": rq.queueID})
break
}
// If the request is waiting then closing the reqChnl will trigger the request to proceed. Otherwise,
diff --git a/rw_core/utils/core_utils_test.go b/rw_core/utils/core_utils_test.go
index 0457606..e55b38c 100644
--- a/rw_core/utils/core_utils_test.go
+++ b/rw_core/utils/core_utils_test.go
@@ -20,7 +20,6 @@
"testing"
"time"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@@ -32,10 +31,6 @@
)
func init() {
- _, err := log.AddPackage(log.JSON, log.WarnLevel, nil)
- if err != nil {
- log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
- }
timeoutError = status.Errorf(codes.Aborted, "timeout")
taskFailureError = status.Error(codes.Internal, "test failure task")
}