Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 3 | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package device |
| 18 | |
| 19 | import ( |
| 20 | "context" |
| 21 | |
| 22 | "github.com/gogo/protobuf/proto" |
| 23 | "github.com/golang/protobuf/ptypes" |
| 24 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
| 25 | "github.com/opencord/voltha-protos/v3/go/voltha" |
| 26 | "google.golang.org/grpc/codes" |
| 27 | "google.golang.org/grpc/status" |
| 28 | ) |
| 29 | |
| 30 | func (agent *Agent) downloadImage(ctx context.Context, img *voltha.ImageDownload) (*voltha.OperationResp, error) { |
| 31 | if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil { |
| 32 | return nil, err |
| 33 | } |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 34 | logger.Debugw(ctx, "downloadImage", log.Fields{"device-id": agent.deviceID}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 35 | |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 36 | device := agent.cloneDeviceWithoutLock() |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 37 | if device.AdminState != voltha.AdminState_ENABLED { |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 38 | agent.requestQueue.RequestComplete() |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 39 | return nil, status.Errorf(codes.FailedPrecondition, "device-id:%s, expected-admin-state:%s", agent.deviceID, voltha.AdminState_ENABLED) |
| 40 | } |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 41 | if device.AdminState != voltha.AdminState_ENABLED { |
| 42 | logger.Debugw(ctx, "device-not-enabled", log.Fields{"id": agent.deviceID}) |
| 43 | agent.requestQueue.RequestComplete() |
| 44 | return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, expected-admin-state:%s", agent.deviceID, voltha.AdminState_ENABLED) |
| 45 | } |
| 46 | |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 47 | // Save the image |
| 48 | clonedImg := proto.Clone(img).(*voltha.ImageDownload) |
| 49 | clonedImg.DownloadState = voltha.ImageDownload_DOWNLOAD_REQUESTED |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 50 | cloned := agent.cloneDeviceWithoutLock() |
| 51 | cloned.ImageDownloads = append(device.ImageDownloads, clonedImg) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 52 | |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 53 | cloned.AdminState = voltha.AdminState_DOWNLOADING_IMAGE |
| 54 | if err := agent.updateDeviceAndReleaseLock(ctx, cloned); err != nil { |
| 55 | return nil, err |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 56 | } |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 57 | |
| 58 | // Send the request to the adapter |
Rohan Agrawal | cf12f20 | 2020-08-03 04:42:01 +0000 | [diff] [blame] | 59 | subCtx, cancel := context.WithTimeout(log.WithSpanFromContext(context.Background(), ctx), agent.defaultTimeout) |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 60 | ch, err := agent.adapterProxy.DownloadImage(ctx, cloned, clonedImg) |
| 61 | if err != nil { |
| 62 | cancel() |
| 63 | return nil, err |
| 64 | } |
| 65 | go agent.waitForAdapterResponse(subCtx, cancel, "downloadImage", ch, agent.onSuccess, agent.onFailure) |
| 66 | |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 67 | return &voltha.OperationResp{Code: voltha.OperationResp_OPERATION_SUCCESS}, nil |
| 68 | } |
| 69 | |
| 70 | // isImageRegistered is a helper method to figure out if an image is already registered |
| 71 | func isImageRegistered(img *voltha.ImageDownload, device *voltha.Device) bool { |
| 72 | for _, image := range device.ImageDownloads { |
| 73 | if image.Id == img.Id && image.Name == img.Name { |
| 74 | return true |
| 75 | } |
| 76 | } |
| 77 | return false |
| 78 | } |
| 79 | |
| 80 | func (agent *Agent) cancelImageDownload(ctx context.Context, img *voltha.ImageDownload) (*voltha.OperationResp, error) { |
| 81 | if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil { |
| 82 | return nil, err |
| 83 | } |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 84 | logger.Debugw(ctx, "cancelImageDownload", log.Fields{"device-id": agent.deviceID}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 85 | |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 86 | // Verify whether the Image is in the list of image being downloaded |
Kent Hagerman | cba2f30 | 2020-07-28 13:37:36 -0400 | [diff] [blame] | 87 | device := agent.getDeviceReadOnlyWithoutLock() |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 88 | if !isImageRegistered(img, device) { |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 89 | agent.requestQueue.RequestComplete() |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 90 | return nil, status.Errorf(codes.FailedPrecondition, "device-id:%s, image-not-registered:%s", agent.deviceID, img.Name) |
| 91 | } |
| 92 | |
| 93 | // Update image download state |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 94 | cloned := agent.cloneDeviceWithoutLock() |
| 95 | for _, image := range cloned.ImageDownloads { |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 96 | if image.Id == img.Id && image.Name == img.Name { |
| 97 | image.DownloadState = voltha.ImageDownload_DOWNLOAD_CANCELLED |
| 98 | } |
| 99 | } |
| 100 | |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 101 | if cloned.AdminState != voltha.AdminState_DOWNLOADING_IMAGE { |
| 102 | agent.requestQueue.RequestComplete() |
| 103 | } else { |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 104 | // Set the device to Enabled |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 105 | cloned.AdminState = voltha.AdminState_ENABLED |
| 106 | if err := agent.updateDeviceAndReleaseLock(ctx, cloned); err != nil { |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 107 | return nil, err |
| 108 | } |
Rohan Agrawal | cf12f20 | 2020-08-03 04:42:01 +0000 | [diff] [blame] | 109 | subCtx, cancel := context.WithTimeout(log.WithSpanFromContext(context.Background(), ctx), agent.defaultTimeout) |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 110 | ch, err := agent.adapterProxy.CancelImageDownload(subCtx, cloned, img) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 111 | if err != nil { |
| 112 | cancel() |
| 113 | return nil, err |
| 114 | } |
| 115 | go agent.waitForAdapterResponse(subCtx, cancel, "cancelImageDownload", ch, agent.onSuccess, agent.onFailure) |
| 116 | } |
| 117 | return &voltha.OperationResp{Code: voltha.OperationResp_OPERATION_SUCCESS}, nil |
| 118 | } |
| 119 | |
| 120 | func (agent *Agent) activateImage(ctx context.Context, img *voltha.ImageDownload) (*voltha.OperationResp, error) { |
| 121 | if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil { |
| 122 | return nil, err |
| 123 | } |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 124 | logger.Debugw(ctx, "activateImage", log.Fields{"device-id": agent.deviceID}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 125 | |
| 126 | // Verify whether the Image is in the list of image being downloaded |
Kent Hagerman | cba2f30 | 2020-07-28 13:37:36 -0400 | [diff] [blame] | 127 | device := agent.getDeviceReadOnlyWithoutLock() |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 128 | if !isImageRegistered(img, device) { |
| 129 | agent.requestQueue.RequestComplete() |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 130 | return nil, status.Errorf(codes.FailedPrecondition, "device-id:%s, image-not-registered:%s", agent.deviceID, img.Name) |
| 131 | } |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 132 | if device.AdminState == voltha.AdminState_DOWNLOADING_IMAGE { |
| 133 | agent.requestQueue.RequestComplete() |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 134 | return nil, status.Errorf(codes.FailedPrecondition, "device-id:%s, device-in-downloading-state:%s", agent.deviceID, img.Name) |
| 135 | } |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 136 | |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 137 | // Update image download state |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 138 | cloned := agent.cloneDeviceWithoutLock() |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 139 | for _, image := range cloned.ImageDownloads { |
| 140 | if image.Id == img.Id && image.Name == img.Name { |
| 141 | image.ImageState = voltha.ImageDownload_IMAGE_ACTIVATING |
| 142 | } |
| 143 | } |
| 144 | // Set the device to downloading_image |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 145 | cloned.AdminState = voltha.AdminState_DOWNLOADING_IMAGE |
| 146 | if err := agent.updateDeviceAndReleaseLock(ctx, cloned); err != nil { |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 147 | return nil, err |
| 148 | } |
| 149 | |
Rohan Agrawal | cf12f20 | 2020-08-03 04:42:01 +0000 | [diff] [blame] | 150 | subCtx, cancel := context.WithTimeout(log.WithSpanFromContext(context.Background(), ctx), agent.defaultTimeout) |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 151 | ch, err := agent.adapterProxy.ActivateImageUpdate(subCtx, cloned, img) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 152 | if err != nil { |
| 153 | cancel() |
| 154 | return nil, err |
| 155 | } |
| 156 | go agent.waitForAdapterResponse(subCtx, cancel, "activateImageUpdate", ch, agent.onSuccess, agent.onFailure) |
| 157 | |
| 158 | // The status of the AdminState will be changed following the update_download_status response from the adapter |
| 159 | // The image name will also be removed from the device list |
| 160 | return &voltha.OperationResp{Code: voltha.OperationResp_OPERATION_SUCCESS}, nil |
| 161 | } |
| 162 | |
| 163 | func (agent *Agent) revertImage(ctx context.Context, img *voltha.ImageDownload) (*voltha.OperationResp, error) { |
| 164 | if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil { |
| 165 | return nil, err |
| 166 | } |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 167 | logger.Debugw(ctx, "revertImage", log.Fields{"device-id": agent.deviceID}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 168 | |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 169 | // Verify whether the Image is in the list of image being downloaded |
Kent Hagerman | cba2f30 | 2020-07-28 13:37:36 -0400 | [diff] [blame] | 170 | device := agent.getDeviceReadOnlyWithoutLock() |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 171 | if !isImageRegistered(img, device) { |
| 172 | agent.requestQueue.RequestComplete() |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 173 | return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, image-not-registered:%s", agent.deviceID, img.Name) |
| 174 | } |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 175 | if device.AdminState != voltha.AdminState_ENABLED { |
| 176 | agent.requestQueue.RequestComplete() |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 177 | return nil, status.Errorf(codes.FailedPrecondition, "deviceId:%s, device-not-enabled-state:%s", agent.deviceID, img.Name) |
| 178 | } |
| 179 | // Update image download state |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 180 | cloned := agent.cloneDeviceWithoutLock() |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 181 | for _, image := range cloned.ImageDownloads { |
| 182 | if image.Id == img.Id && image.Name == img.Name { |
| 183 | image.ImageState = voltha.ImageDownload_IMAGE_REVERTING |
| 184 | } |
| 185 | } |
| 186 | |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 187 | if err := agent.updateDeviceAndReleaseLock(ctx, cloned); err != nil { |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 188 | return nil, err |
| 189 | } |
| 190 | |
Rohan Agrawal | cf12f20 | 2020-08-03 04:42:01 +0000 | [diff] [blame] | 191 | subCtx, cancel := context.WithTimeout(log.WithSpanFromContext(context.Background(), ctx), agent.defaultTimeout) |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 192 | ch, err := agent.adapterProxy.RevertImageUpdate(subCtx, cloned, img) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 193 | if err != nil { |
| 194 | cancel() |
| 195 | return nil, err |
| 196 | } |
| 197 | go agent.waitForAdapterResponse(subCtx, cancel, "revertImageUpdate", ch, agent.onSuccess, agent.onFailure) |
| 198 | |
| 199 | return &voltha.OperationResp{Code: voltha.OperationResp_OPERATION_SUCCESS}, nil |
| 200 | } |
| 201 | |
| 202 | func (agent *Agent) getImageDownloadStatus(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 203 | logger.Debugw(ctx, "getImageDownloadStatus", log.Fields{"device-id": agent.deviceID}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 204 | |
| 205 | if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil { |
| 206 | return nil, err |
| 207 | } |
Kent Hagerman | cba2f30 | 2020-07-28 13:37:36 -0400 | [diff] [blame] | 208 | device := agent.getDeviceReadOnlyWithoutLock() |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 209 | ch, err := agent.adapterProxy.GetImageDownloadStatus(ctx, device, img) |
| 210 | agent.requestQueue.RequestComplete() |
| 211 | if err != nil { |
| 212 | return nil, err |
| 213 | } |
| 214 | // Wait for the adapter response |
| 215 | rpcResponse, ok := <-ch |
| 216 | if !ok { |
| 217 | return nil, status.Errorf(codes.Aborted, "channel-closed-device-id-%s", agent.deviceID) |
| 218 | } |
| 219 | if rpcResponse.Err != nil { |
| 220 | return nil, rpcResponse.Err |
| 221 | } |
| 222 | // Successful response |
| 223 | imgDownload := &voltha.ImageDownload{} |
| 224 | if err := ptypes.UnmarshalAny(rpcResponse.Reply, imgDownload); err != nil { |
| 225 | return nil, status.Errorf(codes.InvalidArgument, "%s", err.Error()) |
| 226 | } |
| 227 | return imgDownload, nil |
| 228 | } |
| 229 | |
| 230 | func (agent *Agent) updateImageDownload(ctx context.Context, img *voltha.ImageDownload) error { |
| 231 | if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil { |
| 232 | return err |
| 233 | } |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 234 | logger.Debugw(ctx, "updating-image-download", log.Fields{"device-id": agent.deviceID, "img": img}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 235 | |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 236 | // Update the image as well as remove it if the download was cancelled |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 237 | cloned := agent.cloneDeviceWithoutLock() |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 238 | clonedImages := make([]*voltha.ImageDownload, len(cloned.ImageDownloads)) |
| 239 | for _, image := range cloned.ImageDownloads { |
| 240 | if image.Id == img.Id && image.Name == img.Name { |
| 241 | if image.DownloadState != voltha.ImageDownload_DOWNLOAD_CANCELLED { |
| 242 | clonedImages = append(clonedImages, img) |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | cloned.ImageDownloads = clonedImages |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 247 | |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 248 | // Set the Admin state to enabled if required |
| 249 | if (img.DownloadState != voltha.ImageDownload_DOWNLOAD_REQUESTED && |
| 250 | img.DownloadState != voltha.ImageDownload_DOWNLOAD_STARTED) || |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 251 | img.ImageState != voltha.ImageDownload_IMAGE_ACTIVATING { |
| 252 | cloned.AdminState = voltha.AdminState_ENABLED |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 253 | } |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 254 | return agent.updateDeviceAndReleaseLock(ctx, cloned) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | func (agent *Agent) getImageDownload(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 258 | logger.Debugw(ctx, "getImageDownload", log.Fields{"device-id": agent.deviceID}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 259 | |
Kent Hagerman | cba2f30 | 2020-07-28 13:37:36 -0400 | [diff] [blame] | 260 | device, err := agent.getDeviceReadOnly(ctx) |
| 261 | if err != nil { |
| 262 | return nil, status.Errorf(codes.Aborted, "%s", err) |
| 263 | } |
Kent Hagerman | f6db9f1 | 2020-07-22 17:16:19 -0400 | [diff] [blame] | 264 | for _, image := range device.ImageDownloads { |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 265 | if image.Id == img.Id && image.Name == img.Name { |
| 266 | return image, nil |
| 267 | } |
| 268 | } |
| 269 | return nil, status.Errorf(codes.NotFound, "image-not-found:%s", img.Name) |
| 270 | } |
| 271 | |
| 272 | func (agent *Agent) listImageDownloads(ctx context.Context, deviceID string) (*voltha.ImageDownloads, error) { |
Rohan Agrawal | 31f2180 | 2020-06-12 05:38:46 +0000 | [diff] [blame] | 273 | logger.Debugw(ctx, "listImageDownloads", log.Fields{"device-id": agent.deviceID}) |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 274 | |
Kent Hagerman | cba2f30 | 2020-07-28 13:37:36 -0400 | [diff] [blame] | 275 | device, err := agent.getDeviceReadOnly(ctx) |
| 276 | if err != nil { |
| 277 | return nil, status.Errorf(codes.Aborted, "%s", err) |
| 278 | } |
| 279 | return &voltha.ImageDownloads{Items: device.ImageDownloads}, nil |
Mahir Gunyel | fa6ea27 | 2020-06-10 17:03:51 -0700 | [diff] [blame] | 280 | } |