[VOL-4814] Adding Rest interfaces for flow and subscribers
Change-Id: I7da50b14e7600884a8b38c37b63704241942d8af
diff --git a/internal/pkg/controller/controller.go b/internal/pkg/controller/controller.go
index f08f7e1..eb48c28 100644
--- a/internal/pkg/controller/controller.go
+++ b/internal/pkg/controller/controller.go
@@ -521,3 +521,44 @@
_, ifPresent := v.BlockedDeviceList.Get(deviceSerialNumber)
return ifPresent
}
+
+// GetFlows returns flow specific to device and flowID
+func (v *VoltController) GetFlow(deviceID string, cookie uint64) (*of.VoltSubFlow, error) {
+ d, err := v.GetDevice(deviceID)
+ if err != nil {
+ logger.Errorw(ctx, "Device Not Found", log.Fields{"Device": deviceID, "Error": err})
+ return nil, err
+ }
+ if flow, ok := d.GetFlow(cookie); ok {
+ return flow, nil
+ }
+ return nil, nil
+}
+
+// GetFlows returns list of flows for a particular device
+func (v *VoltController) GetFlows(deviceID string) ([]*of.VoltSubFlow, error) {
+ d, err := v.GetDevice(deviceID)
+ if err != nil {
+ logger.Errorw(ctx, "Device Not Found", log.Fields{"Device": deviceID, "Error": err})
+ return nil, err
+ }
+ return d.GetAllFlows(), nil
+}
+
+// GetAllFlows returns list of all flows
+func (v *VoltController) GetAllFlows() ([]*of.VoltSubFlow, error) {
+ var flows []*of.VoltSubFlow
+ for _, d := range v.devices {
+ flows = append(flows, d.GetAllFlows()...)
+ }
+ return flows, nil
+}
+
+// GetAllPendingFlows returns list of all flows
+func (v *VoltController) GetAllPendingFlows() ([]*of.VoltSubFlow, error) {
+ var flows []*of.VoltSubFlow
+ for _, d := range v.devices {
+ flows = append(flows, d.GetAllPendingFlows()...)
+ }
+ return flows, nil
+}