[VOL-3756] openonu-adapter-go: Allow reception of OMCI messages via inter-adapter messageType 'OmciResponse' and smaller changes for OnuSwUpgrade preparation
Change-Id: I7392360cd95f07bd6de5b6c4f3decb7a7d878fa2
diff --git a/internal/pkg/onuadaptercore/openonu.go b/internal/pkg/onuadaptercore/openonu.go
index c75dc97..6ab0f78 100644
--- a/internal/pkg/onuadaptercore/openonu.go
+++ b/internal/pkg/onuadaptercore/openonu.go
@@ -449,7 +449,7 @@
return errors.New("unImplemented")
}
-//Download_image according to download image indications as given in apRequest
+//Download_image requests downloading some image according to indications as given in apRequest
func (oo *OpenONUAC) Download_image(ctx context.Context, device *voltha.Device, apRequest *voltha.ImageDownload) (*voltha.ImageDownload, error) {
if !oo.pDownloadManager.imageExists(ctx, apRequest) {
logger.Debugw(ctx, "start image download", log.Fields{"image-description": apRequest})
@@ -459,6 +459,7 @@
return apRequest, err
}
// image already exists
+ logger.Debugw(ctx, "image already downloaded", log.Fields{"image-description": apRequest})
return apRequest, nil
}
@@ -472,14 +473,21 @@
return nil, errors.New("unImplemented")
}
-//Activate_image_update unimplemented
+//Activate_image_update requests downloading some Onu Software image to the INU via OMCI
+// according to indications as given in apRequest and on success activate the image on the ONU
func (oo *OpenONUAC) Activate_image_update(ctx context.Context, device *voltha.Device, apRequest *voltha.ImageDownload) (*voltha.ImageDownload, error) {
- if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil {
- err := handler.doOnuSwUpgrade(ctx, apRequest)
- return apRequest, err
+ if oo.pDownloadManager.imageExists(ctx, apRequest) {
+ if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil {
+ logger.Debugw(ctx, "image download on omci requested", log.Fields{
+ "image-description": apRequest, "device-id": device.Id})
+ err := handler.doOnuSwUpgrade(ctx, apRequest)
+ return apRequest, err
+ }
+ logger.Warnw(ctx, "no handler found for image activation", log.Fields{"device-id": device.Id})
+ return apRequest, fmt.Errorf(fmt.Sprintf("handler-not-found - device-id: %s", device.Id))
}
- logger.Warnw(ctx, "no handler found for Onu image activation", log.Fields{"device-id": device.Id})
- return apRequest, fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
+ logger.Debugw(ctx, "image not yet downloaded on activate request", log.Fields{"image-description": apRequest})
+ return apRequest, fmt.Errorf(fmt.Sprintf("image-not-yet-downloaded - device-id: %s", device.Id))
}
//Revert_image_update unimplemented