[VOL-4814] Adding Rest interfaces for flow and subscribers
Change-Id: I7da50b14e7600884a8b38c37b63704241942d8af
diff --git a/internal/pkg/controller/device.go b/internal/pkg/controller/device.go
index b410490..d60855a 100644
--- a/internal/pkg/controller/device.go
+++ b/internal/pkg/controller/device.go
@@ -176,6 +176,32 @@
return flow, ok
}
+// GetAllFlows - Get the flow from device obj
+func (d *Device) GetAllFlows() ([]*of.VoltSubFlow) {
+ d.flowLock.RLock()
+ defer d.flowLock.RUnlock()
+ var flows []*of.VoltSubFlow
+ logger.Infow(ctx, "Get All Flows", log.Fields{"deviceID": d.ID})
+ for _, f := range d.flows {
+ flows = append(flows, f)
+ }
+ return flows
+}
+
+// GetAllPendingFlows - Get the flow from device obj
+func (d *Device) GetAllPendingFlows() ([]*of.VoltSubFlow) {
+ d.flowLock.RLock()
+ defer d.flowLock.RUnlock()
+ var flows []*of.VoltSubFlow
+ logger.Infow(ctx, "Get All Pending Flows", log.Fields{"deviceID": d.ID})
+ for _, f := range d.flows {
+ if f.State == of.FlowAddPending {
+ flows = append(flows, f)
+ }
+ }
+ return flows
+}
+
// AddFlow - Adds the flow to the device and also to the database
func (d *Device) AddFlow(cntx context.Context, flow *of.VoltSubFlow) error {
d.flowLock.Lock()