Logging improvement for VGC-ONOS-NBI
Change-Id: I08f41ce4b5895ce5facb9419085c9587c7168ccd
diff --git a/voltha-go-controller/onos_nbi/deviceconfig.go b/voltha-go-controller/onos_nbi/deviceconfig.go
index 709ba44..03e64bb 100644
--- a/voltha-go-controller/onos_nbi/deviceconfig.go
+++ b/voltha-go-controller/onos_nbi/deviceconfig.go
@@ -58,30 +58,32 @@
// Get the payload to process the request
d := new(bytes.Buffer)
if _, err := d.ReadFrom(r.Body); err != nil {
- logger.Warnw(ctx, "Error reading buffer", log.Fields{"Reason": err.Error()})
+ logger.Errorw(ctx, "Error reading buffer", log.Fields{"Reason": err.Error()})
+ http.Error(w, err.Error(), http.StatusConflict)
return
}
// Unmarshal the request into device configuration structure
req := &app.DeviceConfig{}
if err := json.Unmarshal(d.Bytes(), req); err != nil {
- logger.Warnw(ctx, "Unmarshal Failed", log.Fields{"Reason": err.Error()})
+ logger.Errorw(ctx, "Unmarshal Failed", log.Fields{"Reason": err.Error()})
http.Error(w, err.Error(), http.StatusConflict)
return
}
app.GetApplication().UpdateDeviceConfig(cntx, req)
+ logger.Debugw(ctx, "Added Device Config ", log.Fields{"Req": req})
}
func (oh *DeviceConfigHandle) FetchDeviceConfig(cntx context.Context, w http.ResponseWriter, r *http.Request) {
- logger.Info(cntx, "Inside FetchDeviceConfig method")
vars := mux.Vars(r)
serialNum := vars["serialNumber"]
+ logger.Infow(cntx, "Inside FetchDeviceConfig method", log.Fields{"serialNum": serialNum})
deviceInfo := DeviceConfigPayload{}
dc := app.GetApplication().GetDeviceConfig(serialNum)
if dc != nil {
deviceInfo.DeviceConfig = dc
oltInfoJSON, err := json.Marshal(deviceInfo)
if err != nil {
- logger.Errorw(ctx, "Failed to marshal olt payload response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Failed to marshal olt payload response", log.Fields{"deviceInfo": deviceInfo, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -89,8 +91,9 @@
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(oltInfoJSON)
if err != nil {
- logger.Errorw(ctx, "Failed to write olt payload response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Failed to write olt payload response", log.Fields{"deviceInfo": deviceInfo, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
} else {
logger.Warnw(ctx, "Device not found", log.Fields{"serialNum": serialNum})
diff --git a/voltha-go-controller/onos_nbi/deviceportadapter.go b/voltha-go-controller/onos_nbi/deviceportadapter.go
index c27737e..5feba61 100644
--- a/voltha-go-controller/onos_nbi/deviceportadapter.go
+++ b/voltha-go-controller/onos_nbi/deviceportadapter.go
@@ -63,7 +63,7 @@
deviceListJSON, err := json.Marshal(deviceListResp)
if err != nil {
- logger.Errorw(ctx, "Error occurred while marshaling device list response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Error occurred while marshaling device list response", log.Fields{"DeviceListResp": deviceListResp, "Error": err.Error()})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -71,9 +71,11 @@
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(deviceListJSON)
if err != nil {
- logger.Errorw(ctx, "error in sending deviceList response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "error in sending deviceList response", log.Fields{"DeviceListResp": deviceListResp, "Error": err.Error()})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(ctx, "Fetching Device List Resp", log.Fields{"DeviceListResp": deviceListResp})
}
// ServeHTTP to serve HTTP requests
@@ -106,6 +108,7 @@
func (dh *DevicePortHandle) GetPortListPerDevice(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
deviceID := vars["olt_of_id"]
+ logger.Infow(ctx, "Received Get Port List request for device", log.Fields{"deviceID": deviceID})
var devicePortListResp DevicePortEntry
devicePortListResp.Device = Device{}
@@ -118,17 +121,16 @@
return true
}
if len(deviceID) > 0 {
- logger.Infow(ctx, "Received Port get request for device", log.Fields{"deviceID": deviceID})
voltDevice := app.GetApplication().GetDevice(deviceID)
if voltDevice != nil {
- logger.Infow(ctx, "Found device", log.Fields{"deviceID": deviceID})
+ logger.Debugw(ctx, "Fetch volt device from voltApplication", log.Fields{"voltDevice": voltDevice})
devicePortListResp.Device = convertVoltDeviceToDevice(voltDevice)
voltDevice.Ports.Range(getPortList)
}
}
portListJSON, err := json.Marshal(devicePortListResp)
if err != nil {
- logger.Errorw(ctx, "Error occurred while marshaling port list response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Error occurred while marshaling port list response", log.Fields{"DevicePortListResp": devicePortListResp, "Error": err.Error()})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -136,9 +138,11 @@
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(portListJSON)
if err != nil {
- logger.Errorw(ctx, "error in sending portList response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Error in sending portList response", log.Fields{"DevicePortListResp": devicePortListResp, "Error": err.Error()})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(ctx, "Fetching Port List for device", log.Fields{"devicePortListResp": devicePortListResp, "deviceID": deviceID})
}
// GetPortList to get device id list
@@ -146,6 +150,7 @@
va := app.GetApplication()
var portListResp PortEntry
portListResp.Ports = []Port{}
+ logger.Debug(ctx, "Received Get Port List")
getPortList := func(key, value interface{}) bool {
voltPort := value.(*app.VoltPort)
@@ -163,7 +168,7 @@
portListJSON, err := json.Marshal(portListResp)
if err != nil {
- logger.Errorw(ctx, "Error occurred while marshaling port list response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Error occurred while marshaling port list response", log.Fields{"PortListResp": portListResp, "Error": err.Error()})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -171,7 +176,9 @@
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(portListJSON)
if err != nil {
- logger.Errorw(ctx, "error in sending portList response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "error in sending portList response", log.Fields{"PortListResp": portListResp, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(ctx, "Fetching Port List ", log.Fields{"PortListResp": portListResp})
}
diff --git a/voltha-go-controller/onos_nbi/dhcprelayadapter.go b/voltha-go-controller/onos_nbi/dhcprelayadapter.go
index 7c30351..172e4aa 100644
--- a/voltha-go-controller/onos_nbi/dhcprelayadapter.go
+++ b/voltha-go-controller/onos_nbi/dhcprelayadapter.go
@@ -60,16 +60,17 @@
func (dh *DhcpRelayHandle) GetAllocations(cntx context.Context, w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
deviceID := vars[DeviceID]
+ logger.Debugw(ctx, "Received Get DhcpAllocation info for device ID", log.Fields{"deviceID": deviceID})
Allocations, err := app.GetApplication().GetAllocations(cntx, deviceID)
if err != nil {
- logger.Errorw(ctx, "Failed to get dhcp allocations", log.Fields{"Reason": err.Error()})
+ logger.Errorw(ctx, "Failed to get dhcp allocations", log.Fields{"deviceID": deviceID, "Reason": err.Error()})
w.WriteHeader(http.StatusInternalServerError)
return
}
AllocRespJSON, err := json.Marshal(Allocations)
if err != nil {
- logger.Errorw(ctx, "Failed to Marshal dhcp allocation response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Failed to Marshal dhcp allocation response", log.Fields{"Allocations": Allocations, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -77,7 +78,9 @@
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(AllocRespJSON)
if err != nil {
- logger.Errorw(ctx, "Failed to write dhcp allocations response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Failed to write dhcp allocations response", log.Fields{"Allocations": Allocations, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(ctx, "Fetching DhcpAllocation info for device ID", log.Fields{"Allocations": Allocations, "deviceID": deviceID})
}
diff --git a/voltha-go-controller/onos_nbi/flowadapter.go b/voltha-go-controller/onos_nbi/flowadapter.go
index 1861e05..b31700d 100644
--- a/voltha-go-controller/onos_nbi/flowadapter.go
+++ b/voltha-go-controller/onos_nbi/flowadapter.go
@@ -81,6 +81,8 @@
}
func (pfh *PendingFlowHandle) GetPendingFlows(cntx context.Context, w http.ResponseWriter, r *http.Request) {
+ logger.Debug(ctx, "Received Get Pending Flows request")
+
flows, err := cntlr.GetController().GetAllPendingFlows()
if err != nil {
logger.Errorw(ctx, "Failed to get Pending flows", log.Fields{"Error": err})
@@ -90,7 +92,7 @@
flowResp := ConvertFlowsToFlowEntry(flows)
FlowRespJSON, err := json.Marshal(flowResp)
if err != nil {
- logger.Errorw(ctx, "Failed to marshal pending flow response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Failed to marshal pending flow response", log.Fields{"Flows": flows, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -98,7 +100,7 @@
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(FlowRespJSON)
if err != nil {
- logger.Errorw(ctx, "Failed to write Pending Flow response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Failed to write Pending Flow response", log.Fields{"Flows": flows, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
}
}
@@ -107,12 +109,19 @@
vars := mux.Vars(r)
deviceID := vars["deviceId"]
flowIDStr := vars["flowId"]
- flowID, _ := strconv.ParseUint(flowIDStr, 10, 64)
+ logger.Debugw(ctx, "Received Get Flows specific to flowID and deviceID", log.Fields{"flowId": flowIDStr, "DeviceID": deviceID})
+
+ flowID, parseErr := strconv.ParseUint(flowIDStr, 10, 64)
+ if parseErr != nil {
+ logger.Errorw(ctx, "Failed to parse flowIDStr from string to uint64", log.Fields{"flowIDStr": flowIDStr, "Reason": parseErr.Error()})
+ w.WriteHeader(http.StatusInternalServerError)
+ return
+ }
var flowResp FlowEntry
if len(deviceID) > 0 && len(flowIDStr) > 0 {
flow, err := fh.getFlow(deviceID, flowID)
if err != nil {
- logger.Errorw(ctx, "Failed to Fetch flow", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Failed to Fetch flow", log.Fields{"FlowID": flowID, "DeviceID": deviceID, "Error": err})
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
@@ -121,7 +130,7 @@
} else {
flows, err := fh.getAllFlows(deviceID)
if err != nil {
- logger.Errorw(ctx, "Failed to Fetch flows", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Failed to Fetch flows", log.Fields{"DeviceID": deviceID, "Error": err})
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
@@ -130,7 +139,7 @@
}
FlowRespJSON, err := json.Marshal(flowResp)
if err != nil {
- logger.Errorw(ctx, "Failed to marshal flow response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Failed to marshal flow response", log.Fields{"FlowID": flowID, "DeviceID": deviceID, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -138,9 +147,11 @@
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(FlowRespJSON)
if err != nil {
- logger.Errorw(ctx, "Failed to write flow response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Failed to write flow response", log.Fields{"FlowID": flowID, "DeviceID": deviceID, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(ctx, "Request for getting Flow specific to flowID and deviceID", log.Fields{"FlowID": flowID, "DeviceID": deviceID, "flowResp": flowResp})
}
func (fh *FlowHandle) getAllFlows(deviceID string) ([]*of.VoltSubFlow, error) {
diff --git a/voltha-go-controller/onos_nbi/groups.go b/voltha-go-controller/onos_nbi/groups.go
index 2280654..7fc738b 100644
--- a/voltha-go-controller/onos_nbi/groups.go
+++ b/voltha-go-controller/onos_nbi/groups.go
@@ -40,9 +40,9 @@
// ServeHTTP to serve http request
func (gh *GroupsHandle) GroupServeHTTP(w http.ResponseWriter, r *http.Request) {
- logger.Infow(ctx, "Received-northbound-request", log.Fields{"Method": r.Method, "URL": r.URL})
vars := mux.Vars(r)
groupID := vars["id"]
+ logger.Infow(ctx, "Received-northbound-request", log.Fields{"Method": r.Method, "groupId": groupID, "URL": r.URL})
switch r.Method {
case cGet:
@@ -60,17 +60,17 @@
func (gh *GroupsHandle) GetGroupInfo(cntx context.Context, groupID string, w http.ResponseWriter, r *http.Request) {
groupResp := GroupList{}
groupResp.Groups = []*GroupsInfo{}
+
grpID, err := strconv.ParseUint(groupID, 10, 32)
if err != nil {
- logger.Errorw(ctx, "Failed to parse string to uint32", log.Fields{"Reason": err.Error()})
+ logger.Errorw(ctx, "Failed to parse received groupID from string to uint32", log.Fields{"groupID": groupID, "Reason": err.Error()})
+ w.WriteHeader(http.StatusInternalServerError)
+ return
}
id := uint32(grpID)
-
- logger.Infow(ctx, "Inside GetGroupInfo method", log.Fields{"groupId": id})
-
Groups, err := app.GetController().GetGroups(ctx, id)
if err != nil {
- logger.Errorw(ctx, "Failed to fetch group info", log.Fields{"Reason": err.Error()})
+ logger.Errorw(ctx, "Failed to fetch group info from Device through grpID", log.Fields{"groupID": groupID, "Reason": err.Error()})
w.WriteHeader(http.StatusNotFound)
return
}
@@ -80,7 +80,7 @@
GroupsRespJSON, err := json.Marshal(groupResp)
if err != nil {
- logger.Errorw(ctx, "Error occurred while marshaling group response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Error occurred while marshaling group response specific to received groupID", log.Fields{"groupId": id, "GroupResp": groupResp, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -88,19 +88,20 @@
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(GroupsRespJSON)
if err != nil {
- logger.Errorw(ctx, "error in sending group response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "error in sending group response specific to received groupID", log.Fields{"groupId": id, "GroupResp": groupResp, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(ctx, "Fetching GroupInfo specific to received groupID", log.Fields{"groupId": id, "GroupResp": groupResp})
}
func (gh *GroupsHandle) GetAllGroups(cntx context.Context, w http.ResponseWriter, r *http.Request) {
- logger.Info(cntx, "Inside GetAllGroups method")
groupListResp := GroupList{}
groupListResp.Groups = []*GroupsInfo{}
GroupsInfo, err := app.GetController().GetGroupList()
if err != nil {
- logger.Errorw(ctx, "Failed to fetch group info", log.Fields{"Reason": err.Error()})
+ logger.Errorw(ctx, "Failed to fetch group info from VoltController Device", log.Fields{"Reason": err.Error()})
w.WriteHeader(http.StatusNotFound)
return
}
@@ -112,7 +113,7 @@
GroupRespJSON, err := json.Marshal(groupListResp)
if err != nil {
- logger.Errorw(ctx, "Error occurred while marshaling meter response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Error occurred while marshaling group List response", log.Fields{"groupListResp": groupListResp, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -120,7 +121,9 @@
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(GroupRespJSON)
if err != nil {
- logger.Errorw(ctx, "error in sending meter response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "error in sending group List response", log.Fields{"groupListResp": groupListResp, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(ctx, "Fetching All GroupInfo", log.Fields{"groupListResp": groupListResp})
}
diff --git a/voltha-go-controller/onos_nbi/maclearning_info.go b/voltha-go-controller/onos_nbi/maclearning_info.go
index cde6b0b..d944d89 100644
--- a/voltha-go-controller/onos_nbi/maclearning_info.go
+++ b/voltha-go-controller/onos_nbi/maclearning_info.go
@@ -40,11 +40,12 @@
// ServeHTTP to serve http request
func (mlh *MacLearnerHandle) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- logger.Infow(ctx, "Received-northbound-request", log.Fields{"Method": r.Method, "URL": r.URL})
vars := mux.Vars(r)
deviceID := vars["deviceId"]
portNum := vars["portNumber"]
vlanID := vars["vlanId"]
+ logger.Infow(ctx, "Received-northbound-request ", log.Fields{"Method": r.Method, "URL": r.URL, "deviceID": deviceID, "portNum": portNum, "vlanID": vlanID})
+
switch r.Method {
case cGet:
if deviceID == "" && portNum == "" && vlanID == "" {
@@ -60,7 +61,6 @@
}
func (mlh *MacLearnerHandle) GetAllMacLearnerInfo(cntx context.Context, w http.ResponseWriter, r *http.Request) {
- logger.Info(cntx, "Inside GetAllMacLearnerInfo method")
MacLearnerInfo, err := app.GetApplication().GetAllMacLearnerInfo()
if err != nil {
logger.Errorw(ctx, "Failed to get mac learning info", log.Fields{"Reason": err.Error()})
@@ -70,7 +70,7 @@
MliRespJSON, err := json.Marshal(MacLearnerInfo)
if err != nil {
- logger.Errorw(ctx, "Error occurred while marshaling mac learner response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Error occurred while marshaling mac learner response", log.Fields{"MacLearnerInfo": MacLearnerInfo, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -78,13 +78,14 @@
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(MliRespJSON)
if err != nil {
- logger.Errorw(ctx, "error in sending mac learner response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "error in sending mac learner response", log.Fields{"MacLearnerInfo": MacLearnerInfo, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(ctx, "Getting All MacLearnerInfo from DHCP Networks", log.Fields{"MacLearnerInfo": MacLearnerInfo})
}
func (mlh *MacLearnerHandle) GetMacLearnerInfo(cntx context.Context, deviceID, portNum, vlanID string, w http.ResponseWriter, r *http.Request) {
- logger.Infow(cntx, "Inside GetMacLearnerInfo method", log.Fields{"deviceID": deviceID, "portNum": portNum, "vlanId": vlanID})
MacLearnerInfo, err := app.GetApplication().GetMacLearnerInfo(cntx, deviceID, portNum, vlanID)
if err != nil {
logger.Errorw(ctx, "Failed to get mac learning info", log.Fields{"Reason": err.Error()})
@@ -94,7 +95,7 @@
MliRespJSON, err := json.Marshal(MacLearnerInfo)
if err != nil {
- logger.Errorw(ctx, "Error occurred while marshaling mac learner response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Error occurred while marshaling mac learner response", log.Fields{"MacLearnerInfo": MacLearnerInfo, "deviceID": deviceID, "portNum": portNum, "vlanId": vlanID, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -102,7 +103,9 @@
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(MliRespJSON)
if err != nil {
- logger.Errorw(ctx, "error in sending mac learner response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "error in sending mac learner response", log.Fields{"MacLearnerInfo": MacLearnerInfo, "deviceID": deviceID, "portNum": portNum, "vlanId": vlanID, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(cntx, "Get MacLearnerInfo from DHCP Networks specific to deviceID, portNum and vlanID", log.Fields{"MacLearnerInfo": MacLearnerInfo, "deviceID": deviceID, "portNum": portNum, "vlanId": vlanID})
}
diff --git a/voltha-go-controller/onos_nbi/meters.go b/voltha-go-controller/onos_nbi/meters.go
index 78d715c..5334e7b 100644
--- a/voltha-go-controller/onos_nbi/meters.go
+++ b/voltha-go-controller/onos_nbi/meters.go
@@ -41,14 +41,13 @@
// ServeHTTP to serve http request
func (mh *MetersHandle) MeterServeHTTP(w http.ResponseWriter, r *http.Request) {
- logger.Infow(ctx, "Received-northbound-request", log.Fields{"Method": r.Method, "URL": r.URL})
vars := mux.Vars(r)
meterID := vars["id"]
+ logger.Infow(ctx, "Received-northbound-request ", log.Fields{"Method": r.Method, "URL": r.URL, "meterID": meterID})
switch r.Method {
case cGet:
if meterID != "" {
- logger.Warnw(ctx, "Calling GetMeter method", log.Fields{"MeterId": meterID})
mh.GetMeter(context.Background(), meterID, w, r)
} else {
mh.GetAllMeters(context.Background(), w, r)
@@ -62,12 +61,11 @@
}
func (mh *MetersHandle) GetMeter(cntx context.Context, meterID string, w http.ResponseWriter, r *http.Request) {
- logger.Info(cntx, "Inside GetMeter method")
meterListResp := MeterList{}
meterListResp.Meters = []Meters{}
mID, err := strconv.ParseUint(meterID, 10, 32)
if err != nil {
- logger.Errorw(ctx, "Failed to parse string to uint32", log.Fields{"Reason": err.Error()})
+ logger.Errorw(ctx, "Failed to parse meterID from string to uint32", log.Fields{"Meter ID": mID, "Reason": err.Error()})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -75,7 +73,7 @@
logger.Infow(ctx, "Meter Id", log.Fields{"metreId": id})
meterInfo, err := app.GetController().GetMeterInfo(cntx, id)
if err != nil {
- logger.Errorw(ctx, "Failed to get meter info", log.Fields{"Reason": err.Error()})
+ logger.Errorw(ctx, "Failed to get meter info from device with Meter Id", log.Fields{"Meter ID": mID, "Reason": err.Error()})
w.WriteHeader(http.StatusNotFound)
return
}
@@ -86,26 +84,28 @@
}
MeterRespJSON, err := json.Marshal(meterListResp)
if err != nil {
- logger.Errorw(ctx, "Error occurred while marshaling meter response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Error occurred while marshaling meter response", log.Fields{"Meter ID": mID, "MeterListResp": meterListResp, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(MeterRespJSON)
if err != nil {
- logger.Errorw(ctx, "error in sending meter response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "error in sending meter response", log.Fields{"Meter ID": mID, "MeterListResp": meterListResp, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(ctx, "Fetch Meter Info specific to received Meter Id", log.Fields{"metreId": id, "MeterListResp": meterListResp})
}
func (mh *MetersHandle) GetAllMeters(cntx context.Context, w http.ResponseWriter, r *http.Request) {
- logger.Info(cntx, "Inside GetAllMeters method")
metersList := MeterList{}
metersList.Meters = []Meters{}
meterInfo, err := app.GetController().GetAllMeterInfo()
if err != nil {
logger.Errorw(ctx, "Failed to get meter info", log.Fields{"Reason": err.Error()})
w.WriteHeader(http.StatusNotFound)
+ return
}
for deviceID, meters := range meterInfo {
for _, meter := range meters {
@@ -115,14 +115,16 @@
}
MeterRespJSON, err := json.Marshal(metersList)
if err != nil {
- logger.Errorw(ctx, "Error occurred while marshaling meter response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Error occurred while marshaling meter response", log.Fields{"MetersList": metersList, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(MeterRespJSON)
if err != nil {
- logger.Errorw(ctx, "error in sending meter response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "error in sending meter response", log.Fields{"MetersList": metersList, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(ctx, "Fetching all Meter Info from device", log.Fields{"MetersList": metersList})
}
diff --git a/voltha-go-controller/onos_nbi/models.go b/voltha-go-controller/onos_nbi/models.go
index cc4bed0..0b7ebff 100644
--- a/voltha-go-controller/onos_nbi/models.go
+++ b/voltha-go-controller/onos_nbi/models.go
@@ -792,7 +792,7 @@
return port
}
func (gh *GroupsHandle) convertGroupsToOnosGroup(groupsInfo *of.Group) *GroupsInfo {
- logger.Info(ctx, "Entering into convertGroupsToOnosGroup")
+ logger.Debug(ctx, "Entering into convertGroupsToOnosGroup")
var groups *GroupsInfo
var bucket []Bucket
Instruction := []Instructions{}
diff --git a/voltha-go-controller/onos_nbi/oltapprestadapter.go b/voltha-go-controller/onos_nbi/oltapprestadapter.go
index cb926e1..4e31a63 100644
--- a/voltha-go-controller/onos_nbi/oltapprestadapter.go
+++ b/voltha-go-controller/onos_nbi/oltapprestadapter.go
@@ -102,10 +102,12 @@
deviceID := vars[DEVICE]
portNo := vars["port"]
+ logger.Infow(ctx, "Received ActivateService request specific for portNo and deviceID", log.Fields{"portNo": portNo, "deviceID": deviceID})
+
// Get the payload to process the request
d := new(bytes.Buffer)
if _, err := d.ReadFrom(r.Body); err != nil {
- logger.Warnw(ctx, "Error reading buffer", log.Fields{"Reason": err.Error()})
+ logger.Errorw(ctx, "Error reading buffer", log.Fields{"portNo": portNo, "deviceID": deviceID, "Reason": err.Error()})
http.Error(w, err.Error(), http.StatusConflict)
return
}
@@ -114,25 +116,25 @@
va := app.GetApplication()
port, err := strconv.Atoi(portNo)
if err != nil {
- logger.Warnw(ctx, "Wrong port number value", log.Fields{"portNo": portNo})
+ logger.Errorw(ctx, "Wrong port number value", log.Fields{"portNo": portNo, "Error": err})
http.Error(w, err.Error(), http.StatusConflict)
return
}
device := va.GetDevice(deviceID)
if device == nil {
- logger.Warnw(ctx, "Device does not exists", log.Fields{"deviceID": deviceID})
+ logger.Errorw(ctx, "Device does not exists", log.Fields{"deviceID": deviceID})
http.Error(w, err.Error(), http.StatusConflict)
return
}
portName := device.GetPortNameFromPortID(uint32(port))
if len(portName) == 0 {
- logger.Warnw(ctx, "Port does not exists", log.Fields{"deviceID": deviceID})
+ logger.Errorw(ctx, "Port does not exists", log.Fields{"portNo": portNo})
err := errorCodes.ErrPortNotFound
http.Error(w, err.Error(), http.StatusConflict)
return
}
if err := va.ActivateService(cntx, deviceID, portName, of.VlanNone, of.VlanNone, 0); err != nil {
- logger.Warnw(ctx, "ActivateService Failed", log.Fields{"deviceID": deviceID, "Port": portNo})
+ logger.Errorw(ctx, "ActivateService Failed", log.Fields{"deviceID": deviceID, "Port": portNo, "Error": err})
http.Error(w, err.Error(), http.StatusBadRequest)
}
}
@@ -142,11 +144,12 @@
vars := mux.Vars(r)
deviceID := vars[DEVICE]
portNo := vars["port"]
+ logger.Infow(ctx, "Received DeactivateService request specific for portNo and deviceID", log.Fields{"portNo": portNo, "deviceID": deviceID})
// Get the payload to process the request
d := new(bytes.Buffer)
if _, err := d.ReadFrom(r.Body); err != nil {
- logger.Warnw(ctx, "Error reading buffer", log.Fields{"Reason": err.Error()})
+ logger.Errorw(ctx, "Error reading buffer", log.Fields{"portNo": portNo, "deviceID": deviceID, "Reason": err.Error()})
http.Error(w, err.Error(), http.StatusConflict)
return
}
@@ -155,25 +158,25 @@
va := app.GetApplication()
port, err := strconv.Atoi(portNo)
if err != nil {
- logger.Warnw(ctx, "Wrong port number value", log.Fields{"portNo": portNo})
+ logger.Errorw(ctx, "Wrong port number value", log.Fields{"portNo": portNo, "Error": err})
http.Error(w, err.Error(), http.StatusConflict)
return
}
device := va.GetDevice(deviceID)
if device == nil {
- logger.Warnw(ctx, "Device does not exists", log.Fields{"deviceID": deviceID})
+ logger.Errorw(ctx, "Device does not exists", log.Fields{"deviceID": deviceID})
http.Error(w, err.Error(), http.StatusConflict)
return
}
portName := device.GetPortNameFromPortID(uint32(port))
if len(portName) == 0 {
- logger.Warnw(ctx, "Port does not exists", log.Fields{"deviceID": deviceID})
+ logger.Errorw(ctx, "Port does not exists", log.Fields{"portNo": portNo})
err := errorCodes.ErrPortNotFound
http.Error(w, err.Error(), http.StatusConflict)
return
}
if err := va.DeactivateService(cntx, deviceID, portName, of.VlanNone, of.VlanNone, 0); err != nil {
- logger.Warnw(ctx, "DeactivateService Failed", log.Fields{"deviceID": deviceID, "Port": portNo})
+ logger.Errorw(ctx, "DeactivateService Failed", log.Fields{"deviceID": deviceID, "Port": portNo, "Error": err})
http.Error(w, err.Error(), http.StatusBadRequest)
}
}
@@ -188,11 +191,12 @@
sVlan := of.VlanNone
cVlan := of.VlanNone
techProfile := uint16(0)
+ logger.Infow(ctx, "Received ActivateService request specific for portNo, sVlan, cVlan and techProfile", log.Fields{"Port": portNo, "SVlan": sVlan, "CVlan": cVlan, "techProfile": techProfile})
if len(sTag) > 0 {
sv, err := strconv.Atoi(sTag)
if err != nil {
- logger.Warnw(ctx, "Wrong vlan value", log.Fields{"sTag": sTag})
+ logger.Errorw(ctx, "Wrong vlan value", log.Fields{"sTag": sTag, "Reason": err.Error()})
http.Error(w, err.Error(), http.StatusConflict)
return
}
@@ -201,7 +205,7 @@
if len(cTag) > 0 {
cv, err := strconv.Atoi(cTag)
if err != nil {
- logger.Warnw(ctx, "Wrong vlan value", log.Fields{"cTag": cTag})
+ logger.Errorw(ctx, "Wrong vlan value", log.Fields{"cTag": cTag, "Reason": err.Error()})
http.Error(w, err.Error(), http.StatusConflict)
return
}
@@ -210,7 +214,7 @@
if len(tpID) > 0 {
tp, err := strconv.Atoi(tpID)
if err != nil {
- logger.Warnw(ctx, "Wrong tech profile value", log.Fields{"tpID": tpID})
+ logger.Errorw(ctx, "Wrong tech profile value", log.Fields{"tpID": tpID, "Reason": err.Error()})
http.Error(w, err.Error(), http.StatusConflict)
return
}
@@ -219,10 +223,12 @@
if len(portNo) > 0 {
if err := app.GetApplication().ActivateService(cntx, app.DeviceAny, portNo, sVlan, cVlan, techProfile); err != nil {
- logger.Warnw(ctx, "ActivateService Failed", log.Fields{"Port": portNo, "SVlan": sVlan, "CVlan": cVlan, "techProfile": techProfile})
+ logger.Errorw(ctx, "ActivateService Failed", log.Fields{"Port": portNo, "SVlan": sVlan, "CVlan": cVlan, "techProfile": techProfile, "Reason": err.Error()})
http.Error(w, err.Error(), http.StatusBadRequest)
+ return
}
}
+ logger.Debugw(ctx, "ActivateService request specific for portNo, sVlan, cVlan and techProfile", log.Fields{"Port": portNo, "SVlan": sVlan, "CVlan": cVlan, "techProfile": techProfile})
}
func (sa *ServiceAdapter) DeactivateServiceWithPortName(cntx context.Context, w http.ResponseWriter, r *http.Request) {
@@ -234,11 +240,12 @@
sVlan := of.VlanNone
cVlan := of.VlanNone
techProfile := uint16(0)
+ logger.Infow(ctx, "Received DeactivateService request specific for portNo, sVlan, cVlan and techProfile", log.Fields{"Port": portNo, "SVlan": sVlan, "CVlan": cVlan, "techProfile": techProfile})
if len(sTag) > 0 {
sv, err := strconv.Atoi(sTag)
if err != nil {
- logger.Warnw(ctx, "Wrong vlan value", log.Fields{"sTag": sTag})
+ logger.Errorw(ctx, "Wrong vlan value", log.Fields{"sTag": sTag, "Reason": err.Error()})
http.Error(w, err.Error(), http.StatusConflict)
return
}
@@ -247,7 +254,7 @@
if len(cTag) > 0 {
cv, err := strconv.Atoi(cTag)
if err != nil {
- logger.Warnw(ctx, "Wrong vlan value", log.Fields{"cTag": cTag})
+ logger.Errorw(ctx, "Wrong vlan value", log.Fields{"cTag": cTag, "Reason": err.Error()})
http.Error(w, err.Error(), http.StatusConflict)
return
}
@@ -256,7 +263,7 @@
if len(tpID) > 0 {
tp, err := strconv.Atoi(tpID)
if err != nil {
- logger.Warnw(ctx, "Wrong tech profile value", log.Fields{"tpID": tpID})
+ logger.Errorw(ctx, "Wrong tech profile value", log.Fields{"tpID": tpID, "Reason": err.Error()})
http.Error(w, err.Error(), http.StatusConflict)
return
}
@@ -265,27 +272,33 @@
if len(portNo) > 0 {
if err := app.GetApplication().DeactivateService(cntx, app.DeviceAny, portNo, sVlan, cVlan, techProfile); err != nil {
- logger.Warnw(ctx, "DeactivateService Failed", log.Fields{"Port": portNo, "SVlan": sVlan, "CVlan": cVlan, "techProfile": techProfile})
+ logger.Errorw(ctx, "DeactivateService Failed", log.Fields{"Port": portNo, "SVlan": sVlan, "CVlan": cVlan, "techProfile": techProfile, "Reason": err.Error()})
http.Error(w, err.Error(), http.StatusBadRequest)
+ return
}
}
+ logger.Debugw(ctx, "DeactivateService request specific for portNo, sVlan, cVlan and techProfile", log.Fields{"Port": portNo, "SVlan": sVlan, "CVlan": cVlan, "techProfile": techProfile})
}
func (sa *ServiceAdapter) GetProgrammedSubscribers(cntx context.Context, w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
deviceID := vars[DEVICE]
portNo := vars["port"]
+ logger.Infow(ctx, "Received Programmed Subscribers request specific for portNo and deviceID", log.Fields{"portNo": portNo, "deviceID": deviceID})
+
subsbr := SubscribersList{}
subsbr.Subscribers = []SubscriberInfo{}
svcs, err := app.GetApplication().GetProgrammedSubscribers(cntx, deviceID, portNo)
if err != nil {
- logger.Errorw(ctx, "Failed to get subscribers", log.Fields{"Reason": err.Error()})
+ logger.Errorw(ctx, "Failed to get subscribers", log.Fields{"portNo": portNo, "deviceID": deviceID, "Reason": err.Error()})
+ w.WriteHeader(http.StatusNotFound)
+ return
}
subs := convertServiceToSubscriberInfo(svcs)
subsbr.Subscribers = subs
subsJSON, err := json.Marshal(subsbr)
if err != nil {
- logger.Errorw(ctx, "Error occurred while marshaling subscriber response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Error occurred while marshaling subscriber response", log.Fields{"Subsbr": subsbr, "portNo": portNo, "deviceID": deviceID, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -293,7 +306,9 @@
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(subsJSON)
if err != nil {
- logger.Errorw(ctx, "error in sending subscriber response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "error in sending subscriber response", log.Fields{"Subsbr": subsbr, "portNo": portNo, "deviceID": deviceID, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(ctx, "Programmed Subscribers request specific for portNo and deviceID", log.Fields{"Subsbr": subsbr, "portNo": portNo, "deviceID": deviceID})
}
diff --git a/voltha-go-controller/onos_nbi/oltflowservice.go b/voltha-go-controller/onos_nbi/oltflowservice.go
index 2da53d3..28d5883 100644
--- a/voltha-go-controller/onos_nbi/oltflowservice.go
+++ b/voltha-go-controller/onos_nbi/oltflowservice.go
@@ -49,14 +49,15 @@
// Get the payload to process the request
d := new(bytes.Buffer)
if _, err := d.ReadFrom(r.Body); err != nil {
- logger.Warnw(ctx, "Error reading buffer", log.Fields{"Reason": err.Error()})
+ logger.Errorw(ctx, "Error reading buffer", log.Fields{"Reason": err.Error()})
+ http.Error(w, err.Error(), http.StatusConflict)
return
}
// Unmarshal the request into service configuration structure
req := &app.OltFlowService{}
if err := json.Unmarshal(d.Bytes(), req); err != nil {
- logger.Warnw(ctx, "Unmarshal Failed", log.Fields{"Reason": err.Error()})
+ logger.Errorw(ctx, "Unmarshal Failed", log.Fields{"req": req, "Reason": err.Error()})
http.Error(w, err.Error(), http.StatusConflict)
return
}
@@ -64,21 +65,22 @@
}
func (oh *OltFlowServiceHandle) fetchOltFlowService(cntx context.Context, w http.ResponseWriter, r *http.Request) {
- logger.Info(cntx, "Inside fetchOltFlowService method")
oltFlowSer := OltFlowServiceConfig{}
va := app.GetApplication()
oltFlowSer.OltFlowService = va.OltFlowServiceConfig
OltFlowRespJSON, err := json.Marshal(oltFlowSer)
if err != nil {
- logger.Errorw(ctx, "Error occurred while marshaling oltFlowService response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Error occurred while marshaling oltFlowService response", log.Fields{"OltFlowService": oltFlowSer.OltFlowService, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(OltFlowRespJSON)
if err != nil {
- logger.Errorw(ctx, "error in sending olt flow service response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "error in sending olt flow service response", log.Fields{"OltFlowService": oltFlowSer.OltFlowService, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(cntx, "Request for Fetching Olt Flow Service", log.Fields{"OltFlowService": oltFlowSer.OltFlowService})
}
diff --git a/voltha-go-controller/onos_nbi/portIgnored.go b/voltha-go-controller/onos_nbi/portIgnored.go
index 513bb3b..53fe086 100644
--- a/voltha-go-controller/onos_nbi/portIgnored.go
+++ b/voltha-go-controller/onos_nbi/portIgnored.go
@@ -40,7 +40,6 @@
logger.Infow(ctx, "Received-northbound-request", log.Fields{"Method": r.Method, "URL": r.URL})
switch r.Method {
case cGet:
- logger.Info(ctx, "calling GetIgnoredPortsInfo handler")
pih.GetIgnoredPortsInfo(context.Background(), w, r)
default:
@@ -60,7 +59,7 @@
PortIgnoredRespJSON, err := json.Marshal(PortIgnoredInfo)
if err != nil {
- logger.Errorw(ctx, "Error occurred while marshaling ignored port response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "Error occurred while marshaling ignored port response", log.Fields{"PortIgnoredInfo": PortIgnoredInfo, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -68,7 +67,9 @@
w.Header().Add("Content-Type", "application/json")
_, err = w.Write(PortIgnoredRespJSON)
if err != nil {
- logger.Errorw(ctx, "error in sending ignored port response", log.Fields{"Error": err})
+ logger.Errorw(ctx, "error in sending ignored port response", log.Fields{"PortIgnoredInfo": PortIgnoredInfo, "Error": err})
w.WriteHeader(http.StatusInternalServerError)
+ return
}
+ logger.Debugw(ctx, "Request for get Ignored Ports Info", log.Fields{"PortIgnoredInfo": PortIgnoredInfo})
}