flow provision status api fix
Change-Id: If40b2a1ab6a87e1857d9ad6dc27034b0f99fcab0
diff --git a/internal/pkg/application/service.go b/internal/pkg/application/service.go
index ebbeef0..532ff62 100644
--- a/internal/pkg/application/service.go
+++ b/internal/pkg/application/service.go
@@ -2047,34 +2047,30 @@
}
// GetFlowProvisionStatus to get status of the subscriber and flow provisioned in controller
-func (va *VoltApplication) GetFlowProvisionStatus(cntx context.Context, portNo string) FlowProvisionStatus {
+func (va *VoltApplication) GetFlowProvisionStatus(portNo string) FlowProvisionStatus {
logger.Infow(ctx, "GetFlowProvisionStatus Request ", log.Fields{"Port": portNo})
flowProvisionStatus := FlowProvisionStatus{}
- serviceCount := 0
+ flowProvisionStatus.FlowProvisionStatus = SUBSCRIBER_NOT_IN_CONTROLLER
va.ServiceByName.Range(func(key, value interface{}) bool {
vs := value.(*VoltService)
logger.Debugw(ctx, "Volt Service ", log.Fields{"VS": vs})
- serviceCount++
- if len(portNo) > 0 {
- if portNo == vs.Port {
- if vs.DsHSIAFlowsApplied && vs.UsHSIAFlowsApplied && vs.LenOfPendingFlows() == 0 {
- flowProvisionStatus.FlowProvisionStatus = ALL_FLOWS_PROVISIONED
- } else if !vs.IsActivated {
- flowProvisionStatus.FlowProvisionStatus = SUBSCRIBER_DISABLED_IN_CONTROLLER
- } else if !vs.DsHSIAFlowsApplied && !vs.UsHSIAFlowsApplied {
- flowProvisionStatus.FlowProvisionStatus = NO_FLOWS_PROVISIONED
- } else if vs.LenOfPendingFlows() > 0 {
- flowProvisionStatus.FlowProvisionStatus = FLOWS_PROVISIONED_PARTIALLY
- }
- } else {
- flowProvisionStatus.FlowProvisionStatus = SUBSCRIBER_NOT_IN_CONTROLLER
+ if portNo == vs.Port {
+ if vs.DsHSIAFlowsApplied && vs.UsHSIAFlowsApplied && vs.LenOfPendingFlows() == 0 {
+ flowProvisionStatus.FlowProvisionStatus = ALL_FLOWS_PROVISIONED
+ return false
+ } else if !vs.IsActivated {
+ flowProvisionStatus.FlowProvisionStatus = SUBSCRIBER_DISABLED_IN_CONTROLLER
+ return false
+ } else if !vs.DsHSIAFlowsApplied && !vs.UsHSIAFlowsApplied {
+ flowProvisionStatus.FlowProvisionStatus = NO_FLOWS_PROVISIONED
+ return false
+ } else if vs.LenOfPendingFlows() > 0 {
+ flowProvisionStatus.FlowProvisionStatus = FLOWS_PROVISIONED_PARTIALLY
+ return false
}
}
return true
})
- if serviceCount == 0 {
- flowProvisionStatus.FlowProvisionStatus = SUBSCRIBER_NOT_IN_CONTROLLER
- }
return flowProvisionStatus
}
diff --git a/voltha-go-controller/nbi/subscriber.go b/voltha-go-controller/nbi/subscriber.go
index bf09450..0accabd 100644
--- a/voltha-go-controller/nbi/subscriber.go
+++ b/voltha-go-controller/nbi/subscriber.go
@@ -302,7 +302,7 @@
vars := mux.Vars(r)
portName := vars["portName"]
logger.Debugw(ctx, "Received-northbound-GetSubscriberProvisionStatus-request", log.Fields{"req": portName})
- flowProvisionStatus := app.GetApplication().GetFlowProvisionStatus(cntx, portName)
+ flowProvisionStatus := app.GetApplication().GetFlowProvisionStatus(portName)
flowProvisionStatusRes, err := json.Marshal(flowProvisionStatus)
if err != nil {
logger.Errorw(ctx, "Error occurred while marshaling flowProvisionStatus response", log.Fields{"Error": err})