[VOL-4756] Cleanup TODO context
Change-Id: I21d5ec8cc015154bc893e54c652d31562d8da5d9
diff --git a/voltha-go-controller/nbi/flow_hash.go b/voltha-go-controller/nbi/flow_hash.go
index a3a6115..75b3e8b 100644
--- a/voltha-go-controller/nbi/flow_hash.go
+++ b/voltha-go-controller/nbi/flow_hash.go
@@ -54,7 +54,7 @@
logger.Errorw(ctx, "Failed to get device", log.Fields{"device": id})
return
}
- device.SetFlowHash(uint32(flowhash))
+ device.SetFlowHash(ctx, uint32(flowhash))
}
logger.Debugw(ctx, "flowhash data is ", log.Fields{"vars": vars, "value": string(reqBody)})
diff --git a/voltha-go-controller/nbi/sadisbwprofile.go b/voltha-go-controller/nbi/sadisbwprofile.go
index d0f404b..2cf4cb5 100644
--- a/voltha-go-controller/nbi/sadisbwprofile.go
+++ b/voltha-go-controller/nbi/sadisbwprofile.go
@@ -17,6 +17,7 @@
import (
"bytes"
+ "context"
"encoding/json"
"net/http"
@@ -51,18 +52,18 @@
logger.Infow(ctx, "Received-northbound-request", log.Fields{"Method": r.Method, "URL": r.URL})
switch r.Method {
case "GET":
- mh.GetProfile(w, r)
+ mh.GetProfile(context.Background(), w, r)
case "POST":
- mh.AddProfile(w, r)
+ mh.AddProfile(context.Background(), w, r)
case "DELETE":
- mh.DelProfile(w, r)
+ mh.DelProfile(context.Background(), w, r)
default:
logger.Warnw(ctx, "Unsupported Method", log.Fields{"Method": r.Method})
}
}
// AddProfile to add meter
-func (mh *ProfileHandle) AddProfile(w http.ResponseWriter, r *http.Request) {
+func (mh *ProfileHandle) AddProfile(cntx context.Context, w http.ResponseWriter, r *http.Request) {
// Get the payload to process the request
d := new(bytes.Buffer)
if _, err := d.ReadFrom(r.Body); err != nil {
@@ -89,16 +90,16 @@
Eir: req.ExceededInformationRate,
Ebs: req.ExceededBurstSize,
}
- app.GetApplication().AddMeterProf(metercfg)
+ app.GetApplication().AddMeterProf(cntx, metercfg)
logger.Debugw(ctx, "northbound-add-meter-successful", log.Fields{"req": req})
}
// GetProfile to get meter
-func (mh *ProfileHandle) GetProfile(w http.ResponseWriter, r *http.Request) {
+func (mh *ProfileHandle) GetProfile(cntx context.Context, w http.ResponseWriter, r *http.Request) {
}
// DelProfile to delete meter
-func (mh *ProfileHandle) DelProfile(w http.ResponseWriter, r *http.Request) {
+func (mh *ProfileHandle) DelProfile(cntx context.Context, w http.ResponseWriter, r *http.Request) {
//TODO : Change the URL and Mux to fetch meter id from the request
d := new(bytes.Buffer)
if _, err := d.ReadFrom(r.Body); err != nil {
@@ -115,7 +116,7 @@
logger.Debugw(ctx, "Received-northbound-del-meter-request", log.Fields{"req": req})
meterName := req.ID
- if err := app.GetApplication().DelMeterProf(meterName); err != nil {
+ if err := app.GetApplication().DelMeterProf(cntx, meterName); err != nil {
logger.Errorw(ctx, "northbound-del-meter-failed", log.Fields{"req": req})
http.Error(w, err.Error(), http.StatusConflict)
return
diff --git a/voltha-go-controller/nbi/sadisigmpproxy.go b/voltha-go-controller/nbi/sadisigmpproxy.go
index 6c8f27d..5d07229 100644
--- a/voltha-go-controller/nbi/sadisigmpproxy.go
+++ b/voltha-go-controller/nbi/sadisigmpproxy.go
@@ -17,6 +17,7 @@
import (
"bytes"
+ "context"
"encoding/json"
"net/http"
"strings"
@@ -56,16 +57,16 @@
logger.Infow(ctx, "Received-northbound-request", log.Fields{"Method": r.Method, "URL": r.URL})
switch r.Method {
case "POST":
- iph.AddIgmpProxyInfo(w, r)
+ iph.AddIgmpProxyInfo(context.Background(), w, r)
case "DELETE":
- iph.DelIgmpProxyInfo(w, r)
+ iph.DelIgmpProxyInfo(context.Background(), w, r)
default:
logger.Warnw(ctx, "Unsupported Method", log.Fields{"Method": r.Method})
}
}
// AddIgmpProxyInfo to add igmp proxy info
-func (iph *IgmpProxyHandle) AddIgmpProxyInfo(w http.ResponseWriter, r *http.Request) {
+func (iph *IgmpProxyHandle) AddIgmpProxyInfo(cntx context.Context, w http.ResponseWriter, r *http.Request) {
// Get the payload to process the request
d := new(bytes.Buffer)
@@ -88,15 +89,15 @@
}
logger.Debugw(ctx, "Received-northbound-add-service-request", log.Fields{"req": req})
- go iph.addIgmpProxy(w, req)
+ go iph.addIgmpProxy(cntx, w, req)
}
// DelIgmpProxyInfo to delete igmp proxy info
-func (iph *IgmpProxyHandle) DelIgmpProxyInfo(w http.ResponseWriter, r *http.Request) {
+func (iph *IgmpProxyHandle) DelIgmpProxyInfo(cntx context.Context, w http.ResponseWriter, r *http.Request) {
}
-func (iph *IgmpProxyHandle) addIgmpProxy(w http.ResponseWriter, req *IgmpProxy) {
+func (iph *IgmpProxyHandle) addIgmpProxy(cntx context.Context, w http.ResponseWriter, req *IgmpProxy) {
var config McastConfig
config.OltSerialNum = req.SourceDeviceAndPort
@@ -109,7 +110,7 @@
logger.Errorw(ctx, "IgmpProxy", log.Fields{"config":config})
- if err := app.GetApplication().AddMcastConfig(config.MvlanProfileID, config.IgmpProfileID,
+ if err := app.GetApplication().AddMcastConfig(cntx, config.MvlanProfileID, config.IgmpProfileID,
config.IgmpProxyIP, config.OltSerialNum); err != nil {
logger.Errorw(ctx, "northbound-add-mcast-config-failed", log.Fields{"config": config, "Error": err})
http.Error(w, err.Error(), http.StatusConflict)
diff --git a/voltha-go-controller/nbi/sadismvlan.go b/voltha-go-controller/nbi/sadismvlan.go
index 28fa1d5..2242188 100644
--- a/voltha-go-controller/nbi/sadismvlan.go
+++ b/voltha-go-controller/nbi/sadismvlan.go
@@ -17,6 +17,7 @@
import (
"bytes"
+ "context"
"encoding/json"
"net/http"
"strconv"
@@ -76,16 +77,16 @@
logger.Infow(ctx, "Received-northbound-request", log.Fields{"Method": r.Method, "URL": r.URL})
switch r.Method {
case "POST":
- iph.AddMvlanInfo(w, r)
+ iph.AddMvlanInfo(context.Background(), w, r)
case "DELETE":
- iph.DelMvlanInfo(w, r)
+ iph.DelMvlanInfo(context.Background(), w, r)
default:
logger.Warnw(ctx, "Unsupported Method", log.Fields{"Method": r.Method})
}
}
// AddMvlanInfo to add igmp proxy info
-func (iph *MulticastHandle) AddMvlanInfo(w http.ResponseWriter, r *http.Request) {
+func (iph *MulticastHandle) AddMvlanInfo(cntx context.Context, w http.ResponseWriter, r *http.Request) {
// Get the payload to process the request
d := new(bytes.Buffer)
@@ -104,15 +105,15 @@
}
logger.Debugw(ctx, "Received-northbound-add-service-request", log.Fields{"req": req})
- go iph.addMvlan(w, req)
+ go iph.addMvlan(cntx, w, req)
}
// DelMvlanInfo to delete igmp proxy info
-func (iph *MulticastHandle) DelMvlanInfo(w http.ResponseWriter, r *http.Request) {
+func (iph *MulticastHandle) DelMvlanInfo(cntx context.Context, w http.ResponseWriter, r *http.Request) {
}
-func (iph *MulticastHandle) addMvlan(w http.ResponseWriter, req *Mvlan) {
+func (iph *MulticastHandle) addMvlan(cntx context.Context, w http.ResponseWriter, req *Mvlan) {
var config MvlanProfile
var groups []string
@@ -123,7 +124,7 @@
config.Groups = make(map[string][]string)
config.Groups["default"] = groups
- if err := app.GetApplication().AddMvlanProfile(config.Name, config.Mvlan, config.PonVlan, config.Groups,
+ if err := app.GetApplication().AddMvlanProfile(cntx, config.Name, config.Mvlan, config.PonVlan, config.Groups,
config.IsChannelBasedGroup, config.OLTSerialNum,
255, config.Proxy); err != nil {
logger.Errorw(ctx, "northbound-add-mvlan-failed", log.Fields{"mvlan": config.Name, "Reason": err.Error()})
diff --git a/voltha-go-controller/nbi/sadissubscriber.go b/voltha-go-controller/nbi/sadissubscriber.go
index 86d9b2b..db27a95 100644
--- a/voltha-go-controller/nbi/sadissubscriber.go
+++ b/voltha-go-controller/nbi/sadissubscriber.go
@@ -17,6 +17,7 @@
import (
"bytes"
+ "context"
"encoding/json"
"net"
"net/http"
@@ -75,16 +76,16 @@
logger.Infow(ctx, "Received-northbound-request", log.Fields{"Method": r.Method, "URL": r.URL})
switch r.Method {
case "POST":
- sh.AddSubscriberInfo(w, r)
+ sh.AddSubscriberInfo(context.Background(), w, r)
case "DELETE":
- sh.DelSubscriberInfo(w, r)
+ sh.DelSubscriberInfo(context.Background(), w, r)
default:
logger.Warnw(ctx, "Unsupported Method", log.Fields{"Method": r.Method})
}
}
// AddSubscriberInfo to add service
-func (sh *SubscriberHandle) AddSubscriberInfo(w http.ResponseWriter, r *http.Request) {
+func (sh *SubscriberHandle) AddSubscriberInfo(cntx context.Context, w http.ResponseWriter, r *http.Request) {
// Get the payload to process the request
d := new(bytes.Buffer)
@@ -104,10 +105,10 @@
//vsCfgList := getVoltServiceFromSrvInfo(req)
- go addAllService(req)
+ go addAllService(cntx, req)
}
-func addAllService(srvInfo *SubscriberDeviceInfo) {
+func addAllService(cntx context.Context, srvInfo *SubscriberDeviceInfo) {
//vsCfgList := getVoltServiceFromSrvInfo(srvInfo)
@@ -178,10 +179,10 @@
vnetcfg.VlanControl = app.OLTSVlan
}
- if err := app.GetApplication().AddVnet(vnetcfg, nil); err != nil {
+ if err := app.GetApplication().AddVnet(cntx, vnetcfg, nil); err != nil {
logger.Errorw(ctx, "AddVnet Failed", log.Fields{"VnetName": vnetName, "Error": err})
}
- if err := app.GetApplication().AddService(vs, nil); err != nil {
+ if err := app.GetApplication().AddService(cntx, vs, nil); err != nil {
logger.Errorw(ctx, "AddService Failed", log.Fields{"Service": vs.Name, "Error": err})
}
@@ -189,7 +190,7 @@
}
// DelSubscriberInfo to delete service
-func (sh *SubscriberHandle) DelSubscriberInfo(w http.ResponseWriter, r *http.Request) {
+func (sh *SubscriberHandle) DelSubscriberInfo(cntx context.Context, w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
id := vars["id"]
@@ -200,5 +201,5 @@
w.WriteHeader(http.StatusAccepted)
logger.Warnw(ctx, "northbound-del-service-req", log.Fields{"ServiceName": id})
- go app.GetApplication().DelServiceWithPrefix(id)
+ go app.GetApplication().DelServiceWithPrefix(cntx, id)
}