[VOL-1890] Flow decomposition fails after a core switch over
Cherry Pick into the master branch from voltha-2.1
Change-Id: I84c3a83b5b9115d6ec334af29634486ba7148634
diff --git a/rw_core/graph/device_graph.go b/rw_core/graph/device_graph.go
index ec6f8d2..357a709 100644
--- a/rw_core/graph/device_graph.go
+++ b/rw_core/graph/device_graph.go
@@ -210,6 +210,25 @@
return nil
}
+func (dg *DeviceGraph) IsUpToDate(ld *voltha.LogicalDevice) bool {
+ if ld != nil {
+ if len(dg.boundaryPorts) != len(ld.Ports) {
+ return false
+ }
+ var portId string
+ var val uint32
+ var exist bool
+ for _, lp := range ld.Ports {
+ portId = concatDeviceIdPortId(lp.DeviceId, lp.DevicePortNo)
+ if val, exist = dg.boundaryPorts[portId]; !exist || val != lp.OfpPort.PortNo {
+ return false
+ }
+ }
+ return true
+ }
+ return len(dg.boundaryPorts) == 0
+}
+
//getDevice returns the device either from the local cache (default) or from the model.
//TODO: Set a cache timeout such that we do not use invalid data. The full device lifecycle should also
//be taken in consideration