[VOL-1825] Implemetation of the reconcile feature in the Core
This commit implements the reconcile feature in the Core as
well as the necessary changes in the GO libraries. Changes were
also made in the simulated OLT and ONU adapters to react to a
reconcile request following an adapter restart. These changes
were tested in a 1-node deployment (1 core pair) and 3-nodes
deployment (3 core-pairs but single adapter instances). Test
was also done using the openolt to ensure the reconcile request
does not cause panic in the Core or Openolt since the reconcile
feature is not implemented in Openolt.
Change-Id: I178d619fbcfcc6caa0ee3abfd70fc03c384c5fea
diff --git a/adapters/simulated_onu/adaptercore/device_handler.go b/adapters/simulated_onu/adaptercore/device_handler.go
index 908fdd5..f0ed677 100644
--- a/adapters/simulated_onu/adaptercore/device_handler.go
+++ b/adapters/simulated_onu/adaptercore/device_handler.go
@@ -302,3 +302,17 @@
// For now we do nothing with it
return
}
+
+func (dh *DeviceHandler) ReconcileDevice(device *voltha.Device) {
+ // Update the device info
+ cloned := proto.Clone(device).(*voltha.Device)
+ cloned.ConnectStatus = voltha.ConnectStatus_REACHABLE
+ cloned.OperStatus = voltha.OperStatus_ACTIVE
+
+ dh.device = cloned
+
+ // Update the device state
+ if err := dh.coreProxy.DeviceStateUpdate(nil, cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+ log.Errorw("error-creating-nni-port", log.Fields{"deviceId": device.Id, "error": err})
+ }
+}
diff --git a/adapters/simulated_onu/adaptercore/simulated_onu.go b/adapters/simulated_onu/adaptercore/simulated_onu.go
index 02448f5..142c9c9 100644
--- a/adapters/simulated_onu/adaptercore/simulated_onu.go
+++ b/adapters/simulated_onu/adaptercore/simulated_onu.go
@@ -149,7 +149,21 @@
}
func (so *SimulatedONU) Reconcile_device(device *voltha.Device) error {
- return errors.New("UnImplemented")
+ if device == nil {
+ log.Warn("device-is-nil")
+ return errors.New("nil-device")
+ }
+ log.Infow("reconcile-device", log.Fields{"deviceId": device.Id})
+ var handler *DeviceHandler
+ handler = so.getDeviceHandler(device.Id)
+ if handler == nil {
+ // Adapter has restarted
+ handler = NewDeviceHandler(so.coreProxy, device, so)
+ so.addDeviceHandlerToMap(handler)
+ }
+ go handler.ReconcileDevice(device)
+
+ return nil
}
func (so *SimulatedONU) Abandon_device(device *voltha.Device) error {